[llvm] 4b5e848 - [NFC] Factor out common code into lambda for further improvement
Max Kazantsev via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 26 00:51:10 PDT 2020
Author: Max Kazantsev
Date: 2020-10-26T14:50:45+07:00
New Revision: 4b5e848befdf786f5c905adf3b6c589216a24bff
URL: https://github.com/llvm/llvm-project/commit/4b5e848befdf786f5c905adf3b6c589216a24bff
DIFF: https://github.com/llvm/llvm-project/commit/4b5e848befdf786f5c905adf3b6c589216a24bff.diff
LOG: [NFC] Factor out common code into lambda for further improvement
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 30f8f11f81a7..b5275cf818f6 100644
--- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
+++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
@@ -2416,14 +2416,16 @@ bool IndVarSimplify::optimizeLoopExits(Loop *L, SCEVExpander &Rewriter) {
// Okay, we do not know the exit count here. Can we at least prove that it
// will remain the same within iteration space?
auto *BI = cast<BranchInst>(ExitingBB->getTerminator());
- if (isTrivialCond(L, BI, SE, false)) {
- FoldExit(ExitingBB, false);
- Changed = true;
- }
- if (isTrivialCond(L, BI, SE, true)) {
- FoldExit(ExitingBB, true);
+ auto OptimizeCond = [&](bool Inverted, const SCEV *MaxIter) {
+ if (isTrivialCond(L, BI, SE, Inverted)) {
+ FoldExit(ExitingBB, Inverted);
+ return true;
+ }
+ return false;
+ };
+ if (OptimizeCond(false, MaxExitCount) ||
+ OptimizeCond(true, MaxExitCount))
Changed = true;
- }
continue;
}
More information about the llvm-commits
mailing list