[llvm] [Codegen] Remove redundant instruction using machinelateCleanup (PR #139716)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Mon May 19 03:02:54 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))
----------------
jayfoad wrote:
Example:
// If a later implicit def overlaps with the first def, ignore it.
"Overlaps" seem like the wrong condition here. Don't you need to check that its a subset of the first def?
What I'd really like to see is an explanation of _exactly_ what kind of instruction we're looking for, e.g. "must have at least one explicit def and any other def must either be dead or a subset of the first def". And then make sure that the code matches the comment.
https://github.com/llvm/llvm-project/pull/139716
More information about the llvm-commits
mailing list