Skip to content

Commit af4c3e7

Browse files
committed
Update RISCVInstrInfo::copyPhysReg with renamable ADDI
1 parent eb1120c commit af4c3e7

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

llvm/lib/CodeGen/TargetInstrInfo.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,9 @@ void TargetInstrInfo::lowerCopy(MachineInstr *MI,
823823
}
824824

825825
copyPhysReg(*MI->getParent(), MI, MI->getDebugLoc(), DstMO.getReg(),
826-
SrcMO.getReg(), SrcMO.isKill());
826+
SrcMO.getReg(), SrcMO.isKill(),
827+
DstMO.getReg().isPhysical() ? DstMO.isRenamable() : false,
828+
SrcMO.getReg().isPhysical() ? SrcMO.isRenamable() : false);
827829

828830
if (MI->getNumOperands() > 2)
829831
transferImplicitOperands(MI, TRI);

llvm/lib/Target/RISCV/RISCVInstrInfo.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,8 @@ void RISCVInstrInfo::copyPhysReg(MachineBasicBlock &MBB,
446446

447447
if (RISCV::GPRRegClass.contains(DstReg, SrcReg)) {
448448
BuildMI(MBB, MBBI, DL, get(RISCV::ADDI), DstReg)
449-
.addReg(SrcReg, getKillRegState(KillSrc))
449+
.addReg(SrcReg,
450+
getKillRegState(KillSrc) | getRenamableRegState(RenamableSrc))
450451
.addImm(0);
451452
return;
452453
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2+
# RUN: llc -o - %s -mtriple=riscv32 -simplify-mir \
3+
# RUN: -run-pass=postrapseudos | FileCheck --check-prefix=RV32 %s
4+
# RUN: llc -o - %s -mtriple=riscv64 -simplify-mir \
5+
# RUN: -run-pass=postrapseudos | FileCheck --check-prefix=RV64 %s
6+
7+
--- |
8+
define void @foo() {
9+
entry:
10+
ret void
11+
}
12+
...
13+
---
14+
name: foo
15+
body: |
16+
bb.0.entry:
17+
liveins: $x11
18+
; RV32-LABEL: name: foo
19+
; RV32: liveins: $x11
20+
; RV32-NEXT: {{ $}}
21+
; RV32-NEXT: $x10 = ADDI renamable $x11, 0
22+
; RV32-NEXT: PseudoRET implicit $x10
23+
;
24+
; RV64-LABEL: name: foo
25+
; RV64: liveins: $x11
26+
; RV64-NEXT: {{ $}}
27+
; RV64-NEXT: $x10 = ADDI renamable $x11, 0
28+
; RV64-NEXT: PseudoRET implicit $x10
29+
renamable $x10 = COPY renamable $x11
30+
PseudoRET implicit $x10
31+
...

0 commit comments

Comments
 (0)