optimization/7145: g++ -O with structure initializer & return value optimization generates bad code

H. J. Lu hjl@lucon.org
Mon Jul 1 11:06:00 GMT 2002


On Mon, Jul 01, 2002 at 11:02:41AM -0700, tlb@tlb.org wrote:
> 
> > http://gcc.gnu.org/ml/gcc-patches/2002-06/msg02277.html
> 
> That's better. There isn't a big performance loss to disabling named
> return-value optimization for variables declared with
> initializer-lists, since you can't use an initializer-list for a
> struct with any sort of constructor. The return code should be just a
> bitwise copy.
> 
> 
> However, I don't think that solves the real problem. At all
> optimization levels but when the function doesn't get inlined, a
> return of a struct with an initializer-list seems to work OK (and
> probably faster) without your patch. It's only when inlining that it
> fails. So the real problem probably lurks in the inliner. The inliner
> probably already does a bunch of magic with trying to unify the return
> value and the caller's assignment, so it might be worth looking into
> how that interacts with unifying the callee's declaration and return
> value.
> 
> Or maybe the plan should be not to attempt the named return value
> optimization when DECL_DECLARED_INLINE_P is true, since inlining will
> give better results anyway.
> 

I believe Jason is looking into it now. I hope it will be fixed in gcc
3.1.1.



H.J.



More information about the Gcc-bugs mailing list