1 ; RUN: opt %loadPolly -polly-detect -polly-scops \
2 ; RUN: -polly-invariant-load-hoisting=true \
3 ; RUN: -analyze < %s | FileCheck %s
5 ; CHECK-NOT: Function: foo_undereferanceable
7 ; CHECK: Function: foo_dereferanceable
9 ; CHECK: Invariant Accesses: {
10 ; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
11 ; CHECK-NEXT: [sizeA] -> { Stmt_for_body_j__TO__for_latch_j[i0, i1] -> MemRef_sizeA_ptr[0] };
12 ; CHECK-NEXT: Execution Context: [sizeA] -> { : }
15 ; CHECK: MayWriteAccess := [Reduction Type: NONE] [Scalar: 0]
16 ; CHECK-NEXT: [sizeA] -> { Stmt_for_body_j__TO__for_latch_j[i0, i1] -> MemRef_A[i1, i0] };
18 ; CHECK-NOT: Function: foo_undereferanceable
20 define void @foo_dereferanceable(double* %A, double* %B, i64* dereferenceable(8) %sizeA_ptr,
21 i32 %lb.i, i32 %lb.j, i32 %ub.i, i32 %ub.j) {
26 %indvar.i = phi i32 [0, %entry], [%indvar.next.i, %for.latch.i]
27 %indvar.next.i = add i32 %indvar.i, 1
28 %cmp.i = icmp sle i32 %indvar.i, 1024
29 br i1 %cmp.i, label %for.body.i, label %exit
35 %indvar.j = phi i32 [0, %for.body.i], [%indvar.next.j, %for.latch.j]
36 %indvar.next.j = add i32 %indvar.j, 1
37 %cmp.j = icmp sle i32 %indvar.j, 1024
38 br i1 %cmp.j, label %for.body.j, label %for.latch.i
41 %prod = mul i32 %indvar.j, %indvar.j
42 %cmp = icmp sle i32 %prod, 1024
43 br i1 %cmp, label %stmt, label %for.latch.j
46 %sext.i = sext i32 %indvar.i to i64
47 %sext.j = sext i32 %indvar.j to i64
49 %sizeA = load i64, i64* %sizeA_ptr
50 %prodA = mul i64 %sext.j, %sizeA
51 %offsetA = add i64 %sext.i, %prodA
52 %ptrA = getelementptr double, double* %A, i64 %offsetA
53 store double 42.0, double* %ptrA
67 define void @foo_undereferanceable(double* %A, double* %B, i64* %sizeA_ptr) {
72 %indvar.i = phi i32 [0, %entry], [%indvar.next.i, %for.latch.i]
73 %indvar.next.i = add i32 %indvar.i, 1
74 %cmp.i = icmp sle i32 %indvar.i, 1024
75 br i1 %cmp.i, label %for.body.i, label %exit
81 %indvar.j = phi i32 [0, %for.body.i], [%indvar.next.j, %for.latch.j]
82 %indvar.next.j = add i32 %indvar.j, 1
83 %cmp.j = icmp sle i32 %indvar.j, 1024
84 br i1 %cmp.j, label %for.body.j, label %for.latch.i
87 %prod = mul i32 %indvar.j, %indvar.j
88 %cmp = icmp sle i32 %prod, 1024
89 br i1 %cmp, label %stmt, label %for.latch.j
92 %sext.i = sext i32 %indvar.i to i64
93 %sext.j = sext i32 %indvar.j to i64
95 %sizeA = load i64, i64* %sizeA_ptr
96 %prodA = mul i64 %sext.j, %sizeA
97 %offsetA = add i64 %sext.i, %prodA
98 %ptrA = getelementptr double, double* %A, i64 %offsetA
99 store double 42.0, double* %ptrA
101 br label %for.latch.j