[llvm] b927aa6 - [SCEV] Turn check in createSimpleAffineAddRec to assertion. (NFC)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 26 05:24:07 PST 2021


Author: Florian Hahn
Date: 2021-11-26T13:23:48Z
New Revision: b927aa69bf2fd50ecf33e3f5ec853eb3c70312c5

URL: https://github.com/llvm/llvm-project/commit/b927aa69bf2fd50ecf33e3f5ec853eb3c70312c5
DIFF: https://github.com/llvm/llvm-project/commit/b927aa69bf2fd50ecf33e3f5ec853eb3c70312c5.diff

LOG: [SCEV] Turn check in createSimpleAffineAddRec to assertion. (NFC)

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

Added: 
    

Modified: 
    llvm/lib/Analysis/ScalarEvolution.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 587d63280501d..4cdb8336d38b1 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -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;
 }


        


More information about the llvm-commits mailing list