From: Wojciech Matyjewicz Date: Sat, 9 Feb 2008 18:06:58 +0000 (+0000) Subject: Add a check if the initial value of the induction variable is 0 (the method comment... X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=402689d11a3879163a3e67ea297937c2c26cc502;p=oota-llvm.git 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 --- diff --git a/include/llvm/Analysis/LoopInfo.h b/include/llvm/Analysis/LoopInfo.h index 93c36e47d8b..4cb03fbd8e7 100644 --- a/include/llvm/Analysis/LoopInfo.h +++ b/include/llvm/Analysis/LoopInfo.h @@ -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(I); ++I) { PHINode *PN = cast(I); - if (Instruction *Inc = - dyn_cast(PN->getIncomingValueForBlock(Backedge))) - if (Inc->getOpcode() == Instruction::Add && Inc->getOperand(0) == PN) - if (ConstantInt *CI = dyn_cast(Inc->getOperand(1))) - if (CI->equalsInt(1)) - return PN; + if (ConstantInt *CI = + dyn_cast(PN->getIncomingValueForBlock(Incoming))) + if (CI->isNullValue()) + if (Instruction *Inc = + dyn_cast(PN->getIncomingValueForBlock(Backedge))) + if (Inc->getOpcode() == Instruction::Add && + Inc->getOperand(0) == PN) + if (ConstantInt *CI = dyn_cast(Inc->getOperand(1))) + if (CI->equalsInt(1)) + return PN; } return 0; }