diff options
| author | Craig Topper <craig.topper@intel.com> | 2019-10-11 06:07:53 +0000 |
|---|---|---|
| committer | Craig Topper <craig.topper@intel.com> | 2019-10-11 06:07:53 +0000 |
| commit | 282eff38477ebf665f88f52411edd591067af883 (patch) | |
| tree | 73930b0d367f91186ee708c1557c7ea59fcb2271 /clang/test/CodeGen/bmi-builtins.c | |
| parent | 2fbfb04ffef41eaeee1c60341d90d4b6a8ca816b (diff) | |
| download | bcm5719-llvm-282eff38477ebf665f88f52411edd591067af883.tar.gz bcm5719-llvm-282eff38477ebf665f88f52411edd591067af883.zip | |
[X86] Always define the tzcnt intrinsics even when _MSC_VER is defined.
These intrinsics use llvm.cttz intrinsics so are always available
even without the bmi feature. We already don't check for the bmi
feature on the intrinsics themselves. But we were blocking the
include of the header file with _MSC_VER unless BMI was enabled
on the command line.
Fixes PR30506.
llvm-svn: 374516
Diffstat (limited to 'clang/test/CodeGen/bmi-builtins.c')
| -rw-r--r-- | clang/test/CodeGen/bmi-builtins.c | 96 |
1 files changed, 51 insertions, 45 deletions
diff --git a/clang/test/CodeGen/bmi-builtins.c b/clang/test/CodeGen/bmi-builtins.c index 9eda3f614d4..9f2d776299f 100644 --- a/clang/test/CodeGen/bmi-builtins.c +++ b/clang/test/CodeGen/bmi-builtins.c @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +bmi -emit-llvm -o - -Wall -Werror | FileCheck %s +// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +bmi -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK,CHECK_TZCNT +// RUN: %clang_cc1 -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 -ffreestanding %s -triple=x86_64-windows-msvc -emit-llvm -o - -Wall -Werror -DTEST_TZCNT | FileCheck %s --check-prefix=CHECK-TZCNT #include <immintrin.h> @@ -13,12 +14,57 @@ // instruction is identical in hardware, the AMD and Intel // intrinsics are different! +unsigned short test_tzcnt_u16(unsigned short __X) { + // CHECK-TZCNT-LABEL: test_tzcnt_u16 + // CHECK-TZCNT: i16 @llvm.cttz.i16(i16 %{{.*}}, i1 false) + return _tzcnt_u16(__X); +} + unsigned short test__tzcnt_u16(unsigned short __X) { - // CHECK-LABEL: test__tzcnt_u16 - // CHECK: i16 @llvm.cttz.i16(i16 %{{.*}}, i1 false) + // CHECK-TZCNT-LABEL: test__tzcnt_u16 + // CHECK-TZCNT: i16 @llvm.cttz.i16(i16 %{{.*}}, i1 false) return __tzcnt_u16(__X); } +unsigned int test__tzcnt_u32(unsigned int __X) { + // CHECK-TZCNT-LABEL: test__tzcnt_u32 + // CHECK-TZCNT: i32 @llvm.cttz.i32(i32 %{{.*}}, i1 false) + return __tzcnt_u32(__X); +} + +int test_mm_tzcnt_32(unsigned int __X) { + // CHECK-TZCNT-LABEL: test_mm_tzcnt_32 + // CHECK-TZCNT: i32 @llvm.cttz.i32(i32 %{{.*}}, i1 false) + return _mm_tzcnt_32(__X); +} + +unsigned int test_tzcnt_u32(unsigned int __X) { + // CHECK-TZCNT-LABEL: test_tzcnt_u32 + // CHECK-TZCNT: i32 @llvm.cttz.i32(i32 %{{.*}}, i1 false) + return _tzcnt_u32(__X); +} + +#ifdef __x86_64__ +unsigned long long test__tzcnt_u64(unsigned long long __X) { + // CHECK-TZCNT-LABEL: test__tzcnt_u64 + // CHECK-TZCNT: i64 @llvm.cttz.i64(i64 %{{.*}}, i1 false) + return __tzcnt_u64(__X); +} + +long long test_mm_tzcnt_64(unsigned long long __X) { + // CHECK-TZCNT-LABEL: test_mm_tzcnt_64 + // CHECK-TZCNT: i64 @llvm.cttz.i64(i64 %{{.*}}, i1 false) + return _mm_tzcnt_64(__X); +} + +unsigned long long test_tzcnt_u64(unsigned long long __X) { + // CHECK-TZCNT-LABEL: test_tzcnt_u64 + // CHECK-TZCNT: i64 @llvm.cttz.i64(i64 %{{.*}}, i1 false) + return _tzcnt_u64(__X); +} +#endif + +#if !defined(TEST_TZCNT) unsigned int test__andn_u32(unsigned int __X, unsigned int __Y) { // CHECK-LABEL: test__andn_u32 // CHECK: xor i32 %{{.*}}, -1 @@ -53,18 +99,6 @@ unsigned int test__blsr_u32(unsigned int __X) { return __blsr_u32(__X); } -unsigned int test__tzcnt_u32(unsigned int __X) { - // CHECK-LABEL: test__tzcnt_u32 - // CHECK: i32 @llvm.cttz.i32(i32 %{{.*}}, i1 false) - return __tzcnt_u32(__X); -} - -int test_mm_tzcnt_32(unsigned int __X) { - // CHECK-LABEL: test_mm_tzcnt_32 - // CHECK: i32 @llvm.cttz.i32(i32 %{{.*}}, i1 false) - return _mm_tzcnt_32(__X); -} - #ifdef __x86_64__ unsigned long long test__andn_u64(unsigned long __X, unsigned long __Y) { // CHECK-LABEL: test__andn_u64 @@ -99,28 +133,10 @@ unsigned long long test__blsr_u64(unsigned long long __X) { // CHECK: and i64 %{{.*}}, %{{.*}} return __blsr_u64(__X); } - -unsigned long long test__tzcnt_u64(unsigned long long __X) { - // CHECK-LABEL: test__tzcnt_u64 - // CHECK: i64 @llvm.cttz.i64(i64 %{{.*}}, i1 false) - return __tzcnt_u64(__X); -} - -long long test_mm_tzcnt_64(unsigned long long __X) { - // CHECK-LABEL: test_mm_tzcnt_64 - // CHECK: i64 @llvm.cttz.i64(i64 %{{.*}}, i1 false) - return _mm_tzcnt_64(__X); -} #endif // Intel intrinsics -unsigned short test_tzcnt_u16(unsigned short __X) { - // CHECK-LABEL: test_tzcnt_u16 - // CHECK: i16 @llvm.cttz.i16(i16 %{{.*}}, i1 false) - return _tzcnt_u16(__X); -} - unsigned int test_andn_u32(unsigned int __X, unsigned int __Y) { // CHECK-LABEL: test_andn_u32 // CHECK: xor i32 %{{.*}}, -1 @@ -160,12 +176,6 @@ unsigned int test_blsr_u32(unsigned int __X) { return _blsr_u32(__X); } -unsigned int test_tzcnt_u32(unsigned int __X) { - // CHECK-LABEL: test_tzcnt_u32 - // CHECK: i32 @llvm.cttz.i32(i32 %{{.*}}, i1 false) - return _tzcnt_u32(__X); -} - #ifdef __x86_64__ unsigned long long test_andn_u64(unsigned long __X, unsigned long __Y) { // CHECK-LABEL: test_andn_u64 @@ -206,10 +216,6 @@ unsigned long long test_blsr_u64(unsigned long long __X) { // CHECK: and i64 %{{.*}}, %{{.*}} return _blsr_u64(__X); } - -unsigned long long test_tzcnt_u64(unsigned long long __X) { - // CHECK-LABEL: test_tzcnt_u64 - // CHECK: i64 @llvm.cttz.i64(i64 %{{.*}}, i1 false) - return _tzcnt_u64(__X); -} #endif + +#endif // !defined(TEST_TZCNT) |

