This is GCC Bugzilla
This is GCC Bugzilla Version 2.20+
View Bug Activity | Format For Printing | Clone This Bug
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.
Subject: Re: New: Failed optimisation of return of struct argment in memcpy-1.c On Sun, 22 Jun 2008, hutchinsonandy at gcc dot gnu dot org wrote: > Testcase gcc.dg/memcpy-1.c fails on AVR target. Have you looked at bug 31677 which suggests using the option "--param sra-max-structure-size=32"? If that works for AVR, you could submit a patch to add it to the testcase for all targets.
Thanks for information --param sra-max-structure-size=32 does indeed remove test failure and produces optimal code. But changing the testcase does not remove the optimization problem - unless sra-max-structure-size was always used. So there is problem somewhere else to fix. See also: http://gcc.gnu.org/ml/gcc-patches/2007-12/msg01144.html Andy
This is really not a task for SRA but for struct copy propagation (which we do not do). See PR14295. As this testcase was for SRA you can either XFAIL it for avr or see if the cost metrics need adjustment.
Quite possibly due to cost metrics. They are far from ideal. Will mark test XFAIL until we can investigate and fix.
Subject: Bug 36598 Author: hutchinsonandy Date: Mon Jun 30 22:38:34 2008 New Revision: 137298 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=137298 Log: PR target/36598 * gcc.dg/memcpy-1.c: Mark test XFAIL for avr target. Modified: trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gcc.dg/memcpy-1.c
*** Bug 39245 has been marked as a duplicate of this bug. ***
Test also fails on powerpc64 with -m32, arm.
(In reply to comment #7) > Test also fails on powerpc64 with -m32, arm. And sh4. http://gcc.gnu.org/ml/gcc-testresults/2009-02/msg01952.html