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: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected]

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.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to