public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/49157] New: Unnecessary stack save/restore code generated for a leaf function (arm-elf-gcc)
@ 2011-05-25 10:34 bmei at broadcom dot com
2011-06-01 19:56 ` [Bug rtl-optimization/49157] " ramana at gcc dot gnu.org
2021-12-19 0:39 ` [Bug middle-end/49157] " pinskia at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: bmei at broadcom dot com @ 2011-05-25 10:34 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49157
Summary: Unnecessary stack save/restore code generated for a
leaf function (arm-elf-gcc)
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: bmei@broadcom.com
For the following example:
struct Complex16{
short a;
short b;
};
short foo (struct Complex16 s)
{
return s.a + s.b;
}
Compile with:
arm-elf-gcc tst.c -O2 -S -mstructure-size-boundary=8
It produces:
foo:
@ args = 0, pretend = 0, frame = 4
@ frame_needed = 0, uses_anonymous_args = 0
@ link register save eliminated.
mov r3, r0, asl #16
mov r3, r3, lsr #16
add r0, r3, r0, lsr #16
mov r0, r0, asl #16
sub sp, sp, #4
mov r0, r0, asr #16
add sp, sp, #4
bx lr
The problem is with struct-size-boundary=8, the structure has BLKmode and
mapped to memory after RTL expand. However, memory accesses are optimized away
later. But GCC records a stack item anyway and generates stack frame
save/restore code for this leaf function.
If we compile without -mstructure-size-boundary=8 (default is 32), it generates
much better code.
foo:
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, uses_anonymous_args = 0
@ link register save eliminated.
add r0, r0, r0, asr #16
mov r0, r0, asl #16
mov r0, r0, asr #16
bx lr
This is not limited to ARM gcc. Our target has the same issue because
STRUCTURE_SIZE_BOUNDARY = 8 to save data memory size.
Though I only tested gcc 4.6, I believe trunk gcc probably has the same
problem.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug rtl-optimization/49157] Unnecessary stack save/restore code generated for a leaf function (arm-elf-gcc)
2011-05-25 10:34 [Bug rtl-optimization/49157] New: Unnecessary stack save/restore code generated for a leaf function (arm-elf-gcc) bmei at broadcom dot com
@ 2011-06-01 19:56 ` ramana at gcc dot gnu.org
2021-12-19 0:39 ` [Bug middle-end/49157] " pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: ramana at gcc dot gnu.org @ 2011-06-01 19:56 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49157
Ramana Radhakrishnan <ramana at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2011.06.01 19:56:05
CC| |ramana at gcc dot gnu.org
Ever Confirmed|0 |1
--- Comment #1 from Ramana Radhakrishnan <ramana at gcc dot gnu.org> 2011-06-01 19:56:05 UTC ---
With an arm-linux-gnueabi toolchain I see the following code - it's pointless
creating space on the stack in this case.
foo:
@ args = 0, pretend = 0, frame = 8
@ frame_needed = 0, uses_anonymous_args = 0
@ link register save eliminated.
add r0, r0, r0, lsr #16
sub sp, sp, #8
sxth r0, r0
add sp, sp, #8
bx lr
Possibly related to PR36409.
Ramana
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug middle-end/49157] Unnecessary stack save/restore code generated for a leaf function (arm-elf-gcc)
2011-05-25 10:34 [Bug rtl-optimization/49157] New: Unnecessary stack save/restore code generated for a leaf function (arm-elf-gcc) bmei at broadcom dot com
2011-06-01 19:56 ` [Bug rtl-optimization/49157] " ramana at gcc dot gnu.org
@ 2021-12-19 0:39 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-19 0:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49157
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-12-19 0:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-25 10:34 [Bug rtl-optimization/49157] New: Unnecessary stack save/restore code generated for a leaf function (arm-elf-gcc) bmei at broadcom dot com
2011-06-01 19:56 ` [Bug rtl-optimization/49157] " ramana at gcc dot gnu.org
2021-12-19 0:39 ` [Bug middle-end/49157] " pinskia 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).