[llvm] a44b732 - [NFC] Split lambda into 2 parts for further reuse
Max Kazantsev via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 2 23:14:16 PST 2020
Author: Max Kazantsev
Date: 2020-11-03T14:13:55+07:00
New Revision: a44b7322a27a636da6a6e1a28091dc7a6d59a4be
URL: https://github.com/llvm/llvm-project/commit/a44b7322a27a636da6a6e1a28091dc7a6d59a4be
DIFF: https://github.com/llvm/llvm-project/commit/a44b7322a27a636da6a6e1a28091dc7a6d59a4be.diff
LOG: [NFC] Split lambda into 2 parts for further reuse
Added:
Modified:
llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
index 0ee0d6e87a0d..650e0494d757 100644
--- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
+++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
@@ -2406,15 +2406,20 @@ bool IndVarSimplify::optimizeLoopExits(Loop *L, SCEVExpander &Rewriter) {
}
#endif
+ auto ReplaceExitCond = [&](BranchInst *BI, Value *NewCond) {
+ auto *OldCond = BI->getCondition();
+ BI->setCondition(NewCond);
+ if (OldCond->use_empty())
+ DeadInsts.emplace_back(OldCond);
+ };
+
auto FoldExit = [&](BasicBlock *ExitingBB, bool IsTaken) {
BranchInst *BI = cast<BranchInst>(ExitingBB->getTerminator());
bool ExitIfTrue = !L->contains(*succ_begin(ExitingBB));
auto *OldCond = BI->getCondition();
auto *NewCond = ConstantInt::get(OldCond->getType(),
IsTaken ? ExitIfTrue : !ExitIfTrue);
- BI->setCondition(NewCond);
- if (OldCond->use_empty())
- DeadInsts.emplace_back(OldCond);
+ ReplaceExitCond(BI, NewCond);
};
bool Changed = false;
More information about the llvm-commits
mailing list