Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGen / X86 / tbm-builtins.c
blobad4247be9a442cd53c6cb85490694045830a3442
1 // RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-unknown -target-feature +tbm -emit-llvm -o - | FileCheck %s
3 #include <x86intrin.h>
5 // NOTE: This should match the tests in llvm/test/CodeGen/X86/tbm-intrinsics-fast-isel.ll
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);
13 #ifdef __x86_64__
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);
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);
25 #endif
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);
34 #ifdef __x86_64__
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);
41 #endif
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);
51 #ifdef __x86_64__
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);
59 #endif
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);
69 #ifdef __x86_64__
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);
77 #endif
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);
86 #ifdef __x86_64__
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);
93 #endif
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);
102 #ifdef __x86_64__
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);
109 #endif
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);
118 #ifdef __x86_64__
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);
125 #endif
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);
135 #ifdef __x86_64__
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);
143 #endif
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);
153 #ifdef __x86_64__
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);
161 #endif
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);
171 #ifdef __x86_64__
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);
179 #endif