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] Fix optimization regression in constant folder


> negative values can be represented in unsigned types just fine, it's just 
> a matter of interpreting it correctly.

I suppose, though the idea of purposely putting a negative value in an
unsigned type because we know that overflow will do the right thing seems
dubious to me.

> Okay, so conceptually it's like:
> 
> struct S {
>   int a1[n1*n2];
>   int a2[n2*n1];
>   int a3[n3];
> } s;  /* so a1 and a2 have the same number of elements */
> 
> And then you access this in e.g. such way:
> 
> for (i = start; i <= end; i++)
>   use (s.a1[i], s.a2[i+2], s.a3[i]);

Somewhat, though a more common case is when you have multiple arrays
that are of the same size (though usually different component sizes)
and the index in each of them is the same value (sounds contrived, but
this happens in Ada discriminated records all the time).  So you know
that the computations for any offset must be a*i+b, for some A and B,
but getting there from the expressions you actually have can be tricky.


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