xref: /llvm-project/polly/test/DeLICM/nomap_writewrite.ll (revision e1f056f692d869708c1898d9d65a69ac5584a0ed)
1; RUN: opt %loadNPMPolly '-passes=print<polly-delicm>' -disable-output < %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;          if (phi < 0.0)
8;            A[j] = undef;
9;          phi += 4.2;
10;        A[j] = phi;
11;      }
12;    }
13;
14; The MAY_WRITE in reduction.for.true conflict with a write of %phi to
15; A[j] if %phi would be mapped to it. Being a MAY_WRITE avoids being target
16; of a mapping itself.
17;
18; TODO: There is actually no reason why these conflict. The MAY_WRITE is an
19; explicit write, defined to occur always before all implicit writes as the
20; write of %phi would be. There is currently no differentiation between
21; implicit and explicit writes in Polly.
22;
23define void @func(ptr noalias nonnull %A) {
24entry:
25  %fsomeval = fadd double 21.0, 21.0
26  br label %outer.preheader
27
28outer.preheader:
29  br label %outer.for
30
31outer.for:
32  %j = phi i32 [0, %outer.preheader], [%j.inc, %outer.inc]
33  %j.cmp = icmp slt i32 %j, 2
34  br i1 %j.cmp, label %reduction.preheader, label %outer.exit
35
36
37    reduction.preheader:
38      br label %reduction.for
39
40    reduction.for:
41      %i = phi i32 [0, %reduction.preheader], [%i.inc, %reduction.inc]
42      %phi = phi double [0.0, %reduction.preheader], [%add, %reduction.inc]
43      %A_idx = getelementptr inbounds double, ptr %A, i32 %j
44      %phi.cmp = fcmp ogt double %phi, 0.0
45      br i1 %phi.cmp, label %reduction.for.true, label %reduction.for.unconditional
46
47    reduction.for.true:
48       store double undef, ptr %A_idx
49       br label %reduction.for.unconditional
50
51    reduction.for.unconditional:
52      %i.cmp = icmp slt i32 %i, 4
53      br i1 %i.cmp, label %body, label %reduction.exit
54
55
56
57        body:
58          %add = fadd double %phi, 4.2
59          br label %reduction.inc
60
61
62
63    reduction.inc:
64      %i.inc = add nuw nsw i32 %i, 1
65      br label %reduction.for
66
67    reduction.exit:
68      store double %phi, ptr %A_idx
69      br label %outer.inc
70
71
72
73outer.inc:
74  %j.inc = add nuw nsw i32 %j, 1
75  br label %outer.for
76
77outer.exit:
78  br label %return
79
80return:
81  ret void
82}
83
84
85; CHECK: Statistics {
86; CHECK:     Compatible overwrites: 1
87; CHECK: }
88; CHECK: No modification has been made
89