• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt %loadPolly -polly-flatten-schedule -polly-delicm -analyze < %s | FileCheck %s
2;
3;    void func(double *A) {
4;      for (int j = 0; j < 2; j += 1) { /* outer */
5;        double phi = 0.0;
6;        for (int i = 0; i < 4; i += 1) /* reduction */
7;          phi += 4.2;
8;        A[j] = phi;
9;      }
10;    }
11;
12define void @func(double* noalias nonnull %A) {
13entry:
14  br label %outer.preheader
15
16outer.preheader:
17  br label %outer.for
18
19outer.for:
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
23
24
25    reduction.preheader:
26      br label %reduction.for
27
28    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
33
34
35
36        body:
37          %add = fadd double %phi, 4.2
38          br label %reduction.inc
39
40
41
42    reduction.inc:
43      %i.inc = add nuw nsw i32 %i, 1
44      br label %reduction.for
45
46    reduction.exit:
47      %A_idx = getelementptr inbounds double, double* %A, i32 %j
48      store double %phi, double* %A_idx
49      br label %outer.inc
50
51
52
53outer.inc:
54  %j.inc = add nuw nsw i32 %j, 1
55  br label %outer.for
56
57outer.exit:
58  br label %return
59
60return:
61  ret void
62}
63
64
65; Unrolled flattened schedule:
66; [0] Stmt_reduction_preheader[0]
67; [1] Stmt_reduction_for[0, 0]
68; [2] Stmt_body[0, 0]
69; [3] Stmt_reduction_inc[0, 0]
70; [4] Stmt_reduction_for[0, 1]
71; [5] Stmt_body[0, 1]
72; [6] Stmt_reduction_inc[0, 1]
73; [7] Stmt_reduction_for[0, 2]
74; [8] Stmt_body[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]
96
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] };
129; CHECK-NEXT: }
130
131