Skip to content

Commit

Permalink
Avoid ExtractMostSignificantBits in AVX512 path
Browse files Browse the repository at this point in the history
  • Loading branch information
xtqqczze committed Oct 14, 2024
1 parent 6221ddb commit 8302532
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,7 @@ private static unsafe void Avx512Decode<TBase64Decoder, T>(TBase64Decoder decode
// The JIT won't hoist these "constants", so help it
Vector512<sbyte> vbmiLookup0 = Vector512.Create(decoder.VbmiLookup0).AsSByte();
Vector512<sbyte> vbmiLookup1 = Vector512.Create(decoder.VbmiLookup1).AsSByte();
Vector512<sbyte> errorMask = Vector512.Create(sbyte.MinValue);
Vector512<byte> vbmiPackedLanesControl = Vector512.Create(
0x06000102, 0x090a0405, 0x0c0d0e08, 0x16101112,
0x191a1415, 0x1c1d1e18, 0x26202122, 0x292a2425,
Expand All @@ -687,7 +688,7 @@ private static unsafe void Avx512Decode<TBase64Decoder, T>(TBase64Decoder decode
// origIndex = [...|00dddddd|00cccccc|00bbbbbb|00aaaaaa]
Vector512<sbyte> origIndex = Avx512Vbmi.PermuteVar64x8x2(vbmiLookup0, str, vbmiLookup1);
Vector512<sbyte> errorVec = (origIndex.AsInt32() | str.AsInt32()).AsSByte();
if (errorVec.ExtractMostSignificantBits() != 0)
if ((errorVec & errorMask) != Vector512<sbyte>.Zero)
{
break;
}
Expand Down

1 comment on commit 8302532

@xtqqczze
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.