A gcc-cris bug?
Graham Stott
graham.stott@btinternet.com
Wed Oct 6 19:25:00 GMT 2004
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.
>
> I'm sure you're along the right lines here, but notice that in the
> original source code I posted, the "foo=0" assignment wasn't moved out of
> the loop: it was right there in the middle:
I don't have your testcase anymore
>
Graham
More information about the Gcc
mailing list