[llvm] [CodeGen][PreISelIntrinsicLowering] Add VP-based lowering for memcpy/memmove/memset (PR #165585)
David Del Río via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 30 02:28:07 PDT 2025
dadra-oc wrote:
As it stands, the expansion is triggered when the target supports scalable vectors and either the new option flag is enabled or the corresponding libcall is set to nullptr in TLI.
I could modify that condition to check if the target machine is RISC-V. Another option would be to introduce a virtual method in TM that returns a target-specific preference which in the case of RISC-V could be the value of a command-line flag.
Let me know which approach you'd prefer.
Regarding the performance evaluation, I do not have any RISC-V hardware that I could use right now and I am basically using gem5 for evaluating small cases and qemu for validation. Running llvm tests-suite or SPEC takes foreverer in gem5.
However, I can give you some numbers for the small tests I have used. For this tests I mesured the number of simulated cycles for the region of code where the call is. On the case of the memmove, I have evaluated with an overlap of half of the elements to be copied and triggering both cases backward and forward copy.
The gem5 model I have used is set to have vector registers of 512b and size in the table is number of int32_t to be copied. I hope these number at least gives an idea of what could be the actual performance impact.
memcpy:
| Size | Libcall | VP-Expansion |
|----------|----------|----------|
| 2 | 328000 | 17000 |
| 4 | 326500 | 17000 |
| 8 | 327000 | 17000 |
| 16 | 328500 | 17000 |
| 32 | 331000 | 33500 |
| 64 | 427000 | 60500 |
| 128 | 555500 | 89000 |
memmove (Forward):
| Size | Libcall | VP-Expansion |
|----------|----------|----------|
| 2 | 66500 | 24000 |
| 4 | 174000 | 24000 |
| 8 | 174500 | 24500 |
| 16 | 175500| 24500 |
| 32 | 177500 | 38000 |
| 64 | 181500 | 64500 |
| 128 | 189500 | 89000 |
memmove (Backward):
| Size | Libcall | VP-Expansion |
|----------|----------|----------|
| 2 | 114500 | 19000 |
| 4 | 236500 | 19000 |
| 8 | 266500 | 19500 |
| 16 | 236500| 21000 |
| 32 | 238500 | 34500 |
| 64 | 242500 | 60500 |
| 128 | 248500 | 96000 |
memset:
| Size | Libcall | VP-Expansion |
|----------|----------|----------|
| 2 | 90000 | 17000 |
| 4 | 98500 | 19000 |
| 8 | 106000 | 19500 |
| 16 | 98000 | 17500 |
| 32 | 114000 | 30500 |
| 64 | 129500 | 56500 |
| 128 | 195500 | 107000 |
https://github.com/llvm/llvm-project/pull/165585
More information about the llvm-commits
mailing list