Skip to content

Commit 6df54d4

Browse files
committed
increased the vectorization threshold
1 parent aa7d825 commit 6df54d4

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/Extensions/ReadOnlySpan/Linq/Max.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public static T Max<T>(this ReadOnlySpan<T> source) where T : IComparable<T>
8686
return result;
8787
}
8888

89-
if(Vector128.IsHardwareAccelerated && Vector128<T>.IsSupported && source.Length > Vector128<T>.Count)
89+
if(Vector128.IsHardwareAccelerated && Vector128<T>.IsSupported && source.Length > Vector128<T>.Count * 2)
9090
{
9191
ref T current = ref MemoryMarshal.GetReference(source);
9292
ref T secondToLast = ref Unsafe.Add(ref current, source.Length - Vector128<T>.Count);
@@ -117,7 +117,7 @@ public static T Max<T>(this ReadOnlySpan<T> source) where T : IComparable<T>
117117
return result;
118118
}
119119

120-
if(Vector64.IsHardwareAccelerated && Vector64<T>.IsSupported && source.Length > Vector64<T>.Count)
120+
if(Vector64.IsHardwareAccelerated && Vector64<T>.IsSupported && source.Length > Vector64<T>.Count * 4)
121121
{
122122
ref T current = ref MemoryMarshal.GetReference(source);
123123
ref T secondToLast = ref Unsafe.Add(ref current, source.Length - Vector64<T>.Count);

src/Extensions/ReadOnlySpan/Linq/Min.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public static T Min<T>(this ReadOnlySpan<T> source) where T : IComparable<T>
8585
return result;
8686
}
8787

88-
if(Vector128.IsHardwareAccelerated && Vector128<T>.IsSupported && source.Length > Vector128<T>.Count)
88+
if(Vector128.IsHardwareAccelerated && Vector128<T>.IsSupported && source.Length > Vector128<T>.Count * 2)
8989
{
9090
ref T current = ref MemoryMarshal.GetReference(source);
9191
ref T secondToLast = ref Unsafe.Add(ref current, source.Length - Vector128<T>.Count);
@@ -115,8 +115,8 @@ public static T Min<T>(this ReadOnlySpan<T> source) where T : IComparable<T>
115115

116116
return result;
117117
}
118-
119-
if(Vector64.IsHardwareAccelerated && Vector64<T>.IsSupported && source.Length > Vector64<T>.Count)
118+
119+
if(Vector64.IsHardwareAccelerated && Vector64<T>.IsSupported && source.Length > Vector64<T>.Count * 4)
120120
{
121121
ref T current = ref MemoryMarshal.GetReference(source);
122122
ref T secondToLast = ref Unsafe.Add(ref current, source.Length - Vector64<T>.Count);

0 commit comments

Comments
 (0)