public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/46092] New: Improve constant handling of thumb2 instructions
@ 2010-10-20 9:20 carrot at google dot com
2010-10-27 16:04 ` [Bug target/46092] " ibolton at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: carrot at google dot com @ 2010-10-20 9:20 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46092
Summary: Improve constant handling of thumb2 instructions
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: carrot@google.com
CC: carrot@google.com
Host: i686-linux
Target: arm-eabi
Build: i686-linux
Compile the following code with options -march=armv7-a -mthumb -Os
unsigned long tv(unsigned long x)
{
if (x >= 65521)
x = x - 65521;
return x;
}
gcc generates:
tv:
movw r3, #65520
cmp r0, r3
ittt hi
subhi r0, r0, #65024 // A
subhi r0, r0, #496 // B
subhi r0, r0, #1 // C
bx lr
Notice that (x = x - 65521) is translated into 3 instructions. Actually 65521
can be loaded into register with one instruction. So the shorter result is:
tv:
movw r3, #65520
cmp r0, r3
ittt hi
movwhi r1, #65521
subhi r0, r1
bx lr
This should be improved by function arm_gen_constant. The function is already
commented with
/* ??? This needs more work for thumb2. */
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/46092] Improve constant handling of thumb2 instructions
2010-10-20 9:20 [Bug target/46092] New: Improve constant handling of thumb2 instructions carrot at google dot com
@ 2010-10-27 16:04 ` ibolton at gcc dot gnu.org
2010-12-10 17:24 ` ams at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: ibolton at gcc dot gnu.org @ 2010-10-27 16:04 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46092
Ian Bolton <ibolton at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |missed-optimization
Status|UNCONFIRMED |NEW
Last reconfirmed| |2010.10.27 16:03:59
CC| |ibolton at gcc dot gnu.org
Ever Confirmed|0 |1
Known to fail| |4.6.0
--- Comment #1 from Ian Bolton <ibolton at gcc dot gnu.org> 2010-10-27 16:03:59 UTC ---
Confirmed on trunk, revision 165513.
In your example, another way would be to subtract r3 (#65520) and then #1.
Note: neither -O3 or -O2 can avoid the three subhi instruction, currently.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/46092] Improve constant handling of thumb2 instructions
2010-10-20 9:20 [Bug target/46092] New: Improve constant handling of thumb2 instructions carrot at google dot com
2010-10-27 16:04 ` [Bug target/46092] " ibolton at gcc dot gnu.org
@ 2010-12-10 17:24 ` ams at gcc dot gnu.org
2010-12-10 17:27 ` ams at gcc dot gnu.org
2012-02-24 12:48 ` ramana at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: ams at gcc dot gnu.org @ 2010-12-10 17:24 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46092
Andrew Stubbs <ams at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
CC| |ams at gcc dot gnu.org
AssignedTo|unassigned at gcc dot |ams at gcc dot gnu.org
|gnu.org |
--- Comment #2 from Andrew Stubbs <ams at gcc dot gnu.org> 2010-12-10 17:23:51 UTC ---
I've posted a patch to fix this issue (among others):
http://gcc.gnu.org/ml/gcc-patches/2010-12/msg00652.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/46092] Improve constant handling of thumb2 instructions
2010-10-20 9:20 [Bug target/46092] New: Improve constant handling of thumb2 instructions carrot at google dot com
2010-10-27 16:04 ` [Bug target/46092] " ibolton at gcc dot gnu.org
2010-12-10 17:24 ` ams at gcc dot gnu.org
@ 2010-12-10 17:27 ` ams at gcc dot gnu.org
2012-02-24 12:48 ` ramana at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: ams at gcc dot gnu.org @ 2010-12-10 17:27 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46092
--- Comment #3 from Andrew Stubbs <ams at gcc dot gnu.org> 2010-12-10 17:27:04 UTC ---
Oh, I should say, what it actually does is this:
subhi r0, r0, #65280 ; 0xff00
subhi r0, r0, #241 ; 0x00f1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/46092] Improve constant handling of thumb2 instructions
2010-10-20 9:20 [Bug target/46092] New: Improve constant handling of thumb2 instructions carrot at google dot com
` (2 preceding siblings ...)
2010-12-10 17:27 ` ams at gcc dot gnu.org
@ 2012-02-24 12:48 ` ramana at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: ramana at gcc dot gnu.org @ 2012-02-24 12:48 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46092
Ramana Radhakrishnan <ramana at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
CC| |ramana at gcc dot gnu.org
Resolution| |FIXED
Target Milestone|--- |4.7.0
Severity|normal |enhancement
--- Comment #4 from Ramana Radhakrishnan <ramana at gcc dot gnu.org> 2012-02-24 12:24:04 UTC ---
Trunk generates this today. Thus fixed.
Ramana
tv:
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, uses_anonymous_args = 0
@ link register save eliminated.
movw r3, #65520
cmp r0, r3
itt hi
subhi r0, r0, #65280
subhi r0, r0, #241
bx lr
.size tv, .-tv
.ident "GCC: (GNU) 4.7.0 20120116 (experimental)"
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-02-24 12:24 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-20 9:20 [Bug target/46092] New: Improve constant handling of thumb2 instructions carrot at google dot com
2010-10-27 16:04 ` [Bug target/46092] " ibolton at gcc dot gnu.org
2010-12-10 17:24 ` ams at gcc dot gnu.org
2010-12-10 17:27 ` ams at gcc dot gnu.org
2012-02-24 12:48 ` ramana 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).