[MLIR][TOSA] Update CustomOp input and output names (#118408)
[llvm-project.git] / clang / test / CodeGen / X86 / tbm-builtins.c
blobd916627a23f5711776fc14b4ec1d7a3895c23d1e
1 // RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-unknown-unknown -target-feature +tbm -emit-llvm -o - | FileCheck %s
2 // RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding %s -triple=x86_64-unknown-unknown -target-feature +tbm -emit-llvm -o - | FileCheck %s
4 #include <x86intrin.h>
6 // NOTE: This should match the tests in llvm/test/CodeGen/X86/tbm-intrinsics-fast-isel.ll
8 unsigned int test__bextri_u32(unsigned int a) {
9 // CHECK-LABEL: test__bextri_u32
10 // CHECK: call i32 @llvm.x86.tbm.bextri.u32(i32 %{{.*}}, i32 1)
11 return __bextri_u32(a, 1);
14 #ifdef __x86_64__
15 unsigned long long test__bextri_u64(unsigned long long a) {
16 // CHECK-LABEL: test__bextri_u64
17 // CHECK: call i64 @llvm.x86.tbm.bextri.u64(i64 %{{.*}}, i64 2)
18 return __bextri_u64(a, 2);
21 unsigned long long test__bextri_u64_bigint(unsigned long long a) {
22 // CHECK-LABEL: test__bextri_u64_bigint
23 // CHECK: call i64 @llvm.x86.tbm.bextri.u64(i64 %{{.*}}, i64 549755813887)
24 return __bextri_u64(a, 0x7fffffffffLL);
26 #endif
28 unsigned int test__blcfill_u32(unsigned int a) {
29 // CHECK-LABEL: test__blcfill_u32
30 // CHECK: [[TMP:%.*]] = add i32 %{{.*}}, 1
31 // CHECK: %{{.*}} = and i32 %{{.*}}, [[TMP]]
32 return __blcfill_u32(a);
35 #ifdef __x86_64__
36 unsigned long long test__blcfill_u64(unsigned long long a) {
37 // CHECK-LABEL: test__blcfill_u64
38 // CHECK: [[TMP:%.*]] = add i64 %{{.*}}, 1
39 // CHECK: %{{.*}} = and i64 %{{.*}}, [[TMP]]
40 return __blcfill_u64(a);
42 #endif
44 unsigned int test__blci_u32(unsigned int a) {
45 // CHECK-LABEL: test__blci_u32
46 // CHECK: [[TMP1:%.*]] = add i32 %{{.*}}, 1
47 // CHECK: [[TMP2:%.*]] = xor i32 [[TMP1]], -1
48 // CHECK: %{{.*}} = or i32 %{{.*}}, [[TMP2]]
49 return __blci_u32(a);
52 #ifdef __x86_64__
53 unsigned long long test__blci_u64(unsigned long long a) {
54 // CHECK-LABEL: test__blci_u64
55 // CHECK: [[TMP1:%.*]] = add i64 %{{.*}}, 1
56 // CHECK: [[TMP2:%.*]] = xor i64 [[TMP1]], -1
57 // CHECK: %{{.*}} = or i64 %{{.*}}, [[TMP2]]
58 return __blci_u64(a);
60 #endif
62 unsigned int test__blcic_u32(unsigned int a) {
63 // CHECK-LABEL: test__blcic_u32
64 // CHECK: [[TMP1:%.*]] = xor i32 %{{.*}}, -1
65 // CHECK: [[TMP2:%.*]] = add i32 %{{.*}}, 1
66 // CHECK-NEXT: {{.*}} = and i32 [[TMP1]], [[TMP2]]
67 return __blcic_u32(a);
70 #ifdef __x86_64__
71 unsigned long long test__blcic_u64(unsigned long long a) {
72 // CHECK-LABEL: test__blcic_u64
73 // CHECK: [[TMP1:%.*]] = xor i64 %{{.*}}, -1
74 // CHECK: [[TMP2:%.*]] = add i64 %{{.*}}, 1
75 // CHECK-NEXT: {{.*}} = and i64 [[TMP1]], [[TMP2]]
76 return __blcic_u64(a);
78 #endif
80 unsigned int test__blcmsk_u32(unsigned int a) {
81 // CHECK-LABEL: test__blcmsk_u32
82 // CHECK: [[TMP:%.*]] = add i32 %{{.*}}, 1
83 // CHECK-NEXT: {{.*}} = xor i32 %{{.*}}, [[TMP]]
84 return __blcmsk_u32(a);
87 #ifdef __x86_64__
88 unsigned long long test__blcmsk_u64(unsigned long long a) {
89 // CHECK-LABEL: test__blcmsk_u64
90 // CHECK: [[TMP:%.*]] = add i64 %{{.*}}, 1
91 // CHECK-NEXT: {{.*}} = xor i64 %{{.*}}, [[TMP]]
92 return __blcmsk_u64(a);
94 #endif
96 unsigned int test__blcs_u32(unsigned int a) {
97 // CHECK-LABEL: test__blcs_u32
98 // CHECK: [[TMP:%.*]] = add i32 %{{.*}}, 1
99 // CHECK-NEXT: {{.*}} = or i32 %{{.*}}, [[TMP]]
100 return __blcs_u32(a);
103 #ifdef __x86_64__
104 unsigned long long test__blcs_u64(unsigned long long a) {
105 // CHECK-LABEL: test__blcs_u64
106 // CHECK: [[TMP:%.*]] = add i64 %{{.*}}, 1
107 // CHECK-NEXT: {{.*}} = or i64 %{{.*}}, [[TMP]]
108 return __blcs_u64(a);
110 #endif
112 unsigned int test__blsfill_u32(unsigned int a) {
113 // CHECK-LABEL: test__blsfill_u32
114 // CHECK: [[TMP:%.*]] = sub i32 %{{.*}}, 1
115 // CHECK-NEXT: {{.*}} = or i32 %{{.*}}, [[TMP]]
116 return __blsfill_u32(a);
119 #ifdef __x86_64__
120 unsigned long long test__blsfill_u64(unsigned long long a) {
121 // CHECK-LABEL: test__blsfill_u64
122 // CHECK: [[TMP:%.*]] = sub i64 %{{.*}}, 1
123 // CHECK-NEXT: {{.*}} = or i64 %{{.*}}, [[TMP]]
124 return __blsfill_u64(a);
126 #endif
128 unsigned int test__blsic_u32(unsigned int a) {
129 // CHECK-LABEL: test__blsic_u32
130 // CHECK: [[TMP1:%.*]] = xor i32 %{{.*}}, -1
131 // CHECK: [[TMP2:%.*]] = sub i32 %{{.*}}, 1
132 // CHECK-NEXT: {{.*}} = or i32 [[TMP1]], [[TMP2]]
133 return __blsic_u32(a);
136 #ifdef __x86_64__
137 unsigned long long test__blsic_u64(unsigned long long a) {
138 // CHECK-LABEL: test__blsic_u64
139 // CHECK: [[TMP1:%.*]] = xor i64 %{{.*}}, -1
140 // CHECK: [[TMP2:%.*]] = sub i64 %{{.*}}, 1
141 // CHECK-NEXT: {{.*}} = or i64 [[TMP1]], [[TMP2]]
142 return __blsic_u64(a);
144 #endif
146 unsigned int test__t1mskc_u32(unsigned int a) {
147 // CHECK-LABEL: test__t1mskc_u32
148 // CHECK: [[TMP1:%.*]] = xor i32 %{{.*}}, -1
149 // CHECK: [[TMP2:%.*]] = add i32 %{{.*}}, 1
150 // CHECK-NEXT: {{.*}} = or i32 [[TMP1]], [[TMP2]]
151 return __t1mskc_u32(a);
154 #ifdef __x86_64__
155 unsigned long long test__t1mskc_u64(unsigned long long a) {
156 // CHECK-LABEL: test__t1mskc_u64
157 // CHECK: [[TMP1:%.*]] = xor i64 %{{.*}}, -1
158 // CHECK: [[TMP2:%.*]] = add i64 %{{.*}}, 1
159 // CHECK-NEXT: {{.*}} = or i64 [[TMP1]], [[TMP2]]
160 return __t1mskc_u64(a);
162 #endif
164 unsigned int test__tzmsk_u32(unsigned int a) {
165 // CHECK-LABEL: test__tzmsk_u32
166 // CHECK: [[TMP1:%.*]] = xor i32 %{{.*}}, -1
167 // CHECK: [[TMP2:%.*]] = sub i32 %{{.*}}, 1
168 // CHECK-NEXT: {{.*}} = and i32 [[TMP1]], [[TMP2]]
169 return __tzmsk_u32(a);
172 #ifdef __x86_64__
173 unsigned long long test__tzmsk_u64(unsigned long long a) {
174 // CHECK-LABEL: test__tzmsk_u64
175 // CHECK: [[TMP1:%.*]] = xor i64 %{{.*}}, -1
176 // CHECK: [[TMP2:%.*]] = sub i64 %{{.*}}, 1
177 // CHECK-NEXT: {{.*}} = and i64 [[TMP1]], [[TMP2]]
178 return __tzmsk_u64(a);
180 #endif
182 // Test constexpr handling.
183 #if defined(__cplusplus) && (__cplusplus >= 201103L)
184 char bextri32_0[__bextri_u32(0x00000000, 0x00000000) == 0x00000000 ? 1 : -1];
185 char bextri32_1[__bextri_u32(0x000003F0, 0xFFFF1004) == 0x0000003F ? 1 : -1];
186 char bextri32_2[__bextri_u32(0x000003F0, 0xFFFF3008) == 0x00000003 ? 1 : -1];
188 char blcfill32[__blcfill_u32(0x89ABCDEF) == (0x89ABCDEF & (0x89ABCDEF + 1)) ? 1 : -1];
189 char blci32[__blci_u32(0x89ABCDEF) == (0x89ABCDEF | ~(0x89ABCDEF + 1)) ? 1 : -1];
190 char blcmsk32[__blcmsk_u32(0x89ABCDEF) == (0x89ABCDEF ^ (0x89ABCDEF + 1)) ? 1 : -1];
191 char blcs32[__blcs_u32(0x89ABCDEF) == (0x89ABCDEF | (0x89ABCDEF + 1)) ? 1 : -1];
192 char blsfill32[__blsfill_u32(0x89ABCDEF) == (0x89ABCDEF | (0x89ABCDEF - 1)) ? 1 : -1];
193 char blsic32[__blsic_u32(0x89ABCDEF) == (~0x89ABCDEF | (0x89ABCDEF - 1)) ? 1 : -1];
194 char t1mskc32[__t1mskc_u32(0x89ABCDEF) == (~0x89ABCDEF | (0x89ABCDEF + 1)) ? 1 : -1];
195 char tzmsk32[__tzmsk_u32(0x89ABCDEF) == (~0x89ABCDEF & (0x89ABCDEF - 1)) ? 1 : -1];
197 #ifdef __x86_64__
198 char bextri64_0[__bextri_u64(0x0000000000000000ULL, 0x0000000000000000ULL) == 0x0000000000000000ULL ? 1 : -1];
199 char bextri64_1[__bextri_u64(0xF000000000000001ULL, 0x0000000000004001ULL) == 0x7800000000000000ULL ? 1 : -1];
200 char bextri64_2[__bextri_u64(0xF000000000000001ULL, 0xFFFFFFFFFFFF1001ULL) == 0x0000000000000000ULL ? 1 : -1];
202 char blcfill64[__blcfill_u64(0xFEDCBA9876543210) == (0xFEDCBA9876543210 & (0xFEDCBA9876543210 + 1)) ? 1 : -1];
203 char blci64[__blci_u64(0xFEDCBA9876543210) == (0xFEDCBA9876543210 | ~(0xFEDCBA9876543210 + 1)) ? 1 : -1];
204 char blcmsk64[__blcmsk_u64(0xFEDCBA9876543210) == (0xFEDCBA9876543210 ^ (0xFEDCBA9876543210 + 1)) ? 1 : -1];
205 char blcs64[__blcs_u64(0xFEDCBA9876543210) == (0xFEDCBA9876543210 | (0xFEDCBA9876543210 + 1)) ? 1 : -1];
206 char blsfill64[__blsfill_u64(0xFEDCBA9876543210) == (0xFEDCBA9876543210 | (0xFEDCBA9876543210 - 1)) ? 1 : -1];
207 char blsic64[__blsic_u64(0xFEDCBA9876543210) == (~0xFEDCBA9876543210 | (0xFEDCBA9876543210 - 1)) ? 1 : -1];
208 char t1mskc64[__t1mskc_u64(0xFEDCBA9876543210) == (~0xFEDCBA9876543210 | (0xFEDCBA9876543210 + 1)) ? 1 : -1];
209 char tzmsk64[__tzmsk_u64(0xFEDCBA9876543210) == (~0xFEDCBA9876543210 & (0xFEDCBA9876543210 - 1)) ? 1 : -1];
210 #endif
211 #endif