binaryen icon indicating copy to clipboard operation
binaryen copied to clipboard

Fold extend followed by operations that do not care about the extended bits

Open kripken opened this issue 3 years ago • 0 comments

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).

kripken avatar Sep 02 '22 18:09 kripken