[New Optimization Proposal] Propagate conditional result to branch / switch arms
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Feature
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- cpp, wasm
- Domain
- compilers, performance
Research direction
Start by examining Binaryen's existing optimization paths for branch and switch arms, including br_table handling. Compare their behavior with the conditional-result examples in the issue and determine the intended transformations. Done means the proposed propagation is implemented consistently for the shown if/else and br_table cases, with tests demonstrating the optimized results.
Written by the indexing model from the issue text.
Description
Example:
if (x == 5) {
return x + 1;
} else {
return x - 1;
}
if (y == true) { // maxBits(y) <= 1
return y | x; // maxBits(x) <= 1
} else {
return y ^ x;
}
if (z < 5) {
return z >= 5;
}
could be optimize to:
if (x == 5) {
return 6; // 5 + 1
} else {
return x - 1;
}
if (y == true) {
return true; // we know y == true, so true | bool(x) -> true
} else {
return x; // here y always `false` so `false ^ x` -> x
}
if (z < 5) {
return false;
}
and same for br tables.
WDYT?
- Dominant language
- WebAssembly
- Stars
- 8.6k
- Forks
- 885
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 77
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.
More from WebAssembly/binaryen
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
WebAssembly/binaryen#9135 · 1 comment ·
-
Difficulty 2/5 Half a day Newbie friendliness 76/100
WebAssembly/binaryen#9018 · 3 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
WebAssembly/binaryen#9133 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
WebAssembly/binaryen#9123 ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
WebAssembly/binaryen#9122 ·
All issues in WebAssembly/binaryen
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
internal.h中,漏掉了1个定义。 Open
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
oxc-project/oxc#26944 ·