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-delicm -analyze < %s | FileCheck %s 2; 3; void func(int *A, int* StartPtr) { 4; for (int j = 0; j < 2; j += 1) { /* outer */ 5; int Start = *Startptr; 6; int phi = Start; 7; for (int i = Start; i < 4; i += 1) /* reduction */ 8; phi += 42; 9; A[j] = phi; 10; } 11; } 12; 13define void @func(i32* noalias nonnull %A, i32* noalias nonnull %StartPtr) { 14entry: 15 br label %outer.preheader 16 17outer.preheader: 18 br label %outer.for 19 20outer.for: 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 24 25 26 reduction.preheader: 27 %Start = load i32, i32* %StartPtr 28 br label %reduction.for 29 30 reduction.for: 31 %i = phi i32 [%Start, %reduction.preheader], [%i.inc, %reduction.inc] 32 %phi = phi i32 [%Start, %reduction.preheader], [%mul, %reduction.inc] 33 br label %body 34 35 36 37 body: 38 %mul = mul i32 %phi, 2 39 br label %reduction.inc 40 41 42 43 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 47 48 reduction.exit: 49 %A_idx = getelementptr inbounds i32, i32* %A, i32 %j 50 store i32 %mul, i32* %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; FIXME: The accesses for %i should not be there because, with 67; load-hoisting %Start is an affine loop. To be fixed in ScopBuilder. 68 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] : Start >= 2147483648 or Start <= 2147483646 }; 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] }; 101; CHECK-NEXT: } 102