Skip to content

Commit 595ae8e

Browse files
committed
[RISCV] Add a InstRW to COPY in RISCVSchedSpacemitX60.td.
This prevents the scheduler from thinking copy instructions are free. In #167008, we saw cases where the scheduler moved ABI copies past other instructions creating high register pressure that caused the register allocator to run out of registers. They can't be spilled because the physical register lifetime was increased, not the virtual register. Ideally, we would detect what registers the COPY is for, but for now I've just treated it as a scalar integer copy.
1 parent d9cf0db commit 595ae8e

File tree

2 files changed

+22
-18
lines changed

2 files changed

+22
-18
lines changed

llvm/lib/Target/RISCV/RISCVSchedSpacemitX60.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,10 @@ def : WriteRes<WriteCSR, [SMX60_IEU]>;
860860
def : WriteRes<WriteNop, [SMX60_IEU]>;
861861
def : WriteRes<WriteRdVLENB, [SMX60_IEUA]>;
862862

863+
// Give COPY instructions an execution resource.
864+
// FIXME: This could be better modeled by looking at the regclasses of the operands.
865+
def : InstRW<[WriteIALU], (instrs COPY)>;
866+
863867
//===----------------------------------------------------------------------===//
864868
// Bypass and advance
865869
def : ReadAdvance<ReadJmp, 0>;

llvm/test/CodeGen/RISCV/rvv/vxrm-insert-out-of-loop.ll

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -308,30 +308,30 @@ define void @test1(ptr nocapture noundef writeonly %dst, i32 noundef signext %i_
308308
; RV64X60-NEXT: addi s1, a7, -1
309309
; RV64X60-NEXT: zext.w s1, s1
310310
; RV64X60-NEXT: mul t3, a1, s1
311-
; RV64X60-NEXT: mul t4, a3, s1
312-
; RV64X60-NEXT: mul t5, a5, s1
313-
; RV64X60-NEXT: add s0, a0, a6
311+
; RV64X60-NEXT: mul t5, a3, s1
312+
; RV64X60-NEXT: mul t4, a5, s1
313+
; RV64X60-NEXT: add s1, a0, a6
314314
; RV64X60-NEXT: csrr t2, vlenb
315-
; RV64X60-NEXT: add s1, a2, a6
316-
; RV64X60-NEXT: add t3, t3, s0
317-
; RV64X60-NEXT: add s0, a4, a6
318-
; RV64X60-NEXT: add t4, t4, s1
319-
; RV64X60-NEXT: li t6, 32
315+
; RV64X60-NEXT: add s0, a2, a6
316+
; RV64X60-NEXT: add s2, s1, t3
317+
; RV64X60-NEXT: add t3, a4, a6
320318
; RV64X60-NEXT: add t5, t5, s0
321-
; RV64X60-NEXT: sltu s0, a0, t4
322-
; RV64X60-NEXT: sltu s1, a2, t3
323-
; RV64X60-NEXT: and t4, s0, s1
324-
; RV64X60-NEXT: or s2, a1, a3
319+
; RV64X60-NEXT: or t6, a1, a3
320+
; RV64X60-NEXT: add t4, t4, t3
325321
; RV64X60-NEXT: sltu s0, a0, t5
326-
; RV64X60-NEXT: sltu s1, a4, t3
327-
; RV64X60-NEXT: srli t3, s2, 63
328-
; RV64X60-NEXT: and s0, s0, s1
329-
; RV64X60-NEXT: or s1, a1, a5
330-
; RV64X60-NEXT: or t4, t4, t3
322+
; RV64X60-NEXT: sltu s1, a2, s2
323+
; RV64X60-NEXT: and t5, s0, s1
331324
; RV64X60-NEXT: slli t3, t2, 1
325+
; RV64X60-NEXT: sltu t4, a0, t4
326+
; RV64X60-NEXT: sltu s0, a4, s2
327+
; RV64X60-NEXT: srli s1, t6, 63
328+
; RV64X60-NEXT: and s0, t4, s0
329+
; RV64X60-NEXT: or t4, t5, s1
330+
; RV64X60-NEXT: or s1, a1, a5
331+
; RV64X60-NEXT: li t5, 32
332332
; RV64X60-NEXT: srli s1, s1, 63
333333
; RV64X60-NEXT: or s0, s0, s1
334-
; RV64X60-NEXT: maxu s1, t3, t6
334+
; RV64X60-NEXT: maxu s1, t3, t5
335335
; RV64X60-NEXT: or s0, t4, s0
336336
; RV64X60-NEXT: sltu s1, a6, s1
337337
; RV64X60-NEXT: or s0, s0, s1

0 commit comments

Comments
 (0)