This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: optimization/7145: g++ -O with structure initializer & return value optimization generates bad code
- From: tlb at tlb dot org
- To: "H. J. Lu" <hjl at lucon dot org>
- Cc: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 01 Jul 2002 11:02:41 -0700
- Subject: Re: optimization/7145: g++ -O with structure initializer & return value optimization generates bad code
> 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