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
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 | Might be worth putting a TODO in here or somewhere to investigate using if/else instead once we have support for that? |
Might be worth putting a TODO in here or somewhere to investigate using if/else instead once we have support for that?