WebAssembly / WebAssembly/binaryen
Remove masks that are shifted out later
Open
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.shl
(i32.and
(local.get $0)
(i32.const 1073741823) ;; 0x3fffffff
)
(i32.const 2)
)
=->
(i32.shl
(local.get $0)
(i32.const 2)
)
Only the top two bits are missing in the mask, and we shift left, so any effect the and had is removed.
Found by the superoptimizer https://github.com/WebAssembly/binaryen/pull/4994 (for comparison to other findings: rule #23, benefit 12936).
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
Review the superoptimizer findings in WebAssembly/binaryen#4994, especially rule #23 and its reported benefit, then locate the optimizer pass that handles this shift-and-mask pattern. Done means the redundant mask is removed for the shown WAT case and the optimization preserves the expression's semantics.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- wasm
- Domain
- compilers, performance
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100