[PATCH] D119940: [CodeGen] Return better Changed status from DetectDeadLanes
Jay Foad via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 16 07:44:09 PST 2022
foad created this revision.
foad added reviewers: serge-sans-paille, piotr.
Herald added a subscriber: hiraditya.
foad requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D119940
Files:
llvm/lib/CodeGen/DetectDeadLanes.cpp
Index: llvm/lib/CodeGen/DetectDeadLanes.cpp
===================================================================
--- llvm/lib/CodeGen/DetectDeadLanes.cpp
+++ llvm/lib/CodeGen/DetectDeadLanes.cpp
@@ -93,7 +93,7 @@
LaneBitmask transferUsedLanes(const MachineInstr &MI, LaneBitmask UsedLanes,
const MachineOperand &MO) const;
- bool runOnce(MachineFunction &MF);
+ std::pair<bool, bool> runOnce(MachineFunction &MF);
LaneBitmask determineInitialDefinedLanes(unsigned Reg);
LaneBitmask determineInitialUsedLanes(unsigned Reg);
@@ -487,7 +487,7 @@
return true;
}
-bool DetectDeadLanes::runOnce(MachineFunction &MF) {
+std::pair<bool, bool> DetectDeadLanes::runOnce(MachineFunction &MF) {
// First pass: Populate defs/uses of vregs with initial values
unsigned NumVirtRegs = MRI->getNumVirtRegs();
for (unsigned RegIdx = 0; RegIdx < NumVirtRegs; ++RegIdx) {
@@ -528,6 +528,7 @@
dbgs() << "\n";
});
+ bool Changed = false;
bool Again = false;
// Mark operands as dead/unused.
for (MachineBasicBlock &MBB : MF) {
@@ -544,6 +545,7 @@
LLVM_DEBUG(dbgs()
<< "Marking operand '" << MO << "' as dead in " << MI);
MO.setIsDead();
+ Changed = true;
}
if (MO.readsReg()) {
bool CrossCopy = false;
@@ -551,10 +553,12 @@
LLVM_DEBUG(dbgs()
<< "Marking operand '" << MO << "' as undef in " << MI);
MO.setIsUndef();
+ Changed = true;
} else if (isUndefInput(MO, &CrossCopy)) {
LLVM_DEBUG(dbgs()
<< "Marking operand '" << MO << "' as undef in " << MI);
MO.setIsUndef();
+ Changed = true;
if (CrossCopy)
Again = true;
}
@@ -563,7 +567,7 @@
}
}
- return Again;
+ return std::make_pair(Changed, Again);
}
bool DetectDeadLanes::runOnMachineFunction(MachineFunction &MF) {
@@ -585,13 +589,16 @@
WorklistMembers.resize(NumVirtRegs);
DefinedByCopy.resize(NumVirtRegs);
+ bool Changed = false;
bool Again;
do {
- Again = runOnce(MF);
+ bool LocalChanged;
+ std::tie(LocalChanged, Again) = runOnce(MF);
+ Changed |= LocalChanged;
} while(Again);
DefinedByCopy.clear();
WorklistMembers.clear();
delete[] VRegInfos;
- return true;
+ return Changed;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119940.409255.patch
Type: text/x-patch
Size: 2413 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220216/dee2ff6e/attachment.bin>
More information about the llvm-commits
mailing list