Skip to content

1

Choose a tag to compare

@pg83 pg83 released this 10 Nov 14:48

First numbered release. String and memory functions for x86-64 under the MIT license: memcpy, memmove, memset, memcmp, memchr, strlen, strcpy, strcat, strcmp, strspn and strcspn, as the entry points str_memcpy and so on (a libc build renames them with -Dstr_memcpy=memcpy and the like). One cpuid at startup picks the configuration of the whole table of primitives: sse2, sse42, avx2, evex (256-bit AVX-512 first blocks over the AVX2 kernels, Skylake-SP), evex512 (the 512-bit ones, Zen 4) or evex512r (evex512 with rep stosb for memset where a short rep stosb starts fast, Zen 5). The functions are written in a small C dialect with builtin SIMD operations and compiled by the project's own optimizer in Python (dev/opt: from the AST through SSA passes, instruction selection, register allocation and layout to the ELF object), so ./build -j8 libstr needs Python alone.

The linked machine code is proved: each configuration's copy of every function and of the kernels behind it, against the function's spec, by symbolic execution with SMT solvers (dev/proof). Proved are the result, every store inside the destination with the byte due there, and every load within the pages of its object, for every length (the loops by induction), every position of the pointers in a page and, for strspn and strcspn, every set. ./build proof is 128 proofs, all proved on this commit.

Validation: CI green (style, the C test at every level its runner has, the decoder round-trip); ./build proof on the lab hosts, 128 of 128 proved; on the lab stand's workload (dev/lab) the mixed trace takes 0.48 of glibc's time on Skylake-SP and 0.90 on Broadwell-EP, at parity with the previous compiler's code (clang and a post pass) measured in the same binary.