alias-set-with-uncomputable-bounds.ll
4.91 KB
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
; RUN: opt -loop-vectorize -force-vector-width=2 -S %s | FileCheck %s
; Tests with alias sets that contain points with uncomputable bounds because
; they include %offset.1, which is loaded in each loop iteration.
; Alias set with uncomputable bounds contains a single load. We do not need
; runtime checks for that group and it should not block vectorization.
define void @test1_uncomputable_bounds_single_load(i32* noalias %ptr.1, i32* noalias %ptr.2, i32* noalias %ptr.3, i64 %N, i64 %X) {
; CHECK-LABEL: define void @test1_uncomputable_bounds_single_load
; CHECK: vector.body
; CHECK: ret void
entry:
%cond = icmp sgt i64 %N, 0
br i1 %cond, label %ph, label %exit
ph:
br label %loop
loop:
%iv = phi i64 [ 0, %ph ], [ %iv.next, %loop ]
%gep.1 = getelementptr inbounds i32, i32* %ptr.3, i64 %iv
%offset.1 = load i32, i32* %gep.1, align 4
%gep.2 = getelementptr inbounds i32, i32* %ptr.2, i32 %offset.1
%lv = load i32, i32* %gep.2, align 4
%gep.3 = getelementptr inbounds i32, i32* %ptr.1, i64 %iv
store i32 %lv , i32* %gep.3, align 4
%offset.2 = add nsw i64 %iv, %X
%gep.4 = getelementptr inbounds i32, i32* %ptr.1, i64 %offset.2
store i32 %lv, i32* %gep.4, align 4
%iv.next = add nuw nsw i64 %iv, 1
%exitcond = icmp eq i64 %iv.next, %N
br i1 %exitcond, label %loop.exit, label %loop
loop.exit:
br label %exit
exit:
ret void
}
; Alias set with uncomputable bounds contains a single store. We do not need
; runtime checks for that group and it should not block vectorization.
define void @test2_uncomputable_bounds_single_store(i32* noalias %ptr.1, i32* noalias %ptr.2, i32* noalias %ptr.3, i64 %N, i64 %X) {
; CHECK-LABEL: define void @test2_uncomputable_bounds_single_store
; CHECK: vector.body
; CHECK: ret void
entry:
%cond = icmp sgt i64 %N, 0
br i1 %cond, label %ph, label %exit
ph:
br label %loop
loop:
%iv = phi i64 [ 0, %ph ], [ %iv.next, %loop ]
%gep.1 = getelementptr inbounds i32, i32* %ptr.3, i64 %iv
%offset.1 = load i32, i32* %gep.1, align 4
%gep.2 = getelementptr inbounds i32, i32* %ptr.2, i32 %offset.1
store i32 20, i32* %gep.2, align 4
%gep.3 = getelementptr inbounds i32, i32* %ptr.1, i64 %iv
store i32 0 , i32* %gep.3, align 4
%offset.2 = add nsw i64 %iv, %X
%gep.4 = getelementptr inbounds i32, i32* %ptr.1, i64 %offset.2
store i32 10, i32* %gep.4, align 4
%iv.next = add nuw nsw i64 %iv, 1
%exitcond = icmp eq i64 %iv.next, %N
br i1 %exitcond, label %loop.exit, label %loop
loop.exit:
br label %exit
exit:
ret void
}
; Alias set with uncomputable bounds contains a load and a store. This blocks
; vectorization, as we cannot generate runtime-checks for the set.
define void @test3_uncomputable_bounds_load_store(i32* noalias %ptr.1, i32* noalias %ptr.2, i32* noalias %ptr.3, i64 %N, i64 %X) {
; CHECK-LABEL: define void @test3_uncomputable_bounds_load_store
; CHECK-NOT: vector.body
entry:
%cond = icmp sgt i64 %N, 0
br i1 %cond, label %ph, label %exit
ph:
br label %loop
loop:
%iv = phi i64 [ 0, %ph ], [ %iv.next, %loop ]
%gep.1 = getelementptr inbounds i32, i32* %ptr.3, i64 %iv
%offset.1 = load i32, i32* %gep.1, align 4
%gep.2 = getelementptr inbounds i32, i32* %ptr.2, i32 %offset.1
store i32 20, i32* %gep.2, align 4
%gep.22 = getelementptr inbounds i32, i32* %ptr.2, i64 %iv
%lv = load i32, i32* %gep.22, align 4
%gep.3 = getelementptr inbounds i32, i32* %ptr.1, i64 %iv
store i32 %lv , i32* %gep.3, align 4
%offset.2 = add nsw i64 %iv, %X
%gep.4 = getelementptr inbounds i32, i32* %ptr.1, i64 %offset.2
store i32 %lv, i32* %gep.4, align 4
%iv.next = add nuw nsw i64 %iv, 1
%exitcond = icmp eq i64 %iv.next, %N
br i1 %exitcond, label %loop.exit, label %loop
loop.exit:
br label %exit
exit:
ret void
}
; Alias set with uncomputable bounds contains a load and a store. This blocks
; vectorization, as we cannot generate runtime-checks for the set.
define void @test4_uncomputable_bounds_store_store(i32* noalias %ptr.1, i32* noalias %ptr.2, i32* noalias %ptr.3, i64 %N, i64 %X) {
; CHECK-LABEL: define void @test4_uncomputable_bounds_store_store
; CHECK-NOT: vector.body
entry:
%cond = icmp sgt i64 %N, 0
br i1 %cond, label %ph, label %exit
ph:
br label %loop
loop:
%iv = phi i64 [ 0, %ph ], [ %iv.next, %loop ]
%gep.1 = getelementptr inbounds i32, i32* %ptr.3, i64 %iv
%offset.1 = load i32, i32* %gep.1, align 4
%gep.2 = getelementptr inbounds i32, i32* %ptr.2, i32 %offset.1
store i32 20, i32* %gep.2, align 4
%gep.22 = getelementptr inbounds i32, i32* %ptr.2, i64 %iv
store i32 30, i32* %gep.22, align 4
%gep.3 = getelementptr inbounds i32, i32* %ptr.1, i64 %iv
store i32 0 , i32* %gep.3, align 4
%offset.2 = add nsw i64 %iv, %X
%gep.4 = getelementptr inbounds i32, i32* %ptr.1, i64 %offset.2
store i32 10, i32* %gep.4, align 4
%iv.next = add nuw nsw i64 %iv, 1
%exitcond = icmp eq i64 %iv.next, %N
br i1 %exitcond, label %loop.exit, label %loop
loop.exit:
br label %exit
exit:
ret void
}