[llvm-bugs] [Bug 32293] New: Mips2 and Mips3 produce inefficient lowerings for partial shifts

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Mar 15 16:06:12 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=32293

            Bug ID: 32293
           Summary: Mips2 and Mips3 produce inefficient lowerings for
                    partial shifts
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: MIPS
          Assignee: unassignedbugs at nondot.org
          Reporter: kyle+llvm at iteratee.net
                CC: llvm-bugs at lists.llvm.org

Mips2 and Mips3 produce inefficient lowerings for partial shifts:

on Mips2 shl lowers to code that looks like:

if (!x)
 ... (Don't modify x)
if (!x)
 ...

specifically:

# BB#0:                                 # %entry
        sllv    $1, $5, $7
        andi    $6, $7, 32
        bnez    $6, $BB4_2
        move     $2, $1
# BB#1:                                 # %entry
        sllv    $2, $4, $7
        not     $3, $7
        srl     $4, $5, 1
        srlv    $3, $4, $3
        or      $2, $2, $3
$BB4_2:                                 # %entry
        bnez    $6, $BB4_4
        addiu   $3, $zero, 0
# BB#3:                                 # %entry
        move     $3, $1
$BB4_4:                                 # %entry
        jr      $ra
        nop

With more careful lowering, the double compare can be eliminated:

# BB#0:                                 # %entry
        andi    $6, $7, 32
        beqz    $6, $BB4_2
        sllv    $1, $5, $7
# BB#1:
        move     $2, $1
        jr      $ra
        addiu   $3, $zero, 0
$BB4_2:                                 # %entry
        sllv    $2, $4, $7
        not     $3, $7
        srl     $4, $5, 1
        srlv    $3, $4, $3
        jr      $ra
        or      $2, $2, $3

The lowering produces 2 selects which each create a branch instruction on the
same condition.

If we're worried about this, we could try to produce better code for these
targets in selection dag.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170315/0f280b88/attachment.html>


More information about the llvm-bugs mailing list