Verify SCEVAddRecExpr's invariant in ScalarEvolution::getAddRecExpr

instead of in SCEVAddRecExpr's constructor, in preparation for an
upcoming change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119554 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman 2010-11-17 20:48:38 +00:00
parent 23465a06f4
commit 203a7239ae
2 changed files with 4 additions and 5 deletions

View File

@ -373,11 +373,7 @@ namespace llvm {
SCEVAddRecExpr(const FoldingSetNodeIDRef ID, SCEVAddRecExpr(const FoldingSetNodeIDRef ID,
const SCEV *const *O, size_t N, const Loop *l) const SCEV *const *O, size_t N, const Loop *l)
: SCEVNAryExpr(ID, scAddRecExpr, O, N), L(l) { : SCEVNAryExpr(ID, scAddRecExpr, O, N), L(l) {}
for (size_t i = 0, e = NumOperands; i != e; ++i)
assert(Operands[i]->isLoopInvariant(l) &&
"Operands of AddRec must be loop-invariant!");
}
public: public:
const SCEV *getStart() const { return Operands[0]; } const SCEV *getStart() const { return Operands[0]; }

View File

@ -2073,6 +2073,9 @@ ScalarEvolution::getAddRecExpr(SmallVectorImpl<const SCEV *> &Operands,
for (unsigned i = 1, e = Operands.size(); i != e; ++i) for (unsigned i = 1, e = Operands.size(); i != e; ++i)
assert(getEffectiveSCEVType(Operands[i]->getType()) == ETy && assert(getEffectiveSCEVType(Operands[i]->getType()) == ETy &&
"SCEVAddRecExpr operand types don't match!"); "SCEVAddRecExpr operand types don't match!");
for (unsigned i = 0, e = Operands.size(); i != e; ++i)
assert(Operands[i]->isLoopInvariant(L) &&
"SCEVAddRecExpr operand is not loop-invariant!");
#endif #endif
if (Operands.back()->isZero()) { if (Operands.back()->isZero()) {