forked from OSchip/llvm-project
Add a check if the initial value of the induction variable is 0 (the method comment says it should be).
llvm-svn: 46907
This commit is contained in:
parent
4cc387212a
commit
5c252865de
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue