Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 21ca6ac

Browse files
committed
prefer CompareNotEqual than CompareEqual
1 parent f59cf11 commit 21ca6ac

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

src/System.Numerics.Vectors/src/System/Numerics/Matrix4x4.cs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1850,7 +1850,7 @@ public static unsafe Matrix4x4 Lerp(Matrix4x4 matrix1, Matrix4x4 matrix2, float
18501850
/// </summary>
18511851
/// <param name="value">The source matrix.</param>
18521852
/// <returns>The negated matrix.</returns>
1853-
public static unsafe Matrix4x4 Negate(Matrix4x4 value)
1853+
public static Matrix4x4 Negate(Matrix4x4 value)
18541854
{
18551855
if (Sse.IsSupported)
18561856
{
@@ -1887,7 +1887,7 @@ public static unsafe Matrix4x4 Negate(Matrix4x4 value)
18871887
/// <param name="value1">The first source matrix.</param>
18881888
/// <param name="value2">The second source matrix.</param>
18891889
/// <returns>The resulting matrix.</returns>
1890-
public static unsafe Matrix4x4 Add(Matrix4x4 value1, Matrix4x4 value2)
1890+
public static Matrix4x4 Add(Matrix4x4 value1, Matrix4x4 value2)
18911891
{
18921892
if (Sse.IsSupported)
18931893
{
@@ -1924,7 +1924,7 @@ public static unsafe Matrix4x4 Add(Matrix4x4 value1, Matrix4x4 value2)
19241924
/// <param name="value1">The first source matrix.</param>
19251925
/// <param name="value2">The second source matrix.</param>
19261926
/// <returns>The result of the subtraction.</returns>
1927-
public static unsafe Matrix4x4 Subtract(Matrix4x4 value1, Matrix4x4 value2)
1927+
public static Matrix4x4 Subtract(Matrix4x4 value1, Matrix4x4 value2)
19281928
{
19291929
if (Sse.IsSupported)
19301930
{
@@ -2005,7 +2005,7 @@ public static Matrix4x4 Multiply(Matrix4x4 value1, Matrix4x4 value2)
20052005
/// <param name="value1">The source matrix.</param>
20062006
/// <param name="value2">The scaling factor.</param>
20072007
/// <returns>The scaled matrix.</returns>
2008-
public static unsafe Matrix4x4 Multiply(Matrix4x4 value1, float value2)
2008+
public static Matrix4x4 Multiply(Matrix4x4 value1, float value2)
20092009
{
20102010
if (Sse.IsSupported)
20112011
{
@@ -2280,10 +2280,10 @@ public static unsafe Matrix4x4 Multiply(Matrix4x4 value1, float value2)
22802280
if (Sse.IsSupported)
22812281
{
22822282
return
2283-
Sse.MoveMask(Sse.CompareEqual(Sse.LoadVector128(&value1.M11), Sse.LoadVector128(&value2.M11))) == 0xF &&
2284-
Sse.MoveMask(Sse.CompareEqual(Sse.LoadVector128(&value1.M21), Sse.LoadVector128(&value2.M21))) == 0xF &&
2285-
Sse.MoveMask(Sse.CompareEqual(Sse.LoadVector128(&value1.M31), Sse.LoadVector128(&value2.M31))) == 0xF &&
2286-
Sse.MoveMask(Sse.CompareEqual(Sse.LoadVector128(&value1.M41), Sse.LoadVector128(&value2.M41))) == 0xF;
2283+
Sse.MoveMask(Sse.CompareNotEqual(Sse.LoadVector128(&value1.M11), Sse.LoadVector128(&value2.M11))) != 0 &&
2284+
Sse.MoveMask(Sse.CompareNotEqual(Sse.LoadVector128(&value1.M21), Sse.LoadVector128(&value2.M21))) != 0 &&
2285+
Sse.MoveMask(Sse.CompareNotEqual(Sse.LoadVector128(&value1.M31), Sse.LoadVector128(&value2.M31))) != 0 &&
2286+
Sse.MoveMask(Sse.CompareNotEqual(Sse.LoadVector128(&value1.M41), Sse.LoadVector128(&value2.M41))) != 0;
22872287
}
22882288
else
22892289
{
@@ -2305,10 +2305,10 @@ public static unsafe Matrix4x4 Multiply(Matrix4x4 value1, float value2)
23052305
if (Sse.IsSupported)
23062306
{
23072307
return
2308-
Sse.MoveMask(Sse.CompareEqual(Sse.LoadVector128(&value1.M11), Sse.LoadVector128(&value2.M11))) != 0xF ||
2309-
Sse.MoveMask(Sse.CompareEqual(Sse.LoadVector128(&value1.M21), Sse.LoadVector128(&value2.M21))) != 0xF ||
2310-
Sse.MoveMask(Sse.CompareEqual(Sse.LoadVector128(&value1.M31), Sse.LoadVector128(&value2.M31))) != 0xF ||
2311-
Sse.MoveMask(Sse.CompareEqual(Sse.LoadVector128(&value1.M41), Sse.LoadVector128(&value2.M41))) != 0xF;
2308+
Sse.MoveMask(Sse.CompareNotEqual(Sse.LoadVector128(&value1.M11), Sse.LoadVector128(&value2.M11))) == 0 ||
2309+
Sse.MoveMask(Sse.CompareNotEqual(Sse.LoadVector128(&value1.M21), Sse.LoadVector128(&value2.M21))) == 0 ||
2310+
Sse.MoveMask(Sse.CompareNotEqual(Sse.LoadVector128(&value1.M31), Sse.LoadVector128(&value2.M31))) == 0 ||
2311+
Sse.MoveMask(Sse.CompareNotEqual(Sse.LoadVector128(&value1.M41), Sse.LoadVector128(&value2.M41))) == 0;
23122312
}
23132313
else
23142314
{
@@ -2333,10 +2333,9 @@ public bool Equals(Matrix4x4 other)
23332333
else
23342334
{
23352335
return (M11 == other.M11 && M22 == other.M22 && M33 == other.M33 && M44 == other.M44 && // Check diagonal element first for early out.
2336-
M12 == other.M12 && M13 == other.M13 && M14 == other.M14 &&
2337-
M21 == other.M21 && M23 == other.M23 && M24 == other.M24 &&
2338-
M31 == other.M31 && M32 == other.M32 && M34 == other.M34 &&
2339-
M41 == other.M41 && M42 == other.M42 && M43 == other.M43);
2336+
M12 == other.M12 && M13 == other.M13 && M14 == other.M14 && M21 == other.M21 &&
2337+
M23 == other.M23 && M24 == other.M24 && M31 == other.M31 && M32 == other.M32 &&
2338+
M34 == other.M34 && M41 == other.M41 && M42 == other.M42 && M43 == other.M43);
23402339
}
23412340
}
23422341

0 commit comments

Comments
 (0)