1 // RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-unknown -target-feature +tbm -emit-llvm -o - | FileCheck %s
2
3 #include <x86intrin.h>
4
5 // NOTE: This should match the tests in llvm/test/CodeGen/X86/tbm-intrinsics-fast-isel.ll
6
test__bextri_u32(unsigned int a)7 unsigned int test__bextri_u32(unsigned int a) {
8 // CHECK-LABEL: test__bextri_u32
9 // CHECK: call i32 @llvm.x86.tbm.bextri.u32(i32 %{{.*}}, i32 1)
10 return __bextri_u32(a, 1);
11 }
12
13 #ifdef __x86_64__
test__bextri_u64(unsigned long long a)14 unsigned long long test__bextri_u64(unsigned long long a) {
15 // CHECK-LABEL: test__bextri_u64
16 // CHECK: call i64 @llvm.x86.tbm.bextri.u64(i64 %{{.*}}, i64 2)
17 return __bextri_u64(a, 2);
18 }
19
test__bextri_u64_bigint(unsigned long long a)20 unsigned long long test__bextri_u64_bigint(unsigned long long a) {
21 // CHECK-LABEL: test__bextri_u64_bigint
22 // CHECK: call i64 @llvm.x86.tbm.bextri.u64(i64 %{{.*}}, i64 549755813887)
23 return __bextri_u64(a, 0x7fffffffffLL);
24 }
25 #endif
26
test__blcfill_u32(unsigned int a)27 unsigned int test__blcfill_u32(unsigned int a) {
28 // CHECK-LABEL: test__blcfill_u32
29 // CHECK: [[TMP:%.*]] = add i32 %{{.*}}, 1
30 // CHECK: %{{.*}} = and i32 %{{.*}}, [[TMP]]
31 return __blcfill_u32(a);
32 }
33
34 #ifdef __x86_64__
test__blcfill_u64(unsigned long long a)35 unsigned long long test__blcfill_u64(unsigned long long a) {
36 // CHECK-LABEL: test__blcfill_u64
37 // CHECK: [[TMP:%.*]] = add i64 %{{.*}}, 1
38 // CHECK: %{{.*}} = and i64 %{{.*}}, [[TMP]]
39 return __blcfill_u64(a);
40 }
41 #endif
42
test__blci_u32(unsigned int a)43 unsigned int test__blci_u32(unsigned int a) {
44 // CHECK-LABEL: test__blci_u32
45 // CHECK: [[TMP1:%.*]] = add i32 %{{.*}}, 1
46 // CHECK: [[TMP2:%.*]] = xor i32 [[TMP1]], -1
47 // CHECK: %{{.*}} = or i32 %{{.*}}, [[TMP2]]
48 return __blci_u32(a);
49 }
50
51 #ifdef __x86_64__
test__blci_u64(unsigned long long a)52 unsigned long long test__blci_u64(unsigned long long a) {
53 // CHECK-LABEL: test__blci_u64
54 // CHECK: [[TMP1:%.*]] = add i64 %{{.*}}, 1
55 // CHECK: [[TMP2:%.*]] = xor i64 [[TMP1]], -1
56 // CHECK: %{{.*}} = or i64 %{{.*}}, [[TMP2]]
57 return __blci_u64(a);
58 }
59 #endif
60
test__blcic_u32(unsigned int a)61 unsigned int test__blcic_u32(unsigned int a) {
62 // CHECK-LABEL: test__blcic_u32
63 // CHECK: [[TMP1:%.*]] = xor i32 %{{.*}}, -1
64 // CHECK: [[TMP2:%.*]] = add i32 %{{.*}}, 1
65 // CHECK-NEXT: {{.*}} = and i32 [[TMP1]], [[TMP2]]
66 return __blcic_u32(a);
67 }
68
69 #ifdef __x86_64__
test__blcic_u64(unsigned long long a)70 unsigned long long test__blcic_u64(unsigned long long a) {
71 // CHECK-LABEL: test__blcic_u64
72 // CHECK: [[TMP1:%.*]] = xor i64 %{{.*}}, -1
73 // CHECK: [[TMP2:%.*]] = add i64 %{{.*}}, 1
74 // CHECK-NEXT: {{.*}} = and i64 [[TMP1]], [[TMP2]]
75 return __blcic_u64(a);
76 }
77 #endif
78
test__blcmsk_u32(unsigned int a)79 unsigned int test__blcmsk_u32(unsigned int a) {
80 // CHECK-LABEL: test__blcmsk_u32
81 // CHECK: [[TMP:%.*]] = add i32 %{{.*}}, 1
82 // CHECK-NEXT: {{.*}} = xor i32 %{{.*}}, [[TMP]]
83 return __blcmsk_u32(a);
84 }
85
86 #ifdef __x86_64__
test__blcmsk_u64(unsigned long long a)87 unsigned long long test__blcmsk_u64(unsigned long long a) {
88 // CHECK-LABEL: test__blcmsk_u64
89 // CHECK: [[TMP:%.*]] = add i64 %{{.*}}, 1
90 // CHECK-NEXT: {{.*}} = xor i64 %{{.*}}, [[TMP]]
91 return __blcmsk_u64(a);
92 }
93 #endif
94
test__blcs_u32(unsigned int a)95 unsigned int test__blcs_u32(unsigned int a) {
96 // CHECK-LABEL: test__blcs_u32
97 // CHECK: [[TMP:%.*]] = add i32 %{{.*}}, 1
98 // CHECK-NEXT: {{.*}} = or i32 %{{.*}}, [[TMP]]
99 return __blcs_u32(a);
100 }
101
102 #ifdef __x86_64__
test__blcs_u64(unsigned long long a)103 unsigned long long test__blcs_u64(unsigned long long a) {
104 // CHECK-LABEL: test__blcs_u64
105 // CHECK: [[TMP:%.*]] = add i64 %{{.*}}, 1
106 // CHECK-NEXT: {{.*}} = or i64 %{{.*}}, [[TMP]]
107 return __blcs_u64(a);
108 }
109 #endif
110
test__blsfill_u32(unsigned int a)111 unsigned int test__blsfill_u32(unsigned int a) {
112 // CHECK-LABEL: test__blsfill_u32
113 // CHECK: [[TMP:%.*]] = sub i32 %{{.*}}, 1
114 // CHECK-NEXT: {{.*}} = or i32 %{{.*}}, [[TMP]]
115 return __blsfill_u32(a);
116 }
117
118 #ifdef __x86_64__
test__blsfill_u64(unsigned long long a)119 unsigned long long test__blsfill_u64(unsigned long long a) {
120 // CHECK-LABEL: test__blsfill_u64
121 // CHECK: [[TMP:%.*]] = sub i64 %{{.*}}, 1
122 // CHECK-NEXT: {{.*}} = or i64 %{{.*}}, [[TMP]]
123 return __blsfill_u64(a);
124 }
125 #endif
126
test__blsic_u32(unsigned int a)127 unsigned int test__blsic_u32(unsigned int a) {
128 // CHECK-LABEL: test__blsic_u32
129 // CHECK: [[TMP1:%.*]] = xor i32 %{{.*}}, -1
130 // CHECK: [[TMP2:%.*]] = sub i32 %{{.*}}, 1
131 // CHECK-NEXT: {{.*}} = or i32 [[TMP1]], [[TMP2]]
132 return __blsic_u32(a);
133 }
134
135 #ifdef __x86_64__
test__blsic_u64(unsigned long long a)136 unsigned long long test__blsic_u64(unsigned long long a) {
137 // CHECK-LABEL: test__blsic_u64
138 // CHECK: [[TMP1:%.*]] = xor i64 %{{.*}}, -1
139 // CHECK: [[TMP2:%.*]] = sub i64 %{{.*}}, 1
140 // CHECK-NEXT: {{.*}} = or i64 [[TMP1]], [[TMP2]]
141 return __blsic_u64(a);
142 }
143 #endif
144
test__t1mskc_u32(unsigned int a)145 unsigned int test__t1mskc_u32(unsigned int a) {
146 // CHECK-LABEL: test__t1mskc_u32
147 // CHECK: [[TMP1:%.*]] = xor i32 %{{.*}}, -1
148 // CHECK: [[TMP2:%.*]] = add i32 %{{.*}}, 1
149 // CHECK-NEXT: {{.*}} = or i32 [[TMP1]], [[TMP2]]
150 return __t1mskc_u32(a);
151 }
152
153 #ifdef __x86_64__
test__t1mskc_u64(unsigned long long a)154 unsigned long long test__t1mskc_u64(unsigned long long a) {
155 // CHECK-LABEL: test__t1mskc_u64
156 // CHECK: [[TMP1:%.*]] = xor i64 %{{.*}}, -1
157 // CHECK: [[TMP2:%.*]] = add i64 %{{.*}}, 1
158 // CHECK-NEXT: {{.*}} = or i64 [[TMP1]], [[TMP2]]
159 return __t1mskc_u64(a);
160 }
161 #endif
162
test__tzmsk_u32(unsigned int a)163 unsigned int test__tzmsk_u32(unsigned int a) {
164 // CHECK-LABEL: test__tzmsk_u32
165 // CHECK: [[TMP1:%.*]] = xor i32 %{{.*}}, -1
166 // CHECK: [[TMP2:%.*]] = sub i32 %{{.*}}, 1
167 // CHECK-NEXT: {{.*}} = and i32 [[TMP1]], [[TMP2]]
168 return __tzmsk_u32(a);
169 }
170
171 #ifdef __x86_64__
test__tzmsk_u64(unsigned long long a)172 unsigned long long test__tzmsk_u64(unsigned long long a) {
173 // CHECK-LABEL: test__tzmsk_u64
174 // CHECK: [[TMP1:%.*]] = xor i64 %{{.*}}, -1
175 // CHECK: [[TMP2:%.*]] = sub i64 %{{.*}}, 1
176 // CHECK-NEXT: {{.*}} = and i64 [[TMP1]], [[TMP2]]
177 return __tzmsk_u64(a);
178 }
179 #endif
180