1 ; RUN: opt %loadPolly -polly-stmt-granularity=bb -polly-invariant-load-hoisting -polly-flatten-schedule -polly-delicm-overapproximate-writes=true -polly-delicm-compute-known=true -polly-print-delicm -disable-output < %s | FileCheck %s
3 ; void func(int *A, int* StartPtr) {
4 ; for (int j = 0; j < 2; j += 1) { /* outer */
5 ; int Start = *Startptr;
7 ; for (int i = Start; i < 4; i += 1) /* reduction */
13 define void @func(ptr noalias nonnull %A, ptr noalias nonnull %StartPtr) {
15 br label %outer.preheader
21 %j = phi i32 [0, %outer.preheader], [%j.inc, %outer.inc]
22 %j.cmp = icmp slt i32 %j, 2
23 br i1 %j.cmp, label %reduction.preheader, label %outer.exit
27 %Start = load i32, ptr %StartPtr
28 br label %reduction.for
31 %i = phi i32 [%Start, %reduction.preheader], [%i.inc, %reduction.inc]
32 %phi = phi i32 [%Start, %reduction.preheader], [%mul, %reduction.inc]
38 %mul = mul i32 %phi, 2
39 br label %reduction.inc
44 %i.inc = add nuw nsw i32 %i, 1
45 %i.cmp = icmp slt i32 %i.inc, 4
46 br i1 %i.cmp, label %reduction.for, label %reduction.exit
49 %A_idx = getelementptr inbounds i32, ptr %A, i32 %j
50 store i32 %mul, ptr %A_idx
56 %j.inc = add nuw nsw i32 %j, 1
66 ; FIXME: The accesses for %i should not be there because, with
67 ; load-hoisting %Start is an affine loop. To be fixed in ScopBuilder.
69 ; CHECK: After accesses {
70 ; CHECK-NEXT: Stmt_reduction_preheader
71 ; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
72 ; CHECK-NEXT: [Start] -> { Stmt_reduction_preheader[i0] -> MemRef_phi__phi[] };
73 ; CHECK-NEXT: new: [Start] -> { Stmt_reduction_preheader[i0] -> MemRef_A[i0] };
74 ; CHECK-NEXT: Stmt_reduction_for
75 ; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
76 ; CHECK-NEXT: [Start] -> { Stmt_reduction_for[i0, i1] -> MemRef_phi__phi[] };
77 ; CHECK-NEXT: new: [Start] -> { Stmt_reduction_for[i0, i1] -> MemRef_A[i0] : -i0 < i1 <= 3 - Start; Stmt_reduction_for[1, 0] -> MemRef_A[1] : Start >= 4; Stmt_reduction_for[0, 0] -> MemRef_A[0] };
78 ; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
79 ; CHECK-NEXT: [Start] -> { Stmt_reduction_for[i0, i1] -> MemRef_phi[] };
80 ; CHECK-NEXT: new: [Start] -> { Stmt_reduction_for[i0, i1] -> MemRef_A[i0] : i0 <= i1 <= 3 - Start; Stmt_reduction_for[i0, 0] -> MemRef_A[i0] : i0 <= -4 + Start; Stmt_reduction_for[1, 0] -> MemRef_A[1] : Start <= 4 }
81 ; CHECK-NEXT: Stmt_body
82 ; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
83 ; CHECK-NEXT: [Start] -> { Stmt_body[i0, i1] -> MemRef_mul[] };
84 ; CHECK-NEXT: new: [Start] -> { Stmt_body[i0, i1] -> MemRef_A[i0] : i0 <= i1 <= 3 - Start; Stmt_body[i0, 0] -> MemRef_A[i0] : i0 <= -4 + Start; Stmt_body[1, 0] -> MemRef_A[1] : Start <= 4 }
85 ; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
86 ; CHECK-NEXT: [Start] -> { Stmt_body[i0, i1] -> MemRef_phi[] };
87 ; CHECK-NEXT: new: [Start] -> { Stmt_body[i0, i1] -> MemRef_A[i0] : i0 <= i1 <= 3 - Start; Stmt_body[1, 0] -> MemRef_A[1]; Stmt_body[0, 0] -> MemRef_A[0] : Start >= 4 };
88 ; CHECK-NEXT: Stmt_reduction_inc
89 ; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
90 ; CHECK-NEXT: [Start] -> { Stmt_reduction_inc[i0, i1] -> MemRef_mul[] };
91 ; CHECK-NEXT: new: [Start] -> { Stmt_reduction_inc[i0, i1] -> MemRef_A[i0] : i0 <= i1 <= 3 - Start; Stmt_reduction_inc[1, 0] -> MemRef_A[1]; Stmt_reduction_inc[0, 0] -> MemRef_A[0] : Start >= 4 };
92 ; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1]
93 ; CHECK-NEXT: [Start] -> { Stmt_reduction_inc[i0, i1] -> MemRef_phi__phi[] };
94 ; CHECK-NEXT: new: [Start] -> { Stmt_reduction_inc[i0, i1] -> MemRef_A[i0] : 0 < i1 <= 3 - Start; Stmt_reduction_inc[i0, 0] -> MemRef_A[i0] }
95 ; CHECK-NEXT: Stmt_reduction_exit
96 ; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]
97 ; CHECK-NEXT: [Start] -> { Stmt_reduction_exit[i0] -> MemRef_A[i0] };
98 ; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1]
99 ; CHECK-NEXT: [Start] -> { Stmt_reduction_exit[i0] -> MemRef_mul[] };
100 ; CHECK-NEXT: new: [Start] -> { Stmt_reduction_exit[i0] -> MemRef_A[i0] };