Commit df861f73 by Jim Stichnoth

Subzero: Optimize a common live range overlap calculation.

Call instruction lowering includes the FakeKill instruction, which creates several precolored variables, one for each scratch register. The live range for each of these variables consists of a set of "point" ranges, one point for every FakeKill instruction. The overlaps() logic is such that a point range never overlaps with an individual instruction, but it can overlap with a normal non-point range. It turns out that during register allocation, usually most of the variables on the Inactive list are these FakeKill instructions. The live range representation can be quite large if there are many calls in the function. In the "Check for inactive ranges that have expired or reactivated" section, a lot of time was spent on overlapsStart() calls that were doomed to return false. This change lets the live range keep track of whether it contains non-point segments, and if not, optimize the overlaps(InstNumberT) method. BUG= none R=jvoung@chromium.org Review URL: https://codereview.chromium.org/631483002
parent 8bcca041
......@@ -37,6 +37,8 @@ bool operator==(const RegWeight &A, const RegWeight &B) {
}
void LiveRange::addSegment(InstNumberT Start, InstNumberT End) {
if (End > Start)
IsNonpoints = true;
#ifdef USE_SET
RangeElementType Element(Start, End);
RangeType::iterator Next = Range.lower_bound(Element);
......@@ -122,6 +124,8 @@ bool LiveRange::overlaps(const LiveRange &Other) const {
}
bool LiveRange::overlaps(InstNumberT OtherBegin) const {
if (!IsNonpoints)
return false;
bool Result = false;
for (const RangeElementType &I : Range) {
if (OtherBegin < I.first) {
......
......@@ -298,11 +298,12 @@ bool operator==(const RegWeight &A, const RegWeight &B);
// inside a loop.
class LiveRange {
public:
LiveRange() : Weight(0) {}
LiveRange() : Weight(0), IsNonpoints(false) {}
void reset() {
Range.clear();
Weight.setWeight(0);
IsNonpoints = false;
}
void addSegment(InstNumberT Start, InstNumberT End);
......@@ -335,6 +336,11 @@ private:
#endif
RangeType Range;
RegWeight Weight;
// IsNonpoints keeps track of whether the live range contains at
// least one interval where Start!=End. If it is empty or has the
// form [x,x),[y,y),...,[z,z), then overlaps(InstNumberT) is
// trivially false.
bool IsNonpoints;
};
Ostream &operator<<(Ostream &Str, const LiveRange &L);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment