[PATCH] D52370: [MachineCopyPropagation] Rework how we manage RegMask clobbers
Justin Bogner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 21 11:03:48 PDT 2018
bogner created this revision.
bogner added a reviewer: MatzeB.
Herald added subscribers: llvm-commits, mcrosier.
Instead of updating the CopyTracker's maps each time we come across a
RegMask, defer checking for this kind of interference until we're
actually trying to propagate a copy. This avoids the need to
repeatedly iterate over maps in the cases where we don't end up doing
any work.
This is a slight compile time improvement for MachineCopyPropagation
as is, but it also enables a much bigger improvement that I'll follow
up with soon.
Repository:
rL LLVM
https://reviews.llvm.org/D52370
Files:
lib/CodeGen/MachineCopyPropagation.cpp
Index: lib/CodeGen/MachineCopyPropagation.cpp
===================================================================
--- lib/CodeGen/MachineCopyPropagation.cpp
+++ lib/CodeGen/MachineCopyPropagation.cpp
@@ -99,33 +99,6 @@
}
}
- /// Remove any entry in the tracker's copy maps that is marked clobbered in \p
- /// RegMask. The map will typically have a lot fewer entries than the regmask
- /// clobbers, so this is more efficient than iterating the clobbered registers
- /// and calling ClobberRegister() on them.
- void removeClobberedRegs(const MachineOperand &RegMask,
- const TargetRegisterInfo &TRI) {
- auto RemoveFromMap = [&RegMask](Reg2MIMap &Map) {
- for (Reg2MIMap::iterator I = Map.begin(), E = Map.end(), Next; I != E;
- I = Next) {
- Next = std::next(I);
- if (RegMask.clobbersPhysReg(I->first))
- Map.erase(I);
- }
- };
- RemoveFromMap(AvailCopyMap);
- RemoveFromMap(CopyMap);
-
- for (SourceMap::iterator I = SrcMap.begin(), E = SrcMap.end(), Next; I != E;
- I = Next) {
- Next = std::next(I);
- if (RegMask.clobbersPhysReg(I->first)) {
- markRegsUnavailable(I->second, TRI);
- SrcMap.erase(I);
- }
- }
- }
-
/// Clobber a single register, removing it from the tracker's copy maps.
void clobberRegister(unsigned Reg, const TargetRegisterInfo &TRI) {
for (MCRegAliasIterator AI(Reg, &TRI, true); AI.isValid(); ++AI) {
@@ -287,6 +260,19 @@
if (!isNopCopy(*PrevCopy, Src, Def, TRI))
return false;
+ for (auto I = PrevCopy->getIterator(), E = Copy.getIterator(); I != E; ++I) {
+ const MachineOperand *RegMask = nullptr;
+ for (const MachineOperand &MO : I->operands())
+ if (MO.isRegMask()) {
+ RegMask = &MO;
+ break;
+ }
+ if (!RegMask)
+ continue;
+ if (RegMask->clobbersPhysReg(Src) || RegMask->clobbersPhysReg(Def))
+ return false;
+ }
+
LLVM_DEBUG(dbgs() << "MCP: copy is a NOP, removing: "; Copy.dump());
// Copy was redundantly redefining either Src or Def. Remove earlier kill
@@ -593,8 +579,6 @@
Changed = true;
++NumDeletes;
}
-
- Tracker.removeClobberedRegs(*RegMask, *TRI);
}
// Any previous copy definition or reading the Defs is no longer available.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52370.166516.patch
Type: text/x-patch
Size: 2333 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180921/2f90f76e/attachment.bin>
More information about the llvm-commits
mailing list