Open
Description
This code: (Zig Godbolt) (LLVM Godbolt)
export fn z(b: bool, x: u64) u64 {
const y = x & -%x; // blsi
return if (b) y else x;
}
Gives:
mov rcx, rsi
neg rcx
test edi, edi
mov rax, -1
cmovne rax, rcx
and rax, rsi
It should be:
blsi rax, rsi
test edi, edi
cmove rax, rsi