From 4318d91ea4be673d4deba39d33ac4718d77986a7 Mon Sep 17 00:00:00 2001 From: Andreas Gampe Date: Fri, 14 Aug 2015 18:39:30 +0000 Subject: Revert "ART: DCHECK zero case for CLZ/CTZ" This reverts commit 51db2c217052fd6881b81f3ac5162fe88c36dbf0. Still breaks for arm32. :( Change-Id: I5fe6fc0cc410cc1c5b6bd68028ce9bf835cb94d5 --- runtime/base/bit_utils.h | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'runtime/base/bit_utils.h') diff --git a/runtime/base/bit_utils.h b/runtime/base/bit_utils.h index 332012bda9..6f45dc8209 100644 --- a/runtime/base/bit_utils.h +++ b/runtime/base/bit_utils.h @@ -29,28 +29,21 @@ namespace art { template static constexpr int CLZ(T x) { static_assert(std::is_integral::value, "T must be integral"); - static_assert(std::is_unsigned::value, "T must be unsigned"); + // TODO: assert unsigned. There is currently many uses with signed values. static_assert(sizeof(T) <= sizeof(long long), // NOLINT [runtime/int] [4] "T too large, must be smaller than long long"); - return - DCHECK_CONSTEXPR(x != 0, "x must not be zero", T(0)) - (sizeof(T) == sizeof(uint32_t)) - ? __builtin_clz(x) - : __builtin_clzll(x); + return (sizeof(T) == sizeof(uint32_t)) + ? __builtin_clz(x) // TODO: __builtin_clz[ll] has undefined behavior for x=0 + : __builtin_clzll(x); } template static constexpr int CTZ(T x) { static_assert(std::is_integral::value, "T must be integral"); - // A similar check to the above does not make sense. It isn't as non-intuitive to ask for - // trailing zeros in a negative number, and the quick backends do this for immediate encodings. - static_assert(sizeof(T) <= sizeof(long long), // NOLINT [runtime/int] [4] - "T too large, must be smaller than long long"); - return - DCHECK_CONSTEXPR(x != 0, "x must not be zero", T(0)) - (sizeof(T) == sizeof(uint32_t)) - ? __builtin_ctz(x) - : __builtin_ctzll(x); + // TODO: assert unsigned. There is currently many uses with signed values. + return (sizeof(T) == sizeof(uint32_t)) + ? __builtin_ctz(x) + : __builtin_ctzll(x); } template -- cgit v1.2.3-59-g8ed1b