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 phi = 0.0;
6;        for (int i = 0; i < 4; i += 1) /* reduction */
7;          phi += 4.2;
8;        if (phi < 0.0)
9;          A[j] = undef;
10;        A[j] = phi;
11;      }
12;    }
13;
14; The MAY_WRITE in reduction.exit.true avoids that anything can be mapped to
15; A[j] because it would be overwritten by that MAY_WRITE just before the final
16; MUST_WRITE. Also nothing can be map to the MAY_WRITE itself because it is a
17; MAY_WRITE.
18;
19define void @func(double* noalias nonnull %A) {
20entry:
21  %fsomeval = fadd double 21.0, 21.0
22  br label %outer.preheader
23
24outer.preheader:
25  br label %outer.for
26
27outer.for:
28  %j = phi i32 [0, %outer.preheader], [%j.inc, %outer.inc]
29  %j.cmp = icmp slt i32 %j, 2
30  br i1 %j.cmp, label %reduction.preheader, label %outer.exit
31
32
33    reduction.preheader:
34      br label %reduction.for
35
36    reduction.for:
37      %i = phi i32 [0, %reduction.preheader], [%i.inc, %reduction.inc]
38      %phi = phi double [0.0, %reduction.preheader], [%add, %reduction.inc]
39      %i.cmp = icmp slt i32 %i, 4
40      br i1 %i.cmp, label %body, label %reduction.exit
41
42
43
44        body:
45          %add = fadd double %phi, 4.2
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      %phi.cmp = fcmp ogt double %phi, 0.0
57      br i1 %phi.cmp, label %reduction.exit.true, label %reduction.exit.unconditional
58
59    reduction.exit.true:
60       store double undef, double* %A_idx
61       br label %reduction.exit.unconditional
62
63    reduction.exit.unconditional:
64      store double %phi, double* %A_idx
65      br label %outer.inc
66
67
68
69outer.inc:
70  %j.inc = add nuw nsw i32 %j, 1
71  br label %outer.for
72
73outer.exit:
74  br label %return
75
76return:
77  ret void
78}
79
80
81; CHECK: Statistics {
82; CHECK:     Compatible overwrites: 1
83; CHECK: }
84; CHECK: No modification has been made
85