[llvm-bugs] [Bug 46203] New: Failure to optimize __builtin_ffs minus 1 to tzcnt+cmovne

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jun 4 10:20:41 PDT 2020


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

            Bug ID: 46203
           Summary: Failure to optimize __builtin_ffs minus 1 to
                    tzcnt+cmovne
           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 mask)
{
    return __builtin_ffs(mask) - 1;
}

With -O3, GCC outputs this :

f(int):
  bsf edi, edi
  mov eax, -1
  cmovne eax, edi
  ret

LLVM outputs this :

f(int): # @f(int)
  bsf ecx, edi
  xor eax, eax
  cmp edi, 1
  sbb eax, eax
  or eax, ecx
  ret

-- 
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/20200604/52e7708f/attachment.html>


More information about the llvm-bugs mailing list