https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95531
Bug ID: 95531
Summary: Failure to use TZCNT for __builtin_ffs
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: gabravier at gmail dot com
Target Milestone: ---
int f(int x)
{
return __builtin_ffs(x);
}
With -O3 -mbmi, LLVM generates this :
f(int): # @f(int)
tzcnt ecx, edi
mov eax, -1
cmovae eax, ecx
add eax, 1
ret
GCC outputs this :
f(int):
bsf eax, edi
mov edx, -1
cmove eax, edx
add eax, 1
ret