This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/36598] New: Failed optimisation of return of struct argment in memcpy-1.c
- From: "hutchinsonandy at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 22 Jun 2008 13:26:05 -0000
- Subject: [Bug c/36598] New: Failed optimisation of return of struct argment in memcpy-1.c
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Testcase gcc.dg/memcpy-1.c fails on AVR target.
Failure occurs because the return value is not simplified to avoid memcpy. This
test works on i686 and I can't see why same optimization should not apply to
AVR
Test is:
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-optimized" } */
/* { dg-final { scan-tree-dump-times "nasty_local" 0 "optimized" } } */
/* { dg-final { cleanup-tree-dump "optimized" } } */
struct a {int a,b,c;} a;
int test(struct a a)
{
struct a nasty_local;
__builtin_memcpy (&nasty_local,&a, sizeof(a));
return nasty_local.a;
}
On i686 we get:
;; Function test (test)
Analyzing Edge Insertions.
test (struct a a)
{
<bb 2>:
return a.a;
}
BUT on AVR we get:
;; Function test (test)
Analyzing Edge Insertions.
test (struct a a)
{
struct a nasty_local;
<bb 2>:
nasty_local = a;
return nasty_local.a;
}
I have confirmed the final AVR code is suboptimal.
--
Summary: Failed optimisation of return of struct argment in
memcpy-1.c
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: hutchinsonandy at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: avr-unknown-none
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36598