1; RUN: opt %loadPolly -polly-stmt-granularity=bb -polly-flatten-schedule -polly-delicm-compute-known=true -polly-delicm-overapproximate-writes=true -polly-delicm-partial-writes=false -polly-delicm -analyze < %s | FileCheck %s --check-prefix=APPROX 2; RUN: opt %loadPolly -polly-stmt-granularity=bb -polly-flatten-schedule -polly-delicm-compute-known=true -polly-delicm-overapproximate-writes=false -polly-delicm-partial-writes=false -polly-delicm -analyze < %s | FileCheck %s --check-prefix=EXACT 3; RUN: opt %loadPolly -polly-stmt-granularity=bb -polly-flatten-schedule -polly-delicm-compute-known=true -polly-delicm-partial-writes=true -polly-delicm -analyze < %s | FileCheck %s --check-prefix=PARTIAL 4; 5; void func(double *A { 6; for (int j = -1; j < 3; j += 1) { /* outer */ 7; double phi = 0.0; 8; if (0 < j) 9; for (int i = 0; i < j; i += 1) /* reduction */ 10; phi += 4.2; 11; A[j] = phi; 12; } 13; } 14; 15define void @func(double* noalias nonnull %A) { 16entry: 17 br label %outer.preheader 18 19outer.preheader: 20 br label %outer.for 21 22outer.for: 23 %j = phi i32 [-1, %outer.preheader], [%j.inc, %outer.inc] 24 %j.cmp = icmp slt i32 %j, 3 25 br i1 %j.cmp, label %reduction.checkloop, label %outer.exit 26 27 28 29 reduction.checkloop: 30 %j2.cmp = icmp slt i32 0, %j 31 br i1 %j2.cmp, label %reduction.preheader, label %reduction.exit 32 33 reduction.preheader: 34 br label %reduction.for 35 36 reduction.for: 37 %i = phi i32 [0, %reduction.preheader], [%i.inc, %reduction.inc] 38 %phi = phi double [0.0, %reduction.preheader], [%add, %reduction.inc] 39 br label %body 40 41 42 43 body: 44 %add = fadd double %phi, 4.2 45 br label %reduction.inc 46 47 48 49 reduction.inc: 50 %i.inc = add nuw nsw i32 %i, 1 51 %i.cmp = icmp slt i32 %i.inc, %j 52 br i1 %i.cmp, label %reduction.for, label %reduction.exit 53 54 reduction.exit: 55 %val = phi double [%add, %reduction.inc], [0.0, %reduction.checkloop] 56 %A_idx = getelementptr inbounds double, double* %A, i32 %j 57 store double %val, double* %A_idx 58 br label %outer.inc 59 60 61 62outer.inc: 63 %j.inc = add nuw nsw i32 %j, 1 64 br label %outer.for 65 66outer.exit: 67 br label %return 68 69return: 70 ret void 71} 72 73 74; APPROX: After accesses { 75; APPROX-NEXT: Stmt_reduction_checkloop 76; APPROX-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1] 77; APPROX-NEXT: { Stmt_reduction_checkloop[i0] -> MemRef_val__phi[] }; 78; APPROX-NEXT: new: { Stmt_reduction_checkloop[i0] -> MemRef_A[-1 + i0] }; 79; APPROX-NEXT: Stmt_reduction_preheader 80; APPROX-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1] 81; APPROX-NEXT: { Stmt_reduction_preheader[i0] -> MemRef_phi__phi[] }; 82; APPROX-NEXT: new: { Stmt_reduction_preheader[i0] -> MemRef_A[-1 + i0] }; 83; APPROX-NEXT: Stmt_reduction_for 84; APPROX-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1] 85; APPROX-NEXT: { Stmt_reduction_for[i0, i1] -> MemRef_phi__phi[] }; 86; APPROX-NEXT: new: { Stmt_reduction_for[i0, i1] -> MemRef_A[-1 + i0] }; 87; APPROX-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1] 88; APPROX-NEXT: { Stmt_reduction_for[i0, i1] -> MemRef_phi[] }; 89; APPROX-NEXT: new: { Stmt_reduction_for[i0, i1] -> MemRef_A[-1 + i0] }; 90; APPROX-NEXT: Stmt_body 91; APPROX-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1] 92; APPROX-NEXT: { Stmt_body[i0, i1] -> MemRef_add[] }; 93; APPROX-NEXT: new: { Stmt_body[i0, i1] -> MemRef_A[-1 + i0] }; 94; APPROX-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1] 95; APPROX-NEXT: { Stmt_body[i0, i1] -> MemRef_phi[] }; 96; APPROX-NEXT: new: { Stmt_body[i0, i1] -> MemRef_A[-1 + i0] }; 97; APPROX-NEXT: Stmt_reduction_inc 98; APPROX-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1] 99; APPROX-NEXT: { Stmt_reduction_inc[i0, i1] -> MemRef_add[] }; 100; APPROX-NEXT: new: { Stmt_reduction_inc[i0, i1] -> MemRef_A[-1 + i0] }; 101; APPROX-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1] 102; APPROX-NEXT: { Stmt_reduction_inc[i0, i1] -> MemRef_phi__phi[] }; 103; APPROX-NEXT: new: { Stmt_reduction_inc[i0, i1] -> MemRef_A[2] }; 104; APPROX-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1] 105; APPROX-NEXT: { Stmt_reduction_inc[i0, i1] -> MemRef_val__phi[] }; 106; APPROX-NEXT: new: { Stmt_reduction_inc[i0, i1] -> MemRef_A[-1 + i0] }; 107; APPROX-NEXT: Stmt_reduction_exit 108; APPROX-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1] 109; APPROX-NEXT: { Stmt_reduction_exit[i0] -> MemRef_val__phi[] }; 110; APPROX-NEXT: new: { Stmt_reduction_exit[i0] -> MemRef_A[-1 + i0] }; 111; APPROX-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0] 112; APPROX-NEXT: { Stmt_reduction_exit[i0] -> MemRef_A[-1 + i0] }; 113; APPROX-NEXT: } 114 115 116; EXACT: No modification has been made 117 118 119; PARTIAL: After accesses { 120; PARTIAL-NEXT: Stmt_reduction_checkloop 121; PARTIAL-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1] 122; PARTIAL-NEXT: { Stmt_reduction_checkloop[i0] -> MemRef_val__phi[] }; 123; PARTIAL-NEXT: new: { Stmt_reduction_checkloop[i0] -> MemRef_A[-1 + i0] : i0 <= 1 }; 124; PARTIAL-NEXT: Stmt_reduction_preheader 125; PARTIAL-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1] 126; PARTIAL-NEXT: { Stmt_reduction_preheader[i0] -> MemRef_phi__phi[] }; 127; PARTIAL-NEXT: new: { Stmt_reduction_preheader[i0] -> MemRef_A[-1 + i0] }; 128; PARTIAL-NEXT: Stmt_reduction_for 129; PARTIAL-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1] 130; PARTIAL-NEXT: { Stmt_reduction_for[i0, i1] -> MemRef_phi__phi[] }; 131; PARTIAL-NEXT: new: { Stmt_reduction_for[i0, i1] -> MemRef_A[-1 + i0] }; 132; PARTIAL-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1] 133; PARTIAL-NEXT: { Stmt_reduction_for[i0, i1] -> MemRef_phi[] }; 134; PARTIAL-NEXT: new: { Stmt_reduction_for[i0, i1] -> MemRef_A[-1 + i0] }; 135; PARTIAL-NEXT: Stmt_body 136; PARTIAL-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1] 137; PARTIAL-NEXT: { Stmt_body[i0, i1] -> MemRef_add[] }; 138; PARTIAL-NEXT: new: { Stmt_body[i0, i1] -> MemRef_A[-1 + i0] }; 139; PARTIAL-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1] 140; PARTIAL-NEXT: { Stmt_body[i0, i1] -> MemRef_phi[] }; 141; PARTIAL-NEXT: new: { Stmt_body[i0, i1] -> MemRef_A[-1 + i0] }; 142; PARTIAL-NEXT: Stmt_reduction_inc 143; PARTIAL-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1] 144; PARTIAL-NEXT: { Stmt_reduction_inc[i0, i1] -> MemRef_add[] }; 145; PARTIAL-NEXT: new: { Stmt_reduction_inc[i0, i1] -> MemRef_A[-1 + i0] }; 146; PARTIAL-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1] 147; PARTIAL-NEXT: { Stmt_reduction_inc[i0, i1] -> MemRef_phi__phi[] }; 148; PARTIAL-NEXT: new: { Stmt_reduction_inc[3, 0] -> MemRef_A[2] }; 149; PARTIAL-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1] 150; PARTIAL-NEXT: { Stmt_reduction_inc[i0, i1] -> MemRef_val__phi[] }; 151; PARTIAL-NEXT: new: { Stmt_reduction_inc[i0, -2 + i0] -> MemRef_A[-1 + i0] }; 152; PARTIAL-NEXT: Stmt_reduction_exit 153; PARTIAL-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1] 154; PARTIAL-NEXT: { Stmt_reduction_exit[i0] -> MemRef_val__phi[] }; 155; PARTIAL-NEXT: new: { Stmt_reduction_exit[i0] -> MemRef_A[-1 + i0] }; 156; PARTIAL-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0] 157; PARTIAL-NEXT: { Stmt_reduction_exit[i0] -> MemRef_A[-1 + i0] }; 158; PARTIAL-NEXT: } 159