More tweaks to improve compile time.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41669 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Evan Cheng 2007-09-01 02:03:17 +00:00
parent 4e9c473c4d
commit 343013538f
2 changed files with 56 additions and 41 deletions

View File

@ -288,26 +288,24 @@ LiveInterval::FindLiveRangeContaining(unsigned Idx) {
void LiveInterval::join(LiveInterval &Other, int *LHSValNoAssignments,
int *RHSValNoAssignments,
SmallVector<VNInfo*, 16> &NewVNInfo) {
// There might be some dead val#, create VNInfo for them.
for (unsigned i = 0, e = NewVNInfo.size(); i != e; ++i) {
VNInfo *VNI = NewVNInfo[i];
if (!VNI) {
VNI = new VNInfo(this, i, ~1U, 0);
NewVNInfo[i] = VNI;
}
}
// Determine if any of our live range values are mapped. This is uncommon, so
// we want to avoid the interval scan if not.
// we want to avoid the interval scan if not.
bool MustMapCurValNos = false;
for (vni_iterator i = vni_begin(), e = vni_end(); i != e; ++i) {
VNInfo *VNI = *i;
unsigned VN = VNI->id;
if (VNI->def == ~1U) continue; // tombstone value #
if (VNI != NewVNInfo[LHSValNoAssignments[VN]]) {
unsigned NumVals = getNumValNums();
unsigned NumNewVals = NewVNInfo.size();
for (unsigned i = 0; i != NumVals; ++i) {
unsigned LHSValID = LHSValNoAssignments[i];
if (i != LHSValID ||
(NewVNInfo[LHSValID] && NewVNInfo[LHSValID]->parent != this))
MustMapCurValNos = true;
break;
// There might be some dead val#, create VNInfo for them.
if (i < NumNewVals) {
VNInfo *VNI = NewVNInfo[i];
if (!VNI) {
VNI = new VNInfo(this, i, ~1U, 0);
NewVNInfo[i] = VNI;
}
}
}
@ -342,19 +340,34 @@ void LiveInterval::join(LiveInterval &Other, int *LHSValNoAssignments,
}
// Remember assignements because val# ids are changing.
std::vector<unsigned> OtherAssignments;
SmallVector<unsigned, 16> OtherAssignments;
for (iterator I = Other.begin(), E = Other.end(); I != E; ++I)
OtherAssignments.push_back(RHSValNoAssignments[I->valno->id]);
// Update val# info. Renumber them and make sure they all belong to this
// LiveInterval now.
valnos.clear();
for (unsigned i = 0, e = NewVNInfo.size(); i != e; ++i) {
for (unsigned i = 0; i != NumVals; ++i) {
if (i == NumNewVals)
break;
VNInfo *VNI = NewVNInfo[i];
VNI->parent = this;
VNI->id = i; // Renumber val#.
if (VNI->parent != this || VNI->id != i) {
VNI->parent = this;
VNI->id = i; // Renumber val#.
valnos[i] = VNI;
}
}
for (unsigned i = NumVals; i < NumNewVals; ++i) {
VNInfo *VNI = NewVNInfo[i];
if (!VNI)
VNI = new VNInfo(this, i, ~1U, 0);
else {
VNI->parent = this;
VNI->id = i; // Renumber val#.
}
valnos.push_back(VNI);
}
if (NumNewVals < NumVals)
valnos.resize(NumNewVals); // shrinkify
// Okay, now insert the RHS live ranges into the LHS.
iterator InsertPos = begin();

View File

@ -682,8 +682,9 @@ bool SimpleRegisterCoalescing::JoinIntervals(LiveInterval &LHS,
assert(RHSValID != -1 && "Didn't find value #?");
RHSValNoAssignments[0] = RHSValID;
if (RHSVal0DefinedFromLHS != -1) {
RHSValsDefinedFromLHS[RHSValNoInfo0] =
LHS.getLiveRangeContaining(RHSValNoInfo0->def-1)->valno;
// This path doesn't go through ComputeUltimateVN so just set
// it to anything.
RHSValsDefinedFromLHS[RHSValNoInfo0] = (VNInfo*)1;
}
} else {
// Loop over the value numbers of the LHS, seeing if any are defined from
@ -798,31 +799,32 @@ bool SimpleRegisterCoalescing::JoinIntervals(LiveInterval &LHS,
}
}
// Update kill info. Some live ranges are extended due to copy coalescing.
for (DenseMap<VNInfo*, VNInfo*>::iterator I = RHSValsDefinedFromLHS.begin(),
E = RHSValsDefinedFromLHS.end(); I != E; ++I) {
VNInfo *VNI = I->first;
unsigned RHSValID = RHSValNoAssignments[VNI->id];
LiveInterval::removeKill(*NewVNInfo[RHSValID], VNI->def);
LHS.addKills(*NewVNInfo[RHSValID], VNI->kills);
}
for (DenseMap<VNInfo*, VNInfo*>::iterator I = LHSValsDefinedFromRHS.begin(),
E = LHSValsDefinedFromRHS.end(); I != E; ++I) {
VNInfo *VNI = I->first;
unsigned LHSValID = LHSValNoAssignments[VNI->id];
LiveInterval::removeKill(*NewVNInfo[LHSValID], VNI->def);
RHS.addKills(*NewVNInfo[LHSValID], VNI->kills);
}
// If we get here, we know that we can coalesce the live ranges. Ask the
// intervals to coalesce themselves now.
if ((RHS.ranges.size() > LHS.ranges.size() &&
MRegisterInfo::isVirtualRegister(LHS.reg)) ||
MRegisterInfo::isPhysicalRegister(RHS.reg)) {
// Update kill info. Some live ranges are extended due to copy coalescing.
for (DenseMap<VNInfo*, VNInfo*>::iterator I = LHSValsDefinedFromRHS.begin(),
E = LHSValsDefinedFromRHS.end(); I != E; ++I) {
VNInfo *VNI = I->first;
unsigned LHSValID = LHSValNoAssignments[VNI->id];
LiveInterval::removeKill(*NewVNInfo[LHSValID], VNI->def);
RHS.addKills(*NewVNInfo[LHSValID], VNI->kills);
}
RHS.join(LHS, &RHSValNoAssignments[0], &LHSValNoAssignments[0], NewVNInfo);
Swapped = true;
} else {
// Update kill info. Some live ranges are extended due to copy coalescing.
for (DenseMap<VNInfo*, VNInfo*>::iterator I = RHSValsDefinedFromLHS.begin(),
E = RHSValsDefinedFromLHS.end(); I != E; ++I) {
VNInfo *VNI = I->first;
unsigned RHSValID = RHSValNoAssignments[VNI->id];
LiveInterval::removeKill(*NewVNInfo[RHSValID], VNI->def);
LHS.addKills(*NewVNInfo[RHSValID], VNI->kills);
}
LHS.join(RHS, &LHSValNoAssignments[0], &RHSValNoAssignments[0], NewVNInfo);
Swapped = false;
}