[LLVMbugs] [Bug 14305] New: thumb2 bit test optimization opportunity

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Nov 9 14:16:28 PST 2012


http://llvm.org/bugs/show_bug.cgi?id=14305

             Bug #: 14305
           Summary: thumb2 bit test optimization opportunity
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: ARM
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: bagel99 at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Created attachment 9515
  --> http://llvm.org/bugs/attachment.cgi?id=9515
bit test example

This is a missing optimization for Thumb2 code.
A bit test on a dead variable is now done with a "tst.w reg,#bit", with
conditions EQ,NE.  It could be done with a "lsls reg,#shf" to shift the bit
into the sign bit, with conditions PL,MI.

The test program generates (on the trunk):

bittest:
    mov     r1, r0
    movs    r0, #0
    tst.w    r1, #128
    it          eq
    moveq    r0, #42
    bx        lr

It could generate, 2 bytes smaller:

bittest:
    mov     r1, r0
    movs    r0, #0
    lsls       r1, #24
    it          pl
    movpl    r0, #42
    bx        lr

Even better would be, 4 bytes smaller:

bittest:
    lsls       r0, #24
    ite        pl
    movpl    r0, #42
    movmi    r0, #0
    bx        lr

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list