[llvm] [RISCV][WIP] Let RA do the CSR saves. (PR #90819)
Alex Bradbury via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 27 03:07:31 PST 2025
asb wrote:
> > @mgudim @ppenzin I was interested in kicking the tires on this to see impact on recentish HEAD on SPEC. Do either of you have a recent version of this patchset that is known good? I built https://github.com/mgudim/llvm-project/tree/save_csr_in_ra3 but I'm getting compiler crashes at the initial cmake configure for llvm-test-suite with `-mllvm -riscv-save-csrs-early=true`, or when I do it with `-save-temps=obj` as well I get errors about unrecognized instruction mnemonic `BUNDLE`.
>
> @asb I think this branch: https://github.com/mgudim/llvm-project/tree/rebased_save_csr_in_ra should be working. To enable saving csrs early don't forget to add these two flags:
>
> ```
> -mllvm -riscv-enable-save-csr-in-ra=true
> -mllvm -min-weight-ratio-needed-to-evict-hint=7.5
> ```
>
> That branch only has one huge commit and its' just POC. I am still working on breaking it up into smaller commits and putting them on (https://github.com/mgudim/llvm-project/tree/save_csr_in_ra3). But that branch is in broken state right now
Thank you. I haven't looked to see what it would take to rebase on current HEAD, but comparing that branch with a baseline of commit `d7e48fbf205a01fcbc109b2555b12aa0d37845a4` (the last upstream commit before your downstream patches), and running SPEC -march=rva22u64 I get these results for dynamically executed instructions:
```
Benchmark Baseline csrinra Diff (%)
============================================================
500.perlbench_r 180245021535 174761106584 -3.04%
502.gcc_r 220872098438 204171725268 -7.56%
505.mcf_r 131589945206 132303362396 0.54%
508.namd_r 220648060756 219744519650 -0.41%
510.parest_r 291341819989 291293000597 -0.02%
511.povray_r 31914276340 27581024333 -13.58%
519.lbm_r 94166321455 96148444880 2.10%
520.omnetpp_r 138002605450 132999926345 -3.63%
523.xalancbmk_r 283566181775 269486838918 -4.97%
525.x264_r 380165034541 383766253106 0.95%
526.blender_r 660528269650 645308870803 -2.30%
531.deepsjeng_r 355058534696 357485665398 0.68%
538.imagick_r 238573640980 238240294103 -0.14%
541.leela_r 421886351049 411685513225 -2.42%
544.nab_r 415595727842 415394887715 -0.05%
557.xz_r 132548717793 133865723492 0.99%
```
There's some big wins here, especially for povray and gcc.
Based on comments in this thread there may be issues with the wider llvm-test-suite, but all SPEC benchmarks compile and run to completion. If you're planning to do a new rebase do let me know as that would be a better test to run.
https://github.com/llvm/llvm-project/pull/90819
More information about the llvm-commits
mailing list