Skip to content

Commit 03a988b

Browse files
committed
Add Arm for SumVertical
1 parent c190951 commit 03a988b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/ImageSharp/Formats/Jpeg/Components/Encoder/ComponentProcessor.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,18 @@ static void SumVertical(Span<float> target, Span<float> source)
129129
Unsafe.Add(ref targetVectorRef, i) = Avx.Add(Unsafe.Add(ref targetVectorRef, i), Unsafe.Add(ref sourceVectorRef, i));
130130
}
131131
}
132+
else if (AdvSimd.IsSupported)
133+
{
134+
ref Vector128<float> targetVectorRef = ref Unsafe.As<float, Vector128<float>>(ref MemoryMarshal.GetReference(target));
135+
ref Vector128<float> sourceVectorRef = ref Unsafe.As<float, Vector128<float>>(ref MemoryMarshal.GetReference(source));
136+
137+
// Spans are guaranteed to be multiple of 8 so no extra 'remainder' steps are needed
138+
nuint count = source.Vector128Count<float>();
139+
for (nuint i = 0; i < count; i++)
140+
{
141+
Unsafe.Add(ref targetVectorRef, i) = AdvSimd.Add(Unsafe.Add(ref targetVectorRef, i), Unsafe.Add(ref sourceVectorRef, i));
142+
}
143+
}
132144
else
133145
{
134146
ref Vector<float> targetVectorRef = ref Unsafe.As<float, Vector<float>>(ref MemoryMarshal.GetReference(target));

0 commit comments

Comments
 (0)