Zig Godbolt
C Godbolt
Currently compiles to:
foo:
mov rax, rdi
or rax, rsi
or rax, rdx
not rax
ret
Should be:
foo:
not rdx
or rdi, rsi
andn rax, rdi, rdx
ret
The difference is that the first snippet is going to take 3 cycles to execute because there is a serial dependency chain between all 3 operations. The second snippet can take 2 cycles to execute because the not and the or can run in the same cycle.