WebAssembly / WebAssembly/binaryen
Optimize checks for higher bits using a low bit mask
Nobody has claimed this yet.
- Dominant language
- WebAssembly
- Stars
- 8.6k
- Forks
- 885
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 69
Description
E.g.
(i32.ne
(i32.and
(local.get $0)
(i32.const 268435455) ;; 0x0fffffff
)
(local.get $0)
)
=->
(i32.ge_u
(local.get $0)
(i32.const 268435456)
)
(x & low-bit-mask) != x implies that x has some bit set that is larger than the bitmask, so we can just look for those bits.
Found by the superoptimizer https://github.com/WebAssembly/binaryen/pull/4994 (for comparison to other findings: rule #15, benefit 16737).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the superoptimizer comparison in WebAssembly/binaryen#4994, especially rule #15 and its reported benefit of 16737, then locate the optimizer checks matching the shown WAT pattern. Done means the low-bit-mask form is recognized as equivalent to the shown i32.ge_u form while preserving behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- wasm
- Domain
- compilers, performance
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100