public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: gcc 3.4.6 on PPC why doing function inline with -O2?
@ 2007-02-23  2:06 ming lei
  0 siblings, 0 replies; 3+ messages in thread
From: ming lei @ 2007-02-23  2:06 UTC (permalink / raw)
  To: aph; +Cc: gcc-help, mlei


Here is the test.c file and two objdump output from compiled with -O1 and 
-O2 using gcc3.4.6 cross compiler(host is x86 linux and target is PPC440) 
respectively. It's obvious that the output from -O2 inlines Goo().

BTW, I compiled with -O2 using gcc 3.3.2 cross compiler on the same file 
which doesnt do inline for Goo().

=============test.c======================
static void Goo()
{
    char a[1024];
    a[0]=21;
}

void Foo(int cmd)
{
    char b[32];

    switch(cmd) {

    case 1:
        b[0] = 13;
        break;

    case 2:
        Goo();
        break;
    }
}
===================use -O2=========================
00000000 <Foo>:
   0:   2f 83 00 01     cmpwi   cr7,r3,1
   4:   94 21 fb d0     stwu    r1,-1072(r1)
   8:   2f 03 00 02     cmpwi   cr6,r3,2
   c:   41 9e 00 20     beq-    cr7,2c <Foo+0x2c>
  10:   41 9a 00 0c     beq-    cr6,1c <Foo+0x1c>
  14:   38 21 04 30     addi    r1,r1,1072
  18:   4e 80 00 20     blr
  1c:   38 00 00 15     li      r0,21
  20:   98 01 00 30     stb     r0,48(r1)
  24:   38 21 04 30     addi    r1,r1,1072
  28:   4e 80 00 20     blr
  2c:   38 00 00 0d     li      r0,13
  30:   98 01 00 10     stb     r0,16(r1)
  34:   38 21 04 30     addi    r1,r1,1072
  38:   4e 80 00 20     blr

===================use -O1=========================
00000000 <Goo>:
   0:   94 21 fb f0     stwu    r1,-1040(r1)
   4:   38 21 04 10     addi    r1,r1,1040
   8:   4e 80 00 20     blr

0000000c <Foo>:
   c:   94 21 ff d0     stwu    r1,-48(r1)
  10:   2f 83 00 01     cmpwi   cr7,r3,1
  14:   40 be 00 0c     bne+    cr7,20 <Foo+0x14>
  18:   38 00 00 0d     li      r0,13
  1c:   98 01 00 10     stb     r0,16(r1)
  20:   38 21 00 30     addi    r1,r1,48
  24:   4e 80 00 20     blr
===============================================




========================================================
Re: gcc 3.4.6 on PPC why doing function inline with -O2?
From: Andrew Haley <aph at redhat dot com>
To: "Ming Lei" <mlei at Brocade dot COM>
Cc: <gcc-help at gcc dot gnu dot org>
Date: Sat, 17 Feb 2007 10:36:05 +0000
Subject: Re: gcc 3.4.6 on PPC why doing function inline with -O2?
References: 
<A5443C1E48CD114B9B1A92EF04F6656601795EF3@hq-exch-1.corp.brocade.com>

--------------------------------------------------------------------------------

Ming Lei writes:

 > I came across a problem while using gcc3.4.6 on PPC440. It turns out
 > with -O2 flag the compiler does inline function expanding. I tested with
 > 3.2 version it doesn't do it in O2. The 3.4.6 manual says that only with
 > -O3 the compiler can do this inline function optimization. Even I used
 > -fno-inline-functions it doesn't work, but used -fno-inline does prevent
 > inline functions.
 >
 > Is it a bug in 3.4.6?

I don't think so.  Do you have a test case that shows this problem?

Andrew.

_________________________________________________________________
The average US Credit Score is 675. The cost to see yours: $0 by Experian. 
http://www.freecreditreport.com/pm/default.aspx?sc=660600&bcd=EMAILFOOTERAVERAGE

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: gcc 3.4.6 on PPC why doing function inline with -O2?
  2007-02-17  1:16 Ming Lei
@ 2007-02-17 11:43 ` Andrew Haley
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Haley @ 2007-02-17 11:43 UTC (permalink / raw)
  To: Ming Lei; +Cc: gcc-help

Ming Lei writes:

 > I came across a problem while using gcc3.4.6 on PPC440. It turns out
 > with -O2 flag the compiler does inline function expanding. I tested with
 > 3.2 version it doesn't do it in O2. The 3.4.6 manual says that only with
 > -O3 the compiler can do this inline function optimization. Even I used
 > -fno-inline-functions it doesn't work, but used -fno-inline does prevent
 > inline functions.
 > 
 > Is it a bug in 3.4.6?

I don't think so.  Do you have a test case that shows this problem?

Andrew.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* gcc 3.4.6 on PPC why doing function inline with -O2?
@ 2007-02-17  1:16 Ming Lei
  2007-02-17 11:43 ` Andrew Haley
  0 siblings, 1 reply; 3+ messages in thread
From: Ming Lei @ 2007-02-17  1:16 UTC (permalink / raw)
  To: gcc-help

Hi,

I came across a problem while using gcc3.4.6 on PPC440. It turns out
with -O2 flag the compiler does inline function expanding. I tested with
3.2 version it doesn't do it in O2. The 3.4.6 manual says that only with
-O3 the compiler can do this inline function optimization. Even I used
-fno-inline-functions it doesn't work, but used -fno-inline does prevent
inline functions.

Is it a bug in 3.4.6?

BTW, what's the difference between -fno-inline and
-fno-inline-functions?

Thanks
Ming

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-02-22 23:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-23  2:06 gcc 3.4.6 on PPC why doing function inline with -O2? ming lei
  -- strict thread matches above, loose matches on Subject: below --
2007-02-17  1:16 Ming Lei
2007-02-17 11:43 ` Andrew Haley

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).