1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=wasm32-unknown-unknown -mattr=+simd128,+nontrapping-fptoint | FileCheck %s
6 define i32 @stest_f64i32(double %x) {
7 ; CHECK-LABEL: stest_f64i32:
8 ; CHECK: .functype stest_f64i32 (f64) -> (i32)
9 ; CHECK-NEXT: # %bb.0: # %entry
10 ; CHECK-NEXT: local.get 0
11 ; CHECK-NEXT: i32.trunc_sat_f64_s
12 ; CHECK-NEXT: # fallthrough-return
14 %conv = fptosi double %x to i64
15 %0 = icmp slt i64 %conv, 2147483647
16 %spec.store.select = select i1 %0, i64 %conv, i64 2147483647
17 %1 = icmp sgt i64 %spec.store.select, -2147483648
18 %spec.store.select7 = select i1 %1, i64 %spec.store.select, i64 -2147483648
19 %conv6 = trunc i64 %spec.store.select7 to i32
23 define i32 @utest_f64i32(double %x) {
24 ; CHECK-LABEL: utest_f64i32:
25 ; CHECK: .functype utest_f64i32 (f64) -> (i32)
26 ; CHECK-NEXT: # %bb.0: # %entry
27 ; CHECK-NEXT: local.get 0
28 ; CHECK-NEXT: i32.trunc_sat_f64_u
29 ; CHECK-NEXT: # fallthrough-return
31 %conv = fptoui double %x to i64
32 %0 = icmp ult i64 %conv, 4294967295
33 %spec.store.select = select i1 %0, i64 %conv, i64 4294967295
34 %conv6 = trunc i64 %spec.store.select to i32
38 define i32 @ustest_f64i32(double %x) {
39 ; CHECK-LABEL: ustest_f64i32:
40 ; CHECK: .functype ustest_f64i32 (f64) -> (i32)
41 ; CHECK-NEXT: # %bb.0: # %entry
42 ; CHECK-NEXT: local.get 0
43 ; CHECK-NEXT: i32.trunc_sat_f64_u
44 ; CHECK-NEXT: # fallthrough-return
46 %conv = fptosi double %x to i64
47 %0 = icmp slt i64 %conv, 4294967295
48 %spec.store.select = select i1 %0, i64 %conv, i64 4294967295
49 %1 = icmp sgt i64 %spec.store.select, 0
50 %spec.store.select7 = select i1 %1, i64 %spec.store.select, i64 0
51 %conv6 = trunc i64 %spec.store.select7 to i32
55 define i32 @stest_f32i32(float %x) {
56 ; CHECK-LABEL: stest_f32i32:
57 ; CHECK: .functype stest_f32i32 (f32) -> (i32)
58 ; CHECK-NEXT: # %bb.0: # %entry
59 ; CHECK-NEXT: local.get 0
60 ; CHECK-NEXT: i32.trunc_sat_f32_s
61 ; CHECK-NEXT: # fallthrough-return
63 %conv = fptosi float %x to i64
64 %0 = icmp slt i64 %conv, 2147483647
65 %spec.store.select = select i1 %0, i64 %conv, i64 2147483647
66 %1 = icmp sgt i64 %spec.store.select, -2147483648
67 %spec.store.select7 = select i1 %1, i64 %spec.store.select, i64 -2147483648
68 %conv6 = trunc i64 %spec.store.select7 to i32
72 define i32 @utest_f32i32(float %x) {
73 ; CHECK-LABEL: utest_f32i32:
74 ; CHECK: .functype utest_f32i32 (f32) -> (i32)
75 ; CHECK-NEXT: # %bb.0: # %entry
76 ; CHECK-NEXT: local.get 0
77 ; CHECK-NEXT: i32.trunc_sat_f32_u
78 ; CHECK-NEXT: # fallthrough-return
80 %conv = fptoui float %x to i64
81 %0 = icmp ult i64 %conv, 4294967295
82 %spec.store.select = select i1 %0, i64 %conv, i64 4294967295
83 %conv6 = trunc i64 %spec.store.select to i32
87 define i32 @ustest_f32i32(float %x) {
88 ; CHECK-LABEL: ustest_f32i32:
89 ; CHECK: .functype ustest_f32i32 (f32) -> (i32)
90 ; CHECK-NEXT: # %bb.0: # %entry
91 ; CHECK-NEXT: local.get 0
92 ; CHECK-NEXT: i32.trunc_sat_f32_u
93 ; CHECK-NEXT: # fallthrough-return
95 %conv = fptosi float %x to i64
96 %0 = icmp slt i64 %conv, 4294967295
97 %spec.store.select = select i1 %0, i64 %conv, i64 4294967295
98 %1 = icmp sgt i64 %spec.store.select, 0
99 %spec.store.select7 = select i1 %1, i64 %spec.store.select, i64 0
100 %conv6 = trunc i64 %spec.store.select7 to i32
104 define i32 @stest_f16i32(half %x) {
105 ; CHECK-LABEL: stest_f16i32:
106 ; CHECK: .functype stest_f16i32 (f32) -> (i32)
107 ; CHECK-NEXT: # %bb.0: # %entry
108 ; CHECK-NEXT: local.get 0
109 ; CHECK-NEXT: call __truncsfhf2
110 ; CHECK-NEXT: call __extendhfsf2
111 ; CHECK-NEXT: i32.trunc_sat_f32_s
112 ; CHECK-NEXT: # fallthrough-return
114 %conv = fptosi half %x to i64
115 %0 = icmp slt i64 %conv, 2147483647
116 %spec.store.select = select i1 %0, i64 %conv, i64 2147483647
117 %1 = icmp sgt i64 %spec.store.select, -2147483648
118 %spec.store.select7 = select i1 %1, i64 %spec.store.select, i64 -2147483648
119 %conv6 = trunc i64 %spec.store.select7 to i32
123 define i32 @stest_f16i32_cse(half %x) {
124 ; CHECK-LABEL: stest_f16i32_cse:
125 ; CHECK: .functype stest_f16i32_cse (f32) -> (i32)
126 ; CHECK-NEXT: # %bb.0: # %entry
127 ; CHECK-NEXT: local.get 0
128 ; CHECK-NEXT: call __truncsfhf2
129 ; CHECK-NEXT: call __extendhfsf2
130 ; CHECK-NEXT: i64.trunc_sat_f32_s
131 ; CHECK-NEXT: i32.wrap_i64
132 ; CHECK-NEXT: # fallthrough-return
134 %conv = fptosi half %x to i64
135 %conv6 = trunc i64 %conv to i32
139 define i32 @utesth_f16i32(half %x) {
140 ; CHECK-LABEL: utesth_f16i32:
141 ; CHECK: .functype utesth_f16i32 (f32) -> (i32)
142 ; CHECK-NEXT: # %bb.0: # %entry
143 ; CHECK-NEXT: local.get 0
144 ; CHECK-NEXT: call __truncsfhf2
145 ; CHECK-NEXT: call __extendhfsf2
146 ; CHECK-NEXT: i32.trunc_sat_f32_u
147 ; CHECK-NEXT: # fallthrough-return
149 %conv = fptoui half %x to i64
150 %0 = icmp ult i64 %conv, 4294967295
151 %spec.store.select = select i1 %0, i64 %conv, i64 4294967295
152 %conv6 = trunc i64 %spec.store.select to i32
156 define i32 @utesth_f16i32_cse(half %x) {
157 ; CHECK-LABEL: utesth_f16i32_cse:
158 ; CHECK: .functype utesth_f16i32_cse (f32) -> (i32)
159 ; CHECK-NEXT: # %bb.0: # %entry
160 ; CHECK-NEXT: local.get 0
161 ; CHECK-NEXT: call __truncsfhf2
162 ; CHECK-NEXT: call __extendhfsf2
163 ; CHECK-NEXT: i64.trunc_sat_f32_u
164 ; CHECK-NEXT: i32.wrap_i64
165 ; CHECK-NEXT: # fallthrough-return
167 %conv = fptoui half %x to i64
168 %conv6 = trunc i64 %conv to i32
172 define i32 @ustest_f16i32(half %x) {
173 ; CHECK-LABEL: ustest_f16i32:
174 ; CHECK: .functype ustest_f16i32 (f32) -> (i32)
175 ; CHECK-NEXT: # %bb.0: # %entry
176 ; CHECK-NEXT: local.get 0
177 ; CHECK-NEXT: call __truncsfhf2
178 ; CHECK-NEXT: call __extendhfsf2
179 ; CHECK-NEXT: i32.trunc_sat_f32_u
180 ; CHECK-NEXT: # fallthrough-return
182 %conv = fptosi half %x to i64
183 %0 = icmp slt i64 %conv, 4294967295
184 %spec.store.select = select i1 %0, i64 %conv, i64 4294967295
185 %1 = icmp sgt i64 %spec.store.select, 0
186 %spec.store.select7 = select i1 %1, i64 %spec.store.select, i64 0
187 %conv6 = trunc i64 %spec.store.select7 to i32
191 define i32 @ustest_f16i32_cse(half %x) {
192 ; CHECK-LABEL: ustest_f16i32_cse:
193 ; CHECK: .functype ustest_f16i32_cse (f32) -> (i32)
194 ; CHECK-NEXT: # %bb.0: # %entry
195 ; CHECK-NEXT: local.get 0
196 ; CHECK-NEXT: call __truncsfhf2
197 ; CHECK-NEXT: call __extendhfsf2
198 ; CHECK-NEXT: i32.trunc_sat_f32_u
199 ; CHECK-NEXT: # fallthrough-return
201 %conv = fptosi half %x to i64
202 %0 = icmp sgt i64 %conv, 0
203 %spec.store.select7 = select i1 %0, i64 %conv, i64 0
204 %conv6 = trunc i64 %spec.store.select7 to i32
210 define i16 @stest_f64i16(double %x) {
211 ; CHECK-LABEL: stest_f64i16:
212 ; CHECK: .functype stest_f64i16 (f64) -> (i32)
213 ; CHECK-NEXT: .local i32
214 ; CHECK-NEXT: # %bb.0: # %entry
215 ; CHECK-NEXT: local.get 0
216 ; CHECK-NEXT: i32.trunc_sat_f64_s
217 ; CHECK-NEXT: local.tee 1
218 ; CHECK-NEXT: i32.const 32767
219 ; CHECK-NEXT: local.get 1
220 ; CHECK-NEXT: i32.const 32767
221 ; CHECK-NEXT: i32.lt_s
222 ; CHECK-NEXT: i32.select
223 ; CHECK-NEXT: local.tee 1
224 ; CHECK-NEXT: i32.const -32768
225 ; CHECK-NEXT: local.get 1
226 ; CHECK-NEXT: i32.const -32768
227 ; CHECK-NEXT: i32.gt_s
228 ; CHECK-NEXT: i32.select
229 ; CHECK-NEXT: # fallthrough-return
231 %conv = fptosi double %x to i32
232 %0 = icmp slt i32 %conv, 32767
233 %spec.store.select = select i1 %0, i32 %conv, i32 32767
234 %1 = icmp sgt i32 %spec.store.select, -32768
235 %spec.store.select7 = select i1 %1, i32 %spec.store.select, i32 -32768
236 %conv6 = trunc i32 %spec.store.select7 to i16
240 define i16 @utest_f64i16(double %x) {
241 ; CHECK-LABEL: utest_f64i16:
242 ; CHECK: .functype utest_f64i16 (f64) -> (i32)
243 ; CHECK-NEXT: .local i32
244 ; CHECK-NEXT: # %bb.0: # %entry
245 ; CHECK-NEXT: local.get 0
246 ; CHECK-NEXT: i32.trunc_sat_f64_u
247 ; CHECK-NEXT: local.tee 1
248 ; CHECK-NEXT: i32.const 65535
249 ; CHECK-NEXT: local.get 1
250 ; CHECK-NEXT: i32.const 65535
251 ; CHECK-NEXT: i32.lt_u
252 ; CHECK-NEXT: i32.select
253 ; CHECK-NEXT: # fallthrough-return
255 %conv = fptoui double %x to i32
256 %0 = icmp ult i32 %conv, 65535
257 %spec.store.select = select i1 %0, i32 %conv, i32 65535
258 %conv6 = trunc i32 %spec.store.select to i16
262 define i16 @ustest_f64i16(double %x) {
263 ; CHECK-LABEL: ustest_f64i16:
264 ; CHECK: .functype ustest_f64i16 (f64) -> (i32)
265 ; CHECK-NEXT: .local i32
266 ; CHECK-NEXT: # %bb.0: # %entry
267 ; CHECK-NEXT: local.get 0
268 ; CHECK-NEXT: i32.trunc_sat_f64_s
269 ; CHECK-NEXT: local.tee 1
270 ; CHECK-NEXT: i32.const 65535
271 ; CHECK-NEXT: local.get 1
272 ; CHECK-NEXT: i32.const 65535
273 ; CHECK-NEXT: i32.lt_s
274 ; CHECK-NEXT: i32.select
275 ; CHECK-NEXT: local.tee 1
276 ; CHECK-NEXT: i32.const 0
277 ; CHECK-NEXT: local.get 1
278 ; CHECK-NEXT: i32.const 0
279 ; CHECK-NEXT: i32.gt_s
280 ; CHECK-NEXT: i32.select
281 ; CHECK-NEXT: # fallthrough-return
283 %conv = fptosi double %x to i32
284 %0 = icmp slt i32 %conv, 65535
285 %spec.store.select = select i1 %0, i32 %conv, i32 65535
286 %1 = icmp sgt i32 %spec.store.select, 0
287 %spec.store.select7 = select i1 %1, i32 %spec.store.select, i32 0
288 %conv6 = trunc i32 %spec.store.select7 to i16
292 define i16 @stest_f32i16(float %x) {
293 ; CHECK-LABEL: stest_f32i16:
294 ; CHECK: .functype stest_f32i16 (f32) -> (i32)
295 ; CHECK-NEXT: .local i32
296 ; CHECK-NEXT: # %bb.0: # %entry
297 ; CHECK-NEXT: local.get 0
298 ; CHECK-NEXT: i32.trunc_sat_f32_s
299 ; CHECK-NEXT: local.tee 1
300 ; CHECK-NEXT: i32.const 32767
301 ; CHECK-NEXT: local.get 1
302 ; CHECK-NEXT: i32.const 32767
303 ; CHECK-NEXT: i32.lt_s
304 ; CHECK-NEXT: i32.select
305 ; CHECK-NEXT: local.tee 1
306 ; CHECK-NEXT: i32.const -32768
307 ; CHECK-NEXT: local.get 1
308 ; CHECK-NEXT: i32.const -32768
309 ; CHECK-NEXT: i32.gt_s
310 ; CHECK-NEXT: i32.select
311 ; CHECK-NEXT: # fallthrough-return
313 %conv = fptosi float %x to i32
314 %0 = icmp slt i32 %conv, 32767
315 %spec.store.select = select i1 %0, i32 %conv, i32 32767
316 %1 = icmp sgt i32 %spec.store.select, -32768
317 %spec.store.select7 = select i1 %1, i32 %spec.store.select, i32 -32768
318 %conv6 = trunc i32 %spec.store.select7 to i16
322 define i16 @utest_f32i16(float %x) {
323 ; CHECK-LABEL: utest_f32i16:
324 ; CHECK: .functype utest_f32i16 (f32) -> (i32)
325 ; CHECK-NEXT: .local i32
326 ; CHECK-NEXT: # %bb.0: # %entry
327 ; CHECK-NEXT: local.get 0
328 ; CHECK-NEXT: i32.trunc_sat_f32_u
329 ; CHECK-NEXT: local.tee 1
330 ; CHECK-NEXT: i32.const 65535
331 ; CHECK-NEXT: local.get 1
332 ; CHECK-NEXT: i32.const 65535
333 ; CHECK-NEXT: i32.lt_u
334 ; CHECK-NEXT: i32.select
335 ; CHECK-NEXT: # fallthrough-return
337 %conv = fptoui float %x to i32
338 %0 = icmp ult i32 %conv, 65535
339 %spec.store.select = select i1 %0, i32 %conv, i32 65535
340 %conv6 = trunc i32 %spec.store.select to i16
344 define i16 @ustest_f32i16(float %x) {
345 ; CHECK-LABEL: ustest_f32i16:
346 ; CHECK: .functype ustest_f32i16 (f32) -> (i32)
347 ; CHECK-NEXT: .local i32
348 ; CHECK-NEXT: # %bb.0: # %entry
349 ; CHECK-NEXT: local.get 0
350 ; CHECK-NEXT: i32.trunc_sat_f32_s
351 ; CHECK-NEXT: local.tee 1
352 ; CHECK-NEXT: i32.const 65535
353 ; CHECK-NEXT: local.get 1
354 ; CHECK-NEXT: i32.const 65535
355 ; CHECK-NEXT: i32.lt_s
356 ; CHECK-NEXT: i32.select
357 ; CHECK-NEXT: local.tee 1
358 ; CHECK-NEXT: i32.const 0
359 ; CHECK-NEXT: local.get 1
360 ; CHECK-NEXT: i32.const 0
361 ; CHECK-NEXT: i32.gt_s
362 ; CHECK-NEXT: i32.select
363 ; CHECK-NEXT: # fallthrough-return
365 %conv = fptosi float %x to i32
366 %0 = icmp slt i32 %conv, 65535
367 %spec.store.select = select i1 %0, i32 %conv, i32 65535
368 %1 = icmp sgt i32 %spec.store.select, 0
369 %spec.store.select7 = select i1 %1, i32 %spec.store.select, i32 0
370 %conv6 = trunc i32 %spec.store.select7 to i16
374 define i16 @stest_f16i16(half %x) {
375 ; CHECK-LABEL: stest_f16i16:
376 ; CHECK: .functype stest_f16i16 (f32) -> (i32)
377 ; CHECK-NEXT: .local i32
378 ; CHECK-NEXT: # %bb.0: # %entry
379 ; CHECK-NEXT: local.get 0
380 ; CHECK-NEXT: call __truncsfhf2
381 ; CHECK-NEXT: call __extendhfsf2
382 ; CHECK-NEXT: i32.trunc_sat_f32_s
383 ; CHECK-NEXT: local.tee 1
384 ; CHECK-NEXT: i32.const 32767
385 ; CHECK-NEXT: local.get 1
386 ; CHECK-NEXT: i32.const 32767
387 ; CHECK-NEXT: i32.lt_s
388 ; CHECK-NEXT: i32.select
389 ; CHECK-NEXT: local.tee 1
390 ; CHECK-NEXT: i32.const -32768
391 ; CHECK-NEXT: local.get 1
392 ; CHECK-NEXT: i32.const -32768
393 ; CHECK-NEXT: i32.gt_s
394 ; CHECK-NEXT: i32.select
395 ; CHECK-NEXT: # fallthrough-return
397 %conv = fptosi half %x to i32
398 %0 = icmp slt i32 %conv, 32767
399 %spec.store.select = select i1 %0, i32 %conv, i32 32767
400 %1 = icmp sgt i32 %spec.store.select, -32768
401 %spec.store.select7 = select i1 %1, i32 %spec.store.select, i32 -32768
402 %conv6 = trunc i32 %spec.store.select7 to i16
406 define i16 @utesth_f16i16(half %x) {
407 ; CHECK-LABEL: utesth_f16i16:
408 ; CHECK: .functype utesth_f16i16 (f32) -> (i32)
409 ; CHECK-NEXT: .local i32
410 ; CHECK-NEXT: # %bb.0: # %entry
411 ; CHECK-NEXT: local.get 0
412 ; CHECK-NEXT: call __truncsfhf2
413 ; CHECK-NEXT: call __extendhfsf2
414 ; CHECK-NEXT: i32.trunc_sat_f32_u
415 ; CHECK-NEXT: local.tee 1
416 ; CHECK-NEXT: i32.const 65535
417 ; CHECK-NEXT: local.get 1
418 ; CHECK-NEXT: i32.const 65535
419 ; CHECK-NEXT: i32.lt_u
420 ; CHECK-NEXT: i32.select
421 ; CHECK-NEXT: # fallthrough-return
423 %conv = fptoui half %x to i32
424 %0 = icmp ult i32 %conv, 65535
425 %spec.store.select = select i1 %0, i32 %conv, i32 65535
426 %conv6 = trunc i32 %spec.store.select to i16
430 define i16 @utesth_f16i16_cse(half %x) {
431 ; CHECK-LABEL: utesth_f16i16_cse:
432 ; CHECK: .functype utesth_f16i16_cse (f32) -> (i32)
433 ; CHECK-NEXT: # %bb.0: # %entry
434 ; CHECK-NEXT: local.get 0
435 ; CHECK-NEXT: call __truncsfhf2
436 ; CHECK-NEXT: call __extendhfsf2
437 ; CHECK-NEXT: i32.trunc_sat_f32_u
438 ; CHECK-NEXT: # fallthrough-return
440 %conv = fptoui half %x to i32
441 %conv6 = trunc i32 %conv to i16
445 define i16 @ustest_f16i16(half %x) {
446 ; CHECK-LABEL: ustest_f16i16:
447 ; CHECK: .functype ustest_f16i16 (f32) -> (i32)
448 ; CHECK-NEXT: .local i32
449 ; CHECK-NEXT: # %bb.0: # %entry
450 ; CHECK-NEXT: local.get 0
451 ; CHECK-NEXT: call __truncsfhf2
452 ; CHECK-NEXT: call __extendhfsf2
453 ; CHECK-NEXT: i32.trunc_sat_f32_s
454 ; CHECK-NEXT: local.tee 1
455 ; CHECK-NEXT: i32.const 65535
456 ; CHECK-NEXT: local.get 1
457 ; CHECK-NEXT: i32.const 65535
458 ; CHECK-NEXT: i32.lt_s
459 ; CHECK-NEXT: i32.select
460 ; CHECK-NEXT: local.tee 1
461 ; CHECK-NEXT: i32.const 0
462 ; CHECK-NEXT: local.get 1
463 ; CHECK-NEXT: i32.const 0
464 ; CHECK-NEXT: i32.gt_s
465 ; CHECK-NEXT: i32.select
466 ; CHECK-NEXT: # fallthrough-return
468 %conv = fptosi half %x to i32
469 %0 = icmp slt i32 %conv, 65535
470 %spec.store.select = select i1 %0, i32 %conv, i32 65535
471 %1 = icmp sgt i32 %spec.store.select, 0
472 %spec.store.select7 = select i1 %1, i32 %spec.store.select, i32 0
473 %conv6 = trunc i32 %spec.store.select7 to i16
477 define i16 @ustest_f16i16_cse(half %x) {
478 ; CHECK-LABEL: ustest_f16i16_cse:
479 ; CHECK: .functype ustest_f16i16_cse (f32) -> (i32)
480 ; CHECK-NEXT: # %bb.0: # %entry
481 ; CHECK-NEXT: local.get 0
482 ; CHECK-NEXT: call __truncsfhf2
483 ; CHECK-NEXT: call __extendhfsf2
484 ; CHECK-NEXT: i32.trunc_sat_f32_u
485 ; CHECK-NEXT: # fallthrough-return
487 %conv = fptosi half %x to i32
488 %0 = icmp sgt i32 %conv, 0
489 %spec.store.select7 = select i1 %0, i32 %conv, i32 0
490 %conv6 = trunc i32 %spec.store.select7 to i16
496 define i64 @stest_f64i64(double %x) {
497 ; CHECK-LABEL: stest_f64i64:
498 ; CHECK: .functype stest_f64i64 (f64) -> (i64)
499 ; CHECK-NEXT: # %bb.0: # %entry
500 ; CHECK-NEXT: local.get 0
501 ; CHECK-NEXT: i64.trunc_sat_f64_s
502 ; CHECK-NEXT: # fallthrough-return
504 %conv = fptosi double %x to i128
505 %0 = icmp slt i128 %conv, 9223372036854775807
506 %spec.store.select = select i1 %0, i128 %conv, i128 9223372036854775807
507 %1 = icmp sgt i128 %spec.store.select, -9223372036854775808
508 %spec.store.select7 = select i1 %1, i128 %spec.store.select, i128 -9223372036854775808
509 %conv6 = trunc i128 %spec.store.select7 to i64
513 define i64 @utest_f64i64(double %x) {
514 ; CHECK-LABEL: utest_f64i64:
515 ; CHECK: .functype utest_f64i64 (f64) -> (i64)
516 ; CHECK-NEXT: .local i32, i64, i64
517 ; CHECK-NEXT: # %bb.0: # %entry
518 ; CHECK-NEXT: global.get __stack_pointer
519 ; CHECK-NEXT: i32.const 16
520 ; CHECK-NEXT: i32.sub
521 ; CHECK-NEXT: local.tee 1
522 ; CHECK-NEXT: global.set __stack_pointer
523 ; CHECK-NEXT: local.get 1
524 ; CHECK-NEXT: local.get 0
525 ; CHECK-NEXT: call __fixunsdfti
526 ; CHECK-NEXT: local.get 1
527 ; CHECK-NEXT: i32.const 8
528 ; CHECK-NEXT: i32.add
529 ; CHECK-NEXT: i64.load 0
530 ; CHECK-NEXT: local.set 2
531 ; CHECK-NEXT: local.get 1
532 ; CHECK-NEXT: i64.load 0
533 ; CHECK-NEXT: local.set 3
534 ; CHECK-NEXT: local.get 1
535 ; CHECK-NEXT: i32.const 16
536 ; CHECK-NEXT: i32.add
537 ; CHECK-NEXT: global.set __stack_pointer
538 ; CHECK-NEXT: local.get 3
539 ; CHECK-NEXT: i64.const 0
540 ; CHECK-NEXT: local.get 2
541 ; CHECK-NEXT: i64.eqz
542 ; CHECK-NEXT: i64.select
543 ; CHECK-NEXT: # fallthrough-return
545 %conv = fptoui double %x to i128
546 %0 = icmp ult i128 %conv, 18446744073709551616
547 %spec.store.select = select i1 %0, i128 %conv, i128 18446744073709551616
548 %conv6 = trunc i128 %spec.store.select to i64
552 define i64 @utest_f64i64_cse_combine(double %x) #0 {
553 ; CHECK-LABEL: utest_f64i64_cse_combine:
554 ; CHECK: .functype utest_f64i64_cse_combine (f64) -> (i64)
555 ; CHECK-NEXT: .local i32, i64, i64
556 ; CHECK-NEXT: # %bb.0: # %entry
557 ; CHECK-NEXT: global.get __stack_pointer
558 ; CHECK-NEXT: i32.const 16
559 ; CHECK-NEXT: i32.sub
560 ; CHECK-NEXT: local.tee 1
561 ; CHECK-NEXT: global.set __stack_pointer
562 ; CHECK-NEXT: local.get 1
563 ; CHECK-NEXT: local.get 0
564 ; CHECK-NEXT: call __fixunsdfti
565 ; CHECK-NEXT: local.get 1
566 ; CHECK-NEXT: i32.const 8
567 ; CHECK-NEXT: i32.add
568 ; CHECK-NEXT: i64.load 0
569 ; CHECK-NEXT: local.set 2
570 ; CHECK-NEXT: local.get 1
571 ; CHECK-NEXT: i64.load 0
572 ; CHECK-NEXT: local.set 3
573 ; CHECK-NEXT: local.get 1
574 ; CHECK-NEXT: i32.const 16
575 ; CHECK-NEXT: i32.add
576 ; CHECK-NEXT: global.set __stack_pointer
577 ; CHECK-NEXT: local.get 3
578 ; CHECK-NEXT: i64.const 0
579 ; CHECK-NEXT: local.get 2
580 ; CHECK-NEXT: i64.eqz
581 ; CHECK-NEXT: i64.select
582 ; CHECK-NEXT: # fallthrough-return
584 %conv = fptoui double %x to i128
585 %spec.store.select = call i128 @llvm.umin.i128(i128 %conv, i128 18446744073709551616)
586 %conv6 = trunc i128 %spec.store.select to i64
591 define i64 @ustest_f64i64(double %x) {
592 ; CHECK-LABEL: ustest_f64i64:
593 ; CHECK: .functype ustest_f64i64 (f64) -> (i64)
594 ; CHECK-NEXT: .local i32, i64, i64
595 ; CHECK-NEXT: # %bb.0: # %entry
596 ; CHECK-NEXT: global.get __stack_pointer
597 ; CHECK-NEXT: i32.const 16
598 ; CHECK-NEXT: i32.sub
599 ; CHECK-NEXT: local.tee 1
600 ; CHECK-NEXT: global.set __stack_pointer
601 ; CHECK-NEXT: local.get 1
602 ; CHECK-NEXT: local.get 0
603 ; CHECK-NEXT: call __fixdfti
604 ; CHECK-NEXT: local.get 1
605 ; CHECK-NEXT: i32.const 8
606 ; CHECK-NEXT: i32.add
607 ; CHECK-NEXT: i64.load 0
608 ; CHECK-NEXT: local.set 2
609 ; CHECK-NEXT: local.get 1
610 ; CHECK-NEXT: i64.load 0
611 ; CHECK-NEXT: local.set 3
612 ; CHECK-NEXT: local.get 1
613 ; CHECK-NEXT: i32.const 16
614 ; CHECK-NEXT: i32.add
615 ; CHECK-NEXT: global.set __stack_pointer
616 ; CHECK-NEXT: local.get 3
617 ; CHECK-NEXT: i64.const 0
618 ; CHECK-NEXT: local.get 2
619 ; CHECK-NEXT: i64.const 1
620 ; CHECK-NEXT: i64.lt_s
621 ; CHECK-NEXT: local.tee 1
622 ; CHECK-NEXT: i64.select
623 ; CHECK-NEXT: local.tee 3
624 ; CHECK-NEXT: i64.const 0
625 ; CHECK-NEXT: local.get 3
626 ; CHECK-NEXT: i64.const 0
628 ; CHECK-NEXT: local.get 2
629 ; CHECK-NEXT: i64.const 1
630 ; CHECK-NEXT: local.get 1
631 ; CHECK-NEXT: i64.select
632 ; CHECK-NEXT: local.tee 2
633 ; CHECK-NEXT: i64.const 0
634 ; CHECK-NEXT: i64.gt_s
635 ; CHECK-NEXT: local.get 2
636 ; CHECK-NEXT: i64.eqz
637 ; CHECK-NEXT: i32.select
638 ; CHECK-NEXT: i64.select
639 ; CHECK-NEXT: # fallthrough-return
641 %conv = fptosi double %x to i128
642 %0 = icmp slt i128 %conv, 18446744073709551616
643 %spec.store.select = select i1 %0, i128 %conv, i128 18446744073709551616
644 %1 = icmp sgt i128 %spec.store.select, 0
645 %spec.store.select7 = select i1 %1, i128 %spec.store.select, i128 0
646 %conv6 = trunc i128 %spec.store.select7 to i64
650 define i64 @ustest_f64i64_cse_combine(double %x) #0 {
651 ; CHECK-LABEL: ustest_f64i64_cse_combine:
652 ; CHECK: .functype ustest_f64i64_cse_combine (f64) -> (i64)
653 ; CHECK-NEXT: .local i32, i64, i64
654 ; CHECK-NEXT: # %bb.0: # %entry
655 ; CHECK-NEXT: global.get __stack_pointer
656 ; CHECK-NEXT: i32.const 16
657 ; CHECK-NEXT: i32.sub
658 ; CHECK-NEXT: local.tee 1
659 ; CHECK-NEXT: global.set __stack_pointer
660 ; CHECK-NEXT: local.get 1
661 ; CHECK-NEXT: local.get 0
662 ; CHECK-NEXT: call __fixdfti
663 ; CHECK-NEXT: local.get 1
664 ; CHECK-NEXT: i32.const 8
665 ; CHECK-NEXT: i32.add
666 ; CHECK-NEXT: i64.load 0
667 ; CHECK-NEXT: local.set 2
668 ; CHECK-NEXT: local.get 1
669 ; CHECK-NEXT: i64.load 0
670 ; CHECK-NEXT: local.set 3
671 ; CHECK-NEXT: local.get 1
672 ; CHECK-NEXT: i32.const 16
673 ; CHECK-NEXT: i32.add
674 ; CHECK-NEXT: global.set __stack_pointer
675 ; CHECK-NEXT: i64.const 0
676 ; CHECK-NEXT: local.get 3
677 ; CHECK-NEXT: i64.const 0
678 ; CHECK-NEXT: local.get 2
679 ; CHECK-NEXT: i64.const 1
680 ; CHECK-NEXT: i64.lt_s
681 ; CHECK-NEXT: local.tee 1
682 ; CHECK-NEXT: i64.select
683 ; CHECK-NEXT: local.get 2
684 ; CHECK-NEXT: i64.const 1
685 ; CHECK-NEXT: local.get 1
686 ; CHECK-NEXT: i64.select
687 ; CHECK-NEXT: i64.const 0
688 ; CHECK-NEXT: i64.lt_s
689 ; CHECK-NEXT: i64.select
690 ; CHECK-NEXT: # fallthrough-return
692 %conv = fptosi double %x to i128
693 %spec.store.select = call i128 @llvm.smin.i128(i128 %conv, i128 18446744073709551616)
694 %spec.store.select7 = call i128 @llvm.smax.i128(i128 %spec.store.select, i128 0)
695 %conv6 = trunc i128 %spec.store.select7 to i64
699 define i64 @stest_f32i64(float %x) {
700 ; CHECK-LABEL: stest_f32i64:
701 ; CHECK: .functype stest_f32i64 (f32) -> (i64)
702 ; CHECK-NEXT: # %bb.0: # %entry
703 ; CHECK-NEXT: local.get 0
704 ; CHECK-NEXT: i64.trunc_sat_f32_s
705 ; CHECK-NEXT: # fallthrough-return
707 %conv = fptosi float %x to i128
708 %0 = icmp slt i128 %conv, 9223372036854775807
709 %spec.store.select = select i1 %0, i128 %conv, i128 9223372036854775807
710 %1 = icmp sgt i128 %spec.store.select, -9223372036854775808
711 %spec.store.select7 = select i1 %1, i128 %spec.store.select, i128 -9223372036854775808
712 %conv6 = trunc i128 %spec.store.select7 to i64
716 define i64 @utest_f32i64(float %x) {
717 ; CHECK-LABEL: utest_f32i64:
718 ; CHECK: .functype utest_f32i64 (f32) -> (i64)
719 ; CHECK-NEXT: .local i32, i64, i64
720 ; CHECK-NEXT: # %bb.0: # %entry
721 ; CHECK-NEXT: global.get __stack_pointer
722 ; CHECK-NEXT: i32.const 16
723 ; CHECK-NEXT: i32.sub
724 ; CHECK-NEXT: local.tee 1
725 ; CHECK-NEXT: global.set __stack_pointer
726 ; CHECK-NEXT: local.get 1
727 ; CHECK-NEXT: local.get 0
728 ; CHECK-NEXT: call __fixunssfti
729 ; CHECK-NEXT: local.get 1
730 ; CHECK-NEXT: i32.const 8
731 ; CHECK-NEXT: i32.add
732 ; CHECK-NEXT: i64.load 0
733 ; CHECK-NEXT: local.set 2
734 ; CHECK-NEXT: local.get 1
735 ; CHECK-NEXT: i64.load 0
736 ; CHECK-NEXT: local.set 3
737 ; CHECK-NEXT: local.get 1
738 ; CHECK-NEXT: i32.const 16
739 ; CHECK-NEXT: i32.add
740 ; CHECK-NEXT: global.set __stack_pointer
741 ; CHECK-NEXT: local.get 3
742 ; CHECK-NEXT: i64.const 0
743 ; CHECK-NEXT: local.get 2
744 ; CHECK-NEXT: i64.eqz
745 ; CHECK-NEXT: i64.select
746 ; CHECK-NEXT: # fallthrough-return
748 %conv = fptoui float %x to i128
749 %0 = icmp ult i128 %conv, 18446744073709551616
750 %spec.store.select = select i1 %0, i128 %conv, i128 18446744073709551616
751 %conv6 = trunc i128 %spec.store.select to i64
755 define i64 @stest_f32i64_cse_combine(float %x) #0 {
756 ; CHECK-LABEL: stest_f32i64_cse_combine:
757 ; CHECK: .functype stest_f32i64_cse_combine (f32) -> (i64)
758 ; CHECK-NEXT: # %bb.0: # %entry
759 ; CHECK-NEXT: local.get 0
760 ; CHECK-NEXT: i64.trunc_sat_f32_s
761 ; CHECK-NEXT: # fallthrough-return
763 %conv = fptosi float %x to i128
764 %spec.store.select = call i128 @llvm.smin.i128(i128 %conv, i128 9223372036854775807)
765 %spec.store.select7 = call i128 @llvm.smax.i128(i128 %spec.store.select, i128 -9223372036854775808)
766 %conv6 = trunc i128 %spec.store.select7 to i64
770 define i64 @ustest_f32i64(float %x) {
771 ; CHECK-LABEL: ustest_f32i64:
772 ; CHECK: .functype ustest_f32i64 (f32) -> (i64)
773 ; CHECK-NEXT: .local i32, i64, i64
774 ; CHECK-NEXT: # %bb.0: # %entry
775 ; CHECK-NEXT: global.get __stack_pointer
776 ; CHECK-NEXT: i32.const 16
777 ; CHECK-NEXT: i32.sub
778 ; CHECK-NEXT: local.tee 1
779 ; CHECK-NEXT: global.set __stack_pointer
780 ; CHECK-NEXT: local.get 1
781 ; CHECK-NEXT: local.get 0
782 ; CHECK-NEXT: call __fixsfti
783 ; CHECK-NEXT: local.get 1
784 ; CHECK-NEXT: i32.const 8
785 ; CHECK-NEXT: i32.add
786 ; CHECK-NEXT: i64.load 0
787 ; CHECK-NEXT: local.set 2
788 ; CHECK-NEXT: local.get 1
789 ; CHECK-NEXT: i64.load 0
790 ; CHECK-NEXT: local.set 3
791 ; CHECK-NEXT: local.get 1
792 ; CHECK-NEXT: i32.const 16
793 ; CHECK-NEXT: i32.add
794 ; CHECK-NEXT: global.set __stack_pointer
795 ; CHECK-NEXT: local.get 3
796 ; CHECK-NEXT: i64.const 0
797 ; CHECK-NEXT: local.get 2
798 ; CHECK-NEXT: i64.const 1
799 ; CHECK-NEXT: i64.lt_s
800 ; CHECK-NEXT: local.tee 1
801 ; CHECK-NEXT: i64.select
802 ; CHECK-NEXT: local.tee 3
803 ; CHECK-NEXT: i64.const 0
804 ; CHECK-NEXT: local.get 3
805 ; CHECK-NEXT: i64.const 0
807 ; CHECK-NEXT: local.get 2
808 ; CHECK-NEXT: i64.const 1
809 ; CHECK-NEXT: local.get 1
810 ; CHECK-NEXT: i64.select
811 ; CHECK-NEXT: local.tee 2
812 ; CHECK-NEXT: i64.const 0
813 ; CHECK-NEXT: i64.gt_s
814 ; CHECK-NEXT: local.get 2
815 ; CHECK-NEXT: i64.eqz
816 ; CHECK-NEXT: i32.select
817 ; CHECK-NEXT: i64.select
818 ; CHECK-NEXT: # fallthrough-return
820 %conv = fptosi float %x to i128
821 %0 = icmp slt i128 %conv, 18446744073709551616
822 %spec.store.select = select i1 %0, i128 %conv, i128 18446744073709551616
823 %1 = icmp sgt i128 %spec.store.select, 0
824 %spec.store.select7 = select i1 %1, i128 %spec.store.select, i128 0
825 %conv6 = trunc i128 %spec.store.select7 to i64
829 define i64 @ustest_f32i64_cse_combine(float %x) #0 {
830 ; CHECK-LABEL: ustest_f32i64_cse_combine:
831 ; CHECK: .functype ustest_f32i64_cse_combine (f32) -> (i64)
832 ; CHECK-NEXT: .local i32, i64, i64
833 ; CHECK-NEXT: # %bb.0: # %entry
834 ; CHECK-NEXT: global.get __stack_pointer
835 ; CHECK-NEXT: i32.const 16
836 ; CHECK-NEXT: i32.sub
837 ; CHECK-NEXT: local.tee 1
838 ; CHECK-NEXT: global.set __stack_pointer
839 ; CHECK-NEXT: local.get 1
840 ; CHECK-NEXT: local.get 0
841 ; CHECK-NEXT: call __fixsfti
842 ; CHECK-NEXT: local.get 1
843 ; CHECK-NEXT: i32.const 8
844 ; CHECK-NEXT: i32.add
845 ; CHECK-NEXT: i64.load 0
846 ; CHECK-NEXT: local.set 2
847 ; CHECK-NEXT: local.get 1
848 ; CHECK-NEXT: i64.load 0
849 ; CHECK-NEXT: local.set 3
850 ; CHECK-NEXT: local.get 1
851 ; CHECK-NEXT: i32.const 16
852 ; CHECK-NEXT: i32.add
853 ; CHECK-NEXT: global.set __stack_pointer
854 ; CHECK-NEXT: i64.const 0
855 ; CHECK-NEXT: local.get 3
856 ; CHECK-NEXT: i64.const 0
857 ; CHECK-NEXT: local.get 2
858 ; CHECK-NEXT: i64.const 1
859 ; CHECK-NEXT: i64.lt_s
860 ; CHECK-NEXT: local.tee 1
861 ; CHECK-NEXT: i64.select
862 ; CHECK-NEXT: local.get 2
863 ; CHECK-NEXT: i64.const 1
864 ; CHECK-NEXT: local.get 1
865 ; CHECK-NEXT: i64.select
866 ; CHECK-NEXT: i64.const 0
867 ; CHECK-NEXT: i64.lt_s
868 ; CHECK-NEXT: i64.select
869 ; CHECK-NEXT: # fallthrough-return
871 %conv = fptosi float %x to i128
872 %spec.store.select = call i128 @llvm.smin.i128(i128 %conv, i128 18446744073709551616)
873 %spec.store.select7 = call i128 @llvm.smax.i128(i128 %spec.store.select, i128 0)
874 %conv6 = trunc i128 %spec.store.select7 to i64
878 define i64 @stest_f16i64(half %x) {
879 ; CHECK-LABEL: stest_f16i64:
880 ; CHECK: .functype stest_f16i64 (f32) -> (i64)
881 ; CHECK-NEXT: # %bb.0: # %entry
882 ; CHECK-NEXT: local.get 0
883 ; CHECK-NEXT: call __truncsfhf2
884 ; CHECK-NEXT: call __extendhfsf2
885 ; CHECK-NEXT: i64.trunc_sat_f32_s
886 ; CHECK-NEXT: # fallthrough-return
888 %conv = fptosi half %x to i128
889 %0 = icmp slt i128 %conv, 9223372036854775807
890 %spec.store.select = select i1 %0, i128 %conv, i128 9223372036854775807
891 %1 = icmp sgt i128 %spec.store.select, -9223372036854775808
892 %spec.store.select7 = select i1 %1, i128 %spec.store.select, i128 -9223372036854775808
893 %conv6 = trunc i128 %spec.store.select7 to i64
897 define i64 @utesth_f16i64(half %x) {
898 ; CHECK-LABEL: utesth_f16i64:
899 ; CHECK: .functype utesth_f16i64 (f32) -> (i64)
900 ; CHECK-NEXT: .local i32, i64, i64
901 ; CHECK-NEXT: # %bb.0: # %entry
902 ; CHECK-NEXT: global.get __stack_pointer
903 ; CHECK-NEXT: i32.const 16
904 ; CHECK-NEXT: i32.sub
905 ; CHECK-NEXT: local.tee 1
906 ; CHECK-NEXT: global.set __stack_pointer
907 ; CHECK-NEXT: local.get 1
908 ; CHECK-NEXT: local.get 0
909 ; CHECK-NEXT: call __truncsfhf2
910 ; CHECK-NEXT: call __extendhfsf2
911 ; CHECK-NEXT: call __fixunssfti
912 ; CHECK-NEXT: local.get 1
913 ; CHECK-NEXT: i32.const 8
914 ; CHECK-NEXT: i32.add
915 ; CHECK-NEXT: i64.load 0
916 ; CHECK-NEXT: local.set 2
917 ; CHECK-NEXT: local.get 1
918 ; CHECK-NEXT: i64.load 0
919 ; CHECK-NEXT: local.set 3
920 ; CHECK-NEXT: local.get 1
921 ; CHECK-NEXT: i32.const 16
922 ; CHECK-NEXT: i32.add
923 ; CHECK-NEXT: global.set __stack_pointer
924 ; CHECK-NEXT: local.get 3
925 ; CHECK-NEXT: i64.const 0
926 ; CHECK-NEXT: local.get 2
927 ; CHECK-NEXT: i64.eqz
928 ; CHECK-NEXT: i64.select
929 ; CHECK-NEXT: # fallthrough-return
931 %conv = fptoui half %x to i128
932 %0 = icmp ult i128 %conv, 18446744073709551616
933 %spec.store.select = select i1 %0, i128 %conv, i128 18446744073709551616
934 %conv6 = trunc i128 %spec.store.select to i64
938 define i64 @utesth_f16i64_cse(half %x) {
939 ; CHECK-LABEL: utesth_f16i64_cse:
940 ; CHECK: .functype utesth_f16i64_cse (f32) -> (i64)
941 ; CHECK-NEXT: .local i32, i64
942 ; CHECK-NEXT: # %bb.0: # %entry
943 ; CHECK-NEXT: global.get __stack_pointer
944 ; CHECK-NEXT: i32.const 16
945 ; CHECK-NEXT: i32.sub
946 ; CHECK-NEXT: local.tee 1
947 ; CHECK-NEXT: global.set __stack_pointer
948 ; CHECK-NEXT: local.get 1
949 ; CHECK-NEXT: local.get 0
950 ; CHECK-NEXT: call __truncsfhf2
951 ; CHECK-NEXT: call __extendhfsf2
952 ; CHECK-NEXT: call __fixunssfti
953 ; CHECK-NEXT: local.get 1
954 ; CHECK-NEXT: i64.load 0
955 ; CHECK-NEXT: local.set 2
956 ; CHECK-NEXT: local.get 1
957 ; CHECK-NEXT: i32.const 16
958 ; CHECK-NEXT: i32.add
959 ; CHECK-NEXT: global.set __stack_pointer
960 ; CHECK-NEXT: local.get 2
961 ; CHECK-NEXT: # fallthrough-return
963 %conv = fptoui half %x to i128
964 %conv6 = trunc i128 %conv to i64
968 define i64 @ustest_f16i64(half %x) {
969 ; CHECK-LABEL: ustest_f16i64:
970 ; CHECK: .functype ustest_f16i64 (f32) -> (i64)
971 ; CHECK-NEXT: .local i32, i64, i64
972 ; CHECK-NEXT: # %bb.0: # %entry
973 ; CHECK-NEXT: global.get __stack_pointer
974 ; CHECK-NEXT: i32.const 16
975 ; CHECK-NEXT: i32.sub
976 ; CHECK-NEXT: local.tee 1
977 ; CHECK-NEXT: global.set __stack_pointer
978 ; CHECK-NEXT: local.get 1
979 ; CHECK-NEXT: local.get 0
980 ; CHECK-NEXT: call __truncsfhf2
981 ; CHECK-NEXT: call __extendhfsf2
982 ; CHECK-NEXT: call __fixsfti
983 ; CHECK-NEXT: local.get 1
984 ; CHECK-NEXT: i32.const 8
985 ; CHECK-NEXT: i32.add
986 ; CHECK-NEXT: i64.load 0
987 ; CHECK-NEXT: local.set 2
988 ; CHECK-NEXT: local.get 1
989 ; CHECK-NEXT: i64.load 0
990 ; CHECK-NEXT: local.set 3
991 ; CHECK-NEXT: local.get 1
992 ; CHECK-NEXT: i32.const 16
993 ; CHECK-NEXT: i32.add
994 ; CHECK-NEXT: global.set __stack_pointer
995 ; CHECK-NEXT: local.get 3
996 ; CHECK-NEXT: i64.const 0
997 ; CHECK-NEXT: local.get 2
998 ; CHECK-NEXT: i64.const 1
999 ; CHECK-NEXT: i64.lt_s
1000 ; CHECK-NEXT: local.tee 1
1001 ; CHECK-NEXT: i64.select
1002 ; CHECK-NEXT: local.tee 3
1003 ; CHECK-NEXT: i64.const 0
1004 ; CHECK-NEXT: local.get 3
1005 ; CHECK-NEXT: i64.const 0
1006 ; CHECK-NEXT: i64.ne
1007 ; CHECK-NEXT: local.get 2
1008 ; CHECK-NEXT: i64.const 1
1009 ; CHECK-NEXT: local.get 1
1010 ; CHECK-NEXT: i64.select
1011 ; CHECK-NEXT: local.tee 2
1012 ; CHECK-NEXT: i64.const 0
1013 ; CHECK-NEXT: i64.gt_s
1014 ; CHECK-NEXT: local.get 2
1015 ; CHECK-NEXT: i64.eqz
1016 ; CHECK-NEXT: i32.select
1017 ; CHECK-NEXT: i64.select
1018 ; CHECK-NEXT: # fallthrough-return
1020 %conv = fptosi half %x to i128
1021 %0 = icmp slt i128 %conv, 18446744073709551616
1022 %spec.store.select = select i1 %0, i128 %conv, i128 18446744073709551616
1023 %1 = icmp sgt i128 %spec.store.select, 0
1024 %spec.store.select7 = select i1 %1, i128 %spec.store.select, i128 0
1025 %conv6 = trunc i128 %spec.store.select7 to i64
1034 define i32 @stest_f64i32_mm(double %x) {
1035 ; CHECK-LABEL: stest_f64i32_mm:
1036 ; CHECK: .functype stest_f64i32_mm (f64) -> (i32)
1037 ; CHECK-NEXT: # %bb.0: # %entry
1038 ; CHECK-NEXT: local.get 0
1039 ; CHECK-NEXT: i32.trunc_sat_f64_s
1040 ; CHECK-NEXT: # fallthrough-return
1042 %conv = fptosi double %x to i64
1043 %spec.store.select = call i64 @llvm.smin.i64(i64 %conv, i64 2147483647)
1044 %spec.store.select7 = call i64 @llvm.smax.i64(i64 %spec.store.select, i64 -2147483648)
1045 %conv6 = trunc i64 %spec.store.select7 to i32
1049 define i32 @utest_f64i32_mm(double %x) {
1050 ; CHECK-LABEL: utest_f64i32_mm:
1051 ; CHECK: .functype utest_f64i32_mm (f64) -> (i32)
1052 ; CHECK-NEXT: # %bb.0: # %entry
1053 ; CHECK-NEXT: local.get 0
1054 ; CHECK-NEXT: i32.trunc_sat_f64_u
1055 ; CHECK-NEXT: # fallthrough-return
1057 %conv = fptoui double %x to i64
1058 %spec.store.select = call i64 @llvm.umin.i64(i64 %conv, i64 4294967295)
1059 %conv6 = trunc i64 %spec.store.select to i32
1063 define i32 @ustest_f64i32_mm(double %x) {
1064 ; CHECK-LABEL: ustest_f64i32_mm:
1065 ; CHECK: .functype ustest_f64i32_mm (f64) -> (i32)
1066 ; CHECK-NEXT: # %bb.0: # %entry
1067 ; CHECK-NEXT: local.get 0
1068 ; CHECK-NEXT: i32.trunc_sat_f64_u
1069 ; CHECK-NEXT: # fallthrough-return
1071 %conv = fptosi double %x to i64
1072 %spec.store.select = call i64 @llvm.smin.i64(i64 %conv, i64 4294967295)
1073 %spec.store.select7 = call i64 @llvm.smax.i64(i64 %spec.store.select, i64 0)
1074 %conv6 = trunc i64 %spec.store.select7 to i32
1078 define i32 @stest_f32i32_mm(float %x) {
1079 ; CHECK-LABEL: stest_f32i32_mm:
1080 ; CHECK: .functype stest_f32i32_mm (f32) -> (i32)
1081 ; CHECK-NEXT: # %bb.0: # %entry
1082 ; CHECK-NEXT: local.get 0
1083 ; CHECK-NEXT: i32.trunc_sat_f32_s
1084 ; CHECK-NEXT: # fallthrough-return
1086 %conv = fptosi float %x to i64
1087 %spec.store.select = call i64 @llvm.smin.i64(i64 %conv, i64 2147483647)
1088 %spec.store.select7 = call i64 @llvm.smax.i64(i64 %spec.store.select, i64 -2147483648)
1089 %conv6 = trunc i64 %spec.store.select7 to i32
1093 define i32 @utest_f32i32_mm(float %x) {
1094 ; CHECK-LABEL: utest_f32i32_mm:
1095 ; CHECK: .functype utest_f32i32_mm (f32) -> (i32)
1096 ; CHECK-NEXT: # %bb.0: # %entry
1097 ; CHECK-NEXT: local.get 0
1098 ; CHECK-NEXT: i32.trunc_sat_f32_u
1099 ; CHECK-NEXT: # fallthrough-return
1101 %conv = fptoui float %x to i64
1102 %spec.store.select = call i64 @llvm.umin.i64(i64 %conv, i64 4294967295)
1103 %conv6 = trunc i64 %spec.store.select to i32
1107 define i32 @ustest_f32i32_mm(float %x) {
1108 ; CHECK-LABEL: ustest_f32i32_mm:
1109 ; CHECK: .functype ustest_f32i32_mm (f32) -> (i32)
1110 ; CHECK-NEXT: # %bb.0: # %entry
1111 ; CHECK-NEXT: local.get 0
1112 ; CHECK-NEXT: i32.trunc_sat_f32_u
1113 ; CHECK-NEXT: # fallthrough-return
1115 %conv = fptosi float %x to i64
1116 %spec.store.select = call i64 @llvm.smin.i64(i64 %conv, i64 4294967295)
1117 %spec.store.select7 = call i64 @llvm.smax.i64(i64 %spec.store.select, i64 0)
1118 %conv6 = trunc i64 %spec.store.select7 to i32
1122 define i32 @stest_f16i32_mm(half %x) {
1123 ; CHECK-LABEL: stest_f16i32_mm:
1124 ; CHECK: .functype stest_f16i32_mm (f32) -> (i32)
1125 ; CHECK-NEXT: # %bb.0: # %entry
1126 ; CHECK-NEXT: local.get 0
1127 ; CHECK-NEXT: call __truncsfhf2
1128 ; CHECK-NEXT: call __extendhfsf2
1129 ; CHECK-NEXT: i32.trunc_sat_f32_s
1130 ; CHECK-NEXT: # fallthrough-return
1132 %conv = fptosi half %x to i64
1133 %spec.store.select = call i64 @llvm.smin.i64(i64 %conv, i64 2147483647)
1134 %spec.store.select7 = call i64 @llvm.smax.i64(i64 %spec.store.select, i64 -2147483648)
1135 %conv6 = trunc i64 %spec.store.select7 to i32
1139 define i32 @utesth_f16i32_mm(half %x) {
1140 ; CHECK-LABEL: utesth_f16i32_mm:
1141 ; CHECK: .functype utesth_f16i32_mm (f32) -> (i32)
1142 ; CHECK-NEXT: # %bb.0: # %entry
1143 ; CHECK-NEXT: local.get 0
1144 ; CHECK-NEXT: call __truncsfhf2
1145 ; CHECK-NEXT: call __extendhfsf2
1146 ; CHECK-NEXT: i32.trunc_sat_f32_u
1147 ; CHECK-NEXT: # fallthrough-return
1149 %conv = fptoui half %x to i64
1150 %spec.store.select = call i64 @llvm.umin.i64(i64 %conv, i64 4294967295)
1151 %conv6 = trunc i64 %spec.store.select to i32
1155 define i32 @ustest_f16i32_mm(half %x) {
1156 ; CHECK-LABEL: ustest_f16i32_mm:
1157 ; CHECK: .functype ustest_f16i32_mm (f32) -> (i32)
1158 ; CHECK-NEXT: # %bb.0: # %entry
1159 ; CHECK-NEXT: local.get 0
1160 ; CHECK-NEXT: call __truncsfhf2
1161 ; CHECK-NEXT: call __extendhfsf2
1162 ; CHECK-NEXT: i32.trunc_sat_f32_u
1163 ; CHECK-NEXT: # fallthrough-return
1165 %conv = fptosi half %x to i64
1166 %spec.store.select = call i64 @llvm.smin.i64(i64 %conv, i64 4294967295)
1167 %spec.store.select7 = call i64 @llvm.smax.i64(i64 %spec.store.select, i64 0)
1168 %conv6 = trunc i64 %spec.store.select7 to i32
1172 define i32 @ustest_f16i32_mm_cse(half %x) {
1173 ; CHECK-LABEL: ustest_f16i32_mm_cse:
1174 ; CHECK: .functype ustest_f16i32_mm_cse (f32) -> (i32)
1175 ; CHECK-NEXT: # %bb.0: # %entry
1176 ; CHECK-NEXT: local.get 0
1177 ; CHECK-NEXT: call __truncsfhf2
1178 ; CHECK-NEXT: call __extendhfsf2
1179 ; CHECK-NEXT: i32.trunc_sat_f32_u
1180 ; CHECK-NEXT: # fallthrough-return
1182 %conv = fptosi half %x to i64
1183 %spec.store.select7 = call i64 @llvm.smax.i64(i64 %conv, i64 0)
1184 %conv6 = trunc i64 %spec.store.select7 to i32
1190 define i16 @stest_f64i16_mm(double %x) {
1191 ; CHECK-LABEL: stest_f64i16_mm:
1192 ; CHECK: .functype stest_f64i16_mm (f64) -> (i32)
1193 ; CHECK-NEXT: .local i32
1194 ; CHECK-NEXT: # %bb.0: # %entry
1195 ; CHECK-NEXT: local.get 0
1196 ; CHECK-NEXT: i32.trunc_sat_f64_s
1197 ; CHECK-NEXT: local.tee 1
1198 ; CHECK-NEXT: i32.const 32767
1199 ; CHECK-NEXT: local.get 1
1200 ; CHECK-NEXT: i32.const 32767
1201 ; CHECK-NEXT: i32.lt_s
1202 ; CHECK-NEXT: i32.select
1203 ; CHECK-NEXT: local.tee 1
1204 ; CHECK-NEXT: i32.const -32768
1205 ; CHECK-NEXT: local.get 1
1206 ; CHECK-NEXT: i32.const -32768
1207 ; CHECK-NEXT: i32.gt_s
1208 ; CHECK-NEXT: i32.select
1209 ; CHECK-NEXT: # fallthrough-return
1211 %conv = fptosi double %x to i32
1212 %spec.store.select = call i32 @llvm.smin.i32(i32 %conv, i32 32767)
1213 %spec.store.select7 = call i32 @llvm.smax.i32(i32 %spec.store.select, i32 -32768)
1214 %conv6 = trunc i32 %spec.store.select7 to i16
1218 define i16 @utest_f64i16_mm(double %x) {
1219 ; CHECK-LABEL: utest_f64i16_mm:
1220 ; CHECK: .functype utest_f64i16_mm (f64) -> (i32)
1221 ; CHECK-NEXT: .local i32
1222 ; CHECK-NEXT: # %bb.0: # %entry
1223 ; CHECK-NEXT: local.get 0
1224 ; CHECK-NEXT: i32.trunc_sat_f64_u
1225 ; CHECK-NEXT: local.tee 1
1226 ; CHECK-NEXT: i32.const 65535
1227 ; CHECK-NEXT: local.get 1
1228 ; CHECK-NEXT: i32.const 65535
1229 ; CHECK-NEXT: i32.lt_u
1230 ; CHECK-NEXT: i32.select
1231 ; CHECK-NEXT: # fallthrough-return
1233 %conv = fptoui double %x to i32
1234 %spec.store.select = call i32 @llvm.umin.i32(i32 %conv, i32 65535)
1235 %conv6 = trunc i32 %spec.store.select to i16
1239 define i16 @ustest_f64i16_mm(double %x) {
1240 ; CHECK-LABEL: ustest_f64i16_mm:
1241 ; CHECK: .functype ustest_f64i16_mm (f64) -> (i32)
1242 ; CHECK-NEXT: .local i32
1243 ; CHECK-NEXT: # %bb.0: # %entry
1244 ; CHECK-NEXT: local.get 0
1245 ; CHECK-NEXT: i32.trunc_sat_f64_s
1246 ; CHECK-NEXT: local.tee 1
1247 ; CHECK-NEXT: i32.const 65535
1248 ; CHECK-NEXT: local.get 1
1249 ; CHECK-NEXT: i32.const 65535
1250 ; CHECK-NEXT: i32.lt_s
1251 ; CHECK-NEXT: i32.select
1252 ; CHECK-NEXT: local.tee 1
1253 ; CHECK-NEXT: i32.const 0
1254 ; CHECK-NEXT: local.get 1
1255 ; CHECK-NEXT: i32.const 0
1256 ; CHECK-NEXT: i32.gt_s
1257 ; CHECK-NEXT: i32.select
1258 ; CHECK-NEXT: # fallthrough-return
1260 %conv = fptosi double %x to i32
1261 %spec.store.select = call i32 @llvm.smin.i32(i32 %conv, i32 65535)
1262 %spec.store.select7 = call i32 @llvm.smax.i32(i32 %spec.store.select, i32 0)
1263 %conv6 = trunc i32 %spec.store.select7 to i16
1267 define i16 @stest_f32i16_mm(float %x) {
1268 ; CHECK-LABEL: stest_f32i16_mm:
1269 ; CHECK: .functype stest_f32i16_mm (f32) -> (i32)
1270 ; CHECK-NEXT: .local i32
1271 ; CHECK-NEXT: # %bb.0: # %entry
1272 ; CHECK-NEXT: local.get 0
1273 ; CHECK-NEXT: i32.trunc_sat_f32_s
1274 ; CHECK-NEXT: local.tee 1
1275 ; CHECK-NEXT: i32.const 32767
1276 ; CHECK-NEXT: local.get 1
1277 ; CHECK-NEXT: i32.const 32767
1278 ; CHECK-NEXT: i32.lt_s
1279 ; CHECK-NEXT: i32.select
1280 ; CHECK-NEXT: local.tee 1
1281 ; CHECK-NEXT: i32.const -32768
1282 ; CHECK-NEXT: local.get 1
1283 ; CHECK-NEXT: i32.const -32768
1284 ; CHECK-NEXT: i32.gt_s
1285 ; CHECK-NEXT: i32.select
1286 ; CHECK-NEXT: # fallthrough-return
1288 %conv = fptosi float %x to i32
1289 %spec.store.select = call i32 @llvm.smin.i32(i32 %conv, i32 32767)
1290 %spec.store.select7 = call i32 @llvm.smax.i32(i32 %spec.store.select, i32 -32768)
1291 %conv6 = trunc i32 %spec.store.select7 to i16
1295 define i16 @utest_f32i16_mm(float %x) {
1296 ; CHECK-LABEL: utest_f32i16_mm:
1297 ; CHECK: .functype utest_f32i16_mm (f32) -> (i32)
1298 ; CHECK-NEXT: .local i32
1299 ; CHECK-NEXT: # %bb.0: # %entry
1300 ; CHECK-NEXT: local.get 0
1301 ; CHECK-NEXT: i32.trunc_sat_f32_u
1302 ; CHECK-NEXT: local.tee 1
1303 ; CHECK-NEXT: i32.const 65535
1304 ; CHECK-NEXT: local.get 1
1305 ; CHECK-NEXT: i32.const 65535
1306 ; CHECK-NEXT: i32.lt_u
1307 ; CHECK-NEXT: i32.select
1308 ; CHECK-NEXT: # fallthrough-return
1310 %conv = fptoui float %x to i32
1311 %spec.store.select = call i32 @llvm.umin.i32(i32 %conv, i32 65535)
1312 %conv6 = trunc i32 %spec.store.select to i16
1316 define i16 @ustest_f32i16_mm(float %x) {
1317 ; CHECK-LABEL: ustest_f32i16_mm:
1318 ; CHECK: .functype ustest_f32i16_mm (f32) -> (i32)
1319 ; CHECK-NEXT: .local i32
1320 ; CHECK-NEXT: # %bb.0: # %entry
1321 ; CHECK-NEXT: local.get 0
1322 ; CHECK-NEXT: i32.trunc_sat_f32_s
1323 ; CHECK-NEXT: local.tee 1
1324 ; CHECK-NEXT: i32.const 65535
1325 ; CHECK-NEXT: local.get 1
1326 ; CHECK-NEXT: i32.const 65535
1327 ; CHECK-NEXT: i32.lt_s
1328 ; CHECK-NEXT: i32.select
1329 ; CHECK-NEXT: local.tee 1
1330 ; CHECK-NEXT: i32.const 0
1331 ; CHECK-NEXT: local.get 1
1332 ; CHECK-NEXT: i32.const 0
1333 ; CHECK-NEXT: i32.gt_s
1334 ; CHECK-NEXT: i32.select
1335 ; CHECK-NEXT: # fallthrough-return
1337 %conv = fptosi float %x to i32
1338 %spec.store.select = call i32 @llvm.smin.i32(i32 %conv, i32 65535)
1339 %spec.store.select7 = call i32 @llvm.smax.i32(i32 %spec.store.select, i32 0)
1340 %conv6 = trunc i32 %spec.store.select7 to i16
1344 define i16 @stest_f16i16_mm(half %x) {
1345 ; CHECK-LABEL: stest_f16i16_mm:
1346 ; CHECK: .functype stest_f16i16_mm (f32) -> (i32)
1347 ; CHECK-NEXT: .local i32
1348 ; CHECK-NEXT: # %bb.0: # %entry
1349 ; CHECK-NEXT: local.get 0
1350 ; CHECK-NEXT: call __truncsfhf2
1351 ; CHECK-NEXT: call __extendhfsf2
1352 ; CHECK-NEXT: i32.trunc_sat_f32_s
1353 ; CHECK-NEXT: local.tee 1
1354 ; CHECK-NEXT: i32.const 32767
1355 ; CHECK-NEXT: local.get 1
1356 ; CHECK-NEXT: i32.const 32767
1357 ; CHECK-NEXT: i32.lt_s
1358 ; CHECK-NEXT: i32.select
1359 ; CHECK-NEXT: local.tee 1
1360 ; CHECK-NEXT: i32.const -32768
1361 ; CHECK-NEXT: local.get 1
1362 ; CHECK-NEXT: i32.const -32768
1363 ; CHECK-NEXT: i32.gt_s
1364 ; CHECK-NEXT: i32.select
1365 ; CHECK-NEXT: # fallthrough-return
1367 %conv = fptosi half %x to i32
1368 %spec.store.select = call i32 @llvm.smin.i32(i32 %conv, i32 32767)
1369 %spec.store.select7 = call i32 @llvm.smax.i32(i32 %spec.store.select, i32 -32768)
1370 %conv6 = trunc i32 %spec.store.select7 to i16
1374 define i16 @utesth_f16i16_mm(half %x) {
1375 ; CHECK-LABEL: utesth_f16i16_mm:
1376 ; CHECK: .functype utesth_f16i16_mm (f32) -> (i32)
1377 ; CHECK-NEXT: .local i32
1378 ; CHECK-NEXT: # %bb.0: # %entry
1379 ; CHECK-NEXT: local.get 0
1380 ; CHECK-NEXT: call __truncsfhf2
1381 ; CHECK-NEXT: call __extendhfsf2
1382 ; CHECK-NEXT: i32.trunc_sat_f32_u
1383 ; CHECK-NEXT: local.tee 1
1384 ; CHECK-NEXT: i32.const 65535
1385 ; CHECK-NEXT: local.get 1
1386 ; CHECK-NEXT: i32.const 65535
1387 ; CHECK-NEXT: i32.lt_u
1388 ; CHECK-NEXT: i32.select
1389 ; CHECK-NEXT: # fallthrough-return
1391 %conv = fptoui half %x to i32
1392 %spec.store.select = call i32 @llvm.umin.i32(i32 %conv, i32 65535)
1393 %conv6 = trunc i32 %spec.store.select to i16
1397 define i16 @ustest_f16i16_mm(half %x) {
1398 ; CHECK-LABEL: ustest_f16i16_mm:
1399 ; CHECK: .functype ustest_f16i16_mm (f32) -> (i32)
1400 ; CHECK-NEXT: .local i32
1401 ; CHECK-NEXT: # %bb.0: # %entry
1402 ; CHECK-NEXT: local.get 0
1403 ; CHECK-NEXT: call __truncsfhf2
1404 ; CHECK-NEXT: call __extendhfsf2
1405 ; CHECK-NEXT: i32.trunc_sat_f32_s
1406 ; CHECK-NEXT: local.tee 1
1407 ; CHECK-NEXT: i32.const 65535
1408 ; CHECK-NEXT: local.get 1
1409 ; CHECK-NEXT: i32.const 65535
1410 ; CHECK-NEXT: i32.lt_s
1411 ; CHECK-NEXT: i32.select
1412 ; CHECK-NEXT: local.tee 1
1413 ; CHECK-NEXT: i32.const 0
1414 ; CHECK-NEXT: local.get 1
1415 ; CHECK-NEXT: i32.const 0
1416 ; CHECK-NEXT: i32.gt_s
1417 ; CHECK-NEXT: i32.select
1418 ; CHECK-NEXT: # fallthrough-return
1420 %conv = fptosi half %x to i32
1421 %spec.store.select = call i32 @llvm.smin.i32(i32 %conv, i32 65535)
1422 %spec.store.select7 = call i32 @llvm.smax.i32(i32 %spec.store.select, i32 0)
1423 %conv6 = trunc i32 %spec.store.select7 to i16
1427 define i16 @ustest_f16i16_mm_cse(half %x) {
1428 ; CHECK-LABEL: ustest_f16i16_mm_cse:
1429 ; CHECK: .functype ustest_f16i16_mm_cse (f32) -> (i32)
1430 ; CHECK-NEXT: # %bb.0: # %entry
1431 ; CHECK-NEXT: local.get 0
1432 ; CHECK-NEXT: call __truncsfhf2
1433 ; CHECK-NEXT: call __extendhfsf2
1434 ; CHECK-NEXT: i32.trunc_sat_f32_u
1435 ; CHECK-NEXT: # fallthrough-return
1437 %conv = fptosi half %x to i32
1438 %spec.store.select7 = call i32 @llvm.smax.i32(i32 %conv, i32 0)
1439 %conv6 = trunc i32 %spec.store.select7 to i16
1445 define i64 @stest_f64i64_mm(double %x) {
1446 ; CHECK-LABEL: stest_f64i64_mm:
1447 ; CHECK: .functype stest_f64i64_mm (f64) -> (i64)
1448 ; CHECK-NEXT: # %bb.0: # %entry
1449 ; CHECK-NEXT: local.get 0
1450 ; CHECK-NEXT: i64.trunc_sat_f64_s
1451 ; CHECK-NEXT: # fallthrough-return
1453 %conv = fptosi double %x to i128
1454 %spec.store.select = call i128 @llvm.smin.i128(i128 %conv, i128 9223372036854775807)
1455 %spec.store.select7 = call i128 @llvm.smax.i128(i128 %spec.store.select, i128 -9223372036854775808)
1456 %conv6 = trunc i128 %spec.store.select7 to i64
1460 define i64 @utest_f64i64_mm(double %x) {
1461 ; CHECK-LABEL: utest_f64i64_mm:
1462 ; CHECK: .functype utest_f64i64_mm (f64) -> (i64)
1463 ; CHECK-NEXT: .local i32, i64, i64
1464 ; CHECK-NEXT: # %bb.0: # %entry
1465 ; CHECK-NEXT: global.get __stack_pointer
1466 ; CHECK-NEXT: i32.const 16
1467 ; CHECK-NEXT: i32.sub
1468 ; CHECK-NEXT: local.tee 1
1469 ; CHECK-NEXT: global.set __stack_pointer
1470 ; CHECK-NEXT: local.get 1
1471 ; CHECK-NEXT: local.get 0
1472 ; CHECK-NEXT: call __fixunsdfti
1473 ; CHECK-NEXT: local.get 1
1474 ; CHECK-NEXT: i32.const 8
1475 ; CHECK-NEXT: i32.add
1476 ; CHECK-NEXT: i64.load 0
1477 ; CHECK-NEXT: local.set 2
1478 ; CHECK-NEXT: local.get 1
1479 ; CHECK-NEXT: i64.load 0
1480 ; CHECK-NEXT: local.set 3
1481 ; CHECK-NEXT: local.get 1
1482 ; CHECK-NEXT: i32.const 16
1483 ; CHECK-NEXT: i32.add
1484 ; CHECK-NEXT: global.set __stack_pointer
1485 ; CHECK-NEXT: local.get 3
1486 ; CHECK-NEXT: i64.const 0
1487 ; CHECK-NEXT: local.get 2
1488 ; CHECK-NEXT: i64.eqz
1489 ; CHECK-NEXT: i64.select
1490 ; CHECK-NEXT: # fallthrough-return
1492 %conv = fptoui double %x to i128
1493 %spec.store.select = call i128 @llvm.umin.i128(i128 %conv, i128 18446744073709551616)
1494 %conv6 = trunc i128 %spec.store.select to i64
1498 define i64 @ustest_f64i64_mm(double %x) {
1499 ; CHECK-LABEL: ustest_f64i64_mm:
1500 ; CHECK: .functype ustest_f64i64_mm (f64) -> (i64)
1501 ; CHECK-NEXT: .local i32, i64, i64
1502 ; CHECK-NEXT: # %bb.0: # %entry
1503 ; CHECK-NEXT: global.get __stack_pointer
1504 ; CHECK-NEXT: i32.const 16
1505 ; CHECK-NEXT: i32.sub
1506 ; CHECK-NEXT: local.tee 1
1507 ; CHECK-NEXT: global.set __stack_pointer
1508 ; CHECK-NEXT: local.get 1
1509 ; CHECK-NEXT: local.get 0
1510 ; CHECK-NEXT: call __fixdfti
1511 ; CHECK-NEXT: local.get 1
1512 ; CHECK-NEXT: i32.const 8
1513 ; CHECK-NEXT: i32.add
1514 ; CHECK-NEXT: i64.load 0
1515 ; CHECK-NEXT: local.set 2
1516 ; CHECK-NEXT: local.get 1
1517 ; CHECK-NEXT: i64.load 0
1518 ; CHECK-NEXT: local.set 3
1519 ; CHECK-NEXT: local.get 1
1520 ; CHECK-NEXT: i32.const 16
1521 ; CHECK-NEXT: i32.add
1522 ; CHECK-NEXT: global.set __stack_pointer
1523 ; CHECK-NEXT: i64.const 0
1524 ; CHECK-NEXT: local.get 3
1525 ; CHECK-NEXT: i64.const 0
1526 ; CHECK-NEXT: local.get 2
1527 ; CHECK-NEXT: i64.const 1
1528 ; CHECK-NEXT: i64.lt_s
1529 ; CHECK-NEXT: local.tee 1
1530 ; CHECK-NEXT: i64.select
1531 ; CHECK-NEXT: local.get 2
1532 ; CHECK-NEXT: i64.const 1
1533 ; CHECK-NEXT: local.get 1
1534 ; CHECK-NEXT: i64.select
1535 ; CHECK-NEXT: i64.const 0
1536 ; CHECK-NEXT: i64.lt_s
1537 ; CHECK-NEXT: i64.select
1538 ; CHECK-NEXT: # fallthrough-return
1540 %conv = fptosi double %x to i128
1541 %spec.store.select = call i128 @llvm.smin.i128(i128 %conv, i128 18446744073709551616)
1542 %spec.store.select7 = call i128 @llvm.smax.i128(i128 %spec.store.select, i128 0)
1543 %conv6 = trunc i128 %spec.store.select7 to i64
1547 define i64 @stest_f32i64_mm(float %x) {
1548 ; CHECK-LABEL: stest_f32i64_mm:
1549 ; CHECK: .functype stest_f32i64_mm (f32) -> (i64)
1550 ; CHECK-NEXT: # %bb.0: # %entry
1551 ; CHECK-NEXT: local.get 0
1552 ; CHECK-NEXT: i64.trunc_sat_f32_s
1553 ; CHECK-NEXT: # fallthrough-return
1555 %conv = fptosi float %x to i128
1556 %spec.store.select = call i128 @llvm.smin.i128(i128 %conv, i128 9223372036854775807)
1557 %spec.store.select7 = call i128 @llvm.smax.i128(i128 %spec.store.select, i128 -9223372036854775808)
1558 %conv6 = trunc i128 %spec.store.select7 to i64
1562 define i64 @utest_f32i64_mm(float %x) {
1563 ; CHECK-LABEL: utest_f32i64_mm:
1564 ; CHECK: .functype utest_f32i64_mm (f32) -> (i64)
1565 ; CHECK-NEXT: .local i32, i64, i64
1566 ; CHECK-NEXT: # %bb.0: # %entry
1567 ; CHECK-NEXT: global.get __stack_pointer
1568 ; CHECK-NEXT: i32.const 16
1569 ; CHECK-NEXT: i32.sub
1570 ; CHECK-NEXT: local.tee 1
1571 ; CHECK-NEXT: global.set __stack_pointer
1572 ; CHECK-NEXT: local.get 1
1573 ; CHECK-NEXT: local.get 0
1574 ; CHECK-NEXT: call __fixunssfti
1575 ; CHECK-NEXT: local.get 1
1576 ; CHECK-NEXT: i32.const 8
1577 ; CHECK-NEXT: i32.add
1578 ; CHECK-NEXT: i64.load 0
1579 ; CHECK-NEXT: local.set 2
1580 ; CHECK-NEXT: local.get 1
1581 ; CHECK-NEXT: i64.load 0
1582 ; CHECK-NEXT: local.set 3
1583 ; CHECK-NEXT: local.get 1
1584 ; CHECK-NEXT: i32.const 16
1585 ; CHECK-NEXT: i32.add
1586 ; CHECK-NEXT: global.set __stack_pointer
1587 ; CHECK-NEXT: local.get 3
1588 ; CHECK-NEXT: i64.const 0
1589 ; CHECK-NEXT: local.get 2
1590 ; CHECK-NEXT: i64.eqz
1591 ; CHECK-NEXT: i64.select
1592 ; CHECK-NEXT: # fallthrough-return
1594 %conv = fptoui float %x to i128
1595 %spec.store.select = call i128 @llvm.umin.i128(i128 %conv, i128 18446744073709551616)
1596 %conv6 = trunc i128 %spec.store.select to i64
1600 define i64 @ustest_f32i64_mm(float %x) {
1601 ; CHECK-LABEL: ustest_f32i64_mm:
1602 ; CHECK: .functype ustest_f32i64_mm (f32) -> (i64)
1603 ; CHECK-NEXT: .local i32, i64, i64
1604 ; CHECK-NEXT: # %bb.0: # %entry
1605 ; CHECK-NEXT: global.get __stack_pointer
1606 ; CHECK-NEXT: i32.const 16
1607 ; CHECK-NEXT: i32.sub
1608 ; CHECK-NEXT: local.tee 1
1609 ; CHECK-NEXT: global.set __stack_pointer
1610 ; CHECK-NEXT: local.get 1
1611 ; CHECK-NEXT: local.get 0
1612 ; CHECK-NEXT: call __fixsfti
1613 ; CHECK-NEXT: local.get 1
1614 ; CHECK-NEXT: i32.const 8
1615 ; CHECK-NEXT: i32.add
1616 ; CHECK-NEXT: i64.load 0
1617 ; CHECK-NEXT: local.set 2
1618 ; CHECK-NEXT: local.get 1
1619 ; CHECK-NEXT: i64.load 0
1620 ; CHECK-NEXT: local.set 3
1621 ; CHECK-NEXT: local.get 1
1622 ; CHECK-NEXT: i32.const 16
1623 ; CHECK-NEXT: i32.add
1624 ; CHECK-NEXT: global.set __stack_pointer
1625 ; CHECK-NEXT: i64.const 0
1626 ; CHECK-NEXT: local.get 3
1627 ; CHECK-NEXT: i64.const 0
1628 ; CHECK-NEXT: local.get 2
1629 ; CHECK-NEXT: i64.const 1
1630 ; CHECK-NEXT: i64.lt_s
1631 ; CHECK-NEXT: local.tee 1
1632 ; CHECK-NEXT: i64.select
1633 ; CHECK-NEXT: local.get 2
1634 ; CHECK-NEXT: i64.const 1
1635 ; CHECK-NEXT: local.get 1
1636 ; CHECK-NEXT: i64.select
1637 ; CHECK-NEXT: i64.const 0
1638 ; CHECK-NEXT: i64.lt_s
1639 ; CHECK-NEXT: i64.select
1640 ; CHECK-NEXT: # fallthrough-return
1642 %conv = fptosi float %x to i128
1643 %spec.store.select = call i128 @llvm.smin.i128(i128 %conv, i128 18446744073709551616)
1644 %spec.store.select7 = call i128 @llvm.smax.i128(i128 %spec.store.select, i128 0)
1645 %conv6 = trunc i128 %spec.store.select7 to i64
1649 define i64 @stest_f16i64_mm(half %x) {
1650 ; CHECK-LABEL: stest_f16i64_mm:
1651 ; CHECK: .functype stest_f16i64_mm (f32) -> (i64)
1652 ; CHECK-NEXT: # %bb.0: # %entry
1653 ; CHECK-NEXT: local.get 0
1654 ; CHECK-NEXT: call __truncsfhf2
1655 ; CHECK-NEXT: call __extendhfsf2
1656 ; CHECK-NEXT: i64.trunc_sat_f32_s
1657 ; CHECK-NEXT: # fallthrough-return
1659 %conv = fptosi half %x to i128
1660 %spec.store.select = call i128 @llvm.smin.i128(i128 %conv, i128 9223372036854775807)
1661 %spec.store.select7 = call i128 @llvm.smax.i128(i128 %spec.store.select, i128 -9223372036854775808)
1662 %conv6 = trunc i128 %spec.store.select7 to i64
1666 define i64 @utesth_f16i64_mm(half %x) {
1667 ; CHECK-LABEL: utesth_f16i64_mm:
1668 ; CHECK: .functype utesth_f16i64_mm (f32) -> (i64)
1669 ; CHECK-NEXT: .local i32, i64, i64
1670 ; CHECK-NEXT: # %bb.0: # %entry
1671 ; CHECK-NEXT: global.get __stack_pointer
1672 ; CHECK-NEXT: i32.const 16
1673 ; CHECK-NEXT: i32.sub
1674 ; CHECK-NEXT: local.tee 1
1675 ; CHECK-NEXT: global.set __stack_pointer
1676 ; CHECK-NEXT: local.get 1
1677 ; CHECK-NEXT: local.get 0
1678 ; CHECK-NEXT: call __truncsfhf2
1679 ; CHECK-NEXT: call __extendhfsf2
1680 ; CHECK-NEXT: call __fixunssfti
1681 ; CHECK-NEXT: local.get 1
1682 ; CHECK-NEXT: i32.const 8
1683 ; CHECK-NEXT: i32.add
1684 ; CHECK-NEXT: i64.load 0
1685 ; CHECK-NEXT: local.set 2
1686 ; CHECK-NEXT: local.get 1
1687 ; CHECK-NEXT: i64.load 0
1688 ; CHECK-NEXT: local.set 3
1689 ; CHECK-NEXT: local.get 1
1690 ; CHECK-NEXT: i32.const 16
1691 ; CHECK-NEXT: i32.add
1692 ; CHECK-NEXT: global.set __stack_pointer
1693 ; CHECK-NEXT: local.get 3
1694 ; CHECK-NEXT: i64.const 0
1695 ; CHECK-NEXT: local.get 2
1696 ; CHECK-NEXT: i64.eqz
1697 ; CHECK-NEXT: i64.select
1698 ; CHECK-NEXT: # fallthrough-return
1700 %conv = fptoui half %x to i128
1701 %spec.store.select = call i128 @llvm.umin.i128(i128 %conv, i128 18446744073709551616)
1702 %conv6 = trunc i128 %spec.store.select to i64
1706 define i64 @ustest_f16i64_mm(half %x) {
1707 ; CHECK-LABEL: ustest_f16i64_mm:
1708 ; CHECK: .functype ustest_f16i64_mm (f32) -> (i64)
1709 ; CHECK-NEXT: .local i32, i64, i64
1710 ; CHECK-NEXT: # %bb.0: # %entry
1711 ; CHECK-NEXT: global.get __stack_pointer
1712 ; CHECK-NEXT: i32.const 16
1713 ; CHECK-NEXT: i32.sub
1714 ; CHECK-NEXT: local.tee 1
1715 ; CHECK-NEXT: global.set __stack_pointer
1716 ; CHECK-NEXT: local.get 1
1717 ; CHECK-NEXT: local.get 0
1718 ; CHECK-NEXT: call __truncsfhf2
1719 ; CHECK-NEXT: call __extendhfsf2
1720 ; CHECK-NEXT: call __fixsfti
1721 ; CHECK-NEXT: local.get 1
1722 ; CHECK-NEXT: i32.const 8
1723 ; CHECK-NEXT: i32.add
1724 ; CHECK-NEXT: i64.load 0
1725 ; CHECK-NEXT: local.set 2
1726 ; CHECK-NEXT: local.get 1
1727 ; CHECK-NEXT: i64.load 0
1728 ; CHECK-NEXT: local.set 3
1729 ; CHECK-NEXT: local.get 1
1730 ; CHECK-NEXT: i32.const 16
1731 ; CHECK-NEXT: i32.add
1732 ; CHECK-NEXT: global.set __stack_pointer
1733 ; CHECK-NEXT: i64.const 0
1734 ; CHECK-NEXT: local.get 3
1735 ; CHECK-NEXT: i64.const 0
1736 ; CHECK-NEXT: local.get 2
1737 ; CHECK-NEXT: i64.const 1
1738 ; CHECK-NEXT: i64.lt_s
1739 ; CHECK-NEXT: local.tee 1
1740 ; CHECK-NEXT: i64.select
1741 ; CHECK-NEXT: local.get 2
1742 ; CHECK-NEXT: i64.const 1
1743 ; CHECK-NEXT: local.get 1
1744 ; CHECK-NEXT: i64.select
1745 ; CHECK-NEXT: i64.const 0
1746 ; CHECK-NEXT: i64.lt_s
1747 ; CHECK-NEXT: i64.select
1748 ; CHECK-NEXT: # fallthrough-return
1750 %conv = fptosi half %x to i128
1751 %spec.store.select = call i128 @llvm.smin.i128(i128 %conv, i128 18446744073709551616)
1752 %spec.store.select7 = call i128 @llvm.smax.i128(i128 %spec.store.select, i128 0)
1753 %conv6 = trunc i128 %spec.store.select7 to i64
1757 define i64 @utesth_f16i64_mm_cse(half %x) {
1758 ; CHECK-LABEL: utesth_f16i64_mm_cse:
1759 ; CHECK: .functype utesth_f16i64_mm_cse (f32) -> (i64)
1760 ; CHECK-NEXT: .local i32, i64
1761 ; CHECK-NEXT: # %bb.0: # %entry
1762 ; CHECK-NEXT: global.get __stack_pointer
1763 ; CHECK-NEXT: i32.const 16
1764 ; CHECK-NEXT: i32.sub
1765 ; CHECK-NEXT: local.tee 1
1766 ; CHECK-NEXT: global.set __stack_pointer
1767 ; CHECK-NEXT: local.get 1
1768 ; CHECK-NEXT: local.get 0
1769 ; CHECK-NEXT: call __truncsfhf2
1770 ; CHECK-NEXT: call __extendhfsf2
1771 ; CHECK-NEXT: call __fixunssfti
1772 ; CHECK-NEXT: local.get 1
1773 ; CHECK-NEXT: i64.load 0
1774 ; CHECK-NEXT: local.set 2
1775 ; CHECK-NEXT: local.get 1
1776 ; CHECK-NEXT: i32.const 16
1777 ; CHECK-NEXT: i32.add
1778 ; CHECK-NEXT: global.set __stack_pointer
1779 ; CHECK-NEXT: local.get 2
1780 ; CHECK-NEXT: # fallthrough-return
1782 %conv = fptoui half %x to i128
1783 %conv6 = trunc i128 %conv to i64
1787 declare i32 @llvm.smin.i32(i32, i32)
1788 declare i32 @llvm.smax.i32(i32, i32)
1789 declare i32 @llvm.umin.i32(i32, i32)
1790 declare i64 @llvm.smin.i64(i64, i64)
1791 declare i64 @llvm.smax.i64(i64, i64)
1792 declare i64 @llvm.umin.i64(i64, i64)
1793 declare i128 @llvm.smin.i128(i128, i128)
1794 declare i128 @llvm.smax.i128(i128, i128)
1795 declare i128 @llvm.umin.i128(i128, i128)