• 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;
3;    void func(double *A, double Start) {
4;      for (int j = 0; j < 2; j += 1) { /* outer */
5;        double phi = Start;
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, double %Start) {
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 [%Start, %reduction.preheader], [%add, %reduction.inc]
31      br label %body
32
33
34
35        body:
36          %add = fadd double %phi, 4.2
37          br label %reduction.inc
38
39
40
41    reduction.inc:
42      %i.inc = add nuw nsw i32 %i, 1
43      %i.cmp = icmp slt i32 %i.inc, 4
44      br i1 %i.cmp, label %reduction.for, label %reduction.exit
45
46    reduction.exit:
47      %A_idx = getelementptr inbounds double, double* %A, i32 %j
48      store double %add, 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; CHECK:      After accesses {
65; CHECK-NEXT:     Stmt_reduction_preheader
66; CHECK-NEXT:             ReadAccess :=       [Reduction Type: NONE] [Scalar: 1]
67; CHECK-NEXT:                 { Stmt_reduction_preheader[i0] -> MemRef_Start[] };
68; CHECK-NEXT:             MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 1]
69; CHECK-NEXT:                 { Stmt_reduction_preheader[i0] -> MemRef_phi__phi[] };
70; CHECK-NEXT:            new: { Stmt_reduction_preheader[i0] -> MemRef_A[i0] };
71; CHECK-NEXT:     Stmt_reduction_for
72; CHECK-NEXT:             ReadAccess :=       [Reduction Type: NONE] [Scalar: 1]
73; CHECK-NEXT:                 { Stmt_reduction_for[i0, i1] -> MemRef_phi__phi[] };
74; CHECK-NEXT:            new: { Stmt_reduction_for[i0, i1] -> MemRef_A[i0] };
75; CHECK-NEXT:             MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 1]
76; CHECK-NEXT:                 { Stmt_reduction_for[i0, i1] -> MemRef_phi[] };
77; CHECK-NEXT:            new: { Stmt_reduction_for[i0, i1] -> MemRef_A[i0] };
78; CHECK-NEXT:     Stmt_body
79; CHECK-NEXT:             MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 1]
80; CHECK-NEXT:                 { Stmt_body[i0, i1] -> MemRef_add[] };
81; CHECK-NEXT:            new: { Stmt_body[i0, i1] -> MemRef_A[i0] };
82; CHECK-NEXT:             ReadAccess :=       [Reduction Type: NONE] [Scalar: 1]
83; CHECK-NEXT:                 { Stmt_body[i0, i1] -> MemRef_phi[] };
84; CHECK-NEXT:            new: {  Stmt_body[i0, i1] -> MemRef_A[i0] : 3i1 <= 22 - 14i0; Stmt_body[1, 3] -> MemRef_A[1] };
85; CHECK-NEXT:     Stmt_reduction_inc
86; CHECK-NEXT:             ReadAccess :=       [Reduction Type: NONE] [Scalar: 1]
87; CHECK-NEXT:                 { Stmt_reduction_inc[i0, i1] -> MemRef_add[] };
88; CHECK-NEXT:            new: { Stmt_reduction_inc[i0, i1] -> MemRef_A[i0] : 3i1 <= 22 - 14i0; Stmt_reduction_inc[1, 3] -> MemRef_A[1] };
89; CHECK-NEXT:             MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 1]
90; CHECK-NEXT:                 { Stmt_reduction_inc[i0, i1] -> MemRef_phi__phi[] };
91; CHECK-NEXT:            new: { Stmt_reduction_inc[i0, i1] -> MemRef_A[i0] };
92; CHECK-NEXT:     Stmt_reduction_exit
93; CHECK-NEXT:             MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 0]
94; CHECK-NEXT:                 { Stmt_reduction_exit[i0] -> MemRef_A[i0] };
95; CHECK-NEXT:             ReadAccess :=       [Reduction Type: NONE] [Scalar: 1]
96; CHECK-NEXT:                 { Stmt_reduction_exit[i0] -> MemRef_add[] };
97; CHECK-NEXT:            new: { Stmt_reduction_exit[i0] -> MemRef_A[i0] };
98; CHECK-NEXT: }
99