public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/46092] New: Improve constant handling of thumb2 instructions
@ 2010-10-20  9:20 carrot at google dot com
  2010-10-27 16:04 ` [Bug target/46092] " 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-20  9:20 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: Improve constant handling of thumb2 instructions
           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 tv(unsigned long x)
{
  if (x >= 65521)
    x = x - 65521;
  return x;
}

gcc generates:

tv:
        movw    r3, #65520
        cmp     r0, r3
        ittt    hi
        subhi   r0, r0, #65024   // A
        subhi   r0, r0, #496     // B
        subhi   r0, r0, #1       // C
        bx      lr

Notice that (x = x - 65521) is translated into 3 instructions. Actually 65521
can be loaded into register with one instruction. So the shorter result is:

tv:
        movw    r3, #65520
        cmp     r0, r3
        ittt    hi
        movwhi   r1, #65521
        subhi   r0, r1
        bx      lr

This should be improved by function arm_gen_constant. The function is already
commented with
/* ??? This needs more work for thumb2.  */


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

end of thread, other threads:[~2012-02-24 12:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-20  9:20 [Bug target/46092] New: Improve constant handling of thumb2 instructions carrot at google dot com
2010-10-27 16:04 ` [Bug target/46092] " ibolton at gcc dot gnu.org
2010-12-10 17:24 ` ams at gcc dot gnu.org
2010-12-10 17:27 ` ams at gcc dot gnu.org
2012-02-24 12:48 ` ramana 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).