[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
Wed Jul 2 09:00:51 PDT 2025


spaits wrote:

Thank you very much for your review @dtcxzyw . I will merge the PR.

It sounds interesting what you wrote about further generalization. If you have some concrete idea what you would like to see I would be more than happy to help implementing them.

I also have some further ideas for this part of the code:
For example, my current pattern would also work, when there are multiple possible results from the swithc (`ResultVector.size() > 1` cases).

Each result, where all the cases "guarding" that result could be replaced to the current pattern. Even partial replacements would be possible. (I am not exactly sure if it would be profitable with switches with many possible values. It would need further discussion).

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


More information about the llvm-commits mailing list