Skip to content

Commit f596eaf

Browse files
committed
Readd using to prevent build failure.
Add AdvSimd equivalent operation to TestZ.
1 parent 6e26a21 commit f596eaf

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/libraries/System.Private.CoreLib/src/System/Text/Unicode/Utf8Utility.Transcoding.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Buffers;
55
using System.Diagnostics;
66
using System.Numerics;
7+
using System.Runtime.CompilerServices;
78
using System.Runtime.Intrinsics;
89
using System.Runtime.Intrinsics.Arm;
910
using System.Runtime.Intrinsics.X86;
@@ -950,21 +951,26 @@ public static OperationStatus TranscodeToUtf8(char* pInputBuffer, int inputLengt
950951
for (i = 0; (uint)i < maxIters; i++)
951952
{
952953
utf16Data = Unsafe.ReadUnaligned<Vector128<short>>(pInputBuffer);
953-
if (!Sse41.TestZ(utf16Data, nonAsciiUtf16DataMask))
954-
{
955-
goto LoopTerminatedDueToNonAsciiDataInVectorLocal;
956-
}
957954

958955
if (AdvSimd.IsSupported)
959956
{
957+
if (AdvSimd.CompareTest(utf16Data, nonAsciiUtf16DataMask).ToScalar() == 0)
958+
{
959+
goto LoopTerminatedDueToNonAsciiDataInVectorLocal;
960+
}
961+
960962
Vector64<sbyte> lower = AdvSimd.ExtractNarrowingSaturateLower(utf16Data);
961963
Vector128<sbyte> source = AdvSimd.ExtractNarrowingSaturateUpper(lower, AdvSimd.LoadVector128((short*)pInputBuffer));
962964
AdvSimd.Store((ulong*)pOutputBuffer, source.AsUInt64());
963965
}
964966
else
965967
{
966-
// narrow and write
968+
if (!Sse41.TestZ(utf16Data, nonAsciiUtf16DataMask))
969+
{
970+
goto LoopTerminatedDueToNonAsciiDataInVectorLocal;
971+
}
967972

973+
// narrow and write
968974
Sse2.StoreScalar((ulong*)pOutputBuffer /* unaligned */, Sse2.PackUnsignedSaturate(utf16Data, utf16Data).AsUInt64());
969975
}
970976

0 commit comments

Comments
 (0)