This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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] Lno branch merge part 8 -- canonical induction variable creation


On Fri, Aug 06, 2004 at 10:54:54AM +0200, Zdenek Dvorak wrote:
> > I don't see anything in canonicalize_loop_induction_variables
> > that ensures that this addition doesn't overflow.  If TYPE is
> > unsigned I guess it doesn't matter -- with the predecrement
> > and EQ_EXPR we can iterate 2**32 times with a 32-bit variable.
> > But other parts of the compiler are going to do the wrong thing
> > if TYPE is signed.
> 
> Even in signed type it works exactly the same way.

Overflow of signed types invokes undefined behaviour, and so
various bits of the compiler assume that it can't happen.

You've just broken that assumption.

You should probably force your new induction variable to be
unsigned; you don't gain much from preserving the original
type you've detected the iteration count from.


r~


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