[PATCH] D118020: [RISCV] Set CostPerUse for floating point registers
Wang Pengcheng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 18 01:30:05 PST 2022
pcwang-thead added a comment.
In D118020#3329779 <https://reviews.llvm.org/D118020#3329779>, @asb wrote:
> I'm surprised this resulted in performance increases. I might have guessed that with so few FP instructions being compressible, the further constraint on register selection might be more likely to result in a (slight) decrease in performance. Shows the value of running the benchmarks!
>
> I've put this patch on the agenda for the RISC-V LLVM call today, but based on the data so far this seems to make sense.
I am surprised too.
IMO, there is a possible reason that may explain the performance increases:
- When register number is in [8, 15], instructions can be compressed.
- For the first 16 integer registers, registers x0-x4(and sometimes x5) are reserved for special usage, and the register allocation orders are like below:
def GPR : RegisterClass<"RISCV", [XLenVT], 32, (add
(sequence "X%u", 10, 17),
(sequence "X%u", 5, 7),
(sequence "X%u", 28, 31),
(sequence "X%u", 8, 9),
(sequence "X%u", 18, 27),
(sequence "X%u", 0, 4)
)> {
let RegInfos = XLenRI;
}
which means we will allocates most RVC integer registers first.
So, for most programs, there is minimal difference whether we set `CostPerUse` to `0` or `1`.
- For the first 16 float registers, there is no reserved register, and the register allocation orders are like below:
def FPR32 : RegisterClass<"RISCV", [f32], 32, (add
(sequence "F%u_F", 0, 7),
(sequence "F%u_F", 10, 17),
(sequence "F%u_F", 28, 31),
(sequence "F%u_F", 8, 9),
(sequence "F%u_F", 18, 27)
)>;
which means we will allocates temporary float registers first and most float instructions can't be compressed.
So when we set `CostPerUse` to `1`, a lot of float instructions can be compressed, which results in improvements on icache misses.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D118020/new/
https://reviews.llvm.org/D118020
More information about the llvm-commits
mailing list