From 27f3fb2bcc8ea06f3f471560fc1c87210cd0c62b Mon Sep 17 00:00:00 2001 From: Benoit Steiner Date: Wed, 25 Feb 2015 22:54:20 -0800 Subject: Fixed another clang warning --- unsupported/Eigen/CXX11/src/Tensor/TensorIntDiv.h | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'unsupported/Eigen/CXX11/src/Tensor/TensorIntDiv.h') diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorIntDiv.h b/unsupported/Eigen/CXX11/src/Tensor/TensorIntDiv.h index 2714117ab..4b22c64de 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorIntDiv.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorIntDiv.h @@ -28,6 +28,21 @@ namespace Eigen { namespace internal { +namespace { + template + EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE int count_leading_zeros(const T val) + { +#ifndef __CUDA_ARCH__ + if (sizeof(T) == 8) { + return __builtin_clzl(val); + } + return __builtin_clz(val); +#else + return __clz(val); +#endif + } +}; + template struct TensorIntDivisor { public: @@ -44,11 +59,7 @@ struct TensorIntDivisor { eigen_assert(divider <= (1<<(N-1)) - 1); // fast ln2 -#ifndef __CUDA_ARCH__ - const int leading_zeros = __builtin_clz(divider); -#else - const int leading_zeros = __clz(divider); -#endif + const int leading_zeros = count_leading_zeros(divider); const int log_div = N - (leading_zeros+1); multiplier = (static_cast(1) << (N+log_div)) / divider - (static_cast(1) << N) + 1; -- cgit v1.2.3