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