} else {
if (auto *CondInst = dyn_cast<Instruction>(BI.getCondition()))
Invariants = collectHomogenousInstGraphLoopInvariants(L, *CondInst, LI);
- if (Invariants.empty())
- // Couldn't find invariant inputs!
+ if (Invariants.empty()) {
+ LLVM_DEBUG(dbgs() << " Couldn't find invariant inputs!\n");
return false;
+ }
}
// Check that one of the branch's successors exits, and which one.
ExitDirection = false;
LoopExitSuccIdx = 1;
LoopExitBB = BI.getSuccessor(1);
- if (L.contains(LoopExitBB))
+ if (L.contains(LoopExitBB)) {
+ LLVM_DEBUG(dbgs() << " Branch doesn't exit the loop!\n");
return false;
+ }
}
auto *ContinueBB = BI.getSuccessor(1 - LoopExitSuccIdx);
auto *ParentBB = BI.getParent();
- if (!areLoopExitPHIsLoopInvariant(L, *ParentBB, *LoopExitBB))
+ if (!areLoopExitPHIsLoopInvariant(L, *ParentBB, *LoopExitBB)) {
+ LLVM_DEBUG(dbgs() << " Loop exit PHI's aren't loop-invariant!\n");
return false;
+ }
// When unswitching only part of the branch's condition, we need the exit
// block to be reached directly from the partially unswitched input. This can
// is a graph of `or` operations, or the exit block is along the false edge
// and the condition is a graph of `and` operations.
if (!FullUnswitch) {
- if (ExitDirection) {
- if (!match(BI.getCondition(), m_LogicalOr()))
- return false;
- } else {
- if (!match(BI.getCondition(), m_LogicalAnd()))
- return false;
+ if (ExitDirection ? !match(BI.getCondition(), m_LogicalOr())
+ : !match(BI.getCondition(), m_LogicalAnd())) {
+ LLVM_DEBUG(dbgs() << " Branch condition is in improper form for "
+ "non-full unswitch!\n");
+ return false;
}
}