Implement optimizations for i32.eqz
translation.
#795
Labels
optimization
An performance optimization issue.
register-machine
A work item for the register-machine engine.
When translating a Wasm
i32.eqz
instruction we can view it as negation of local conditionals that can be in the form ofi32.eq
,i32.lt_s
,i64.ge_u
etc. and in some cases alsoi32.{and, or, xor}
. Instead of simply emitting awasmi
IRi32.eq x imm(0)
instruction we can sometimes instead negate the previous instruction thus emitting fewer instructions in total.Although this optimization might be mitigated by Wasm codegens that already perform this optimization. More research is needed here.
Affected Wasm instructions if they come after an
i32.eqz
ori64.eqz
:br_if
: Compile asbr_if
with negated conditional.select
: Compile asselect
with swapped operands. (equal to negated)Affected Wasm instruction if they come before an
i32.eqz
ori64.eqz
:and
,or
: Compile as not-and
or not-or
. (to be further optimized bybr_if
)i32.eq
,i32.lt_s
,i64.ge_u
etc..The text was updated successfully, but these errors were encountered: