This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
g++/i386: 4-byte inline struct return
- To: egcs at cygnus dot com
- Subject: g++/i386: 4-byte inline struct return
- From: Hasdi R Hashim <hasdi at umich dot edu>
- Date: Wed, 16 Sep 1998 23:28:39 -0400 (EDT)
Hello guys,
I would really, really appreaciate it if somebody would look into
this. This is the general case, I am sure you can come with multiple
permutations of the code snippet (I did), before you can isolate the
problem.
SOURCE CODE:
struct foo { long x; } ;
inline foo bar(long x) return z ; { z.x = x; }
foo a;
void foobar() { a = bar(1); }
OUTPUT ASM CODE (notice redundant code):
foobar__Fv:
pushl %ebp
movl %esp,%ebp
subl $4,%esp
movl $1,-4(%ebp)
movl $1,a
leave
ret
WHAT I EXPECT (mo efficient):
foobar__Fv:
pushl %ebp
movl %esp,%ebp
movl $1,a
leave
ret
I tried every single trick I could think off to make "foo a = bar(1)" as
efficient as "long a = 1". I think the problem has to with struct returns
because when I substitute "struct foo.." with "typedef long foo" I get the
expected code. Can somebody please work on this? This has enormous
potential; it would help me and millions other sorry hackers out there.
TQ :) :) ;)
Hasdi
PS - yes, I did -O, -O2 and -O3