public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/41653]  New: not optimal result for multiplication with constant when -Os is specified
@ 2009-10-10  9:20 carrot at google dot com
  2009-10-12 21:51 ` [Bug target/41653] " rth at gcc dot gnu dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: carrot at google dot com @ 2009-10-10  9:20 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2010-04-08  9:30 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-10  9:20 [Bug target/41653] New: not optimal result for multiplication with constant when -Os is specified carrot at google dot com
2009-10-12 21:51 ` [Bug target/41653] " rth at gcc dot gnu dot org
2009-10-15  8:19 ` carrot at google dot com
2009-10-15 10:19 ` ramana at gcc dot gnu dot org
2009-12-07  8:59 ` carrot at google dot com
2009-12-11  0:23 ` ramana at gcc dot gnu dot org
2009-12-11  0:25 ` ramana at gcc dot gnu dot org
2009-12-11  7:54 ` carrot at google dot com
2009-12-12  1:08 ` rearnsha at gcc dot gnu dot org
2010-03-20 13:00 ` steven at gcc dot gnu dot org
2010-04-08  9:28 ` carrot at gcc dot gnu dot org
2010-04-08  9:30 ` 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).