[SCCP] Flip range arguments for NSW region check.
authorFlorian Hahn <flo@fhahn.com>
Mon, 30 Jan 2023 18:03:18 +0000 (18:03 +0000)
committerFlorian Hahn <flo@fhahn.com>
Mon, 30 Jan 2023 18:03:18 +0000 (18:03 +0000)
This brings the operand order in line with the NUW handling, which was
missed out in 72121a20cda4dc91d0ef5548f930.

At the moment this is NFC as we only additions, but it
should fix miscompiles with 024115ab14822a recommitted.

llvm/lib/Transforms/Utils/SCCPSolver.cpp

index 310c4a7..80f1126 100644 (file)
@@ -153,8 +153,8 @@ static bool refineInstruction(SCCPSolver &Solver,
   }
   if (!Inst.hasNoSignedWrap()) {
     auto NSWRange = ConstantRange::makeGuaranteedNoWrapRegion(
-        Instruction::Add, RangeA, OverflowingBinaryOperator::NoSignedWrap);
-    if (NSWRange.contains(RangeB)) {
+        Instruction::Add, RangeB, OverflowingBinaryOperator::NoSignedWrap);
+    if (NSWRange.contains(RangeA)) {
       Inst.setHasNoSignedWrap();
       Changed = true;
     }