aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorWojciech Matyjewicz <wmatyjewicz@fastmail.fm>2008-02-09 18:06:58 +0000
committerWojciech Matyjewicz <wmatyjewicz@fastmail.fm>2008-02-09 18:06:58 +0000
commit36b4c44bd40f08851142730aa717b092352881ca (patch)
treed97b8af581f4057586a5a99dc83780396879a517 /include
parent2f39752377ef4e3b1d5dbce7af3b610bb1eddf17 (diff)
downloadexternal_llvm-36b4c44bd40f08851142730aa717b092352881ca.zip
external_llvm-36b4c44bd40f08851142730aa717b092352881ca.tar.gz
external_llvm-36b4c44bd40f08851142730aa717b092352881ca.tar.bz2
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
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Analysis/LoopInfo.h16
1 files changed, 10 insertions, 6 deletions
diff --git a/include/llvm/Analysis/LoopInfo.h b/include/llvm/Analysis/LoopInfo.h
index 93c36e4..4cb03fb 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<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;
}