[llvm] [RegisterCoalescer] Remove unneeded definesFullReg check (PR #178241)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 27 07:56:02 PST 2026
https://github.com/jayfoad created https://github.com/llvm/llvm-project/pull/178241
An equivalent check is already done inside
TargetInstrInfo::isReMaterializable.
>From 3cdcae5e58fb1836e69583e742874b4f068b747c Mon Sep 17 00:00:00 2001
From: Jay Foad <jay.foad at amd.com>
Date: Tue, 27 Jan 2026 15:54:28 +0000
Subject: [PATCH] [RegisterCoalescer] Remove unneeded definesFullReg check
An equivalent check is already done inside
TargetInstrInfo::isReMaterializable.
---
llvm/lib/CodeGen/RegisterCoalescer.cpp | 18 ------------------
1 file changed, 18 deletions(-)
diff --git a/llvm/lib/CodeGen/RegisterCoalescer.cpp b/llvm/lib/CodeGen/RegisterCoalescer.cpp
index 971813d1c22a7..527ecca6eab47 100644
--- a/llvm/lib/CodeGen/RegisterCoalescer.cpp
+++ b/llvm/lib/CodeGen/RegisterCoalescer.cpp
@@ -1288,22 +1288,6 @@ bool RegisterCoalescer::removePartialRedundancy(const CoalescerPair &CP,
return true;
}
-/// Returns true if @p MI defines the full vreg @p Reg, as opposed to just
-/// defining a subregister.
-static bool definesFullReg(const MachineInstr &MI, Register Reg) {
- assert(!Reg.isPhysical() && "This code cannot handle physreg aliasing");
-
- for (const MachineOperand &Op : MI.all_defs()) {
- if (Op.getReg() != Reg)
- continue;
- // Return true if we define the full register or don't care about the value
- // inside other subregisters.
- if (Op.getSubReg() == 0 || Op.isUndef())
- return true;
- }
- return false;
-}
-
bool RegisterCoalescer::reMaterializeDef(const CoalescerPair &CP,
MachineInstr *CopyMI,
bool &IsDefCopy) {
@@ -1335,8 +1319,6 @@ bool RegisterCoalescer::reMaterializeDef(const CoalescerPair &CP,
if (!TII->isReMaterializable(*DefMI))
return false;
- if (!definesFullReg(*DefMI, SrcReg))
- return false;
bool SawStore = false;
if (!DefMI->isSafeToMove(SawStore))
return false;
More information about the llvm-commits
mailing list