This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v2.0] Use saturated arithmetic for overflow detection.


On Fri, Nov 01, 2013 at 04:48:38PM +0000, Joseph S. Myers wrote:
> On Fri, 1 Nov 2013, Ondrej Bilka wrote:
> 
> > This version adds saturated arithmetic support with optimized x86_64
> > version.
> 
> I consider such an x86_64 version to be premature optimization without 
> clear benchmark results (speed or code size) to justify it.  It would not 
> surprise me if use of the overflow flag is slow in some cases and straight 
> comparisons would be faster.  And using these asm versions prevents the 
> compiler from optimizing based on constant arguments.
> 
> In my view, we shouldn't optimize this with inline asm at all.  For any 
> optimizations, work on getting appropriate built-in functions into GCC 
> (making sure that they do get optimized there based on constant arguments, 
> so that the overflow flag is used only when it's the most efficient 
> approach) and then use those functions in glibc (architecture-independent 
> file) conditional on the GCC version.
> 
I could omit assembly optimizations but then do not argue about
performance impact. As results are used in malloc which is around
hundred times slower than performance lost effect is small. If function
allocates memory in two places then you should merge these allocations
into one which has better performance gain/added complexity ratio.

 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]