Bug with PPC 32-bit inline assembler [4.1.1 and 4.3.2]
Andrew Haley
aph@redhat.com
Tue Sep 23 14:48:00 GMT 2008
Tom St Denis wrote:
> I ran into a bug with the PPC side of things with both 4.1.1 [came with
> FC5] and a freshly built 4.3.2, the snippet is this block
>
> #if 0
>
> #define SQRADDSC(i, j) \
> asm( \
> " mullw %0,%6,%7 \n\t" \
> " mulhwu %1,%6,%7 \n\t" \
> " xor %2,%2,%2 \n\t" \
> :"=r"(sc0), "=r"(sc1), "=r"(sc2):"0"(sc0), "1"(sc1), "2"(sc2),
> "r"(i),"r"(j) : "%cc");
>
> #else
>
> #define SQRADDSC(i, j) \
> asm( \
> " mullw %0,%3,%4 \n\t" \
> " mulhwu %1,%3,%4 \n\t" \
> " xor %2,%2,%2 \n\t" \
> :"=r"(sc0), "=r"(sc1), "=r"(sc2): "r"(i),"r"(j) : "%cc");
>
> #endif
>
> Where {sc0,sc1,sc2} are not previously initialized. The first block
> (that is disabled) is my old code. It would correctly warn about
> uninitialized variables. The 2nd block was my fix which to me seems
> correct. However, the compiler generates output like this
>
> # 0 "" 2
> # 38 "fp_sqr_comba_6.i" 1
> mullw 25,25,18 mulhwu 9,25,18
> xor 0,0,0
> Where r25 is both an input and output it seems. Clearly r25 is not
> supposed to be overwritten here.
This isn't a bug: look for "earlyclobber" in the documentation.
Andrew.
More information about the Gcc-help
mailing list