Add an extra safety check in front of the optimization in r141442.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141470 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Andrew Trick 2011-10-08 02:16:39 +00:00
parent d5d1700972
commit 94794dd8d3

View File

@ -908,6 +908,15 @@ bool SCEVExpander::isExpandedAddRecExprPHI(PHINode *PN, Instruction *IncV,
if (IncV->getType() != Type::getInt1PtrTy(SE.getContext(), AS)
&& IncV->getType() != Type::getInt8PtrTy(SE.getContext(), AS))
return false;
// Ensure the operands dominate the insertion point. I don't know of a
// case when this would not be true, so this is somewhat untested.
if (L == IVIncInsertLoop) {
for (User::op_iterator OI = IncV->op_begin()+1,
OE = IncV->op_end(); OI != OE; ++OI)
if (Instruction *OInst = dyn_cast<Instruction>(OI))
if (!SE.DT->dominates(OInst, IVIncInsertPos))
return false;
}
break;
}
IncV = dyn_cast<Instruction>(IncV->getOperand(0));