diff options
| author | Folkert de Vries <folkert@folkertdev.nl> | 2025-02-22 21:23:57 +0100 |
|---|---|---|
| committer | Amanieu d'Antras <amanieu@gmail.com> | 2025-02-23 23:21:06 +0000 |
| commit | 2dbc1e9b25b285f2aec7da8c059679c8bf31afcc (patch) | |
| tree | a8492ab84bb9de03b0a80ed4fdb5a330cebaa5ee /library | |
| parent | 1fab09a95c60d9188aafde8997de56e47ff6c983 (diff) | |
| download | rust-2dbc1e9b25b285f2aec7da8c059679c8bf31afcc.tar.gz rust-2dbc1e9b25b285f2aec7da8c059679c8bf31afcc.zip | |
use `simd_shuffle` in the implementation of `vec_splat`
Diffstat (limited to 'library')
| -rw-r--r-- | library/stdarch/crates/core_arch/src/powerpc/altivec.rs | 19 | ||||
| -rw-r--r-- | library/stdarch/crates/core_arch/src/simd.rs | 4 |
2 files changed, 7 insertions, 16 deletions
diff --git a/library/stdarch/crates/core_arch/src/powerpc/altivec.rs b/library/stdarch/crates/core_arch/src/powerpc/altivec.rs index 466e9879b96..95c67619fc9 100644 --- a/library/stdarch/crates/core_arch/src/powerpc/altivec.rs +++ b/library/stdarch/crates/core_arch/src/powerpc/altivec.rs @@ -1455,8 +1455,7 @@ mod sealed { #[cfg_attr(test, assert_instr(vspltb, IMM4 = 15))] unsafe fn vspltb<const IMM4: u32>(a: vector_signed_char) -> vector_signed_char { static_assert_uimm_bits!(IMM4, 4); - let b = u8x16::splat(IMM4 as u8); - vec_perm(a, a, transmute(b)) + simd_shuffle(a, a, const { u32x16::from_array([IMM4; 16]) }) } #[inline] @@ -1464,12 +1463,7 @@ mod sealed { #[cfg_attr(test, assert_instr(vsplth, IMM3 = 7))] unsafe fn vsplth<const IMM3: u32>(a: vector_signed_short) -> vector_signed_short { static_assert_uimm_bits!(IMM3, 3); - let b0 = IMM3 as u8 * 2; - let b1 = b0 + 1; - let b = u8x16::new( - b0, b1, b0, b1, b0, b1, b0, b1, b0, b1, b0, b1, b0, b1, b0, b1, - ); - vec_perm(a, a, transmute(b)) + simd_shuffle(a, a, const { u32x8::from_array([IMM3; 8]) }) } #[inline] @@ -1478,14 +1472,7 @@ mod sealed { #[cfg_attr(all(test, target_feature = "vsx"), assert_instr(xxspltw, IMM2 = 3))] unsafe fn vspltw<const IMM2: u32>(a: vector_signed_int) -> vector_signed_int { static_assert_uimm_bits!(IMM2, 2); - let b0 = IMM2 as u8 * 4; - let b1 = b0 + 1; - let b2 = b0 + 2; - let b3 = b0 + 3; - let b = u8x16::new( - b0, b1, b2, b3, b0, b1, b2, b3, b0, b1, b2, b3, b0, b1, b2, b3, - ); - vec_perm(a, a, transmute(b)) + simd_shuffle(a, a, const { u32x4::from_array([IMM2; 4]) }) } #[unstable(feature = "stdarch_powerpc", issue = "111145")] diff --git a/library/stdarch/crates/core_arch/src/simd.rs b/library/stdarch/crates/core_arch/src/simd.rs index 9adc2f50890..a97d45c3bd3 100644 --- a/library/stdarch/crates/core_arch/src/simd.rs +++ b/library/stdarch/crates/core_arch/src/simd.rs @@ -17,6 +17,10 @@ macro_rules! simd_ty { pub(crate) const fn new($($param_name: $elem_type),*) -> Self { $id([$($param_name),*]) } + #[inline(always)] + pub(crate) const fn from_array(elements: [$elem_type; $len]) -> Self { + $id(elements) + } // FIXME: Workaround rust@60637 #[inline(always)] pub(crate) fn splat(value: $elem_type) -> Self { |
