[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
Thu Jun 6 16:18:55 PDT 2024


================
@@ -6895,8 +6895,9 @@ static bool SwitchToLookupTable(SwitchInst *SI, IRBuilder<> &Builder,
   for (PHINode *PHI : PHIs) {
     const ResultListTy &ResultList = ResultLists[PHI];
 
-    // If using a bitmask, use any value to fill the lookup table holes.
-    Constant *DV = NeedMask ? ResultLists[PHI][0].second : DefaultResults[PHI];
+    // Use any value to fill the lookup table holes.
+    Constant *DV = HolesHaveUndefinedResults ? ResultLists[PHI][0].second
----------------
DianQK wrote:

I believe this makes sense. For example, we could treat `[1, poison, 3, 4]` as `[1, 2, 3, 4]` or merge `[1, poison, 3, 4]` and `[1, 2, poison, 4]` into `[1, 2, 3, 4]`. If you're considering implementing it, please let me know. :)

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


More information about the llvm-commits mailing list