From bed15215fb73dae4fb161635d4e99b79e355e8e9 Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Wed, 22 Jan 2025 17:06:52 +0100 Subject: [PATCH] impl `VectorMax/Min` for `vector_float/double` these implementations work with just the vector target feature, but they only get a dedicated instruction in vector-enhancements-1 --- .../stdarch/crates/core_arch/src/s390x/macros.rs | 7 +++++++ .../stdarch/crates/core_arch/src/s390x/vector.rs | 14 ++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/library/stdarch/crates/core_arch/src/s390x/macros.rs b/library/stdarch/crates/core_arch/src/s390x/macros.rs index 92faf387bd72..4c11b1d00e0a 100644 --- a/library/stdarch/crates/core_arch/src/s390x/macros.rs +++ b/library/stdarch/crates/core_arch/src/s390x/macros.rs @@ -2,6 +2,13 @@ #![allow(unused_imports)] // FIXME remove when more tests are added macro_rules! test_impl { + ($fun:ident ($($v:ident : $ty:ty),*) -> $r:ty [$call:ident, _]) => { + #[inline] + #[target_feature(enable = "vector")] + pub unsafe fn $fun ($($v : $ty),*) -> $r { + $call ($($v),*) + } + }; ($fun:ident +($($v:ident : $ty:ty),*) -> $r:ty [$call:ident, $instr:ident]) => { #[inline] #[target_feature(enable = "vector")] diff --git a/library/stdarch/crates/core_arch/src/s390x/vector.rs b/library/stdarch/crates/core_arch/src/s390x/vector.rs index 420a8176bbab..808196dd071b 100644 --- a/library/stdarch/crates/core_arch/src/s390x/vector.rs +++ b/library/stdarch/crates/core_arch/src/s390x/vector.rs @@ -330,6 +330,13 @@ mod sealed { impl_vec_trait! { [VectorMax vec_max] ~(vmxlb, vmxb, vmxlh, vmxh, vmxlf, vmxf, vmxlg, vmxg) } + // FIXME(vector-enhancements-1) test for the `vfmaxsb` etc. instruction + test_impl! { vec_vfmaxsb (a: vector_float, b: vector_float) -> vector_float [simd_fmax, _] } + test_impl! { vec_vfmaxdb (a: vector_double, b: vector_double) -> vector_double [simd_fmax, _] } + + impl_vec_trait!([VectorMax vec_max] vec_vfmaxsb (vector_float, vector_float) -> vector_float); + impl_vec_trait!([VectorMax vec_max] vec_vfmaxdb (vector_double, vector_double) -> vector_double); + #[unstable(feature = "stdarch_s390x", issue = "135681")] pub trait VectorMin { type Result; @@ -348,6 +355,13 @@ mod sealed { impl_vec_trait! { [VectorMin vec_min] ~(vmxlb, vmxb, vmxlh, vmxh, vmxlf, vmxf, vmxlg, vmxg) } + // FIXME(vector-enhancements-1) test for the `vfminsb` etc. instruction + test_impl! { vec_vfminsb (a: vector_float, b: vector_float) -> vector_float [simd_fmin, _] } + test_impl! { vec_vfmindb (a: vector_double, b: vector_double) -> vector_double [simd_fmin, _] } + + impl_vec_trait!([VectorMin vec_min] vec_vfminsb (vector_float, vector_float) -> vector_float); + impl_vec_trait!([VectorMin vec_min] vec_vfmindb (vector_double, vector_double) -> vector_double); + #[unstable(feature = "stdarch_s390x", issue = "135681")] pub trait VectorAbs { unsafe fn vec_abs(self) -> Self;