Skip to content

Commit b927aa6

Browse files
committed
[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
1 parent b62b21b commit b927aa6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

llvm/lib/Analysis/ScalarEvolution.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5341,9 +5341,12 @@ const SCEV *ScalarEvolution::createSimpleAffineAddRec(PHINode *PN,
53415341
// We can add Flags to the post-inc expression only if we
53425342
// know that it is *undefined behavior* for BEValueV to
53435343
// overflow.
5344-
if (auto *BEInst = dyn_cast<Instruction>(BEValueV))
5345-
if (isLoopInvariant(Accum, L) && isAddRecNeverPoison(BEInst, L))
5344+
if (auto *BEInst = dyn_cast<Instruction>(BEValueV)) {
5345+
assert(isLoopInvariant(Accum, L) &&
5346+
"Accum is defined outside L, but is not invariant?");
5347+
if (isAddRecNeverPoison(BEInst, L))
53465348
(void)getAddRecExpr(getAddExpr(StartVal, Accum), Accum, L, Flags);
5349+
}
53475350

53485351
return PHISCEV;
53495352
}

0 commit comments

Comments
 (0)