summaryrefslogtreecommitdiffstats
path: root/polly/test
diff options
context:
space:
mode:
authorMichael Kruse <llvm@meinersbur.de>2017-07-24 12:43:27 +0000
committerMichael Kruse <llvm@meinersbur.de>2017-07-24 12:43:27 +0000
commit07e8c36dc73fa56357f0da4ac71c559fe952b31d (patch)
treed6b599dea44fe7d77f43324496bc288365fc817f /polly/test
parente2699b572e99110dc647a9f9dd1147b70db40412 (diff)
downloadbcm5719-llvm-07e8c36dc73fa56357f0da4ac71c559fe952b31d.tar.gz
bcm5719-llvm-07e8c36dc73fa56357f0da4ac71c559fe952b31d.zip
[ForwardOpTree] Support read-only value uses.
Read-only values (values defined before the SCoP) require special handing with -polly-analyze-read-only-scalars=true (which is the default). If active, each use of a value requires a read access. When a copied value uses a read-only value, we must also ensure that such a MemoryAccess is available or is created. Differential Revision: https://reviews.llvm.org/D35764 llvm-svn: 308876
Diffstat (limited to 'polly/test')
-rw-r--r--polly/test/ForwardOpTree/forward_readonly.ll84
1 files changed, 84 insertions, 0 deletions
diff --git a/polly/test/ForwardOpTree/forward_readonly.ll b/polly/test/ForwardOpTree/forward_readonly.ll
new file mode 100644
index 00000000000..ca514cfc606
--- /dev/null
+++ b/polly/test/ForwardOpTree/forward_readonly.ll
@@ -0,0 +1,84 @@
+; RUN: opt %loadPolly -polly-analyze-read-only-scalars=true -polly-optree -analyze < %s | FileCheck %s -match-full-lines -check-prefixes=STATS,MODEL
+; RUN: opt %loadPolly -polly-analyze-read-only-scalars=false -polly-optree -analyze < %s | FileCheck %s -match-full-lines -check-prefixes=STATS,NOMODEL
+;
+; Move %val to %bodyB, so %bodyA can be removed (by -polly-simplify)
+;
+; for (int j = 0; j < n; j += 1) {
+; bodyA:
+; double val = arg + 21.0;
+;
+; bodyB:
+; A[0] = val;
+; }
+;
+define void @func(i32 %n, double* noalias nonnull %A, double %arg) {
+entry:
+ br label %for
+
+for:
+ %j = phi i32 [0, %entry], [%j.inc, %inc]
+ %j.cmp = icmp slt i32 %j, %n
+ br i1 %j.cmp, label %bodyA, label %exit
+
+ bodyA:
+ %val = fadd double %arg, 21.0
+ br label %bodyB
+
+ bodyB:
+ store double %val, double* %A
+ br label %inc
+
+inc:
+ %j.inc = add nuw nsw i32 %j, 1
+ br label %for
+
+exit:
+ br label %return
+
+return:
+ ret void
+}
+
+
+; STATS: Statistics {
+; STATS: Instructions copied: 1
+; STATS: Read-only accesses copied: 1
+; STATS: Operand trees forwarded: 1
+; STATS: Statements with forwarded operand trees: 1
+; STATS: }
+
+; MODEL: After statements {
+; MODEL-NEXT: Stmt_bodyA
+; MODEL-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
+; MODEL-NEXT: [n] -> { Stmt_bodyA[i0] -> MemRef_arg[] };
+; MODEL-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; MODEL-NEXT: [n] -> { Stmt_bodyA[i0] -> MemRef_val[] };
+; MODEL-NEXT: Instructions {
+; MODEL-NEXT: %val = fadd double %arg, 2.100000e+01
+; MODEL-NEXT: }
+; MODEL-NEXT: Stmt_bodyB
+; MODEL-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]
+; MODEL-NEXT: [n] -> { Stmt_bodyB[i0] -> MemRef_A[0] };
+; MODEL-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
+; MODEL-NEXT: [n] -> { Stmt_bodyB[i0] -> MemRef_arg[] };
+; MODEL-NEXT: Instructions {
+; MODEL-NEXT: %val = fadd double %arg, 2.100000e+01
+; MODEL-NEXT: store double %val, double* %A
+; MODEL-NEXT: }
+; MODEL-NEXT: }
+
+; NOMODEL: After statements {
+; NOMODEL-NEXT: Stmt_bodyA
+; NOMODEL-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
+; NOMODEL-NEXT: [n] -> { Stmt_bodyA[i0] -> MemRef_val[] };
+; NOMODEL-NEXT: Instructions {
+; NOMODEL-NEXT: %val = fadd double %arg, 2.100000e+01
+; NOMODEL-NEXT: }
+; NOMODEL-NEXT: Stmt_bodyB
+; NOMODEL-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]
+; NOMODEL-NEXT: [n] -> { Stmt_bodyB[i0] -> MemRef_A[0] };
+; NOMODEL-NEXT: Instructions {
+; NOMODEL-NEXT: %val = fadd double %arg, 2.100000e+01
+; NOMODEL-NEXT: store double %val, double* %A
+; NOMODEL-NEXT: }
+; NOMODEL-NEXT: }
OpenPOWER on IntegriCloud