[Bug c/13591] loop unrolling creates incorrect code with inline asm
Richard Sandiford
rsandifo@redhat.com
Tue Jan 6 23:10:00 GMT 2004
"shay_gal-on at pmc-sierra dot com" <gcc-bugzilla@gcc.gnu.org> writes:
> Sorry about the typo.
> I get the same result when changing $4 to %4 [...]
BTW, like I say, changing $4 to %4 isn't enough:
I assume it's supposed to be %4 instead, but that's not well-formed
either (%4 is an input only).
I.e., even after changing $4 to %4, the asm still isn't valid. You're
trying to modify p0, or at least the register that holds p0, without
telling gcc about it. The asm statement should list p0 as both an
input and an output.
Put it another way: with the asm as it is now, gcc sees something which
reads p0 (a loop invariant) and which writes to a0-3. Since a0-3 aren't
used in the loop, there's no reason not to hoist it.
If you make p0 an input and an output, gcc will realise that the asm
does something different each time round.
[ Actually, if this is just a cache preload sequence, the "m" thing
is probably a red herring. But in that case, the asm is only really
being executed for its side effects, not its results, so you should
probably make it "volatile" instead. You could then get rid of the
dummy() function.
Note that making the asm volatile would probably hide the problem
you're seeing (in other words, you'd probably get away with having p0
be an input only). It'd still be wrong though: p0 really should be
both an input and an output. ]
Richard
More information about the Gcc-bugs
mailing list