[gomp] Fix degenerate omp for loops (PR libgomp/29949)

Jakub Jelinek jakub@redhat.com
Sat Dec 2 07:35:00 GMT 2006


On Sat, Dec 02, 2006 at 12:23:06AM +0100, Zdenek Dvorak wrote:
> > >Lastly, the compiler expanded loops (static without chunk size, static with
> > >chunk size) failed because the arithmetics to compute range given to the
> > >current thread was mostly done in unsigned long and thus when N2 - N1
> > >was negative (for positive STEP resp. positive for negative STEP), we ended
> > >up with a huge range.  I tried to figure out why this was cast to utype,
> > >but haven't found why it has been written that way.
> 
> I think that not casting to unsigned type might give wrong results for
> loops like
> 
> for (i = -many; i < many; i++)
> 
> ie. in cases the number of iterations does not fit in the signed type.
> 
> (sorry if I understand the situation wrong, I did not really check the
> code whether this is the case or not, it just seems to be one possible
> reason why we want to compute these things in unsigned type).

Guess you are right, in which case I'm afraid I need to revokethe omp-low.c
part of my patch and instead add an additional comparison and conditional
jump to the code I'm afraid.

	Jakub



More information about the Gcc-patches mailing list