binaryen
binaryen copied to clipboard
Fold extend followed by operations that do not care about the extended bits
E.g.
(i64.eqz
(i64.extend_i32_u
(i64.eqz
(local.get $0)
)
)
)
=->
(i64.ne
(local.get $0)
(i64.const 0)
)
Comparing to zero is the same with or without extending: if was zero, it'll remain so, and if it wasn't zero, it still won't be zero.
Found by the superoptimizer https://github.com/WebAssembly/binaryen/pull/4994 (for comparison to other findings: rule #1, benefit 140074).