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

tlb@tlb.org tlb@tlb.org
Mon Jul 1 11:02:00 GMT 2002


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

--
Trevor Blackwell         tlb@tlb.org          (650) 776-7870



More information about the Gcc-bugs mailing list