[llvm-bugs] [Bug 32690] New: [X86] SBB/AND used instead of XOR/ADC

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Apr 17 20:02:47 PDT 2017


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

            Bug ID: 32690
           Summary: [X86] SBB/AND used instead of XOR/ADC
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: craig.topper at gmail.com
                CC: llvm-bugs at lists.llvm.org

On 32-bit targets this C code

unsigned bar(unsigned bitWidth) {
  return ((uint64_t)bitWidth + 63) / 64;
}

Produces this assembly output

_bar:                                   ## @bar
## BB#0:                                ## %entry
        movl    4(%esp), %ecx
        addl    $63, %ecx
        sbbl    %eax, %eax
        andl    $1, %eax
        shldl   $26, %ecx, %eax
        retl

As you can see the carry of the addition into eax is implemented using sbb/and
instead of using xor %eax, %eax and an adc. 

Using sbb has an unnecessary dependency on the last writer of eax. While the
xor version would not.

-- 
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/20170418/0e43e475/attachment.html>


More information about the llvm-bugs mailing list