public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/52415] New: memcpy to local variable generates unnecessary stack frame for armv7
@ 2012-02-28 10:40 jay.foad at gmail dot com
  2012-02-28 11:51 ` [Bug target/52415] " rguenth at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: jay.foad at gmail dot com @ 2012-02-28 10:40 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 52415
           Summary: memcpy to local variable generates unnecessary stack
                    frame for armv7
    Classification: Unclassified
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: jay.foad@gmail.com


This test case uses memcpy to load the bytes of a float into an int:

$ cat m.c
int f(float *p) {
    int i;
    __builtin_memcpy(&i, p, sizeof i);
    return i;
}

When compiled for armv7 I get:

$ cc1 -o - -O3 m.c -quiet -march=armv7 -mthumb
...
f:
    @ args = 0, pretend = 0, frame = 4
    @ frame_needed = 0, uses_anonymous_args = 0
    @ link register save eliminated.
    ldr    r0, [r0, #0]    @ unaligned
    sub    sp, sp, #4
    str    r0, [sp, #0]    @ unaligned
    ldr    r0, [sp, #0]
    add    sp, sp, #4
    bx    lr
...

The stack frame is unnecessary; it could compile to just:

    ldr    r0, [r0, #0]
    bx    lr

I'm using trunk rev 184597, configured with --target=arm-elf.


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

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

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-28 10:40 [Bug target/52415] New: memcpy to local variable generates unnecessary stack frame for armv7 jay.foad at gmail dot com
2012-02-28 11:51 ` [Bug target/52415] " rguenth at gcc dot gnu.org
2012-02-28 12:02 ` jay.foad at gmail dot com
2012-02-28 12:17 ` rguenth at gcc dot gnu.org
2012-02-28 12:39 ` jakub at gcc dot gnu.org
2012-02-28 13:07 ` jay.foad at gmail dot com
2012-04-05  8:13 ` mhlavink at redhat dot com
2012-04-17  8:30 ` gjl at gcc dot gnu.org
2012-04-18 12:48 ` mhlavink at redhat dot com
2012-04-18 20:02 ` gjl at gcc dot gnu.org
2012-06-06 11:00 ` 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).