This is the mail archive of the libc-alpha@sources.redhat.com 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: mktime.c fixes (part 4 of 6): verify assumptions at compile-time


On Wed, 31 Dec 2003, Paul Eggert wrote:

> OK, but GCC 3.3.2 doesn't optimize this closely-related version:
> 
>   int f (int a) { int b = 2 * a; return b / 2; }
> 
> even though it is semantically equivalent.  This latter example is
> more typical of code in programs that attempt to detect signed integer
> overflow, since they typically save intermediate results in
> temporaries for later checking.  As long as GCC happens to not
> optimize such programs we'll be OK; but things are clearly dicey.

Hopefully tree-ssa will fix the bug that one gets optimized but not the
other (or at least facilitate its fixing).

> With the exception of the (now-disabled) GCC 2.2.2 optimization, GCC's
> optimizations in this area haven't broken any real programs that I
> know of.  Conversely, I don't expect that they have improved
> performance all that much in real code, as not too many people write
> "(2 * a) / 2", even after macro expansion.

Performance improvements are more likely in loop optimizations (a signed
integer loop variable can't wrap around), and there is a reference to
flag_wrapv in the loop code.

-- 
Joseph S. Myers
jsm@polyomino.org.uk


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