summaryrefslogtreecommitdiffstats
path: root/polly/lib/Analysis/ScopInfo.cpp
diff options
context:
space:
mode:
authorDominik Adamski <adamski.dominik@gmail.com>2019-07-17 21:25:18 +0000
committerDominik Adamski <adamski.dominik@gmail.com>2019-07-17 21:25:18 +0000
commiteece5a9d31840de69a074ed1ea3ed7c0e44916a0 (patch)
tree6c000fbad8d8080329b8d85987690dfcad5bf77d /polly/lib/Analysis/ScopInfo.cpp
parent4a09a73fb091e9100fb95aa364a7afb8daa042dc (diff)
downloadbcm5719-llvm-eece5a9d31840de69a074ed1ea3ed7c0e44916a0.tar.gz
bcm5719-llvm-eece5a9d31840de69a074ed1ea3ed7c0e44916a0.zip
[NFC][ScopBuilder]Move finalizeAccesses and its callees to ScopBuilder
Scope of changes: 1) Moved finalizeAccesses to ScopBuilder 2) Moved updateAccessDimensionality to ScopBuilder 3) Moved foldSizeConstantsToRight to ScopBuilder 4) Moved foldSizeConstantsToRight to ScopBuilder 5) Moved assumeNoOutOfBounds to ScopBuilder 6) Moved markFortranArrays to ScopBuilder 7) Added iterator range for AccessFunctions vector. Differential Revision: https://reviews.llvm.org/D63794 llvm-svn: 366374
Diffstat (limited to 'polly/lib/Analysis/ScopInfo.cpp')
-rw-r--r--polly/lib/Analysis/ScopInfo.cpp189
1 files changed, 0 insertions, 189 deletions
diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp
index 9ccd9bf1680..c9a780ad987 100644
--- a/polly/lib/Analysis/ScopInfo.cpp
+++ b/polly/lib/Analysis/ScopInfo.cpp
@@ -848,35 +848,6 @@ void MemoryAccess::foldAccessRelation() {
}
}
-/// Check if @p Expr is divisible by @p Size.
-static bool isDivisible(const SCEV *Expr, unsigned Size, ScalarEvolution &SE) {
- assert(Size != 0);
- if (Size == 1)
- return true;
-
- // Only one factor needs to be divisible.
- if (auto *MulExpr = dyn_cast<SCEVMulExpr>(Expr)) {
- for (auto *FactorExpr : MulExpr->operands())
- if (isDivisible(FactorExpr, Size, SE))
- return true;
- return false;
- }
-
- // For other n-ary expressions (Add, AddRec, Max,...) all operands need
- // to be divisible.
- if (auto *NAryExpr = dyn_cast<SCEVNAryExpr>(Expr)) {
- for (auto *OpExpr : NAryExpr->operands())
- if (!isDivisible(OpExpr, Size, SE))
- return false;
- return true;
- }
-
- auto *SizeSCEV = SE.getConstant(Expr->getType(), Size);
- auto *UDivSCEV = SE.getUDivExpr(Expr, SizeSCEV);
- auto *MulSCEV = SE.getMulExpr(UDivSCEV, SizeSCEV);
- return MulSCEV == Expr;
-}
-
void MemoryAccess::buildAccessRelation(const ScopArrayInfo *SAI) {
assert(AccessRelation.is_null() && "AccessRelation already built");
@@ -2836,166 +2807,6 @@ Scop::Scop(Region &R, ScalarEvolution &ScalarEvolution, LoopInfo &LI,
Scop::~Scop() = default;
-void Scop::foldSizeConstantsToRight() {
- isl::union_set Accessed = getAccesses().range();
-
- for (auto Array : arrays()) {
- if (Array->getNumberOfDimensions() <= 1)
- continue;
-
- isl::space Space = Array->getSpace();
- Space = Space.align_params(Accessed.get_space());
-
- if (!Accessed.contains(Space))
- continue;
-
- isl::set Elements = Accessed.extract_set(Space);
- isl::map Transform = isl::map::universe(Array->getSpace().map_from_set());
-
- std::vector<int> Int;
- int Dims = Elements.dim(isl::dim::set);
- for (int i = 0; i < Dims; i++) {
- isl::set DimOnly = isl::set(Elements).project_out(isl::dim::set, 0, i);
- DimOnly = DimOnly.project_out(isl::dim::set, 1, Dims - i - 1);
- DimOnly = DimOnly.lower_bound_si(isl::dim::set, 0, 0);
-
- isl::basic_set DimHull = DimOnly.affine_hull();
-
- if (i == Dims - 1) {
- Int.push_back(1);
- Transform = Transform.equate(isl::dim::in, i, isl::dim::out, i);
- continue;
- }
-
- if (DimHull.dim(isl::dim::div) == 1) {
- isl::aff Diff = DimHull.get_div(0);
- isl::val Val = Diff.get_denominator_val();
-
- int ValInt = 1;
- if (Val.is_int()) {
- auto ValAPInt = APIntFromVal(Val);
- if (ValAPInt.isSignedIntN(32))
- ValInt = ValAPInt.getSExtValue();
- } else {
- }
-
- Int.push_back(ValInt);
- isl::constraint C = isl::constraint::alloc_equality(
- isl::local_space(Transform.get_space()));
- C = C.set_coefficient_si(isl::dim::out, i, ValInt);
- C = C.set_coefficient_si(isl::dim::in, i, -1);
- Transform = Transform.add_constraint(C);
- continue;
- }
-
- isl::basic_set ZeroSet = isl::basic_set(DimHull);
- ZeroSet = ZeroSet.fix_si(isl::dim::set, 0, 0);
-
- int ValInt = 1;
- if (ZeroSet.is_equal(DimHull)) {
- ValInt = 0;
- }
-
- Int.push_back(ValInt);
- Transform = Transform.equate(isl::dim::in, i, isl::dim::out, i);
- }
-
- isl::set MappedElements = isl::map(Transform).domain();
- if (!Elements.is_subset(MappedElements))
- continue;
-
- bool CanFold = true;
- if (Int[0] <= 1)
- CanFold = false;
-
- unsigned NumDims = Array->getNumberOfDimensions();
- for (unsigned i = 1; i < NumDims - 1; i++)
- if (Int[0] != Int[i] && Int[i])
- CanFold = false;
-
- if (!CanFold)
- continue;
-
- for (auto &Access : AccessFunctions)
- if (Access->getScopArrayInfo() == Array)
- Access->setAccessRelation(
- Access->getAccessRelation().apply_range(Transform));
-
- std::vector<const SCEV *> Sizes;
- for (unsigned i = 0; i < NumDims; i++) {
- auto Size = Array->getDimensionSize(i);
-
- if (i == NumDims - 1)
- Size = SE->getMulExpr(Size, SE->getConstant(Size->getType(), Int[0]));
- Sizes.push_back(Size);
- }
-
- Array->updateSizes(Sizes, false /* CheckConsistency */);
- }
-}
-
-void Scop::markFortranArrays() {
- for (ScopStmt &Stmt : Stmts) {
- for (MemoryAccess *MemAcc : Stmt) {
- Value *FAD = MemAcc->getFortranArrayDescriptor();
- if (!FAD)
- continue;
-
- // TODO: const_cast-ing to edit
- ScopArrayInfo *SAI =
- const_cast<ScopArrayInfo *>(MemAcc->getLatestScopArrayInfo());
- assert(SAI && "memory access into a Fortran array does not "
- "have an associated ScopArrayInfo");
- SAI->applyAndSetFAD(FAD);
- }
- }
-}
-
-void Scop::finalizeAccesses() {
- updateAccessDimensionality();
- foldSizeConstantsToRight();
- foldAccessRelations();
- assumeNoOutOfBounds();
- markFortranArrays();
-}
-
-void Scop::updateAccessDimensionality() {
- // Check all array accesses for each base pointer and find a (virtual) element
- // size for the base pointer that divides all access functions.
- for (ScopStmt &Stmt : *this)
- for (MemoryAccess *Access : Stmt) {
- if (!Access->isArrayKind())
- continue;
- ScopArrayInfo *Array =
- const_cast<ScopArrayInfo *>(Access->getScopArrayInfo());
-
- if (Array->getNumberOfDimensions() != 1)
- continue;
- unsigned DivisibleSize = Array->getElemSizeInBytes();
- const SCEV *Subscript = Access->getSubscript(0);
- while (!isDivisible(Subscript, DivisibleSize, *SE))
- DivisibleSize /= 2;
- auto *Ty = IntegerType::get(SE->getContext(), DivisibleSize * 8);
- Array->updateElementType(Ty);
- }
-
- for (auto &Stmt : *this)
- for (auto &Access : Stmt)
- Access->updateDimensionality();
-}
-
-void Scop::foldAccessRelations() {
- for (auto &Stmt : *this)
- for (auto &Access : Stmt)
- Access->foldAccessRelation();
-}
-
-void Scop::assumeNoOutOfBounds() {
- for (auto &Stmt : *this)
- for (auto &Access : Stmt)
- Access->assumeNoOutOfBound();
-}
-
void Scop::removeFromStmtMap(ScopStmt &Stmt) {
for (Instruction *Inst : Stmt.getInstructions())
InstStmtMap.erase(Inst);
OpenPOWER on IntegriCloud