aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineCopyPropagation.cpp
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2023-01-13 21:40:04 -0700
committerOwen Anderson <resistor@mac.com>2023-01-25 23:11:46 -0600
commit1a0ec9140c87947599db8d3f864054f62cb13298 (patch)
treea0bbebfd5151cc845039e5d16b8127d49b9dc233 /llvm/lib/CodeGen/MachineCopyPropagation.cpp
parentcdc2a0473e90732245387344248b5487778f9b6f (diff)
downloadllvm-1a0ec9140c87947599db8d3f864054f62cb13298.zip
llvm-1a0ec9140c87947599db8d3f864054f62cb13298.tar.gz
llvm-1a0ec9140c87947599db8d3f864054f62cb13298.tar.bz2
Resolve a FIXME in MachineCopyPropagation by allowig propagation to subregister uses.
Reviewed By: barannikov88 Differential Revision: https://reviews.llvm.org/D141747
Diffstat (limited to 'llvm/lib/CodeGen/MachineCopyPropagation.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineCopyPropagation.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/MachineCopyPropagation.cpp b/llvm/lib/CodeGen/MachineCopyPropagation.cpp
index 8718245..970659c 100644
--- a/llvm/lib/CodeGen/MachineCopyPropagation.cpp
+++ b/llvm/lib/CodeGen/MachineCopyPropagation.cpp
@@ -595,12 +595,15 @@ void MachineCopyPropagation::forwardUses(MachineInstr &MI) {
const MachineOperand &CopySrc = *CopyOperands->Source;
Register CopySrcReg = CopySrc.getReg();
- // FIXME: Don't handle partial uses of wider COPYs yet.
+ // When the use is a subregister of the COPY destination,
+ // record the subreg index.
+ unsigned SubregIdx = 0;
+
+ // This can only occur when we are dealing with physical registers.
if (MOUse.getReg() != CopyDstReg) {
- LLVM_DEBUG(
- dbgs() << "MCP: FIXME! Not forwarding COPY to sub-register use:\n "
- << MI);
- continue;
+ SubregIdx = TRI->getSubRegIndex(CopyDstReg, MOUse.getReg());
+ if (!SubregIdx)
+ continue;
}
// Don't forward COPYs of reserved regs unless they are constant.
@@ -633,7 +636,11 @@ void MachineCopyPropagation::forwardUses(MachineInstr &MI) {
<< "\n with " << printReg(CopySrcReg, TRI)
<< "\n in " << MI << " from " << *Copy);
- MOUse.setReg(CopySrcReg);
+ if (SubregIdx)
+ MOUse.setReg(TRI->getSubReg(CopySrcReg, SubregIdx));
+ else
+ MOUse.setReg(CopySrcReg);
+
if (!CopySrc.isRenamable())
MOUse.setIsRenamable(false);
MOUse.setIsUndef(CopySrc.isUndef());