@@ -444,31 +444,27 @@ MCRegister RAGreedy::tryAssign(const LiveInterval &VirtReg,
444
444
// Interference eviction
445
445
// ===----------------------------------------------------------------------===//
446
446
447
- Register RegAllocEvictionAdvisor::canReassign (const LiveInterval &VirtReg,
448
- Register PrevReg) const {
449
- auto Order =
450
- AllocationOrder::create (VirtReg.reg (), *VRM, RegClassInfo, Matrix);
451
- MCRegister PhysReg;
452
- for (auto I = Order.begin (), E = Order.end (); I != E && !PhysReg; ++I) {
453
- if ((*I).id () == PrevReg.id ())
454
- continue ;
447
+ bool RegAllocEvictionAdvisor::canReassign (const LiveInterval &VirtReg,
448
+ MCRegister FromReg) const {
449
+ auto HasRegUnitInterference = [&](MCRegUnit Unit) {
450
+ // Instantiate a "subquery", not to be confused with the Queries array.
451
+ LiveIntervalUnion::Query SubQ (VirtReg, Matrix->getLiveUnions ()[Unit]);
452
+ return SubQ.checkInterference ();
453
+ };
455
454
456
- MCRegUnitIterator Units (*I, TRI);
457
- for (; Units.isValid (); ++Units) {
458
- // Instantiate a "subquery", not to be confused with the Queries array.
459
- LiveIntervalUnion::Query subQ (VirtReg, Matrix->getLiveUnions ()[*Units]);
460
- if (subQ.checkInterference ())
461
- break ;
455
+ for (MCRegister Reg :
456
+ AllocationOrder::create (VirtReg.reg (), *VRM, RegClassInfo, Matrix)) {
457
+ if (Reg == FromReg)
458
+ continue ;
459
+ // If no units have interference, reassignment is possible.
460
+ if (none_of (TRI->regunits (Reg), HasRegUnitInterference)) {
461
+ LLVM_DEBUG (dbgs () << " can reassign: " << VirtReg << " from "
462
+ << printReg (FromReg, TRI) << " to "
463
+ << printReg (Reg, TRI) << ' \n ' );
464
+ return true ;
462
465
}
463
- // If no units have interference, break out with the current PhysReg.
464
- if (!Units.isValid ())
465
- PhysReg = *I;
466
466
}
467
- if (PhysReg)
468
- LLVM_DEBUG (dbgs () << " can reassign: " << VirtReg << " from "
469
- << printReg (PrevReg, TRI) << " to "
470
- << printReg (PhysReg, TRI) << ' \n ' );
471
- return PhysReg;
467
+ return false ;
472
468
}
473
469
474
470
// / evictInterference - Evict any interferring registers that prevent VirtReg
0 commit comments