Always convert switches to br_tables unless there is only one case,
which is equivalent to a simple branch. This reduces code size for wasm,
and we defer possible jump table optimizations to the VM.
Addresses PR41502.
Details
Details
Diff Detail
Diff Detail
- Repository
- rL LLVM
- Build Status
Buildable 30841 Build 30840: arc lint + arc unit
Event Timeline
Comment Actions
The theory here is that br_table represents the performance characteristics of a jump table, while br_if represents the performance characteristics of a branch. In hardware, a small switch with 3 cases is often more efficient with a couple of conditional branches than a jump table.
Comment Actions
I'm in favor of this. There are a bunch of tradeoffs that VMs can make, and this lets them make their own choices, by emitting the higher-level construct, which is also smaller in size in the wasm.
llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp | ||
---|---|---|
277 ↗ | (On Diff #196330) | Might be worth putting a TODO in here or somewhere to investigate using if/else instead once we have support for that? |
@sunfish There are some CHECK-NOTs that I don't know how to preserve here, given that the structure has completely changed. Any ideas? Or do you think it's OK not preserving these?