[LoopPred] Fix a bug in unconditional latch bailout introduced in r362284
This is a really silly bug that even a simple test w/an unconditional latch would have caught. I tried to guard against the case, but put it in the wrong if check. Oops.
llvm-svn: 362727
diff --git a/llvm/lib/Transforms/Scalar/LoopPredication.cpp b/llvm/lib/Transforms/Scalar/LoopPredication.cpp
index 017bf21..ed715d3 100644
--- a/llvm/lib/Transforms/Scalar/LoopPredication.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopPredication.cpp
@@ -850,7 +850,7 @@
}
auto *BI = dyn_cast<BranchInst>(LoopLatch->getTerminator());
- if (!BI) {
+ if (!BI || !BI->isConditional()) {
LLVM_DEBUG(dbgs() << "Failed to match the latch terminator!\n");
return None;
}
@@ -860,7 +860,7 @@
"One of the latch's destinations must be the header");
auto *ICI = dyn_cast<ICmpInst>(BI->getCondition());
- if (!ICI || !BI->isConditional()) {
+ if (!ICI) {
LLVM_DEBUG(dbgs() << "Failed to match the latch condition!\n");
return None;
}