1; RUN: opt %loadPolly -polly-stmt-granularity=bb -polly-delicm -analyze < %s | FileCheck %s 2; 3; Register-promoted reduction but without preheader. 4; 5; void func(double *A) { 6; for (int j = 0; j < 2; j += 1) { /* outer */ 7; double phi = A[j]; 8; for (int i = 0; i < 4; i += 1) /* reduction */ 9; phi += 4.2; 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 %A_idx = getelementptr inbounds double, double* %A, i32 %j 25 %init = load double, double* %A_idx 26 br i1 %j.cmp, label %reduction.for, label %outer.exit 27 28 29 30 reduction.for: 31 %i = phi i32 [0, %outer.for], [%i.inc, %reduction.inc] 32 %phi = phi double [%init, %outer.for], [%add, %reduction.inc] 33 br label %body 34 35 36 37 body: 38 %add = fadd double %phi, 4.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 store double %add, double* %A_idx 50 br label %outer.inc 51 52 53 54outer.inc: 55 %j.inc = add nuw nsw i32 %j, 1 56 br label %outer.for 57 58outer.exit: 59 br label %return 60 61return: 62 ret void 63} 64 65 66; CHECK: Statistics { 67; CHECK: Compatible overwrites: 1 68; CHECK: Overwrites mapped to: 1 69; CHECK: Value scalars mapped: 2 70; CHECK: PHI scalars mapped: 1 71; CHECK: } 72 73; CHECK: After accesses { 74; CHECK-NEXT: Stmt_outer_for 75; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0] 76; CHECK-NEXT: { Stmt_outer_for[i0] -> MemRef_A[i0] }; 77; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1] 78; CHECK-NEXT: { Stmt_outer_for[i0] -> MemRef_phi__phi[] }; 79; CHECK-NEXT: new: { Stmt_outer_for[i0] -> MemRef_A[i0] : i0 <= 1 }; 80; CHECK-NEXT: Stmt_reduction_for 81; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1] 82; CHECK-NEXT: { Stmt_reduction_for[i0, i1] -> MemRef_phi__phi[] }; 83; CHECK-NEXT: new: { Stmt_reduction_for[i0, i1] -> MemRef_A[i0] }; 84; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1] 85; CHECK-NEXT: { Stmt_reduction_for[i0, i1] -> MemRef_phi[] }; 86; CHECK-NEXT: new: { Stmt_reduction_for[i0, i1] -> MemRef_A[i0] }; 87; CHECK-NEXT: Stmt_body 88; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1] 89; CHECK-NEXT: { Stmt_body[i0, i1] -> MemRef_add[] }; 90; CHECK-NEXT: new: { Stmt_body[i0, i1] -> MemRef_A[i0] }; 91; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1] 92; CHECK-NEXT: { Stmt_body[i0, i1] -> MemRef_phi[] }; 93; CHECK-NEXT: new: { Stmt_body[i0, i1] -> MemRef_A[i0] }; 94; CHECK-NEXT: Stmt_reduction_inc 95; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1] 96; CHECK-NEXT: { Stmt_reduction_inc[i0, i1] -> MemRef_add[] }; 97; CHECK-NEXT: new: { Stmt_reduction_inc[i0, i1] -> MemRef_A[i0] }; 98; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1] 99; CHECK-NEXT: { Stmt_reduction_inc[i0, i1] -> MemRef_phi__phi[] }; 100; CHECK-NEXT: new: { Stmt_reduction_inc[i0, i1] -> MemRef_A[i0] : i1 <= 2 }; 101; CHECK-NEXT: Stmt_reduction_exit 102; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0] 103; CHECK-NEXT: { Stmt_reduction_exit[i0] -> MemRef_A[i0] }; 104; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1] 105; CHECK-NEXT: { Stmt_reduction_exit[i0] -> MemRef_add[] }; 106; CHECK-NEXT: new: { Stmt_reduction_exit[i0] -> MemRef_A[i0] }; 107; CHECK-NEXT: } 108