Handle a corner case with IV chain collection with bailout instead of assert.

Fixes PR11783: bad cast to AddRecExpr.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148572 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Andrew Trick
2012-01-20 21:23:40 +00:00
parent a44919ef45
commit 0041d4d447
2 changed files with 49 additions and 2 deletions

View File

@ -2484,11 +2484,15 @@ void LSRInstance::ChainInstruction(Instruction *UserInst, Instruction *IVOper,
DEBUG(dbgs() << "IV Chain Limit\n");
return;
}
LastIncExpr = SE.getSCEV(NextIV);
// IVUsers may have skipped over sign/zero extensions. We don't currently
// attempt to form chains involving extensions unless they can be hoisted
// into this loop's AddRec.
if (!isa<SCEVAddRecExpr>(LastIncExpr))
return;
++NChains;
IVChainVec.resize(NChains);
ChainUsersVec.resize(NChains);
LastIncExpr = SE.getSCEV(NextIV);
assert(isa<SCEVAddRecExpr>(LastIncExpr) && "expect recurrence at IV user");
DEBUG(dbgs() << "IV Head: (" << *UserInst << ") IV=" << *LastIncExpr
<< "\n");
}