[llvm-commits] [llvm] r103940 - /llvm/trunk/lib/CodeGen/RegAllocFast.cpp
Jakob Stoklund Olesen
stoklund at 2pi.dk
Mon May 17 08:30:37 PDT 2010
Author: stoklund
Date: Mon May 17 10:30:37 2010
New Revision: 103940
URL: http://llvm.org/viewvc/llvm-project?rev=103940&view=rev
Log:
Minor optimizations. DenseMap::begin() is surprisingly slow on an empty map.
Modified:
llvm/trunk/lib/CodeGen/RegAllocFast.cpp
Modified: llvm/trunk/lib/CodeGen/RegAllocFast.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocFast.cpp?rev=103940&r1=103939&r2=103940&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/RegAllocFast.cpp (original)
+++ llvm/trunk/lib/CodeGen/RegAllocFast.cpp Mon May 17 10:30:37 2010
@@ -267,6 +267,7 @@
/// 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 @@
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);
}
More information about the llvm-commits
mailing list