Skip to content

Commit

Permalink
Inlining + Fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
rgesteve committed Mar 20, 2024
1 parent 1ea798e commit 76ecff2
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2228,6 +2228,7 @@ internal static unsafe nuint WidenAsciiToUtf16(byte* pAsciiBuffer, char* pUtf16B
goto Finish;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static unsafe void WidenAsciiToUtf1_Vector<TVectorByte, TVectorUShort>(byte* pAsciiBuffer, char* pUtf16Buffer, ref nuint currentOffset, nuint elementCount)
where TVectorByte : unmanaged, ISimdVector<TVectorByte, byte>
where TVectorUShort : unmanaged, ISimdVector<TVectorUShort, ushort>
Expand All @@ -2238,7 +2239,7 @@ private static unsafe void WidenAsciiToUtf1_Vector<TVectorByte, TVectorUShort>(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<TVectorByte>(asciiVector))
if (!HasMatch<TVectorByte>(asciiVector))
{
(TVectorUShort utf16LowVector, TVectorUShort utf16HighVector) = Widen<TVectorByte, TVectorUShort>(asciiVector);
utf16LowVector.Store(pCurrentWriteAddress);
Expand All @@ -2261,7 +2262,7 @@ private static unsafe void WidenAsciiToUtf1_Vector<TVectorByte, TVectorUShort>(b
while (currentOffset <= finalOffsetWhereCanRunLoop)
{
asciiVector = TVectorByte.Load(pAsciiBuffer + currentOffset);
if (HasNoMatch<TVectorByte>(asciiVector))
if (HasMatch<TVectorByte>(asciiVector))
{
break;
}
Expand All @@ -2278,14 +2279,14 @@ private static unsafe void WidenAsciiToUtf1_Vector<TVectorByte, TVectorUShort>(b
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static unsafe bool HasNoMatch<TVectorByte>(TVectorByte vector)
private static unsafe bool HasMatch<TVectorByte>(TVectorByte vector)
where TVectorByte : unmanaged, ISimdVector<TVectorByte, byte>
{
if (AdvSimd.IsSupported && typeof(TVectorByte) == typeof(Vector128<byte>))
{
return !VectorContainsNonAsciiChar((Vector128<byte>)(object)vector);
return VectorContainsNonAsciiChar((Vector128<byte>)(object)vector);
}
return !TVectorByte.AnyMatches(vector);
return TVectorByte.AnyMatches(vector);
}


Expand Down

0 comments on commit 76ecff2

Please sign in to comment.