From 6dc719ea1cfe3ca190514997d5bb00fca0e3fbb6 Mon Sep 17 00:00:00 2001 From: Pete Harris Date: Sat, 16 Nov 2024 11:54:56 +0000 Subject: [PATCH] Remove vint4 hadd_s() (#527) --- Source/UnitTest/test_simd.cpp | 12 ------------ Source/astcenc_vecmathlib_neon_4.h | 9 --------- Source/astcenc_vecmathlib_none_4.h | 8 -------- Source/astcenc_vecmathlib_sse_4.h | 16 ---------------- 4 files changed, 45 deletions(-) diff --git a/Source/UnitTest/test_simd.cpp b/Source/UnitTest/test_simd.cpp index 24fb63f5..349d9bfb 100644 --- a/Source/UnitTest/test_simd.cpp +++ b/Source/UnitTest/test_simd.cpp @@ -1651,18 +1651,6 @@ TEST(vint4, hmax) EXPECT_EQ(r2.lane<3>(), 5); } -/** @brief Test vint4 hadd_s. */ -TEST(vint4, hadd_s) -{ - vint4 a1(1, 3, 5, 7); - int r1 = hadd_s(a1); - EXPECT_EQ(r1, 16); - - vint4 a2(1, 2, -1, 5); - int r2 = hadd_s(a2); - EXPECT_EQ(r2, 7); -} - /** @brief Test vint4 hadd_rgb_s. */ TEST(vint4, hadd_rgb_s) { diff --git a/Source/astcenc_vecmathlib_neon_4.h b/Source/astcenc_vecmathlib_neon_4.h index 7cfd0a2f..f31063d9 100644 --- a/Source/astcenc_vecmathlib_neon_4.h +++ b/Source/astcenc_vecmathlib_neon_4.h @@ -582,15 +582,6 @@ ASTCENC_SIMD_INLINE vint4 hmax(vint4 a) return vint4(vmaxvq_s32(a.m)); } -/** - * @brief Return the horizontal sum of a vector. - */ -ASTCENC_SIMD_INLINE int hadd_s(vint4 a) -{ - int32x2_t t = vadd_s32(vget_high_s32(a.m), vget_low_s32(a.m)); - return vget_lane_s32(vpadd_s32(t, t), 0); -} - /** * @brief Store a vector to a 16B aligned memory address. */ diff --git a/Source/astcenc_vecmathlib_none_4.h b/Source/astcenc_vecmathlib_none_4.h index 862f592a..b2cde419 100644 --- a/Source/astcenc_vecmathlib_none_4.h +++ b/Source/astcenc_vecmathlib_none_4.h @@ -646,14 +646,6 @@ ASTCENC_SIMD_INLINE vint4 hmax(vint4 a) return vint4(std::max(b, c)); } -/** - * @brief Return the horizontal sum of vector lanes as a scalar. - */ -ASTCENC_SIMD_INLINE int hadd_s(vint4 a) -{ - return a.m[0] + a.m[1] + a.m[2] + a.m[3]; -} - /** * @brief Store a vector to an aligned memory address. */ diff --git a/Source/astcenc_vecmathlib_sse_4.h b/Source/astcenc_vecmathlib_sse_4.h index 938ead66..f6991e46 100644 --- a/Source/astcenc_vecmathlib_sse_4.h +++ b/Source/astcenc_vecmathlib_sse_4.h @@ -621,22 +621,6 @@ ASTCENC_SIMD_INLINE vint4 hmax(vint4 a) return a; } -/** - * @brief Return the horizontal sum of a vector as a scalar. - */ -ASTCENC_SIMD_INLINE int hadd_s(vint4 a) -{ - // Add top and bottom halves, lane 1/0 - __m128i fold = _mm_castps_si128(_mm_movehl_ps(_mm_castsi128_ps(a.m), - _mm_castsi128_ps(a.m))); - __m128i t = _mm_add_epi32(a.m, fold); - - // Add top and bottom halves, lane 0 (_mm_hadd_ps exists but slow) - t = _mm_add_epi32(t, _mm_shuffle_epi32(t, 0x55)); - - return _mm_cvtsi128_si32(t); -} - /** * @brief Store a vector to a 16B aligned memory address. */