[llvm] [SimplifyCFG] Allow some switch optimizations early in the pipeline (PR #158242)

Antonio Frighetto via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 8 02:49:14 PDT 2025


================
@@ -7929,14 +7943,10 @@ bool SimplifyCFGOpt::simplifySwitch(SwitchInst *SI, IRBuilder<> &Builder) {
   if (Options.ForwardSwitchCondToPhi && forwardSwitchConditionToPHI(SI))
     return requestResimplify();
 
-  // The conversion from switch to lookup tables results in difficult-to-analyze
-  // code and makes pruning branches much harder. This is a problem if the
-  // switch expression itself can still be restricted as a result of inlining or
-  // CVP. Therefore, only apply this transformation during late stages of the
-  // optimisation pipeline.
-  if (Options.ConvertSwitchToLookupTable &&
-      simplifySwitchLookup(SI, Builder, DTU, DL, TTI))
-    return requestResimplify();
+  if (Options.ConvertSwitchToArithmetic || Options.ConvertSwitchToLookupTable)
----------------
antoniofrighetto wrote:

Would it be reasonable to refine the comment instead of dropping it (at least, the final heuristic part)? The premise should still apply.

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


More information about the llvm-commits mailing list