LLVM’s libc Gets Much Faster memcpy For RISC-V


Being merged into LLVM’s libc library recently are an optimized memory copy function “memcpy” implementation for the RISC-V architecture.

Optimized memcpy for RISC-V was merged that better handles where unaligned memory accesses are either illegal or extremely slow. ARM32 could benefit as well but for now it’s enabled for RISC-V 32-bit and 64-bit software.

Benchmarks of this new implementation by Guillaume Chatelet of Google show some tests dropping from 474 ns to 126 ns while in extreme cases going from 6033 ns down to just 981 ns.

RISC-V libc memcpy performance

Even with these big memcpy speed-ups for RISC-V, GNU’s Glibc is still showing much faster RISC-V memcpy results. In some cases the Glibc memcpy performance on RISC-V is still twice as fast as the new optimized implementation with LLVM libc. Details for those interested via this change that is now in living in LLVM 17 Git.