riscv-newlib
riscv-newlib copied to clipboard
improve memcpy performance
improve speed (memcpy32_speed.c and memcpy64_speed.c) and code size (memcpy_size.c)
- Coding style: Could you using GNU coding style? 2 space instead of tab to indent, and using tab to replace 8 space, you could reference other files in
<src>/newlib
, or find clang-format file in<gcc-src>/contrib/clang-format
. - PREFER_SIZE_OVER_SPEED use byte-wise copy is fine, but I think
__OPTIMIZE_SIZE__
use the original implementation would be better. - Could you try to merge memcpy32_speed.c and memcpy64_speed.c? It seems using same algorithm to speed up.
- Perhaps you could use unsigned long instead of magic number or uint32_t/uint64_t, e.g.
sizeof (unsigned long) - 1
instead of 3 or 7.
- Perhaps you could use unsigned long instead of magic number or uint32_t/uint64_t, e.g.
- Need more comment to describe the algorithm, especially memcpy_<SIZE>_<ALIGN?> and MEMCPY_ALIGNMENT functions.
- Some function using
#if 1
/#else
to comment out code like memcpy_4_2, and it seems like memcpy32_speed / memcpy64_speed using different implementation? I'd like remove all#if 1
and#else
part in the code to keep it cleaner. - Do you mind sharing your experimental result about that?
Whar is the status of this patch? Do we still need it? riscv-newlib itself has been deprecated. Support for a small memcpy when optimizing for size was added a while ago, so that part of the patch is likely no longer needed. The other changes might be useful if performance data shows that they make memcpy faster.