[Bug target/46127] New: Use 16bit add instead of 32bit in thumb2
carrot at google dot com
gcc-bugzilla@gcc.gnu.org
Fri Oct 22 07:32:00 GMT 2010
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46127
Summary: Use 16bit add instead of 32bit in thumb2
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 compressBound (unsigned long sourceLen)
{
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
(sourceLen >> 25) + 13;
}
GCC 4.6 generates:
compressBound:
add r3, r0, #13 // A
add r3, r3, r0, lsr #12
add r3, r3, r0, lsr #14
add r0, r3, r0, lsr #25
bx lr
We can change the instruction order and register a little
compressBound:
add r3, r0, r0, lsr #12
add r3, r3, r0, lsr #14
add r0, r3, r0, lsr #25
add r0, r0, #13 // B
bx lr
Now instruction A becomes instruction B. Instruction A is 32 bit, instruction B
is 16 bit, so it becomes shorter.
Don't know how to handle it in compiler.
More information about the Gcc-bugs
mailing list