[PATCH v1 2/3] riscv: Add RVV implementation __strcpy_vector
Sergei Lewis
slewis@rivosinc.com
Fri Sep 19 16:26:13 GMT 2025
>
> In previous measurements, reading the vl CSR appears to add noticeable
> latency
>
Why do we ever need to read the vl CSR at all? Sure, vle8ff adjusts it if
there is a fault. However, consider: strcpy() behaviour is undefined if the
buffer is not null terminated, so no particular behaviour is required in
that situation and we are free to choose whatever is cheapest; and if it
/is/ null terminated, the null byte will be available to subsequent
operations as normal regardless of what else vle8ff does or does not do,
and the subsequent comparison and store operations will behave correctly
without us needing to explicitly interact with VL.
Compare:
mv t0, a0
vsetvli t1, zero, e8, m8, ta, ma
1: vle8ff.v v8, (a1)
vmseq.vi v0, v8, 0
vfirst.m a2, v0
bgez a2, 1f
vse8.v v8, (t0)
add t0, t0, t1
add a1, a1, t1
bltz a2, 1b
1: addi t1, a2, 1
vsetvli zero, t1, e8, m8, ta, ma
vse8.v v8, (t0)
ret
Also, I note the submitted patch uses m4. Why not m8?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20250919/1e14f1e5/attachment.htm>
More information about the Libc-alpha
mailing list