[llvm] [Transforms/Util] Add SimplifySwitchVar pass (PR #149937)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 6 11:38:49 PDT 2025


nikic wrote:

> We could keep the general structure more-or-less, but do the checks for LUTs much later in `switchToLookupTable`, i.e., collect the case-value mappings first, then create a `SwitchLookupTable` to determine what kind to generate. Then we could check if we really want to create an `ArrayKind` LUT, and only then do the checks (whether Options.ConvertSwitchToLookupTable is set, TTI support and `no-jump-tables` attribute). If we don't, we can generate code for the other kinds already.
> 
> Is there a better way to achieve this?

That approach sounds reasonable to me.

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


More information about the llvm-commits mailing list