Scev analysing number of loop iterations returns (2^32-1) instead of -1

Richard Guenther richard.guenther@gmail.com
Wed Oct 7 14:52:00 GMT 2009


On Wed, Oct 7, 2009 at 4:37 PM, Tobias Grosser
<grosser@fim.uni-passau.de> wrote:
> I try to analyse this code:
> ------------------------------------------------------
> int foo (int N)
> {
>  int ftab[257];
>  int i, j;
>
>  for (i = 0; i < N  - 7488645; i++)
>    j = ftab [i];
>
>  return j;
> }
> ------------------------------------------------------
>
> The number of iterations I get is:
>
> (unsigned int) N_5(D) + 0x0ffffffff
>
> However I expect it to be
>
> (unsigned int) N_5(D) + (-1)

No, that would be (unsigned int) (N_5(D) + -1) instead.

It's fold that canonicalizes this to the above form - you
simply have to deal with it (unsigned arithmetic, that is).

Richard.



More information about the Gcc mailing list