This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: fold_builtin_memcpy cannot optimize <retval>?
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Richard Guenther <rguenth at tat dot physik dot uni-tuebingen dot de>
- Cc: gcc at gcc dot gnu dot org
- Date: Fri, 21 Jan 2005 11:51:58 +0100
- Subject: Re: fold_builtin_memcpy cannot optimize <retval>?
- References: <Pine.LNX.4.44.0501211136170.16464-100000@alwazn.tat.physik.uni-tuebingen.de>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Fri, Jan 21, 2005 at 11:38:37AM +0100, Richard Guenther wrote:
> The simple testcase
>
> struct Foo {};
> Foo bar(const Foo& a)
> {
> Foo res;
> res = a;
> return res;
> }
>
> leaves us with
>
> Foo bar(const Foo&) (a)
> {
> struct Foo res;
>
> # BLOCK 0
> # PRED: ENTRY [100.0%] (fallthru,exec)
> __builtin_memcpy (&<retval>, a_1, 0);
> return <retval>;
> # SUCC: EXIT [100.0%]
>
> }
>
> in the optimized tree-dump and obviously ugly asm code.
>
> What's going on here?
The arguments to __builtin_memcpy fail validation (validate_arglist).
The reason is that second argument in this case is not POINTER_TYPE
as memcpy requires, but REFERENCE_TYPE.
Not sure if it is better to just make sure __builtin_memcpy will
never see a REFERENCE_TYPE argument in this case, or make argument
validation in builtins.c less strict and for POINTER_TYPE requirements
allow REFERENCE_TYPEs as well.
Jakub