Skip to content

Commit 597bc0c

Browse files
Update MultiplyAdd
1 parent 959e600 commit 597bc0c

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/ImageSharp/Common/Helpers/Vector256Utilities.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public static Vector256<float> MultiplyAdd(
146146
{
147147
if (Fma.IsSupported)
148148
{
149-
return Fma.MultiplyAdd(vm1, vm0, va);
149+
return Fma.MultiplyAdd(vm0, vm1, va);
150150
}
151151

152152
if (Avx.IsSupported)

src/ImageSharp/Common/Helpers/Vector512Utilities.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,15 @@ public static Vector512<float> RoundToNearestInteger(Vector512<float> vector)
145145
public static Vector512<float> MultiplyAdd(
146146
Vector512<float> va,
147147
Vector512<float> vm0,
148-
Vector512<float> vm1) => va + (vm0 * vm1);
148+
Vector512<float> vm1)
149+
{
150+
if (Avx512F.IsSupported)
151+
{
152+
return Avx512F.FusedMultiplyAdd(vm0, vm1, va);
153+
}
154+
155+
return va + (vm0 * vm1);
156+
}
149157

150158
[DoesNotReturn]
151159
private static void ThrowUnreachableException() => throw new UnreachableException();

0 commit comments

Comments
 (0)