diff options
author | Michael Kruse <llvm@meinersbur.de> | 2017-03-07 20:28:43 +0000 |
---|---|---|
committer | Michael Kruse <llvm@meinersbur.de> | 2017-03-07 20:28:43 +0000 |
commit | 5a4ec5c42b84a56b8c7177f04bd65183f5286402 (patch) | |
tree | 551e24e15ecfc184d8cea862853eeb4f7a974933 /polly/test/ScopDetect | |
parent | 06b1af5bf1172be1b3f6fa762f0c901656678e6d (diff) | |
download | bcm5719-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')
3 files changed, 76 insertions, 1 deletions
diff --git a/polly/test/ScopDetect/base_pointer.ll b/polly/test/ScopDetect/base_pointer.ll index 8a176b52fbb..9b3e6d658f0 100644 --- a/polly/test/ScopDetect/base_pointer.ll +++ b/polly/test/ScopDetect/base_pointer.ll @@ -1,4 +1,4 @@ -; RUN: opt %loadPolly -disable-basicaa -polly-detect -analyze < %s | FileCheck %s +; RUN: opt %loadPolly -disable-basicaa -polly-detect -polly-invariant-load-hoisting=true -analyze < %s | FileCheck %s 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" diff --git a/polly/test/ScopDetect/base_pointer_load_is_inst_inside_invariant_1___%for.i---%exit.jscop b/polly/test/ScopDetect/base_pointer_load_is_inst_inside_invariant_1___%for.i---%exit.jscop new file mode 100644 index 00000000000..71e43070d19 --- /dev/null +++ b/polly/test/ScopDetect/base_pointer_load_is_inst_inside_invariant_1___%for.i---%exit.jscop @@ -0,0 +1,33 @@ +{ + "arrays" : [ + { + "name" : "MemRef_A", + "sizes" : [ "*" ], + "type" : "float*" + }, + { + "name" : "MemRef_ptr", + "sizes" : [ "*" ], + "type" : "float" + } + ], + "context" : "[n] -> { : -9223372036854775808 <= n <= 9223372036854775807 }", + "name" : "%for.i---%exit", + "statements" : [ + { + "accesses" : [ + { + "kind" : "read", + "relation" : "[n] -> { Stmt_S1[i0] -> MemRef_A[0] }" + }, + { + "kind" : "write", + "relation" : "[n] -> { Stmt_S1[i0] -> MemRef_ptr[i0+1] }" + } + ], + "domain" : "[n] -> { Stmt_S1[i0] : 0 <= i0 < n }", + "name" : "Stmt_S1", + "schedule" : "[n] -> { Stmt_S1[i0] -> [i0] }" + } + ] +} 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: } |