Skip to content

Commit 4109697

Browse files
committed
Enable usage of Vector<T>.Sum on .NET 6
See dotnet/runtime#35626
1 parent 6d7bf0d commit 4109697

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

CommunityToolkit.HighPerformance/Helpers/Internals/SpanHelper.Count.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,11 @@ private static nint CountSimd<T>(ref T r0, nint length, T value)
240240
offset += Vector<T>.Count;
241241
}
242242

243+
#if NET6_0_OR_GREATER
244+
result += CastToNativeInt(Vector.Sum(partials));
245+
#else
243246
result += CastToNativeInt(Vector.Dot(partials, Vector<T>.One));
247+
#endif
244248
length -= offset - initialOffset;
245249
}
246250
while (length >= Vector<T>.Count);

0 commit comments

Comments
 (0)