1 ; RUN: opt %loadNPMPolly -polly-stmt-granularity=bb '-passes=print<polly-delicm>' -disable-output < %s | FileCheck %s -match-full-lines
3 ; Reduction over parametric number of elements and a loopguard if the
4 ; reduction loop is not executed at all, such that A[j] is also not written to.
5 ; Reduction variable promoted to register.
7 ; void func(double *A) {
8 ; for (int j = 0; j < 2; j += 1) { /* outer */
11 ; for (int i = 0; i < n; i += 1) /* reduction */
18 define void @func(i32 %n, ptr noalias nonnull %A) {
20 br label %outer.preheader
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.guard, label %outer.exit
32 %A_idx = getelementptr inbounds double, ptr %A, i32 %j
33 %init = load double, ptr %A_idx
34 %guard.cmp = icmp sle i32 %n,0
35 br i1 %guard.cmp, label %reduction.skip, label %reduction.for
38 %i = phi i32 [0, %reduction.guard], [%i.inc, %reduction.inc]
39 %phi = phi double [%init, %reduction.guard], [%add, %reduction.inc]
45 %add = fadd double %phi, 4.2
46 br label %reduction.inc
51 %i.inc = add nuw nsw i32 %i, 1
52 %i.cmp = icmp slt i32 %i.inc, %n
53 br i1 %i.cmp, label %reduction.for, label %reduction.exit
56 store double %add, ptr %A_idx
57 br label %reduction.skip
65 %j.inc = add nuw nsw i32 %j, 1
77 ; CHECK: Compatible overwrites: 1
78 ; CHECK: Overwrites mapped to: 1
79 ; CHECK: Value scalars mapped: 2
80 ; CHECK: PHI scalars mapped: 1
83 ; CHECK: After accesses {
84 ; CHECK-NEXT: Stmt_reduction_guard
85 ; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
86 ; CHECK-NEXT: [n] -> { Stmt_reduction_guard[i0] -> MemRef_A[i0] };
87 ; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
88 ; CHECK-NEXT: [n] -> { Stmt_reduction_guard[i0] -> MemRef_phi__phi[] };
89 ; CHECK-NEXT: new: [n] -> { Stmt_reduction_guard[i0] -> MemRef_A[i0] : n > 0 };
90 ; CHECK-NEXT: Stmt_reduction_for
91 ; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
92 ; CHECK-NEXT: [n] -> { Stmt_reduction_for[i0, i1] -> MemRef_phi__phi[] };
93 ; CHECK-NEXT: new: [n] -> { Stmt_reduction_for[i0, i1] -> MemRef_A[i0] };
94 ; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
95 ; CHECK-NEXT: [n] -> { Stmt_reduction_for[i0, i1] -> MemRef_phi[] };
96 ; CHECK-NEXT: new: [n] -> { Stmt_reduction_for[i0, i1] -> MemRef_A[i0] };
97 ; CHECK-NEXT: Stmt_body
98 ; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
99 ; CHECK-NEXT: [n] -> { Stmt_body[i0, i1] -> MemRef_add[] };
100 ; CHECK-NEXT: new: [n] -> { Stmt_body[i0, i1] -> MemRef_A[i0] };
101 ; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
102 ; CHECK-NEXT: [n] -> { Stmt_body[i0, i1] -> MemRef_phi[] };
103 ; CHECK-NEXT: new: [n] -> { Stmt_body[i0, i1] -> MemRef_A[i0] };
104 ; CHECK-NEXT: Stmt_reduction_inc
105 ; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
106 ; CHECK-NEXT: [n] -> { Stmt_reduction_inc[i0, i1] -> MemRef_add[] };
107 ; CHECK-NEXT: new: [n] -> { Stmt_reduction_inc[i0, i1] -> MemRef_A[i0] };
108 ; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
109 ; CHECK-NEXT: [n] -> { Stmt_reduction_inc[i0, i1] -> MemRef_phi__phi[] };
110 ; CHECK-NEXT: new: [n] -> { Stmt_reduction_inc[i0, i1] -> MemRef_A[i0] : i1 <= -2 + n };
111 ; CHECK-NEXT: Stmt_reduction_exit
112 ; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]
113 ; CHECK-NEXT: [n] -> { Stmt_reduction_exit[i0] -> MemRef_A[i0] };
114 ; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
115 ; CHECK-NEXT: [n] -> { Stmt_reduction_exit[i0] -> MemRef_add[] };
116 ; CHECK-NEXT: new: [n] -> { Stmt_reduction_exit[i0] -> MemRef_A[i0] };