MaxGraey edited issue #4607:
Feature
Simple optimization which rewrite
x < 0
(icmp slt_imm x, 0
) tox >>> bit_size(ty) - 1
(ushr_imm x, 31 | 63
).Benefit
x < 0
is pretty common operation. Although LLVM itself applies this rule, but some code generators / optimizers such as Binaryen (wasm-opt / wasm-pack use it) don't such peephole rewrites because replacing the constant0
to31
or63
has a negative effect on entropy when compressing wasm module via gzip or brotli.Besides, such optimization will improve cranelift IR itself, because it will remove the finalizing
bint.i32
/bint.i64
aftericmp
.
forushr
/ushr_imm
it is not needed.Implementation
- Add necessary rewrite for simple_opt before this line
- Add tests for
filetests/simple_preopt/simplily32.clif
andfiletests/simple_preopt/simplily64.clif
Last updated: Nov 22 2024 at 16:03 UTC