[PATCH] Sign extend before converting constants to GMP values.

Sebastian Pop sebpop@gmail.com
Thu Jun 30 16:35:00 GMT 2011


On Thu, Jun 30, 2011 at 10:03, Richard Guenther <rguenther@suse.de> wrote:
> But what do you do for
>
>  for (unsigned char i = 128; i < 255; ++i)
>
> ?  You change 128 to -128 which is wrong.

Yes, 128 gets translated to -128.
And 255 gets translated to -1.
And so the loop iteration domain gets translated in the polyhedral form
as going from -128 to -1 with strides of 1.
So this particular program is not miscompiled by graphite:

int main ()
{
  unsigned char j;
  int x[300];
  for (j = 128; j < 255; j++)
    x[j] = j;

  for (j = 128; j < 255; j++)
    if (x[j] != j)
      __builtin_abort ();

  return 0;
}

I was trying to build a program that fails to attach to the PR.

> So yes, you also have to
> deal with modulo arithmetic in graphite.

I'm trying to understand where we have to deal with the modulo arithmetic.
Tobias, what are you doing in Polly?
Do you insert the loop iteration domain constraints with the modulo
of the types?

Sebastian



More information about the Gcc-patches mailing list