public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/40657] allocate local variables with fewer instructions
[not found] <bug-40657-4@http.gcc.gnu.org/bugzilla/>
@ 2012-06-20 18:24 ` aldot at gcc dot gnu.org
2012-06-20 18:31 ` bernds at gcc dot gnu.org
1 sibling, 0 replies; 14+ messages in thread
From: aldot at gcc dot gnu.org @ 2012-06-20 18:24 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40657
Bernhard Reutner-Fischer <aldot at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |aldot at gcc dot gnu.org
--- Comment #12 from Bernhard Reutner-Fischer <aldot at gcc dot gnu.org> 2012-06-20 18:24:29 UTC ---
Fixed?
$ arm-oe-linux-uclibceabi-gcc -Os -mthumb -march=armv5te -S pr40657.c -o -
.arch armv5te
.fpu softvfp
.eabi_attribute 20, 1
.eabi_attribute 21, 1
.eabi_attribute 23, 3
.eabi_attribute 24, 1
.eabi_attribute 25, 1
.eabi_attribute 26, 2
.eabi_attribute 30, 4
.eabi_attribute 34, 0
.eabi_attribute 18, 4
.code 16
.file "pr40657.c"
.text
.align 1
.global foo
.code 16
.thumb_func
.type foo, %function
foo:
push {r0, r1, r2, lr}
add r0, sp, #4
bl bar
@ sp needed for prologue
ldr r0, [sp, #4]
pop {r1, r2, r3, pc}
.size foo, .-foo
.ident "GCC: (GNU) 4.7.1 20120421 (prerelease)"
.section .note.GNU-stack,"",%progbits
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug target/40657] allocate local variables with fewer instructions
[not found] <bug-40657-4@http.gcc.gnu.org/bugzilla/>
2012-06-20 18:24 ` [Bug target/40657] allocate local variables with fewer instructions aldot at gcc dot gnu.org
@ 2012-06-20 18:31 ` bernds at gcc dot gnu.org
1 sibling, 0 replies; 14+ messages in thread
From: bernds at gcc dot gnu.org @ 2012-06-20 18:31 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40657
Bernd Schmidt <bernds at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |RESOLVED
CC| |bernds at gcc dot gnu.org
Resolution| |FIXED
--- Comment #13 from Bernd Schmidt <bernds at gcc dot gnu.org> 2012-06-20 18:30:54 UTC ---
Yeah.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug target/40657] allocate local variables with fewer instructions
2009-07-06 8:16 [Bug target/40657] New: " carrot at google dot com
` (10 preceding siblings ...)
2010-07-02 17:41 ` carrot at google dot com
@ 2010-07-09 9:03 ` bernds at gcc dot gnu dot org
11 siblings, 0 replies; 14+ messages in thread
From: bernds at gcc dot gnu dot org @ 2010-07-09 9:03 UTC (permalink / raw)
To: gcc-bugs
------- Comment #11 from bernds at gcc dot gnu dot org 2010-07-09 09:03 -------
Subject: Bug 40657
Author: bernds
Date: Fri Jul 9 09:03:22 2010
New Revision: 161988
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161988
Log:
PR target/40657
* config/arm/arm.c (thumb1_extra_regs_pushed): New arg FOR_PROLOGUE.
All callers changed.
Handle the case when we're called for the epilogue.
(thumb_unexpanded_epilogue): Use it.
(thumb1_expand_epilogue): Likewise.
testsuite/
PR target/40657
* gcc.target/arm/pr40657-1.c: New test.
* gcc.target/arm/pr40657-2.c: New test.
* gcc.c-torture/execute/pr40657.c: New test.
Added:
trunk/gcc/testsuite/gcc.c-torture/execute/pr40657.c
trunk/gcc/testsuite/gcc.target/arm/pr40657-1.c
trunk/gcc/testsuite/gcc.target/arm/pr40657-2.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/config/arm/arm.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40657
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug target/40657] allocate local variables with fewer instructions
2009-07-06 8:16 [Bug target/40657] New: " carrot at google dot com
` (9 preceding siblings ...)
2010-04-27 9:36 ` bernds at gcc dot gnu dot org
@ 2010-07-02 17:41 ` carrot at google dot com
2010-07-09 9:03 ` bernds at gcc dot gnu dot org
11 siblings, 0 replies; 14+ messages in thread
From: carrot at google dot com @ 2010-07-02 17:41 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from carrot at google dot com 2010-07-02 17:41 -------
The patch optimizes the prologue part only, the epilogue can also be enhanced.
Now compile the attached test case, I get
push {r0, r1, r2, lr}
add r0, sp, #4
bl bar
ldr r0, [sp, #4]
add sp, sp, #12
pop {pc}
The last two instructions can be merged as
pop {r1-r3, pc}
--
carrot at google dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|FIXED |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40657
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug target/40657] allocate local variables with fewer instructions
2009-07-06 8:16 [Bug target/40657] New: " carrot at google dot com
` (8 preceding siblings ...)
2010-04-27 9:34 ` bernds at gcc dot gnu dot org
@ 2010-04-27 9:36 ` bernds at gcc dot gnu dot org
2010-07-02 17:41 ` carrot at google dot com
2010-07-09 9:03 ` bernds at gcc dot gnu dot org
11 siblings, 0 replies; 14+ messages in thread
From: bernds at gcc dot gnu dot org @ 2010-04-27 9:36 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from bernds at gcc dot gnu dot org 2010-04-27 09:35 -------
Fixed.
--
bernds at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40657
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug target/40657] allocate local variables with fewer instructions
2009-07-06 8:16 [Bug target/40657] New: " carrot at google dot com
` (7 preceding siblings ...)
2010-03-31 21:42 ` bernds at codesourcery dot com
@ 2010-04-27 9:34 ` bernds at gcc dot gnu dot org
2010-04-27 9:36 ` bernds at gcc dot gnu dot org
` (2 subsequent siblings)
11 siblings, 0 replies; 14+ messages in thread
From: bernds at gcc dot gnu dot org @ 2010-04-27 9:34 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from bernds at gcc dot gnu dot org 2010-04-27 09:34 -------
Subject: Bug 40657
Author: bernds
Date: Tue Apr 27 09:34:08 2010
New Revision: 158771
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=158771
Log:
PR target/40657
* config/arm/arm.c (thumb1_extra_regs_pushed): New function.
(thumb1_expand_prologue, thumb1_output_function_prologue): Call it
here to determine which regs to push and how much stack to reserve.
PR target/40657
* gcc.target/arm/thumb-stackframe.c: New test.
Added:
trunk/gcc/testsuite/gcc.target/arm/thumb-stackframe.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/config/arm/arm.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40657
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug target/40657] allocate local variables with fewer instructions
2009-07-06 8:16 [Bug target/40657] New: " carrot at google dot com
` (6 preceding siblings ...)
2009-12-22 22:53 ` ramana at gcc dot gnu dot org
@ 2010-03-31 21:42 ` bernds at codesourcery dot com
2010-04-27 9:34 ` bernds at gcc dot gnu dot org
` (3 subsequent siblings)
11 siblings, 0 replies; 14+ messages in thread
From: bernds at codesourcery dot com @ 2010-03-31 21:42 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from bernds at codesourcery dot com 2010-03-31 21:42 -------
A patch is at http://gcc.gnu.org/ml/gcc-patches/2010-03/msg01274.html
--
bernds at codesourcery dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bernds at codesourcery dot
| |com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40657
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug target/40657] allocate local variables with fewer instructions
2009-07-06 8:16 [Bug target/40657] New: " carrot at google dot com
` (5 preceding siblings ...)
2009-07-13 14:23 ` rearnsha at arm dot com
@ 2009-12-22 22:53 ` ramana at gcc dot gnu dot org
2010-03-31 21:42 ` bernds at codesourcery dot com
` (4 subsequent siblings)
11 siblings, 0 replies; 14+ messages in thread
From: ramana at gcc dot gnu dot org @ 2009-12-22 22:53 UTC (permalink / raw)
To: gcc-bugs
--
ramana at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40657
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug target/40657] allocate local variables with fewer instructions
2009-07-06 8:16 [Bug target/40657] New: " carrot at google dot com
` (4 preceding siblings ...)
2009-07-07 6:45 ` carrot at google dot com
@ 2009-07-13 14:23 ` rearnsha at arm dot com
2009-12-22 22:53 ` ramana at gcc dot gnu dot org
` (5 subsequent siblings)
11 siblings, 0 replies; 14+ messages in thread
From: rearnsha at arm dot com @ 2009-07-13 14:23 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from rearnsha at arm dot com 2009-07-13 14:22 -------
Subject: Re: allocate local variables with fewer
instructions
On Mon, 2009-07-06 at 10:43 +0000, steven at gcc dot gnu dot org wrote:
> But how to do this in GCC... The "push {lr}" is never even in the
> RTL. Output with same options + "-dAP":
We already do this for ARM state. In thumb the split between epilogue
code in RTL and text makes it slightly more complex, but not massively
so.
R.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40657
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug target/40657] allocate local variables with fewer instructions
2009-07-06 8:16 [Bug target/40657] New: " carrot at google dot com
` (3 preceding siblings ...)
2009-07-06 10:43 ` steven at gcc dot gnu dot org
@ 2009-07-07 6:45 ` carrot at google dot com
2009-07-13 14:23 ` rearnsha at arm dot com
` (6 subsequent siblings)
11 siblings, 0 replies; 14+ messages in thread
From: carrot at google dot com @ 2009-07-07 6:45 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from carrot at google dot com 2009-07-07 06:44 -------
Could we do the optimization in function thumb1_expand_prologue? If we find
this opportunity in function thumb1_expand_prologue, we can remove the sp
manipulations from prologue and epilogue. We also should add extra registers to
push/pop operands.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40657
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug target/40657] allocate local variables with fewer instructions
2009-07-06 8:16 [Bug target/40657] New: " carrot at google dot com
` (2 preceding siblings ...)
2009-07-06 9:55 ` ramana at gcc dot gnu dot org
@ 2009-07-06 10:43 ` steven at gcc dot gnu dot org
2009-07-07 6:45 ` carrot at google dot com
` (7 subsequent siblings)
11 siblings, 0 replies; 14+ messages in thread
From: steven at gcc dot gnu dot org @ 2009-07-06 10:43 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from steven at gcc dot gnu dot org 2009-07-06 10:43 -------
Ah, heh, so you're saying that pushing/popping registers you don't have to save
may be a size optimization? That's an interesting idea.
But how to do this in GCC... The "push {lr}" is never even in the RTL. Output
with same options + "-dAP":
foo:
push {lr}
@ basic block 2
@(insn/f 20 2 21 t.c:3 (set (reg/f:SI 13 sp)
@ (plus:SI (reg/f:SI 13 sp)
@ (const_int -12 [0xfffffffffffffff4]))) 5 {*thumb1_addsi3} (nil))
@ 0x0000
sub sp, sp, #12 @ 20 *thumb1_addsi3/7 [length = 2]
@(insn 6 21 7 t.c:5 (set (reg:SI 0 r0)
@ (plus:SI (reg/f:SI 13 sp)
@ (const_int 4 [0x4]))) 5 {*thumb1_addsi3} (expr_list:REG_EQUAL
(plus:SI (reg/f:SI 13 sp)
@ (const_int 4 [0x4]))
@ (nil)))
@ 0x0002
add r0, sp, #4 @ 6 *thumb1_addsi3/6 [length = 2]
@(call_insn 7 6 13 t.c:5 (parallel [
@ (call (mem:SI (symbol_ref:SI ("bar") [flags 0x41] <function_decl
0x2000000000545200 bar>) [0 S4 A32])
@ (const_int 0 [0x0]))
@ (use (const_int 0 [0x0]))
@ (clobber (reg:SI 14 lr))
@ ]) 253 {*call_insn} (expr_list:REG_DEAD (reg:SI 0 r0)
@ (nil))
@ (expr_list:REG_DEP_TRUE (use (reg:SI 0 r0))
@ (nil)))
@ 0x0004
bl bar @ 7 *call_insn [length = 4]
@(insn 13 7 22 t.c:7 (set (reg/i:SI 0 r0)
@ (mem/c/i:SI (plus:SI (reg/f:SI 13 sp)
@ (const_int 4 [0x4])) [2 x+0 S4 A32])) 167 {*thumb1_movsi_insn}
(nil))
@ 0x0008
ldr r0, [sp, #4] @ 13 *thumb1_movsi_insn/7 [length = 2]
@(insn 23 22 16 t.c:7 (set (reg/f:SI 13 sp)
@ (plus:SI (reg/f:SI 13 sp)
@ (const_int 12 [0xc]))) 5 {*thumb1_addsi3} (nil))
@ 0x000a
add sp, sp, #12 @ 23 *thumb1_addsi3/7 [length = 2]
@(insn 24 16 25 t.c:7 (unspec:SI [
@ (reg/f:SI 13 sp)
@ ] 6) 339 {prologue_use} (nil))
@ 0x000c
@ sp needed for prologue @ 24 prologue_use [length = 0]
@(jump_insn 25 24 26 t.c:7 (unspec_volatile [
@ (return)
@ ] 1) 321 {*epilogue_insns} (nil))
@ 0x000c
pop {pc}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40657
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug target/40657] allocate local variables with fewer instructions
2009-07-06 8:16 [Bug target/40657] New: " carrot at google dot com
2009-07-06 8:16 ` [Bug target/40657] " carrot at google dot com
2009-07-06 9:14 ` steven at gcc dot gnu dot org
@ 2009-07-06 9:55 ` ramana at gcc dot gnu dot org
2009-07-06 10:43 ` steven at gcc dot gnu dot org
` (8 subsequent siblings)
11 siblings, 0 replies; 14+ messages in thread
From: ramana at gcc dot gnu dot org @ 2009-07-06 9:55 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from ramana at gcc dot gnu dot org 2009-07-06 09:54 -------
(In reply to comment #2)
> IIRC push-multiple and pop-multiple are not supported yet. Richard E.?
>
I am not sure what you mean here. push and pop multiple are supported to the
best of the cases that GCC can detect them. since load and store multiple are
not first class citizens, the ARM backend attempts to detect them in the form
of peephole2's and peephole's.
However this case isn't to do with push or pop multiple but to do with saving
space in the thumb prologue and epilogue by emitting push and pop multiple
instructions instead of explicit instructions to manipulate the stack. Notice
that r2 and r3 are not used in the code that Carrot is proposing in comment #1.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40657
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug target/40657] allocate local variables with fewer instructions
2009-07-06 8:16 [Bug target/40657] New: " carrot at google dot com
2009-07-06 8:16 ` [Bug target/40657] " carrot at google dot com
@ 2009-07-06 9:14 ` steven at gcc dot gnu dot org
2009-07-06 9:55 ` ramana at gcc dot gnu dot org
` (9 subsequent siblings)
11 siblings, 0 replies; 14+ messages in thread
From: steven at gcc dot gnu dot org @ 2009-07-06 9:14 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from steven at gcc dot gnu dot org 2009-07-06 09:13 -------
IIRC push-multiple and pop-multiple are not supported yet. Richard E.?
--
steven at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |rearnsha at gcc dot gnu dot
| |org
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2009-07-06 09:13:55
date| |
Summary|allocate local variables |allocate local variables
|with fewer instructions |with fewer instructions
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40657
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug target/40657] allocate local variables with fewer instructions
2009-07-06 8:16 [Bug target/40657] New: " carrot at google dot com
@ 2009-07-06 8:16 ` carrot at google dot com
2009-07-06 9:14 ` steven at gcc dot gnu dot org
` (10 subsequent siblings)
11 siblings, 0 replies; 14+ messages in thread
From: carrot at google dot com @ 2009-07-06 8:16 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from carrot at google dot com 2009-07-06 08:16 -------
Created an attachment (id=18140)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=18140&action=view)
test case
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40657
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2012-06-20 18:31 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-40657-4@http.gcc.gnu.org/bugzilla/>
2012-06-20 18:24 ` [Bug target/40657] allocate local variables with fewer instructions aldot at gcc dot gnu.org
2012-06-20 18:31 ` bernds at gcc dot gnu.org
2009-07-06 8:16 [Bug target/40657] New: " carrot at google dot com
2009-07-06 8:16 ` [Bug target/40657] " carrot at google dot com
2009-07-06 9:14 ` steven at gcc dot gnu dot org
2009-07-06 9:55 ` ramana at gcc dot gnu dot org
2009-07-06 10:43 ` steven at gcc dot gnu dot org
2009-07-07 6:45 ` carrot at google dot com
2009-07-13 14:23 ` rearnsha at arm dot com
2009-12-22 22:53 ` ramana at gcc dot gnu dot org
2010-03-31 21:42 ` bernds at codesourcery dot com
2010-04-27 9:34 ` bernds at gcc dot gnu dot org
2010-04-27 9:36 ` bernds at gcc dot gnu dot org
2010-07-02 17:41 ` carrot at google dot com
2010-07-09 9:03 ` bernds at gcc dot gnu dot 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).