[llvm] [CodeGen] NFC: Change order of checks in MachineInstr->isDead() (PR #124207)
Jeffrey Byrnes via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 23 15:21:08 PST 2025
https://github.com/jrbyrnes created https://github.com/llvm/llvm-project/pull/124207
[[Change-Id: Ic349022bb99ef91f5396e462ade0366bc772ae02](https://github.com/llvm/llvm-project/pull/123531)](https://github.com/llvm/llvm-project/pull/123531) moved isDead() from DeadMachineInstrElim to MachineInstr . In the process of moving, I reordered the checks to improve chances of early exit, but this has caused a slight increase in compile time.
This PR reverts back to the original order of chekcs.
>From b01d845dc42cdc31c3fce5984524f559891fedd9 Mon Sep 17 00:00:00 2001
From: Jeffrey Byrnes <Jeffrey.Byrnes at amd.com>
Date: Thu, 23 Jan 2025 15:10:52 -0800
Subject: [PATCH] [CodeGen] NFC: Change order of checking in
MachineInstr->isDead()
Change-Id: Ic349022bb99ef91f5396e462ade0366bc772ae02
---
llvm/lib/CodeGen/MachineInstr.cpp | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp
index 0f7f525fa479e8..a9f756b6843603 100644
--- a/llvm/lib/CodeGen/MachineInstr.cpp
+++ b/llvm/lib/CodeGen/MachineInstr.cpp
@@ -1353,18 +1353,6 @@ bool MachineInstr::wouldBeTriviallyDead() const {
bool MachineInstr::isDead(const MachineRegisterInfo &MRI,
LiveRegUnits *LivePhysRegs) const {
- // Technically speaking inline asm without side effects and no defs can still
- // be deleted. But there is so much bad inline asm code out there, we should
- // let them be.
- if (isInlineAsm())
- return false;
-
- // If we suspect this instruction may have some side-effects, then we say
- // this instruction cannot be dead.
- // FIXME: See issue #105950 for why LIFETIME markers are considered dead here.
- if (!isLifetimeMarker() && !wouldBeTriviallyDead())
- return false;
-
// Instructions without side-effects are dead iff they only define dead regs.
// This function is hot and this loop returns early in the common case,
// so only perform additional checks before this if absolutely necessary.
@@ -1385,7 +1373,19 @@ bool MachineInstr::isDead(const MachineRegisterInfo &MRI,
}
}
- return true;
+ // Technically speaking inline asm without side effects and no defs can still
+ // be deleted. But there is so much bad inline asm code out there, we should
+ // let them be.
+ if (isInlineAsm())
+ return false;
+
+ // FIXME: See issue #105950 for why LIFETIME markers are considered dead here.
+ if (isLifetimeMarker())
+ return true;
+
+ // If there are no defs with uses, then we call the instruction dead so long
+ // as we do not suspect it may have sideeffects.
+ return wouldBeTriviallyDead();
}
static bool MemOperandsHaveAlias(const MachineFrameInfo &MFI,
More information about the llvm-commits
mailing list