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: unassignedb...@nondot.org
          Reporter: craig.top...@gmail.com
                CC: llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to