diff options
| author | Johannes Doerfert <doerfert@cs.uni-saarland.de> | 2016-02-25 14:06:11 +0000 |
|---|---|---|
| committer | Johannes Doerfert <doerfert@cs.uni-saarland.de> | 2016-02-25 14:06:11 +0000 |
| commit | 9dd42ee7c18a5a13ea40ea31654d01ea26d8d014 (patch) | |
| tree | 82b51a41cda6c1a759011a21ec3f6a500f29d360 | |
| parent | 45ef10f1104c7bb04cc81b399996a400915af7a7 (diff) | |
| download | bcm5719-llvm-9dd42ee7c18a5a13ea40ea31654d01ea26d8d014.tar.gz bcm5719-llvm-9dd42ee7c18a5a13ea40ea31654d01ea26d8d014.zip | |
Try to build alias checks even when non-affine accesses are allowed
From now on we bail only if a non-trivial alias group contains a non-affine
access, not when we discover aliasing and non-affine accesses are allowed.
llvm-svn: 261863
| -rw-r--r-- | polly/lib/Analysis/ScopDetection.cpp | 6 | ||||
| -rw-r--r-- | polly/lib/Analysis/ScopInfo.cpp | 14 | ||||
| -rw-r--r-- | polly/test/Isl/Ast/alias_simple_2.ll | 2 | ||||
| -rw-r--r-- | polly/test/ScopInfo/aliasing_with_non_affine_access.ll | 49 |
4 files changed, 65 insertions, 6 deletions
diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp index c16d9fb20b2..d3ac0fc567b 100644 --- a/polly/lib/Analysis/ScopDetection.cpp +++ b/polly/lib/Analysis/ScopDetection.cpp @@ -232,12 +232,6 @@ ScopDetection::ScopDetection() : FunctionPass(ID) { PollyUseRuntimeAliasChecks = false; return; } - - if (AllowNonAffine) { - DEBUG(errs() << "WARNING: We disable runtime alias checks as non affine " - "accesses are enabled.\n"); - PollyUseRuntimeAliasChecks = false; - } } template <class RR, typename... Args> diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp index dc18d618b3b..e549ba21327 100644 --- a/polly/lib/Analysis/ScopInfo.cpp +++ b/polly/lib/Analysis/ScopInfo.cpp @@ -2689,6 +2689,20 @@ bool Scop::buildAliasGroups(AliasAnalysis &AA) { continue; } + // Check if we have non-affine accesses left, if so bail out as we cannot + // generate a good access range yet. + for (auto *MA : AG) + if (!MA->isAffine()) { + invalidate(ALIASING, MA->getAccessInstruction()->getDebugLoc()); + return false; + } + for (auto &ReadOnlyPair : ReadOnlyPairs) + for (auto *MA : ReadOnlyPair.second) + if (!MA->isAffine()) { + invalidate(ALIASING, MA->getAccessInstruction()->getDebugLoc()); + return false; + } + // Calculate minimal and maximal accesses for non read only accesses. MinMaxAliasGroups.emplace_back(); MinMaxVectorPairTy &pair = MinMaxAliasGroups.back(); diff --git a/polly/test/Isl/Ast/alias_simple_2.ll b/polly/test/Isl/Ast/alias_simple_2.ll index 155ad2607e4..42f6bb47515 100644 --- a/polly/test/Isl/Ast/alias_simple_2.ll +++ b/polly/test/Isl/Ast/alias_simple_2.ll @@ -3,6 +3,7 @@ ; RUN: opt %loadPolly -polly-ast -analyze -disable-basicaa -tbaa < %s | FileCheck %s --check-prefix=TBAA ; RUN: opt %loadPolly -polly-ast -analyze -disable-basicaa -scev-aa < %s | FileCheck %s --check-prefix=SCEV ; RUN: opt %loadPolly -polly-ast -analyze -disable-basicaa -globals-aa < %s | FileCheck %s --check-prefix=GLOB +; RUN: opt %loadPolly -polly-ast -analyze -disable-basicaa -globals-aa -polly-allow-nonaffine < %s | FileCheck %s --check-prefix=NONAFFINE ; ; int A[1024], B[1024]; ; @@ -17,6 +18,7 @@ ; TBAA: if (1 && (&MemRef_B[N] <= &MemRef_A[0] || &MemRef_A[N] <= &MemRef_B[0])) ; SCEV: if (1 && (&MemRef_B[N] <= &MemRef_A[0] || &MemRef_A[N] <= &MemRef_B[0])) ; GLOB: if (1 && (&MemRef_B[N] <= &MemRef_A[0] || &MemRef_A[N] <= &MemRef_B[0])) +; NONAFFINE: if (1 && (&MemRef_B[N] <= &MemRef_A[0] || &MemRef_A[N] <= &MemRef_B[0])) ; target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" diff --git a/polly/test/ScopInfo/aliasing_with_non_affine_access.ll b/polly/test/ScopInfo/aliasing_with_non_affine_access.ll new file mode 100644 index 00000000000..db719219e21 --- /dev/null +++ b/polly/test/ScopInfo/aliasing_with_non_affine_access.ll @@ -0,0 +1,49 @@ +; RUN: opt %loadPolly -analyze -polly-scops < %s | FileCheck %s +; RUN: opt %loadPolly -analyze -polly-scops -pass-remarks-analysis="polly-scops" 2>&1 < %s | FileCheck %s --check-prefix=REMARK +; +; This test case has a non-affine access (the memset call) that aliases with +; other accesses. Thus, we bail out. +; +; CHECK-NOT: Statements +; +; REMARK: remark: <unknown>:0:0: SCoP begins here. +; REMARK-NEXT: remark: <unknown>:0:0: Possibly aliasing pointer, use restrict keyword. +; REMARK-NEXT: remark: <unknown>:0:0: Possibly aliasing pointer, use restrict keyword. +; REMARK-NEXT: remark: <unknown>:0:0: No-aliasing assumption: { : 1 = 0 } +; REMARK-NEXT: remark: <unknown>:0:0: SCoP ends here but was dismissed. +; +; ModuleID = 'bugpoint-reduced-simplified.bc' +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" + +%struct.info = type { i32, %struct.ctr*, i32, %struct.ord*, %struct.ctr*, i32, i8*, i32, i32, double } +%struct.ctr = type { i32, i8, i8, i32 } +%struct.ord = type { i32, i8 } + +; Function Attrs: argmemonly nounwind +declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i32, i1) #0 + +; Function Attrs: nounwind uwtable +define void @bestVirtualIndex(%struct.info** %ppIdxInfo) { +entry: + %0 = load %struct.info*, %struct.info** %ppIdxInfo, align 8 + br label %if.end125 + +if.end125: ; preds = %entry + %1 = load %struct.ctr*, %struct.ctr** undef, align 8 + br label %for.end143 + +for.end143: ; preds = %if.end125 + %2 = bitcast %struct.ctr* %1 to i8* + tail call void @llvm.memset.p0i8.i64(i8* %2, i8 0, i64 32, i32 4, i1 false) + %needToFreeIdxStr = getelementptr inbounds %struct.info, %struct.info* %0, i64 0, i32 7 + %3 = load i32, i32* %needToFreeIdxStr, align 8 + br i1 false, label %if.end149, label %if.then148 + +if.then148: ; preds = %for.end143 + br label %if.end149 + +if.end149: ; preds = %if.then148, %for.end143 + unreachable +} + +attributes #0 = { argmemonly nounwind } |

