[llvm] [Codegen] Remove redundant instruction using machinelateCleanup (PR #139716)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon May 19 05:11:52 PDT 2025
================
@@ -189,7 +189,13 @@ static bool isCandidate(const MachineInstr *MI, Register &DefedReg,
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;
+ if (MO.isImplicit() && TRI->regsOverlap(MO.getReg(), DefedReg))
----------------
arsenm wrote:
The implicit operands could be anything, the extra operand could be an arbitrary def of an unrelated register.
I'm assuming this pattern appeared as a result of coalescing SUBREG_TO_REG. We should really try to remove it and require emitting instructions that explicitly define the used register parts. We have to go out our way to maintain the liveness it introduced in the producer instructions, and it introduces a lot of complexity in downstream optimizations (like this case). But that will be a big project, particularly for x86
https://github.com/llvm/llvm-project/pull/139716
More information about the llvm-commits
mailing list