Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ GetIndexOfFirstCharToEncodeSsse3()

unsafe nuint System.Text.Encodings.Web.OptimizedInboxTextEncoder.GetIndexOfFirstCharToEncodeSsse3 ( char * pData,
nuint lengthInChars )
inlineprivate

Definition at line 498 of file OptimizedInboxTextEncoder.cs.

499 {
501 Vector128<byte> right = Vector128.Create((byte)7);
502 Vector128<byte> value = Vector128.Create(1, 2, 4, 8, 16, 32, 64, 128, 0, 0, 0, 0, 0, 0, 0, 0);
504 nuint num = 0u;
505 if (lengthInChars < 16)
506 {
507 goto IL_00d4;
508 }
509 nuint num2 = lengthInChars & unchecked((nuint)(-16));
510 int num3;
511 while (true)
512 {
513 Vector128<byte> vector = Sse2.PackUnsignedSaturate(Sse2.LoadVector128((short*)(pData + num)), Sse2.LoadVector128((short*)(pData + 8 + num)));
514 Vector128<byte> left = Ssse3.Shuffle(asVector, vector);
515 Vector128<byte> right2 = Ssse3.Shuffle(value, Sse2.And(Sse2.ShiftRightLogical(vector.AsUInt32(), 4).AsByte(), right));
516 Vector128<byte> left2 = Sse2.And(left, right2);
517 num3 = Sse2.MoveMask(Sse2.CompareEqual(left2, zero));
518 if (((uint)num3 & 0xFFFFu) != 0)
519 {
520 break;
521 }
522 if ((num += 16) < num2)
523 {
524 continue;
525 }
526 goto IL_00d4;
527 }
528 goto IL_01ea;
529 IL_00d4:
530 if ((lengthInChars & 8) != 0)
531 {
532 Vector128<byte> vector2 = Sse2.PackUnsignedSaturate(Sse2.LoadVector128((short*)(pData + num)), zero.AsInt16());
533 Vector128<byte> left3 = Ssse3.Shuffle(asVector, vector2);
534 Vector128<byte> right3 = Ssse3.Shuffle(value, Sse2.And(Sse2.ShiftRightLogical(vector2.AsUInt32(), 4).AsByte(), right));
535 Vector128<byte> left4 = Sse2.And(left3, right3);
536 num3 = Sse2.MoveMask(Sse2.CompareEqual(left4, zero));
537 if ((byte)num3 != 0)
538 {
539 goto IL_01ea;
540 }
541 num += 8;
542 }
543 if ((lengthInChars & 4) != 0)
544 {
545 Vector128<byte> vector3 = Sse2.PackUnsignedSaturate(Sse2.LoadScalarVector128((ulong*)(pData + num)).AsInt16(), zero.AsInt16());
546 Vector128<byte> left5 = Ssse3.Shuffle(asVector, vector3);
547 Vector128<byte> right4 = Ssse3.Shuffle(value, Sse2.And(Sse2.ShiftRightLogical(vector3.AsUInt32(), 4).AsByte(), right));
548 Vector128<byte> left6 = Sse2.And(left5, right4);
549 num3 = Sse2.MoveMask(Sse2.CompareEqual(left6, zero));
550 if (((uint)num3 & 0xFu) != 0)
551 {
552 goto IL_01ea;
553 }
554 num += 4;
555 }
556 if ((lengthInChars & 3) != 0)
557 {
558 while (_allowedAsciiCodePoints.IsAllowedAsciiCodePoint(pData[num]) && ++num != lengthInChars)
559 {
560 }
561 }
562 goto IL_01e7;
563 IL_01ea:
564 num += (uint)BitOperations.TrailingZeroCount(num3);
565 goto IL_01e7;
566 IL_01e7:
567 return num;
568 }
static int TrailingZeroCount(int value)
static Vector128< byte > Create(byte value)
Definition Vector128.cs:138
static unsafe Vector128< sbyte > LoadVector128(sbyte *address)
Definition Sse2.cs:582
static unsafe Vector128< double > LoadScalarVector128(double *address)
Definition Sse2.cs:627
static int MoveMask(Vector128< sbyte > value)
Definition Sse2.cs:772
static Vector128< sbyte > CompareEqual(Vector128< sbyte > left, Vector128< sbyte > right)
Definition Sse2.cs:232
static Vector128< byte > PackUnsignedSaturate(Vector128< short > left, Vector128< short > right)
Definition Sse2.cs:892
static Vector128< byte > And(Vector128< byte > left, Vector128< byte > right)
Definition Sse2.cs:132
static Vector128< short > ShiftRightLogical(Vector128< short > value, Vector128< short > count)
Definition Sse2.cs:1057
static Vector128< sbyte > Shuffle(Vector128< sbyte > value, Vector128< sbyte > mask)
Definition Ssse3.cs:112

References System.Text.Encodings.Web.OptimizedInboxTextEncoder._allowedAsciiCodePoints, System.Runtime.Intrinsics.X86.Sse2.And(), System.Text.Encodings.Web.OptimizedInboxTextEncoder.AllowedAsciiCodePoints.AsVector, System.Runtime.Intrinsics.X86.Sse2.CompareEqual(), System.Runtime.Intrinsics.Vector128< T >.Create(), System.Text.Encodings.Web.OptimizedInboxTextEncoder.AllowedAsciiCodePoints.IsAllowedAsciiCodePoint(), System.Runtime.Intrinsics.X86.Sse2.LoadScalarVector128(), System.Runtime.Intrinsics.X86.Sse2.LoadVector128(), System.Runtime.Intrinsics.X86.Sse2.MoveMask(), System.Runtime.Intrinsics.X86.Sse2.PackUnsignedSaturate(), System.Runtime.Intrinsics.X86.Sse2.ShiftRightLogical(), System.Runtime.Intrinsics.X86.Ssse3.Shuffle(), System.Numerics.BitOperations.TrailingZeroCount(), System.Text.Encodings.Web.value, and System.Runtime.Intrinsics.Vector128< T >.Zero.

Referenced by System.Text.Encodings.Web.OptimizedInboxTextEncoder.GetIndexOfFirstCharToEncode().