[llvm-bugs] [Bug 45700] New: Failure to optimize condition into sbb

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Apr 27 09:13:58 PDT 2020


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

            Bug ID: 45700
           Summary: Failure to optimize condition into sbb
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: gabravier at gmail.com
                CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
                    llvm-dev at redking.me.uk, spatel+llvm at rotateright.com

int f(int a, unsigned b, unsigned c)
{
    if (b <= c)
        a++;
    return a;
}

This optimizes into an sbb on gcc : 

f(int, unsigned int, unsigned int):
  mov eax, edi
  cmp edx, esi
  sbb eax, -1
  ret

With LLVM, this is output instead :

f(int, unsigned int, unsigned int):
  xor eax, eax
  cmp esi, edx
  setbe al
  add eax, edi
  ret

And I doubt that is faster than the sbb.

-- 
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/20200427/8c1810ee/attachment.html>


More information about the llvm-bugs mailing list