WebAssembly / WebAssembly/binaryen
[Feature] Evaluated case elimination pass
Open
Nobody has claimed this yet.
- Dominant language
- WebAssembly
- Stars
- 8.6k
- Forks
- 885
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 69
Description
function test(x: i32) : i32 {
switch (x) {
case 1: return 2;
case 2: return 2;
}
return 2;
}
current with -O4:
(func $test (export "test") (type $t0) (param $p0 i32) (result i32)
block $B0
block $B1
get_local $p0
i32.const 1
i32.ne
if $I2
get_local $p0
i32.const 2
i32.eq
br_if $B1
br $B0
end
i32.const 2
return
end
i32.const 2
return
end
i32.const 2)
optimal (with evaluated case elimination transform):
(func $test (export "test") (type $t0) (param $p0 i32) (result i32)
i32.const 2
)
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
Reproduce the example with -O4 and compare the current WebAssembly output with the optimal output shown in the issue. Locate the existing optimizer passes that simplify switch or evaluated cases, then verify that this example reduces to a function returning i32.const 2.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- wasm
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100