This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: IVOPT improvement patch
On Sat, May 29, 2010 at 8:22 AM, Zdenek Dvorak <rakdver@kam.mff.cuni.cz> wrote:
> 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.
Thanks,
David
>
> Zdenek
>