1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-apple-darwin10 | FileCheck %s --check-prefixes=ISEL,SSE
3 ; RUN: llc < %s -mtriple=x86_64-apple-darwin10 -fast-isel -fast-isel-abort=1 | FileCheck %s --check-prefixes=FASTISEL,SSE
4 ; RUN: llc < %s -mtriple=x86_64-apple-darwin10 -mcpu=corei7-avx | FileCheck %s --check-prefixes=ISEL,AVX
5 ; RUN: llc < %s -mtriple=x86_64-apple-darwin10 -fast-isel -fast-isel-abort=1 -mcpu=corei7-avx | FileCheck %s --check-prefixes=FASTISEL,AVX
6 ; RUN: llc < %s -mtriple=x86_64-apple-darwin10 -mcpu=skylake-avx512 -verify-machineinstrs | FileCheck %s --check-prefixes=ISEL,AVX512,AVX512-ISEL
7 ; RUN: llc < %s -mtriple=x86_64-apple-darwin10 -fast-isel -fast-isel-abort=1 -mcpu=skylake-avx512 -verify-machineinstrs | FileCheck %s --check-prefixes=FASTISEL,AVX512,AVX512-FASTISEL
10 define float @select_fcmp_one_f32(float %a, float %b, float %c, float %d) {
11 ; SSE-LABEL: select_fcmp_one_f32:
13 ; SSE-NEXT: ucomiss %xmm1, %xmm0
14 ; SSE-NEXT: jne LBB0_2
16 ; SSE-NEXT: movaps %xmm3, %xmm2
18 ; SSE-NEXT: movaps %xmm2, %xmm0
21 ; AVX-LABEL: select_fcmp_one_f32:
23 ; AVX-NEXT: vcmpneq_oqss %xmm1, %xmm0, %xmm0
24 ; AVX-NEXT: vblendvps %xmm0, %xmm2, %xmm3, %xmm0
27 ; AVX512-LABEL: select_fcmp_one_f32:
29 ; AVX512-NEXT: vcmpneq_oqss %xmm1, %xmm0, %k1
30 ; AVX512-NEXT: vmovss %xmm2, %xmm3, %xmm3 {%k1}
31 ; AVX512-NEXT: vmovaps %xmm3, %xmm0
33 %1 = fcmp one float %a, %b
34 %2 = select i1 %1, float %c, float %d
38 define double @select_fcmp_one_f64(double %a, double %b, double %c, double %d) {
39 ; SSE-LABEL: select_fcmp_one_f64:
41 ; SSE-NEXT: ucomisd %xmm1, %xmm0
42 ; SSE-NEXT: jne LBB1_2
44 ; SSE-NEXT: movaps %xmm3, %xmm2
46 ; SSE-NEXT: movaps %xmm2, %xmm0
49 ; AVX-LABEL: select_fcmp_one_f64:
51 ; AVX-NEXT: vcmpneq_oqsd %xmm1, %xmm0, %xmm0
52 ; AVX-NEXT: vblendvpd %xmm0, %xmm2, %xmm3, %xmm0
55 ; AVX512-LABEL: select_fcmp_one_f64:
57 ; AVX512-NEXT: vcmpneq_oqsd %xmm1, %xmm0, %k1
58 ; AVX512-NEXT: vmovsd %xmm2, %xmm3, %xmm3 {%k1}
59 ; AVX512-NEXT: vmovapd %xmm3, %xmm0
61 %1 = fcmp one double %a, %b
62 %2 = select i1 %1, double %c, double %d
66 define float @select_icmp_eq_f32(i64 %a, i64 %b, float %c, float %d) {
67 ; SSE-LABEL: select_icmp_eq_f32:
69 ; SSE-NEXT: cmpq %rsi, %rdi
72 ; SSE-NEXT: movaps %xmm1, %xmm0
76 ; AVX-LABEL: select_icmp_eq_f32:
78 ; AVX-NEXT: cmpq %rsi, %rdi
81 ; AVX-NEXT: vmovaps %xmm1, %xmm0
85 ; AVX512-ISEL-LABEL: select_icmp_eq_f32:
86 ; AVX512-ISEL: ## %bb.0:
87 ; AVX512-ISEL-NEXT: cmpq %rsi, %rdi
88 ; AVX512-ISEL-NEXT: sete %al
89 ; AVX512-ISEL-NEXT: kmovd %eax, %k1
90 ; AVX512-ISEL-NEXT: vmovss %xmm0, %xmm1, %xmm1 {%k1}
91 ; AVX512-ISEL-NEXT: vmovaps %xmm1, %xmm0
92 ; AVX512-ISEL-NEXT: retq
94 ; AVX512-FASTISEL-LABEL: select_icmp_eq_f32:
95 ; AVX512-FASTISEL: ## %bb.0:
96 ; AVX512-FASTISEL-NEXT: cmpq %rsi, %rdi
97 ; AVX512-FASTISEL-NEXT: je LBB2_2
98 ; AVX512-FASTISEL-NEXT: ## %bb.1:
99 ; AVX512-FASTISEL-NEXT: vmovaps %xmm1, %xmm0
100 ; AVX512-FASTISEL-NEXT: LBB2_2:
101 ; AVX512-FASTISEL-NEXT: retq
102 %1 = icmp eq i64 %a, %b
103 %2 = select i1 %1, float %c, float %d
107 define float @select_icmp_ne_f32(i64 %a, i64 %b, float %c, float %d) {
108 ; SSE-LABEL: select_icmp_ne_f32:
110 ; SSE-NEXT: cmpq %rsi, %rdi
111 ; SSE-NEXT: jne LBB3_2
112 ; SSE-NEXT: ## %bb.1:
113 ; SSE-NEXT: movaps %xmm1, %xmm0
117 ; AVX-LABEL: select_icmp_ne_f32:
119 ; AVX-NEXT: cmpq %rsi, %rdi
120 ; AVX-NEXT: jne LBB3_2
121 ; AVX-NEXT: ## %bb.1:
122 ; AVX-NEXT: vmovaps %xmm1, %xmm0
126 ; AVX512-ISEL-LABEL: select_icmp_ne_f32:
127 ; AVX512-ISEL: ## %bb.0:
128 ; AVX512-ISEL-NEXT: cmpq %rsi, %rdi
129 ; AVX512-ISEL-NEXT: setne %al
130 ; AVX512-ISEL-NEXT: kmovd %eax, %k1
131 ; AVX512-ISEL-NEXT: vmovss %xmm0, %xmm1, %xmm1 {%k1}
132 ; AVX512-ISEL-NEXT: vmovaps %xmm1, %xmm0
133 ; AVX512-ISEL-NEXT: retq
135 ; AVX512-FASTISEL-LABEL: select_icmp_ne_f32:
136 ; AVX512-FASTISEL: ## %bb.0:
137 ; AVX512-FASTISEL-NEXT: cmpq %rsi, %rdi
138 ; AVX512-FASTISEL-NEXT: jne LBB3_2
139 ; AVX512-FASTISEL-NEXT: ## %bb.1:
140 ; AVX512-FASTISEL-NEXT: vmovaps %xmm1, %xmm0
141 ; AVX512-FASTISEL-NEXT: LBB3_2:
142 ; AVX512-FASTISEL-NEXT: retq
143 %1 = icmp ne i64 %a, %b
144 %2 = select i1 %1, float %c, float %d
148 define float @select_icmp_ugt_f32(i64 %a, i64 %b, float %c, float %d) {
149 ; SSE-LABEL: select_icmp_ugt_f32:
151 ; SSE-NEXT: cmpq %rsi, %rdi
152 ; SSE-NEXT: ja LBB4_2
153 ; SSE-NEXT: ## %bb.1:
154 ; SSE-NEXT: movaps %xmm1, %xmm0
158 ; AVX-LABEL: select_icmp_ugt_f32:
160 ; AVX-NEXT: cmpq %rsi, %rdi
161 ; AVX-NEXT: ja LBB4_2
162 ; AVX-NEXT: ## %bb.1:
163 ; AVX-NEXT: vmovaps %xmm1, %xmm0
167 ; AVX512-ISEL-LABEL: select_icmp_ugt_f32:
168 ; AVX512-ISEL: ## %bb.0:
169 ; AVX512-ISEL-NEXT: cmpq %rsi, %rdi
170 ; AVX512-ISEL-NEXT: seta %al
171 ; AVX512-ISEL-NEXT: kmovd %eax, %k1
172 ; AVX512-ISEL-NEXT: vmovss %xmm0, %xmm1, %xmm1 {%k1}
173 ; AVX512-ISEL-NEXT: vmovaps %xmm1, %xmm0
174 ; AVX512-ISEL-NEXT: retq
176 ; AVX512-FASTISEL-LABEL: select_icmp_ugt_f32:
177 ; AVX512-FASTISEL: ## %bb.0:
178 ; AVX512-FASTISEL-NEXT: cmpq %rsi, %rdi
179 ; AVX512-FASTISEL-NEXT: ja LBB4_2
180 ; AVX512-FASTISEL-NEXT: ## %bb.1:
181 ; AVX512-FASTISEL-NEXT: vmovaps %xmm1, %xmm0
182 ; AVX512-FASTISEL-NEXT: LBB4_2:
183 ; AVX512-FASTISEL-NEXT: retq
184 %1 = icmp ugt i64 %a, %b
185 %2 = select i1 %1, float %c, float %d
189 define float @select_icmp_uge_f32(i64 %a, i64 %b, float %c, float %d) {
190 ; SSE-LABEL: select_icmp_uge_f32:
192 ; SSE-NEXT: cmpq %rsi, %rdi
193 ; SSE-NEXT: jae LBB5_2
194 ; SSE-NEXT: ## %bb.1:
195 ; SSE-NEXT: movaps %xmm1, %xmm0
199 ; AVX-LABEL: select_icmp_uge_f32:
201 ; AVX-NEXT: cmpq %rsi, %rdi
202 ; AVX-NEXT: jae LBB5_2
203 ; AVX-NEXT: ## %bb.1:
204 ; AVX-NEXT: vmovaps %xmm1, %xmm0
208 ; AVX512-ISEL-LABEL: select_icmp_uge_f32:
209 ; AVX512-ISEL: ## %bb.0:
210 ; AVX512-ISEL-NEXT: cmpq %rsi, %rdi
211 ; AVX512-ISEL-NEXT: setae %al
212 ; AVX512-ISEL-NEXT: kmovd %eax, %k1
213 ; AVX512-ISEL-NEXT: vmovss %xmm0, %xmm1, %xmm1 {%k1}
214 ; AVX512-ISEL-NEXT: vmovaps %xmm1, %xmm0
215 ; AVX512-ISEL-NEXT: retq
217 ; AVX512-FASTISEL-LABEL: select_icmp_uge_f32:
218 ; AVX512-FASTISEL: ## %bb.0:
219 ; AVX512-FASTISEL-NEXT: cmpq %rsi, %rdi
220 ; AVX512-FASTISEL-NEXT: jae LBB5_2
221 ; AVX512-FASTISEL-NEXT: ## %bb.1:
222 ; AVX512-FASTISEL-NEXT: vmovaps %xmm1, %xmm0
223 ; AVX512-FASTISEL-NEXT: LBB5_2:
224 ; AVX512-FASTISEL-NEXT: retq
225 %1 = icmp uge i64 %a, %b
226 %2 = select i1 %1, float %c, float %d
230 define float @select_icmp_ult_f32(i64 %a, i64 %b, float %c, float %d) {
231 ; SSE-LABEL: select_icmp_ult_f32:
233 ; SSE-NEXT: cmpq %rsi, %rdi
234 ; SSE-NEXT: jb LBB6_2
235 ; SSE-NEXT: ## %bb.1:
236 ; SSE-NEXT: movaps %xmm1, %xmm0
240 ; AVX-LABEL: select_icmp_ult_f32:
242 ; AVX-NEXT: cmpq %rsi, %rdi
243 ; AVX-NEXT: jb LBB6_2
244 ; AVX-NEXT: ## %bb.1:
245 ; AVX-NEXT: vmovaps %xmm1, %xmm0
249 ; AVX512-ISEL-LABEL: select_icmp_ult_f32:
250 ; AVX512-ISEL: ## %bb.0:
251 ; AVX512-ISEL-NEXT: cmpq %rsi, %rdi
252 ; AVX512-ISEL-NEXT: setb %al
253 ; AVX512-ISEL-NEXT: kmovd %eax, %k1
254 ; AVX512-ISEL-NEXT: vmovss %xmm0, %xmm1, %xmm1 {%k1}
255 ; AVX512-ISEL-NEXT: vmovaps %xmm1, %xmm0
256 ; AVX512-ISEL-NEXT: retq
258 ; AVX512-FASTISEL-LABEL: select_icmp_ult_f32:
259 ; AVX512-FASTISEL: ## %bb.0:
260 ; AVX512-FASTISEL-NEXT: cmpq %rsi, %rdi
261 ; AVX512-FASTISEL-NEXT: jb LBB6_2
262 ; AVX512-FASTISEL-NEXT: ## %bb.1:
263 ; AVX512-FASTISEL-NEXT: vmovaps %xmm1, %xmm0
264 ; AVX512-FASTISEL-NEXT: LBB6_2:
265 ; AVX512-FASTISEL-NEXT: retq
266 %1 = icmp ult i64 %a, %b
267 %2 = select i1 %1, float %c, float %d
271 define float @select_icmp_ule_f32(i64 %a, i64 %b, float %c, float %d) {
272 ; SSE-LABEL: select_icmp_ule_f32:
274 ; SSE-NEXT: cmpq %rsi, %rdi
275 ; SSE-NEXT: jbe LBB7_2
276 ; SSE-NEXT: ## %bb.1:
277 ; SSE-NEXT: movaps %xmm1, %xmm0
281 ; AVX-LABEL: select_icmp_ule_f32:
283 ; AVX-NEXT: cmpq %rsi, %rdi
284 ; AVX-NEXT: jbe LBB7_2
285 ; AVX-NEXT: ## %bb.1:
286 ; AVX-NEXT: vmovaps %xmm1, %xmm0
290 ; AVX512-ISEL-LABEL: select_icmp_ule_f32:
291 ; AVX512-ISEL: ## %bb.0:
292 ; AVX512-ISEL-NEXT: cmpq %rsi, %rdi
293 ; AVX512-ISEL-NEXT: setbe %al
294 ; AVX512-ISEL-NEXT: kmovd %eax, %k1
295 ; AVX512-ISEL-NEXT: vmovss %xmm0, %xmm1, %xmm1 {%k1}
296 ; AVX512-ISEL-NEXT: vmovaps %xmm1, %xmm0
297 ; AVX512-ISEL-NEXT: retq
299 ; AVX512-FASTISEL-LABEL: select_icmp_ule_f32:
300 ; AVX512-FASTISEL: ## %bb.0:
301 ; AVX512-FASTISEL-NEXT: cmpq %rsi, %rdi
302 ; AVX512-FASTISEL-NEXT: jbe LBB7_2
303 ; AVX512-FASTISEL-NEXT: ## %bb.1:
304 ; AVX512-FASTISEL-NEXT: vmovaps %xmm1, %xmm0
305 ; AVX512-FASTISEL-NEXT: LBB7_2:
306 ; AVX512-FASTISEL-NEXT: retq
307 %1 = icmp ule i64 %a, %b
308 %2 = select i1 %1, float %c, float %d
312 define float @select_icmp_sgt_f32(i64 %a, i64 %b, float %c, float %d) {
313 ; SSE-LABEL: select_icmp_sgt_f32:
315 ; SSE-NEXT: cmpq %rsi, %rdi
316 ; SSE-NEXT: jg LBB8_2
317 ; SSE-NEXT: ## %bb.1:
318 ; SSE-NEXT: movaps %xmm1, %xmm0
322 ; AVX-LABEL: select_icmp_sgt_f32:
324 ; AVX-NEXT: cmpq %rsi, %rdi
325 ; AVX-NEXT: jg LBB8_2
326 ; AVX-NEXT: ## %bb.1:
327 ; AVX-NEXT: vmovaps %xmm1, %xmm0
331 ; AVX512-ISEL-LABEL: select_icmp_sgt_f32:
332 ; AVX512-ISEL: ## %bb.0:
333 ; AVX512-ISEL-NEXT: cmpq %rsi, %rdi
334 ; AVX512-ISEL-NEXT: setg %al
335 ; AVX512-ISEL-NEXT: kmovd %eax, %k1
336 ; AVX512-ISEL-NEXT: vmovss %xmm0, %xmm1, %xmm1 {%k1}
337 ; AVX512-ISEL-NEXT: vmovaps %xmm1, %xmm0
338 ; AVX512-ISEL-NEXT: retq
340 ; AVX512-FASTISEL-LABEL: select_icmp_sgt_f32:
341 ; AVX512-FASTISEL: ## %bb.0:
342 ; AVX512-FASTISEL-NEXT: cmpq %rsi, %rdi
343 ; AVX512-FASTISEL-NEXT: jg LBB8_2
344 ; AVX512-FASTISEL-NEXT: ## %bb.1:
345 ; AVX512-FASTISEL-NEXT: vmovaps %xmm1, %xmm0
346 ; AVX512-FASTISEL-NEXT: LBB8_2:
347 ; AVX512-FASTISEL-NEXT: retq
348 %1 = icmp sgt i64 %a, %b
349 %2 = select i1 %1, float %c, float %d
353 define float @select_icmp_sge_f32(i64 %a, i64 %b, float %c, float %d) {
354 ; SSE-LABEL: select_icmp_sge_f32:
356 ; SSE-NEXT: cmpq %rsi, %rdi
357 ; SSE-NEXT: jge LBB9_2
358 ; SSE-NEXT: ## %bb.1:
359 ; SSE-NEXT: movaps %xmm1, %xmm0
363 ; AVX-LABEL: select_icmp_sge_f32:
365 ; AVX-NEXT: cmpq %rsi, %rdi
366 ; AVX-NEXT: jge LBB9_2
367 ; AVX-NEXT: ## %bb.1:
368 ; AVX-NEXT: vmovaps %xmm1, %xmm0
372 ; AVX512-ISEL-LABEL: select_icmp_sge_f32:
373 ; AVX512-ISEL: ## %bb.0:
374 ; AVX512-ISEL-NEXT: cmpq %rsi, %rdi
375 ; AVX512-ISEL-NEXT: setge %al
376 ; AVX512-ISEL-NEXT: kmovd %eax, %k1
377 ; AVX512-ISEL-NEXT: vmovss %xmm0, %xmm1, %xmm1 {%k1}
378 ; AVX512-ISEL-NEXT: vmovaps %xmm1, %xmm0
379 ; AVX512-ISEL-NEXT: retq
381 ; AVX512-FASTISEL-LABEL: select_icmp_sge_f32:
382 ; AVX512-FASTISEL: ## %bb.0:
383 ; AVX512-FASTISEL-NEXT: cmpq %rsi, %rdi
384 ; AVX512-FASTISEL-NEXT: jge LBB9_2
385 ; AVX512-FASTISEL-NEXT: ## %bb.1:
386 ; AVX512-FASTISEL-NEXT: vmovaps %xmm1, %xmm0
387 ; AVX512-FASTISEL-NEXT: LBB9_2:
388 ; AVX512-FASTISEL-NEXT: retq
389 %1 = icmp sge i64 %a, %b
390 %2 = select i1 %1, float %c, float %d
394 define float @select_icmp_slt_f32(i64 %a, i64 %b, float %c, float %d) {
395 ; SSE-LABEL: select_icmp_slt_f32:
397 ; SSE-NEXT: cmpq %rsi, %rdi
398 ; SSE-NEXT: jl LBB10_2
399 ; SSE-NEXT: ## %bb.1:
400 ; SSE-NEXT: movaps %xmm1, %xmm0
404 ; AVX-LABEL: select_icmp_slt_f32:
406 ; AVX-NEXT: cmpq %rsi, %rdi
407 ; AVX-NEXT: jl LBB10_2
408 ; AVX-NEXT: ## %bb.1:
409 ; AVX-NEXT: vmovaps %xmm1, %xmm0
413 ; AVX512-ISEL-LABEL: select_icmp_slt_f32:
414 ; AVX512-ISEL: ## %bb.0:
415 ; AVX512-ISEL-NEXT: cmpq %rsi, %rdi
416 ; AVX512-ISEL-NEXT: setl %al
417 ; AVX512-ISEL-NEXT: kmovd %eax, %k1
418 ; AVX512-ISEL-NEXT: vmovss %xmm0, %xmm1, %xmm1 {%k1}
419 ; AVX512-ISEL-NEXT: vmovaps %xmm1, %xmm0
420 ; AVX512-ISEL-NEXT: retq
422 ; AVX512-FASTISEL-LABEL: select_icmp_slt_f32:
423 ; AVX512-FASTISEL: ## %bb.0:
424 ; AVX512-FASTISEL-NEXT: cmpq %rsi, %rdi
425 ; AVX512-FASTISEL-NEXT: jl LBB10_2
426 ; AVX512-FASTISEL-NEXT: ## %bb.1:
427 ; AVX512-FASTISEL-NEXT: vmovaps %xmm1, %xmm0
428 ; AVX512-FASTISEL-NEXT: LBB10_2:
429 ; AVX512-FASTISEL-NEXT: retq
430 %1 = icmp slt i64 %a, %b
431 %2 = select i1 %1, float %c, float %d
435 define float @select_icmp_sle_f32(i64 %a, i64 %b, float %c, float %d) {
436 ; SSE-LABEL: select_icmp_sle_f32:
438 ; SSE-NEXT: cmpq %rsi, %rdi
439 ; SSE-NEXT: jle LBB11_2
440 ; SSE-NEXT: ## %bb.1:
441 ; SSE-NEXT: movaps %xmm1, %xmm0
445 ; AVX-LABEL: select_icmp_sle_f32:
447 ; AVX-NEXT: cmpq %rsi, %rdi
448 ; AVX-NEXT: jle LBB11_2
449 ; AVX-NEXT: ## %bb.1:
450 ; AVX-NEXT: vmovaps %xmm1, %xmm0
454 ; AVX512-ISEL-LABEL: select_icmp_sle_f32:
455 ; AVX512-ISEL: ## %bb.0:
456 ; AVX512-ISEL-NEXT: cmpq %rsi, %rdi
457 ; AVX512-ISEL-NEXT: setle %al
458 ; AVX512-ISEL-NEXT: kmovd %eax, %k1
459 ; AVX512-ISEL-NEXT: vmovss %xmm0, %xmm1, %xmm1 {%k1}
460 ; AVX512-ISEL-NEXT: vmovaps %xmm1, %xmm0
461 ; AVX512-ISEL-NEXT: retq
463 ; AVX512-FASTISEL-LABEL: select_icmp_sle_f32:
464 ; AVX512-FASTISEL: ## %bb.0:
465 ; AVX512-FASTISEL-NEXT: cmpq %rsi, %rdi
466 ; AVX512-FASTISEL-NEXT: jle LBB11_2
467 ; AVX512-FASTISEL-NEXT: ## %bb.1:
468 ; AVX512-FASTISEL-NEXT: vmovaps %xmm1, %xmm0
469 ; AVX512-FASTISEL-NEXT: LBB11_2:
470 ; AVX512-FASTISEL-NEXT: retq
471 %1 = icmp sle i64 %a, %b
472 %2 = select i1 %1, float %c, float %d
476 define i8 @select_icmp_sle_i8(i64 %a, i64 %b, i8 %c, i8 %d) {
477 ; ISEL-LABEL: select_icmp_sle_i8:
479 ; ISEL-NEXT: movl %edx, %eax
480 ; ISEL-NEXT: cmpq %rsi, %rdi
481 ; ISEL-NEXT: cmovgl %ecx, %eax
482 ; ISEL-NEXT: ## kill: def $al killed $al killed $eax
485 ; FASTISEL-LABEL: select_icmp_sle_i8:
486 ; FASTISEL: ## %bb.0:
487 ; FASTISEL-NEXT: cmpq %rsi, %rdi
488 ; FASTISEL-NEXT: jle LBB12_1
489 ; FASTISEL-NEXT: ## %bb.2:
490 ; FASTISEL-NEXT: movl %ecx, %eax
491 ; FASTISEL-NEXT: ## kill: def $al killed $al killed $eax
492 ; FASTISEL-NEXT: retq
493 ; FASTISEL-NEXT: LBB12_1:
494 ; FASTISEL-NEXT: movl %edx, %eax
495 ; FASTISEL-NEXT: ## kill: def $al killed $al killed $eax
496 ; FASTISEL-NEXT: retq
497 %1 = icmp sle i64 %a, %b
498 %2 = select i1 %1, i8 %c, i8 %d