diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2010-05-17 15:30:37 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2010-05-17 15:30:37 +0000 |
commit | f5e8c86424333a7ccbf71c2b25ef3b85749bf358 (patch) | |
tree | 3526f0fc722db80660c8ea80d7c557ee790e0bbe /llvm/lib/CodeGen/RegAllocFast.cpp | |
parent | 6649cdaa237839afaa77a3ef43321b3b8db8be28 (diff) | |
download | bcm5719-llvm-f5e8c86424333a7ccbf71c2b25ef3b85749bf358.tar.gz bcm5719-llvm-f5e8c86424333a7ccbf71c2b25ef3b85749bf358.zip |
Minor optimizations. DenseMap::begin() is surprisingly slow on an empty map.
llvm-svn: 103940
Diffstat (limited to 'llvm/lib/CodeGen/RegAllocFast.cpp')
-rw-r--r-- | llvm/lib/CodeGen/RegAllocFast.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/llvm/lib/CodeGen/RegAllocFast.cpp b/llvm/lib/CodeGen/RegAllocFast.cpp index 70c1c1e3e68..ea3fa61c890 100644 --- a/llvm/lib/CodeGen/RegAllocFast.cpp +++ b/llvm/lib/CodeGen/RegAllocFast.cpp @@ -267,6 +267,7 @@ void RAFast::spillVirtReg(MachineBasicBlock::iterator MI, /// spillAll - Spill all dirty virtregs without killing them. void RAFast::spillAll(MachineInstr *MI) { + if (LiveVirtRegs.empty()) return; isBulkSpilling = true; for (LiveRegMap::iterator i = LiveVirtRegs.begin(), e = LiveVirtRegs.end(); i != e; ++i) @@ -471,17 +472,15 @@ void RAFast::allocVirtReg(MachineInstr *MI, LiveRegEntry &LRE, unsigned Hint) { unsigned BestReg = 0, BestCost = spillImpossible; for (TargetRegisterClass::iterator I = AOB; I != AOE; ++I) { unsigned Cost = calcSpillCost(*I); - if (Cost < BestCost) { - BestReg = *I; - BestCost = Cost; - if (Cost == 0) break; - } + // Cost is 0 when all aliases are already disabled. + if (Cost == 0) + return assignVirtToPhysReg(LRE, *I); + if (Cost < BestCost) + BestReg = *I, BestCost = Cost; } if (BestReg) { - // BestCost is 0 when all aliases are already disabled. - if (BestCost) - definePhysReg(MI, BestReg, regFree); + definePhysReg(MI, BestReg, regFree); return assignVirtToPhysReg(LRE, BestReg); } |