This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: gcc 2.95.3 for ppc uses GPR 0 in addi
- To: Karl Cooper <KCooper at transcept dot com>
- Subject: Re: gcc 2.95.3 for ppc uses GPR 0 in addi
- From: Franz Sirl <Franz dot Sirl-kernel at lauterbach dot com>
- Date: Thu, 27 Jul 2000 19:50:19 +0200
- Cc: "'gcc-bugs at gcc dot gnu dot org'" <gcc-bugs at gcc dot gnu dot org>
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.