This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/52415] New: memcpy to local variable generates unnecessary stack frame for armv7
- From: "jay.foad at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 28 Feb 2012 10:29:09 +0000
- Subject: [Bug target/52415] New: memcpy to local variable generates unnecessary stack frame for armv7
- Auto-submitted: auto-generated
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.