1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 19:42:54 +02:00

Fix for PR9633 [indvars] Assertion `isa<X>(Val) && "cast<Ty>() argument 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.

llvm-svn: 130271
This commit is contained in:
Andrew Trick 2011-04-27 01:21:25 +00:00
parent 84e88d4c96
commit 73a354c27e

View File

@ -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;
}