[llvm] f285be6 - [SCEV][NFC] Introduce API for getting basic block's symbolic max exit count

Max Kazantsev via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 22 01:09:17 PST 2022


Author: Max Kazantsev
Date: 2022-11-22T16:02:58+07:00
New Revision: f285be6214fdd5dc650438baea563e11ade4d5cd

URL: https://github.com/llvm/llvm-project/commit/f285be6214fdd5dc650438baea563e11ade4d5cd
DIFF: https://github.com/llvm/llvm-project/commit/f285be6214fdd5dc650438baea563e11ade4d5cd.diff

LOG: [SCEV][NFC] Introduce API for getting basic block's symbolic max exit count

Currently, it just returns exact exit count. This is a refectoring step
before it is actually implemented.

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 49f8ae84f46f5..47fddb389e01f 100644
--- a/llvm/include/llvm/Analysis/ScalarEvolution.h
+++ b/llvm/include/llvm/Analysis/ScalarEvolution.h
@@ -1462,6 +1462,10 @@ class ScalarEvolution {
     /// Get the symbolic max backedge taken count for the loop.
     const SCEV *getSymbolicMax(const Loop *L, ScalarEvolution *SE);
 
+    /// Get the symbolic max backedge taken count for the particular loop exit.
+    const SCEV *getSymbolicMax(const BasicBlock *ExitingBlock,
+                               ScalarEvolution *SE) const;
+
     /// Return true if the number of times this backedge is taken is either the
     /// value returned by getConstantMax or zero.
     bool isConstantMaxOrZero(ScalarEvolution *SE) const;

diff  --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index dd4fd89319451..6bd4aa32cd8e9 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -8223,8 +8223,9 @@ const SCEV *ScalarEvolution::getExitCount(const Loop *L,
                                           ExitCountKind Kind) {
   switch (Kind) {
   case Exact:
-  case SymbolicMaximum:
     return getBackedgeTakenInfo(L).getExact(ExitingBlock, this);
+  case SymbolicMaximum:
+    return getBackedgeTakenInfo(L).getSymbolicMax(ExitingBlock, this);
   case ConstantMaximum:
     return getBackedgeTakenInfo(L).getConstantMax(ExitingBlock, this);
   };
@@ -8556,6 +8557,12 @@ const SCEV *ScalarEvolution::BackedgeTakenInfo::getConstantMax(
   return SE->getCouldNotCompute();
 }
 
+const SCEV *ScalarEvolution::BackedgeTakenInfo::getSymbolicMax(
+    const BasicBlock *ExitingBlock, ScalarEvolution *SE) const {
+  // FIXME: Need to implement this. Return exact for now.
+  return getExact(ExitingBlock, SE);
+}
+
 /// getConstantMax - Get the constant max backedge taken count for the loop.
 const SCEV *
 ScalarEvolution::BackedgeTakenInfo::getConstantMax(ScalarEvolution *SE) const {


        


More information about the llvm-commits mailing list