[PATCH v2 3/3] riscv: memcpy_noalignment: Reorder to store via a3, then bump a3
Peter Bergner
bergner@tenstorrent.com
Tue Sep 16 22:06:46 GMT 2025
On 9/3/25 4:45 AM, Yao Zihong wrote:
> Rewrite the copy micro-step from:
>
> REG_L a4, 0(a5)
> addi a3, a3, SZREG
> addi a5, a5, SZREG
> REG_S a4, -SZREG(a3)
>
> to:
>
> REG_L a4, 0(a5)
> addi a5, a5, SZREG
> REG_S a4, 0(a3)
> addi a3, a3, SZREG
>
> Semantics are unchanged: both read *(a5_old), write *(a3_old), and then
> increment a3/a5 by SZREG. memcpy assumes non-overlapping regions, so the
> reordering preserves correctness.
LGTM and bonus, the REG_S insn is converted to a compressed form too.
Reviewed-by: Peter Bergner <bergner@tenstorrent.com>
Peter
More information about the Libc-alpha
mailing list