Re: x86: combined usage of "-Os -mregparm=3" leads to broken codes

2014-09-23 Thread Bin Meng
On Tue, Sep 23, 2014 at 6:49 PM, Richard Biener wrote: > > I suppose doing "m" (*params_ptr) would also work. > > Richard. This one works! Thank you. Regards, Bin

Re: x86: combined usage of "-Os -mregparm=3" leads to broken codes

2014-09-23 Thread Bin Meng
On Tue, Sep 23, 2014 at 6:41 PM, Andrew Haley wrote: > > And neither are they used by the asm; so you have no right to expect %edx > to contain anything, and neither have you the right to touch it. > > Do this: > > asm volatile ( > "pushl %1;" > "call *%%eax;" > "add

Re: x86: combined usage of "-Os -mregparm=3" leads to broken codes

2014-09-23 Thread Richard Biener
On Tue, Sep 23, 2014 at 12:41 PM, Andrew Haley wrote: > On 09/23/2014 10:39 AM, Bin Meng wrote: >> On Tue, Sep 23, 2014 at 5:11 PM, Bin Meng wrote: >>> >>> Sorry I still don't get it. The inline-asm codes are put in the very end >>> of the test function just before return, so the clobbered regist

Re: x86: combined usage of "-Os -mregparm=3" leads to broken codes

2014-09-23 Thread Richard Biener
On Tue, Sep 23, 2014 at 11:39 AM, Bin Meng wrote: > On Tue, Sep 23, 2014 at 5:11 PM, Bin Meng wrote: >> >> Sorry I still don't get it. The inline-asm codes are put in the very end >> of the test function just before return, so the clobbered registers are >> not used by gcc. The %edx gets overwrit

Re: x86: combined usage of "-Os -mregparm=3" leads to broken codes

2014-09-23 Thread Andrew Haley
On 09/23/2014 10:39 AM, Bin Meng wrote: > On Tue, Sep 23, 2014 at 5:11 PM, Bin Meng wrote: >> >> Sorry I still don't get it. The inline-asm codes are put in the very end >> of the test function just before return, so the clobbered registers are >> not used by gcc. And neither are they used by the

Re: x86: combined usage of "-Os -mregparm=3" leads to broken codes

2014-09-23 Thread Bin Meng
On Tue, Sep 23, 2014 at 5:11 PM, Bin Meng wrote: > > Sorry I still don't get it. The inline-asm codes are put in the very end > of the test function just before return, so the clobbered registers are > not used by gcc. The %edx gets overwritten before the inline-asm block. > > I just did a modific

Re: x86: combined usage of "-Os -mregparm=3" leads to broken codes

2014-09-23 Thread Bin Meng
On Tue, Sep 23, 2014 at 4:32 PM, Jakub Jelinek wrote: > You are doing a call in the inline-asm behind compiler's back, and > some registers are call clobbered in the ABI. So, unless you call a very > special function written in assembly that doesn't clobber those registers > (basically, uses a cu

Re: x86: combined usage of "-Os -mregparm=3" leads to broken codes

2014-09-23 Thread Jakub Jelinek
On Tue, Sep 23, 2014 at 04:20:16PM +0800, Bin Meng wrote: > Hi Richard, > > On Tue, Sep 23, 2014 at 4:09 PM, Richard Biener > wrote: > > Your asm constraints do not specify that they use %edx. > > > > Richard. > > > > Sorry, I don't understand. The %edx is not used by the inline assembly codes.

Re: x86: combined usage of "-Os -mregparm=3" leads to broken codes

2014-09-23 Thread Bin Meng
Hi Richard, On Tue, Sep 23, 2014 at 4:09 PM, Richard Biener wrote: > Your asm constraints do not specify that they use %edx. > > Richard. > Sorry, I don't understand. The %edx is not used by the inline assembly codes. The 'mov(%eax),%edx' corresponds to C code: pcall = (PCALL)(r->a + r->b);

Re: x86: combined usage of "-Os -mregparm=3" leads to broken codes

2014-09-23 Thread Richard Biener
On Tue, Sep 23, 2014 at 9:51 AM, Bin Meng wrote: > Hi, > > I get a piece of code to be compiled by gcc with the combined '-Os > -mregparm=3' options to generate the x86 32-bit codes, and I found gcc > created broken codes. > > The test codes that can be used to trigger this issue: (save the > foll

x86: combined usage of "-Os -mregparm=3" leads to broken codes

2014-09-23 Thread Bin Meng
Hi, I get a piece of code to be compiled by gcc with the combined '-Os -mregparm=3' options to generate the x86 32-bit codes, and I found gcc created broken codes. The test codes that can be used to trigger this issue: (save the following to test.c.) typedef struct { int a; int