Skip to content

Commit 77e74c5

Browse files
committed
[RISCV] Move V0 to the end of register allocation order
According to https://riscv-optimization-guide-riseproject-c94355ae3e6872252baa952524.gitlab.io/riscv-optimization-guide.html: > The v0 register defined by the RISC-V vector extension is special in > that it can be used both as a general purpose vector register and also > as a mask register. As a preference, use registers other than v0 for > non-mask values. Otherwise data will have to be moved out of v0 when a > mask is required in an operation. v0 may be used when all other > registers are in use, and using v0 would avoid spilling register state > to memory. And using V0 register may stall masking pipeline and stop chaining for some microarchitectures. So we should try not to use V0 and register groups contained it as much as possible. We achieve this via moving V0 to the end of RA order.
1 parent d1a461d commit 77e74c5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+516
-520
lines changed

llvm/lib/Target/RISCV/RISCVRegisterInfo.td

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -510,17 +510,21 @@ defvar VM8VTs = [vint8m8_t, vint16m8_t, vint32m8_t, vint64m8_t,
510510

511511
def VR : VReg<!listconcat(VM1VTs, VMaskVTs),
512512
(add (sequence "V%u", 8, 31),
513-
(sequence "V%u", 0, 7)), 1>;
513+
// Reverse the order so that we don't kill too much
514+
// LMUL groups.
515+
(sequence "V%u", 7, 0)), 1>;
514516

515517
def VRNoV0 : VReg<!listconcat(VM1VTs, VMaskVTs), (sub VR, V0), 1>;
516518

517519
def VRM2 : VReg<VM2VTs, (add (sequence "V%uM2", 8, 31, 2),
518-
(sequence "V%uM2", 0, 7, 2)), 2>;
520+
// Reverse the order so that we don't kill too much
521+
// LMUL groups.
522+
(sequence "V%uM2", 6, 0, 2)), 2>;
519523

520524
def VRM2NoV0 : VReg<VM2VTs, (sub VRM2, V0M2), 2>;
521525

522526
def VRM4 : VReg<VM4VTs, (add V8M4, V12M4, V16M4, V20M4,
523-
V24M4, V28M4, V0M4, V4M4), 4>;
527+
V24M4, V28M4, V4M4, V0M4), 4>;
524528

525529
def VRM4NoV0 : VReg<VM4VTs, (sub VRM4, V0M4), 4>;
526530

0 commit comments

Comments
 (0)