public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/43491] New: Unnecessary temporary for global register variable
@ 2010-03-23 14:21 mirq-gccboogs at rere dot qmqm dot pl
2010-09-08 16:22 ` [Bug rtl-optimization/43491] " ibolton at gcc dot gnu dot org
0 siblings, 1 reply; 2+ messages in thread
From: mirq-gccboogs at rere dot qmqm dot pl @ 2010-03-23 14:21 UTC (permalink / raw)
To: gcc-bugs
gcc sometimes allocates a temporary register for a variable that is global and
has a fixed register. This happens when:
a. the global is a register-fixed variable
b. global is a pointer to structure
c. an address of structure's field is passed as argument to inlined function
d. the global is marked as constant
code:
struct b {
unsigned g,h,j;
};
register struct b *const reg asm("r4");
static inline int diff(unsigned *p)
{
return *p;
}
void c(void);
void d(void)
{
while (diff(®->j))
c();
}
generates:
d:
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, uses_anonymous_args = 0
ldr r3, [r4, #8] @ first ok
push {r5, lr}
mov r5, r4 @ an temporary even when r4 is marked const
cbz r3, .L1
.L4:
bl c
ldr r3, [r5, #8] @ accesses via temporary
cmp r3, #0
bne .L4
.L1:
pop {r5, pc}
--
Summary: Unnecessary temporary for global register variable
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: rtl-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: mirq-gccboogs at rere dot qmqm dot pl
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: arm-none-eabi
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43491
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug rtl-optimization/43491] Unnecessary temporary for global register variable
2010-03-23 14:21 [Bug rtl-optimization/43491] New: Unnecessary temporary for global register variable mirq-gccboogs at rere dot qmqm dot pl
@ 2010-09-08 16:22 ` ibolton at gcc dot gnu dot org
0 siblings, 0 replies; 2+ messages in thread
From: ibolton at gcc dot gnu dot org @ 2010-09-08 16:22 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from ibolton at gcc dot gnu dot org 2010-09-08 16:21 -------
reg is assigned to a temporary (reg.0) at the very first tree pass, as shown by
this 004t.gimple dump:
d ()
{
struct b * const reg.0;
unsigned int * D.2019;
int D.2020;
goto <D.1276>;
<D.1275>:
c ();
<D.1276>:
reg.0 = reg;
D.2019 = ®.0->j;
D.2020 = diff (D.2019);
if (D.2020 != 0) goto <D.1275>; else goto <D.1277>;
<D.1277>:
}
I'm thinking that this is perfectly normal thing to do, and that the redundant
move is meant to disappear in a later pass. My guess is that IRA is choosing
not to assign the pseudo to r4, but I do not know why at the moment.
--
ibolton at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Keywords| |missed-optimization, ra
Known to fail| |4.5.3 4.6.0
Last reconfirmed|0000-00-00 00:00:00 |2010-09-08 16:21:50
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43491
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-09-08 16:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-23 14:21 [Bug rtl-optimization/43491] New: Unnecessary temporary for global register variable mirq-gccboogs at rere dot qmqm dot pl
2010-09-08 16:22 ` [Bug rtl-optimization/43491] " ibolton 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).