A gcc-cris bug?
Paolo Bonzini
bonzini@gnu.org
Thu Oct 7 10:33:00 GMT 2004
Graham Stott wrote:
> All,
>
>
>>>One problem is the insn "foo = 0" gets moved after the loop
>>>end because
>>>loop optimize determines that it's loop invariant but isn't checking
>>>if the insn would modify the loop termination condition.
>
> Actually this isn't a problem because the loop optimizer does notice
> that the loop termination condition has been modified.
>
> int main()
> {
> int foo = 100;
> int i;
>
> for (i = A; i < foo; i++)
> foo = B;
> }
>
> When B > A the loop iterates the correct # of times which is B - A + 1,
> infact the whole loop gets optimized away :-). But when B <= A we end up
> with a decrement-until-zero loop starting at B-A which for some reason
> doesn't get optimized away.
Optimizing away the loop may only paper over the problem. What happens
if you add a "if (i != B + 1) abort ();", in the various cases?
I'm sending a patch shortly.
Paolo
More information about the Gcc
mailing list