agora inbox for [email protected]  
help / color / mirror / Atom feed
From: Nathan Bossart <[email protected]>
Subject: [PATCH v1 1/1] remove switch statement in vector8_shift_{left,right}
Date: Wed, 1 Jul 2026 19:30:59 -0500

---
 src/include/port/simd.h | 29 +++--------------------------
 1 file changed, 3 insertions(+), 26 deletions(-)

diff --git a/src/include/port/simd.h b/src/include/port/simd.h
index 50615aec7f4..25a26c81cce 100644
--- a/src/include/port/simd.h
+++ b/src/include/port/simd.h
@@ -548,10 +548,6 @@ vector8_pack_16(const Vector8 v1, const Vector8 v2)
 
 /*
  * Unsigned shift left of each 32-bit element in the vector by "i" bits.
- *
- * XXX AArch64 requires an integer literal, so we have to list all expected
- * values of "i" from all callers in a switch statement.  If you add a new
- * caller, be sure your expected values of "i" are handled.
  */
 #ifndef USE_NO_SIMD
 static inline Vector8
@@ -560,24 +556,13 @@ vector8_shift_left(const Vector8 v1, int i)
 #ifdef USE_SSE2
 	return _mm_slli_epi32(v1, i);
 #elif defined(USE_NEON)
-	switch (i)
-	{
-		case 4:
-			return (Vector8) vshlq_n_u32((Vector32) v1, 4);
-		default:
-			Assert(false);
-			return vector8_broadcast(0);
-	}
+	return (Vector8) vshlq_u32((Vector32) v1, vdupq_n_s32(i));
 #endif
 }
 #endif							/* ! USE_NO_SIMD */
 
 /*
  * Unsigned shift right of each 32-bit element in the vector by "i" bits.
- *
- * XXX AArch64 requires an integer literal, so we have to list all expected
- * values of "i" from all callers in a switch statement.  If you add a new
- * caller, be sure your expected values of "i" are handled.
  */
 #ifndef USE_NO_SIMD
 static inline Vector8
@@ -586,16 +571,8 @@ vector8_shift_right(const Vector8 v1, int i)
 #ifdef USE_SSE2
 	return _mm_srli_epi32(v1, i);
 #elif defined(USE_NEON)
-	switch (i)
-	{
-		case 4:
-			return (Vector8) vshrq_n_u32((Vector32) v1, 4);
-		case 8:
-			return (Vector8) vshrq_n_u32((Vector32) v1, 8);
-		default:
-			Assert(false);
-			return vector8_broadcast(0);
-	}
+	/* negative shift count means right shift */
+	return (Vector8) vshlq_u32((Vector32) v1, vdupq_n_s32(-i));
 #endif
 }
 #endif							/* ! USE_NO_SIMD */
-- 
2.50.1 (Apple Git-155)


--9YipY07vKHAnXga/--





view thread (28+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: [PATCH v1 1/1] remove switch statement in vector8_shift_{left,right}
  In-Reply-To: <no-message-id-661819@localhost>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox