public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/46127] New: Use 16bit add instead of 32bit in thumb2
@ 2010-10-22  7:32 carrot at google dot com
  2010-10-27 16:18 ` [Bug target/46127] " 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-22  7:32 UTC (permalink / raw)
  To: gcc-bugs

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.


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

* [Bug target/46127] Use 16bit add instead of 32bit in thumb2
  2010-10-22  7:32 [Bug target/46127] New: Use 16bit add instead of 32bit in thumb2 carrot at google dot com
@ 2010-10-27 16:18 ` ibolton at gcc dot gnu.org
  2011-03-25 20:05 ` jakub 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:18 UTC (permalink / raw)
  To: gcc-bugs

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

Ian Bolton <ibolton at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |missed-optimization
   Last reconfirmed|                            |2010.10.27 16:18:15
                 CC|                            |ibolton at gcc dot gnu.org
     Ever Confirmed|0                           |1
   Target Milestone|---                         |4.6.0
           Severity|normal                      |minor

--- Comment #1 from Ian Bolton <ibolton at gcc dot gnu.org> 2010-10-27 16:18:15 UTC ---
I think the scheduler would have to bias against doing anything that *could* be
16-bit (if register allocation permitted) earlier than always 32-bit
instructions (regardless of register allocation) IFF an operand is shared
between them, and then leave it to IRA to re-use r0 for B and lead to a 16-bit
instruction being emitted.

I expect this kind of heuristic could lead to unfortunate regressions (unlucky
knock-on effects of seemingly arbitrary rule changes) but it could also lead to
some wins, like in your example.

I've set this to P4 minor.


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

* [Bug target/46127] Use 16bit add instead of 32bit in thumb2
  2010-10-22  7:32 [Bug target/46127] New: Use 16bit add instead of 32bit in thumb2 carrot at google dot com
  2010-10-27 16:18 ` [Bug target/46127] " ibolton at gcc dot gnu.org
@ 2011-03-25 20:05 ` jakub at gcc dot gnu.org
  2011-04-28 17:02 ` rguenth at gcc dot gnu.org
  2023-05-15  5:11 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-03-25 20:05 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.6.0                       |4.6.1

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-03-25 19:52:53 UTC ---
GCC 4.6.0 is being released, adjusting target milestone.


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

* [Bug target/46127] Use 16bit add instead of 32bit in thumb2
  2010-10-22  7:32 [Bug target/46127] New: Use 16bit add instead of 32bit in thumb2 carrot at google dot com
  2010-10-27 16:18 ` [Bug target/46127] " ibolton at gcc dot gnu.org
  2011-03-25 20:05 ` jakub at gcc dot gnu.org
@ 2011-04-28 17:02 ` rguenth at gcc dot gnu.org
  2023-05-15  5:11 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-04-28 17:02 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.6.1                       |---


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

* [Bug target/46127] Use 16bit add instead of 32bit in thumb2
  2010-10-22  7:32 [Bug target/46127] New: Use 16bit add instead of 32bit in thumb2 carrot at google dot com
                   ` (2 preceding siblings ...)
  2011-04-28 17:02 ` rguenth at gcc dot gnu.org
@ 2023-05-15  5:11 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-15  5:11 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46127

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|minor                       |enhancement
   Last reconfirmed|2010-10-27 16:18:15         |2023-5-14

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

end of thread, other threads:[~2023-05-15  5:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-22  7:32 [Bug target/46127] New: Use 16bit add instead of 32bit in thumb2 carrot at google dot com
2010-10-27 16:18 ` [Bug target/46127] " ibolton at gcc dot gnu.org
2011-03-25 20:05 ` jakub at gcc dot gnu.org
2011-04-28 17:02 ` rguenth at gcc dot gnu.org
2023-05-15  5:11 ` pinskia 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).