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

Hasdi R Hashim hasdi@umich.edu
Fri Sep 18 06:59:00 GMT 1998


On Thu, 17 Sep 1998, Hasdi R Hashim wrote:
> On Thu, 17 Sep 1998, Joern Rennecke wrote:
> > This problem is ABI related.  For instance, you will get better code for
> > i386-linuxaout that for i386-pc-linux-gnu.
> > Unless you use -freg-struct-return , but then, you can get problems with
> > library functions like inet_makeaddr.
> 
> I'll try this when I get back home. I think gcc should return struct
> values in registers anyway (ignoring -fpcc-struct-return) if the caller
> and callee can follow the same struct-return convention (i.e. inline and
> static functions). Is there a fallacy in my thinking? I hope somebody more
> experience can tell me if this is easy to 'fix' in egcs. 

Ok, I tried it out and it turns out using -freg-struct-return turned out
worse: (this is using egcs release - forgot the version - wished my box is
on the network :(

	EXPECTED:	movl	$1,dest

	ACTUAL:		movl	$1,[bp-4]	; redundant
			movl	$1,dest

	AFTER -freg..:	movl	$1,%eax		; even more
			movl	%eax,[bp-4]	; redundant
			movl	$1,dest

Curiously, when I tried out the same code on gcc 2.8.1/UltraSparc, 4-byte
struct return is identical to 4-byte int return. Either 2.8.1 is smarter
or i386.md needs a little fixing. I'd be willing to look into that if I
know which insn to look out for. It's probably common to both gcc and g++.
I'd have to investigate when I get back home.

Hasdi





More information about the Gcc mailing list