[Bug target/41653] New: not optimal result for multiplication with constant when -Os is specified
carrot at google dot com
gcc-bugzilla@gcc.gnu.org
Sat Oct 10 09:20:00 GMT 2009
Compile the following code with options -Os -mthumb -march=armv5te
int mul12(int x)
{
return x*12;
}
Gcc generates:
lsl r3, r0, #1
add r0, r3, r0
lsl r0, r0, #2
@ sp needed for prologue
bx lr
This code sequence may be good for speed. But when we optimize for size, we can
get shorter code sequence:
mov r3, 12
mul r0, r3, r0
bx lr
These code is generated by the expand pass. We may consider to generate
different instructions when optimize for size.
This kind of multiplication is usually found in computing the address of an
array element.
--
Summary: not optimal result for multiplication with constant when
-Os is specified
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=41653
More information about the Gcc-bugs
mailing list