Skip to content

Commit c467585

Browse files
committed
[NFC] Reuse existing variables instead of re-requesting successors
1 parent 9f39ba1 commit c467585

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

llvm/lib/Transforms/Scalar/LoopDeletion.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ static bool canProveExitOnFirstIteration(Loop *L, DominatorTree &DT,
293293
using namespace PatternMatch;
294294
ICmpInst::Predicate Pred;
295295
Value *LHS, *RHS;
296-
const BasicBlock *IfTrue, *IfFalse;
296+
BasicBlock *IfTrue, *IfFalse;
297297
auto *Term = BB->getTerminator();
298298
// TODO: Handle switches.
299299
if (!match(Term, m_Br(m_ICmp(Pred, m_Value(LHS), m_Value(RHS)),
@@ -316,13 +316,12 @@ static bool canProveExitOnFirstIteration(Loop *L, DominatorTree &DT,
316316
// in-loop.
317317
// TODO: isKnownPredicateAt is more powerful, but it's too compile time
318318
// consuming. So we avoid using it here.
319-
if (L->contains(Term->getSuccessor(1)) &&
320-
SE.isKnownPredicate(Pred, LHSS, RHSS))
321-
MarkLiveEdge(BB, Term->getSuccessor(0));
322-
else if (L->contains(Term->getSuccessor(0)) &&
319+
if (L->contains(IfFalse) && SE.isKnownPredicate(Pred, LHSS, RHSS))
320+
MarkLiveEdge(BB, IfTrue);
321+
else if (L->contains(IfTrue) &&
323322
SE.isKnownPredicate(ICmpInst::getInversePredicate(Pred), LHSS,
324323
RHSS))
325-
MarkLiveEdge(BB, Term->getSuccessor(1));
324+
MarkLiveEdge(BB, IfFalse);
326325
else
327326
MarkAllSuccessorsLive(BB);
328327
}

0 commit comments

Comments
 (0)