public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/46631] New: Change operands order so we can use 16bit and instead of 32bit in thumb2
@ 2010-11-24  2:57 carrot at google dot com
  2010-11-24 12:09 ` [Bug target/46631] " rguenth at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: carrot at google dot com @ 2010-11-24  2:57 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: Change operands order so we can use 16bit and 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


Compile the following code with options -march=armv7-a -mthumb -Os

struct S {
      int bi_buf;
      int bi_valid;
};

int tz (struct S* p, int bits, int value)
{
      if (p == 0) return 1;
      p->bi_valid = bits;
      p->bi_buf = value & ((1 << bits) - 1);
      return 0;
}

GCC 4.6 generates:

00000000 <tz>:
   0:    2301          movs    r3, #1
   2:    b138          cbz    r0, 14 <tz+0x14>
   4:    408b          lsls    r3, r1
   6:    6041          str    r1, [r0, #4]
   8:    3b01          subs    r3, #1
   a:    ea03 0202     and.w    r2, r3, r2             // A
   e:    6002          str    r2, [r0, #0]
  10:    2000          movs    r0, #0
  12:    4770          bx    lr
  14:    4618          mov    r0, r3
  16:    4770          bx    lr

Notice instruction A is 32 bit, if we change it to

   and  r2, r2, r3

then we can encode it as 16bit.


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

end of thread, other threads:[~2010-12-08 16:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-24  2:57 [Bug target/46631] New: Change operands order so we can use 16bit and instead of 32bit in thumb2 carrot at google dot com
2010-11-24 12:09 ` [Bug target/46631] " rguenth at gcc dot gnu.org
2010-12-03  9:55 ` ramana at gcc dot gnu.org
2010-12-08 16:38 ` rearnsha at gcc dot gnu.org
2010-12-08 16:49 ` rearnsha 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).