PATCH RFC: Change some tree-ssa-operands fields to unsigned

Andrew MacLeod amacleod@redhat.com
Fri Jan 19 13:52:00 GMT 2007


On Thu, 2007-01-18 at 21:00 -0800, Ian Lance Taylor wrote:
> tree-ssa-operand.h has macros with code like this:
>     gcc_assert ((X) >= 0 && (X) < VUSE_VECT_NUM_ELEM (V)),
> These are often used in loops.  In a loop VRP can often eliminate the
> (X) >= 0 test.  However, when VRP does this, it is relying on
> undefined signed overflow: it is assuming that the loop will not wrap.
> This generates extra warnings with a warning I am working on for cases
> where gcc optimizers rely on undefined signed overflow.
> 
> I would like to hear any comments on this patch.  This eliminates the
> warnings by changing the relevant fields and variables to unsigned.
> In essence I am eliminating the (X) >= 0 part of the condition in the
> code rather than having the compiler eliminate it.
> 
> If I don't hear any comments in a couple of days, I plan to check this
> in.

Check it in :-)

All that code is really doing is making sure in the index variable is
within the correct range for the array, and those checks are only in
place with checking enabled anyway.

Probably should have been unsigned in the first place, but I never
bothered going back and changing it because it never seemed to matter.
I'm guilty of that from time to time :-)

Andrew



More information about the Gcc-patches mailing list