diff options
author | Craig Topper <craig.topper@intel.com> | 2018-09-26 17:01:44 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@intel.com> | 2018-09-26 17:01:44 +0000 |
commit | 26346fbcb9bb9fe7a6374e84eb994e8743e65327 (patch) | |
tree | 2a9067e82d5b0b301240a1a8ec97403b9ccc2f3e /lib/Headers/lzcntintrin.h | |
parent | f10f8c29df7bf378dcde4d3341709145d82c0156 (diff) |
[X86] For lzcnt/tzcnt intrinsics use cttz/ctlz intrinsics with zero_undef flag set to false.
Previously we used a select and the zero_undef=true intrinsic. In -O2 this pattern will get optimized to zero_undef=false. But in -O0 this optimization won't happen. This results in a compare and cmov being wrapped around a tzcnt/lzcnt instruction.
By using the zero_undef=false intrinsic directly without the select, we can improve the -O0 codegen to just an lzcnt/tzcnt instruction.
Differential Revision: https://reviews.llvm.org/D52392
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@343126 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Headers/lzcntintrin.h')
-rw-r--r-- | lib/Headers/lzcntintrin.h | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/Headers/lzcntintrin.h b/lib/Headers/lzcntintrin.h index 558f1828f0..f2674d2a5a 100644 --- a/lib/Headers/lzcntintrin.h +++ b/lib/Headers/lzcntintrin.h @@ -44,7 +44,7 @@ static __inline__ unsigned short __DEFAULT_FN_ATTRS __lzcnt16(unsigned short __X) { - return __X ? __builtin_clzs(__X) : 16; + return __builtin_ia32_lzcnt_u16(__X); } /// Counts the number of leading zero bits in the operand. @@ -61,7 +61,7 @@ __lzcnt16(unsigned short __X) static __inline__ unsigned int __DEFAULT_FN_ATTRS __lzcnt32(unsigned int __X) { - return __X ? __builtin_clz(__X) : 32; + return __builtin_ia32_lzcnt_u32(__X); } /// Counts the number of leading zero bits in the operand. @@ -78,7 +78,7 @@ __lzcnt32(unsigned int __X) static __inline__ unsigned int __DEFAULT_FN_ATTRS _lzcnt_u32(unsigned int __X) { - return __X ? __builtin_clz(__X) : 32; + return __builtin_ia32_lzcnt_u32(__X); } #ifdef __x86_64__ @@ -96,7 +96,7 @@ _lzcnt_u32(unsigned int __X) static __inline__ unsigned long long __DEFAULT_FN_ATTRS __lzcnt64(unsigned long long __X) { - return __X ? __builtin_clzll(__X) : 64; + return __builtin_ia32_lzcnt_u64(__X); } /// Counts the number of leading zero bits in the operand. @@ -113,7 +113,7 @@ __lzcnt64(unsigned long long __X) static __inline__ unsigned long long __DEFAULT_FN_ATTRS _lzcnt_u64(unsigned long long __X) { - return __X ? __builtin_clzll(__X) : 64; + return __builtin_ia32_lzcnt_u64(__X); } #endif |