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
/// indirect operand.
bool hasOperand(const SCEV *S, const SCEV *Op) const;
/// 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;
bool runOnFunction(Function &F) override;
void releaseMemory() override;
void getAnalysisUsage(AnalysisUsage &AU) const override;
void collectParametricTerms(ScalarEvolution &SE,
SmallVectorImpl<const SCEV *> &Terms) const;
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,
/// Return in Subscripts the access functions for each dimension in Sizes.
const SCEV *
computeAccessFunctions(ScalarEvolution &SE,
// Second step: find subscript sizes.
SmallVector<const SCEV *, 4> Sizes;
// 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;
// Third step: compute the access functions for each subscript.
SmallVector<const SCEV *, 4> SrcSubscripts, DstSubscripts;
static void findArrayDimensionsRec(ScalarEvolution &SE,
SmallVectorImpl<const SCEV *> &Terms,
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);
// The GCD of all Terms is the dimension of the innermost dimension.
const SCEV *GCD = findGCD(SE, Terms);
+ 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;
for (unsigned I = 0; I < Terms.size(); ++I) {
// Normalize the terms before the next call to findArrayDimensionsRec.
const SCEV *Q, *R;
Terms.end());
if (Terms.size() > 0)
Terms.end());
if (Terms.size() > 0)
- findArrayDimensionsRec(SE, Terms, Sizes, Zero, One);
+ findArrayDimensionsRec(SE, Terms, Sizes);
/// Second step of delinearization: compute the array dimensions Sizes from the
/// set of Terms extracted from the memory access function of this SCEVAddRec.
/// 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)
SmallVectorImpl<const SCEV *> &Sizes) const {
if (Terms.size() < 2)
dbgs() << *T << "\n";
});
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";
DEBUG({
dbgs() << "Sizes:\n";
collectParametricTerms(SE, Terms);
// Second step: find subscript sizes.
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);
// Third step: compute the access functions for each subscript.
const SCEV *Remainder = computeAccessFunctions(SE, Subscripts, Sizes);