2017-08-01 04:21:53 +08:00
|
|
|
// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-unknown -target-feature +tbm -emit-llvm -o - | FileCheck %s
|
2013-10-01 01:25:14 +08:00
|
|
|
|
|
|
|
#include <x86intrin.h>
|
|
|
|
|
2016-06-19 01:09:40 +08:00
|
|
|
// NOTE: This should match the tests in llvm/test/CodeGen/X86/tbm-intrinsics-fast-isel.ll
|
|
|
|
|
2013-10-01 01:25:14 +08:00
|
|
|
unsigned int test__bextri_u32(unsigned int a) {
|
2016-06-19 01:09:40 +08:00
|
|
|
// CHECK-LABEL: test__bextri_u32
|
|
|
|
// CHECK: call i32 @llvm.x86.tbm.bextri.u32(i32 %{{.*}}, i32 1)
|
2013-10-01 01:25:14 +08:00
|
|
|
return __bextri_u32(a, 1);
|
|
|
|
}
|
|
|
|
|
2019-07-11 01:11:23 +08:00
|
|
|
#ifdef __x86_64__
|
2013-10-01 01:25:14 +08:00
|
|
|
unsigned long long test__bextri_u64(unsigned long long a) {
|
2016-06-19 01:09:40 +08:00
|
|
|
// CHECK-LABEL: test__bextri_u64
|
|
|
|
// CHECK: call i64 @llvm.x86.tbm.bextri.u64(i64 %{{.*}}, i64 2)
|
2013-10-01 01:25:14 +08:00
|
|
|
return __bextri_u64(a, 2);
|
|
|
|
}
|
|
|
|
|
2013-10-03 12:21:19 +08:00
|
|
|
unsigned long long test__bextri_u64_bigint(unsigned long long a) {
|
2016-06-19 01:09:40 +08:00
|
|
|
// CHECK-LABEL: test__bextri_u64_bigint
|
|
|
|
// CHECK: call i64 @llvm.x86.tbm.bextri.u64(i64 %{{.*}}, i64 549755813887)
|
2013-10-03 12:21:19 +08:00
|
|
|
return __bextri_u64(a, 0x7fffffffffLL);
|
|
|
|
}
|
2019-07-11 01:11:23 +08:00
|
|
|
#endif
|
2013-10-03 12:21:19 +08:00
|
|
|
|
2013-10-01 01:25:14 +08:00
|
|
|
unsigned int test__blcfill_u32(unsigned int a) {
|
2016-06-19 01:09:40 +08:00
|
|
|
// CHECK-LABEL: test__blcfill_u32
|
2017-08-01 04:21:53 +08:00
|
|
|
// CHECK: [[TMP:%.*]] = add i32 %{{.*}}, 1
|
|
|
|
// CHECK: %{{.*}} = and i32 %{{.*}}, [[TMP]]
|
2013-10-01 01:25:14 +08:00
|
|
|
return __blcfill_u32(a);
|
|
|
|
}
|
|
|
|
|
2019-07-11 01:11:23 +08:00
|
|
|
#ifdef __x86_64__
|
2013-10-01 01:25:14 +08:00
|
|
|
unsigned long long test__blcfill_u64(unsigned long long a) {
|
2016-06-19 01:09:40 +08:00
|
|
|
// CHECK-LABEL: test__blcfill_u64
|
2017-08-01 04:21:53 +08:00
|
|
|
// CHECK: [[TMP:%.*]] = add i64 %{{.*}}, 1
|
|
|
|
// CHECK: %{{.*}} = and i64 %{{.*}}, [[TMP]]
|
2013-10-01 01:25:14 +08:00
|
|
|
return __blcfill_u64(a);
|
|
|
|
}
|
2019-07-11 01:11:23 +08:00
|
|
|
#endif
|
2013-10-01 01:25:14 +08:00
|
|
|
|
|
|
|
unsigned int test__blci_u32(unsigned int a) {
|
2016-06-19 01:09:40 +08:00
|
|
|
// CHECK-LABEL: test__blci_u32
|
2017-08-01 04:21:53 +08:00
|
|
|
// CHECK: [[TMP1:%.*]] = add i32 %{{.*}}, 1
|
|
|
|
// CHECK: [[TMP2:%.*]] = xor i32 [[TMP1]], -1
|
|
|
|
// CHECK: %{{.*}} = or i32 %{{.*}}, [[TMP2]]
|
2013-10-01 01:25:14 +08:00
|
|
|
return __blci_u32(a);
|
|
|
|
}
|
|
|
|
|
2019-07-11 01:11:23 +08:00
|
|
|
#ifdef __x86_64__
|
2013-10-01 01:25:14 +08:00
|
|
|
unsigned long long test__blci_u64(unsigned long long a) {
|
2016-06-19 01:09:40 +08:00
|
|
|
// CHECK-LABEL: test__blci_u64
|
2017-08-01 04:21:53 +08:00
|
|
|
// CHECK: [[TMP1:%.*]] = add i64 %{{.*}}, 1
|
|
|
|
// CHECK: [[TMP2:%.*]] = xor i64 [[TMP1]], -1
|
|
|
|
// CHECK: %{{.*}} = or i64 %{{.*}}, [[TMP2]]
|
2013-10-01 01:25:14 +08:00
|
|
|
return __blci_u64(a);
|
|
|
|
}
|
2019-07-11 01:11:23 +08:00
|
|
|
#endif
|
2013-10-01 01:25:14 +08:00
|
|
|
|
|
|
|
unsigned int test__blcic_u32(unsigned int a) {
|
2016-06-19 01:09:40 +08:00
|
|
|
// CHECK-LABEL: test__blcic_u32
|
2017-08-01 04:21:53 +08:00
|
|
|
// CHECK: [[TMP1:%.*]] = xor i32 %{{.*}}, -1
|
|
|
|
// CHECK: [[TMP2:%.*]] = add i32 %{{.*}}, 1
|
|
|
|
// CHECK-NEXT: {{.*}} = and i32 [[TMP1]], [[TMP2]]
|
2013-10-01 01:25:14 +08:00
|
|
|
return __blcic_u32(a);
|
|
|
|
}
|
|
|
|
|
2019-07-11 01:11:23 +08:00
|
|
|
#ifdef __x86_64__
|
2013-10-01 01:25:14 +08:00
|
|
|
unsigned long long test__blcic_u64(unsigned long long a) {
|
2016-06-19 01:09:40 +08:00
|
|
|
// CHECK-LABEL: test__blcic_u64
|
2017-08-01 04:21:53 +08:00
|
|
|
// CHECK: [[TMP1:%.*]] = xor i64 %{{.*}}, -1
|
|
|
|
// CHECK: [[TMP2:%.*]] = add i64 %{{.*}}, 1
|
|
|
|
// CHECK-NEXT: {{.*}} = and i64 [[TMP1]], [[TMP2]]
|
2013-10-01 01:25:14 +08:00
|
|
|
return __blcic_u64(a);
|
|
|
|
}
|
2019-07-11 01:11:23 +08:00
|
|
|
#endif
|
2013-10-01 01:25:14 +08:00
|
|
|
|
|
|
|
unsigned int test__blcmsk_u32(unsigned int a) {
|
2016-06-19 01:09:40 +08:00
|
|
|
// CHECK-LABEL: test__blcmsk_u32
|
2017-08-01 04:21:53 +08:00
|
|
|
// CHECK: [[TMP:%.*]] = add i32 %{{.*}}, 1
|
|
|
|
// CHECK-NEXT: {{.*}} = xor i32 %{{.*}}, [[TMP]]
|
2013-10-01 01:25:14 +08:00
|
|
|
return __blcmsk_u32(a);
|
|
|
|
}
|
|
|
|
|
2019-07-11 01:11:23 +08:00
|
|
|
#ifdef __x86_64__
|
2013-10-01 01:25:14 +08:00
|
|
|
unsigned long long test__blcmsk_u64(unsigned long long a) {
|
2016-06-19 01:09:40 +08:00
|
|
|
// CHECK-LABEL: test__blcmsk_u64
|
2017-08-01 04:21:53 +08:00
|
|
|
// CHECK: [[TMP:%.*]] = add i64 %{{.*}}, 1
|
|
|
|
// CHECK-NEXT: {{.*}} = xor i64 %{{.*}}, [[TMP]]
|
2013-10-01 01:25:14 +08:00
|
|
|
return __blcmsk_u64(a);
|
|
|
|
}
|
2019-07-11 01:11:23 +08:00
|
|
|
#endif
|
2013-10-01 01:25:14 +08:00
|
|
|
|
|
|
|
unsigned int test__blcs_u32(unsigned int a) {
|
2016-06-19 01:09:40 +08:00
|
|
|
// CHECK-LABEL: test__blcs_u32
|
2017-08-01 04:21:53 +08:00
|
|
|
// CHECK: [[TMP:%.*]] = add i32 %{{.*}}, 1
|
|
|
|
// CHECK-NEXT: {{.*}} = or i32 %{{.*}}, [[TMP]]
|
2013-10-01 01:25:14 +08:00
|
|
|
return __blcs_u32(a);
|
|
|
|
}
|
|
|
|
|
2019-07-11 01:11:23 +08:00
|
|
|
#ifdef __x86_64__
|
2013-10-01 01:25:14 +08:00
|
|
|
unsigned long long test__blcs_u64(unsigned long long a) {
|
2016-06-19 01:09:40 +08:00
|
|
|
// CHECK-LABEL: test__blcs_u64
|
2017-08-01 04:21:53 +08:00
|
|
|
// CHECK: [[TMP:%.*]] = add i64 %{{.*}}, 1
|
|
|
|
// CHECK-NEXT: {{.*}} = or i64 %{{.*}}, [[TMP]]
|
2013-10-01 01:25:14 +08:00
|
|
|
return __blcs_u64(a);
|
|
|
|
}
|
2019-07-11 01:11:23 +08:00
|
|
|
#endif
|
2013-10-01 01:25:14 +08:00
|
|
|
|
|
|
|
unsigned int test__blsfill_u32(unsigned int a) {
|
2016-06-19 01:09:40 +08:00
|
|
|
// CHECK-LABEL: test__blsfill_u32
|
2017-08-01 04:21:53 +08:00
|
|
|
// CHECK: [[TMP:%.*]] = sub i32 %{{.*}}, 1
|
|
|
|
// CHECK-NEXT: {{.*}} = or i32 %{{.*}}, [[TMP]]
|
2013-10-01 01:25:14 +08:00
|
|
|
return __blsfill_u32(a);
|
|
|
|
}
|
|
|
|
|
2019-07-11 01:11:23 +08:00
|
|
|
#ifdef __x86_64__
|
2013-10-01 01:25:14 +08:00
|
|
|
unsigned long long test__blsfill_u64(unsigned long long a) {
|
2016-06-19 01:09:40 +08:00
|
|
|
// CHECK-LABEL: test__blsfill_u64
|
2017-08-01 04:21:53 +08:00
|
|
|
// CHECK: [[TMP:%.*]] = sub i64 %{{.*}}, 1
|
|
|
|
// CHECK-NEXT: {{.*}} = or i64 %{{.*}}, [[TMP]]
|
2013-10-01 01:25:14 +08:00
|
|
|
return __blsfill_u64(a);
|
|
|
|
}
|
2019-07-11 01:11:23 +08:00
|
|
|
#endif
|
2013-10-01 01:25:14 +08:00
|
|
|
|
|
|
|
unsigned int test__blsic_u32(unsigned int a) {
|
2016-06-19 01:09:40 +08:00
|
|
|
// CHECK-LABEL: test__blsic_u32
|
2017-08-01 04:21:53 +08:00
|
|
|
// CHECK: [[TMP1:%.*]] = xor i32 %{{.*}}, -1
|
|
|
|
// CHECK: [[TMP2:%.*]] = sub i32 %{{.*}}, 1
|
|
|
|
// CHECK-NEXT: {{.*}} = or i32 [[TMP1]], [[TMP2]]
|
2013-10-01 01:25:14 +08:00
|
|
|
return __blsic_u32(a);
|
|
|
|
}
|
|
|
|
|
2019-07-11 01:11:23 +08:00
|
|
|
#ifdef __x86_64__
|
2013-10-01 01:25:14 +08:00
|
|
|
unsigned long long test__blsic_u64(unsigned long long a) {
|
2016-06-19 01:09:40 +08:00
|
|
|
// CHECK-LABEL: test__blsic_u64
|
2017-08-01 04:21:53 +08:00
|
|
|
// CHECK: [[TMP1:%.*]] = xor i64 %{{.*}}, -1
|
|
|
|
// CHECK: [[TMP2:%.*]] = sub i64 %{{.*}}, 1
|
|
|
|
// CHECK-NEXT: {{.*}} = or i64 [[TMP1]], [[TMP2]]
|
2013-10-01 01:25:14 +08:00
|
|
|
return __blsic_u64(a);
|
|
|
|
}
|
2019-07-11 01:11:23 +08:00
|
|
|
#endif
|
2013-10-01 01:25:14 +08:00
|
|
|
|
|
|
|
unsigned int test__t1mskc_u32(unsigned int a) {
|
2016-06-19 01:09:40 +08:00
|
|
|
// CHECK-LABEL: test__t1mskc_u32
|
2017-08-01 04:21:53 +08:00
|
|
|
// CHECK: [[TMP1:%.*]] = xor i32 %{{.*}}, -1
|
|
|
|
// CHECK: [[TMP2:%.*]] = add i32 %{{.*}}, 1
|
|
|
|
// CHECK-NEXT: {{.*}} = or i32 [[TMP1]], [[TMP2]]
|
2013-10-01 01:25:14 +08:00
|
|
|
return __t1mskc_u32(a);
|
|
|
|
}
|
|
|
|
|
2019-07-11 01:11:23 +08:00
|
|
|
#ifdef __x86_64__
|
2013-10-01 01:25:14 +08:00
|
|
|
unsigned long long test__t1mskc_u64(unsigned long long a) {
|
2016-06-19 01:09:40 +08:00
|
|
|
// CHECK-LABEL: test__t1mskc_u64
|
2017-08-01 04:21:53 +08:00
|
|
|
// CHECK: [[TMP1:%.*]] = xor i64 %{{.*}}, -1
|
|
|
|
// CHECK: [[TMP2:%.*]] = add i64 %{{.*}}, 1
|
|
|
|
// CHECK-NEXT: {{.*}} = or i64 [[TMP1]], [[TMP2]]
|
2013-10-01 01:25:14 +08:00
|
|
|
return __t1mskc_u64(a);
|
|
|
|
}
|
2019-07-11 01:11:23 +08:00
|
|
|
#endif
|
2013-10-01 01:25:14 +08:00
|
|
|
|
|
|
|
unsigned int test__tzmsk_u32(unsigned int a) {
|
2016-06-19 01:09:40 +08:00
|
|
|
// CHECK-LABEL: test__tzmsk_u32
|
2017-08-01 04:21:53 +08:00
|
|
|
// CHECK: [[TMP1:%.*]] = xor i32 %{{.*}}, -1
|
|
|
|
// CHECK: [[TMP2:%.*]] = sub i32 %{{.*}}, 1
|
|
|
|
// CHECK-NEXT: {{.*}} = and i32 [[TMP1]], [[TMP2]]
|
2013-10-01 01:25:14 +08:00
|
|
|
return __tzmsk_u32(a);
|
|
|
|
}
|
|
|
|
|
2019-07-11 01:11:23 +08:00
|
|
|
#ifdef __x86_64__
|
2013-10-01 01:25:14 +08:00
|
|
|
unsigned long long test__tzmsk_u64(unsigned long long a) {
|
2016-06-19 01:09:40 +08:00
|
|
|
// CHECK-LABEL: test__tzmsk_u64
|
2017-08-01 04:21:53 +08:00
|
|
|
// CHECK: [[TMP1:%.*]] = xor i64 %{{.*}}, -1
|
|
|
|
// CHECK: [[TMP2:%.*]] = sub i64 %{{.*}}, 1
|
|
|
|
// CHECK-NEXT: {{.*}} = and i64 [[TMP1]], [[TMP2]]
|
2013-10-01 01:25:14 +08:00
|
|
|
return __tzmsk_u64(a);
|
|
|
|
}
|
2019-07-11 01:11:23 +08:00
|
|
|
#endif
|