bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GCC optimizes integer overflow: bug or feature?


From: Zdenek Dvorak
Subject: Re: GCC optimizes integer overflow: bug or feature?
Date: Tue, 19 Dec 2006 12:41:04 +0100
User-agent: Mutt/1.5.9i

Hello,

> >Now, if your argument is that following the LIA-1 standard will prevent 
> >optimizations that could otherwise be made if one followed only the C 
> >standard, that's a reasonable argument, but it should not be couched as 
> >if it implies that preventing the optimizations would not be following 
> >the C standard.
> 
> I continue to suspect that the gains from this optimization are minimal
> to non-existent in practice.

the majority of loop optimizations work only assuming that induction
variables do not overflow.  This assumption can sometimes be verified
using quite expensive analyses of the loop code, or in majority of cases
easily derived if the induction variables are either signed or pointers
(where the standard allows us to assume that the arithmetics does not
overflow).

Note that there was even a serious discussion about enabling
-funsafe-loop-optimizations by default at some optimization level, thus
making us assert that *no* induction variables (regardless of
signedness) overflow; which IIRC is what some other compilers do.

IMHO, using loops relying on the behavior of overflow of an
induction variable (*) is an ugly hack and whoever writes such a code
does not deserve for his program to work.

Zdenek

(*) especially without bothering to verify what the language standard
says about that




reply via email to

[Prev in Thread] Current Thread [Next in Thread]