1; RUN: opt %loadPolly -polly-stmt-granularity=bb -polly-flatten-schedule \ 2; RUN: -polly-delicm-overapproximate-writes=true \ 3; RUN: -polly-delicm-compute-known=true -polly-delicm \ 4; RUN: -analyze < %s | FileCheck %s 5; 6; Make sure delicm works even in case two stores that store the same value. 7; 8; void func(double *A) { 9; for (int j = 0; j < 2; j += 1) { /* outer */ 10; double phi = A[j]; 11; for (int i = 0; i < 4; i += 1) /* reduction */ 12; phi += 4.2; 13; A[j] = phi; 14; } 15; } 16; 17define void @func(double* noalias nonnull %A) { 18entry: 19 br label %outer.preheader 20 21outer.preheader: 22 br label %outer.for 23 24outer.for: 25 %j = phi i32 [0, %outer.preheader], [%j.inc, %outer.inc] 26 %j.cmp = icmp slt i32 %j, 2 27 br i1 %j.cmp, label %reduction.preheader, label %outer.exit 28 29 30 reduction.preheader: 31 %A_idx = getelementptr inbounds double, double* %A, i32 %j 32 %init = load double, double* %A_idx 33 br label %reduction.for 34 35 reduction.for: 36 %i = phi i32 [0, %reduction.preheader], [%i.inc, %reduction.inc] 37 %phi = phi double [%init, %reduction.preheader], [%add, %reduction.inc] 38 br label %body 39 40 41 42 body: 43 %add = fadd double %phi, 4.2 44 br label %reduction.inc 45 46 47 48 reduction.inc: 49 %i.inc = add nuw nsw i32 %i, 1 50 %i.cmp = icmp slt i32 %i.inc, 4 51 br i1 %i.cmp, label %reduction.for, label %reduction.exit 52 53 reduction.exit: 54 store double %add, double* %A_idx 55 store double %add, double* %A_idx 56 br label %outer.inc 57 58 59 60outer.inc: 61 %j.inc = add nuw nsw i32 %j, 1 62 br label %outer.for 63 64outer.exit: 65 br label %return 66 67return: 68 ret void 69} 70 71 72; CHECK: After accesses { 73; CHECK-NEXT: Stmt_reduction_preheader 74; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0] 75; CHECK-NEXT: { Stmt_reduction_preheader[i0] -> MemRef_A[i0] }; 76; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1] 77; CHECK-NEXT: { Stmt_reduction_preheader[i0] -> MemRef_phi__phi[] }; 78; CHECK-NEXT: new: { Stmt_reduction_preheader[i0] -> MemRef_A[i0] }; 79; CHECK-NEXT: Stmt_reduction_for 80; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1] 81; CHECK-NEXT: { Stmt_reduction_for[i0, i1] -> MemRef_phi__phi[] }; 82; CHECK-NEXT: new: { Stmt_reduction_for[i0, i1] -> MemRef_A[i0] }; 83; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1] 84; CHECK-NEXT: { Stmt_reduction_for[i0, i1] -> MemRef_phi[] }; 85; CHECK-NEXT: new: { Stmt_reduction_for[i0, i1] -> MemRef_A[i0] }; 86; CHECK-NEXT: Stmt_body 87; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1] 88; CHECK-NEXT: { Stmt_body[i0, i1] -> MemRef_add[] }; 89; CHECK-NEXT: new: { Stmt_body[i0, i1] -> MemRef_A[i0] }; 90; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1] 91; CHECK-NEXT: { Stmt_body[i0, i1] -> MemRef_phi[] }; 92; CHECK-NEXT: new: { Stmt_body[i0, i1] -> MemRef_A[i0] : 3i1 <= 22 - 14i0; Stmt_body[1, 3] -> MemRef_A[1] }; 93; CHECK-NEXT: Stmt_reduction_inc 94; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1] 95; CHECK-NEXT: { Stmt_reduction_inc[i0, i1] -> MemRef_add[] }; 96; CHECK-NEXT: new: { Stmt_reduction_inc[i0, i1] -> MemRef_A[i0] : 3i1 <= 22 - 14i0; Stmt_reduction_inc[1, 3] -> MemRef_A[1] }; 97; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1] 98; CHECK-NEXT: { Stmt_reduction_inc[i0, i1] -> MemRef_phi__phi[] }; 99; CHECK-NEXT: new: { Stmt_reduction_inc[i0, i1] -> MemRef_A[i0] }; 100; CHECK-NEXT: Stmt_reduction_exit 101; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0] 102; CHECK-NEXT: { Stmt_reduction_exit[i0] -> MemRef_A[i0] }; 103; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1] 104; CHECK-NEXT: { Stmt_reduction_exit[i0] -> MemRef_add[] }; 105; CHECK-NEXT: new: { Stmt_reduction_exit[i0] -> MemRef_A[i0] }; 106; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0] 107; CHECK-NEXT: { Stmt_reduction_exit[i0] -> MemRef_A[i0] }; 108; CHECK-NEXT: } 109