[llvm] r208456 - move findArrayDimensions to ScalarEvolution

Sebastian Pop spop at codeaurora.org
Fri May 9 15:45:07 PDT 2014


Author: spop
Date: Fri May  9 17:45:07 2014
New Revision: 208456

URL: http://llvm.org/viewvc/llvm-project?rev=208456&view=rev
Log:
move findArrayDimensions to ScalarEvolution

we do not use the information from SCEVAddRecExpr to compute the shape of the array,
so a better place for this function is in ScalarEvolution.

Modified:
    llvm/trunk/include/llvm/Analysis/ScalarEvolution.h
    llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h
    llvm/trunk/lib/Analysis/DependenceAnalysis.cpp
    llvm/trunk/lib/Analysis/ScalarEvolution.cpp

Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolution.h?rev=208456&r1=208455&r2=208456&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/ScalarEvolution.h (original)
+++ llvm/trunk/include/llvm/Analysis/ScalarEvolution.h Fri May  9 17:45:07 2014
@@ -894,6 +894,11 @@ namespace llvm {
     /// indirect operand.
     bool hasOperand(const SCEV *S, const SCEV *Op) const;
 
+    /// Compute the array dimensions Sizes from the set of Terms extracted from
+    /// the memory access function of this SCEVAddRecExpr.
+    void findArrayDimensions(SmallVectorImpl<const SCEV *> &Terms,
+                             SmallVectorImpl<const SCEV *> &Sizes) const;
+
     bool runOnFunction(Function &F) override;
     void releaseMemory() override;
     void getAnalysisUsage(AnalysisUsage &AU) const override;

Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h?rev=208456&r1=208455&r2=208456&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h (original)
+++ llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h Fri May  9 17:45:07 2014
@@ -361,12 +361,6 @@ namespace llvm {
     void collectParametricTerms(ScalarEvolution &SE,
                                 SmallVectorImpl<const SCEV *> &Terms) const;
 
-    /// Compute the array dimensions Sizes from the set of Terms extracted from
-    /// the memory access function of this SCEVAddRecExpr.
-    void findArrayDimensions(ScalarEvolution &SE,
-                             SmallVectorImpl<const SCEV *> &Terms,
-                             SmallVectorImpl<const SCEV *> &Sizes) const;
-
     /// Return in Subscripts the access functions for each dimension in Sizes.
     const SCEV *
     computeAccessFunctions(ScalarEvolution &SE,

Modified: llvm/trunk/lib/Analysis/DependenceAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DependenceAnalysis.cpp?rev=208456&r1=208455&r2=208456&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/DependenceAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/DependenceAnalysis.cpp Fri May  9 17:45:07 2014
@@ -3195,7 +3195,7 @@ DependenceAnalysis::tryDelinearize(const
 
   // Second step: find subscript sizes.
   SmallVector<const SCEV *, 4> Sizes;
-  SrcAR->findArrayDimensions(*SE, Terms, Sizes);
+  SE->findArrayDimensions(Terms, Sizes);
 
   // Third step: compute the access functions for each subscript.
   SmallVector<const SCEV *, 4> SrcSubscripts, DstSubscripts;

Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=208456&r1=208455&r2=208456&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Fri May  9 17:45:07 2014
@@ -7195,8 +7195,7 @@ findGCD(ScalarEvolution &SE, SmallVector
 
 static void findArrayDimensionsRec(ScalarEvolution &SE,
                                    SmallVectorImpl<const SCEV *> &Terms,
-                                   SmallVectorImpl<const SCEV *> &Sizes,
-                                   const SCEV *Zero, const SCEV *One) {
+                                   SmallVectorImpl<const SCEV *> &Sizes) {
   // The GCD of all Terms is the dimension of the innermost dimension.
   const SCEV *GCD = findGCD(SE, Terms);
 
@@ -7215,6 +7214,8 @@ static void findArrayDimensionsRec(Scala
     return;
   }
 
+  const SCEV *Zero = SE.getConstant(GCD->getType(), 0);
+
   for (unsigned I = 0; I < Terms.size(); ++I) {
     // Normalize the terms before the next call to findArrayDimensionsRec.
     const SCEV *Q, *R;
@@ -7230,7 +7231,7 @@ static void findArrayDimensionsRec(Scala
               Terms.end());
 
   if (Terms.size() > 0)
-    findArrayDimensionsRec(SE, Terms, Sizes, Zero, One);
+    findArrayDimensionsRec(SE, Terms, Sizes);
   Sizes.push_back(GCD);
 }
 
@@ -7283,8 +7284,8 @@ static inline int numberOfTerms(const SC
 
 /// Second step of delinearization: compute the array dimensions Sizes from the
 /// set of Terms extracted from the memory access function of this SCEVAddRec.
-void SCEVAddRecExpr::findArrayDimensions(
-    ScalarEvolution &SE, SmallVectorImpl<const SCEV *> &Terms,
+void ScalarEvolution::findArrayDimensions(
+    SmallVectorImpl<const SCEV *> &Terms,
     SmallVectorImpl<const SCEV *> &Sizes) const {
 
   if (Terms.size() < 2)
@@ -7316,9 +7317,8 @@ void SCEVAddRecExpr::findArrayDimensions
         dbgs() << *T << "\n";
     });
 
-  const SCEV *Zero = SE.getConstant(this->getType(), 0);
-  const SCEV *One = SE.getConstant(this->getType(), 1);
-  findArrayDimensionsRec(SE, Terms, Sizes, Zero, One);
+  ScalarEvolution &SE = *const_cast<ScalarEvolution *>(this);
+  findArrayDimensionsRec(SE, Terms, Sizes);
 
   DEBUG({
       dbgs() << "Sizes:\n";
@@ -7436,7 +7436,7 @@ SCEVAddRecExpr::delinearize(ScalarEvolut
   collectParametricTerms(SE, Terms);
 
   // Second step: find subscript sizes.
-  findArrayDimensions(SE, Terms, Sizes);
+  SE.findArrayDimensions(Terms, Sizes);
 
   // Third step: compute the access functions for each subscript.
   const SCEV *Remainder = computeAccessFunctions(SE, Subscripts, Sizes);





More information about the llvm-commits mailing list