Add a check if the initial value of the induction variable is 0 (the method comment says it should be).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46907 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Wojciech Matyjewicz 2008-02-09 18:06:58 +00:00
parent 63a18c491a
commit 402689d11a

View File

@ -360,12 +360,16 @@ public:
// Loop over all of the PHI nodes, looking for a canonical indvar.
for (typename BlockT::iterator I = H->begin(); isa<PHINode>(I); ++I) {
PHINode *PN = cast<PHINode>(I);
if (Instruction *Inc =
dyn_cast<Instruction>(PN->getIncomingValueForBlock(Backedge)))
if (Inc->getOpcode() == Instruction::Add && Inc->getOperand(0) == PN)
if (ConstantInt *CI = dyn_cast<ConstantInt>(Inc->getOperand(1)))
if (CI->equalsInt(1))
return PN;
if (ConstantInt *CI =
dyn_cast<ConstantInt>(PN->getIncomingValueForBlock(Incoming)))
if (CI->isNullValue())
if (Instruction *Inc =
dyn_cast<Instruction>(PN->getIncomingValueForBlock(Backedge)))
if (Inc->getOpcode() == Instruction::Add &&
Inc->getOperand(0) == PN)
if (ConstantInt *CI = dyn_cast<ConstantInt>(Inc->getOperand(1)))
if (CI->equalsInt(1))
return PN;
}
return 0;
}