aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Analysis/LoopInfo.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-06-08 21:50:30 +0000
committerChris Lattner <sabre@nondot.org>2004-06-08 21:50:30 +0000
commit47c31a824803b6fffcf9818dccbbe040c366c5ab (patch)
treec758539f0e6d247fe0484f804f77b17e2b41e63d /lib/Analysis/LoopInfo.cpp
parent8e6e7c90ce5ecefb78637491ba40bf98c3ca1b67 (diff)
downloadexternal_llvm-47c31a824803b6fffcf9818dccbbe040c366c5ab.zip
external_llvm-47c31a824803b6fffcf9818dccbbe040c366c5ab.tar.gz
external_llvm-47c31a824803b6fffcf9818dccbbe040c366c5ab.tar.bz2
Don't grab the condition of unconditional branches!
This fixes PR363 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14076 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/LoopInfo.cpp')
-rw-r--r--lib/Analysis/LoopInfo.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/Analysis/LoopInfo.cpp b/lib/Analysis/LoopInfo.cpp
index c4b2bf6..8619984 100644
--- a/lib/Analysis/LoopInfo.cpp
+++ b/lib/Analysis/LoopInfo.cpp
@@ -442,14 +442,15 @@ Value *Loop::getTripCount() const {
IV->getIncomingBlock(contains(IV->getIncomingBlock(1)));
if (BranchInst *BI = dyn_cast<BranchInst>(BackedgeBlock->getTerminator()))
- if (SetCondInst *SCI = dyn_cast<SetCondInst>(BI->getCondition()))
- if (SCI->getOperand(0) == Inc)
- if (BI->getSuccessor(0) == getHeader()) {
- if (SCI->getOpcode() == Instruction::SetNE)
+ if (BI->isConditional())
+ if (SetCondInst *SCI = dyn_cast<SetCondInst>(BI->getCondition()))
+ if (SCI->getOperand(0) == Inc)
+ if (BI->getSuccessor(0) == getHeader()) {
+ if (SCI->getOpcode() == Instruction::SetNE)
+ return SCI->getOperand(1);
+ } else if (SCI->getOpcode() == Instruction::SetEQ) {
return SCI->getOperand(1);
- } else if (SCI->getOpcode() == Instruction::SetEQ) {
- return SCI->getOperand(1);
- }
+ }
return 0;
}