public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/36598]  New: Failed optimisation of return of struct argment in memcpy-1.c
@ 2008-06-22 13:26 hutchinsonandy at gcc dot gnu dot org
  2008-06-22 13:33 ` [Bug c/36598] " joseph at codesourcery dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 10+ messages in thread
From: hutchinsonandy at gcc dot gnu dot org @ 2008-06-22 13:26 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c/36598] Failed optimisation of return of struct argment in memcpy-1.c
  2008-06-22 13:26 [Bug c/36598] New: Failed optimisation of return of struct argment in memcpy-1.c hutchinsonandy at gcc dot gnu dot org
@ 2008-06-22 13:33 ` joseph at codesourcery dot com
  2008-06-22 14:33 ` hutchinsonandy at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: joseph at codesourcery dot com @ 2008-06-22 13:33 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from joseph at codesourcery dot com  2008-06-22 13:32 -------
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.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36598


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c/36598] Failed optimisation of return of struct argment in memcpy-1.c
  2008-06-22 13:26 [Bug c/36598] New: Failed optimisation of return of struct argment in memcpy-1.c hutchinsonandy at gcc dot gnu dot org
  2008-06-22 13:33 ` [Bug c/36598] " joseph at codesourcery dot com
@ 2008-06-22 14:33 ` hutchinsonandy at gcc dot gnu dot org
  2008-06-22 14:51 ` rguenth at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: hutchinsonandy at gcc dot gnu dot org @ 2008-06-22 14:33 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from hutchinsonandy at gcc dot gnu dot org  2008-06-22 14:33 -------
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


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36598


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c/36598] Failed optimisation of return of struct argment in memcpy-1.c
  2008-06-22 13:26 [Bug c/36598] New: Failed optimisation of return of struct argment in memcpy-1.c hutchinsonandy at gcc dot gnu dot org
  2008-06-22 13:33 ` [Bug c/36598] " joseph at codesourcery dot com
  2008-06-22 14:33 ` hutchinsonandy at gcc dot gnu dot org
@ 2008-06-22 14:51 ` rguenth at gcc dot gnu dot org
  2008-06-22 16:12 ` hutchinsonandy at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-06-22 14:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from rguenth at gcc dot gnu dot org  2008-06-22 14:50 -------
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.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |14295


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36598


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c/36598] Failed optimisation of return of struct argment in memcpy-1.c
  2008-06-22 13:26 [Bug c/36598] New: Failed optimisation of return of struct argment in memcpy-1.c hutchinsonandy at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2008-06-22 14:51 ` rguenth at gcc dot gnu dot org
@ 2008-06-22 16:12 ` hutchinsonandy at gcc dot gnu dot org
  2008-06-30 22:40 ` [Bug middle-end/36598] " hutchinsonandy at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: hutchinsonandy at gcc dot gnu dot org @ 2008-06-22 16:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from hutchinsonandy at gcc dot gnu dot org  2008-06-22 16:11 -------
Quite possibly due to cost metrics. They are far from ideal.

Will mark test XFAIL until we can investigate and fix.


-- 

hutchinsonandy at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |eric dot weddington at atmel
                   |                            |dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36598


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug middle-end/36598] Failed optimisation of return of struct argment in memcpy-1.c
  2008-06-22 13:26 [Bug c/36598] New: Failed optimisation of return of struct argment in memcpy-1.c hutchinsonandy at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2008-06-22 16:12 ` hutchinsonandy at gcc dot gnu dot org
@ 2008-06-30 22:40 ` hutchinsonandy at gcc dot gnu dot org
  2009-02-20 18:06 ` danglin at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: hutchinsonandy at gcc dot gnu dot org @ 2008-06-30 22:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from hutchinsonandy at gcc dot gnu dot org  2008-06-30 22:39 -------
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


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36598


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug middle-end/36598] Failed optimisation of return of struct argment in memcpy-1.c
  2008-06-22 13:26 [Bug c/36598] New: Failed optimisation of return of struct argment in memcpy-1.c hutchinsonandy at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2008-06-30 22:40 ` [Bug middle-end/36598] " hutchinsonandy at gcc dot gnu dot org
@ 2009-02-20 18:06 ` danglin at gcc dot gnu dot org
  2009-02-20 18:09 ` danglin at gcc dot gnu dot org
  2009-02-20 19:49 ` ubizjak at gmail dot com
  7 siblings, 0 replies; 10+ messages in thread
From: danglin at gcc dot gnu dot org @ 2009-02-20 18:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from danglin at gcc dot gnu dot org  2009-02-20 18:05 -------
*** Bug 39245 has been marked as a duplicate of this bug. ***


-- 

danglin at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |danglin at gcc dot gnu dot
                   |                            |org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36598


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug middle-end/36598] Failed optimisation of return of struct argment in memcpy-1.c
  2008-06-22 13:26 [Bug c/36598] New: Failed optimisation of return of struct argment in memcpy-1.c hutchinsonandy at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2009-02-20 18:06 ` danglin at gcc dot gnu dot org
@ 2009-02-20 18:09 ` danglin at gcc dot gnu dot org
  2009-02-20 19:49 ` ubizjak at gmail dot com
  7 siblings, 0 replies; 10+ messages in thread
From: danglin at gcc dot gnu dot org @ 2009-02-20 18:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from danglin at gcc dot gnu dot org  2009-02-20 18:08 -------
Test also fails on powerpc64 with -m32, arm.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36598


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug middle-end/36598] Failed optimisation of return of struct argment in memcpy-1.c
  2008-06-22 13:26 [Bug c/36598] New: Failed optimisation of return of struct argment in memcpy-1.c hutchinsonandy at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2009-02-20 18:09 ` danglin at gcc dot gnu dot org
@ 2009-02-20 19:49 ` ubizjak at gmail dot com
  7 siblings, 0 replies; 10+ messages in thread
From: ubizjak at gmail dot com @ 2009-02-20 19:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from ubizjak at gmail dot com  2009-02-20 19:49 -------
(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


-- 

ubizjak at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kkojima at gcc dot gnu dot
                   |                            |org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
 GCC target triplet|avr-unknown-none            |
   Last reconfirmed|0000-00-00 00:00:00         |2009-02-20 19:49:15
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36598


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug middle-end/36598] Failed optimisation of return of struct argment in memcpy-1.c
       [not found] <bug-36598-4@http.gcc.gnu.org/bugzilla/>
@ 2012-06-06 10:16 ` rguenth at gcc dot gnu.org
  0 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-06-06 10:16 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36598

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

--- Comment #9 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-06-06 10:15:42 UTC ---
Fixed for avr and ppc at least.


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2012-06-06 10:16 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-22 13:26 [Bug c/36598] New: Failed optimisation of return of struct argment in memcpy-1.c hutchinsonandy at gcc dot gnu dot org
2008-06-22 13:33 ` [Bug c/36598] " joseph at codesourcery dot com
2008-06-22 14:33 ` hutchinsonandy at gcc dot gnu dot org
2008-06-22 14:51 ` rguenth at gcc dot gnu dot org
2008-06-22 16:12 ` hutchinsonandy at gcc dot gnu dot org
2008-06-30 22:40 ` [Bug middle-end/36598] " hutchinsonandy at gcc dot gnu dot org
2009-02-20 18:06 ` danglin at gcc dot gnu dot org
2009-02-20 18:09 ` danglin at gcc dot gnu dot org
2009-02-20 19:49 ` ubizjak at gmail dot com
     [not found] <bug-36598-4@http.gcc.gnu.org/bugzilla/>
2012-06-06 10:16 ` rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).