|
5 | 5 | using System.Runtime.CompilerServices;
|
6 | 6 | using System.Runtime.InteropServices;
|
7 | 7 | using System.Runtime.Intrinsics;
|
| 8 | +using System.Runtime.Intrinsics.Arm; |
8 | 9 | using System.Runtime.Intrinsics.X86;
|
9 | 10 | using SixLabors.ImageSharp.Memory;
|
10 | 11 |
|
@@ -201,12 +202,24 @@ static void MultiplyToAverage(Span<float> target, float multiplier)
|
201 | 202 |
|
202 | 203 | // Spans are guaranteed to be multiple of 8 so no extra 'remainder' steps are needed
|
203 | 204 | nuint count = target.Vector256Count<float>();
|
204 |
| - var multiplierVector = Vector256.Create(multiplier); |
| 205 | + Vector256<float> multiplierVector = Vector256.Create(multiplier); |
205 | 206 | for (nuint i = 0; i < count; i++)
|
206 | 207 | {
|
207 | 208 | Unsafe.Add(ref targetVectorRef, i) = Avx.Multiply(Unsafe.Add(ref targetVectorRef, i), multiplierVector);
|
208 | 209 | }
|
209 | 210 | }
|
| 211 | + else if (AdvSimd.IsSupported) |
| 212 | + { |
| 213 | + ref Vector128<float> targetVectorRef = ref Unsafe.As<float, Vector128<float>>(ref MemoryMarshal.GetReference(target)); |
| 214 | + |
| 215 | + // Spans are guaranteed to be multiple of 8 so no extra 'remainder' steps are needed |
| 216 | + nuint count = target.Vector128Count<float>(); |
| 217 | + Vector128<float> multiplierVector = Vector128.Create(multiplier); |
| 218 | + for (nuint i = 0; i < count; i++) |
| 219 | + { |
| 220 | + Unsafe.Add(ref targetVectorRef, i) = AdvSimd.Multiply(Unsafe.Add(ref targetVectorRef, i), multiplierVector); |
| 221 | + } |
| 222 | + } |
210 | 223 | else
|
211 | 224 | {
|
212 | 225 | ref Vector<float> targetVectorRef = ref Unsafe.As<float, Vector<float>>(ref MemoryMarshal.GetReference(target));
|
|
0 commit comments