From bffb6bdf455097ac5a6f98eb4bb549166e318989 Mon Sep 17 00:00:00 2001 From: Benoit Steiner Date: Wed, 25 Feb 2015 23:54:43 -0800 Subject: Made TensorIntDiv.h compile with MSVC --- unsupported/Eigen/CXX11/src/Tensor/TensorIntDiv.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 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 4b22c64de..535abd6fd 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorIntDiv.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorIntDiv.h @@ -29,14 +29,16 @@ namespace Eigen { namespace internal { namespace { + // Note: result is undefined if val == 0 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); + return __builtin_clz(static_cast(val)); +#elif EIGEN_COMP_MSVC + DWORD leading_zero = 0; + _BitScanReverse( &leading_zero, value); + return 31 - leading_zero; #else return __clz(val); #endif -- cgit v1.2.3