diff --git a/library/stdarch/crates/core_arch/src/powerpc/altivec.rs b/library/stdarch/crates/core_arch/src/powerpc/altivec.rs index 466e9879b96c..95c67619fc91 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(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(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(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 9adc2f50890d..a97d45c3bd34 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 {