acompiled

The catalog contains seeded project examples. Your workspace stores your own projects and conversations.

yuki-ito/neon-mem

Public
Star6

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.

Code
Blame·2 commits across 27 linesoldernewer
2
README: every size class, and the test that found the memset overrunSep 24 3`memcpy` and `memset` for AArch64, written around one idea: never loop over a byte count you can cover with a few overlapping loads and stores.
6|---|---|---|
7| 0–3 | first, middle and last byte | first byte, then a halfword from the end |
8| 4–7 | two overlapping W moves | two overlapping W stores |
9| 8–15 | two overlapping X moves | two overlapping X stores |
10| 16 | two X moves | two Q stores to the same 16 bytes |
11| 17–32 | two overlapping Q moves | two overlapping Q stores |
12| 33–64 | two Q pairs, one from each end | four overlapping Q stores |
13| 65–128 | four Q pairs, two from each end | four Q pairs, two from each end |
14| 129+ | first 16 bytes, a 64-byte LDP/STP loop on the aligned part of dst, then the last 64 from the end | the same, with STP only |
README: every size class, and the test that found the memset overrunSep 24 16Both follow AAPCS64 and touch only registers the caller does not expect to keep, so neither saves anything.
17
18## Test
19
20Every build runs `test/sizes.c` on Linux: both routines, every size from 0 to 1,024 at all 64 destination alignments, with guard bytes on both sides of the buffer. It is freestanding, with no libc for the target, and talks to Linux through `svc`. On a builder that is not an Arm machine it runs under qemu-aarch64.
21
22It is the test that found the 65–79 byte overrun in the first `memset` loop.
23
24## Not yet
25
26- A `DC ZVA` path for large zero fills. It needs a `DCZID_EL0` read to learn the block size.
27- SVE versions. The size classes should carry over, with `whilelo` replacing the overlapping tails.