[llvm] [SimplifyCFG] Transform switch to select when common bits uniquely identify one case (PR #145233)

Gábor Spaits via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 30 22:09:38 PDT 2025


spaits wrote:

@dtcxzyw Thank you very much for reviewing my PR.
- I have rebased the PR to main
- ActiveBits is now unsigned
- Replaced the old `icmp ne (and %1 AndMask) 0` with `cmp eq and(%1, AndMask) AndMask`. You have pointed out, that the old method could only identify `select`s where there was one single bit common in every pattern. The new method can use multiple bits to identify the pattern. A good example of such a case, where the new method works but the old doesn't is test `range0to15_middle_two_bits`. I have also added some negative tests too.

Thank you very much for reviewing and pointing out the inefficiency in my original logic.
I would like to ask you to please re-review the PR.

https://github.com/llvm/llvm-project/pull/145233


More information about the llvm-commits mailing list