[SCEV] Turn check in createSimpleAffineAddRec to assertion. (NFC)
authorFlorian Hahn <flo@fhahn.com>
Fri, 26 Nov 2021 13:23:48 +0000 (13:23 +0000)
committerFlorian Hahn <flo@fhahn.com>
Fri, 26 Nov 2021 13:23:48 +0000 (13:23 +0000)
Accum is guaranteed to be defined outside L (via Loop::isLoopInvariant
checks above). I think that should guarantee that the more powerful
ScalarEvolution::isLoopInvariant also determines that the value is loop
invariant.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D114634

llvm/lib/Analysis/ScalarEvolution.cpp

index 587d632..4cdb833 100644 (file)
@@ -5341,9 +5341,12 @@ const SCEV *ScalarEvolution::createSimpleAffineAddRec(PHINode *PN,
   // We can add Flags to the post-inc expression only if we
   // know that it is *undefined behavior* for BEValueV to
   // overflow.
-  if (auto *BEInst = dyn_cast<Instruction>(BEValueV))
-    if (isLoopInvariant(Accum, L) && isAddRecNeverPoison(BEInst, L))
+  if (auto *BEInst = dyn_cast<Instruction>(BEValueV)) {
+    assert(isLoopInvariant(Accum, L) &&
+           "Accum is defined outside L, but is not invariant?");
+    if (isAddRecNeverPoison(BEInst, L))
       (void)getAddRecExpr(getAddExpr(StartVal, Accum), Accum, L, Flags);
+  }
 
   return PHISCEV;
 }