From c2e35a6f3258d102b731c77de9530714c4d02802 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Tue, 19 Mar 2019 19:01:34 +0000 Subject: RegAllocFast: Remove early selection loop, the spill calculation will report cost 0 anyway for free regs The 2nd loop calculates spill costs but reports free registers as cost 0 anyway, so there is little benefit from having a separate early loop. Surprisingly this is not NFC, as many register are marked regDisabled so the first loop often picks up later registers unnecessarily instead of the first one available in the allocation order... Patch by Matthias Braun llvm-svn: 356499 --- llvm/lib/CodeGen/RegAllocFast.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'llvm/lib/CodeGen/RegAllocFast.cpp') diff --git a/llvm/lib/CodeGen/RegAllocFast.cpp b/llvm/lib/CodeGen/RegAllocFast.cpp index d3e52f92f45..46620d8fa4d 100644 --- a/llvm/lib/CodeGen/RegAllocFast.cpp +++ b/llvm/lib/CodeGen/RegAllocFast.cpp @@ -582,17 +582,9 @@ void RegAllocFast::allocVirtReg(MachineInstr &MI, LiveReg &LR, unsigned Hint) { } } - // First try to find a completely free register. - ArrayRef AllocationOrder = RegClassInfo.getOrder(&RC); - for (MCPhysReg PhysReg : AllocationOrder) { - if (PhysRegState[PhysReg] == regFree && !isRegUsedInInstr(PhysReg)) { - assignVirtToPhysReg(LR, PhysReg); - return; - } - } - MCPhysReg BestReg = 0; unsigned BestCost = spillImpossible; + ArrayRef AllocationOrder = RegClassInfo.getOrder(&RC); for (MCPhysReg PhysReg : AllocationOrder) { LLVM_DEBUG(dbgs() << "\tRegister: " << printReg(PhysReg, TRI) << ' '); unsigned Cost = calcSpillCost(PhysReg); -- cgit v1.2.3