[llvm] [SimplifyCFG] handle monotonic wrapped case for D150943 (PR #65882)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 11 19:44:42 PDT 2023


================
@@ -6082,15 +6083,20 @@ SwitchLookupTable::SwitchLookupTable(
           LinearMappingPossible = false;
           break;
         }
-        Wrapped |=
-            Dist.isStrictlyPositive() ? Val.sle(PrevVal) : Val.sgt(PrevVal);
+        NMon |= Dist.isStrictlyPositive() ? Val.sle(PrevVal) : Val.sgt(PrevVal);
       }
       PrevVal = Val;
     }
     if (LinearMappingPossible) {
       LinearOffset = cast<ConstantInt>(TableContents[0]);
       LinearMultiplier = ConstantInt::get(M.getContext(), DistToPrev);
-      LinearMapValWrapped = Wrapped;
+      bool MayMWrap = false, MayOWrap = false;
+      APInt M = LinearMultiplier->getValue(), O = LinearOffset->getValue();
+      APInt Res = O.sadd_ov(
----------------
nikic wrote:

Is the sadd_ov check here needed as well? If yes, is it possible to add a test case that needs it?

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


More information about the llvm-commits mailing list