Skip to content

Commit

Permalink
Use AdvSimd.Arm64.LoadPairVector128 in OptimizedInboxTextEncoder.AdvS…
Browse files Browse the repository at this point in the history
…imd64.cs
  • Loading branch information
echesakov committed Jun 25, 2021
1 parent 0d45572 commit fab6ef3
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,10 @@ private unsafe nuint GetIndexOfFirstCharToEncodeAdvSimd64(char* pData, nuint len
// Read 16 chars at a time into 2x 128-bit vectors, then pack into a single 128-bit vector.
// We turn 16 chars (256 bits) into 16 nibbles (64 bits) during this process.

(Vector128<short> lowerVector, Vector128<short> upperVector) = AdvSimd.Arm64.LoadPairVector128((/* unaligned */ short*)(pData + i));
Vector128<byte> packed = AdvSimd.ExtractNarrowingSaturateUnsignedUpper(
AdvSimd.ExtractNarrowingSaturateUnsignedLower(AdvSimd.LoadVector128((/* unaligned */ short*)(pData + i))),
AdvSimd.LoadVector128((/* unaligned */ short*)(pData + 8 + i)));
AdvSimd.ExtractNarrowingSaturateUnsignedLower(lowerVector),
upperVector);
var allowedCodePointsShuffled = AdvSimd.Arm64.VectorTableLookup(allowedCodePoints, AdvSimd.And(packed, vec0xF));
var vecPowersOfTwoShuffled = AdvSimd.Arm64.VectorTableLookup(vecPowersOfTwo, AdvSimd.ShiftRightArithmetic(packed.AsSByte(), 4).AsByte());
var result = AdvSimd.CompareTest(allowedCodePointsShuffled, vecPowersOfTwoShuffled);
Expand Down

0 comments on commit fab6ef3

Please sign in to comment.