binaryen
binaryen copied to clipboard
optimise LSBit mask (followed by branch) to use `ctz`
I have code snippets like
i32.const 1
i32.and
i32.eqz
br_if 1 (;@1;)
which could be optimised to
i32.ctz
br_if 1 (;@1;)
Similar analogous transformations:
-
i32.const 1; i32.and; i32.eqz; iftoi32.ctz; if -
i32.const 1; i32.and; iftoi32.ctz; if(with legs swapped) - possibly 64-bit variants (but here probably instructions for truncation need to be added)
- what about sightedness testing? (cmp against 0 -->
clz)