This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

g++/i386: 4-byte inline struct return


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




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]