Skip to content

Commit 77d3a8e

Browse files
committed
Make vector shift and rotate functions const
1 parent 8b187e9 commit 77d3a8e

File tree

3 files changed

+363
-244
lines changed

3 files changed

+363
-244
lines changed

crates/core_arch/src/x86/avx2.rs

Lines changed: 30 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2818,8 +2818,9 @@ pub const fn _mm256_bslli_epi128<const IMM8: i32>(a: __m256i) -> __m256i {
28182818
#[target_feature(enable = "avx2")]
28192819
#[cfg_attr(test, assert_instr(vpsllvd))]
28202820
#[stable(feature = "simd_x86", since = "1.27.0")]
2821-
pub fn _mm_sllv_epi32(a: __m128i, count: __m128i) -> __m128i {
2822-
unsafe { transmute(psllvd(a.as_i32x4(), count.as_i32x4())) }
2821+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
2822+
pub const fn _mm_sllv_epi32(a: __m128i, count: __m128i) -> __m128i {
2823+
unsafe { transmute(simd_shl(a.as_u32x4(), count.as_u32x4())) }
28232824
}
28242825

28252826
/// Shifts packed 32-bit integers in `a` left by the amount
@@ -2831,8 +2832,9 @@ pub fn _mm_sllv_epi32(a: __m128i, count: __m128i) -> __m128i {
28312832
#[target_feature(enable = "avx2")]
28322833
#[cfg_attr(test, assert_instr(vpsllvd))]
28332834
#[stable(feature = "simd_x86", since = "1.27.0")]
2834-
pub fn _mm256_sllv_epi32(a: __m256i, count: __m256i) -> __m256i {
2835-
unsafe { transmute(psllvd256(a.as_i32x8(), count.as_i32x8())) }
2835+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
2836+
pub const fn _mm256_sllv_epi32(a: __m256i, count: __m256i) -> __m256i {
2837+
unsafe { transmute(simd_shl(a.as_u32x8(), count.as_u32x8())) }
28362838
}
28372839

28382840
/// Shifts packed 64-bit integers in `a` left by the amount
@@ -2844,8 +2846,9 @@ pub fn _mm256_sllv_epi32(a: __m256i, count: __m256i) -> __m256i {
28442846
#[target_feature(enable = "avx2")]
28452847
#[cfg_attr(test, assert_instr(vpsllvq))]
28462848
#[stable(feature = "simd_x86", since = "1.27.0")]
2847-
pub fn _mm_sllv_epi64(a: __m128i, count: __m128i) -> __m128i {
2848-
unsafe { transmute(psllvq(a.as_i64x2(), count.as_i64x2())) }
2849+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
2850+
pub const fn _mm_sllv_epi64(a: __m128i, count: __m128i) -> __m128i {
2851+
unsafe { transmute(simd_shl(a.as_u64x2(), count.as_u64x2())) }
28492852
}
28502853

28512854
/// Shifts packed 64-bit integers in `a` left by the amount
@@ -2857,8 +2860,9 @@ pub fn _mm_sllv_epi64(a: __m128i, count: __m128i) -> __m128i {
28572860
#[target_feature(enable = "avx2")]
28582861
#[cfg_attr(test, assert_instr(vpsllvq))]
28592862
#[stable(feature = "simd_x86", since = "1.27.0")]
2860-
pub fn _mm256_sllv_epi64(a: __m256i, count: __m256i) -> __m256i {
2861-
unsafe { transmute(psllvq256(a.as_i64x4(), count.as_i64x4())) }
2863+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
2864+
pub const fn _mm256_sllv_epi64(a: __m256i, count: __m256i) -> __m256i {
2865+
unsafe { transmute(simd_shl(a.as_u64x4(), count.as_u64x4())) }
28622866
}
28632867

28642868
/// Shifts packed 16-bit integers in `a` right by `count` while
@@ -2923,8 +2927,9 @@ pub const fn _mm256_srai_epi32<const IMM8: i32>(a: __m256i) -> __m256i {
29232927
#[target_feature(enable = "avx2")]
29242928
#[cfg_attr(test, assert_instr(vpsravd))]
29252929
#[stable(feature = "simd_x86", since = "1.27.0")]
2926-
pub fn _mm_srav_epi32(a: __m128i, count: __m128i) -> __m128i {
2927-
unsafe { transmute(psravd(a.as_i32x4(), count.as_i32x4())) }
2930+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
2931+
pub const fn _mm_srav_epi32(a: __m128i, count: __m128i) -> __m128i {
2932+
unsafe { transmute(simd_shr(a.as_i32x4(), count.as_i32x4())) }
29282933
}
29292934

29302935
/// Shifts packed 32-bit integers in `a` right by the amount specified by the
@@ -2935,8 +2940,9 @@ pub fn _mm_srav_epi32(a: __m128i, count: __m128i) -> __m128i {
29352940
#[target_feature(enable = "avx2")]
29362941
#[cfg_attr(test, assert_instr(vpsravd))]
29372942
#[stable(feature = "simd_x86", since = "1.27.0")]
2938-
pub fn _mm256_srav_epi32(a: __m256i, count: __m256i) -> __m256i {
2939-
unsafe { transmute(psravd256(a.as_i32x8(), count.as_i32x8())) }
2943+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
2944+
pub const fn _mm256_srav_epi32(a: __m256i, count: __m256i) -> __m256i {
2945+
unsafe { transmute(simd_shr(a.as_i32x8(), count.as_i32x8())) }
29402946
}
29412947

29422948
/// Shifts 128-bit lanes in `a` right by `imm8` bytes while shifting in zeros.
@@ -3123,8 +3129,9 @@ pub const fn _mm256_srli_epi64<const IMM8: i32>(a: __m256i) -> __m256i {
31233129
#[target_feature(enable = "avx2")]
31243130
#[cfg_attr(test, assert_instr(vpsrlvd))]
31253131
#[stable(feature = "simd_x86", since = "1.27.0")]
3126-
pub fn _mm_srlv_epi32(a: __m128i, count: __m128i) -> __m128i {
3127-
unsafe { transmute(psrlvd(a.as_i32x4(), count.as_i32x4())) }
3132+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
3133+
pub const fn _mm_srlv_epi32(a: __m128i, count: __m128i) -> __m128i {
3134+
unsafe { transmute(simd_shr(a.as_u32x4(), count.as_u32x4())) }
31283135
}
31293136

31303137
/// Shifts packed 32-bit integers in `a` right by the amount specified by
@@ -3135,8 +3142,9 @@ pub fn _mm_srlv_epi32(a: __m128i, count: __m128i) -> __m128i {
31353142
#[target_feature(enable = "avx2")]
31363143
#[cfg_attr(test, assert_instr(vpsrlvd))]
31373144
#[stable(feature = "simd_x86", since = "1.27.0")]
3138-
pub fn _mm256_srlv_epi32(a: __m256i, count: __m256i) -> __m256i {
3139-
unsafe { transmute(psrlvd256(a.as_i32x8(), count.as_i32x8())) }
3145+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
3146+
pub const fn _mm256_srlv_epi32(a: __m256i, count: __m256i) -> __m256i {
3147+
unsafe { transmute(simd_shr(a.as_u32x8(), count.as_u32x8())) }
31403148
}
31413149

31423150
/// Shifts packed 64-bit integers in `a` right by the amount specified by
@@ -3147,8 +3155,9 @@ pub fn _mm256_srlv_epi32(a: __m256i, count: __m256i) -> __m256i {
31473155
#[target_feature(enable = "avx2")]
31483156
#[cfg_attr(test, assert_instr(vpsrlvq))]
31493157
#[stable(feature = "simd_x86", since = "1.27.0")]
3150-
pub fn _mm_srlv_epi64(a: __m128i, count: __m128i) -> __m128i {
3151-
unsafe { transmute(psrlvq(a.as_i64x2(), count.as_i64x2())) }
3158+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
3159+
pub const fn _mm_srlv_epi64(a: __m128i, count: __m128i) -> __m128i {
3160+
unsafe { transmute(simd_shr(a.as_u64x2(), count.as_u64x2())) }
31523161
}
31533162

31543163
/// Shifts packed 64-bit integers in `a` right by the amount specified by
@@ -3159,8 +3168,9 @@ pub fn _mm_srlv_epi64(a: __m128i, count: __m128i) -> __m128i {
31593168
#[target_feature(enable = "avx2")]
31603169
#[cfg_attr(test, assert_instr(vpsrlvq))]
31613170
#[stable(feature = "simd_x86", since = "1.27.0")]
3162-
pub fn _mm256_srlv_epi64(a: __m256i, count: __m256i) -> __m256i {
3163-
unsafe { transmute(psrlvq256(a.as_i64x4(), count.as_i64x4())) }
3171+
#[rustc_const_unstable(feature = "stdarch_const_intrinsics", issue = "none")]
3172+
pub const fn _mm256_srlv_epi64(a: __m256i, count: __m256i) -> __m256i {
3173+
unsafe { transmute(simd_shr(a.as_u64x4(), count.as_u64x4())) }
31643174
}
31653175

31663176
/// Load 256-bits of integer data from memory into dst using a non-temporal memory hint. mem_addr
@@ -3764,36 +3774,16 @@ unsafe extern "C" {
37643774
fn pslld(a: i32x8, count: i32x4) -> i32x8;
37653775
#[link_name = "llvm.x86.avx2.psll.q"]
37663776
fn psllq(a: i64x4, count: i64x2) -> i64x4;
3767-
#[link_name = "llvm.x86.avx2.psllv.d"]
3768-
fn psllvd(a: i32x4, count: i32x4) -> i32x4;
3769-
#[link_name = "llvm.x86.avx2.psllv.d.256"]
3770-
fn psllvd256(a: i32x8, count: i32x8) -> i32x8;
3771-
#[link_name = "llvm.x86.avx2.psllv.q"]
3772-
fn psllvq(a: i64x2, count: i64x2) -> i64x2;
3773-
#[link_name = "llvm.x86.avx2.psllv.q.256"]
3774-
fn psllvq256(a: i64x4, count: i64x4) -> i64x4;
37753777
#[link_name = "llvm.x86.avx2.psra.w"]
37763778
fn psraw(a: i16x16, count: i16x8) -> i16x16;
37773779
#[link_name = "llvm.x86.avx2.psra.d"]
37783780
fn psrad(a: i32x8, count: i32x4) -> i32x8;
3779-
#[link_name = "llvm.x86.avx2.psrav.d"]
3780-
fn psravd(a: i32x4, count: i32x4) -> i32x4;
3781-
#[link_name = "llvm.x86.avx2.psrav.d.256"]
3782-
fn psravd256(a: i32x8, count: i32x8) -> i32x8;
37833781
#[link_name = "llvm.x86.avx2.psrl.w"]
37843782
fn psrlw(a: i16x16, count: i16x8) -> i16x16;
37853783
#[link_name = "llvm.x86.avx2.psrl.d"]
37863784
fn psrld(a: i32x8, count: i32x4) -> i32x8;
37873785
#[link_name = "llvm.x86.avx2.psrl.q"]
37883786
fn psrlq(a: i64x4, count: i64x2) -> i64x4;
3789-
#[link_name = "llvm.x86.avx2.psrlv.d"]
3790-
fn psrlvd(a: i32x4, count: i32x4) -> i32x4;
3791-
#[link_name = "llvm.x86.avx2.psrlv.d.256"]
3792-
fn psrlvd256(a: i32x8, count: i32x8) -> i32x8;
3793-
#[link_name = "llvm.x86.avx2.psrlv.q"]
3794-
fn psrlvq(a: i64x2, count: i64x2) -> i64x2;
3795-
#[link_name = "llvm.x86.avx2.psrlv.q.256"]
3796-
fn psrlvq256(a: i64x4, count: i64x4) -> i64x4;
37973787
#[link_name = "llvm.x86.avx2.pshuf.b"]
37983788
fn pshufb(a: u8x32, b: u8x32) -> u8x32;
37993789
#[link_name = "llvm.x86.avx2.permd"]

0 commit comments

Comments
 (0)