aboutsummaryrefslogtreecommitdiffhomepage
path: root/unsupported/Eigen/CXX11/src/Tensor/TensorIntDiv.h
diff options
context:
space:
mode:
authorGravatar Benoit Steiner <benoit.steiner.goog@gmail.com>2015-02-25 23:54:43 -0800
committerGravatar Benoit Steiner <benoit.steiner.goog@gmail.com>2015-02-25 23:54:43 -0800
commitbffb6bdf455097ac5a6f98eb4bb549166e318989 (patch)
tree86c9f23cb891f568a07bdef3debb114a88a5b3c3 /unsupported/Eigen/CXX11/src/Tensor/TensorIntDiv.h
parent27f3fb2bcc8ea06f3f471560fc1c87210cd0c62b (diff)
Made TensorIntDiv.h compile with MSVC
Diffstat (limited to 'unsupported/Eigen/CXX11/src/Tensor/TensorIntDiv.h')
-rw-r--r--unsupported/Eigen/CXX11/src/Tensor/TensorIntDiv.h10
1 files changed, 6 insertions, 4 deletions
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 <typename T>
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<uint32_t>(val));
+#elif EIGEN_COMP_MSVC
+ DWORD leading_zero = 0;
+ _BitScanReverse( &leading_zero, value);
+ return 31 - leading_zero;
#else
return __clz(val);
#endif