Skip to content

Commit f56f612

Browse files
committed
Updating Load512 for WideningLoader for performance increase
1 parent 6e01940 commit f56f612

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/libraries/System.Private.CoreLib/src/System/Text/Ascii.Equality.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,8 +536,19 @@ public static Vector256<ushort> Load256(ref byte ptr)
536536
[MethodImpl(MethodImplOptions.AggressiveInlining)]
537537
public static Vector512<ushort> Load512(ref byte ptr)
538538
{
539-
(Vector256<ushort> lower, Vector256<ushort> upper) = Vector256.Widen(Vector256.LoadUnsafe(ref ptr));
540-
return Vector512.Create(lower, upper);
539+
// This is done here for performance gain.
540+
// A similar implementation would be as below:
541+
//
542+
// (Vector256<ushort> lower, Vector256<ushort> upper) = Vector256.Widen(Vector256.LoadUnsafe(ref ptr));
543+
// return Vector512.Create(lower, upper);
544+
//
545+
// This is similar to what is done for Load256 here. But
546+
// for Vector512, this implementation is low performance
547+
// since a load and widen on Vector256 followed by a
548+
// create on Vector512 is leading to a performance lower
549+
// than that of similar implementationfor Vector256.
550+
(Vector512<ushort> lower, Vector512<ushort> _) = Vector512.Widen(Vector256.LoadUnsafe(ref ptr).ToVector512());
551+
return lower;
541552
}
542553

543554
[MethodImpl(MethodImplOptions.AggressiveInlining)]

0 commit comments

Comments
 (0)