[llvm] [SimplifyCFG] Add optimization for switches of powers of two (PR #70977)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 9 19:08:11 PST 2023
DKay7 wrote:
> > I added all your suggestions and also wrote a test with both positive and negative cases. But what should I do with a failed test in the pipeline? Thanks.
>
> Possibly you could change `i32 64, label %bb5` to `i32 128, label %bb5`. But I'm not sure that's okay.
Well, it doesn't help for `switch-unreachable-default.ll`. Main problem with this test is that it was designed as described in it:
```
; The switch is lowered with a jump table for cases 1--32 and case 64 handled
; separately. Even though the default of the switch is unreachable, the
; fall-through for the jump table *is* reachable so the range check must be
; emitted.
```
And proposed optimization is able to lower the __entire__ switch to one jump table. There's one way to fix it: I can replace `i32 64, label %bb5` with something negative, for example: `i32 -64, label %bb5`. Then, proposed optimization won't do anything and test will be passed.
https://github.com/llvm/llvm-project/pull/70977
More information about the llvm-commits
mailing list