Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Ramstack.Globbing.Tests/Ramstack.Globbing.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>preview</LangVersion>
Expand Down
1 change: 1 addition & 0 deletions Ramstack.Globbing.Tests/SimdConfigurationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public void VerifySimdConfiguration()
Assert.That(Sse2.IsSupported, Is.False);
Assert.That(Sse41.IsSupported, Is.False);
Assert.That(Avx2.IsSupported, Is.False);
Assert.That(AdvSimd.Arm64.IsSupported, Is.False);
Assert.That(AdvSimd.IsSupported, Is.False);
}

Expand Down
18 changes: 13 additions & 5 deletions Ramstack.Globbing/Internal/PathHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ public PathSegmentIterator() =>

while ((int)_position < length)
{
if ((Avx2.IsSupported || Sse2.IsSupported || AdvSimd.IsSupported) && _mask != 0)
if ((Avx2.IsSupported || Sse2.IsSupported || AdvSimd.Arm64.IsSupported) && _mask != 0)
{
var offset = BitOperations.TrailingZeroCount(_mask);
if (AdvSimd.IsSupported)
Expand Down Expand Up @@ -446,8 +446,7 @@ public PathSegmentIterator() =>
if (_mask == 0)
_position += Vector128<ushort>.Count;
}
#if NET7_0_OR_GREATER
else if (AdvSimd.IsSupported && (int)_position + Vector128<ushort>.Count <= length)
else if (AdvSimd.Arm64.IsSupported && (int)_position + Vector128<ushort>.Count <= length)
{
var chunk = LoadVector128(ref source, _position);
var backslashMask = CreateBackslash128Bitmask(flags);
Expand All @@ -466,15 +465,24 @@ public PathSegmentIterator() =>
// This avoids reloading SIMD registers and repeating comparisons
// on the same chunk of data.
//
_mask = comparison.ExtractMostSignificantBits();
_mask = ExtractMostSignificantBits(comparison);

//
// Advance position to the next chunk when no separators found
//
if (_mask == 0)
_position += Vector128<ushort>.Count;

[MethodImpl(MethodImplOptions.AggressiveInlining)]
static uint ExtractMostSignificantBits(Vector128<ushort> v)
{
var sum = AdvSimd.Arm64.AddAcross(
AdvSimd.ShiftLogical(
AdvSimd.And(v, Vector128.Create((ushort)0x8000)),
Vector128.Create((short)-15, -14, -13, -12, -11, -10, -9, -8)));
return sum.ToScalar();
}
}
#endif
else
{
for (; (int)_position < length; _position++)
Expand Down
2 changes: 1 addition & 1 deletion Ramstack.Globbing/Ramstack.Globbing.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFramework>net6.0</TargetFramework>
<Description>Fast and zero-allocation .NET globbing library for matching file paths using glob patterns.</Description>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down