diff options
author | Chris Lattner <sabre@nondot.org> | 2004-06-08 21:50:30 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-06-08 21:50:30 +0000 |
commit | 4c7a24af44068e615b3c4d5a45e2ad9d76229ecc (patch) | |
tree | e02b8ef2b81504b8369a8c1845e1d6e3255cfcd5 /llvm/lib/Analysis/LoopInfo.cpp | |
parent | c365e7cc99cd7b30b888d070a030fb963b9b2701 (diff) | |
download | bcm5719-llvm-4c7a24af44068e615b3c4d5a45e2ad9d76229ecc.tar.gz bcm5719-llvm-4c7a24af44068e615b3c4d5a45e2ad9d76229ecc.zip |
Don't grab the condition of unconditional branches!
This fixes PR363
llvm-svn: 14076
Diffstat (limited to 'llvm/lib/Analysis/LoopInfo.cpp')
-rw-r--r-- | llvm/lib/Analysis/LoopInfo.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/llvm/lib/Analysis/LoopInfo.cpp b/llvm/lib/Analysis/LoopInfo.cpp index c4b2bf68146..8619984f3df 100644 --- a/llvm/lib/Analysis/LoopInfo.cpp +++ b/llvm/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; } |