Skip to content

Commit 6c11b7e

Browse files
authored
[CodeGen] NFC: Change order of checks in MachineInstr->isDead() (llvm#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 checks.
1 parent a12d7e4 commit 6c11b7e

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

llvm/lib/CodeGen/MachineInstr.cpp

+13-13
Original file line numberDiff line numberDiff line change
@@ -1353,18 +1353,6 @@ bool MachineInstr::wouldBeTriviallyDead() const {
13531353

13541354
bool MachineInstr::isDead(const MachineRegisterInfo &MRI,
13551355
LiveRegUnits *LivePhysRegs) const {
1356-
// Technically speaking inline asm without side effects and no defs can still
1357-
// be deleted. But there is so much bad inline asm code out there, we should
1358-
// let them be.
1359-
if (isInlineAsm())
1360-
return false;
1361-
1362-
// If we suspect this instruction may have some side-effects, then we say
1363-
// this instruction cannot be dead.
1364-
// FIXME: See issue #105950 for why LIFETIME markers are considered dead here.
1365-
if (!isLifetimeMarker() && !wouldBeTriviallyDead())
1366-
return false;
1367-
13681356
// Instructions without side-effects are dead iff they only define dead regs.
13691357
// This function is hot and this loop returns early in the common case,
13701358
// so only perform additional checks before this if absolutely necessary.
@@ -1385,7 +1373,19 @@ bool MachineInstr::isDead(const MachineRegisterInfo &MRI,
13851373
}
13861374
}
13871375

1388-
return true;
1376+
// Technically speaking inline asm without side effects and no defs can still
1377+
// be deleted. But there is so much bad inline asm code out there, we should
1378+
// let them be.
1379+
if (isInlineAsm())
1380+
return false;
1381+
1382+
// FIXME: See issue #105950 for why LIFETIME markers are considered dead here.
1383+
if (isLifetimeMarker())
1384+
return true;
1385+
1386+
// If there are no defs with uses, then we call the instruction dead so long
1387+
// as we do not suspect it may have sideeffects.
1388+
return wouldBeTriviallyDead();
13891389
}
13901390

13911391
static bool MemOperandsHaveAlias(const MachineFrameInfo &MFI,

0 commit comments

Comments
 (0)