WebAssembly / WebAssembly/binaryen
[Proposal] Add getMaxSignBits for tracking sign values
Nobody has claimed this yet.
- Dominant language
- WebAssembly
- Stars
- 8.6k
- Forks
- 885
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 69
Description
With existing getMaxBits we could provide wide range of optimizations but getMaxBits completely blind for signed operations and values. This leaves a lot of places that could be relatively easily optimised. For example:
i32(x) - i32(y) < 0 -> x < y
If we know x - y never overflow (it required getMaxSignBits for signed comparison). Or more expressive example:
i32(x) * 400 / 100 -> x * 4
if we know getMaxSignBits(x) >= 9.
For example:
(i32(x) >> 9) * 400 / 100 -> (x >> 9) << 2
In general, getMaxSignBits is the building block for helpers that calculate the signed overflow for +, - and *
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 by locating the existing getMaxBits implementation and the optimizer paths for signed comparisons and arithmetic. Determine the intended getMaxSignBits behavior from the examples, then define the helper and its overflow-analysis uses; done means the proposed signed optimizations are supported without incorrect transformations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- wasm
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100