public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/42879]  New: Replace "tst  r3, 1" with "lsl r3, r3, 31" in thumb2
@ 2010-01-27  0:31 carrot at google dot com
  2010-01-27 10:25 ` [Bug target/42879] " rguenth at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: carrot at google dot com @ 2010-01-27  0:31 UTC (permalink / raw)
  To: gcc-bugs

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

struct A
{
  bool v:1;
};

bool bar();

bool foo(struct A* p)
{
  if (p->v)
    return true;
  return bar();
}

Gcc generates

_Z3fooP1A:
        push    {r3, lr}
        .save {r3, lr}
.LCFI0:
        ldrb    r3, [r0, #0]    @ zero_extendqisi2
        tst     r3, #1
        bne     .L3
        bl      _Z3barv
        b       .L2
.L3:
        movs    r0, #1
.L2:
        pop     {r3, pc}

The "tst  r3, #1" is a 32 bit instruction, it can be replaced by a 16 bit
instruction "lsl r3, r3, 31" while still retain the original semantics.


-- 
           Summary: Replace "tst  r3, 1" with "lsl r3, r3, 31" in thumb2
           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=42879


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

* [Bug target/42879] Replace "tst  r3, 1" with "lsl r3, r3, 31" in thumb2
  2010-01-27  0:31 [Bug target/42879] New: Replace "tst r3, 1" with "lsl r3, r3, 31" in thumb2 carrot at google dot com
@ 2010-01-27 10:25 ` rguenth at gcc dot gnu dot org
  2010-01-29 23:32 ` ramana at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-01-27 10:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2010-01-27 10:25 -------
Could be done in a peephole if there's a scratch available for the destination.


-- 

rguenth 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         |2010-01-27 10:25:46
               date|                            |


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


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

* [Bug target/42879] Replace "tst  r3, 1" with "lsl r3, r3, 31" in thumb2
  2010-01-27  0:31 [Bug target/42879] New: Replace "tst r3, 1" with "lsl r3, r3, 31" in thumb2 carrot at google dot com
  2010-01-27 10:25 ` [Bug target/42879] " rguenth at gcc dot gnu dot org
@ 2010-01-29 23:32 ` ramana at gcc dot gnu dot org
  2010-03-19 18:42 ` steven at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: ramana at gcc dot gnu dot org @ 2010-01-29 23:32 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from ramana at gcc dot gnu dot org  2010-01-29 23:32 -------
(In reply to comment #1)
> Could be done in a peephole if there's a scratch available for the destination.
> 

We already do this for Thumb1 don't we ? Turning on *tlobits_cbranch and the
appropriate bit in arm.c should be enough but GAS doesn't want to assemble lsl
r2,r3, #1 as a 16 bit instruction yet. 

cheers
Ramana


-- 


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


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

* [Bug target/42879] Replace "tst  r3, 1" with "lsl r3, r3, 31" in thumb2
  2010-01-27  0:31 [Bug target/42879] New: Replace "tst r3, 1" with "lsl r3, r3, 31" in thumb2 carrot at google dot com
  2010-01-27 10:25 ` [Bug target/42879] " rguenth at gcc dot gnu dot org
  2010-01-29 23:32 ` ramana at gcc dot gnu dot org
@ 2010-03-19 18:42 ` steven at gcc dot gnu dot org
  2010-04-24 11:53 ` carrot at google dot com
  2010-05-11  3:22 ` carrot at google dot com
  4 siblings, 0 replies; 6+ messages in thread
From: steven at gcc dot gnu dot org @ 2010-03-19 18:42 UTC (permalink / raw)
  To: gcc-bugs



-- 

steven at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
OtherBugsDependingO|                            |16996
              nThis|                            |
           Severity|normal                      |enhancement


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


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

* [Bug target/42879] Replace "tst  r3, 1" with "lsl r3, r3, 31" in thumb2
  2010-01-27  0:31 [Bug target/42879] New: Replace "tst r3, 1" with "lsl r3, r3, 31" in thumb2 carrot at google dot com
                   ` (2 preceding siblings ...)
  2010-03-19 18:42 ` steven at gcc dot gnu dot org
@ 2010-04-24 11:53 ` carrot at google dot com
  2010-05-11  3:22 ` carrot at google dot com
  4 siblings, 0 replies; 6+ messages in thread
From: carrot at google dot com @ 2010-04-24 11:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from carrot at google dot com  2010-04-24 11:53 -------
lsls  r2,r3, #1   can be assembled to 16 bit.

lsl   r2,r3, #1  is 32 bit because only 32 bit encoding can ignore condition
code.


-- 


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


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

* [Bug target/42879] Replace "tst  r3, 1" with "lsl r3, r3, 31" in thumb2
  2010-01-27  0:31 [Bug target/42879] New: Replace "tst r3, 1" with "lsl r3, r3, 31" in thumb2 carrot at google dot com
                   ` (3 preceding siblings ...)
  2010-04-24 11:53 ` carrot at google dot com
@ 2010-05-11  3:22 ` carrot at google dot com
  4 siblings, 0 replies; 6+ messages in thread
From: carrot at google dot com @ 2010-05-11  3:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from carrot at google dot com  2010-05-11 03:21 -------
Fixed by http://gcc.gnu.org/ml/gcc-cvs/2010-05/msg00263.html.


-- 

carrot at google dot com changed:

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


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


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

end of thread, other threads:[~2010-05-11  3:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-27  0:31 [Bug target/42879] New: Replace "tst r3, 1" with "lsl r3, r3, 31" in thumb2 carrot at google dot com
2010-01-27 10:25 ` [Bug target/42879] " rguenth at gcc dot gnu dot org
2010-01-29 23:32 ` ramana at gcc dot gnu dot org
2010-03-19 18:42 ` steven at gcc dot gnu dot org
2010-04-24 11:53 ` carrot at google dot com
2010-05-11  3:22 ` 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).