[llvm] [RISCV][RegAlloc] Add getCSRFirstUseCost for RISC-V (PR #131349)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 14 09:31:38 PDT 2025


================
@@ -0,0 +1,91 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+; RUN: llc %s -mtriple=riscv64 -regalloc-csr-first-time-cost=0 | FileCheck %s -check-prefix=ZERO-COST
+; RUN: llc %s -mtriple=riscv64 | FileCheck %s -check-prefix=DEFAULT-COST
+
+define fastcc void @Perl_sv_setnv(ptr %.str.54.3682) nounwind {
+; ZERO-COST-LABEL: Perl_sv_setnv:
+; ZERO-COST:       # %bb.0: # %entry
+; ZERO-COST-NEXT:    addi sp, sp, -32
+; ZERO-COST-NEXT:    sd ra, 24(sp) # 8-byte Folded Spill
+; ZERO-COST-NEXT:    sd s0, 16(sp) # 8-byte Folded Spill
+; ZERO-COST-NEXT:    sd s1, 8(sp) # 8-byte Folded Spill
+; ZERO-COST-NEXT:    bnez zero, .LBB0_5
+; ZERO-COST-NEXT:  # %bb.1: # %entry
+; ZERO-COST-NEXT:    li a1, 1
+; ZERO-COST-NEXT:    bnez a1, .LBB0_6
+; ZERO-COST-NEXT:  .LBB0_2: # %entry
+; ZERO-COST-NEXT:    mv s0, a0
+; ZERO-COST-NEXT:    beqz zero, .LBB0_4
+; ZERO-COST-NEXT:  # %bb.3: # %sw.bb34.i
+; ZERO-COST-NEXT:    li s0, 0
+; ZERO-COST-NEXT:  .LBB0_4: # %Perl_sv_reftype.exit
+; ZERO-COST-NEXT:    li s1, 0
+; ZERO-COST-NEXT:    li a0, 0
+; ZERO-COST-NEXT:    li a1, 0
+; ZERO-COST-NEXT:    jalr s1
+; ZERO-COST-NEXT:    li a0, 0
+; ZERO-COST-NEXT:    mv a1, s0
+; ZERO-COST-NEXT:    li a2, 0
+; ZERO-COST-NEXT:    jalr s1
+; ZERO-COST-NEXT:  .LBB0_5: # %entry
+; ZERO-COST-NEXT:    beqz zero, .LBB0_2
+; ZERO-COST-NEXT:  .LBB0_6: # %sw.bb3
+; ZERO-COST-NEXT:    ld ra, 24(sp) # 8-byte Folded Reload
+; ZERO-COST-NEXT:    ld s0, 16(sp) # 8-byte Folded Reload
+; ZERO-COST-NEXT:    ld s1, 8(sp) # 8-byte Folded Reload
+; ZERO-COST-NEXT:    addi sp, sp, 32
+; ZERO-COST-NEXT:    ret
+;
+; DEFAULT-COST-LABEL: Perl_sv_setnv:
+; DEFAULT-COST:       # %bb.0: # %entry
+; DEFAULT-COST-NEXT:    addi sp, sp, -32
+; DEFAULT-COST-NEXT:    sd ra, 24(sp) # 8-byte Folded Spill
+; DEFAULT-COST-NEXT:    sd s0, 16(sp) # 8-byte Folded Spill
+; DEFAULT-COST-NEXT:    bnez zero, .LBB0_5
+; DEFAULT-COST-NEXT:  # %bb.1: # %entry
+; DEFAULT-COST-NEXT:    li a1, 1
+; DEFAULT-COST-NEXT:    bnez a1, .LBB0_6
+; DEFAULT-COST-NEXT:  .LBB0_2: # %entry
+; DEFAULT-COST-NEXT:    sd a0, 8(sp) # 8-byte Folded Spill
+; DEFAULT-COST-NEXT:    beqz zero, .LBB0_4
----------------
topperc wrote:

This is non-sensical instruction. Any idea what caused it?

https://github.com/llvm/llvm-project/pull/131349


More information about the llvm-commits mailing list