memcpy and memset for AArch64, from overlapping loads and LDP/STP Q pairs. Every build checks every size up to 1,024 bytes at all 64 alignments.
memset: a 65..128 class, like memcpy's
Browse filesThe loop starts at the first 16-byte boundary past dst, up to 16 bytes in, so its first 64 bytes can end 80 bytes in. With dst on a 16-byte boundary, every size from 65 to 79 wrote past the end, and each byte of misalignment takes one size off that range: 480 calls in latch's test. memcpy_neon has had this class since it started aligning its loop, for the same reason.
failing
4 steps in 2 ms
1 file changed
+15−2
@@ -4,7 +4,11 @@
44 //
55 // 0..15 scalar stores of the byte replicated across x6
66 // 16..64 two to four overlapping Q stores
7−// 65+ align to 16, 64 bytes per iteration, last 64 from the end
7+// 65..128 four Q-register pairs, two from each end
8+// 129+ align to 16, 64 bytes per iteration, last 64 from the end
9+//
10+// The 65..128 class exists because a 64-byte loop starting at the first
11+// aligned address can run past the end of a buffer shorter than 80 bytes.
812
913 .text
1014 .p2align 6
@@ -16,7 +20,7 @@ memset_neon:
1620 cmp x2, #16
1721 b.lo .Lset0_15
1822 cmp x2, #64
19− b.hi .Lset_long
23+ b.hi .Lset65
2024 str q0, [x0] // 16..64
2125 str q0, [x5, #-16]
2226 cmp x2, #32
@@ -44,6 +48,15 @@ memset_neon:
4448 strh w6, [x5, #-2]
4549 ret
4650
51+.Lset65:
52+ cmp x2, #128
53+ b.hi .Lset_long
54+ stp q0, q0, [x0] // 65..128
55+ stp q0, q0, [x0, #32]
56+ stp q0, q0, [x5, #-64]
57+ stp q0, q0, [x5, #-32]
58+ ret
59+
4760 .Lset_long:
4861 str q0, [x0] // unaligned head
4962 bic x6, x0, #15