1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
| ; RUN: opt %loadPolly -polly-detect -polly-scops \
; RUN: -polly-invariant-load-hoisting=true \
; RUN: -analyze < %s | FileCheck %s
; CHECK-NOT: Function: foo_undereferanceable
; CHECK: Function: foo_dereferanceable
; CHECK: Invariant Accesses: {
; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
; CHECK-NEXT: [sizeA] -> { Stmt_for_body_j__TO__for_latch_j[i0, i1] -> MemRef_sizeA_ptr[0] };
; CHECK-NEXT: Execution Context: [sizeA] -> { : }
; CHECK-NEXT: }
; CHECK: MayWriteAccess := [Reduction Type: NONE] [Scalar: 0]
; CHECK-NEXT: [sizeA] -> { Stmt_for_body_j__TO__for_latch_j[i0, i1] -> MemRef_A[i1, i0] };
; CHECK-NOT: Function: foo_undereferanceable
define void @foo_dereferanceable(double* %A, double* %B, i64* dereferenceable(8) %sizeA_ptr,
i32 %lb.i, i32 %lb.j, i32 %ub.i, i32 %ub.j) {
entry:
br label %for.i
for.i:
%indvar.i = phi i32 [0, %entry], [%indvar.next.i, %for.latch.i]
%indvar.next.i = add i32 %indvar.i, 1
%cmp.i = icmp sle i32 %indvar.i, 1024
br i1 %cmp.i, label %for.body.i, label %exit
for.body.i:
br label %for.j
for.j:
%indvar.j = phi i32 [0, %for.body.i], [%indvar.next.j, %for.latch.j]
%indvar.next.j = add i32 %indvar.j, 1
%cmp.j = icmp sle i32 %indvar.j, 1024
br i1 %cmp.j, label %for.body.j, label %for.latch.i
for.body.j:
%prod = mul i32 %indvar.j, %indvar.j
%cmp = icmp sle i32 %prod, 1024
br i1 %cmp, label %stmt, label %for.latch.j
stmt:
%sext.i = sext i32 %indvar.i to i64
%sext.j = sext i32 %indvar.j to i64
%sizeA = load i64, i64* %sizeA_ptr
%prodA = mul i64 %sext.j, %sizeA
%offsetA = add i64 %sext.i, %prodA
%ptrA = getelementptr double, double* %A, i64 %offsetA
store double 42.0, double* %ptrA
br label %for.latch.j
for.latch.j:
br label %for.j
for.latch.i:
br label %for.i
exit:
ret void
}
define void @foo_undereferanceable(double* %A, double* %B, i64* %sizeA_ptr) {
entry:
br label %for.i
for.i:
%indvar.i = phi i32 [0, %entry], [%indvar.next.i, %for.latch.i]
%indvar.next.i = add i32 %indvar.i, 1
%cmp.i = icmp sle i32 %indvar.i, 1024
br i1 %cmp.i, label %for.body.i, label %exit
for.body.i:
br label %for.j
for.j:
%indvar.j = phi i32 [0, %for.body.i], [%indvar.next.j, %for.latch.j]
%indvar.next.j = add i32 %indvar.j, 1
%cmp.j = icmp sle i32 %indvar.j, 1024
br i1 %cmp.j, label %for.body.j, label %for.latch.i
for.body.j:
%prod = mul i32 %indvar.j, %indvar.j
%cmp = icmp sle i32 %prod, 1024
br i1 %cmp, label %stmt, label %for.latch.j
stmt:
%sext.i = sext i32 %indvar.i to i64
%sext.j = sext i32 %indvar.j to i64
%sizeA = load i64, i64* %sizeA_ptr
%prodA = mul i64 %sext.j, %sizeA
%offsetA = add i64 %sext.i, %prodA
%ptrA = getelementptr double, double* %A, i64 %offsetA
store double 42.0, double* %ptrA
br label %for.latch.j
for.latch.j:
br label %for.j
for.latch.i:
br label %for.i
exit:
ret void
}
|