• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt %loadPolly -polly-stmt-granularity=bb -polly-flatten-schedule -polly-delicm-overapproximate-writes=true -polly-delicm-compute-known=true -polly-delicm -analyze < %s | FileCheck %s
2; RUN: opt %loadPolly -polly-stmt-granularity=bb -polly-flatten-schedule -polly-delicm-partial-writes=true -polly-delicm-compute-known=true -polly-delicm -analyze < %s | FileCheck -check-prefix=PARTIAL %s
3;
4;    void func(double *A) {
5;      for (int j = 0; j < 2; j += 1) { /* outer */
6;        double phi = 0.0;
7;        for (int i = 0; i < 4; i += 1) { /* reduction */
8;          phi += 4.2;
9;          A[j] = phi;
10;        }
11;      }
12;    }
13;
14define void @func(double* noalias nonnull %A) {
15entry:
16  br label %outer.preheader
17
18outer.preheader:
19  br label %outer.for
20
21outer.for:
22  %j = phi i32 [0, %outer.preheader], [%j.inc, %outer.inc]
23  %j.cmp = icmp slt i32 %j, 2
24  br i1 %j.cmp, label %reduction.preheader, label %outer.exit
25
26
27    reduction.preheader:
28      br label %reduction.for
29
30    reduction.for:
31      %i = phi i32 [0, %reduction.preheader], [%i.inc, %reduction.inc]
32      %phi = phi double [0.0, %reduction.preheader], [%add, %reduction.inc]
33      br label %body
34
35
36
37        body:
38          %add = fadd double %phi, 4.2
39          %A_idx = getelementptr inbounds double, double* %A, i32 %j
40          store double %add, double* %A_idx
41          br label %reduction.inc
42
43
44
45    reduction.inc:
46      %i.inc = add nuw nsw i32 %i, 1
47      %i.cmp = icmp slt i32 %i.inc, 4
48      br i1 %i.cmp, label %reduction.for, label %reduction.exit
49
50    reduction.exit:
51      br label %outer.inc
52
53
54
55outer.inc:
56  %j.inc = add nuw nsw i32 %j, 1
57  br label %outer.for
58
59outer.exit:
60  br label %return
61
62return:
63  ret void
64}
65
66
67; CHECK:      After accesses {
68; CHECK-NEXT:    Stmt_reduction_preheader
69; CHECK-NEXT:            MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 1]
70; CHECK-NEXT:                 { Stmt_reduction_preheader[i0] -> MemRef_phi__phi[] };
71; CHECK-NEXT:            new: { Stmt_reduction_preheader[i0] -> MemRef_A[i0] };
72; CHECK-NEXT:     Stmt_reduction_for
73; CHECK-NEXT:             ReadAccess :=       [Reduction Type: NONE] [Scalar: 1]
74; CHECK-NEXT:                 { Stmt_reduction_for[i0, i1] -> MemRef_phi__phi[] };
75; CHECK-NEXT:            new: { Stmt_reduction_for[i0, i1] -> MemRef_A[i0] };
76; CHECK-NEXT:             MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 1]
77; CHECK-NEXT:                 { Stmt_reduction_for[i0, i1] -> MemRef_phi[] };
78; CHECK-NEXT:            new: { Stmt_reduction_for[i0, i1] -> MemRef_A[i0] };
79; CHECK-NEXT:     Stmt_body
80; CHECK-NEXT:             MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 1]
81; CHECK-NEXT:                 { Stmt_body[i0, i1] -> MemRef_add[] };
82; CHECK-NEXT:            new: { Stmt_body[i0, i1] -> MemRef_A[i0] };
83; CHECK-NEXT:             ReadAccess :=       [Reduction Type: NONE] [Scalar: 1]
84; CHECK-NEXT:                 { Stmt_body[i0, i1] -> MemRef_phi[] };
85; CHECK-NEXT:            new: { Stmt_body[i0, i1] -> MemRef_A[i0] : 3i1 <= 21 - 13i0; Stmt_body[1, 3] -> MemRef_A[1] };
86; CHECK-NEXT:             MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 0]
87; CHECK-NEXT:                 { Stmt_body[i0, i1] -> MemRef_A[i0] };
88; CHECK-NEXT:     Stmt_reduction_inc
89; CHECK-NEXT:             ReadAccess :=       [Reduction Type: NONE] [Scalar: 1]
90; CHECK-NEXT:                 { Stmt_reduction_inc[i0, i1] -> MemRef_add[] };
91; CHECK-NEXT:            new: { Stmt_reduction_inc[i0, i1] -> MemRef_A[i0] : 3i1 <= 21 - 13i0; Stmt_reduction_inc[1, 3] -> MemRef_A[1] };
92; CHECK-NEXT:             MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 1]
93; CHECK-NEXT:                 { Stmt_reduction_inc[i0, i1] -> MemRef_phi__phi[] };
94; CHECK-NEXT:            new: { Stmt_reduction_inc[i0, i1] -> MemRef_A[i0] };
95; CHECK-NEXT: }
96
97
98; PARTIAL:      After accesses {
99; PARTIAL-NEXT:     Stmt_reduction_preheader
100; PARTIAL-NEXT:             MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 1]
101; PARTIAL-NEXT:                 { Stmt_reduction_preheader[i0] -> MemRef_phi__phi[] };
102; PARTIAL-NEXT:            new: { Stmt_reduction_preheader[i0] -> MemRef_A[i0] };
103; PARTIAL-NEXT:     Stmt_reduction_for
104; PARTIAL-NEXT:             ReadAccess :=       [Reduction Type: NONE] [Scalar: 1]
105; PARTIAL-NEXT:                 { Stmt_reduction_for[i0, i1] -> MemRef_phi__phi[] };
106; PARTIAL-NEXT:            new: { Stmt_reduction_for[i0, i1] -> MemRef_A[i0] };
107; PARTIAL-NEXT:             MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 1]
108; PARTIAL-NEXT:                 { Stmt_reduction_for[i0, i1] -> MemRef_phi[] };
109; PARTIAL-NEXT:            new: { Stmt_reduction_for[i0, i1] -> MemRef_A[i0] };
110; PARTIAL-NEXT:     Stmt_body
111; PARTIAL-NEXT:             MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 1]
112; PARTIAL-NEXT:                 { Stmt_body[i0, i1] -> MemRef_add[] };
113; PARTIAL-NEXT:            new: { Stmt_body[i0, i1] -> MemRef_A[i0] };
114; PARTIAL-NEXT:             ReadAccess :=       [Reduction Type: NONE] [Scalar: 1]
115; PARTIAL-NEXT:                 { Stmt_body[i0, i1] -> MemRef_phi[] };
116; PARTIAL-NEXT:            new: { Stmt_body[i0, i1] -> MemRef_A[i0] : 3i1 <= 21 - 13i0; Stmt_body[1, 3] -> MemRef_A[1] };
117; PARTIAL-NEXT:             MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 0]
118; PARTIAL-NEXT:                 { Stmt_body[i0, i1] -> MemRef_A[i0] };
119; PARTIAL-NEXT:     Stmt_reduction_inc
120; PARTIAL-NEXT:             ReadAccess :=       [Reduction Type: NONE] [Scalar: 1]
121; PARTIAL-NEXT:                 { Stmt_reduction_inc[i0, i1] -> MemRef_add[] };
122; PARTIAL-NEXT:            new: { Stmt_reduction_inc[i0, i1] -> MemRef_A[i0] : 3i1 <= 21 - 13i0; Stmt_reduction_inc[1, 3] -> MemRef_A[1] };
123; PARTIAL-NEXT:             MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 1]
124; PARTIAL-NEXT:                 { Stmt_reduction_inc[i0, i1] -> MemRef_phi__phi[] };
125; PARTIAL-NEXT:            new: { Stmt_reduction_inc[i0, i1] -> MemRef_A[i0] : i1 <= 2 };
126; PARTIAL-NEXT: }
127