[llvm] [Thumb1] Resolve Fixme: use 'mov hi, $src; mov $dst, hi' (PR #81908)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 15 11:23:01 PST 2024
https://github.com/AtariDreams created https://github.com/llvm/llvm-project/pull/81908
None
>From 4ff4bfca8cce714480237212d4a088566ec6a4f1 Mon Sep 17 00:00:00 2001
From: Rose <83477269+AtariDreams at users.noreply.github.com>
Date: Thu, 15 Feb 2024 14:21:56 -0500
Subject: [PATCH] [Thumb1] Resolve Fixme: use 'mov hi, $src; mov $dst, hi'
---
llvm/lib/Target/ARM/Thumb1InstrInfo.cpp | 32 ++++++++++++++++++++++---
1 file changed, 29 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/Target/ARM/Thumb1InstrInfo.cpp b/llvm/lib/Target/ARM/Thumb1InstrInfo.cpp
index 85eabdb17ad190..01b8c76674d207 100644
--- a/llvm/lib/Target/ARM/Thumb1InstrInfo.cpp
+++ b/llvm/lib/Target/ARM/Thumb1InstrInfo.cpp
@@ -53,9 +53,6 @@ void Thumb1InstrInfo::copyPhysReg(MachineBasicBlock &MBB,
.addReg(SrcReg, getKillRegState(KillSrc))
.add(predOps(ARMCC::AL));
else {
- // FIXME: Can also use 'mov hi, $src; mov $dst, hi',
- // with hi as either r10 or r11.
-
const TargetRegisterInfo *RegInfo = st.getRegisterInfo();
if (MBB.computeRegisterLiveness(RegInfo, ARM::CPSR, I)
== MachineBasicBlock::LQR_Dead) {
@@ -65,6 +62,35 @@ void Thumb1InstrInfo::copyPhysReg(MachineBasicBlock &MBB,
return;
}
+ // Can also use 'mov hi, $src; mov $dst, hi',
+ // with hi as either r10 or r11.
+ if (MBB.computeRegisterLiveness(RegInfo, ARM::R10, I) ==
+ MachineBasicBlock::LQR_Dead) {
+ // Use high register to move source to destination
+ BuildMI(MBB, I, DL, get(ARM::tMOVr), ARM::R10)
+ .addReg(SrcReg, getKillRegState(KillSrc))
+ .add(predOps(ARMCC::AL));
+ BuildMI(MBB, I, DL, get(ARM::tMOVr), DestReg)
+ .addReg(ARM::R10, getKillRegState(KillSrc))
+ .add(predOps(ARMCC::AL))
+ ->addRegisterDead(ARM::R10, RegInfo);
+ return;
+ }
+
+ if (MBB.computeRegisterLiveness(RegInfo, ARM::R11, I) ==
+ MachineBasicBlock::LQR_Dead) {
+ // Use high register to move source to destination
+ BuildMI(MBB, I, DL, get(ARM::tMOVr), ARM::R11)
+ .addReg(SrcReg, getKillRegState(KillSrc))
+ .add(predOps(ARMCC::AL));
+ BuildMI(MBB, I, DL, get(ARM::tMOVr), DestReg)
+ .addReg(ARM::R11, getKillRegState(KillSrc))
+ .add(predOps(ARMCC::AL))
+ ->addRegisterDead(ARM::R11, RegInfo);
+ ;
+ return;
+ }
+
// 'MOV lo, lo' is unpredictable on < v6, so use the stack to do it
BuildMI(MBB, I, DL, get(ARM::tPUSH))
.add(predOps(ARMCC::AL))
More information about the llvm-commits
mailing list