summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2015-11-17 18:46:48 +0000
committerHans Wennborg <hans@hanshq.net>2015-11-17 18:46:48 +0000
commit1acf955a6ac8cfccf43001ca30604ce34329f05f (patch)
tree52294f5b70b95e48c1e1065c95420dedd99cdb0b /clang
parentf09d1bfceda328864be10e883a863f0265feb6fe (diff)
downloadbcm5719-llvm-1acf955a6ac8cfccf43001ca30604ce34329f05f.tar.gz
bcm5719-llvm-1acf955a6ac8cfccf43001ca30604ce34329f05f.zip
bmiintrin.h: Allow using the tzcnt intrinsics for non-BMI targets
The tzcnt intrinsics are used non non-BMI targets by code (e.g. ffmpeg) that uses it as a potentially faster BSF. The TZCNT instruction is special in that it's encoded in a backward-compatible way and behaves as BSF on non-BMI targets. Differential Revision: http://reviews.llvm.org/D14748 llvm-svn: 253358
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Headers/bmiintrin.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/clang/lib/Headers/bmiintrin.h b/clang/lib/Headers/bmiintrin.h
index dc2f83f3e2d..da98792d830 100644
--- a/clang/lib/Headers/bmiintrin.h
+++ b/clang/lib/Headers/bmiintrin.h
@@ -39,7 +39,12 @@
/* Define the default attributes for the functions in this file. */
#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("bmi")))
-static __inline__ unsigned short __DEFAULT_FN_ATTRS
+/* Allow using the tzcnt intrinsics even for non-BMI targets. Since the TZCNT
+ instruction behaves as BSF on non-BMI targets, there is code that expects
+ to use it as a potentially faster version of BSF. */
+#define __RELAXED_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
+
+static __inline__ unsigned short __RELAXED_FN_ATTRS
__tzcnt_u16(unsigned short __X)
{
return __X ? __builtin_ctzs(__X) : 16;
@@ -83,7 +88,7 @@ __blsr_u32(unsigned int __X)
return __X & (__X - 1);
}
-static __inline__ unsigned int __DEFAULT_FN_ATTRS
+static __inline__ unsigned int __RELAXED_FN_ATTRS
__tzcnt_u32(unsigned int __X)
{
return __X ? __builtin_ctz(__X) : 32;
@@ -136,7 +141,7 @@ __blsr_u64(unsigned long long __X)
return __X & (__X - 1);
}
-static __inline__ unsigned long long __DEFAULT_FN_ATTRS
+static __inline__ unsigned long long __RELAXED_FN_ATTRS
__tzcnt_u64(unsigned long long __X)
{
return __X ? __builtin_ctzll(__X) : 64;
@@ -145,5 +150,6 @@ __tzcnt_u64(unsigned long long __X)
#endif /* __x86_64__ */
#undef __DEFAULT_FN_ATTRS
+#undef __RELAXED_FN_ATTRS
#endif /* __BMIINTRIN_H */
OpenPOWER on IntegriCloud