This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: gcc 2.95.3 for ppc uses GPR 0 in addi


At 19:15 27.07.00, Karl Cooper wrote:
>The following C code with user-provided asm code
>causes gcc to produce incorrect assembler output:
>void waitfor (int delta)
>{
>   asm
>   (
>     "addi    %%r4,%0,1\n\t"
>     "mftb    %%r6\n\t"
>     "add     %%r4,%%r4,%%r6\n\t"
>     "1: mftb %%r5\n\t"
>     "cmpl    0,%%r4,%%r5\n\t"
>     "bgt     1b\n\t"
>     :
>     : "r" (delta)
^^^^^^^^^^^^^^^^^^

>     : "r4", "r5", "r6"
>   );
>}
>
>
>The resulting .s file chooses r0 to load the input parameter,
>resulting in an addi  r4,r0,1 instruction which effectively
>zeroes the input parameter.

But you explicitly allowed r0-r31 by using "r", if you want to restrict the 
range to r1-r31, use "b". This is a common programming error when using 
inline assembly on PPC.

Franz.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]