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 44031cc49d5874..3cfcfef7271cbf 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 @@ -2228,6 +2228,7 @@ internal static unsafe nuint WidenAsciiToUtf16(byte* pAsciiBuffer, char* pUtf16B goto Finish; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] private static unsafe void WidenAsciiToUtf1_Vector(byte* pAsciiBuffer, char* pUtf16Buffer, ref nuint currentOffset, nuint elementCount) where TVectorByte : unmanaged, ISimdVector where TVectorUShort : unmanaged, ISimdVector @@ -2238,7 +2239,7 @@ private static unsafe void WidenAsciiToUtf1_Vector(b // write instructions. See: https://github.com/dotnet/runtime/issues/33002 nuint finalOffsetWhereCanRunLoop = elementCount - (nuint)TVectorByte.Count; TVectorByte asciiVector = TVectorByte.Load(pAsciiBuffer + currentOffset); - if (HasNoMatch(asciiVector)) + if (!HasMatch(asciiVector)) { (TVectorUShort utf16LowVector, TVectorUShort utf16HighVector) = Widen(asciiVector); utf16LowVector.Store(pCurrentWriteAddress); @@ -2261,7 +2262,7 @@ private static unsafe void WidenAsciiToUtf1_Vector(b while (currentOffset <= finalOffsetWhereCanRunLoop) { asciiVector = TVectorByte.Load(pAsciiBuffer + currentOffset); - if (HasNoMatch(asciiVector)) + if (HasMatch(asciiVector)) { break; } @@ -2278,14 +2279,14 @@ private static unsafe void WidenAsciiToUtf1_Vector(b } [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static unsafe bool HasNoMatch(TVectorByte vector) + private static unsafe bool HasMatch(TVectorByte vector) where TVectorByte : unmanaged, ISimdVector { if (AdvSimd.IsSupported && typeof(TVectorByte) == typeof(Vector128)) { - return !VectorContainsNonAsciiChar((Vector128)(object)vector); + return VectorContainsNonAsciiChar((Vector128)(object)vector); } - return !TVectorByte.AnyMatches(vector); + return TVectorByte.AnyMatches(vector); }