Skip to content

Commit 949774c

Browse files
committed
[Thumb1] Resolve Fixme: use 'mov hi, $src; mov $dst, hi'
1 parent 3e004d1 commit 949774c

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

llvm/lib/Target/ARM/Thumb1InstrInfo.cpp

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ void Thumb1InstrInfo::copyPhysReg(MachineBasicBlock &MBB,
5353
.addReg(SrcReg, getKillRegState(KillSrc))
5454
.add(predOps(ARMCC::AL));
5555
else {
56-
// FIXME: Can also use 'mov hi, $src; mov $dst, hi',
57-
// with hi as either r10 or r11.
58-
5956
const TargetRegisterInfo *RegInfo = st.getRegisterInfo();
6057
if (MBB.computeRegisterLiveness(RegInfo, ARM::CPSR, I)
6158
== MachineBasicBlock::LQR_Dead) {
@@ -65,6 +62,35 @@ void Thumb1InstrInfo::copyPhysReg(MachineBasicBlock &MBB,
6562
return;
6663
}
6764

65+
// Can also use 'mov hi, $src; mov $dst, hi',
66+
// with hi as either r10 or r11.
67+
if (MBB.computeRegisterLiveness(RegInfo, ARM::R10, I) ==
68+
MachineBasicBlock::LQR_Dead) {
69+
// Use high register to move source to destination
70+
BuildMI(MBB, I, DL, get(ARM::tMOVr), ARM::R10)
71+
.addReg(SrcReg, getKillRegState(KillSrc))
72+
.add(predOps(ARMCC::AL));
73+
BuildMI(MBB, I, DL, get(ARM::tMOVr), DestReg)
74+
.addReg(ARM::R10, getKillRegState(KillSrc))
75+
.add(predOps(ARMCC::AL))
76+
->addRegisterDead(ARM::R10, RegInfo);
77+
return;
78+
}
79+
80+
if (MBB.computeRegisterLiveness(RegInfo, ARM::R11, I) ==
81+
MachineBasicBlock::LQR_Dead) {
82+
// Use high register to move source to destination
83+
BuildMI(MBB, I, DL, get(ARM::tMOVr), ARM::R11)
84+
.addReg(SrcReg, getKillRegState(KillSrc))
85+
.add(predOps(ARMCC::AL));
86+
BuildMI(MBB, I, DL, get(ARM::tMOVr), DestReg)
87+
.addReg(ARM::R11, getKillRegState(KillSrc))
88+
.add(predOps(ARMCC::AL))
89+
->addRegisterDead(ARM::R11, RegInfo);
90+
;
91+
return;
92+
}
93+
6894
// 'MOV lo, lo' is unpredictable on < v6, so use the stack to do it
6995
BuildMI(MBB, I, DL, get(ARM::tPUSH))
7096
.add(predOps(ARMCC::AL))

0 commit comments

Comments
 (0)