From 754e940865aaf63be79dcb921572eff4b1042c7c Mon Sep 17 00:00:00 2001 From: Sebastian Pop Date: Fri, 9 May 2014 22:45:07 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208456 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/ScalarEvolution.h | 5 +++++ .../llvm/Analysis/ScalarEvolutionExpressions.h | 6 ------ lib/Analysis/DependenceAnalysis.cpp | 2 +- lib/Analysis/ScalarEvolution.cpp | 18 +++++++++--------- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/include/llvm/Analysis/ScalarEvolution.h b/include/llvm/Analysis/ScalarEvolution.h index 1e086fbd702..4db8686bae7 100644 --- a/include/llvm/Analysis/ScalarEvolution.h +++ b/include/llvm/Analysis/ScalarEvolution.h @@ -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 &Terms, + SmallVectorImpl &Sizes) const; + bool runOnFunction(Function &F) override; void releaseMemory() override; void getAnalysisUsage(AnalysisUsage &AU) const override; diff --git a/include/llvm/Analysis/ScalarEvolutionExpressions.h b/include/llvm/Analysis/ScalarEvolutionExpressions.h index 0a8a03076ac..ba32e928d95 100644 --- a/include/llvm/Analysis/ScalarEvolutionExpressions.h +++ b/include/llvm/Analysis/ScalarEvolutionExpressions.h @@ -361,12 +361,6 @@ namespace llvm { void collectParametricTerms(ScalarEvolution &SE, SmallVectorImpl &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 &Terms, - SmallVectorImpl &Sizes) const; - /// Return in Subscripts the access functions for each dimension in Sizes. const SCEV * computeAccessFunctions(ScalarEvolution &SE, diff --git a/lib/Analysis/DependenceAnalysis.cpp b/lib/Analysis/DependenceAnalysis.cpp index 96acda3f45c..57231b8325a 100644 --- a/lib/Analysis/DependenceAnalysis.cpp +++ b/lib/Analysis/DependenceAnalysis.cpp @@ -3195,7 +3195,7 @@ DependenceAnalysis::tryDelinearize(const SCEV *SrcSCEV, const SCEV *DstSCEV, // Second step: find subscript sizes. SmallVector Sizes; - SrcAR->findArrayDimensions(*SE, Terms, Sizes); + SE->findArrayDimensions(Terms, Sizes); // Third step: compute the access functions for each subscript. SmallVector SrcSubscripts, DstSubscripts; diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index b8a49f590f0..f065d851a00 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -7195,8 +7195,7 @@ findGCD(ScalarEvolution &SE, SmallVectorImpl &Terms) { static void findArrayDimensionsRec(ScalarEvolution &SE, SmallVectorImpl &Terms, - SmallVectorImpl &Sizes, - const SCEV *Zero, const SCEV *One) { + SmallVectorImpl &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(ScalarEvolution &SE, 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(ScalarEvolution &SE, 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 SCEV *S) { /// 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 &Terms, +void ScalarEvolution::findArrayDimensions( + SmallVectorImpl &Terms, SmallVectorImpl &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(this); + findArrayDimensionsRec(SE, Terms, Sizes); DEBUG({ dbgs() << "Sizes:\n"; @@ -7436,7 +7436,7 @@ SCEVAddRecExpr::delinearize(ScalarEvolution &SE, 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); -- 2.34.1