1 ; RUN: opt %loadPolly -polly-stmt-granularity=bb -polly-print-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. Load hoisted before loop.
6 ; void func(double *A) {
7 ; for (int j = 0; j < 2; j += 1) { /* outer */
9 ; for (int i = 0; i < n; i += 1) { /* reduction */
16 define void @func(i32 %n, ptr noalias nonnull %A) {
18 br label %outer.preheader
24 %j = phi i32 [0, %outer.preheader], [%j.inc, %outer.inc]
25 %j.cmp = icmp slt i32 %j, 2
26 br i1 %j.cmp, label %reduction.preheader, label %outer.exit
30 %guard.cmp = icmp sle i32 %n,0
31 br i1 %guard.cmp, label %reduction.exit, label %reduction.for
34 %i = phi i32 [0, %reduction.preheader], [%i.inc, %reduction.inc]
35 %phi = phi double [0.0, %reduction.preheader], [%add, %reduction.inc]
41 %add = fadd double %phi, 4.2
42 %A_idx = getelementptr inbounds double, ptr %A, i32 %j
43 store double %add, ptr %A_idx
44 br label %reduction.inc
49 %i.inc = add nuw nsw i32 %i, 1
50 %i.cmp = icmp slt i32 %i.inc, %n
51 br i1 %i.cmp, label %reduction.for, label %reduction.exit
59 %j.inc = add nuw nsw i32 %j, 1
71 ; CHECK: Compatible overwrites: 1
72 ; CHECK: Overwrites mapped to: 1
73 ; CHECK: Value scalars mapped: 2
74 ; CHECK: PHI scalars mapped: 1
77 ; CHECK: After accesses {
78 ; CHECK-NEXT: Stmt_reduction_preheader
79 ; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
80 ; CHECK-NEXT: [n] -> { Stmt_reduction_preheader[i0] -> MemRef_phi__phi[] };
81 ; CHECK-NEXT: new: [n] -> { Stmt_reduction_preheader[i0] -> MemRef_A[i0] : n > 0 };
82 ; CHECK-NEXT: Stmt_reduction_for
83 ; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
84 ; CHECK-NEXT: [n] -> { Stmt_reduction_for[i0, i1] -> MemRef_phi__phi[] };
85 ; CHECK-NEXT: new: [n] -> { Stmt_reduction_for[i0, i1] -> MemRef_A[i0] };
86 ; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
87 ; CHECK-NEXT: [n] -> { Stmt_reduction_for[i0, i1] -> MemRef_phi[] };
88 ; CHECK-NEXT: new: [n] -> { Stmt_reduction_for[i0, i1] -> MemRef_A[i0] };
89 ; CHECK-NEXT: Stmt_body
90 ; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
91 ; CHECK-NEXT: [n] -> { Stmt_body[i0, i1] -> MemRef_add[] };
92 ; CHECK-NEXT: new: [n] -> { Stmt_body[i0, i1] -> MemRef_A[i0] };
93 ; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
94 ; CHECK-NEXT: [n] -> { Stmt_body[i0, i1] -> MemRef_phi[] };
95 ; CHECK-NEXT: new: [n] -> { Stmt_body[i0, i1] -> MemRef_A[i0] };
96 ; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]
97 ; CHECK-NEXT: [n] -> { Stmt_body[i0, i1] -> MemRef_A[i0] };
98 ; CHECK-NEXT: Stmt_reduction_inc
99 ; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
100 ; CHECK-NEXT: [n] -> { Stmt_reduction_inc[i0, i1] -> MemRef_add[] };
101 ; CHECK-NEXT: new: [n] -> { Stmt_reduction_inc[i0, i1] -> MemRef_A[i0] };
102 ; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
103 ; CHECK-NEXT: [n] -> { Stmt_reduction_inc[i0, i1] -> MemRef_phi__phi[] };
104 ; CHECK-NEXT: new: [n] -> { Stmt_reduction_inc[i0, i1] -> MemRef_A[i0] : i1 <= -2 + n };