From 39cb56a392161b489ef61e0db76e72da85332f36 Mon Sep 17 00:00:00 2001 From: Deepak Rajendrakumaran Date: Tue, 26 Mar 2024 10:13:57 -0700 Subject: [PATCH] Fixing perf --- .../src/System/Text/Ascii.Utility.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/Ascii.Utility.cs b/src/libraries/System.Private.CoreLib/src/System/Text/Ascii.Utility.cs index 824c51e9a028be..90147e8b3ec69d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Text/Ascii.Utility.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Text/Ascii.Utility.cs @@ -2200,11 +2200,21 @@ private static unsafe void WidenAsciiToUtf1_Vector(b private static unsafe bool HasMatch(TVectorByte vector) where TVectorByte : unmanaged, ISimdVector { + if (typeof(TVectorByte) == typeof(Vector256)) + { + return (((Vector256)(object)vector).ExtractMostSignificantBits() != 0); + } + else if (typeof(TVectorByte) == typeof(Vector512)) + { + return (((Vector512)(object)vector).ExtractMostSignificantBits() != 0); + } + if (AdvSimd.IsSupported && typeof(TVectorByte) == typeof(Vector128)) { return VectorContainsNonAsciiChar((Vector128)(object)vector); } - return ((vector & TVectorByte.Create((byte)0b1000_0000)) != TVectorByte.Zero); + + return (((Vector128)(object)vector).ExtractMostSignificantBits() != 0); }