1; RUN: opt %loadPolly -basic-aa -polly-scops -analyze \ 2; RUN: -polly-invariant-load-hoisting=true < %s | FileCheck %s 3 4; void f(long A[], int N, int *init_ptr) { 5; long i, j; 6; 7; for (i = 0; i < N; ++i) { 8; init = *init_ptr; 9; for (i = 0; i < N; ++i) { 10; A[i] = init + 2; 11; } 12; } 13; } 14 15; CHECK-LABEL: Function: f 16; 17; CHECK: Statements { 18; CHECK-NEXT: Stmt_for_j 19; CHECK-NEXT: Domain := 20; CHECK-NEXT: [N] -> { Stmt_for_j[i0, i1] : 0 <= i0 < N and 0 <= i1 < N }; 21; CHECK-NEXT: Schedule := 22; CHECK-NEXT: [N] -> { Stmt_for_j[i0, i1] -> [i0, i1] }; 23; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1] 24; CHECK-NEXT: [N] -> { Stmt_for_j[i0, i1] -> MemRef_init[] }; 25; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0] 26; CHECK-NEXT: [N] -> { Stmt_for_j[i0, i1] -> MemRef_A[i1] }; 27; CHECK-NEXT: } 28; 29; CHECK-LABEL: Function: g 30; 31; CHECK: Statements { 32; CHECK-NEXT: Stmt_for_j 33; CHECK-NEXT: Domain := 34; CHECK-NEXT: [N] -> { Stmt_for_j[i0, i1] : 0 <= i0 < N and 0 <= i1 < N }; 35; CHECK-NEXT: Schedule := 36; CHECK-NEXT: [N] -> { Stmt_for_j[i0, i1] -> [i0, i1] }; 37; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0] 38; CHECK-NEXT: [N] -> { Stmt_for_j[i0, i1] -> MemRef_A[i1] }; 39; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1] 40; CHECK-NEXT: [N] -> { Stmt_for_j[i0, i1] -> MemRef_init[] }; 41; CHECK-NEXT: } 42 43target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" 44 45 46define void @f(i64* noalias %A, i64 %N, i64* noalias %init_ptr) nounwind { 47entry: 48 br label %for.i 49 50for.i: 51 %indvar.i = phi i64 [ 0, %entry ], [ %indvar.i.next, %for.i.end ] 52 %indvar.i.next = add nsw i64 %indvar.i, 1 53 br label %entry.next 54 55entry.next: 56 %init = load i64, i64* %init_ptr 57 br label %for.j 58 59for.j: 60 %indvar.j = phi i64 [ 0, %entry.next ], [ %indvar.j.next, %for.j ] 61 %init_plus_two = add i64 %init, 2 62 %scevgep = getelementptr i64, i64* %A, i64 %indvar.j 63 store i64 %init_plus_two, i64* %scevgep 64 %indvar.j.next = add nsw i64 %indvar.j, 1 65 %exitcond.j = icmp eq i64 %indvar.j.next, %N 66 br i1 %exitcond.j, label %for.i.end, label %for.j 67 68for.i.end: 69 %exitcond.i = icmp eq i64 %indvar.i.next, %N 70 br i1 %exitcond.i, label %return, label %for.i 71 72return: 73 ret void 74} 75 76define void @g(i64* noalias %A, i64 %N, i64* noalias %init_ptr) nounwind { 77entry: 78 br label %for.i 79 80for.i: 81 %indvar.i = phi i64 [ 0, %entry ], [ %indvar.i.next, %for.i.end ] 82 %indvar.i.next = add nsw i64 %indvar.i, 1 83 br label %entry.next 84 85entry.next: 86 %init = load i64, i64* %init_ptr 87 br label %for.j 88 89for.j: 90 %indvar.j = phi i64 [ 0, %entry.next ], [ %indvar.j.next, %for.j ] 91 %scevgep = getelementptr i64, i64* %A, i64 %indvar.j 92 store i64 %init, i64* %scevgep 93 %indvar.j.next = add nsw i64 %indvar.j, 1 94 %exitcond.j = icmp eq i64 %indvar.j.next, %N 95 br i1 %exitcond.j, label %for.i.end, label %for.j 96 97for.i.end: 98 %exitcond.i = icmp eq i64 %indvar.i.next, %N 99 br i1 %exitcond.i, label %return, label %for.i 100 101return: 102 ret void 103} 104