[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 12:29:44 PST 2024
https://github.com/AtariDreams updated https://github.com/llvm/llvm-project/pull/81908
>From 949774c3b26d90f686bf7b07208e0ea4c71d2eb7 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 1/2] [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))
>From b34cf5ba5276aee727cf9b5e404fcfe54801ded8 Mon Sep 17 00:00:00 2001
From: Rose <83477269+AtariDreams at users.noreply.github.com>
Date: Thu, 15 Feb 2024 15:29:22 -0500
Subject: [PATCH 2/2] ok
---
llvm/lib/Target/ARM/Thumb1InstrInfo.cpp | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/llvm/lib/Target/ARM/Thumb1InstrInfo.cpp b/llvm/lib/Target/ARM/Thumb1InstrInfo.cpp
index 01b8c76674d207..1161d62ff7bea1 100644
--- a/llvm/lib/Target/ARM/Thumb1InstrInfo.cpp
+++ b/llvm/lib/Target/ARM/Thumb1InstrInfo.cpp
@@ -71,9 +71,8 @@ void Thumb1InstrInfo::copyPhysReg(MachineBasicBlock &MBB,
.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);
+ .addReg(ARM::R10, RegState::Kill)
+ .add(predOps(ARMCC::AL));
return;
}
@@ -84,10 +83,8 @@ void Thumb1InstrInfo::copyPhysReg(MachineBasicBlock &MBB,
.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);
- ;
+ .addReg(ARM::R11, RegState::Kill)
+ .add(predOps(ARMCC::AL));
return;
}
More information about the llvm-commits
mailing list