1; RUN: opt %loadPolly -polly-detect -polly-scops \ 2; RUN: -polly-invariant-load-hoisting=true \ 3; RUN: -analyze < %s | FileCheck %s 4 5; CHECK-NOT: Function: foo_undereferanceable 6 7; CHECK: Function: foo_dereferanceable 8 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] -> { : } 13; CHECK-NEXT: } 14 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] }; 17 18; CHECK-NOT: Function: foo_undereferanceable 19 20define void @foo_dereferanceable(double* %A, double* %B, i64* dereferenceable(8) align 8 %sizeA_ptr, 21 i32 %lb.i, i32 %lb.j, i32 %ub.i, i32 %ub.j) { 22entry: 23 br label %for.i 24 25for.i: 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 30 31for.body.i: 32 br label %for.j 33 34for.j: 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 39 40for.body.j: 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 44 45stmt: 46 %sext.i = sext i32 %indvar.i to i64 47 %sext.j = sext i32 %indvar.j to i64 48 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 54 55 br label %for.latch.j 56 57for.latch.j: 58 br label %for.j 59 60for.latch.i: 61 br label %for.i 62 63exit: 64 ret void 65} 66 67define void @foo_undereferanceable(double* %A, double* %B, i64* %sizeA_ptr) { 68entry: 69 br label %for.i 70 71for.i: 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 76 77for.body.i: 78 br label %for.j 79 80for.j: 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 85 86for.body.j: 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 90 91stmt: 92 %sext.i = sext i32 %indvar.i to i64 93 %sext.j = sext i32 %indvar.j to i64 94 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 100 101 br label %for.latch.j 102 103for.latch.j: 104 br label %for.j 105 106for.latch.i: 107 br label %for.i 108 109exit: 110 ret void 111} 112 113