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