|
6 | 6 | using System.Runtime.CompilerServices; |
7 | 7 | using System.Runtime.InteropServices; |
8 | 8 | using System.Runtime.Intrinsics; |
9 | | -using System.Runtime.Intrinsics.X86; |
10 | 9 |
|
11 | 10 | namespace System.Numerics |
12 | 11 | { |
@@ -988,18 +987,8 @@ public static float Sum(Vector3 value) |
988 | 987 | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
989 | 988 | internal static Vector3 Sum(Vector128<float> value) |
990 | 989 | { |
991 | | - // Preserve Z while forming <Y + X, Z, Z, Z>, then add <Z, Y + X, Y + X, Y + X>. |
992 | | - // This broadcasts the sum without an extra addition of zero; NaN payloads can differ by lane. |
993 | | - if (Sse.IsSupported) |
994 | | - { |
995 | | - Vector128<float> pair = Sse.Shuffle(value, value, 0xA9); |
996 | | - pair = Sse.AddScalar(pair, value); |
997 | | - return (pair + Sse.Shuffle(pair, pair, 0x01)).AsVector3(); |
998 | | - } |
999 | | - |
1000 | | - Vector128<float> sum = Vector128.Shuffle(value, Vector128.Create(1, 2, 2, 2)); |
1001 | | - sum = sum.WithElement(0, sum.ToScalar() + value.ToScalar()); |
1002 | | - return (sum + Vector128.Shuffle(sum, Vector128.Create(1, 0, 0, 0))).AsVector3(); |
| 990 | + Vector128<float> sum = Vector128.Shuffle(value, Vector128.Create(1, 0, 3, 2)) + value; |
| 991 | + return Vector128.Create((Vector128.Shuffle(value, Vector128.Create(2)) + sum).ToScalar()).AsVector3(); |
1003 | 992 | } |
1004 | 993 |
|
1005 | 994 | /// <summary>Transforms a vector by a specified 4x4 matrix.</summary> |
|
0 commit comments