diff options
| author | Johannes Doerfert <doerfert@cs.uni-saarland.de> | 2014-10-10 15:14:29 +0000 |
|---|---|---|
| committer | Johannes Doerfert <doerfert@cs.uni-saarland.de> | 2014-10-10 15:14:29 +0000 |
| commit | 9b5786960d83d4318e220da05651073146a815c2 (patch) | |
| tree | 6411e0a7a9adb00a014b2e8d6d7f4cbe2290d17c | |
| parent | 59eb767e11d4ffefb5f55409524e5c8416b2b0db (diff) | |
| download | bcm5719-llvm-9b5786960d83d4318e220da05651073146a815c2.tar.gz bcm5719-llvm-9b5786960d83d4318e220da05651073146a815c2.zip | |
Relax the condition on the jsop accesses regarding the alignment.
We restricted the new access functions to be a subset of the old one
because we want to keep the alignment, however if the alignment is
"not special", thus the default for the type, we can allow any access.
Differential Revision: http://reviews.llvm.org/D5680
llvm-svn: 219503
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] }" + } + ] +} |

