Skip to content

Commit 7baa84b

Browse files
committed
add vec_nmsub
1 parent 83146e0 commit 7baa84b

File tree

1 file changed

+50
-4
lines changed

1 file changed

+50
-4
lines changed

crates/core_arch/src/s390x/vector.rs

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,47 @@ mod sealed {
649649
impl_vec_trait! { [VectorNabs vec_nabs] vec_nabs_f32 (vector_float) }
650650
impl_vec_trait! { [VectorNabs vec_nabs] vec_nabs_f64 (vector_double) }
651651

652+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
653+
pub trait VectorNmsub {
654+
unsafe fn vec_nmsub(self, b: Self, c: Self) -> Self;
655+
}
656+
657+
#[inline]
658+
#[target_feature(enable = "vector")]
659+
#[cfg_attr(
660+
all(test, target_feature = "vector-enhancements-2"),
661+
assert_instr(vfnmssb)
662+
)]
663+
unsafe fn vec_nmsub_f32(a: vector_float, b: vector_float, c: vector_float) -> vector_float {
664+
simd_neg(simd_fma(a, b, simd_neg(c)))
665+
}
666+
667+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
668+
impl VectorNmsub for vector_float {
669+
#[target_feature(enable = "vector")]
670+
unsafe fn vec_nmsub(self, b: Self, c: Self) -> Self {
671+
vec_nmsub_f32(self, b, c)
672+
}
673+
}
674+
675+
#[inline]
676+
#[target_feature(enable = "vector")]
677+
#[cfg_attr(
678+
all(test, target_feature = "vector-enhancements-2"),
679+
assert_instr(vfnmsdb)
680+
)]
681+
unsafe fn vec_nmsub_f64(a: vector_double, b: vector_double, c: vector_double) -> vector_double {
682+
simd_neg(simd_fma(a, b, simd_neg(c)))
683+
}
684+
685+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
686+
impl VectorNmsub for vector_double {
687+
#[target_feature(enable = "vector")]
688+
unsafe fn vec_nmsub(self, b: Self, c: Self) -> Self {
689+
vec_nmsub_f64(self, b, c)
690+
}
691+
}
692+
652693
#[unstable(feature = "stdarch_s390x", issue = "135681")]
653694
pub trait VectorSplat {
654695
unsafe fn vec_splat<const IMM: u32>(self) -> Self;
@@ -2571,13 +2612,18 @@ where
25712612
#[inline]
25722613
#[target_feature(enable = "vector")]
25732614
#[unstable(feature = "stdarch_s390x", issue = "135681")]
2574-
pub unsafe fn vec_nabs<T>(a: T) -> T
2575-
where
2576-
T: sealed::VectorNabs,
2577-
{
2615+
pub unsafe fn vec_nabs<T: sealed::VectorNabs>(a: T) -> T {
25782616
a.vec_nabs()
25792617
}
25802618

2619+
/// Vector Negative Multiply Subtract
2620+
#[inline]
2621+
#[target_feature(enable = "vector")]
2622+
#[unstable(feature = "stdarch_s390x", issue = "135681")]
2623+
pub unsafe fn vec_nmsub<T: sealed::VectorNmsub>(a: T, b: T, c: T) -> T {
2624+
a.vec_nmsub(b, c)
2625+
}
2626+
25812627
/// Vector square root.
25822628
#[inline]
25832629
#[target_feature(enable = "vector")]

0 commit comments

Comments
 (0)