sse: add compile time range checks
@@ -1674,7 +1674,8 @@ simde_mm_div_ss (simde__m128 a, simde__m128 b) {
SIMDE__FUNCTION_ATTRIBUTES
int16_t
-simde_mm_extract_pi16 (simde__m64 a, const int imm8) {
+simde_mm_extract_pi16 (simde__m64 a, const int imm8)
+ HEDLEY_REQUIRE_MSG((imm8 & 3) == imm8, "imm8 must be in range [0, 3]") {
return simde__m64_to_private(a).i16[imm8];
}
#if defined(SIMDE_SSE_NATIVE) && defined(SIMDE_ARCH_X86_MMX) && !defined(HEDLEY_PGI_VERSION)
@@ -1756,7 +1757,8 @@ SIMDE_MM_SET_ROUNDING_MODE(unsigned int a) {
SIMDE__FUNCTION_ATTRIBUTES
simde__m64
-simde_mm_insert_pi16 (simde__m64 a, int16_t i, const int imm8) {
+simde_mm_insert_pi16 (simde__m64 a, int16_t i, const int imm8)
+ HEDLEY_REQUIRE_MSG((imm8 & 3) == imm8, "imm8 must be in range [0, 3]") {
simde__m64_private
r_,
a_ = simde__m64_to_private(a);
@@ -2796,7 +2798,8 @@ simde_mm_sfence (void) {
#else
SIMDE__FUNCTION_ATTRIBUTES
simde__m64
-simde_mm_shuffle_pi16 (simde__m64 a, const int imm8) {
+simde_mm_shuffle_pi16 (simde__m64 a, const int imm8)
+ HEDLEY_REQUIRE_MSG((imm8 & 0xff) == imm8, "imm8 must be in range [0, 255]") {
simde__m64_private r_;
simde__m64_private a_ = simde__m64_to_private(a);
@@ -2837,7 +2840,8 @@ HEDLEY_DIAGNOSTIC_POP
#else
SIMDE__FUNCTION_ATTRIBUTES
simde__m128
-simde_mm_shuffle_ps (simde__m128 a, simde__m128 b, const int imm8) {
+simde_mm_shuffle_ps (simde__m128 a, simde__m128 b, const int imm8)
+ HEDLEY_REQUIRE_MSG((imm8 & 0xff) == imm8, "imm8 must be in range [0, 255]") {
simde__m128_private
r_,
a_ = simde__m128_to_private(a),
