On x86-64 platforms, we can rely on BSR not changing the destination
operand when the input is zero.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
{
int n;
- __asm__("bsrl %1,%0 ; cmovel %2,%0"
- : "=&r" (n)
- : "rm" (v), "rm" (0));
+ __asm__("bsrl %1,%0"
+ : "=r" (n)
+ : "rm" (v), "0" (0));
return n;
}
{
uint64_t n;
- __asm__("bsrq %1,%0 ; cmoveq %2,%0"
- : "=&r" (n)
- : "rm" (v), "rm" (UINT64_C(0)));
+ __asm__("bsrq %1,%0"
+ : "=r" (n)
+ : "rm" (v), "0" (UINT64_C(0)));
return n;
}