Skip to content

Commit

Permalink
Fix for PR9633 [indvars] Assertion `isa<X>(Val) && "cast<Ty>() argume…
Browse files Browse the repository at this point in the history
…nt of incompatible type!"' failed.

Added a type check in ScalarEvolution::computeSCEVAtScope to handle the case in which operands of an
AddRecExpr in the current scope are folded.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130271 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
atrick committed Apr 27, 2011
1 parent cb5fd74 commit 3f95c88
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/Analysis/ScalarEvolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4701,9 +4701,14 @@ const SCEV *ScalarEvolution::computeSCEVAtScope(const SCEV *V, const Loop *L) {
for (++i; i != e; ++i)
NewOps.push_back(getSCEVAtScope(AddRec->getOperand(i), L));

AddRec = cast<SCEVAddRecExpr>(
const SCEV *FoldedRec =
getAddRecExpr(NewOps, AddRec->getLoop(),
AddRec->getNoWrapFlags(SCEV::FlagNW)));
AddRec->getNoWrapFlags(SCEV::FlagNW));
AddRec = dyn_cast<SCEVAddRecExpr>(FoldedRec);
// In cases with "undef" values, a loop's own recurrence may
// fold into a constant. Go ahead and return the optimistic value.
if (!AddRec)
return FoldedRec;
break;
}

Expand Down

0 comments on commit 3f95c88

Please sign in to comment.