[llvm] [Codegen] Remove redundant instruction using machinelateCleanup (PR #139716)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri May 16 06:37:33 PDT 2025
================
@@ -186,13 +186,24 @@ static bool isCandidate(const MachineInstr *MI, Register &DefedReg,
for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
const MachineOperand &MO = MI->getOperand(i);
if (MO.isReg()) {
- if (MO.isDef() && DefedReg == MCRegister::NoRegister) {
+ if (MO.isDef()) {
if (i == 0 && !MO.isImplicit() && !MO.isDead())
DefedReg = MO.getReg();
- else
+ else if (i != 0 && DefedReg != MCRegister::NoRegister) {
+ if (MO.isDead() && MO.isImplicit()) {
+ continue;
+ } else if (MO.isImplicit() &&
+ MI->getParent()
+ ->getParent()
+ ->getSubtarget()
+ .getRegisterInfo()
+ ->isSubRegister(MO.getReg(), DefedReg)) {
----------------
arsenm wrote:
This shouldn't have to do so much to find TRI, just pass it into isCandidate as an argument.
Also probably should use regsOverlap instead of isSubRegister?
https://github.com/llvm/llvm-project/pull/139716
More information about the llvm-commits
mailing list