From 547a8608e5ff329c0f4e2da38c6eae023fc75647 Mon Sep 17 00:00:00 2001 From: Benoit Steiner Date: Mon, 23 Nov 2015 12:17:45 -0800 Subject: Fixed the implementation of Eigen::internal::count_leading_zeros for MSVC. Also updated the code to silence bogux warnings generated by nvcc when compilining this function. --- unsupported/Eigen/CXX11/src/Tensor/TensorIntDiv.h | 13 +++++-------- 1 file changed, 5 insertions(+), 8 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 81c661269..b58173e58 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorIntDiv.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorIntDiv.h @@ -34,10 +34,7 @@ namespace { EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE int count_leading_zeros(const T val) { #ifdef __CUDA_ARCH__ - if (sizeof(T) == 8) { - return __clzll(val); - } - return __clz(val); + return (sizeof(T) == 8) ? __clzll(val) : __clz(val); #elif EIGEN_COMP_MSVC DWORD leading_zeros = 0; if (sizeof(T) == 8) { @@ -46,11 +43,11 @@ namespace { else { _BitScanReverse(&leading_zero, val); } + return leading_zeros; #else - if (sizeof(T) == 8) { - return __builtin_clzl(static_cast(val)); - } - return __builtin_clz(static_cast(val)); + return (sizeof(T) == 8) ? + __builtin_clzl(static_cast(val)) : + __builtin_clz(static_cast(val)); #endif } -- cgit v1.2.3