Skip to content

Commit

Permalink
_mm_srai_epi{16, 32}: statically assert the const generic parameter…
Browse files Browse the repository at this point in the history
… `imm8` is in range
  • Loading branch information
lqd committed Feb 28, 2021
1 parent 66463d5 commit fb1798b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions crates/core_arch/src/x86/sse2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,7 @@ pub unsafe fn _mm_sll_epi64(a: __m128i, count: __m128i) -> __m128i {
#[rustc_legacy_const_generics(1)]
#[stable(feature = "simd_x86", since = "1.27.0")]
pub unsafe fn _mm_srai_epi16<const imm8: i32>(a: __m128i) -> __m128i {
static_assert_imm8!(imm8);
transmute(psraiw(a.as_i16x8(), imm8))
}

Expand All @@ -622,6 +623,7 @@ pub unsafe fn _mm_sra_epi16(a: __m128i, count: __m128i) -> __m128i {
#[rustc_legacy_const_generics(1)]
#[stable(feature = "simd_x86", since = "1.27.0")]
pub unsafe fn _mm_srai_epi32<const imm8: i32>(a: __m128i) -> __m128i {
static_assert_imm8!(imm8);
transmute(psraid(a.as_i32x4(), imm8))
}

Expand Down

0 comments on commit fb1798b

Please sign in to comment.