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
This commit is contained in:
Folkert de Vries 2025-01-22 17:06:52 +01:00 committed by Amanieu d'Antras
parent cefc61d22e
commit bed15215fb
2 changed files with 21 additions and 0 deletions

View file

@ -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")]

View file

@ -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<Other> {
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;