public static int SIMDSum(this ReadOnlySpan <int> array) { int length = Vector <int> .Count * 32; int vectorizedLength = (array.Length / length) * length; Span <int> temp = stackalloc int[length]; int result = 0; for (int i = 0; i < vectorizedLength; i += length) { temp.AddAssign(array.Slice(i, length)); } for (int i = 0; i < length; i++) { result += temp[i]; } for (int i = vectorizedLength; i < array.Length; i++) { result += array[i]; } return(result); }