Commit 904c8ced authored by Ben Noordhuis's avatar Ben Noordhuis Committed by V8 LUCI CQ

Fix std::is_same compiler error

std::is_same is the wrong predicate to use because `unsigned long` need
not be equivalent to either `unsigned int` or `unsigned long long`.

Fixes: https://github.com/nodejs/node-v8/issues/229
Bug: v8:12982
Change-Id: Iafff3c6a33f841490fa66d48649d24f720c869f1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3749192
Auto-Submit: Ben Noordhuis <info@bnoordhuis.nl>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Commit-Queue: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-by: 's avatarDarius Mercadier <dmercadier@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#81581}
parent ef90abfa
...@@ -148,9 +148,14 @@ inline int32_t reinterpret_vmaxvq_u64(uint64x2_t v) { ...@@ -148,9 +148,14 @@ inline int32_t reinterpret_vmaxvq_u64(uint64x2_t v) {
template <typename T> template <typename T>
inline uintptr_t fast_search_noavx(T* array, uintptr_t array_len, inline uintptr_t fast_search_noavx(T* array, uintptr_t array_len,
uintptr_t index, T search_element) { uintptr_t index, T search_element) {
static_assert(std::is_same<T, uint32_t>::value || static constexpr bool is_uint32 =
std::is_same<T, uint64_t>::value || sizeof(T) == sizeof(uint32_t) && std::is_integral<T>::value;
std::is_same<T, double>::value); static constexpr bool is_uint64 =
sizeof(T) == sizeof(uint64_t) && std::is_integral<T>::value;
static constexpr bool is_double =
sizeof(T) == sizeof(double) && std::is_floating_point<T>::value;
static_assert(is_uint32 || is_uint64 || is_double);
#if !(defined(__SSE3__) || defined(NEON64)) #if !(defined(__SSE3__) || defined(NEON64))
// No SIMD available. // No SIMD available.
...@@ -178,14 +183,14 @@ inline uintptr_t fast_search_noavx(T* array, uintptr_t array_len, ...@@ -178,14 +183,14 @@ inline uintptr_t fast_search_noavx(T* array, uintptr_t array_len,
// Inserting one of the vectorized loop // Inserting one of the vectorized loop
#ifdef __SSE3__ #ifdef __SSE3__
if constexpr (std::is_same<T, uint32_t>::value) { if constexpr (is_uint32) {
#define MOVEMASK(x) _mm_movemask_ps(_mm_castsi128_ps(x)) #define MOVEMASK(x) _mm_movemask_ps(_mm_castsi128_ps(x))
#define EXTRACT(x) base::bits::CountTrailingZeros32(x) #define EXTRACT(x) base::bits::CountTrailingZeros32(x)
VECTORIZED_LOOP_x86(__m128i, __m128i, _mm_set1_epi32, _mm_cmpeq_epi32, VECTORIZED_LOOP_x86(__m128i, __m128i, _mm_set1_epi32, _mm_cmpeq_epi32,
MOVEMASK, EXTRACT) MOVEMASK, EXTRACT)
#undef MOVEMASK #undef MOVEMASK
#undef EXTRACT #undef EXTRACT
} else if constexpr (std::is_same<T, uint64_t>::value) { } else if constexpr (is_uint64) {
#define SET1(x) _mm_castsi128_ps(_mm_set1_epi64x(x)) #define SET1(x) _mm_castsi128_ps(_mm_set1_epi64x(x))
#define CMP(a, b) _mm_cmpeq_pd(_mm_castps_pd(a), _mm_castps_pd(b)) #define CMP(a, b) _mm_cmpeq_pd(_mm_castps_pd(a), _mm_castps_pd(b))
#define EXTRACT(x) base::bits::CountTrailingZeros32(x) #define EXTRACT(x) base::bits::CountTrailingZeros32(x)
...@@ -193,20 +198,20 @@ inline uintptr_t fast_search_noavx(T* array, uintptr_t array_len, ...@@ -193,20 +198,20 @@ inline uintptr_t fast_search_noavx(T* array, uintptr_t array_len,
#undef SET1 #undef SET1
#undef CMP #undef CMP
#undef EXTRACT #undef EXTRACT
} else if constexpr (std::is_same<T, double>::value) { } else if constexpr (is_double) {
#define EXTRACT(x) base::bits::CountTrailingZeros32(x) #define EXTRACT(x) base::bits::CountTrailingZeros32(x)
VECTORIZED_LOOP_x86(__m128d, __m128d, _mm_set1_pd, _mm_cmpeq_pd, VECTORIZED_LOOP_x86(__m128d, __m128d, _mm_set1_pd, _mm_cmpeq_pd,
_mm_movemask_pd, EXTRACT) _mm_movemask_pd, EXTRACT)
#undef EXTRACT #undef EXTRACT
} }
#elif defined(NEON64) #elif defined(NEON64)
if constexpr (std::is_same<T, uint32_t>::value) { if constexpr (is_uint32) {
VECTORIZED_LOOP_Neon(uint32x4_t, uint32x4_t, vdupq_n_u32, vceqq_u32, VECTORIZED_LOOP_Neon(uint32x4_t, uint32x4_t, vdupq_n_u32, vceqq_u32,
vmaxvq_u32) vmaxvq_u32)
} else if constexpr (std::is_same<T, uint64_t>::value) { } else if constexpr (is_uint64) {
VECTORIZED_LOOP_Neon(uint64x2_t, uint64x2_t, vdupq_n_u64, vceqq_u64, VECTORIZED_LOOP_Neon(uint64x2_t, uint64x2_t, vdupq_n_u64, vceqq_u64,
reinterpret_vmaxvq_u64) reinterpret_vmaxvq_u64)
} else if constexpr (std::is_same<T, double>::value) { } else if constexpr (is_double) {
VECTORIZED_LOOP_Neon(float64x2_t, uint64x2_t, vdupq_n_f64, vceqq_f64, VECTORIZED_LOOP_Neon(float64x2_t, uint64x2_t, vdupq_n_f64, vceqq_f64,
reinterpret_vmaxvq_u64) reinterpret_vmaxvq_u64)
} }
...@@ -240,9 +245,14 @@ template <typename T> ...@@ -240,9 +245,14 @@ template <typename T>
TARGET_AVX2 inline uintptr_t fast_search_avx(T* array, uintptr_t array_len, TARGET_AVX2 inline uintptr_t fast_search_avx(T* array, uintptr_t array_len,
uintptr_t index, uintptr_t index,
T search_element) { T search_element) {
static_assert(std::is_same<T, uint32_t>::value || static constexpr bool is_uint32 =
std::is_same<T, uint64_t>::value || sizeof(T) == sizeof(uint32_t) && std::is_integral<T>::value;
std::is_same<T, double>::value); static constexpr bool is_uint64 =
sizeof(T) == sizeof(uint64_t) && std::is_integral<T>::value;
static constexpr bool is_double =
sizeof(T) == sizeof(double) && std::is_floating_point<T>::value;
static_assert(is_uint32 || is_uint64 || is_double);
const int target_align = 32; const int target_align = 32;
// Scalar loop to reach desired alignment // Scalar loop to reach desired alignment
...@@ -256,21 +266,21 @@ TARGET_AVX2 inline uintptr_t fast_search_avx(T* array, uintptr_t array_len, ...@@ -256,21 +266,21 @@ TARGET_AVX2 inline uintptr_t fast_search_avx(T* array, uintptr_t array_len,
} }
// Generating vectorized loop // Generating vectorized loop
if constexpr (std::is_same<T, uint32_t>::value) { if constexpr (is_uint32) {
#define MOVEMASK(x) _mm256_movemask_ps(_mm256_castsi256_ps(x)) #define MOVEMASK(x) _mm256_movemask_ps(_mm256_castsi256_ps(x))
#define EXTRACT(x) base::bits::CountTrailingZeros32(x) #define EXTRACT(x) base::bits::CountTrailingZeros32(x)
VECTORIZED_LOOP_x86(__m256i, __m256i, _mm256_set1_epi32, _mm256_cmpeq_epi32, VECTORIZED_LOOP_x86(__m256i, __m256i, _mm256_set1_epi32, _mm256_cmpeq_epi32,
MOVEMASK, EXTRACT) MOVEMASK, EXTRACT)
#undef MOVEMASK #undef MOVEMASK
#undef EXTRACT #undef EXTRACT
} else if constexpr (std::is_same<T, uint64_t>::value) { } else if constexpr (is_uint64) {
#define MOVEMASK(x) _mm256_movemask_pd(_mm256_castsi256_pd(x)) #define MOVEMASK(x) _mm256_movemask_pd(_mm256_castsi256_pd(x))
#define EXTRACT(x) base::bits::CountTrailingZeros32(x) #define EXTRACT(x) base::bits::CountTrailingZeros32(x)
VECTORIZED_LOOP_x86(__m256i, __m256i, _mm256_set1_epi64x, VECTORIZED_LOOP_x86(__m256i, __m256i, _mm256_set1_epi64x,
_mm256_cmpeq_epi64, MOVEMASK, EXTRACT) _mm256_cmpeq_epi64, MOVEMASK, EXTRACT)
#undef MOVEMASK #undef MOVEMASK
#undef EXTRACT #undef EXTRACT
} else if constexpr (std::is_same<T, double>::value) { } else if constexpr (is_double) {
#define CMP(a, b) _mm256_cmp_pd(a, b, _CMP_EQ_OQ) #define CMP(a, b) _mm256_cmp_pd(a, b, _CMP_EQ_OQ)
#define EXTRACT(x) base::bits::CountTrailingZeros32(x) #define EXTRACT(x) base::bits::CountTrailingZeros32(x)
VECTORIZED_LOOP_x86(__m256d, __m256d, _mm256_set1_pd, CMP, VECTORIZED_LOOP_x86(__m256d, __m256d, _mm256_set1_pd, CMP,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment