diff options
author | Philip Reames <listmail@philipreames.com> | 2019-10-24 18:19:41 -0700 |
---|---|---|
committer | Philip Reames <listmail@philipreames.com> | 2019-10-24 18:21:55 -0700 |
commit | c27010ef76acd2e2a74be6ffd747130ccc760787 (patch) | |
tree | fb227cde458d9d0a20c3a2e602ebbc5ebd89648c /llvm/lib/Analysis/ScalarEvolution.cpp | |
parent | ef7a154d17f2e38ba3c8bfa33f240b60464e4cc7 (diff) | |
download | bcm5719-llvm-c27010ef76acd2e2a74be6ffd747130ccc760787.tar.gz bcm5719-llvm-c27010ef76acd2e2a74be6ffd747130ccc760787.zip |
[SCEV] Start reworking backedge taken count APIs to unify max handling [NFC]
This is a first step in figuring out a proper API for maximum (non constant) exit counts. This may evolve a bit as we get experience with the API needs; suggestions very welcome. This patch just tried to provide a framework that we can later add maximum too in a clean and obvious way.
Diffstat (limited to 'llvm/lib/Analysis/ScalarEvolution.cpp')
-rw-r--r-- | llvm/lib/Analysis/ScalarEvolution.cpp | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 5ce0a1adeaa..f2c2df4879f 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -6599,12 +6599,18 @@ ScalarEvolution::getSmallConstantTripMultiple(const Loop *L, return (unsigned)Result->getZExtValue(); } -/// Get the expression for the number of loop iterations for which this loop is -/// guaranteed not to exit via ExitingBlock. Otherwise return -/// SCEVCouldNotCompute. const SCEV *ScalarEvolution::getExitCount(const Loop *L, - BasicBlock *ExitingBlock) { - return getBackedgeTakenInfo(L).getExact(ExitingBlock, this); + BasicBlock *ExitingBlock, + ExitCountKind Kind) { + switch (Kind) { + case Exact: + return getBackedgeTakenInfo(L).getExact(ExitingBlock, this); + case ConstantMaximum: + return getCouldNotCompute(); + default: + llvm_unreachable("Impossible case!"); + }; + } const SCEV * @@ -6613,14 +6619,16 @@ ScalarEvolution::getPredicatedBackedgeTakenCount(const Loop *L, return getPredicatedBackedgeTakenInfo(L).getExact(L, this, &Preds); } -const SCEV *ScalarEvolution::getBackedgeTakenCount(const Loop *L) { - return getBackedgeTakenInfo(L).getExact(L, this); -} - -/// Similar to getBackedgeTakenCount, except return the least SCEV value that is -/// known never to be less than the actual backedge taken count. -const SCEV *ScalarEvolution::getConstantMaxBackedgeTakenCount(const Loop *L) { - return getBackedgeTakenInfo(L).getMax(this); +const SCEV *ScalarEvolution::getBackedgeTakenCount(const Loop *L, + ExitCountKind Kind) { + switch (Kind) { + case Exact: + return getBackedgeTakenInfo(L).getExact(L, this); + case ConstantMaximum: + return getBackedgeTakenInfo(L).getMax(this); + default: + llvm_unreachable("Impossible case!"); + }; } bool ScalarEvolution::isBackedgeTakenCountMaxOrZero(const Loop *L) { |