1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -fast-isel -mtriple=x86_64-unknown-unknown -mattr=+bmi | FileCheck %s --check-prefix=X64
4 ; NOTE: This should use IR equivalent to what is generated by clang/test/CodeGen/bmi-builtins.c
10 define i64 @test__andn_u64(i64 %a0, i64 %a1) {
11 ; X64-LABEL: test__andn_u64:
13 ; X64-NEXT: movq %rdi, %rax
14 ; X64-NEXT: xorq $-1, %rax
15 ; X64-NEXT: andq %rsi, %rax
17 %xor = xor i64 %a0, -1
18 %res = and i64 %xor, %a1
22 define i64 @test__bextr_u64(i64 %a0, i64 %a1) {
23 ; X64-LABEL: test__bextr_u64:
25 ; X64-NEXT: bextrq %rsi, %rdi, %rax
27 %res = call i64 @llvm.x86.bmi.bextr.64(i64 %a0, i64 %a1)
31 define i64 @test__blsi_u64(i64 %a0) {
32 ; X64-LABEL: test__blsi_u64:
34 ; X64-NEXT: xorl %eax, %eax
35 ; X64-NEXT: subq %rdi, %rax
36 ; X64-NEXT: andq %rdi, %rax
39 %res = and i64 %a0, %neg
43 define i64 @test__blsmsk_u64(i64 %a0) {
44 ; X64-LABEL: test__blsmsk_u64:
46 ; X64-NEXT: leaq -1(%rdi), %rax
47 ; X64-NEXT: xorq %rdi, %rax
50 %res = xor i64 %a0, %dec
54 define i64 @test__blsr_u64(i64 %a0) {
55 ; X64-LABEL: test__blsr_u64:
57 ; X64-NEXT: leaq -1(%rdi), %rax
58 ; X64-NEXT: andq %rdi, %rax
61 %res = and i64 %a0, %dec
65 define i64 @test__tzcnt_u64(i64 %a0) {
66 ; X64-LABEL: test__tzcnt_u64:
68 ; X64-NEXT: tzcntq %rdi, %rax
70 %cmp = icmp ne i64 %a0, 0
71 %cttz = call i64 @llvm.cttz.i64(i64 %a0, i1 false)
79 define i64 @test_andn_u64(i64 %a0, i64 %a1) {
80 ; X64-LABEL: test_andn_u64:
82 ; X64-NEXT: movq %rdi, %rax
83 ; X64-NEXT: xorq $-1, %rax
84 ; X64-NEXT: andq %rsi, %rax
86 %xor = xor i64 %a0, -1
87 %res = and i64 %xor, %a1
91 define i64 @test_bextr_u64(i64 %a0, i32 %a1, i32 %a2) {
92 ; X64-LABEL: test_bextr_u64:
94 ; X64-NEXT: andl $255, %esi
95 ; X64-NEXT: andl $255, %edx
96 ; X64-NEXT: shll $8, %edx
97 ; X64-NEXT: orl %esi, %edx
98 ; X64-NEXT: movl %edx, %eax
99 ; X64-NEXT: bextrq %rax, %rdi, %rax
101 %and1 = and i32 %a1, 255
102 %and2 = and i32 %a2, 255
103 %shl = shl i32 %and2, 8
104 %or = or i32 %and1, %shl
105 %zext = zext i32 %or to i64
106 %res = call i64 @llvm.x86.bmi.bextr.64(i64 %a0, i64 %zext)
110 define i64 @test_blsi_u64(i64 %a0) {
111 ; X64-LABEL: test_blsi_u64:
113 ; X64-NEXT: xorl %eax, %eax
114 ; X64-NEXT: subq %rdi, %rax
115 ; X64-NEXT: andq %rdi, %rax
117 %neg = sub i64 0, %a0
118 %res = and i64 %a0, %neg
122 define i64 @test_blsmsk_u64(i64 %a0) {
123 ; X64-LABEL: test_blsmsk_u64:
125 ; X64-NEXT: leaq -1(%rdi), %rax
126 ; X64-NEXT: xorq %rdi, %rax
128 %dec = sub i64 %a0, 1
129 %res = xor i64 %a0, %dec
133 define i64 @test_blsr_u64(i64 %a0) {
134 ; X64-LABEL: test_blsr_u64:
136 ; X64-NEXT: leaq -1(%rdi), %rax
137 ; X64-NEXT: andq %rdi, %rax
139 %dec = sub i64 %a0, 1
140 %res = and i64 %a0, %dec
144 define i64 @test_tzcnt_u64(i64 %a0) {
145 ; X64-LABEL: test_tzcnt_u64:
147 ; X64-NEXT: tzcntq %rdi, %rax
149 %cmp = icmp ne i64 %a0, 0
150 %cttz = call i64 @llvm.cttz.i64(i64 %a0, i1 false)
154 declare i64 @llvm.cttz.i64(i64, i1)
155 declare i64 @llvm.x86.bmi.bextr.64(i64, i64)