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

* [Bug target/41653] not optimal result for multiplication with constant when -Os is specified
  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 ` rth at gcc dot gnu dot org
  2009-10-15  8:19 ` carrot at google dot com
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rth at gcc dot gnu dot org @ 2009-10-12 21:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rth at gcc dot gnu dot org  2009-10-12 21:51 -------
The expand pass relies on the rtx cost model to be correct.
I assume that arm_size_rtx_costs is models multiply incorrectly.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41653


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

* [Bug target/41653] not optimal result for multiplication with constant when -Os is specified
  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
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: carrot at google dot com @ 2009-10-15  8:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from carrot at google dot com  2009-10-15 08:18 -------
arm_size_rtx_costs calls thumb1_rtx_costs for TARGET_THUMB1.

thumb1_rtx_costs is also called by several other functions. Looked at its
implementation briefly, it is actually tuned for speed only. Following are some
obvious example:

    case UDIV:
    case UMOD:
    case DIV:
    case MOD:
      return 100;

    case TRUNCATE:
      return 99;

So a new function thumb1_size_rtx_costs is required to model the thumb1 size
feature, right?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41653


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

* [Bug target/41653] not optimal result for multiplication with constant when -Os is specified
  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
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: ramana at gcc dot gnu dot org @ 2009-10-15 10:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from ramana at gcc dot gnu dot org  2009-10-15 10:19 -------
Confirmed. 


-- 

ramana at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2009-10-15 10:19:37
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41653


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

* [Bug target/41653] not optimal result for multiplication with constant when -Os is specified
  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
                   ` (2 preceding siblings ...)
  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
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: carrot at google dot com @ 2009-12-07  8:59 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from carrot at google dot com  2009-12-07 08:58 -------
Created an attachment (id=19247)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19247&action=view)
patch

The attached patch can fix this bug. But due to
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42258, it can't bring any benefit
at now.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41653


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

* [Bug target/41653] not optimal result for multiplication with constant when -Os is specified
  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
                   ` (3 preceding siblings ...)
  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
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: ramana at gcc dot gnu dot org @ 2009-12-11  0:23 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from ramana at gcc dot gnu dot org  2009-12-11 00:22 -------
(In reply to comment #4)
> Created an attachment (id=19247)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19247&action=view) [edit]
> patch
> 
> The attached patch can fix this bug. But due to
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42258, it can't bring any benefit
> at now.
> 

Please submit patches to gcc-patches@gcc.gnu.org rather than attaching it to
the bug report. 

Ramana


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41653


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

* [Bug target/41653] not optimal result for multiplication with constant when -Os is specified
  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
                   ` (4 preceding siblings ...)
  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
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: ramana at gcc dot gnu dot org @ 2009-12-11  0:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from ramana at gcc dot gnu dot org  2009-12-11 00:25 -------
(In reply to comment #5)

> Please submit patches to gcc-patches@gcc.gnu.org rather than attaching it to
> the bug report. 

Also when doing so can you measure the impact of your patch with CSIBe and see
code size numbers ? 


Thanks,
Ramana

> 
> Ramana
> 


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41653


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

* [Bug target/41653] not optimal result for multiplication with constant when -Os is specified
  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
                   ` (5 preceding siblings ...)
  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
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: carrot at google dot com @ 2009-12-11  7:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from carrot at google dot com  2009-12-11 07:54 -------
(In reply to comment #6)
> (In reply to comment #5)
> 
> > Please submit patches to gcc-patches@gcc.gnu.org rather than attaching it to
> > the bug report. 
> 
> Also when doing so can you measure the impact of your patch with CSIBe and see
> code size numbers ? 
> 
Because of http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42258, this patch can't
reduce instructions, actually it brings one more instruction. Only when that
regression has been fixed, this patch can then take effect. I will do
thoroughly testing and evaluation after that.


-- 

carrot at google dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |42258


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41653


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

* [Bug target/41653] not optimal result for multiplication with constant when -Os is specified
  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
                   ` (6 preceding siblings ...)
  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
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rearnsha at gcc dot gnu dot org @ 2009-12-12  1:08 UTC (permalink / raw)
  To: gcc-bugs



-- 

rearnsha at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41653


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

* [Bug target/41653] not optimal result for multiplication with constant when -Os is specified
  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
                   ` (7 preceding siblings ...)
  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
  10 siblings, 0 replies; 12+ messages in thread
From: steven at gcc dot gnu dot org @ 2010-03-20 13:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from steven at gcc dot gnu dot org  2010-03-20 12:59 -------
Carrot, re. your comment #7: Time for that thoroughly testing.


-- 

steven at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |WAITING


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41653


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

* [Bug target/41653] not optimal result for multiplication with constant when -Os is specified
  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
                   ` (8 preceding siblings ...)
  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
  10 siblings, 0 replies; 12+ messages in thread
From: carrot at gcc dot gnu dot org @ 2010-04-08  9:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from carrot at gcc dot gnu dot org  2010-04-08 09:27 -------
Subject: Bug 41653

Author: carrot
Date: Thu Apr  8 09:27:44 2010
New Revision: 158110

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=158110
Log:
        PR target/41653
        * config/arm/arm.c (thumb1_size_rtx_costs): New function.
        (arm_size_rtx_costs): Call the new function when optimized for size.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/arm/arm.c


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41653


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

* [Bug target/41653] not optimal result for multiplication with constant when -Os is specified
  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
                   ` (9 preceding siblings ...)
  2010-04-08  9:28 ` carrot at gcc dot gnu dot org
@ 2010-04-08  9:30 ` carrot at google dot com
  10 siblings, 0 replies; 12+ messages in thread
From: carrot at google dot com @ 2010-04-08  9:30 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from carrot at google dot com  2010-04-08 09:29 -------
Fixed by the above patch.


-- 

carrot at google dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|                            |FIXED


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).