[llvm] f19a95b - [SCEV] Split computeExitLimitFromICmp into two versions [NFC]
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 2 09:58:43 PST 2022
Author: Philip Reames
Date: 2022-01-02T09:58:32-08:00
New Revision: f19a95bbed1605f3b7575063054eb9fa1d13b125
URL: https://github.com/llvm/llvm-project/commit/f19a95bbed1605f3b7575063054eb9fa1d13b125
DIFF: https://github.com/llvm/llvm-project/commit/f19a95bbed1605f3b7575063054eb9fa1d13b125.diff
LOG: [SCEV] Split computeExitLimitFromICmp into two versions [NFC]
This is in advance of a following change which needs to the non-icmp API.
Added:
Modified:
llvm/include/llvm/Analysis/ScalarEvolution.h
llvm/lib/Analysis/ScalarEvolution.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/ScalarEvolution.h b/llvm/include/llvm/Analysis/ScalarEvolution.h
index df50611832cee..ac7e3a46a6ead 100644
--- a/llvm/include/llvm/Analysis/ScalarEvolution.h
+++ b/llvm/include/llvm/Analysis/ScalarEvolution.h
@@ -1713,6 +1713,17 @@ class ScalarEvolution {
bool IsSubExpr,
bool AllowPredicates = false);
+ /// Variant of previous which takes the components representing an ICmp
+ /// as opposed to the ICmpInst itself. Note that the prior version can
+ /// return more precise results in some cases and is preferred when caller
+ /// has a materialized ICmp.
+ ExitLimit computeExitLimitFromICmp(const Loop *L, ICmpInst::Predicate Pred,
+ const SCEV *LHS, const SCEV *RHS,
+ bool ExitIfTrue,
+ bool IsSubExpr,
+ bool AllowPredicates = false);
+
+
/// Compute the number of times the backedge of the specified loop will
/// execute if its exit condition were a switch with a single exiting case
/// to ExitingBB.
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 0c3f32295ae13..d80505aef0927 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -8203,6 +8203,28 @@ ScalarEvolution::computeExitLimitFromICmp(const Loop *L,
const SCEV *LHS = getSCEV(ExitCond->getOperand(0));
const SCEV *RHS = getSCEV(ExitCond->getOperand(1));
+ ExitLimit EL = computeExitLimitFromICmp(L, Pred, LHS, RHS, ExitIfTrue,
+ ControlsExit, AllowPredicates);
+ if (EL.hasAnyInfo()) return EL;
+
+ auto *ExhaustiveCount =
+ computeExitCountExhaustively(L, ExitCond, ExitIfTrue);
+
+ if (!isa<SCEVCouldNotCompute>(ExhaustiveCount))
+ return ExhaustiveCount;
+
+ return computeShiftCompareExitLimit(ExitCond->getOperand(0),
+ ExitCond->getOperand(1), L, OriginalPred);
+}
+ScalarEvolution::ExitLimit
+ScalarEvolution::computeExitLimitFromICmp(const Loop *L,
+ ICmpInst::Predicate Pred,
+ const SCEV *LHS, const SCEV *RHS,
+ bool ExitIfTrue,
+ bool ControlsExit,
+ bool AllowPredicates) {
+
+
// Try to evaluate any dependencies out of the loop.
LHS = getSCEVAtScope(LHS, L);
RHS = getSCEVAtScope(RHS, L);
@@ -8312,14 +8334,7 @@ ScalarEvolution::computeExitLimitFromICmp(const Loop *L,
break;
}
- auto *ExhaustiveCount =
- computeExitCountExhaustively(L, ExitCond, ExitIfTrue);
-
- if (!isa<SCEVCouldNotCompute>(ExhaustiveCount))
- return ExhaustiveCount;
-
- return computeShiftCompareExitLimit(ExitCond->getOperand(0),
- ExitCond->getOperand(1), L, OriginalPred);
+ return getCouldNotCompute();
}
ScalarEvolution::ExitLimit
More information about the llvm-commits
mailing list