3 ms·
> it appears musl does not use AVX instructions much if at all. Right, or at least, not explicitly (a sufficiently smart compiler might be able to auto-vectori
by loeg 3y ago
> it appears musl does not use AVX instructions much if at all.
Right, or at least, not explicitly (a sufficiently smart compiler might be able to auto-vectorize it). The author is (reasonably) suggesting that most Linux systems use glibc, rather than musl.
Here's musl:
strlen: https://git.musl-libc.org/cgit/musl/tree/src/string/strlen.c https://git.musl-libc.org/cgit/musl/tree/src/string/strlen.c (64-bit words at a time)
memcpy (generic): https://git.musl-libc.org/cgit/musl/tree/src/string/memcpy.c https://git.musl-libc.org/cgit/musl/tree/src/string/memcpy.c (32-bit copies, unrolled to 4 at a time for a suitably long copy)
(Throwing the generic memcpy into godbolt -O3 shows Clang does choose to implement this in part with XMM and YMM registers: https://godbolt.org/z/dh6hqG77j https://godbolt.org/z/dh6hqG77j as does GCC: https://godbolt.org/z/aKraqPaPs https://godbolt.org/z/aKraqPaPs )
memcpy (x86_64 asm): https://git.musl-libc.org/cgit/musl/tree/src/string/x86_64/memcpy.s https://git.musl-libc.org/cgit/musl/tree/src/string/x86_64/m... (rep movsq -- 64-bit words at a time, implemented by the CPU microcode)