diff options
Diffstat (limited to 'polly/lib')
-rw-r--r-- | polly/lib/Analysis/ScopDetection.cpp | 6 | ||||
-rw-r--r-- | polly/lib/CodeGen/IslCodeGeneration.cpp | 15 | ||||
-rw-r--r-- | polly/lib/CodeGen/IslExprBuilder.cpp | 29 |
3 files changed, 33 insertions, 17 deletions
diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp index ac20cd8d285..e25d76e15b0 100644 --- a/polly/lib/Analysis/ScopDetection.cpp +++ b/polly/lib/Analysis/ScopDetection.cpp @@ -202,12 +202,6 @@ ScopDetection::ScopDetection() : FunctionPass(ID) { return; } - if (PollyDelinearize) { - DEBUG(errs() << "WARNING: We disable runtime alias checks as " - "delinearization is enabled.\n"); - PollyUseRuntimeAliasChecks = false; - } - if (AllowNonAffine) { DEBUG(errs() << "WARNING: We disable runtime alias checks as non affine " "accesses are enabled.\n"); diff --git a/polly/lib/CodeGen/IslCodeGeneration.cpp b/polly/lib/CodeGen/IslCodeGeneration.cpp index 7b4b76091c0..d72298b54eb 100644 --- a/polly/lib/CodeGen/IslCodeGeneration.cpp +++ b/polly/lib/CodeGen/IslCodeGeneration.cpp @@ -57,8 +57,12 @@ class IslNodeBuilder { public: IslNodeBuilder(PollyIRBuilder &Builder, ScopAnnotator &Annotator, Pass *P, LoopInfo &LI, ScalarEvolution &SE, DominatorTree &DT) - : Builder(Builder), Annotator(Annotator), ExprBuilder(Builder, IDToValue), - P(P), LI(LI), SE(SE), DT(DT) {} + : Builder(Builder), Annotator(Annotator), + Rewriter(new SCEVExpander(SE, "polly")), + ExprBuilder(Builder, IDToValue, *Rewriter), P(P), LI(LI), SE(SE), + DT(DT) {} + + ~IslNodeBuilder() { delete Rewriter; } /// @brief Add the mappings from array id's to array llvm::Value's. void addMemoryAccesses(Scop &S); @@ -69,6 +73,10 @@ public: private: PollyIRBuilder &Builder; ScopAnnotator &Annotator; + + /// @brief A SCEVExpander to create llvm values from SCEVs. + SCEVExpander *Rewriter; + IslExprBuilder ExprBuilder; Pass *P; LoopInfo &LI; @@ -532,7 +540,6 @@ void IslNodeBuilder::create(__isl_take isl_ast_node *Node) { } void IslNodeBuilder::addParameters(__isl_take isl_set *Context) { - SCEVExpander Rewriter(SE, "polly"); for (unsigned i = 0; i < isl_set_dim(Context, isl_dim_param); ++i) { isl_id *Id; @@ -544,7 +551,7 @@ void IslNodeBuilder::addParameters(__isl_take isl_set *Context) { Scev = (const SCEV *)isl_id_get_user(Id); T = dyn_cast<IntegerType>(Scev->getType()); InsertLocation = --(Builder.GetInsertBlock()->end()); - Value *V = Rewriter.expandCodeFor(Scev, T, InsertLocation); + Value *V = Rewriter->expandCodeFor(Scev, T, InsertLocation); IDToValue[Id] = V; isl_id_free(Id); diff --git a/polly/lib/CodeGen/IslExprBuilder.cpp b/polly/lib/CodeGen/IslExprBuilder.cpp index 4ccdb003d34..158288dca46 100644 --- a/polly/lib/CodeGen/IslExprBuilder.cpp +++ b/polly/lib/CodeGen/IslExprBuilder.cpp @@ -14,6 +14,7 @@ #include "polly/ScopInfo.h" #include "polly/Support/GICHelper.h" +#include "llvm/Analysis/ScalarEvolutionExpander.h" #include "llvm/Support/Debug.h" using namespace llvm; @@ -100,10 +101,6 @@ Value *IslExprBuilder::createAccessAddress(isl_ast_expr *Expr) { assert(isl_ast_expr_get_op_n_arg(Expr) >= 2 && "We need at least two operands to create a member access."); - // TODO: Support for multi-dimensional array. - assert(isl_ast_expr_get_op_n_arg(Expr) == 2 && - "Multidimensional access functions are not supported yet"); - Value *Base, *IndexOp, *Access; isl_ast_expr *BaseExpr; isl_id *BaseId; @@ -121,9 +118,27 @@ Value *IslExprBuilder::createAccessAddress(isl_ast_expr *Expr) { Base = Builder.CreateBitCast(Base, SAI->getType(), "polly.access.cast." + BaseName); - IndexOp = create(isl_ast_expr_get_op_arg(Expr, 1)); - assert(IndexOp->getType()->isIntegerTy() && - "Access index should be an integer"); + IndexOp = nullptr; + for (unsigned u = 1, e = isl_ast_expr_get_op_n_arg(Expr); u < e; u++) { + Value *NextIndex = create(isl_ast_expr_get_op_arg(Expr, u)); + assert(NextIndex->getType()->isIntegerTy() && + "Access index should be an integer"); + + if (!IndexOp) + IndexOp = NextIndex; + else + IndexOp = Builder.CreateAdd(IndexOp, NextIndex); + + // For every but the last dimension multiply the size, for the last + // dimension we can exit the loop. + if (u + 1 >= e) + break; + + const SCEV *DimSCEV = SAI->getDimensionSize(u - 1); + Value *DimSize = Expander.expandCodeFor(DimSCEV, IndexOp->getType(), + Builder.GetInsertPoint()); + IndexOp = Builder.CreateMul(IndexOp, DimSize); + } Access = Builder.CreateGEP(Base, IndexOp, "polly.access." + BaseName); |