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;     for (i = 0; i < N; ++i) {
9;       init = *init_ptr;
10;       A[i] = init + 2;
11;     }
12;   }
13; }
14
15target 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"
16
17; Function Attrs: nounwind
18; CHECK:      Invariant Accesses:
19; CHECK-NEXT:     ReadAccess :=  [Reduction Type: NONE] [Scalar: 0]
20; CHECK-NEXT:          [N] -> { Stmt_for_j[i0, i1] -> MemRef_init_ptr[0] };
21define void @f(i64* noalias %A, i64 %N, i64* noalias %init_ptr) #0 {
22entry:
23  br label %for.i
24
25for.i:                                            ; preds = %for.i.end, %entry
26  %indvar.i = phi i64 [ 0, %entry ], [ %indvar.i.next, %for.i.end ]
27  %indvar.i.next = add nsw i64 %indvar.i, 1
28  br label %entry.next
29
30entry.next:                                       ; preds = %for.i
31  br label %for.j
32
33for.j:                                            ; preds = %for.j, %entry.next
34  %indvar.j = phi i64 [ 0, %entry.next ], [ %indvar.j.next, %for.j ]
35  %init = load i64, i64* %init_ptr
36  %init_plus_two = add i64 %init, 2
37  %scevgep = getelementptr i64, i64* %A, i64 %indvar.j
38  store i64 %init_plus_two, i64* %scevgep
39; CHECK:      Statements {
40; CHECK-NEXT:   Stmt_for_j
41; CHECK-NOT:     ReadAccess
42; CHECK:         MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]
43; CHECK-NEXT:            [N] -> { Stmt_for_j[i0, i1] -> MemRef_A[i1] };
44; CHECK-NEXT:  }
45  %indvar.j.next = add nsw i64 %indvar.j, 1
46  %exitcond.j = icmp eq i64 %indvar.j.next, %N
47  br i1 %exitcond.j, label %for.i.end, label %for.j
48
49for.i.end:                                        ; preds = %for.j
50  %exitcond.i = icmp eq i64 %indvar.i.next, %N
51  br i1 %exitcond.i, label %return, label %for.i
52
53return:                                           ; preds = %for.i.end
54  ret void
55}
56
57attributes #0 = { nounwind }
58