1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=dse -S %s | FileCheck %s
4 define void @memset_equal_size_values(ptr %ptr, i64 %len) {
5 ; CHECK-LABEL: @memset_equal_size_values(
6 ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 1 [[PTR:%.*]], i8 0, i64 [[LEN:%.*]], i1 false)
9 call void @llvm.memset.p0.i64(ptr align 1 %ptr, i8 0, i64 %len, i1 false)
10 call void @llvm.memset.p0.i64(ptr align 1 %ptr, i8 0, i64 %len, i1 false)
14 define void @memset_different_size_values_1(ptr %ptr, i64 %len.1, i64 %len.2) {
15 ; CHECK-LABEL: @memset_different_size_values_1(
16 ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 1 [[PTR:%.*]], i8 0, i64 [[LEN_1:%.*]], i1 false)
17 ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 1 [[PTR]], i8 0, i64 [[LEN_2:%.*]], i1 false)
18 ; CHECK-NEXT: ret void
20 call void @llvm.memset.p0.i64(ptr align 1 %ptr, i8 0, i64 %len.1, i1 false)
21 call void @llvm.memset.p0.i64(ptr align 1 %ptr, i8 0, i64 %len.2, i1 false)
25 define void @memset_different_size_values_2(ptr %ptr, i64 %len) {
26 ; CHECK-LABEL: @memset_different_size_values_2(
27 ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 1 [[PTR:%.*]], i8 0, i64 [[LEN:%.*]], i1 false)
28 ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 1 [[PTR]], i8 0, i64 100, i1 false)
29 ; CHECK-NEXT: ret void
31 call void @llvm.memset.p0.i64(ptr align 1 %ptr, i8 0, i64 %len, i1 false)
32 call void @llvm.memset.p0.i64(ptr align 1 %ptr, i8 0, i64 100, i1 false)
36 define void @memset_different_size_values_3(ptr %ptr, i64 %len) {
37 ; CHECK-LABEL: @memset_different_size_values_3(
38 ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 1 [[PTR:%.*]], i8 0, i64 100, i1 false)
39 ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 1 [[PTR]], i8 0, i64 [[LEN:%.*]], i1 false)
40 ; CHECK-NEXT: ret void
42 call void @llvm.memset.p0.i64(ptr align 1 %ptr, i8 0, i64 100, i1 false)
43 call void @llvm.memset.p0.i64(ptr align 1 %ptr, i8 0, i64 %len, i1 false)
47 define void @memset_and_store_1(ptr %ptr, i64 %len) {
48 ; CHECK-LABEL: @memset_and_store_1(
49 ; CHECK-NEXT: store i64 123, ptr [[PTR:%.*]], align 4
50 ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 1 [[PTR]], i8 0, i64 [[LEN:%.*]], i1 false)
51 ; CHECK-NEXT: ret void
53 store i64 123, ptr %ptr
54 call void @llvm.memset.p0.i64(ptr align 1 %ptr, i8 0, i64 %len, i1 false)
58 define void @memset_and_store_2(ptr %ptr, i64 %len) {
59 ; CHECK-LABEL: @memset_and_store_2(
60 ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 1 [[PTR:%.*]], i8 0, i64 [[LEN:%.*]], i1 false)
61 ; CHECK-NEXT: store i64 123, ptr [[PTR]], align 4
62 ; CHECK-NEXT: ret void
64 call void @llvm.memset.p0.i64(ptr align 1 %ptr, i8 0, i64 %len, i1 false)
65 store i64 123, ptr %ptr
69 define void @memcpy_equal_size_values(ptr noalias %src, ptr noalias %dst, i64 %len) {
70 ; CHECK-LABEL: @memcpy_equal_size_values(
71 ; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr [[DST:%.*]], ptr [[SRC:%.*]], i64 [[LEN:%.*]], i1 false)
72 ; CHECK-NEXT: ret void
74 call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 %len, i1 false)
75 call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 %len, i1 false)
79 define void @memcpy_different_size_values_1(ptr noalias %src, ptr noalias %dst, i64 %len.1, i64 %len.2) {
80 ; CHECK-LABEL: @memcpy_different_size_values_1(
81 ; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr [[DST:%.*]], ptr [[SRC:%.*]], i64 [[LEN_1:%.*]], i1 false)
82 ; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr [[DST]], ptr [[SRC]], i64 [[LEN_2:%.*]], i1 false)
83 ; CHECK-NEXT: ret void
85 call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 %len.1, i1 false)
86 call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 %len.2, i1 false)
90 define void @memcpy_different_size_values_2(ptr noalias %src, ptr noalias %dst, i64 %len) {
91 ; CHECK-LABEL: @memcpy_different_size_values_2(
92 ; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr [[DST:%.*]], ptr [[SRC:%.*]], i64 [[LEN:%.*]], i1 false)
93 ; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr [[DST]], ptr [[SRC]], i64 100, i1 false)
94 ; CHECK-NEXT: ret void
96 call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 %len, i1 false)
97 call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 100, i1 false)
101 define void @memcpy_different_size_values_3(ptr noalias %src, ptr noalias %dst, i64 %len) {
102 ; CHECK-LABEL: @memcpy_different_size_values_3(
103 ; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr [[DST:%.*]], ptr [[SRC:%.*]], i64 100, i1 false)
104 ; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr [[DST]], ptr [[SRC]], i64 [[LEN:%.*]], i1 false)
105 ; CHECK-NEXT: ret void
107 call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 100, i1 false)
108 call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 %len, i1 false)
112 define void @memset_and_memcpy_equal_size_values(ptr noalias %src, ptr noalias %dst, i64 %len) {
113 ; CHECK-LABEL: @memset_and_memcpy_equal_size_values(
114 ; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr [[DST:%.*]], ptr [[SRC:%.*]], i64 [[LEN:%.*]], i1 false)
115 ; CHECK-NEXT: ret void
117 call void @llvm.memset.p0.i64(ptr align 1 %dst, i8 0, i64 %len, i1 false)
118 call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 %len, i1 false)
122 define void @memset_and_memcpy_different_size_values_1(ptr noalias %src, ptr noalias %dst, i64 %len.1, i64 %len.2) {
123 ; CHECK-LABEL: @memset_and_memcpy_different_size_values_1(
124 ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 1 [[DST:%.*]], i8 0, i64 [[LEN_1:%.*]], i1 false)
125 ; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr [[DST]], ptr [[SRC:%.*]], i64 [[LEN_2:%.*]], i1 false)
126 ; CHECK-NEXT: ret void
128 call void @llvm.memset.p0.i64(ptr align 1 %dst, i8 0, i64 %len.1, i1 false)
129 call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 %len.2, i1 false)
133 define void @memset_and_memcpy_different_size_values_2(ptr noalias %src, ptr noalias %dst, i64 %len.1) {
134 ; CHECK-LABEL: @memset_and_memcpy_different_size_values_2(
135 ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 1 [[DST:%.*]], i8 0, i64 [[LEN_1:%.*]], i1 false)
136 ; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr [[DST]], ptr [[SRC:%.*]], i64 100, i1 false)
137 ; CHECK-NEXT: ret void
139 call void @llvm.memset.p0.i64(ptr align 1 %dst, i8 0, i64 %len.1, i1 false)
140 call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 100, i1 false)
144 define void @memset_and_memcpy_different_size_values_3(ptr noalias %src, ptr noalias %dst, i64 %len.1) {
145 ; CHECK-LABEL: @memset_and_memcpy_different_size_values_3(
146 ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 1 [[DST:%.*]], i8 0, i64 100, i1 false)
147 ; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr [[DST]], ptr [[SRC:%.*]], i64 [[LEN_1:%.*]], i1 false)
148 ; CHECK-NEXT: ret void
150 call void @llvm.memset.p0.i64(ptr align 1 %dst, i8 0, i64 100, i1 false)
151 call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 %len.1, i1 false)
155 define void @memcpy_and_memset_equal_size_values(ptr noalias %src, ptr noalias %dst, i64 %len) {
156 ; CHECK-LABEL: @memcpy_and_memset_equal_size_values(
157 ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 1 [[DST:%.*]], i8 0, i64 [[LEN:%.*]], i1 false)
158 ; CHECK-NEXT: ret void
160 call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 %len, i1 false)
161 call void @llvm.memset.p0.i64(ptr align 1 %dst, i8 0, i64 %len, i1 false)
165 define void @memcpy_and_memset_different_size_values_1(ptr noalias %src, ptr noalias %dst, i64 %len.1, i64 %len.2) {
166 ; CHECK-LABEL: @memcpy_and_memset_different_size_values_1(
167 ; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr [[DST:%.*]], ptr [[SRC:%.*]], i64 [[LEN_1:%.*]], i1 false)
168 ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 1 [[DST]], i8 0, i64 [[LEN_2:%.*]], i1 false)
169 ; CHECK-NEXT: ret void
171 call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 %len.1, i1 false)
172 call void @llvm.memset.p0.i64(ptr align 1 %dst, i8 0, i64 %len.2, i1 false)
176 define void @memcpy_and_memset_different_size_values_2(ptr noalias %src, ptr noalias %dst, i64 %len.1) {
177 ; CHECK-LABEL: @memcpy_and_memset_different_size_values_2(
178 ; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr [[DST:%.*]], ptr [[SRC:%.*]], i64 [[LEN_1:%.*]], i1 false)
179 ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 1 [[DST]], i8 0, i64 100, i1 false)
180 ; CHECK-NEXT: ret void
182 call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 %len.1, i1 false)
183 call void @llvm.memset.p0.i64(ptr align 1 %dst, i8 0, i64 100, i1 false)
187 define void @memcpy_and_memset_different_size_values_3(ptr noalias %src, ptr noalias %dst, i64 %len.1) {
188 ; CHECK-LABEL: @memcpy_and_memset_different_size_values_3(
189 ; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr [[DST:%.*]], ptr [[SRC:%.*]], i64 100, i1 false)
190 ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 1 [[DST]], i8 0, i64 [[LEN_1:%.*]], i1 false)
191 ; CHECK-NEXT: ret void
193 call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 100, i1 false)
194 call void @llvm.memset.p0.i64(ptr align 1 %dst, i8 0, i64 %len.1, i1 false)
198 define void @memmove_equal_size_values(ptr noalias %src, ptr noalias %dst, i64 %len) {
199 ; CHECK-LABEL: @memmove_equal_size_values(
200 ; CHECK-NEXT: call void @llvm.memmove.p0.p0.i64(ptr [[DST:%.*]], ptr [[SRC:%.*]], i64 [[LEN:%.*]], i1 false)
201 ; CHECK-NEXT: ret void
203 call void @llvm.memmove.p0.p0.i64(ptr %dst, ptr %src, i64 %len, i1 false)
204 call void @llvm.memmove.p0.p0.i64(ptr %dst, ptr %src, i64 %len, i1 false)
208 define void @memmove_different_size_values_1(ptr noalias %src, ptr noalias %dst, i64 %len.1, i64 %len.2) {
209 ; CHECK-LABEL: @memmove_different_size_values_1(
210 ; CHECK-NEXT: call void @llvm.memmove.p0.p0.i64(ptr [[DST:%.*]], ptr [[SRC:%.*]], i64 [[LEN_1:%.*]], i1 false)
211 ; CHECK-NEXT: call void @llvm.memmove.p0.p0.i64(ptr [[DST]], ptr [[SRC]], i64 [[LEN_2:%.*]], i1 false)
212 ; CHECK-NEXT: ret void
214 call void @llvm.memmove.p0.p0.i64(ptr %dst, ptr %src, i64 %len.1, i1 false)
215 call void @llvm.memmove.p0.p0.i64(ptr %dst, ptr %src, i64 %len.2, i1 false)
219 define void @memmove_different_size_values_2(ptr noalias %src, ptr noalias %dst, i64 %len) {
220 ; CHECK-LABEL: @memmove_different_size_values_2(
221 ; CHECK-NEXT: call void @llvm.memmove.p0.p0.i64(ptr [[DST:%.*]], ptr [[SRC:%.*]], i64 [[LEN:%.*]], i1 false)
222 ; CHECK-NEXT: call void @llvm.memmove.p0.p0.i64(ptr [[DST]], ptr [[SRC]], i64 100, i1 false)
223 ; CHECK-NEXT: ret void
225 call void @llvm.memmove.p0.p0.i64(ptr %dst, ptr %src, i64 %len, i1 false)
226 call void @llvm.memmove.p0.p0.i64(ptr %dst, ptr %src, i64 100, i1 false)
230 define void @memmove_different_size_values_3(ptr noalias %src, ptr noalias %dst, i64 %len) {
231 ; CHECK-LABEL: @memmove_different_size_values_3(
232 ; CHECK-NEXT: call void @llvm.memmove.p0.p0.i64(ptr [[DST:%.*]], ptr [[SRC:%.*]], i64 100, i1 false)
233 ; CHECK-NEXT: call void @llvm.memmove.p0.p0.i64(ptr [[DST]], ptr [[SRC]], i64 [[LEN:%.*]], i1 false)
234 ; CHECK-NEXT: ret void
236 call void @llvm.memmove.p0.p0.i64(ptr %dst, ptr %src, i64 100, i1 false)
237 call void @llvm.memmove.p0.p0.i64(ptr %dst, ptr %src, i64 %len, i1 false)
241 define void @memset_and_memmove_equal_size_values(ptr noalias %src, ptr noalias %dst, i64 %len) {
242 ; CHECK-LABEL: @memset_and_memmove_equal_size_values(
243 ; CHECK-NEXT: call void @llvm.memmove.p0.p0.i64(ptr [[DST:%.*]], ptr [[SRC:%.*]], i64 [[LEN:%.*]], i1 false)
244 ; CHECK-NEXT: ret void
246 call void @llvm.memset.p0.i64(ptr align 1 %dst, i8 0, i64 %len, i1 false)
247 call void @llvm.memmove.p0.p0.i64(ptr %dst, ptr %src, i64 %len, i1 false)
251 define void @memset_and_memmove_different_size_values_1(ptr noalias %src, ptr noalias %dst, i64 %len.1, i64 %len.2) {
252 ; CHECK-LABEL: @memset_and_memmove_different_size_values_1(
253 ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 1 [[DST:%.*]], i8 0, i64 [[LEN_1:%.*]], i1 false)
254 ; CHECK-NEXT: call void @llvm.memmove.p0.p0.i64(ptr [[DST]], ptr [[SRC:%.*]], i64 [[LEN_2:%.*]], i1 false)
255 ; CHECK-NEXT: ret void
257 call void @llvm.memset.p0.i64(ptr align 1 %dst, i8 0, i64 %len.1, i1 false)
258 call void @llvm.memmove.p0.p0.i64(ptr %dst, ptr %src, i64 %len.2, i1 false)
262 define void @memset_and_memmove_different_size_values_2(ptr noalias %src, ptr noalias %dst, i64 %len.1) {
263 ; CHECK-LABEL: @memset_and_memmove_different_size_values_2(
264 ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 1 [[DST:%.*]], i8 0, i64 [[LEN_1:%.*]], i1 false)
265 ; CHECK-NEXT: call void @llvm.memmove.p0.p0.i64(ptr [[DST]], ptr [[SRC:%.*]], i64 100, i1 false)
266 ; CHECK-NEXT: ret void
268 call void @llvm.memset.p0.i64(ptr align 1 %dst, i8 0, i64 %len.1, i1 false)
269 call void @llvm.memmove.p0.p0.i64(ptr %dst, ptr %src, i64 100, i1 false)
273 define void @memset_and_memmove_different_size_values_3(ptr noalias %src, ptr noalias %dst, i64 %len.1) {
274 ; CHECK-LABEL: @memset_and_memmove_different_size_values_3(
275 ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 1 [[DST:%.*]], i8 0, i64 100, i1 false)
276 ; CHECK-NEXT: call void @llvm.memmove.p0.p0.i64(ptr [[DST]], ptr [[SRC:%.*]], i64 [[LEN_1:%.*]], i1 false)
277 ; CHECK-NEXT: ret void
279 call void @llvm.memset.p0.i64(ptr align 1 %dst, i8 0, i64 100, i1 false)
280 call void @llvm.memmove.p0.p0.i64(ptr %dst, ptr %src, i64 %len.1, i1 false)
284 define void @memmove_and_memset_equal_size_values(ptr noalias %src, ptr noalias %dst, i64 %len) {
285 ; CHECK-LABEL: @memmove_and_memset_equal_size_values(
286 ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 1 [[DST:%.*]], i8 0, i64 [[LEN:%.*]], i1 false)
287 ; CHECK-NEXT: ret void
289 call void @llvm.memmove.p0.p0.i64(ptr %dst, ptr %src, i64 %len, i1 false)
290 call void @llvm.memset.p0.i64(ptr align 1 %dst, i8 0, i64 %len, i1 false)
294 define void @memmove_and_memset_different_size_values_1(ptr noalias %src, ptr noalias %dst, i64 %len.1, i64 %len.2) {
295 ; CHECK-LABEL: @memmove_and_memset_different_size_values_1(
296 ; CHECK-NEXT: call void @llvm.memmove.p0.p0.i64(ptr [[DST:%.*]], ptr [[SRC:%.*]], i64 [[LEN_1:%.*]], i1 false)
297 ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 1 [[DST]], i8 0, i64 [[LEN_2:%.*]], i1 false)
298 ; CHECK-NEXT: ret void
300 call void @llvm.memmove.p0.p0.i64(ptr %dst, ptr %src, i64 %len.1, i1 false)
301 call void @llvm.memset.p0.i64(ptr align 1 %dst, i8 0, i64 %len.2, i1 false)
305 define void @memmove_and_memset_different_size_values_2(ptr noalias %src, ptr noalias %dst, i64 %len.1) {
306 ; CHECK-LABEL: @memmove_and_memset_different_size_values_2(
307 ; CHECK-NEXT: call void @llvm.memmove.p0.p0.i64(ptr [[DST:%.*]], ptr [[SRC:%.*]], i64 [[LEN_1:%.*]], i1 false)
308 ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 1 [[DST]], i8 0, i64 100, i1 false)
309 ; CHECK-NEXT: ret void
311 call void @llvm.memmove.p0.p0.i64(ptr %dst, ptr %src, i64 %len.1, i1 false)
312 call void @llvm.memset.p0.i64(ptr align 1 %dst, i8 0, i64 100, i1 false)
316 define void @memmove_and_memset_different_size_values_3(ptr noalias %src, ptr noalias %dst, i64 %len.1) {
317 ; CHECK-LABEL: @memmove_and_memset_different_size_values_3(
318 ; CHECK-NEXT: call void @llvm.memmove.p0.p0.i64(ptr [[DST:%.*]], ptr [[SRC:%.*]], i64 100, i1 false)
319 ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 1 [[DST]], i8 0, i64 [[LEN_1:%.*]], i1 false)
320 ; CHECK-NEXT: ret void
322 call void @llvm.memmove.p0.p0.i64(ptr %dst, ptr %src, i64 100, i1 false)
323 call void @llvm.memset.p0.i64(ptr align 1 %dst, i8 0, i64 %len.1, i1 false)
327 define void @memmove_and_memcpy_equal_size_values(ptr noalias %src, ptr noalias %dst, i64 %len) {
328 ; CHECK-LABEL: @memmove_and_memcpy_equal_size_values(
329 ; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr [[DST:%.*]], ptr [[SRC:%.*]], i64 [[LEN:%.*]], i1 false)
330 ; CHECK-NEXT: ret void
332 call void @llvm.memmove.p0.p0.i64(ptr %dst, ptr %src, i64 %len, i1 false)
333 call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 %len, i1 false)
337 define void @memcpy_and_memmove_equal_size_values(ptr noalias %src, ptr noalias %dst, i64 %len) {
338 ; CHECK-LABEL: @memcpy_and_memmove_equal_size_values(
339 ; CHECK-NEXT: call void @llvm.memmove.p0.p0.i64(ptr [[DST:%.*]], ptr [[SRC:%.*]], i64 [[LEN:%.*]], i1 false)
340 ; CHECK-NEXT: ret void
342 call void @llvm.memcpy.p0.p0.i64(ptr %dst, ptr %src, i64 %len, i1 false)
343 call void @llvm.memmove.p0.p0.i64(ptr %dst, ptr %src, i64 %len, i1 false)
347 declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg)
348 declare void @llvm.memcpy.p0.p0.i64(ptr nocapture, ptr nocapture, i64, i1)
349 declare void @llvm.memmove.p0.p0.i64(ptr nocapture, ptr nocapture, i64, i1)