Skip to content

Commit b98535c

Browse files
committed
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
1 parent 65e036b commit b98535c

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

Diff for: crates/core_arch/src/s390x/macros.rs

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
#![allow(unused_imports)] // FIXME remove when more tests are added
33

44
macro_rules! test_impl {
5+
($fun:ident ($($v:ident : $ty:ty),*) -> $r:ty [$call:ident, _]) => {
6+
#[inline]
7+
#[target_feature(enable = "vector")]
8+
pub unsafe fn $fun ($($v : $ty),*) -> $r {
9+
$call ($($v),*)
10+
}
11+
};
512
($fun:ident +($($v:ident : $ty:ty),*) -> $r:ty [$call:ident, $instr:ident]) => {
613
#[inline]
714
#[target_feature(enable = "vector")]

Diff for: crates/core_arch/src/s390x/vector.rs

+14
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,13 @@ mod sealed {
330330

331331
impl_vec_trait! { [VectorMax vec_max] ~(vmxlb, vmxb, vmxlh, vmxh, vmxlf, vmxf, vmxlg, vmxg) }
332332

333+
// FIXME(vector-enhancements-1) test for the `vfmaxsb` etc. instruction
334+
test_impl! { vec_vfmaxsb (a: vector_float, b: vector_float) -> vector_float [simd_fmax, _] }
335+
test_impl! { vec_vfmaxdb (a: vector_double, b: vector_double) -> vector_double [simd_fmax, _] }
336+
337+
impl_vec_trait!([VectorMax vec_max] vec_vfmaxsb (vector_float, vector_float) -> vector_float);
338+
impl_vec_trait!([VectorMax vec_max] vec_vfmaxdb (vector_double, vector_double) -> vector_double);
339+
333340
#[unstable(feature = "stdarch_s390x", issue = "135681")]
334341
pub trait VectorMin<Other> {
335342
type Result;
@@ -348,6 +355,13 @@ mod sealed {
348355

349356
impl_vec_trait! { [VectorMin vec_min] ~(vmxlb, vmxb, vmxlh, vmxh, vmxlf, vmxf, vmxlg, vmxg) }
350357

358+
// FIXME(vector-enhancements-1) test for the `vfminsb` etc. instruction
359+
test_impl! { vec_vfminsb (a: vector_float, b: vector_float) -> vector_float [simd_fmin, _] }
360+
test_impl! { vec_vfmindb (a: vector_double, b: vector_double) -> vector_double [simd_fmin, _] }
361+
362+
impl_vec_trait!([VectorMin vec_min] vec_vfminsb (vector_float, vector_float) -> vector_float);
363+
impl_vec_trait!([VectorMin vec_min] vec_vfmindb (vector_double, vector_double) -> vector_double);
364+
351365
#[unstable(feature = "stdarch_s390x", issue = "135681")]
352366
pub trait VectorAbs {
353367
unsafe fn vec_abs(self) -> Self;

0 commit comments

Comments
 (0)