summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--polly/lib/Exchange/JSONExporter.cpp42
-rw-r--r--polly/test/Isl/CodeGen/MemAccess/default_aligned_new_access_function.ll41
-rw-r--r--polly/test/Isl/CodeGen/MemAccess/simple_stride___%for.cond---%for.end.jscop21
3 files changed, 92 insertions, 12 deletions
diff --git a/polly/lib/Exchange/JSONExporter.cpp b/polly/lib/Exchange/JSONExporter.cpp
index e462ece9791..bd1fce593cd 100644
--- a/polly/lib/Exchange/JSONExporter.cpp
+++ b/polly/lib/Exchange/JSONExporter.cpp
@@ -185,6 +185,7 @@ bool JSONImporter::runOnScop(Scop &scop) {
S = &scop;
Region &R = S->getRegion();
Dependences *D = &getAnalysis<Dependences>();
+ const DataLayout &DL = getAnalysis<DataLayoutPass>().getDataLayout();
std::string FileName = ImportDir + "/" + getFileName(S);
@@ -281,18 +282,33 @@ bool JSONImporter::runOnScop(Scop &scop) {
newAccessMap = isl_map_set_tuple_id(newAccessMap, isl_dim_out, OutId);
// We keep the old alignment, thus we cannot allow accesses to memory
- // locations that were not accessed before.
- isl_set *newAccessSet = isl_map_range(isl_map_copy(newAccessMap));
- isl_set *currentAccessSet = isl_map_range(isl_map_copy(currentAccessMap));
- bool isSubset = isl_set_is_subset(newAccessSet, currentAccessSet);
- isl_set_free(newAccessSet);
- isl_set_free(currentAccessSet);
-
- if (!isSubset) {
- errs() << "JScop file changes the accessed memory\n";
- isl_map_free(currentAccessMap);
- isl_map_free(newAccessMap);
- return false;
+ // locations that were not accessed before if the alignment of the access
+ // is not the default alignment.
+ bool SpecialAlignment = true;
+ if (LoadInst *LoadI = dyn_cast<LoadInst>(MA->getAccessInstruction())) {
+ SpecialAlignment =
+ DL.getABITypeAlignment(LoadI->getType()) != LoadI->getAlignment();
+ } else if (StoreInst *StoreI =
+ dyn_cast<StoreInst>(MA->getAccessInstruction())) {
+ SpecialAlignment =
+ DL.getABITypeAlignment(StoreI->getValueOperand()->getType()) !=
+ StoreI->getAlignment();
+ }
+
+ if (SpecialAlignment) {
+ isl_set *newAccessSet = isl_map_range(isl_map_copy(newAccessMap));
+ isl_set *currentAccessSet =
+ isl_map_range(isl_map_copy(currentAccessMap));
+ bool isSubset = isl_set_is_subset(newAccessSet, currentAccessSet);
+ isl_set_free(newAccessSet);
+ isl_set_free(currentAccessSet);
+
+ if (!isSubset) {
+ errs() << "JScop file changes the accessed memory\n";
+ isl_map_free(currentAccessMap);
+ isl_map_free(newAccessMap);
+ return false;
+ }
}
// We need to copy the isl_ids for the parameter dimensions to the new
@@ -342,6 +358,7 @@ bool JSONImporter::runOnScop(Scop &scop) {
void JSONImporter::getAnalysisUsage(AnalysisUsage &AU) const {
ScopPass::getAnalysisUsage(AU);
AU.addRequired<Dependences>();
+ AU.addRequired<DataLayoutPass>();
}
Pass *polly::createJSONImporterPass() { return new JSONImporter(); }
@@ -360,6 +377,7 @@ INITIALIZE_PASS_BEGIN(JSONImporter, "polly-import-jscop",
" (Reads a .jscop file for each Scop)",
false, false);
INITIALIZE_PASS_DEPENDENCY(Dependences)
+INITIALIZE_PASS_DEPENDENCY(DataLayoutPass)
INITIALIZE_PASS_END(JSONImporter, "polly-import-jscop",
"Polly - Import Scops from JSON"
" (Reads a .jscop file for each Scop)",
diff --git a/polly/test/Isl/CodeGen/MemAccess/default_aligned_new_access_function.ll b/polly/test/Isl/CodeGen/MemAccess/default_aligned_new_access_function.ll
new file mode 100644
index 00000000000..9e89550e325
--- /dev/null
+++ b/polly/test/Isl/CodeGen/MemAccess/default_aligned_new_access_function.ll
@@ -0,0 +1,41 @@
+; RUN: opt %loadPolly -basicaa -polly-import-jscop -polly-import-jscop-dir=%S -analyze < %s | FileCheck %s
+;
+; Check that we allow the new access functions even though they access
+; different locations than the original ones (but the alignment is the
+; default, thus there is no problem).
+;
+; CHECK-DAG: New access function '{ Stmt_for_body[i0] -> MemRef_B[0] }'detected in JSCOP file
+; CHECK-DAG: New access function '{ Stmt_for_body[i0] -> MemRef_A[i0] }'detected in JSCOP file
+;
+; void simple_stride(int *restrict A, int *restrict B) {
+; for (int i = 0; i < 16; i++)
+; A[i * 2] = B[i * 2];
+; }
+;
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+
+define void @simple_stride(i32* noalias %A, i32* noalias %B) {
+entry:
+ br label %for.cond
+
+for.cond: ; preds = %for.inc, %entry
+ %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 0, %entry ]
+ %exitcond = icmp ne i64 %indvars.iv, 16
+ br i1 %exitcond, label %for.body, label %for.end
+
+for.body: ; preds = %for.cond
+ %tmp = shl nsw i64 %indvars.iv, 1
+ %arrayidx = getelementptr inbounds i32* %B, i64 %tmp
+ %tmp4 = load i32* %arrayidx, align 4
+ %tmp5 = shl nsw i64 %indvars.iv, 1
+ %arrayidx3 = getelementptr inbounds i32* %A, i64 %tmp5
+ store i32 %tmp4, i32* %arrayidx3, align 4
+ br label %for.inc
+
+for.inc: ; preds = %for.body
+ %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
+ br label %for.cond
+
+for.end: ; preds = %for.cond
+ ret void
+}
diff --git a/polly/test/Isl/CodeGen/MemAccess/simple_stride___%for.cond---%for.end.jscop b/polly/test/Isl/CodeGen/MemAccess/simple_stride___%for.cond---%for.end.jscop
new file mode 100644
index 00000000000..0fe6461b133
--- /dev/null
+++ b/polly/test/Isl/CodeGen/MemAccess/simple_stride___%for.cond---%for.end.jscop
@@ -0,0 +1,21 @@
+{
+ "context" : "{ : }",
+ "name" : "for.cond => for.end",
+ "statements" : [
+ {
+ "accesses" : [
+ {
+ "kind" : "read",
+ "relation" : "{ Stmt_for_body[i0] -> MemRef_B[0] }"
+ },
+ {
+ "kind" : "write",
+ "relation" : "{ Stmt_for_body[i0] -> MemRef_A[i0] }"
+ }
+ ],
+ "domain" : "{ Stmt_for_body[i0] : i0 >= 0 and i0 <= 15 }",
+ "name" : "Stmt_for_body",
+ "schedule" : "{ Stmt_for_body[i0] -> scattering[0, i0, 0] }"
+ }
+ ]
+}
OpenPOWER on IntegriCloud