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 | f3ea06b108d45c53dade87d6f1f48ac0a0e20562 (patch) | |
tree | f1de0091bec6bbd01a4cf92f1db9c0f496abc8f5 /lib/CodeGen | |
parent | 548643c573d53950e28e9e810cd0454ba9a21af0 (diff) |
Minor optimizations. DenseMap::begin() is surprisingly slow on an empty map.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103940 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/RegAllocFast.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/CodeGen/RegAllocFast.cpp b/lib/CodeGen/RegAllocFast.cpp index 70c1c1e3e6..ea3fa61c89 100644 --- a/lib/CodeGen/RegAllocFast.cpp +++ b/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); } |