Skip to content

Commit 46ccf79

Browse files
authored
Merge pull request #24 from simdutf/minor_optimization
fix: optimize NEON kernel by replacing MaxAcross over bytes with MaxAcross over words
2 parents 754e529 + dd89b98 commit 46ccf79

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ We recommend you install .NET 8: https://dotnet.microsoft.com/en-us/download/dot
2323
## Running tests
2424

2525
```
26-
cd test
2726
dotnet test
2827
```
2928

src/UTF8.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,10 @@ public static class UTF8
566566
Vector128<byte> must23 = AdvSimd.Or(isThirdByte, isFourthByte);
567567
Vector128<byte> must23As80 = AdvSimd.And(must23, v80);
568568
Vector128<byte> error = AdvSimd.Xor(must23As80, sc);
569-
if (AdvSimd.Arm64.MaxAcross(error).ToScalar() != 0)
569+
// AdvSimd.Arm64.MaxAcross(error) works, but it might be slower
570+
// than AdvSimd.Arm64.MaxAcross(Vector128.AsUInt32(error)) on some
571+
// hardware:
572+
if (AdvSimd.Arm64.MaxAcross(Vector128.AsUInt32(error)).ToScalar() != 0)
570573
{
571574
return SimdUnicode.UTF8.RewindAndValidateWithErrors(processedLength, pInputBuffer + processedLength, inputLength - processedLength);
572575
}

0 commit comments

Comments
 (0)