diff options
author | Benoit Steiner <benoit.steiner.goog@gmail.com> | 2015-11-23 12:17:45 -0800 |
---|---|---|
committer | Benoit Steiner <benoit.steiner.goog@gmail.com> | 2015-11-23 12:17:45 -0800 |
commit | 547a8608e5ff329c0f4e2da38c6eae023fc75647 (patch) | |
tree | a5cec7da9099ae90dad7776f395a441c8a750778 /unsupported/Eigen/CXX11/src/Tensor/TensorIntDiv.h | |
parent | 562078780a5511f33c6bb5639c5a93e56163a443 (diff) |
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.
Diffstat (limited to 'unsupported/Eigen/CXX11/src/Tensor/TensorIntDiv.h')
-rw-r--r-- | unsupported/Eigen/CXX11/src/Tensor/TensorIntDiv.h | 13 |
1 files changed, 5 insertions, 8 deletions
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<uint64_t>(val)); - } - return __builtin_clz(static_cast<uint32_t>(val)); + return (sizeof(T) == 8) ? + __builtin_clzl(static_cast<uint64_t>(val)) : + __builtin_clz(static_cast<uint32_t>(val)); #endif } |