* Bug in PPC inline assembly?
@ 2005-07-17 23:15 Stefan
2005-07-17 23:19 ` David Edelsohn
2005-07-18 1:11 ` Alan Lehotsky
0 siblings, 2 replies; 4+ messages in thread
From: Stefan @ 2005-07-17 23:15 UTC (permalink / raw)
To: gcc
I have some problems with using inline PowerPC assembly in GCC (4.0.1).
Consider the following code:
void save_fp_register(double* buffer)
{
asm("stfd F0, 0(%0)" : : "r" (buffer) );
}
When compiled with -Os the generated code becomes
save_fp_register:
stfd F0, 0(3)
blr
Which is OK; the input parameter comes in r3 which is used directly in
the stfd operation. However, when compiled with -O0 (no optimization)
the generated code instead becomes
save_fp_register:
stwu 1,-24(1)
stw 31,20(1)
mr 31,1
stw 3,8(31)
lwz 0,8(31)
stfd F0, 0(0) <-- error
lwz 11,0(1)
lwz 31,-4(11)
mr 1,11
blr
The input parameter r3 is transferred to r0, which is used in the stfd
operation. However, for this particular operation r0 means 0 -- not the
value stored in r0 -- which means that the machine will actually try to
store the value at address 0x0.
Is this a bug in GCC or is it my code that is messed up?
-- Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Bug in PPC inline assembly?
2005-07-17 23:15 Bug in PPC inline assembly? Stefan
@ 2005-07-17 23:19 ` David Edelsohn
2005-07-18 1:11 ` Alan Lehotsky
1 sibling, 0 replies; 4+ messages in thread
From: David Edelsohn @ 2005-07-17 23:19 UTC (permalink / raw)
To: Stefan; +Cc: gcc
>>>>> Stefan writes:
Stefan> I have some problems with using inline PowerPC assembly in GCC (4.0.1).
Stefan> Consider the following code:
Stefan> void save_fp_register(double* buffer)
Stefan> {
Stefan> asm("stfd F0, 0(%0)" : : "r" (buffer) );
Stefan> }
Use constraint "b".
David
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Bug in PPC inline assembly?
2005-07-17 23:15 Bug in PPC inline assembly? Stefan
2005-07-17 23:19 ` David Edelsohn
@ 2005-07-18 1:11 ` Alan Lehotsky
2005-07-18 19:00 ` Stefan
1 sibling, 1 reply; 4+ messages in thread
From: Alan Lehotsky @ 2005-07-18 1:11 UTC (permalink / raw)
To: Stefan; +Cc: gcc
On Jul 17, 2005, at 19:15, Stefan wrote:
> I have some problems with using inline PowerPC assembly in GCC
> (4.0.1). Consider the following code:
>
> void save_fp_register(double* buffer)
> {
> asm("stfd F0, 0(%0)" : : "r" (buffer) );
> }
>
Try using 'b' for the constraint - that selects for an "address base
register", as opposed to 'r'
that is any of the general registers (including R0)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Bug in PPC inline assembly?
2005-07-18 1:11 ` Alan Lehotsky
@ 2005-07-18 19:00 ` Stefan
0 siblings, 0 replies; 4+ messages in thread
From: Stefan @ 2005-07-18 19:00 UTC (permalink / raw)
To: gcc; +Cc: apl, dje
Thanks for your help: using constraint "b" instead of "r" solved my problem.
-- Stefan
> Try using 'b' for the constraint - that selects for an "address base
> register", as opposed to 'r' that is any of the general registers
(including
> R0)
>> I have some problems with using inline PowerPC assembly in GCC (4.0.1).
>> Consider the following code:
>>
>> void save_fp_register(double* buffer)
>> {
>> asm("stfd F0, 0(%0)" : : "r" (buffer) );
>> }
>>
>> When compiled with -Os the generated code becomes
>>
>> save_fp_register:
>> stfd F0, 0(3)
>> blr
>>
>> Which is OK; the input parameter comes in r3 which is used directly
in the
>> stfd operation. However, when compiled with -O0 (no optimization) the
>> generated code instead becomes
>>
>> save_fp_register:
>> stwu 1,-24(1)
>> stw 31,20(1)
>> mr 31,1
>> stw 3,8(31)
>> lwz 0,8(31)
>> stfd F0, 0(0) <-- error
>> lwz 11,0(1)
>> lwz 31,-4(11)
>> mr 1,11
>> blr
>>
>> The input parameter r3 is transferred to r0, which is used in the stfd
>> operation. However, for this particular operation r0 means 0 -- not
the value
>> stored in r0 -- which means that the machine will actually try to
store the
>> value at address 0x0.
>>
>> Is this a bug in GCC or is it my code that is messed up?
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-07-18 19:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-17 23:15 Bug in PPC inline assembly? Stefan
2005-07-17 23:19 ` David Edelsohn
2005-07-18 1:11 ` Alan Lehotsky
2005-07-18 19:00 ` Stefan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).