public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/45026]  New: Empty function compiles to many loads and stores
@ 2010-07-21 21:06 steven at gcc dot gnu dot org
  2010-07-26 20:08 ` [Bug target/45026] " sje at cup dot hp dot com
  0 siblings, 1 reply; 2+ messages in thread
From: steven at gcc dot gnu dot org @ 2010-07-21 21:06 UTC (permalink / raw)
  To: gcc-bugs

Consider this test case:
typedef struct teststruct
{
  double d;
  char f1;
  int arr[15];
} teststruct;

void
copystruct5 (teststruct param)
{
  return;
}

The mighty copystruct5 function does absolutely nothing, so I expect this to be
compiled to absolutely nothing. But not so with r162374 at -O2:

        .file   "t.c"
        .pred.safe_across_calls p1-p5,p16-p63
        .text
        .align 16
        .align 64
        .global copystruct5#
        .type   copystruct5#, @function
        .proc copystruct5#
copystruct5:
        .prologue
        .spill 48
        .mmi
        .fframe 48
        adds r12 = -48, r12
[.L2:]  
        .body
        ;;
        mov r14 = r12
        adds r15 = 16, r12
        ;;
        .mmi
        st8 [r14] = r32, 8
        st8 [r15] = r34
        nop 0
        ;;
        .mmi
        st8 [r14] = r33
        nop 0
        adds r14 = 24, r12
        ;;
        .mmi
        st8 [r14] = r35
        nop 0
        adds r14 = 32, r12
        ;;
        .mmi
        st8 [r14] = r36
        nop 0
        adds r14 = 40, r12
        ;;
        .mmi
        st8 [r14] = r37
        nop 0
        adds r14 = 48, r12
        ;;
        .mmi
        st8 [r14] = r38
        nop 0
        adds r14 = 56, r12
        ;;
        .mib
        st8 [r14] = r39
        .restore sp
        adds r12 = 48, r12
        br.ret.sptk.many b0
        .endp copystruct5#
        .ident  "GCC: (GNU) 4.6.0 20100721 (experimental) [trunk revision
162374]"

What's that?!


-- 
           Summary: Empty function compiles to many loads and stores
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: steven at gcc dot gnu dot org
GCC target triplet: ia64-unknown-linux-gnu


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


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

* [Bug target/45026] Empty function compiles to many loads and stores
  2010-07-21 21:06 [Bug target/45026] New: Empty function compiles to many loads and stores steven at gcc dot gnu dot org
@ 2010-07-26 20:08 ` sje at cup dot hp dot com
  0 siblings, 0 replies; 2+ messages in thread
From: sje at cup dot hp dot com @ 2010-07-26 20:08 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from sje at cup dot hp dot com  2010-07-26 20:07 -------
It doesn't result in any loads, just stores.  This code is storing the first
part of the structure argument which was passed (partially) in registers into
memory.  Obviously it doesn't need to do this since the argument isn't used.  I
think this is an unfortunate side-effect of passing a large structure as an
argument.  If the structure were smaller and fit entirely into registers you
would see an empty function.  Large structures are split on IA64 with the first
part going into registers and the last part going into memory and it looks like
GCC 'reconstructs' the structure in memory before determining if it is needed
or not.

Ideally, you should pass a pointer here instead of passing (and copying) the
structure, but it would be nice if GCC realised the argument wasn't needed and
didn't do the stores so this could be considered a missed optimization.


-- 

sje at cup dot hp dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sje at cup dot hp dot com


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


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

end of thread, other threads:[~2010-07-26 20:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-21 21:06 [Bug target/45026] New: Empty function compiles to many loads and stores steven at gcc dot gnu dot org
2010-07-26 20:08 ` [Bug target/45026] " sje at cup dot hp dot com

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).