Skip to content

Commit 01683d0

Browse files
committed
Remove duplicate mul_add, keep only mul_sub
StdFloat already provides mul_add. This PR now only adds mul_sub.
1 parent f963261 commit 01683d0

File tree

4 files changed

+3
-27
lines changed

4 files changed

+3
-27
lines changed

crates/core_simd/examples/dot_product.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// Add these imports to use the stdsimd library
55
#![feature(portable_simd)]
66
use core_simd::simd::prelude::*;
7+
use std_float::StdFloat;
78

89
// This is your barebones dot product implementation:
910
// Take 2 vectors, multiply them element wise and *then*

crates/core_simd/examples/fma.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
#![feature(portable_simd)]
44
use core_simd::simd::prelude::*;
5+
use std_float::StdFloat;
56

67
fn main() {
78
let a = f32x4::from_array([1.0, 2.0, 3.0, 4.0]);

crates/core_simd/src/simd/num/float.rs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -235,27 +235,6 @@ pub trait SimdFloat: Copy + Sealed {
235235
/// assert!(v.reduce_min().is_nan());
236236
/// ```
237237
fn reduce_min(self) -> Self::Scalar;
238-
239-
/// Fused multiply-add: computes `(self * a) + b` with only one rounding error.
240-
///
241-
/// This produces more accurate results than separate multiply and add operations,
242-
/// and can be faster on platforms with dedicated FMA instructions.
243-
///
244-
/// # Examples
245-
///
246-
/// ```
247-
/// # #![feature(portable_simd)]
248-
/// # #[cfg(feature = "as_crate")] use core_simd::simd;
249-
/// # #[cfg(not(feature = "as_crate"))] use core::simd;
250-
/// # use simd::prelude::*;
251-
/// let a = f32x4::splat(2.0);
252-
/// let b = f32x4::splat(3.0);
253-
/// let c = f32x4::splat(4.0);
254-
/// assert_eq!(a.mul_add(b, c), f32x4::splat(10.0)); // 2*3 + 4 = 10
255-
/// ```
256-
#[must_use = "method returns a new vector and does not mutate the original value"]
257-
fn mul_add(self, a: Self, b: Self) -> Self;
258-
259238
/// Fused multiply-subtract: computes `(self * a) - b` with only one rounding error.
260239
///
261240
/// This produces more accurate results than separate multiply and subtract operations,
@@ -480,12 +459,6 @@ macro_rules! impl_trait {
480459
unsafe { core::intrinsics::simd::simd_reduce_min(self) }
481460
}
482461

483-
#[inline]
484-
fn mul_add(self, a: Self, b: Self) -> Self {
485-
// Safety: `self`, `a`, and `b` are float vectors
486-
unsafe { core::intrinsics::simd::simd_fma(self, a, b) }
487-
}
488-
489462
#[inline]
490463
fn mul_sub(self, a: Self, b: Self) -> Self {
491464
// self * a - b = self * a + (-b)

crates/core_simd/tests/fma.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![feature(portable_simd)]
22

33
use core_simd::simd::prelude::*;
4+
use std_float::StdFloat;
45

56
#[test]
67
fn test_mul_add_basic() {

0 commit comments

Comments
 (0)