Open
Description
https://godbolt.org/z/hhbsf8she
For the expression (x >> amt) != 0
, for values of amt
between 8 and 31, LLVM emits a cmp
against an immediate instead of a shift right and comparison. The compare against immediate instruction takes 7 bytes to encode; the shift right instruction takes 4 bytes
src:
cmp rdi,0x7fffffff ; 48 81 ff ff ff ff 7f
setae al ; 0f 97 c0
ret ; c3
tgt:
shr rdi, 0x1f ; 48 c1 ef 1f
setne al ; 0f 95 c0
ret ; c3