public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/42601] New: Simplify code to address function static variables with option -fpic
@ 2010-01-04 2:20 carrot at google dot com
2010-01-04 14:26 ` [Bug target/42601] " rguenth at gcc dot gnu dot org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: carrot at google dot com @ 2010-01-04 2:20 UTC (permalink / raw)
To: gcc-bugs
Compile following code with options -mthumb -fpic -Os,
int foo(int j)
{
static int i;
int t = i;
i = j;
return t;
}
GCC generates:
foo:
ldr r3, .L2 // A
ldr r2, .L2+4 // B
.LPIC0:
add r3, pc // C
add r3, r3, r2 // D
ldr r2, [r3]
@ sp needed for prologue
str r0, [r3]
mov r0, r2
bx lr
.L3:
.align 2
.L2:
.word _GLOBAL_OFFSET_TABLE_-(.LPIC0+4)
.word .LANCHOR0(GOTOFF)
".word _GLOBAL_OFFSET_TABLE_-(.LPIC0+4)" is the GOT table address relative to
instruction C, ".word .LANCHOR0(GOTOFF)" is offset of symbol .LANCHOR0
relative to GOT table. So firstly instruction AC computes the GOT table
address, then instruciton BD add the offset of variable i relative to GOT
table. Actually it is not necessary to compute the GOT address. The better code
can be:
foo:
ldr r3, .L2 // E
.LPIC0:
add r3, pc // F
ldr r2, [r3]
@ sp needed for prologue
str r0, [r3]
mov r0, r2
bx lr
.L3:
.align 2
.L2:
.word .LANCHOR0-(.LPIC0+4) //offset of i relative to instruction
F
Now it has two less instructions, 1 less memory access and smaller constant
pool.
--
Summary: Simplify code to address function static variables with
option -fpic
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=42601
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/42601] Simplify code to address function static variables with option -fpic
2010-01-04 2:20 [Bug target/42601] New: Simplify code to address function static variables with option -fpic carrot at google dot com
@ 2010-01-04 14:26 ` rguenth at gcc dot gnu dot org
2010-01-05 18:20 ` ramana at gcc dot gnu dot org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-01-04 14:26 UTC (permalink / raw)
To: gcc-bugs
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
Keywords| |missed-optimization
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42601
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/42601] Simplify code to address function static variables with option -fpic
2010-01-04 2:20 [Bug target/42601] New: Simplify code to address function static variables with option -fpic carrot at google dot com
2010-01-04 14:26 ` [Bug target/42601] " rguenth at gcc dot gnu dot org
@ 2010-01-05 18:20 ` ramana at gcc dot gnu dot org
2010-04-10 13:14 ` carrot at gcc dot gnu dot org
2010-04-10 13:18 ` carrot at google dot com
3 siblings, 0 replies; 5+ messages in thread
From: ramana at gcc dot gnu dot org @ 2010-01-05 18:20 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from ramana at gcc dot gnu dot org 2010-01-05 18:20 -------
Confirmed but definitely an enhancement.
--
ramana 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-01-05 18:20:29
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42601
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/42601] Simplify code to address function static variables with option -fpic
2010-01-04 2:20 [Bug target/42601] New: Simplify code to address function static variables with option -fpic carrot at google dot com
2010-01-04 14:26 ` [Bug target/42601] " rguenth at gcc dot gnu dot org
2010-01-05 18:20 ` ramana at gcc dot gnu dot org
@ 2010-04-10 13:14 ` carrot at gcc dot gnu dot org
2010-04-10 13:18 ` carrot at google dot com
3 siblings, 0 replies; 5+ messages in thread
From: carrot at gcc dot gnu dot org @ 2010-04-10 13:14 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from carrot at gcc dot gnu dot org 2010-04-10 13:14 -------
Subject: Bug 42601
Author: carrot
Date: Sat Apr 10 13:13:47 2010
New Revision: 158189
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=158189
Log:
PR target/42601
* config/arm/arm.c (arm_pic_static_addr): New function.
(legitimize_pic_address): Call arm_pic_static_addr when it detects
a static symbol.
(arm_output_addr_const_extra): Output expression for new pattern.
* config/arm/arm.md (UNSPEC_SYMBOL_OFFSET): New unspec symbol.
Modified:
trunk/gcc/ChangeLog
trunk/gcc/config/arm/arm.c
trunk/gcc/config/arm/arm.md
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42601
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/42601] Simplify code to address function static variables with option -fpic
2010-01-04 2:20 [Bug target/42601] New: Simplify code to address function static variables with option -fpic carrot at google dot com
` (2 preceding siblings ...)
2010-04-10 13:14 ` carrot at gcc dot gnu dot org
@ 2010-04-10 13:18 ` carrot at google dot com
3 siblings, 0 replies; 5+ messages in thread
From: carrot at google dot com @ 2010-04-10 13:18 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from carrot at google dot com 2010-04-10 13:17 -------
Fixed by patch http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=158189.
--
carrot at google dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42601
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-04-10 13:18 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-04 2:20 [Bug target/42601] New: Simplify code to address function static variables with option -fpic carrot at google dot com
2010-01-04 14:26 ` [Bug target/42601] " rguenth at gcc dot gnu dot org
2010-01-05 18:20 ` ramana at gcc dot gnu dot org
2010-04-10 13:14 ` carrot at gcc dot gnu dot org
2010-04-10 13:18 ` carrot at google dot com
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).