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
This commit is contained in:
Johannes Doerfert
2016-02-25 14:06:11 +00:00
parent 45ef10f110
commit 9dd42ee7c1
4 changed files with 65 additions and 6 deletions

View File

@@ -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>

View File

@@ -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();

View File

@@ -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"

View File

@@ -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 }