1; RUN: opt %loadPolly -polly-stmt-granularity=bb -polly-delicm -analyze < %s | FileCheck %s -match-full-lines
2;
3; Hosted reduction load (but not the store) without preheader.
4;
5;    void func(double *A) {
6;      for (int j = 0; j < 2; j += 1) { /* outer */
7;        double phi = 0.0;
8;        for (int i = 0; i < 4; i += 1) { /* reduction */
9;          phi += 4.2;
10;          A[j] = phi;
11;        }
12;      }
13;    }
14;
15define void @func(double* noalias nonnull %A) {
16entry:
17  br label %outer.preheader
18
19outer.preheader:
20  br label %outer.for
21
22outer.for:
23  %j = phi i32 [0, %outer.preheader], [%j.inc, %outer.inc]
24  %j.cmp = icmp slt i32 %j, 2
25  br i1 %j.cmp, label %reduction.for, label %outer.exit
26
27
28    reduction.for:
29      %i = phi i32 [0, %outer.for], [%i.inc, %reduction.inc]
30      %phi = phi double [0.0, %outer.for], [%add, %reduction.inc]
31      br label %body
32
33
34
35        body:
36          %add = fadd double %phi, 4.2
37          %A_idx = getelementptr inbounds double, double* %A, i32 %j
38          store double %add, double* %A_idx
39          br label %reduction.inc
40
41
42
43    reduction.inc:
44      %i.inc = add nuw nsw i32 %i, 1
45      %i.cmp = icmp slt i32 %i.inc, 4
46      br i1 %i.cmp, label %reduction.for, label %reduction.exit
47
48    reduction.exit:
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; CHECK: Statistics {
66; CHECK:     Compatible overwrites: 1
67; CHECK:     Overwrites mapped to:  1
68; CHECK:     Value scalars mapped:  2
69; CHECK:     PHI scalars mapped:    1
70; CHECK: }
71
72; CHECK-NEXT: After accesses {
73; CHECK-NEXT:     Stmt_outer_for
74; CHECK-NEXT:             MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 1]
75; CHECK-NEXT:                 { Stmt_outer_for[i0] -> MemRef_phi__phi[] };
76; CHECK-NEXT:            new: { Stmt_outer_for[i0] -> MemRef_A[i0] : i0 <= 1 };
77; CHECK-NEXT:     Stmt_reduction_for
78; CHECK-NEXT:             ReadAccess :=       [Reduction Type: NONE] [Scalar: 1]
79; CHECK-NEXT:                 { Stmt_reduction_for[i0, i1] -> MemRef_phi__phi[] };
80; CHECK-NEXT:            new: { Stmt_reduction_for[i0, i1] -> MemRef_A[i0] };
81; CHECK-NEXT:             MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 1]
82; CHECK-NEXT:                 { Stmt_reduction_for[i0, i1] -> MemRef_phi[] };
83; CHECK-NEXT:            new: { Stmt_reduction_for[i0, i1] -> MemRef_A[i0] };
84; CHECK-NEXT:     Stmt_body
85; CHECK-NEXT:             MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 1]
86; CHECK-NEXT:                 { Stmt_body[i0, i1] -> MemRef_add[] };
87; CHECK-NEXT:            new: { Stmt_body[i0, i1] -> MemRef_A[i0] };
88; CHECK-NEXT:             ReadAccess :=       [Reduction Type: NONE] [Scalar: 1]
89; CHECK-NEXT:                 { Stmt_body[i0, i1] -> MemRef_phi[] };
90; CHECK-NEXT:            new: { Stmt_body[i0, i1] -> MemRef_A[i0] };
91; CHECK-NEXT:             MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 0]
92; CHECK-NEXT:                 { Stmt_body[i0, i1] -> MemRef_A[i0] };
93; CHECK-NEXT:     Stmt_reduction_inc
94; CHECK-NEXT:             ReadAccess :=       [Reduction Type: NONE] [Scalar: 1]
95; CHECK-NEXT:                 { Stmt_reduction_inc[i0, i1] -> MemRef_add[] };
96; CHECK-NEXT:            new: { Stmt_reduction_inc[i0, i1] -> MemRef_A[i0] };
97; CHECK-NEXT:             MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 1]
98; CHECK-NEXT:                 { Stmt_reduction_inc[i0, i1] -> MemRef_phi__phi[] };
99; CHECK-NEXT:            new: { Stmt_reduction_inc[i0, i1] -> MemRef_A[i0] : i1 <= 2 };
100; CHECK-NEXT: }
101