summaryrefslogtreecommitdiffstats
path: root/polly/test/ScopDetect/base_pointer_load_setNewAccessRelation.ll
diff options
context:
space:
mode:
authorMichael Kruse <llvm@meinersbur.de>2017-03-07 20:28:43 +0000
committerMichael Kruse <llvm@meinersbur.de>2017-03-07 20:28:43 +0000
commit5a4ec5c42b84a56b8c7177f04bd65183f5286402 (patch)
tree551e24e15ecfc184d8cea862853eeb4f7a974933 /polly/test/ScopDetect/base_pointer_load_setNewAccessRelation.ll
parent06b1af5bf1172be1b3f6fa762f0c901656678e6d (diff)
downloadbcm5719-llvm-5a4ec5c42b84a56b8c7177f04bd65183f5286402.tar.gz
bcm5719-llvm-5a4ec5c42b84a56b8c7177f04bd65183f5286402.zip
[ScopDetection] Require LoadInst base pointers to be hoisted.
Only when load-hoisted we can be sure the base pointer is invariant during the SCoP's execution. Most of the time it would be added to the required hoists for the alias checks anyway, except with -polly-ignore-aliasing, -polly-use-runtime-alias-checks=0 or if AliasAnalysis is already sure it doesn't alias with anything (for instance if there is no other pointer to alias with). Two more parts in Polly assume that this load-hoisting took place: - setNewAccessRelation() which contains an assert which tests this. - BlockGenerator which would use to the base ptr from the original code if not load-hoisted (if the access expression is regenerated) Differential Revision: https://reviews.llvm.org/D30694 llvm-svn: 297195
Diffstat (limited to 'polly/test/ScopDetect/base_pointer_load_setNewAccessRelation.ll')
-rw-r--r--polly/test/ScopDetect/base_pointer_load_setNewAccessRelation.ll42
1 files changed, 42 insertions, 0 deletions
diff --git a/polly/test/ScopDetect/base_pointer_load_setNewAccessRelation.ll b/polly/test/ScopDetect/base_pointer_load_setNewAccessRelation.ll
new file mode 100644
index 00000000000..6c8b5be83c3
--- /dev/null
+++ b/polly/test/ScopDetect/base_pointer_load_setNewAccessRelation.ll
@@ -0,0 +1,42 @@
+; RUN: opt %loadPolly -polly-ignore-aliasing -polly-invariant-load-hoisting=true -polly-import-jscop -polly-import-jscop-dir=%S -polly-scops -polly-codegen -analyze < %s | FileCheck %s
+;
+; This violated an assertion in setNewAccessRelation that assumed base pointers
+; to be load-hoisted. Without this assertion, it codegen would generate invalid
+; code.
+;
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
+
+define void @base_pointer_load_is_inst_inside_invariant_1(i64 %n, float** %A) {
+entry:
+ br label %for.i
+
+for.i:
+ %indvar.i = phi i64 [ %indvar.i.next, %for.i.inc ], [ 0, %entry ]
+ br label %S1
+
+S1:
+ %ptr = load float*, float** %A
+ %conv = sitofp i64 %indvar.i to float
+ %arrayidx5 = getelementptr float, float* %ptr, i64 %indvar.i
+ store float %conv, float* %arrayidx5, align 4
+ br label %for.i.inc
+
+for.i.inc:
+ %indvar.i.next = add i64 %indvar.i, 1
+ %exitcond.i = icmp ne i64 %indvar.i.next, %n
+ br i1 %exitcond.i, label %for.i, label %exit
+
+exit:
+ ret void
+}
+
+
+; Detected by -polly-detect with required load hoist.
+; CHECK-NOT: Valid Region for Scop: for.i => exit
+;
+; Load hoist if %ptr by -polly-scops.
+; CHECK: Invariant Accesses: {
+; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
+; CHECK-NEXT: [n] -> { Stmt_S1[i0] -> MemRef_A[0] };
+; CHECK-NEXT: Execution Context: [n] -> { : n > 0 }
+; CHECK-NEXT: }
OpenPOWER on IntegriCloud