Bug in 2.8.1 / egcs MIPS compilers in asm statements when hi/lo clobbered
Jeffrey A Law
law@cygnus.com
Sat Oct 31 04:38:00 GMT 1998
> The (cut down as an example) code at the end of this message causes the
> MIPS versions of gcc 2.8.1 (and earlier) and the egcs compilers to give
> the error message
>
> TEST.C: In function `z':
> TEST.C:10: fixed or forbidden register was spilled.
> This may be due to a compiler bug or to impossible asm
> statements or clauses.
>
> This seems to be due to "hi" and "lo" in the clobbered register list. The
> problem is that if this is compiled with -O2 without "hi" and "lo" in the
> clobbered list then the code gets rearranged so that the result of f *= b
> is destroyed by the mult in the asm statement before it is read from the
> "lo" register.
>
> Thanks
> --
> Martin E:martin@snsys.com T:+44 117 929 9733 F:+44 117 929 9251
>
>
> int a, b, c, d, e, f;
>
> z()
> {
> d *= e;
> e *= f;
> asm ("mult %1,%2; mflo %0":"=r"(a):"r"(b),"r"(c):"lo","hi");
> f *= b;
> }
For a variety of reasons it is unsafe to mention hi/lo in the clobber
list on mips targets. This is true for all currently released gcc compilers.
However, this problem has been addressed in the current egcs development
sources and your code compiles correctly as far as I can tell:
lw $5,d
lw $4,e
mult $5,$4
mflo $5
lw $3,f
mult $4,$3
mflo $4
lw $2,b
mult $3,$2
mflo $3
lw $6,c
#APP
mult $2,$6; mflo $2
#NO_APP
sw $2,a
sw $5,d
sw $4,e
sw $3,f
j $31
--
Jeff Law (law@cygnus.com)
Cygnus Solutions EGCS GNU Compiler System
http://www.cygnus.com http://www.cygnus.com/egcs
More information about the Gcc-bugs
mailing list