This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] Lno branch merge part 8 -- canonical induction variable creation
Hello,
> 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.
the various bit being? I must admit that on various places in loop
optimizer we break this assumption in just about every possible way,
and I have never seen a problem with it.
> 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.
Thinking about it, on this particular place the variable should
always be unsigned (since we count # of iterations always as unsigned,
from obvious reasons).
I will add a comment about it.
Zdenek