[llvm] c467585 - [NFC] Reuse existing variables instead of re-requesting successors
Max Kazantsev via llvm-commits
llvm-commits at lists.llvm.org
Thu May 27 01:29:54 PDT 2021
Author: Max Kazantsev
Date: 2021-05-27T15:29:37+07:00
New Revision: c467585682dcdda75e645ef3ab47c8b48440db12
URL: https://github.com/llvm/llvm-project/commit/c467585682dcdda75e645ef3ab47c8b48440db12
DIFF: https://github.com/llvm/llvm-project/commit/c467585682dcdda75e645ef3ab47c8b48440db12.diff
LOG: [NFC] Reuse existing variables instead of re-requesting successors
Added:
Modified:
llvm/lib/Transforms/Scalar/LoopDeletion.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/LoopDeletion.cpp b/llvm/lib/Transforms/Scalar/LoopDeletion.cpp
index ed6b078fcf8e..8326a1589bcf 100644
--- a/llvm/lib/Transforms/Scalar/LoopDeletion.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopDeletion.cpp
@@ -293,7 +293,7 @@ static bool canProveExitOnFirstIteration(Loop *L, DominatorTree &DT,
using namespace PatternMatch;
ICmpInst::Predicate Pred;
Value *LHS, *RHS;
- const BasicBlock *IfTrue, *IfFalse;
+ BasicBlock *IfTrue, *IfFalse;
auto *Term = BB->getTerminator();
// TODO: Handle switches.
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,
// in-loop.
// TODO: isKnownPredicateAt is more powerful, but it's too compile time
// consuming. So we avoid using it here.
- if (L->contains(Term->getSuccessor(1)) &&
- SE.isKnownPredicate(Pred, LHSS, RHSS))
- MarkLiveEdge(BB, Term->getSuccessor(0));
- else if (L->contains(Term->getSuccessor(0)) &&
+ if (L->contains(IfFalse) && SE.isKnownPredicate(Pred, LHSS, RHSS))
+ MarkLiveEdge(BB, IfTrue);
+ else if (L->contains(IfTrue) &&
SE.isKnownPredicate(ICmpInst::getInversePredicate(Pred), LHSS,
RHSS))
- MarkLiveEdge(BB, Term->getSuccessor(1));
+ MarkLiveEdge(BB, IfFalse);
else
MarkAllSuccessorsLive(BB);
}
More information about the llvm-commits
mailing list