[CFG] Loop unrolling

Zdenek Dvorak rakdver@atrey.karlin.mff.cuni.cz
Thu Feb 28 05:39:00 GMT 2002


Hello.

> > > > > I feel bit unconfortable to check in the code that is known to produce invalid
> > > > > results even th te devel branch.
> > > > 
> > > > It should be correct in all useful cases. If someone relies on how program
> > > > behave when counter overflows, he deserve his program not to work :-) But
> > > > you're probably right with this.
> > > 
> > > Well, thats the matter of opinion. C stanrad specifies the overflow behaviour
> > > on unisgned arithmetics, so it is perfectly correct to make unsigned loops
> > > overflow and sometimes it even makes sense (when you need to iterate 2^32 times).
> > 
> > IMHO standard doesn't specify sizeof(int), so using it this way is not too
> > reliable.  Also I do not optimize loops that use unsigned comparison in their
> > exit condition at all now, exactly to avoid these problems. Unfortunately,
> > if someone tests for equality and uses overflow, I may run into problems.
> > I will look to it.
> No, you can't rely on signedness of comparison. One can simply use insigned
> counter and retype it to int.

And unless it is specified what happens if you retype value out of size of int
(which probably isn't), I may do whatever I want.

Zdenek



More information about the Gcc-patches mailing list