public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/43513] New: The stack pointer is adjusted twice
@ 2010-03-25 9:19 carrot at google dot com
2010-03-25 9:20 ` [Bug target/43513] " carrot at google dot com
` (3 more replies)
0 siblings, 4 replies; 12+ messages in thread
From: carrot at google dot com @ 2010-03-25 9:19 UTC (permalink / raw)
To: gcc-bugs
Compile the attached code with options -march=armv7-a -mthumb -Os -fpic, gcc
generates:
foo3:
push {r4, r5, r6, r7, lr}
sub sp, sp, #12 // A
ldr r3, .L4
add r7, sp, #0 // B
sub sp, sp, #48 // C
mov r0, sp
...
Instruction A is used to allocate space for spilled variables. Instruction B
setups a frame pointer. Instruction C allocate space for local variables.
Instruction A and C can be merged into one, so ABC can be rewritten as:
sub sp, sp, 60
add r7, sp, r8
Instruction C is emitted at the expand phase. But instructions AB is emitted
from function arm_expand_prologue in pro_and_epilogue pass. So one possible
solution is stop emitting code to allocate space for local variables. Instead
record the local variables' space size and allocate the space with spill space
together in pro_and_epilogue pass.
--
Summary: The stack pointer is adjusted twice
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: carrot at google dot com
GCC build triplet: i686-linux
GCC host triplet: i686-linux
GCC target triplet: arm-eabi
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43513
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug target/43513] The stack pointer is adjusted twice
2010-03-25 9:19 [Bug target/43513] New: The stack pointer is adjusted twice carrot at google dot com
@ 2010-03-25 9:20 ` carrot at google dot com
2010-03-25 9:53 ` steven at gcc dot gnu dot org
` (2 subsequent siblings)
3 siblings, 0 replies; 12+ messages in thread
From: carrot at google dot com @ 2010-03-25 9:20 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from carrot at google dot com 2010-03-25 09:20 -------
Created an attachment (id=20195)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20195&action=view)
test case
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43513
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug target/43513] The stack pointer is adjusted twice
2010-03-25 9:19 [Bug target/43513] New: The stack pointer is adjusted twice carrot at google dot com
2010-03-25 9:20 ` [Bug target/43513] " carrot at google dot com
@ 2010-03-25 9:53 ` steven at gcc dot gnu dot org
2010-03-26 6:42 ` carrot at google dot com
2010-03-26 9:05 ` [Bug middle-end/43513] " rearnsha at gcc dot gnu dot org
3 siblings, 0 replies; 12+ messages in thread
From: steven at gcc dot gnu dot org @ 2010-03-25 9:53 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from steven at gcc dot gnu dot org 2010-03-25 09:53 -------
Any reason why combine-stack-adj.c doesn't perform this optimization for you?
--
steven at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2010-03-25 09:53:22
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43513
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug target/43513] The stack pointer is adjusted twice
2010-03-25 9:19 [Bug target/43513] New: The stack pointer is adjusted twice carrot at google dot com
2010-03-25 9:20 ` [Bug target/43513] " carrot at google dot com
2010-03-25 9:53 ` steven at gcc dot gnu dot org
@ 2010-03-26 6:42 ` carrot at google dot com
2010-03-26 9:05 ` [Bug middle-end/43513] " rearnsha at gcc dot gnu dot org
3 siblings, 0 replies; 12+ messages in thread
From: carrot at google dot com @ 2010-03-26 6:42 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from carrot at google dot com 2010-03-26 06:42 -------
There are 2 problems with csa for arm:
1. In function rest_of_handle_stack_adjustments:
if (!ACCUMULATE_OUTGOING_ARGS)
{
...
}
ACCUMULATE_OUTGOING_ARGS is defined to 1 in arm.h, so this pass is not
applied to arm back end.
2. Even if I change the condition to enable it, the stack adjustments are still
not combined.
Following are related insns:
...
(insn/f 117 116 118 2 src/t9.c:5 (set (reg/f:SI 13 sp)
(plus:SI (reg/f:SI 13 sp)
(const_int -12 [0xfffffffffffffff4]))) -1 (nil))
(insn 118 117 119 2 src/t9.c:5 (set (mem:BLK (scratch) [0 A8])
(unspec:BLK [
(reg/f:SI 13 sp)
(reg/f:SI 7 r7)
] 5)) -1 (nil))
(insn/f 119 118 120 2 src/t9.c:5 (set (reg/f:SI 7 r7)
(plus:SI (reg/f:SI 13 sp)
(const_int 0 [0x0]))) -1 (nil))
...
(insn 55 50 57 2 src/t9.c:7 (set (reg/f:SI 13 sp)
(plus:SI (reg/f:SI 13 sp)
(const_int -48 [0xffffffffffffffd0]))) 4 {*arm_addsi3} (nil))
...
Among them insn 118 trigger the following code in function
combine_stack_adjustments_for_block, and prevent the combine of stack
adjustment codes. It is emitted along with insn 117.
/* Otherwise, we were not able to process the instruction.
Do not continue collecting data across such a one. */
if (last_sp_set
&& (CALL_P (insn)
|| reg_mentioned_p (stack_pointer_rtx, PATTERN (insn))))
{
/* Clear the collected stack references. */
...
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43513
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug middle-end/43513] The stack pointer is adjusted twice
2010-03-25 9:19 [Bug target/43513] New: The stack pointer is adjusted twice carrot at google dot com
` (2 preceding siblings ...)
2010-03-26 6:42 ` carrot at google dot com
@ 2010-03-26 9:05 ` rearnsha at gcc dot gnu dot org
3 siblings, 0 replies; 12+ messages in thread
From: rearnsha at gcc dot gnu dot org @ 2010-03-26 9:05 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from rearnsha at gcc dot gnu dot org 2010-03-26 09:05 -------
This is a case where we have a 'variable length array' declaration but where
the variable is really const and well-known at compile time. However, we still
end up with it being 'variably sized' at rtl expand time.
I think it would be much better if the generic optimizers could spot this case
and remove it entirely, turning it into a natural array declartion. Then we
could eliminate even more from this function (for example, it doesn't really
need a frame pointer).
So changing to 'middle-end'.
--
rearnsha at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |rearnsha at gcc dot gnu dot
| |org
Severity|normal |enhancement
Component|target |middle-end
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43513
^ permalink raw reply [flat|nested] 12+ messages in thread
[parent not found: <bug-43513-4@http.gcc.gnu.org/bugzilla/>]
end of thread, other threads:[~2011-08-31 8:57 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-25 9:19 [Bug target/43513] New: The stack pointer is adjusted twice carrot at google dot com
2010-03-25 9:20 ` [Bug target/43513] " carrot at google dot com
2010-03-25 9:53 ` steven at gcc dot gnu dot org
2010-03-26 6:42 ` carrot at google dot com
2010-03-26 9:05 ` [Bug middle-end/43513] " rearnsha at gcc dot gnu dot org
[not found] <bug-43513-4@http.gcc.gnu.org/bugzilla/>
2011-07-27 10:57 ` rguenth at gcc dot gnu.org
2011-07-30 12:39 ` vries at gcc dot gnu.org
2011-07-31 10:03 ` vries at gcc dot gnu.org
2011-07-31 10:05 ` vries at gcc dot gnu.org
2011-08-31 7:07 ` vries at gcc dot gnu.org
2011-08-31 8:27 ` vries at gcc dot gnu.org
2011-08-31 9:43 ` vries 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).