1; RUN: opt -basic-aa %loadPolly -polly-stmt-granularity=bb -polly-scops -analyze < %s | FileCheck %s 2; 3; CHECK: ReadAccess := [Reduction Type: NONE 4; CHECK: { Stmt_for_body[i0] -> MemRef_A[1 + i0] }; 5; CHECK: ReadAccess := [Reduction Type: NONE 6; CHECK: { Stmt_for_body[i0] -> MemRef_A[i0] }; 7; CHECK: MustWriteAccess := [Reduction Type: NONE 8; CHECK: { Stmt_for_body[i0] -> MemRef_first[0] }; 9; CHECK: ReadAccess := [Reduction Type: + 10; CHECK: { Stmt_for_body[i0] -> MemRef_sum[0] }; 11; CHECK: MustWriteAccess := [Reduction Type: + 12; CHECK: { Stmt_for_body[i0] -> MemRef_sum[0] }; 13; CHECK: ReadAccess := [Reduction Type: NONE 14; CHECK: { Stmt_for_body[i0] -> MemRef_A[-1 + i0] }; 15; CHECK: ReadAccess := [Reduction Type: NONE 16; CHECK: { Stmt_for_body[i0] -> MemRef_A[i0] }; 17; CHECK: MustWriteAccess := [Reduction Type: NONE 18; CHECK: { Stmt_for_body[i0] -> MemRef_middle[0] }; 19; CHECK: ReadAccess := [Reduction Type: * 20; CHECK: { Stmt_for_body[i0] -> MemRef_prod[0] }; 21; CHECK: MustWriteAccess := [Reduction Type: * 22; CHECK: { Stmt_for_body[i0] -> MemRef_prod[0] }; 23; CHECK: ReadAccess := [Reduction Type: NONE 24; CHECK: { Stmt_for_body[i0] -> MemRef_A[-1 + i0] }; 25; CHECK: ReadAccess := [Reduction Type: NONE 26; CHECK: { Stmt_for_body[i0] -> MemRef_A[1 + i0] }; 27; CHECK: MustWriteAccess := [Reduction Type: NONE 28; CHECK: { Stmt_for_body[i0] -> MemRef_last[0] }; 29; 30; int first, sum, middle, prod, last; 31; 32; void f(int * restrict A) { 33; int i; 34; for (int i = 0; i < 100; i++) { 35; first = A[i+1] + A[i]; 36; sum += i * 3; 37; middle = A[i-1] + A[i]; 38; prod *= (i + 3); 39; last = A[i-1] + A[i+1]; 40; } 41; } 42target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-n32-S64" 43 44@first = common global i32 0, align 4 45@sum = common global i32 0, align 4 46@middle = common global i32 0, align 4 47@prod = common global i32 0, align 4 48@last = common global i32 0, align 4 49 50define void @f(i32* noalias %A) { 51entry: 52 br label %for.cond 53 54for.cond: ; preds = %for.inc, %entry 55 %i1.0 = phi i32 [ 0, %entry ], [ %inc, %for.inc ] 56 %exitcond = icmp ne i32 %i1.0, 100 57 br i1 %exitcond, label %for.body, label %for.end 58 59for.body: ; preds = %for.cond 60 %add = add nsw i32 %i1.0, 1 61 %arrayidx = getelementptr inbounds i32, i32* %A, i32 %add 62 %tmp = load i32, i32* %arrayidx, align 4 63 %arrayidx2 = getelementptr inbounds i32, i32* %A, i32 %i1.0 64 %tmp1 = load i32, i32* %arrayidx2, align 4 65 %add3 = add nsw i32 %tmp, %tmp1 66 store i32 %add3, i32* @first, align 4 67 %mul = mul nsw i32 %i1.0, 3 68 %tmp2 = load i32, i32* @sum, align 4 69 %add4 = add nsw i32 %tmp2, %mul 70 store i32 %add4, i32* @sum, align 4 71 %sub = add nsw i32 %i1.0, -1 72 %arrayidx5 = getelementptr inbounds i32, i32* %A, i32 %sub 73 %tmp3 = load i32, i32* %arrayidx5, align 4 74 %arrayidx6 = getelementptr inbounds i32, i32* %A, i32 %i1.0 75 %tmp4 = load i32, i32* %arrayidx6, align 4 76 %add7 = add nsw i32 %tmp3, %tmp4 77 store i32 %add7, i32* @middle, align 4 78 %add8 = add nsw i32 %i1.0, 3 79 %tmp5 = load i32, i32* @prod, align 4 80 %mul9 = mul nsw i32 %tmp5, %add8 81 store i32 %mul9, i32* @prod, align 4 82 %sub10 = add nsw i32 %i1.0, -1 83 %arrayidx11 = getelementptr inbounds i32, i32* %A, i32 %sub10 84 %tmp6 = load i32, i32* %arrayidx11, align 4 85 %add12 = add nsw i32 %i1.0, 1 86 %arrayidx13 = getelementptr inbounds i32, i32* %A, i32 %add12 87 %tmp7 = load i32, i32* %arrayidx13, align 4 88 %add14 = add nsw i32 %tmp6, %tmp7 89 store i32 %add14, i32* @last, align 4 90 br label %for.inc 91 92for.inc: ; preds = %for.body 93 %inc = add nsw i32 %i1.0, 1 94 br label %for.cond 95 96for.end: ; preds = %for.cond 97 ret void 98} 99