[llvm] [SimplifyCFG] Don't use a mask for lookup tables generated from switches with an unreachable default case (PR #94468)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 5 22:48:10 PDT 2024


================
@@ -6743,8 +6743,14 @@ static bool SwitchToLookupTable(SwitchInst *SI, IRBuilder<> &Builder,
     TableSize =
         (MaxCaseVal->getValue() - MinCaseVal->getValue()).getLimitedValue() + 1;
 
+  // If the default destination is unreachable, or if the lookup table covers
+  // all values of the conditional variable, branch directly to the lookup table
+  // BB. Otherwise, check that the condition is within the case range.
+  bool DefaultIsReachable = !SI->defaultDestUndefined();
+
   bool TableHasHoles = (NumResults < TableSize);
-  bool NeedMask = (TableHasHoles && !HasDefaultResults);
+  bool HolesHaveUndefinedResults = (TableHasHoles && !HasDefaultResults);
----------------
DianQK wrote:

This variable name is confusing to me. Could you explain it further and add comments?

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


More information about the llvm-commits mailing list