[PATCH] D152665: [RegAlloc] Simplify RegAllocEvictionAdvisor::canReassign (NFC)
Sergei Barannikov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 15 19:40:22 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb70b96c0f5a7: [RegAlloc] Simplify RegAllocEvictionAdvisor::canReassign (NFC) (authored by barannikov88).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D152665/new/
https://reviews.llvm.org/D152665
Files:
llvm/lib/CodeGen/RegAllocEvictionAdvisor.h
llvm/lib/CodeGen/RegAllocGreedy.cpp
Index: llvm/lib/CodeGen/RegAllocGreedy.cpp
===================================================================
--- llvm/lib/CodeGen/RegAllocGreedy.cpp
+++ llvm/lib/CodeGen/RegAllocGreedy.cpp
@@ -444,31 +444,27 @@
// Interference eviction
//===----------------------------------------------------------------------===//
-Register RegAllocEvictionAdvisor::canReassign(const LiveInterval &VirtReg,
- Register PrevReg) const {
- auto Order =
- AllocationOrder::create(VirtReg.reg(), *VRM, RegClassInfo, Matrix);
- MCRegister PhysReg;
- for (auto I = Order.begin(), E = Order.end(); I != E && !PhysReg; ++I) {
- if ((*I).id() == PrevReg.id())
- continue;
+bool RegAllocEvictionAdvisor::canReassign(const LiveInterval &VirtReg,
+ MCRegister FromReg) const {
+ auto HasRegUnitInterference = [&](MCRegUnit Unit) {
+ // Instantiate a "subquery", not to be confused with the Queries array.
+ LiveIntervalUnion::Query SubQ(VirtReg, Matrix->getLiveUnions()[Unit]);
+ return SubQ.checkInterference();
+ };
- MCRegUnitIterator Units(*I, TRI);
- for (; Units.isValid(); ++Units) {
- // Instantiate a "subquery", not to be confused with the Queries array.
- LiveIntervalUnion::Query subQ(VirtReg, Matrix->getLiveUnions()[*Units]);
- if (subQ.checkInterference())
- break;
+ for (MCRegister Reg :
+ AllocationOrder::create(VirtReg.reg(), *VRM, RegClassInfo, Matrix)) {
+ if (Reg == FromReg)
+ continue;
+ // If no units have interference, reassignment is possible.
+ if (none_of(TRI->regunits(Reg), HasRegUnitInterference)) {
+ LLVM_DEBUG(dbgs() << "can reassign: " << VirtReg << " from "
+ << printReg(FromReg, TRI) << " to "
+ << printReg(Reg, TRI) << '\n');
+ return true;
}
- // If no units have interference, break out with the current PhysReg.
- if (!Units.isValid())
- PhysReg = *I;
}
- if (PhysReg)
- LLVM_DEBUG(dbgs() << "can reassign: " << VirtReg << " from "
- << printReg(PrevReg, TRI) << " to "
- << printReg(PhysReg, TRI) << '\n');
- return PhysReg;
+ return false;
}
/// evictInterference - Evict any interferring registers that prevent VirtReg
Index: llvm/lib/CodeGen/RegAllocEvictionAdvisor.h
===================================================================
--- llvm/lib/CodeGen/RegAllocEvictionAdvisor.h
+++ llvm/lib/CodeGen/RegAllocEvictionAdvisor.h
@@ -121,7 +121,7 @@
protected:
RegAllocEvictionAdvisor(const MachineFunction &MF, const RAGreedy &RA);
- Register canReassign(const LiveInterval &VirtReg, Register PrevReg) const;
+ bool canReassign(const LiveInterval &VirtReg, MCRegister FromReg) const;
// Get the upper limit of elements in the given Order we need to analize.
// TODO: is this heuristic, we could consider learning it.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152665.531973.patch
Type: text/x-patch
Size: 2979 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230616/b66b3159/attachment.bin>
More information about the llvm-commits
mailing list