diff --git a/src/ImageSharp/Common/Helpers/SimdUtils.HwIntrinsics.cs b/src/ImageSharp/Common/Helpers/SimdUtils.HwIntrinsics.cs
index 4faf577fd9..00c0d89f02 100644
--- a/src/ImageSharp/Common/Helpers/SimdUtils.HwIntrinsics.cs
+++ b/src/ImageSharp/Common/Helpers/SimdUtils.HwIntrinsics.cs
@@ -532,6 +532,7 @@ namespace SixLabors.ImageSharp
///
/// Performs a multiplication and an addition of the .
///
+ /// ret = (vm0 * vm1) + va
/// The vector to add to the intermediate result.
/// The first vector to multiply.
/// The second vector to multiply.
@@ -552,6 +553,31 @@ namespace SixLabors.ImageSharp
}
}
+ ///
+ /// Performs a multiplication and a substraction of the .
+ ///
+ /// ret = (vm0 * vm1) - vs
+ /// The vector to substract from the intermediate result.
+ /// The first vector to multiply.
+ /// The second vector to multiply.
+ /// The .
+ [MethodImpl(InliningOptions.ShortMethod)]
+ public static Vector256 MultiplySubstract(
+ in Vector256 vs,
+ in Vector256 vm0,
+ in Vector256 vm1)
+ {
+ if (Fma.IsSupported)
+ {
+ return Fma.MultiplySubtract(vm1, vm0, vs);
+ }
+ else
+ {
+ return Avx.Subtract(Avx.Multiply(vm0, vm1), vs);
+ }
+ }
+
+
///
/// as many elements as possible, slicing them down (keeping the remainder).
///