mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-21 12:38:45 +00:00
Use a smallvector for inactiveCounts and initialize it lazily
instead of init'ing it maximally to zeros on entry. getFreePhysReg is pretty hot and only a few elements are typically used. This speeds up linscan by 5% on 176.gcc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47631 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e6d088acc9
commit
fe42462164
@ -839,7 +839,7 @@ void RALinScan::assignRegOrStackSlotAtInterval(LiveInterval* cur)
|
|||||||
/// getFreePhysReg - return a free physical register for this virtual register
|
/// getFreePhysReg - return a free physical register for this virtual register
|
||||||
/// interval if we have one, otherwise return 0.
|
/// interval if we have one, otherwise return 0.
|
||||||
unsigned RALinScan::getFreePhysReg(LiveInterval *cur) {
|
unsigned RALinScan::getFreePhysReg(LiveInterval *cur) {
|
||||||
std::vector<unsigned> inactiveCounts(tri_->getNumRegs(), 0);
|
SmallVector<unsigned, 256> inactiveCounts;
|
||||||
unsigned MaxInactiveCount = 0;
|
unsigned MaxInactiveCount = 0;
|
||||||
|
|
||||||
const TargetRegisterClass *RC = reginfo_->getRegClass(cur->reg);
|
const TargetRegisterClass *RC = reginfo_->getRegClass(cur->reg);
|
||||||
@ -856,6 +856,8 @@ unsigned RALinScan::getFreePhysReg(LiveInterval *cur) {
|
|||||||
const TargetRegisterClass *RegRC = reginfo_->getRegClass(reg);
|
const TargetRegisterClass *RegRC = reginfo_->getRegClass(reg);
|
||||||
if (RelatedRegClasses.getLeaderValue(RegRC) == RCLeader) {
|
if (RelatedRegClasses.getLeaderValue(RegRC) == RCLeader) {
|
||||||
reg = vrm_->getPhys(reg);
|
reg = vrm_->getPhys(reg);
|
||||||
|
if (inactiveCounts.size() <= reg)
|
||||||
|
inactiveCounts.resize(reg+1);
|
||||||
++inactiveCounts[reg];
|
++inactiveCounts[reg];
|
||||||
MaxInactiveCount = std::max(MaxInactiveCount, inactiveCounts[reg]);
|
MaxInactiveCount = std::max(MaxInactiveCount, inactiveCounts[reg]);
|
||||||
}
|
}
|
||||||
@ -882,7 +884,10 @@ unsigned RALinScan::getFreePhysReg(LiveInterval *cur) {
|
|||||||
for (; I != E; ++I)
|
for (; I != E; ++I)
|
||||||
if (prt_->isRegAvail(*I)) {
|
if (prt_->isRegAvail(*I)) {
|
||||||
FreeReg = *I;
|
FreeReg = *I;
|
||||||
|
if (FreeReg < inactiveCounts.size())
|
||||||
FreeRegInactiveCount = inactiveCounts[FreeReg];
|
FreeRegInactiveCount = inactiveCounts[FreeReg];
|
||||||
|
else
|
||||||
|
FreeRegInactiveCount = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -896,7 +901,8 @@ unsigned RALinScan::getFreePhysReg(LiveInterval *cur) {
|
|||||||
// reevaluated now.
|
// reevaluated now.
|
||||||
for (; I != E; ++I) {
|
for (; I != E; ++I) {
|
||||||
unsigned Reg = *I;
|
unsigned Reg = *I;
|
||||||
if (prt_->isRegAvail(Reg) && FreeRegInactiveCount < inactiveCounts[Reg]) {
|
if (prt_->isRegAvail(Reg) && Reg < inactiveCounts.size() &&
|
||||||
|
FreeRegInactiveCount < inactiveCounts[Reg]) {
|
||||||
FreeReg = Reg;
|
FreeReg = Reg;
|
||||||
FreeRegInactiveCount = inactiveCounts[Reg];
|
FreeRegInactiveCount = inactiveCounts[Reg];
|
||||||
if (FreeRegInactiveCount == MaxInactiveCount)
|
if (FreeRegInactiveCount == MaxInactiveCount)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user