Skip to content

Commit b6c4ad7

Browse files
authored
[RISCV] Remove x7 from fastcc list. (#96729)
Like #93321, this patch also tries to solve the conflict usage of x7 for fastcc and Zicfilp. But this patch removes x7 from fastcc directly. Its purpose is to reduce the code complexity of #93321, and we also found that it at most increase 0.02% instruction count for most benchmarks and it might be benefit for benchmarks.
1 parent f56cdd4 commit b6c4ad7

File tree

5 files changed

+680
-652
lines changed

5 files changed

+680
-652
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18884,15 +18884,14 @@ ArrayRef<MCPhysReg> RISCV::getArgGPRs(const RISCVABI::ABI ABI) {
1888418884
static ArrayRef<MCPhysReg> getFastCCArgGPRs(const RISCVABI::ABI ABI) {
1888518885
// The GPRs used for passing arguments in the FastCC, X5 and X6 might be used
1888618886
// for save-restore libcall, so we don't use them.
18887+
// Don't use X7 for fastcc, since Zicfilp uses X7 as the label register.
1888718888
static const MCPhysReg FastCCIGPRs[] = {
18888-
RISCV::X10, RISCV::X11, RISCV::X12, RISCV::X13, RISCV::X14,
18889-
RISCV::X15, RISCV::X16, RISCV::X17, RISCV::X7, RISCV::X28,
18890-
RISCV::X29, RISCV::X30, RISCV::X31};
18889+
RISCV::X10, RISCV::X11, RISCV::X12, RISCV::X13, RISCV::X14, RISCV::X15,
18890+
RISCV::X16, RISCV::X17, RISCV::X28, RISCV::X29, RISCV::X30, RISCV::X31};
1889118891

1889218892
// The GPRs used for passing arguments in the FastCC when using ILP32E/ILP64E.
1889318893
static const MCPhysReg FastCCEGPRs[] = {RISCV::X10, RISCV::X11, RISCV::X12,
18894-
RISCV::X13, RISCV::X14, RISCV::X15,
18895-
RISCV::X7};
18894+
RISCV::X13, RISCV::X14, RISCV::X15};
1889618895

1889718896
if (ABI == RISCVABI::ABI_ILP32E || ABI == RISCVABI::ABI_LP64E)
1889818897
return ArrayRef(FastCCEGPRs);

llvm/test/CodeGen/RISCV/fastcc-int.ll

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,17 @@ define i32 @caller(<16 x i32> %A) nounwind {
3232
; RV32-NEXT: lw a5, 20(a0)
3333
; RV32-NEXT: lw a6, 24(a0)
3434
; RV32-NEXT: lw a7, 28(a0)
35-
; RV32-NEXT: lw t2, 32(a0)
36-
; RV32-NEXT: lw t3, 36(a0)
37-
; RV32-NEXT: lw t4, 40(a0)
38-
; RV32-NEXT: lw t5, 44(a0)
39-
; RV32-NEXT: lw t6, 48(a0)
40-
; RV32-NEXT: lw t1, 52(a0)
35+
; RV32-NEXT: lw t3, 32(a0)
36+
; RV32-NEXT: lw t4, 36(a0)
37+
; RV32-NEXT: lw t5, 40(a0)
38+
; RV32-NEXT: lw t6, 44(a0)
39+
; RV32-NEXT: lw t1, 48(a0)
40+
; RV32-NEXT: lw t2, 52(a0)
4141
; RV32-NEXT: lw s0, 56(a0)
4242
; RV32-NEXT: lw a0, 60(a0)
43-
; RV32-NEXT: sw a0, 8(sp)
44-
; RV32-NEXT: sw s0, 4(sp)
43+
; RV32-NEXT: sw a0, 12(sp)
44+
; RV32-NEXT: sw s0, 8(sp)
45+
; RV32-NEXT: sw t2, 4(sp)
4546
; RV32-NEXT: sw t1, 0(sp)
4647
; RV32-NEXT: mv a0, t0
4748
; RV32-NEXT: call callee
@@ -63,16 +64,17 @@ define i32 @caller(<16 x i32> %A) nounwind {
6364
; RV64-NEXT: ld a5, 40(a0)
6465
; RV64-NEXT: ld a6, 48(a0)
6566
; RV64-NEXT: ld a7, 56(a0)
66-
; RV64-NEXT: ld t2, 64(a0)
67-
; RV64-NEXT: ld t3, 72(a0)
68-
; RV64-NEXT: ld t4, 80(a0)
69-
; RV64-NEXT: ld t5, 88(a0)
70-
; RV64-NEXT: ld t6, 96(a0)
71-
; RV64-NEXT: ld t1, 104(a0)
67+
; RV64-NEXT: ld t3, 64(a0)
68+
; RV64-NEXT: ld t4, 72(a0)
69+
; RV64-NEXT: ld t5, 80(a0)
70+
; RV64-NEXT: ld t6, 88(a0)
71+
; RV64-NEXT: ld t1, 96(a0)
72+
; RV64-NEXT: ld t2, 104(a0)
7273
; RV64-NEXT: ld s0, 112(a0)
7374
; RV64-NEXT: ld a0, 120(a0)
74-
; RV64-NEXT: sd a0, 16(sp)
75-
; RV64-NEXT: sd s0, 8(sp)
75+
; RV64-NEXT: sd a0, 24(sp)
76+
; RV64-NEXT: sd s0, 16(sp)
77+
; RV64-NEXT: sd t2, 8(sp)
7678
; RV64-NEXT: sd t1, 0(sp)
7779
; RV64-NEXT: mv a0, t0
7880
; RV64-NEXT: call callee

0 commit comments

Comments
 (0)