1 ; RUN: opt %loadPolly -polly-flatten-schedule -polly-print-delicm -disable-output < %s | FileCheck %s
3 ; void func(double *A) {
4 ; for (int j = 0; j < 2; j += 1) { /* outer */
6 ; for (int i = 0; i < 4; i += 1) /* reduction */
12 define void @func(ptr noalias nonnull %A) {
14 br label %outer.preheader
20 %j = phi i32 [0, %outer.preheader], [%j.inc, %outer.inc]
21 %j.cmp = icmp slt i32 %j, 2
22 br i1 %j.cmp, label %reduction.preheader, label %outer.exit
26 br label %reduction.for
29 %i = phi i32 [0, %reduction.preheader], [%i.inc, %reduction.inc]
30 %phi = phi double [0.0, %reduction.preheader], [%add, %reduction.inc]
31 %i.cmp = icmp slt i32 %i, 4
32 br i1 %i.cmp, label %body, label %reduction.exit
37 %add = fadd double %phi, 4.2
38 br label %reduction.inc
43 %i.inc = add nuw nsw i32 %i, 1
44 br label %reduction.for
47 %A_idx = getelementptr inbounds double, ptr %A, i32 %j
48 store double %phi, ptr %A_idx
54 %j.inc = add nuw nsw i32 %j, 1
65 ; Unrolled flattened schedule:
66 ; [0] Stmt_reduction_preheader[0]
67 ; [1] Stmt_reduction_for[0, 0]
69 ; [3] Stmt_reduction_inc[0, 0]
70 ; [4] Stmt_reduction_for[0, 1]
72 ; [6] Stmt_reduction_inc[0, 1]
73 ; [7] Stmt_reduction_for[0, 2]
75 ; [9] Stmt_reduction_inc[0, 2]
76 ; [10] Stmt_reduction_for[0, 3]
77 ; [11] Stmt_body[0, 3]
78 ; [12] Stmt_reduction_inc[0, 3]
79 ; [13] Stmt_reduction_for[0, 4]
80 ; [14] Stmt_reduction_exit[0]
81 ; [15] Stmt_reduction_preheader[0]
82 ; [16] Stmt_reduction_for[1, 0]
83 ; [17] Stmt_body[1, 0]
84 ; [18] Stmt_reduction_inc[1, 0]
85 ; [19] Stmt_reduction_for[1, 1]
86 ; [20] Stmt_body[1, 1]
87 ; [21] Stmt_reduction_inc[1, 1]
88 ; [22] Stmt_reduction_for[1, 2]
89 ; [23] Stmt_body[1, 2]
90 ; [24] Stmt_reduction_inc[1, 2]
91 ; [25] Stmt_reduction_for[1, 3]
92 ; [26] Stmt_body[1, 3]
93 ; [27] Stmt_reduction_inc[1, 3]
94 ; [28] Stmt_reduction_for[1, 4]
95 ; [29] Stmt_reduction_exit[1]
97 ; CHECK: After accesses {
98 ; CHECK-NEXT: Stmt_reduction_preheader
99 ; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
100 ; CHECK-NEXT: { Stmt_reduction_preheader[i0] -> MemRef_phi__phi[] };
101 ; CHECK-NEXT: new: { Stmt_reduction_preheader[i0] -> MemRef_A[i0] };
102 ; CHECK-NEXT: Stmt_reduction_for
103 ; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
104 ; CHECK-NEXT: { Stmt_reduction_for[i0, i1] -> MemRef_phi__phi[] };
105 ; CHECK-NEXT: new: { Stmt_reduction_for[i0, i1] -> MemRef_A[i0] };
106 ; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
107 ; CHECK-NEXT: { Stmt_reduction_for[i0, i1] -> MemRef_phi[] };
108 ; CHECK-NEXT: new: { Stmt_reduction_for[i0, i1] -> MemRef_A[i0] };
109 ; CHECK-NEXT: Stmt_body
110 ; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
111 ; CHECK-NEXT: { Stmt_body[i0, i1] -> MemRef_add[] };
112 ; CHECK-NEXT: new: { Stmt_body[i0, i1] -> MemRef_A[i0] };
113 ; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
114 ; CHECK-NEXT: { Stmt_body[i0, i1] -> MemRef_phi[] };
115 ; CHECK-NEXT: new: { Stmt_body[i0, i1] -> MemRef_A[i0] };
116 ; CHECK-NEXT: Stmt_reduction_inc
117 ; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
118 ; CHECK-NEXT: { Stmt_reduction_inc[i0, i1] -> MemRef_add[] };
119 ; CHECK-NEXT: new: { Stmt_reduction_inc[i0, i1] -> MemRef_A[i0] : i1 <= 7 - 5i0; Stmt_reduction_inc[1, 3] -> MemRef_A[1] };
120 ; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
121 ; CHECK-NEXT: { Stmt_reduction_inc[i0, i1] -> MemRef_phi__phi[] };
122 ; CHECK-NEXT: new: { Stmt_reduction_inc[i0, i1] -> MemRef_A[i0] };
123 ; CHECK-NEXT: Stmt_reduction_exit
124 ; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]
125 ; CHECK-NEXT: { Stmt_reduction_exit[i0] -> MemRef_A[i0] };
126 ; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
127 ; CHECK-NEXT: { Stmt_reduction_exit[i0] -> MemRef_phi[] };
128 ; CHECK-NEXT: new: { Stmt_reduction_exit[i0] -> MemRef_A[i0] };