1; RUN: opt %loadPolly -polly-delicm -analyze < %s | FileCheck %s
2;
3;    void func(double *A) {
4;      for (int j = 0; j < 2; j += 1) { /* outer */
5;        double phi1 = 0.0, phi2 = 0.0;
6;        for (int i = 0; i < 4; i += 1) { /* reduction */
7;          phi1 += 4.2;
8;          phi2 += 29.0;
9;        }
10;        A[j] = phi1 + phi2;
11;      }
12;    }
13;
14; Check that we cannot map both, %phi1 and %phi2 to A[j] (conflict).
15; Note that it is undefined which one will be mapped. We keep the test
16; symmetric so it passes if either one is mapped.
17;
18define void @func(double* noalias nonnull %A) {
19entry:
20  br label %outer.preheader
21
22outer.preheader:
23  br label %outer.for
24
25outer.for:
26  %j = phi i32 [0, %outer.preheader], [%j.inc, %outer.inc]
27  %j.cmp = icmp slt i32 %j, 2
28  br i1 %j.cmp, label %reduction.preheader, label %outer.exit
29
30
31    reduction.preheader:
32      br label %reduction.for
33
34    reduction.for:
35      %i = phi i32 [0, %reduction.preheader], [%i.inc, %reduction.inc]
36      %phi1 = phi double [0.0, %reduction.preheader], [%add1, %reduction.inc]
37      %phi2 = phi double [0.0, %reduction.preheader], [%add2, %reduction.inc]
38      %i.cmp = icmp slt i32 %i, 4
39      br i1 %i.cmp, label %body, label %reduction.exit
40
41
42
43        body:
44          %add1 = fadd double %phi1, 4.2
45          %add2 = fadd double %phi2, 29.0
46          br label %reduction.inc
47
48
49
50    reduction.inc:
51      %i.inc = add nuw nsw i32 %i, 1
52      br label %reduction.for
53
54    reduction.exit:
55      %A_idx = getelementptr inbounds double, double* %A, i32 %j
56      %sum = fadd double %phi1, %phi2
57      store double %sum, double* %A_idx
58      br label %outer.inc
59
60
61
62outer.inc:
63  %j.inc = add nuw nsw i32 %j, 1
64  br label %outer.for
65
66outer.exit:
67  br label %return
68
69return:
70  ret void
71}
72
73
74; CHECK: Statistics {
75; CHECK:     Compatible overwrites: 1
76; CHECK:     Overwrites mapped to:  1
77; CHECK:     Value scalars mapped:  2
78; CHECK:     PHI scalars mapped:    1
79; CHECK: }
80