[polly] r252615 - tests: Add test that has a single pointer both as scalar read and array base

Tobias Grosser via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 10 08:23:30 PST 2015


Author: grosser
Date: Tue Nov 10 10:23:30 2015
New Revision: 252615

URL: http://llvm.org/viewvc/llvm-project?rev=252615&view=rev
Log:
tests: Add test that has a single pointer both as scalar read and array base

In case we also model scalar reads it can happen that a pointer appears in both
a scalar read access as well as the base pointer of an array access. As this
is a little surprising, we add a specific test case to document this behaviour.
To my understanding it should be OK to have a read from an array A[] and
read/write accesses to A[...]. isl is treating these arrays as unrelated as
their dimensionality differs. This seems to be correct as A[] remains constant
throughout the execution of the scop and is not affected by the reads/writes to
A[...]. If this causes confusion, it might make sense to make this behaviour
more obvious by using different names (e.g., A_scalar[], A[...]).

Added:
    polly/trunk/test/ScopInfo/pointer-used-as-base-pointer-and-scalar-read.ll

Added: polly/trunk/test/ScopInfo/pointer-used-as-base-pointer-and-scalar-read.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/pointer-used-as-base-pointer-and-scalar-read.ll?rev=252615&view=auto
==============================================================================
--- polly/trunk/test/ScopInfo/pointer-used-as-base-pointer-and-scalar-read.ll (added)
+++ polly/trunk/test/ScopInfo/pointer-used-as-base-pointer-and-scalar-read.ll Tue Nov 10 10:23:30 2015
@@ -0,0 +1,88 @@
+; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s
+
+; In this test case we pass a pointer %A into a PHI node and also use this
+; pointer as base pointer of an array store. As a result, we get both scalar
+; and array memory accesses to A[] and A[0].
+
+; CHECK: Arrays {
+; CHECK:     float MemRef_A[*]; // Element size 4
+; CHECK:     float* MemRef_A; // Element size 0
+; CHECK:     float* MemRef_x__phi; // Element size 0
+; CHECK:     float* MemRef_B; // Element size 0
+; CHECK:     float* MemRef_C[*]; // Element size 0
+; CHECK: }
+; CHECK: Arrays (Bounds as pw_affs) {
+; CHECK:     float MemRef_A[*]; // Element size 4
+; CHECK:     float* MemRef_A; // Element size 0
+; CHECK:     float* MemRef_x__phi; // Element size 0
+; CHECK:     float* MemRef_B; // Element size 0
+; CHECK:     float* MemRef_C[*]; // Element size 0
+; CHECK: }
+; CHECK: Alias Groups (0):
+; CHECK:     n/a
+; CHECK: Statements {
+; CHECK:   Stmt_then
+; CHECK:         Domain :=
+; CHECK:             [p] -> { Stmt_then[i0] : p = 32 and i0 <= 999 and i0 >= 0 };
+; CHECK:         Schedule :=
+; CHECK:             [p] -> { Stmt_then[i0] -> [i0, 1] };
+; CHECK:         MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 0]
+; CHECK:             [p] -> { Stmt_then[i0] -> MemRef_A[0] };
+; CHECK:         ReadAccess :=       [Reduction Type: NONE] [Scalar: 1]
+; CHECK:             [p] -> { Stmt_then[i0] -> MemRef_A[] };
+; CHECK:         MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 1]
+; CHECK:             [p] -> { Stmt_then[i0] -> MemRef_x__phi[] };
+; CHECK:   Stmt_else
+; CHECK:         Domain :=
+; CHECK:             [p] -> { Stmt_else[i0] : (p >= 33 and i0 <= 999 and i0 >= 0) or (p <= 31 and i0 <= 999 and i0 >= 0) };
+; CHECK:         Schedule :=
+; CHECK:             [p] -> { Stmt_else[i0] -> [i0, 0] : p >= 33 or p <= 31 };
+; CHECK:         MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 0]
+; CHECK:             [p] -> { Stmt_else[i0] -> MemRef_A[0] };
+; CHECK:         ReadAccess :=       [Reduction Type: NONE] [Scalar: 1]
+; CHECK:             [p] -> { Stmt_else[i0] -> MemRef_B[] };
+; CHECK:         MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 1]
+; CHECK:             [p] -> { Stmt_else[i0] -> MemRef_x__phi[] };
+; CHECK:   Stmt_bb8
+; CHECK:         Domain :=
+; CHECK:             [p] -> { Stmt_bb8[i0] : (p >= 33 and i0 <= 999 and i0 >= 0) or (p <= 32 and i0 <= 999 and i0 >= 0) };
+; CHECK:         Schedule :=
+; CHECK:             [p] -> { Stmt_bb8[i0] -> [i0, 2] };
+; CHECK:         ReadAccess :=       [Reduction Type: NONE] [Scalar: 1]
+; CHECK:             [p] -> { Stmt_bb8[i0] -> MemRef_x__phi[] };
+; CHECK:         MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 0]
+; CHECK:             [p] -> { Stmt_bb8[i0] -> MemRef_C[0] };
+
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+
+define void @foo(float* noalias %A, float* noalias %B, float ** noalias %C, i32 %p) {
+bb:
+  br label %bb1
+
+bb1:
+  %i.0 = phi i64 [ 0, %bb ], [ %tmp9, %bb8 ]
+  %exitcond = icmp ne i64 %i.0, 1000
+  br i1 %exitcond, label %bb2, label %bb10
+
+bb2:
+  %cmp = icmp eq i32 %p, 32
+  br i1 %cmp, label %then, label %else
+
+then:
+  store float 3.0, float* %A
+  br label %bb8
+
+else:
+  store float 4.0, float* %A
+  br label %bb8
+
+bb8:
+  %x = phi float* [%A, %then], [%B, %else]
+  store float* %x, float** %C
+  %tmp9 = add nuw nsw i64 %i.0, 1
+  br label %bb1
+
+bb10:
+  ret void
+}




More information about the llvm-commits mailing list