IVOPT improvement patch

Zdenek Dvorak rakdver@kam.mff.cuni.cz
Sat May 29 20:18:00 GMT 2010


Hi,

> >> > Also, note that for loops with one exit, your change actually makes the test weaker.
> >> > For instance, before your change, we could deduce that
> >> >
> >> > int a[100];
> >> > for (i = 0; i < n; i++)
> >> >  a[i] = i;
> >> >
> >> > iterates at most 100 times.
> >>
> >> Fixed and added two test cases.
> >>
> >> (Note -- one more bug in the original code was found and fixed -- the
> >> period computation is wrong when step is not power of 2).
> >
> > that is wrong, the original computation is correct.  If step is (e.g.) odd,
> > then it takes (range of type) iterations before the variable achieves the same
> > value (that it overflows in the meantime several times does not matter, since
> > we are careful to use the type in that overflow has defined semantics, and
> > we test for equality in the replacement condition),
> 
> The overflow semantics is indeed different -- it is also true for any
> iv cand with non zero base. The period is really LCM (type_range,
> step)/step - 1 --- the computation in original code matches this --
> but the comment seems wrong.

yes, the comment needs to be fixed,

Zdenek



More information about the Gcc-patches mailing list