Skip to content

Commit 62b68c8

Browse files
committed
Use Vector API
1 parent 1b746dd commit 62b68c8

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

1brc/Utf8Span.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,8 @@ internal nuint IndexOfSemicolon()
219219
var sepVec = Vector256.Create((byte)';');
220220

221221
var matches = Vector256.Equals(Unsafe.ReadUnaligned<Vector256<byte>>(Pointer), sepVec);
222-
var mask = (uint)Avx2.MoveMask(matches);
223-
var tzc = (uint)BitOperations.TrailingZeroCount(mask);
222+
var mask = Vector256.ExtractMostSignificantBits(matches);
223+
nuint tzc = (uint)BitOperations.TrailingZeroCount(mask);
224224

225225
if (mask == 0) // For non-taken branches prefer placing them in a "leaf" instead of mask != 0, somewhere on GH they explain why, it would be nice to find.
226226
return IndexOfSemicolonCont(this);
@@ -236,21 +236,21 @@ static nuint IndexOfSemicolonCont(Utf8Span span)
236236

237237
var sepVec = Vector256.Create((byte)';');
238238
var matches = Vector256.Equals(Unsafe.ReadUnaligned<Vector256<byte>>(span.Pointer + vectorSize), sepVec);
239-
var mask = (uint)Avx2.MoveMask(matches);
239+
var mask = Vector256.ExtractMostSignificantBits(matches);
240240
var tzc = (uint)BitOperations.TrailingZeroCount(mask);
241241
if (mask != 0)
242242
return vectorSize + tzc;
243243

244244
const nuint vectorSize2 = 2 * vectorSize;
245245
matches = Vector256.Equals(Unsafe.ReadUnaligned<Vector256<byte>>(span.Pointer + vectorSize2), sepVec);
246-
mask = (uint)Avx2.MoveMask(matches);
246+
mask = Vector256.ExtractMostSignificantBits(matches);
247247
tzc = (uint)BitOperations.TrailingZeroCount(mask);
248248
if (mask != 0)
249249
return vectorSize2 + tzc;
250250

251251
const nuint vectorSize3 = 3 * vectorSize;
252252
matches = Vector256.Equals(Unsafe.ReadUnaligned<Vector256<byte>>(span.Pointer + vectorSize3), sepVec);
253-
mask = (uint)Avx2.MoveMask(matches);
253+
mask = Vector256.ExtractMostSignificantBits(matches);
254254
tzc = (uint)BitOperations.TrailingZeroCount(mask);
255255
return vectorSize3 + tzc;
256256
}

0 commit comments

Comments
 (0)