1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=x86_64-unknown-unknown -mattr=+tbm < %s | FileCheck %s
4 define i32 @test_x86_tbm_bextri_u32(i32 %a) nounwind {
5 ; CHECK-LABEL: test_x86_tbm_bextri_u32:
7 ; CHECK-NEXT: bextrl $3076, %edi, %eax # imm = 0xC04
10 %t1 = and i32 %t0, 4095
14 ; Make sure we still use AH subreg trick for extracting bits 15:8
15 define i32 @test_x86_tbm_bextri_u32_subreg(i32 %a) nounwind {
16 ; CHECK-LABEL: test_x86_tbm_bextri_u32_subreg:
18 ; CHECK-NEXT: movl %edi, %eax
19 ; CHECK-NEXT: movzbl %ah, %eax
22 %t1 = and i32 %t0, 255
26 define i32 @test_x86_tbm_bextri_u32_m(ptr nocapture %a) nounwind {
27 ; CHECK-LABEL: test_x86_tbm_bextri_u32_m:
29 ; CHECK-NEXT: bextrl $3076, (%rdi), %eax # imm = 0xC04
31 %t0 = load i32, ptr %a
33 %t2 = and i32 %t1, 4095
37 define i32 @test_x86_tbm_bextri_u32_z(i32 %a, i32 %b) nounwind {
38 ; CHECK-LABEL: test_x86_tbm_bextri_u32_z:
40 ; CHECK-NEXT: bextrl $3076, %edi, %eax # imm = 0xC04
41 ; CHECK-NEXT: cmovel %esi, %eax
44 %t1 = and i32 %t0, 4095
45 %t2 = icmp eq i32 %t1, 0
46 %t3 = select i1 %t2, i32 %b, i32 %t1
50 define i32 @test_x86_tbm_bextri_u32_z2(i32 %a, i32 %b, i32 %c) nounwind {
51 ; CHECK-LABEL: test_x86_tbm_bextri_u32_z2:
53 ; CHECK-NEXT: movl %esi, %eax
54 ; CHECK-NEXT: bextrl $3076, %edi, %ecx # imm = 0xC04
55 ; CHECK-NEXT: cmovnel %edx, %eax
58 %t1 = and i32 %t0, 4095
59 %t2 = icmp eq i32 %t1, 0
60 %t3 = select i1 %t2, i32 %b, i32 %c
64 define i32 @test_x86_tbm_bextri_u32_sle(i32 %a, i32 %b, i32 %c) nounwind {
65 ; CHECK-LABEL: test_x86_tbm_bextri_u32_sle:
67 ; CHECK-NEXT: movl %esi, %eax
68 ; CHECK-NEXT: bextrl $3076, %edi, %ecx # imm = 0xC04
69 ; CHECK-NEXT: testl %ecx, %ecx
70 ; CHECK-NEXT: cmovgl %edx, %eax
73 %t1 = and i32 %t0, 4095
74 %t2 = icmp sle i32 %t1, 0
75 %t3 = select i1 %t2, i32 %b, i32 %c
79 define i64 @test_x86_tbm_bextri_u64(i64 %a) nounwind {
80 ; CHECK-LABEL: test_x86_tbm_bextri_u64:
82 ; CHECK-NEXT: bextrl $3076, %edi, %eax # imm = 0xC04
85 %t1 = and i64 %t0, 4095
89 ; Make sure we still use AH subreg trick for extracting bits 15:8
90 define i64 @test_x86_tbm_bextri_u64_subreg(i64 %a) nounwind {
91 ; CHECK-LABEL: test_x86_tbm_bextri_u64_subreg:
93 ; CHECK-NEXT: movq %rdi, %rax
94 ; CHECK-NEXT: movzbl %ah, %eax
97 %t1 = and i64 %t0, 255
101 define i64 @test_x86_tbm_bextri_u64_m(ptr nocapture %a) nounwind {
102 ; CHECK-LABEL: test_x86_tbm_bextri_u64_m:
104 ; CHECK-NEXT: bextrl $3076, (%rdi), %eax # imm = 0xC04
106 %t0 = load i64, ptr %a
107 %t1 = lshr i64 %t0, 4
108 %t2 = and i64 %t1, 4095
112 define i64 @test_x86_tbm_bextri_u64_z(i64 %a, i64 %b) nounwind {
113 ; CHECK-LABEL: test_x86_tbm_bextri_u64_z:
115 ; CHECK-NEXT: bextrl $3076, %edi, %eax # imm = 0xC04
116 ; CHECK-NEXT: cmoveq %rsi, %rax
119 %t1 = and i64 %t0, 4095
120 %t2 = icmp eq i64 %t1, 0
121 %t3 = select i1 %t2, i64 %b, i64 %t1
125 define i64 @test_x86_tbm_bextri_u64_z2(i64 %a, i64 %b, i64 %c) nounwind {
126 ; CHECK-LABEL: test_x86_tbm_bextri_u64_z2:
128 ; CHECK-NEXT: movq %rsi, %rax
129 ; CHECK-NEXT: bextrl $3076, %edi, %ecx # imm = 0xC04
130 ; CHECK-NEXT: cmovneq %rdx, %rax
133 %t1 = and i64 %t0, 4095
134 %t2 = icmp eq i64 %t1, 0
135 %t3 = select i1 %t2, i64 %b, i64 %c
139 define i64 @test_x86_tbm_bextri_u64_sle(i64 %a, i64 %b, i64 %c) nounwind {
140 ; CHECK-LABEL: test_x86_tbm_bextri_u64_sle:
142 ; CHECK-NEXT: movq %rsi, %rax
143 ; CHECK-NEXT: bextrl $3076, %edi, %ecx # imm = 0xC04
144 ; CHECK-NEXT: testq %rcx, %rcx
145 ; CHECK-NEXT: cmovgq %rdx, %rax
148 %t1 = and i64 %t0, 4095
149 %t2 = icmp sle i64 %t1, 0
150 %t3 = select i1 %t2, i64 %b, i64 %c
154 define i32 @test_x86_tbm_blcfill_u32(i32 %a) nounwind {
155 ; CHECK-LABEL: test_x86_tbm_blcfill_u32:
157 ; CHECK-NEXT: blcfilll %edi, %eax
160 %t1 = and i32 %t0, %a
164 define i32 @test_x86_tbm_blcfill_u32_z(i32 %a, i32 %b) nounwind {
165 ; CHECK-LABEL: test_x86_tbm_blcfill_u32_z:
167 ; CHECK-NEXT: blcfilll %edi, %eax
168 ; CHECK-NEXT: cmovel %esi, %eax
171 %t1 = and i32 %t0, %a
172 %t2 = icmp eq i32 %t1, 0
173 %t3 = select i1 %t2, i32 %b, i32 %t1
177 define i32 @test_x86_tbm_blcfill_u32_z2(i32 %a, i32 %b, i32 %c) nounwind {
178 ; CHECK-LABEL: test_x86_tbm_blcfill_u32_z2:
180 ; CHECK-NEXT: movl %esi, %eax
181 ; CHECK-NEXT: blcfilll %edi, %ecx
182 ; CHECK-NEXT: cmovnel %edx, %eax
185 %t1 = and i32 %t0, %a
186 %t2 = icmp eq i32 %t1, 0
187 %t3 = select i1 %t2, i32 %b, i32 %c
191 define i32 @test_x86_tbm_blcfill_u32_sle(i32 %a, i32 %b, i32 %c) nounwind {
192 ; CHECK-LABEL: test_x86_tbm_blcfill_u32_sle:
194 ; CHECK-NEXT: movl %esi, %eax
195 ; CHECK-NEXT: blcfilll %edi, %ecx
196 ; CHECK-NEXT: cmovgl %edx, %eax
199 %t1 = and i32 %t0, %a
200 %t2 = icmp sle i32 %t1, 0
201 %t3 = select i1 %t2, i32 %b, i32 %c
205 define i64 @test_x86_tbm_blcfill_u64(i64 %a) nounwind {
206 ; CHECK-LABEL: test_x86_tbm_blcfill_u64:
208 ; CHECK-NEXT: blcfillq %rdi, %rax
211 %t1 = and i64 %t0, %a
215 define i64 @test_x86_tbm_blcfill_u64_z(i64 %a, i64 %b) nounwind {
216 ; CHECK-LABEL: test_x86_tbm_blcfill_u64_z:
218 ; CHECK-NEXT: blcfillq %rdi, %rax
219 ; CHECK-NEXT: cmoveq %rsi, %rax
222 %t1 = and i64 %t0, %a
223 %t2 = icmp eq i64 %t1, 0
224 %t3 = select i1 %t2, i64 %b, i64 %t1
228 define i64 @test_x86_tbm_blcfill_u64_z2(i64 %a, i64 %b, i64 %c) nounwind {
229 ; CHECK-LABEL: test_x86_tbm_blcfill_u64_z2:
231 ; CHECK-NEXT: movq %rsi, %rax
232 ; CHECK-NEXT: blcfillq %rdi, %rcx
233 ; CHECK-NEXT: cmovneq %rdx, %rax
236 %t1 = and i64 %t0, %a
237 %t2 = icmp eq i64 %t1, 0
238 %t3 = select i1 %t2, i64 %b, i64 %c
242 define i64 @test_x86_tbm_blcfill_u64_sle(i64 %a, i64 %b, i64 %c) nounwind {
243 ; CHECK-LABEL: test_x86_tbm_blcfill_u64_sle:
245 ; CHECK-NEXT: movq %rsi, %rax
246 ; CHECK-NEXT: blcfillq %rdi, %rcx
247 ; CHECK-NEXT: cmovgq %rdx, %rax
250 %t1 = and i64 %t0, %a
251 %t2 = icmp sle i64 %t1, 0
252 %t3 = select i1 %t2, i64 %b, i64 %c
256 define i32 @test_x86_tbm_blci_u32(i32 %a) nounwind {
257 ; CHECK-LABEL: test_x86_tbm_blci_u32:
259 ; CHECK-NEXT: blcil %edi, %eax
262 %t1 = xor i32 %t0, -1
267 define i32 @test_x86_tbm_blci_u32_z(i32 %a, i32 %b) nounwind {
268 ; CHECK-LABEL: test_x86_tbm_blci_u32_z:
270 ; CHECK-NEXT: blcil %edi, %eax
271 ; CHECK-NEXT: cmovel %esi, %eax
274 %t1 = xor i32 %t0, -1
276 %t3 = icmp eq i32 %t2, 0
277 %t4 = select i1 %t3, i32 %b, i32 %t2
281 define i32 @test_x86_tbm_blci_u32_z2(i32 %a, i32 %b, i32 %c) nounwind {
282 ; CHECK-LABEL: test_x86_tbm_blci_u32_z2:
284 ; CHECK-NEXT: movl %esi, %eax
285 ; CHECK-NEXT: blcil %edi, %ecx
286 ; CHECK-NEXT: cmovnel %edx, %eax
289 %t1 = xor i32 %t0, -1
291 %t3 = icmp eq i32 %t2, 0
292 %t4 = select i1 %t3, i32 %b, i32 %c
296 define i32 @test_x86_tbm_blci_u32_sle(i32 %a, i32 %b, i32 %c) nounwind {
297 ; CHECK-LABEL: test_x86_tbm_blci_u32_sle:
299 ; CHECK-NEXT: movl %esi, %eax
300 ; CHECK-NEXT: blcil %edi, %ecx
301 ; CHECK-NEXT: cmovgl %edx, %eax
304 %t1 = xor i32 %t0, -1
306 %t3 = icmp sle i32 %t2, 0
307 %t4 = select i1 %t3, i32 %b, i32 %c
311 define i64 @test_x86_tbm_blci_u64(i64 %a) nounwind {
312 ; CHECK-LABEL: test_x86_tbm_blci_u64:
314 ; CHECK-NEXT: blciq %rdi, %rax
317 %t1 = xor i64 %t0, -1
322 define i64 @test_x86_tbm_blci_u64_z(i64 %a, i64 %b) nounwind {
323 ; CHECK-LABEL: test_x86_tbm_blci_u64_z:
325 ; CHECK-NEXT: blciq %rdi, %rax
326 ; CHECK-NEXT: cmoveq %rsi, %rax
329 %t1 = xor i64 %t0, -1
331 %t3 = icmp eq i64 %t2, 0
332 %t4 = select i1 %t3, i64 %b, i64 %t2
336 define i64 @test_x86_tbm_blci_u64_z2(i64 %a, i64 %b, i64 %c) nounwind {
337 ; CHECK-LABEL: test_x86_tbm_blci_u64_z2:
339 ; CHECK-NEXT: movq %rsi, %rax
340 ; CHECK-NEXT: blciq %rdi, %rcx
341 ; CHECK-NEXT: cmovneq %rdx, %rax
344 %t1 = xor i64 %t0, -1
346 %t3 = icmp eq i64 %t2, 0
347 %t4 = select i1 %t3, i64 %b, i64 %c
351 define i64 @test_x86_tbm_blci_u64_sle(i64 %a, i64 %b, i64 %c) nounwind {
352 ; CHECK-LABEL: test_x86_tbm_blci_u64_sle:
354 ; CHECK-NEXT: movq %rsi, %rax
355 ; CHECK-NEXT: blciq %rdi, %rcx
356 ; CHECK-NEXT: cmovgq %rdx, %rax
359 %t1 = xor i64 %t0, -1
361 %t3 = icmp sle i64 %t2, 0
362 %t4 = select i1 %t3, i64 %b, i64 %c
366 define i32 @test_x86_tbm_blci_u32_b(i32 %a) nounwind {
367 ; CHECK-LABEL: test_x86_tbm_blci_u32_b:
369 ; CHECK-NEXT: blcil %edi, %eax
376 define i64 @test_x86_tbm_blci_u64_b(i64 %a) nounwind {
377 ; CHECK-LABEL: test_x86_tbm_blci_u64_b:
379 ; CHECK-NEXT: blciq %rdi, %rax
386 define i32 @test_x86_tbm_blcic_u32(i32 %a) nounwind {
387 ; CHECK-LABEL: test_x86_tbm_blcic_u32:
389 ; CHECK-NEXT: blcicl %edi, %eax
393 %t2 = and i32 %t1, %t0
397 define i32 @test_x86_tbm_blcic_u32_z(i32 %a, i32 %b) nounwind {
398 ; CHECK-LABEL: test_x86_tbm_blcic_u32_z:
400 ; CHECK-NEXT: blcicl %edi, %eax
401 ; CHECK-NEXT: cmovel %esi, %eax
405 %t2 = and i32 %t1, %t0
406 %t3 = icmp eq i32 %t2, 0
407 %t4 = select i1 %t3, i32 %b, i32 %t2
411 define i32 @test_x86_tbm_blcic_u32_z2(i32 %a, i32 %b, i32 %c) nounwind {
412 ; CHECK-LABEL: test_x86_tbm_blcic_u32_z2:
414 ; CHECK-NEXT: movl %esi, %eax
415 ; CHECK-NEXT: blcicl %edi, %ecx
416 ; CHECK-NEXT: cmovnel %edx, %eax
420 %t2 = and i32 %t1, %t0
421 %t3 = icmp eq i32 %t2, 0
422 %t4 = select i1 %t3, i32 %b, i32 %c
426 define i32 @test_x86_tbm_blcic_u32_sle(i32 %a, i32 %b, i32 %c) nounwind {
427 ; CHECK-LABEL: test_x86_tbm_blcic_u32_sle:
429 ; CHECK-NEXT: movl %esi, %eax
430 ; CHECK-NEXT: blcicl %edi, %ecx
431 ; CHECK-NEXT: cmovgl %edx, %eax
435 %t2 = and i32 %t1, %t0
436 %t3 = icmp sle i32 %t2, 0
437 %t4 = select i1 %t3, i32 %b, i32 %c
441 define i64 @test_x86_tbm_blcic_u64(i64 %a) nounwind {
442 ; CHECK-LABEL: test_x86_tbm_blcic_u64:
444 ; CHECK-NEXT: blcicq %rdi, %rax
448 %t2 = and i64 %t1, %t0
452 define i64 @test_x86_tbm_blcic_u64_z(i64 %a, i64 %b) nounwind {
453 ; CHECK-LABEL: test_x86_tbm_blcic_u64_z:
455 ; CHECK-NEXT: blcicq %rdi, %rax
456 ; CHECK-NEXT: cmoveq %rsi, %rax
460 %t2 = and i64 %t1, %t0
461 %t3 = icmp eq i64 %t2, 0
462 %t4 = select i1 %t3, i64 %b, i64 %t2
466 define i64 @test_x86_tbm_blcic_u64_z2(i64 %a, i64 %b, i64 %c) nounwind {
467 ; CHECK-LABEL: test_x86_tbm_blcic_u64_z2:
469 ; CHECK-NEXT: movq %rsi, %rax
470 ; CHECK-NEXT: blcicq %rdi, %rcx
471 ; CHECK-NEXT: cmovneq %rdx, %rax
475 %t2 = and i64 %t1, %t0
476 %t3 = icmp eq i64 %t2, 0
477 %t4 = select i1 %t3, i64 %b, i64 %c
481 define i64 @test_x86_tbm_blcic_u64_sle(i64 %a, i64 %b, i64 %c) nounwind {
482 ; CHECK-LABEL: test_x86_tbm_blcic_u64_sle:
484 ; CHECK-NEXT: movq %rsi, %rax
485 ; CHECK-NEXT: blcicq %rdi, %rcx
486 ; CHECK-NEXT: cmovgq %rdx, %rax
490 %t2 = and i64 %t1, %t0
491 %t3 = icmp sle i64 %t2, 0
492 %t4 = select i1 %t3, i64 %b, i64 %c
496 define i32 @test_x86_tbm_blcmsk_u32(i32 %a) nounwind {
497 ; CHECK-LABEL: test_x86_tbm_blcmsk_u32:
499 ; CHECK-NEXT: blcmskl %edi, %eax
502 %t1 = xor i32 %t0, %a
506 define i32 @test_x86_tbm_blcmsk_u32_z(i32 %a, i32 %b) nounwind {
507 ; CHECK-LABEL: test_x86_tbm_blcmsk_u32_z:
509 ; CHECK-NEXT: blcmskl %edi, %eax
510 ; CHECK-NEXT: cmovel %esi, %eax
513 %t1 = xor i32 %t0, %a
514 %t2 = icmp eq i32 %t1, 0
515 %t3 = select i1 %t2, i32 %b, i32 %t1
519 define i32 @test_x86_tbm_blcmsk_u32_z2(i32 %a, i32 %b, i32 %c) nounwind {
520 ; CHECK-LABEL: test_x86_tbm_blcmsk_u32_z2:
522 ; CHECK-NEXT: movl %esi, %eax
523 ; CHECK-NEXT: blcmskl %edi, %ecx
524 ; CHECK-NEXT: cmovnel %edx, %eax
527 %t1 = xor i32 %t0, %a
528 %t2 = icmp eq i32 %t1, 0
529 %t3 = select i1 %t2, i32 %b, i32 %c
533 define i32 @test_x86_tbm_blcmsk_u32_sle(i32 %a, i32 %b, i32 %c) nounwind {
534 ; CHECK-LABEL: test_x86_tbm_blcmsk_u32_sle:
536 ; CHECK-NEXT: movl %esi, %eax
537 ; CHECK-NEXT: blcmskl %edi, %ecx
538 ; CHECK-NEXT: cmovgl %edx, %eax
541 %t1 = xor i32 %t0, %a
542 %t2 = icmp sle i32 %t1, 0
543 %t3 = select i1 %t2, i32 %b, i32 %c
547 define i64 @test_x86_tbm_blcmsk_u64(i64 %a) nounwind {
548 ; CHECK-LABEL: test_x86_tbm_blcmsk_u64:
550 ; CHECK-NEXT: blcmskq %rdi, %rax
553 %t1 = xor i64 %t0, %a
557 define i64 @test_x86_tbm_blcmsk_u64_z(i64 %a, i64 %b) nounwind {
558 ; CHECK-LABEL: test_x86_tbm_blcmsk_u64_z:
560 ; CHECK-NEXT: blcmskq %rdi, %rax
561 ; CHECK-NEXT: cmoveq %rsi, %rax
564 %t1 = xor i64 %t0, %a
565 %t2 = icmp eq i64 %t1, 0
566 %t3 = select i1 %t2, i64 %b, i64 %t1
570 define i64 @test_x86_tbm_blcmsk_u64_z2(i64 %a, i64 %b, i64 %c) nounwind {
571 ; CHECK-LABEL: test_x86_tbm_blcmsk_u64_z2:
573 ; CHECK-NEXT: movq %rsi, %rax
574 ; CHECK-NEXT: blcmskq %rdi, %rcx
575 ; CHECK-NEXT: cmovneq %rdx, %rax
578 %t1 = xor i64 %t0, %a
579 %t2 = icmp eq i64 %t1, 0
580 %t3 = select i1 %t2, i64 %b, i64 %c
584 define i64 @test_x86_tbm_blcmsk_u64_sle(i64 %a, i64 %b, i64 %c) nounwind {
585 ; CHECK-LABEL: test_x86_tbm_blcmsk_u64_sle:
587 ; CHECK-NEXT: movq %rsi, %rax
588 ; CHECK-NEXT: blcmskq %rdi, %rcx
589 ; CHECK-NEXT: cmovgq %rdx, %rax
592 %t1 = xor i64 %t0, %a
593 %t2 = icmp sle i64 %t1, 0
594 %t3 = select i1 %t2, i64 %b, i64 %c
598 define i32 @test_x86_tbm_blcs_u32(i32 %a) nounwind {
599 ; CHECK-LABEL: test_x86_tbm_blcs_u32:
601 ; CHECK-NEXT: blcsl %edi, %eax
608 define i32 @test_x86_tbm_blcs_u32_z(i32 %a, i32 %b) nounwind {
609 ; CHECK-LABEL: test_x86_tbm_blcs_u32_z:
611 ; CHECK-NEXT: blcsl %edi, %eax
612 ; CHECK-NEXT: cmovel %esi, %eax
616 %t2 = icmp eq i32 %t1, 0
617 %t3 = select i1 %t2, i32 %b, i32 %t1
621 define i32 @test_x86_tbm_blcs_u32_z2(i32 %a, i32 %b, i32 %c) nounwind {
622 ; CHECK-LABEL: test_x86_tbm_blcs_u32_z2:
624 ; CHECK-NEXT: movl %esi, %eax
625 ; CHECK-NEXT: blcsl %edi, %ecx
626 ; CHECK-NEXT: cmovnel %edx, %eax
630 %t2 = icmp eq i32 %t1, 0
631 %t3 = select i1 %t2, i32 %b, i32 %c
635 define i32 @test_x86_tbm_blcs_u32_sle(i32 %a, i32 %b, i32 %c) nounwind {
636 ; CHECK-LABEL: test_x86_tbm_blcs_u32_sle:
638 ; CHECK-NEXT: movl %esi, %eax
639 ; CHECK-NEXT: blcsl %edi, %ecx
640 ; CHECK-NEXT: cmovgl %edx, %eax
644 %t2 = icmp sle i32 %t1, 0
645 %t3 = select i1 %t2, i32 %b, i32 %c
649 define i64 @test_x86_tbm_blcs_u64(i64 %a) nounwind {
650 ; CHECK-LABEL: test_x86_tbm_blcs_u64:
652 ; CHECK-NEXT: blcsq %rdi, %rax
659 define i64 @test_x86_tbm_blcs_u64_z(i64 %a, i64 %b) nounwind {
660 ; CHECK-LABEL: test_x86_tbm_blcs_u64_z:
662 ; CHECK-NEXT: blcsq %rdi, %rax
663 ; CHECK-NEXT: cmoveq %rsi, %rax
667 %t2 = icmp eq i64 %t1, 0
668 %t3 = select i1 %t2, i64 %b, i64 %t1
672 define i64 @test_x86_tbm_blcs_u64_z2(i64 %a, i64 %b, i64 %c) nounwind {
673 ; CHECK-LABEL: test_x86_tbm_blcs_u64_z2:
675 ; CHECK-NEXT: movq %rsi, %rax
676 ; CHECK-NEXT: blcsq %rdi, %rcx
677 ; CHECK-NEXT: cmovneq %rdx, %rax
681 %t2 = icmp eq i64 %t1, 0
682 %t3 = select i1 %t2, i64 %b, i64 %c
686 define i64 @test_x86_tbm_blcs_u64_sle(i64 %a, i64 %b, i64 %c) nounwind {
687 ; CHECK-LABEL: test_x86_tbm_blcs_u64_sle:
689 ; CHECK-NEXT: movq %rsi, %rax
690 ; CHECK-NEXT: blcsq %rdi, %rcx
691 ; CHECK-NEXT: cmovgq %rdx, %rax
695 %t2 = icmp sle i64 %t1, 0
696 %t3 = select i1 %t2, i64 %b, i64 %c
700 define i32 @test_x86_tbm_blsfill_u32(i32 %a) nounwind {
701 ; CHECK-LABEL: test_x86_tbm_blsfill_u32:
703 ; CHECK-NEXT: blsfilll %edi, %eax
710 define i32 @test_x86_tbm_blsfill_u32_z(i32 %a, i32 %b) nounwind {
711 ; CHECK-LABEL: test_x86_tbm_blsfill_u32_z:
713 ; CHECK-NEXT: blsfilll %edi, %eax
714 ; CHECK-NEXT: cmovel %esi, %eax
718 %t2 = icmp eq i32 %t1, 0
719 %t3 = select i1 %t2, i32 %b, i32 %t1
723 define i32 @test_x86_tbm_blsfill_u32_z2(i32 %a, i32 %b, i32 %c) nounwind {
724 ; CHECK-LABEL: test_x86_tbm_blsfill_u32_z2:
726 ; CHECK-NEXT: movl %esi, %eax
727 ; CHECK-NEXT: blsfilll %edi, %ecx
728 ; CHECK-NEXT: cmovnel %edx, %eax
732 %t2 = icmp eq i32 %t1, 0
733 %t3 = select i1 %t2, i32 %b, i32 %c
737 define i32 @test_x86_tbm_blsfill_u32_sle(i32 %a, i32 %b, i32 %c) nounwind {
738 ; CHECK-LABEL: test_x86_tbm_blsfill_u32_sle:
740 ; CHECK-NEXT: movl %esi, %eax
741 ; CHECK-NEXT: blsfilll %edi, %ecx
742 ; CHECK-NEXT: cmovgl %edx, %eax
746 %t2 = icmp sle i32 %t1, 0
747 %t3 = select i1 %t2, i32 %b, i32 %c
751 define i64 @test_x86_tbm_blsfill_u64(i64 %a) nounwind {
752 ; CHECK-LABEL: test_x86_tbm_blsfill_u64:
754 ; CHECK-NEXT: blsfillq %rdi, %rax
761 define i64 @test_x86_tbm_blsfill_u64_z(i64 %a, i64 %b) nounwind {
762 ; CHECK-LABEL: test_x86_tbm_blsfill_u64_z:
764 ; CHECK-NEXT: blsfillq %rdi, %rax
765 ; CHECK-NEXT: cmoveq %rsi, %rax
769 %t2 = icmp eq i64 %t1, 0
770 %t3 = select i1 %t2, i64 %b, i64 %t1
774 define i64 @test_x86_tbm_blsfill_u64_z2(i64 %a, i64 %b, i64 %c) nounwind {
775 ; CHECK-LABEL: test_x86_tbm_blsfill_u64_z2:
777 ; CHECK-NEXT: movq %rsi, %rax
778 ; CHECK-NEXT: blsfillq %rdi, %rcx
779 ; CHECK-NEXT: cmovneq %rdx, %rax
783 %t2 = icmp eq i64 %t1, 0
784 %t3 = select i1 %t2, i64 %b, i64 %c
788 define i64 @test_x86_tbm_blsfill_u64_sle(i64 %a, i64 %b, i64 %c) nounwind {
789 ; CHECK-LABEL: test_x86_tbm_blsfill_u64_sle:
791 ; CHECK-NEXT: movq %rsi, %rax
792 ; CHECK-NEXT: blsfillq %rdi, %rcx
793 ; CHECK-NEXT: cmovgq %rdx, %rax
797 %t2 = icmp sle i64 %t1, 0
798 %t3 = select i1 %t2, i64 %b, i64 %c
802 define i32 @test_x86_tbm_blsic_u32(i32 %a) nounwind {
803 ; CHECK-LABEL: test_x86_tbm_blsic_u32:
805 ; CHECK-NEXT: blsicl %edi, %eax
809 %t2 = or i32 %t0, %t1
813 define i32 @test_x86_tbm_blsic_u32_z(i32 %a, i32 %b) nounwind {
814 ; CHECK-LABEL: test_x86_tbm_blsic_u32_z:
816 ; CHECK-NEXT: blsicl %edi, %eax
817 ; CHECK-NEXT: cmovel %esi, %eax
821 %t2 = or i32 %t0, %t1
822 %t3 = icmp eq i32 %t2, 0
823 %t4 = select i1 %t3, i32 %b, i32 %t2
827 define i32 @test_x86_tbm_blsic_u32_z2(i32 %a, i32 %b, i32 %c) nounwind {
828 ; CHECK-LABEL: test_x86_tbm_blsic_u32_z2:
830 ; CHECK-NEXT: movl %esi, %eax
831 ; CHECK-NEXT: blsicl %edi, %ecx
832 ; CHECK-NEXT: cmovnel %edx, %eax
836 %t2 = or i32 %t0, %t1
837 %t3 = icmp eq i32 %t2, 0
838 %t4 = select i1 %t3, i32 %b, i32 %c
842 define i32 @test_x86_tbm_blsic_u32_sle(i32 %a, i32 %b, i32 %c) nounwind {
843 ; CHECK-LABEL: test_x86_tbm_blsic_u32_sle:
845 ; CHECK-NEXT: movl %esi, %eax
846 ; CHECK-NEXT: blsicl %edi, %ecx
847 ; CHECK-NEXT: cmovgl %edx, %eax
851 %t2 = or i32 %t0, %t1
852 %t3 = icmp sle i32 %t2, 0
853 %t4 = select i1 %t3, i32 %b, i32 %c
857 define i64 @test_x86_tbm_blsic_u64(i64 %a) nounwind {
858 ; CHECK-LABEL: test_x86_tbm_blsic_u64:
860 ; CHECK-NEXT: blsicq %rdi, %rax
864 %t2 = or i64 %t0, %t1
868 define i64 @test_x86_tbm_blsic_u64_z(i64 %a, i64 %b) nounwind {
869 ; CHECK-LABEL: test_x86_tbm_blsic_u64_z:
871 ; CHECK-NEXT: blsicq %rdi, %rax
872 ; CHECK-NEXT: cmoveq %rsi, %rax
876 %t2 = or i64 %t0, %t1
877 %t3 = icmp eq i64 %t2, 0
878 %t4 = select i1 %t3, i64 %b, i64 %t2
882 define i64 @test_x86_tbm_blsic_u64_z2(i64 %a, i64 %b, i64 %c) nounwind {
883 ; CHECK-LABEL: test_x86_tbm_blsic_u64_z2:
885 ; CHECK-NEXT: movq %rsi, %rax
886 ; CHECK-NEXT: blsicq %rdi, %rcx
887 ; CHECK-NEXT: cmovneq %rdx, %rax
891 %t2 = or i64 %t0, %t1
892 %t3 = icmp eq i64 %t2, 0
893 %t4 = select i1 %t3, i64 %b, i64 %c
897 define i64 @test_x86_tbm_blsic_u64_sle(i64 %a, i64 %b, i64 %c) nounwind {
898 ; CHECK-LABEL: test_x86_tbm_blsic_u64_sle:
900 ; CHECK-NEXT: movq %rsi, %rax
901 ; CHECK-NEXT: blsicq %rdi, %rcx
902 ; CHECK-NEXT: cmovgq %rdx, %rax
906 %t2 = or i64 %t0, %t1
907 %t3 = icmp sle i64 %t2, 0
908 %t4 = select i1 %t3, i64 %b, i64 %c
912 define i32 @test_x86_tbm_t1mskc_u32(i32 %a) nounwind {
913 ; CHECK-LABEL: test_x86_tbm_t1mskc_u32:
915 ; CHECK-NEXT: t1mskcl %edi, %eax
919 %t2 = or i32 %t0, %t1
923 define i32 @test_x86_tbm_t1mskc_u32_z(i32 %a, i32 %b) nounwind {
924 ; CHECK-LABEL: test_x86_tbm_t1mskc_u32_z:
926 ; CHECK-NEXT: t1mskcl %edi, %eax
927 ; CHECK-NEXT: cmovel %esi, %eax
931 %t2 = or i32 %t0, %t1
932 %t3 = icmp eq i32 %t2, 0
933 %t4 = select i1 %t3, i32 %b, i32 %t2
937 define i32 @test_x86_tbm_t1mskc_u32_z2(i32 %a, i32 %b, i32 %c) nounwind {
938 ; CHECK-LABEL: test_x86_tbm_t1mskc_u32_z2:
940 ; CHECK-NEXT: movl %esi, %eax
941 ; CHECK-NEXT: t1mskcl %edi, %ecx
942 ; CHECK-NEXT: cmovnel %edx, %eax
946 %t2 = or i32 %t0, %t1
947 %t3 = icmp eq i32 %t2, 0
948 %t4 = select i1 %t3, i32 %b, i32 %c
952 define i32 @test_x86_tbm_t1mskc_u32_sle(i32 %a, i32 %b, i32 %c) nounwind {
953 ; CHECK-LABEL: test_x86_tbm_t1mskc_u32_sle:
955 ; CHECK-NEXT: movl %esi, %eax
956 ; CHECK-NEXT: t1mskcl %edi, %ecx
957 ; CHECK-NEXT: cmovgl %edx, %eax
961 %t2 = or i32 %t0, %t1
962 %t3 = icmp sle i32 %t2, 0
963 %t4 = select i1 %t3, i32 %b, i32 %c
967 define i64 @test_x86_tbm_t1mskc_u64(i64 %a) nounwind {
968 ; CHECK-LABEL: test_x86_tbm_t1mskc_u64:
970 ; CHECK-NEXT: t1mskcq %rdi, %rax
974 %t2 = or i64 %t0, %t1
978 define i64 @test_x86_tbm_t1mskc_u64_z(i64 %a, i64 %b) nounwind {
979 ; CHECK-LABEL: test_x86_tbm_t1mskc_u64_z:
981 ; CHECK-NEXT: t1mskcq %rdi, %rax
982 ; CHECK-NEXT: cmoveq %rsi, %rax
986 %t2 = or i64 %t0, %t1
987 %t3 = icmp eq i64 %t2, 0
988 %t4 = select i1 %t3, i64 %b, i64 %t2
992 define i64 @test_x86_tbm_t1mskc_u64_z2(i64 %a, i64 %b, i64 %c) nounwind {
993 ; CHECK-LABEL: test_x86_tbm_t1mskc_u64_z2:
995 ; CHECK-NEXT: movq %rsi, %rax
996 ; CHECK-NEXT: t1mskcq %rdi, %rcx
997 ; CHECK-NEXT: cmovneq %rdx, %rax
1001 %t2 = or i64 %t0, %t1
1002 %t3 = icmp eq i64 %t2, 0
1003 %t4 = select i1 %t3, i64 %b, i64 %c
1007 define i64 @test_x86_tbm_t1mskc_u64_sle(i64 %a, i64 %b, i64 %c) nounwind {
1008 ; CHECK-LABEL: test_x86_tbm_t1mskc_u64_sle:
1010 ; CHECK-NEXT: movq %rsi, %rax
1011 ; CHECK-NEXT: t1mskcq %rdi, %rcx
1012 ; CHECK-NEXT: cmovgq %rdx, %rax
1014 %t0 = xor i64 %a, -1
1016 %t2 = or i64 %t0, %t1
1017 %t3 = icmp sle i64 %t2, 0
1018 %t4 = select i1 %t3, i64 %b, i64 %c
1022 define i32 @test_x86_tbm_tzmsk_u32(i32 %a) nounwind {
1023 ; CHECK-LABEL: test_x86_tbm_tzmsk_u32:
1025 ; CHECK-NEXT: tzmskl %edi, %eax
1027 %t0 = xor i32 %a, -1
1028 %t1 = add i32 %a, -1
1029 %t2 = and i32 %t0, %t1
1033 define i32 @test_x86_tbm_tzmsk_u32_z(i32 %a, i32 %b) nounwind {
1034 ; CHECK-LABEL: test_x86_tbm_tzmsk_u32_z:
1036 ; CHECK-NEXT: tzmskl %edi, %eax
1037 ; CHECK-NEXT: cmovel %esi, %eax
1039 %t0 = xor i32 %a, -1
1040 %t1 = add i32 %a, -1
1041 %t2 = and i32 %t0, %t1
1042 %t3 = icmp eq i32 %t2, 0
1043 %t4 = select i1 %t3, i32 %b, i32 %t2
1047 define i32 @test_x86_tbm_tzmsk_u32_z2(i32 %a, i32 %b, i32 %c) nounwind {
1048 ; CHECK-LABEL: test_x86_tbm_tzmsk_u32_z2:
1050 ; CHECK-NEXT: movl %esi, %eax
1051 ; CHECK-NEXT: tzmskl %edi, %ecx
1052 ; CHECK-NEXT: cmovnel %edx, %eax
1054 %t0 = xor i32 %a, -1
1055 %t1 = add i32 %a, -1
1056 %t2 = and i32 %t0, %t1
1057 %t3 = icmp eq i32 %t2, 0
1058 %t4 = select i1 %t3, i32 %b, i32 %c
1062 define i32 @test_x86_tbm_tzmsk_u32_sle(i32 %a, i32 %b, i32 %c) nounwind {
1063 ; CHECK-LABEL: test_x86_tbm_tzmsk_u32_sle:
1065 ; CHECK-NEXT: movl %esi, %eax
1066 ; CHECK-NEXT: tzmskl %edi, %ecx
1067 ; CHECK-NEXT: cmovgl %edx, %eax
1069 %t0 = xor i32 %a, -1
1070 %t1 = add i32 %a, -1
1071 %t2 = and i32 %t0, %t1
1072 %t3 = icmp sle i32 %t2, 0
1073 %t4 = select i1 %t3, i32 %b, i32 %c
1077 define i64 @test_x86_tbm_tzmsk_u64(i64 %a) nounwind {
1078 ; CHECK-LABEL: test_x86_tbm_tzmsk_u64:
1080 ; CHECK-NEXT: tzmskq %rdi, %rax
1082 %t0 = xor i64 %a, -1
1083 %t1 = add i64 %a, -1
1084 %t2 = and i64 %t0, %t1
1088 define i64 @test_x86_tbm_tzmsk_u64_z(i64 %a, i64 %b) nounwind {
1089 ; CHECK-LABEL: test_x86_tbm_tzmsk_u64_z:
1091 ; CHECK-NEXT: tzmskq %rdi, %rax
1092 ; CHECK-NEXT: cmoveq %rsi, %rax
1094 %t0 = xor i64 %a, -1
1095 %t1 = add i64 %a, -1
1096 %t2 = and i64 %t0, %t1
1097 %t3 = icmp eq i64 %t2, 0
1098 %t4 = select i1 %t3, i64 %b, i64 %t2
1102 define i64 @test_x86_tbm_tzmsk_u64_z2(i64 %a, i64 %b, i64 %c) nounwind {
1103 ; CHECK-LABEL: test_x86_tbm_tzmsk_u64_z2:
1105 ; CHECK-NEXT: movq %rsi, %rax
1106 ; CHECK-NEXT: tzmskq %rdi, %rcx
1107 ; CHECK-NEXT: cmovneq %rdx, %rax
1109 %t0 = xor i64 %a, -1
1110 %t1 = add i64 %a, -1
1111 %t2 = and i64 %t0, %t1
1112 %t3 = icmp eq i64 %t2, 0
1113 %t4 = select i1 %t3, i64 %b, i64 %c
1117 define i64 @test_x86_tbm_tzmsk_u64_sle(i64 %a, i64 %b, i64 %c) nounwind {
1118 ; CHECK-LABEL: test_x86_tbm_tzmsk_u64_sle:
1120 ; CHECK-NEXT: movq %rsi, %rax
1121 ; CHECK-NEXT: tzmskq %rdi, %rcx
1122 ; CHECK-NEXT: cmovgq %rdx, %rax
1124 %t0 = xor i64 %a, -1
1125 %t1 = add i64 %a, -1
1126 %t2 = and i64 %t0, %t1
1127 %t3 = icmp sle i64 %t2, 0
1128 %t4 = select i1 %t3, i64 %b, i64 %c
1132 define i64 @test_and_large_constant_mask(i64 %x) {
1133 ; CHECK-LABEL: test_and_large_constant_mask:
1134 ; CHECK: # %bb.0: # %entry
1135 ; CHECK-NEXT: bextrq $15872, %rdi, %rax # imm = 0x3E00
1138 %and = and i64 %x, 4611686018427387903
1142 define i64 @test_and_large_constant_mask_load(ptr %x) {
1143 ; CHECK-LABEL: test_and_large_constant_mask_load:
1144 ; CHECK: # %bb.0: # %entry
1145 ; CHECK-NEXT: bextrq $15872, (%rdi), %rax # imm = 0x3E00
1148 %x1 = load i64, ptr %x
1149 %and = and i64 %x1, 4611686018427387903
1153 ; Make sure the mask doesn't break our matching of blcic
1154 define i64 @masked_blcic(i64) {
1155 ; CHECK-LABEL: masked_blcic:
1157 ; CHECK-NEXT: movzwl %di, %eax
1158 ; CHECK-NEXT: blcicl %eax, %eax
1160 %2 = and i64 %0, 65535
1162 %4 = add nuw nsw i64 %2, 1
1167 define i32 @blcic32_branch(i32 %x) nounwind {
1168 ; CHECK-LABEL: blcic32_branch:
1170 ; CHECK-NEXT: pushq %rbx
1171 ; CHECK-NEXT: blcicl %edi, %ebx
1172 ; CHECK-NEXT: jne .LBB89_2
1173 ; CHECK-NEXT: # %bb.1:
1174 ; CHECK-NEXT: callq bar@PLT
1175 ; CHECK-NEXT: .LBB89_2:
1176 ; CHECK-NEXT: movl %ebx, %eax
1177 ; CHECK-NEXT: popq %rbx
1179 %tmp = xor i32 %x, -1
1180 %tmp2 = add i32 %x, 1
1181 %tmp3 = and i32 %tmp, %tmp2
1182 %cmp = icmp eq i32 %tmp3, 0
1183 br i1 %cmp, label %1, label %2
1185 tail call void @bar()
1190 define i64 @blcic64_branch(i64 %x) nounwind {
1191 ; CHECK-LABEL: blcic64_branch:
1193 ; CHECK-NEXT: pushq %rbx
1194 ; CHECK-NEXT: blcicq %rdi, %rbx
1195 ; CHECK-NEXT: jne .LBB90_2
1196 ; CHECK-NEXT: # %bb.1:
1197 ; CHECK-NEXT: callq bar@PLT
1198 ; CHECK-NEXT: .LBB90_2:
1199 ; CHECK-NEXT: movq %rbx, %rax
1200 ; CHECK-NEXT: popq %rbx
1202 %tmp = xor i64 %x, -1
1203 %tmp2 = add i64 %x, 1
1204 %tmp3 = and i64 %tmp, %tmp2
1205 %cmp = icmp eq i64 %tmp3, 0
1206 br i1 %cmp, label %1, label %2
1208 tail call void @bar()
1213 define i32 @tzmsk32_branch(i32 %x) nounwind {
1214 ; CHECK-LABEL: tzmsk32_branch:
1216 ; CHECK-NEXT: pushq %rbx
1217 ; CHECK-NEXT: tzmskl %edi, %ebx
1218 ; CHECK-NEXT: jne .LBB91_2
1219 ; CHECK-NEXT: # %bb.1:
1220 ; CHECK-NEXT: callq bar@PLT
1221 ; CHECK-NEXT: .LBB91_2:
1222 ; CHECK-NEXT: movl %ebx, %eax
1223 ; CHECK-NEXT: popq %rbx
1225 %tmp = xor i32 %x, -1
1226 %tmp2 = add i32 %x, -1
1227 %tmp3 = and i32 %tmp, %tmp2
1228 %cmp = icmp eq i32 %tmp3, 0
1229 br i1 %cmp, label %1, label %2
1231 tail call void @bar()
1236 define i64 @tzmsk64_branch(i64 %x) nounwind {
1237 ; CHECK-LABEL: tzmsk64_branch:
1239 ; CHECK-NEXT: pushq %rbx
1240 ; CHECK-NEXT: tzmskq %rdi, %rbx
1241 ; CHECK-NEXT: jne .LBB92_2
1242 ; CHECK-NEXT: # %bb.1:
1243 ; CHECK-NEXT: callq bar@PLT
1244 ; CHECK-NEXT: .LBB92_2:
1245 ; CHECK-NEXT: movq %rbx, %rax
1246 ; CHECK-NEXT: popq %rbx
1248 %tmp = xor i64 %x, -1
1249 %tmp2 = add i64 %x, -1
1250 %tmp3 = and i64 %tmp, %tmp2
1251 %cmp = icmp eq i64 %tmp3, 0
1252 br i1 %cmp, label %1, label %2
1254 tail call void @bar()
1259 define i32 @blcfill32_branch(i32 %x) nounwind {
1260 ; CHECK-LABEL: blcfill32_branch:
1262 ; CHECK-NEXT: pushq %rbx
1263 ; CHECK-NEXT: blcfilll %edi, %ebx
1264 ; CHECK-NEXT: jne .LBB93_2
1265 ; CHECK-NEXT: # %bb.1:
1266 ; CHECK-NEXT: callq bar@PLT
1267 ; CHECK-NEXT: .LBB93_2:
1268 ; CHECK-NEXT: movl %ebx, %eax
1269 ; CHECK-NEXT: popq %rbx
1271 %tmp2 = add i32 %x, 1
1272 %tmp3 = and i32 %tmp2, %x
1273 %cmp = icmp eq i32 %tmp3, 0
1274 br i1 %cmp, label %1, label %2
1276 tail call void @bar()
1281 define i64 @blcfill64_branch(i64 %x) nounwind {
1282 ; CHECK-LABEL: blcfill64_branch:
1284 ; CHECK-NEXT: pushq %rbx
1285 ; CHECK-NEXT: blcfillq %rdi, %rbx
1286 ; CHECK-NEXT: jne .LBB94_2
1287 ; CHECK-NEXT: # %bb.1:
1288 ; CHECK-NEXT: callq bar@PLT
1289 ; CHECK-NEXT: .LBB94_2:
1290 ; CHECK-NEXT: movq %rbx, %rax
1291 ; CHECK-NEXT: popq %rbx
1293 %tmp2 = add i64 %x, 1
1294 %tmp3 = and i64 %tmp2, %x
1295 %cmp = icmp eq i64 %tmp3, 0
1296 br i1 %cmp, label %1, label %2
1298 tail call void @bar()