public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* g++/i386: 4-byte inline struct return
@ 1998-09-16 22:55 Hasdi R Hashim
  1998-09-17  9:59 ` Joern Rennecke
  1998-09-17 22:12 ` Martin von Loewis
  0 siblings, 2 replies; 9+ messages in thread
From: Hasdi R Hashim @ 1998-09-16 22:55 UTC (permalink / raw)
  To: egcs

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



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

end of thread, other threads:[~1998-09-18  6:59 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-09-16 22:55 g++/i386: 4-byte inline struct return Hasdi R Hashim
1998-09-17  9:59 ` Joern Rennecke
1998-09-17  9:59   ` Hasdi R Hashim
1998-09-17  9:59     ` Joern Rennecke
1998-09-17  9:59       ` Hasdi R Hashim
1998-09-17 18:37     ` Joe Buck
1998-09-18  2:04     ` Martin von Loewis
1998-09-18  6:59     ` Hasdi R Hashim
1998-09-17 22:12 ` Martin von Loewis

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