binaryen
binaryen copied to clipboard
Avoid wrapping when 64-bit operations are enough
(i32.eq
(i32.and
(i32.wrap_i64
(local.get $0)
)
(i32.const 255)
)
(i32.const 4)
)
=->
(i64.eq
(i64.and
(local.get $0)
(i64.const 255)
)
(i64.const 4)
)
All the operations work fine on 32 or 64 bit. The local input happens to be 64, so we can keep it that way until the final operations which always returns i32 anyhow.
Are there CPUs where 64-bit operations are slower than 32?
Sort of the complement to #5004 (use i64 rather than i32).
Found by the superoptimizer https://github.com/WebAssembly/binaryen/pull/4994 (for comparison to other findings: rule #5, benefit 39644).