[PATCH] Speed up creation of live ranges for physical registers by using a segment set

Vaidas Gasiunas vaidas.gasiunas at sap.com
Thu Nov 13 00:58:12 PST 2014


================
Comment at: include/llvm/CodeGen/LiveIntervalAnalysis.h:386
@@ -385,1 +385,3 @@
+        // use segment set to speed-up initial computation of the live range
+        LR->createSegmentSet();
         computeRegUnitRange(*LR, Unit);
----------------
Gerolf wrote:
> Since the focus is on speeding up computeRegUnitRange() is seems cleaner to handle both the segment set allocation and flushing locally within that function. This will also remove the asymmetry in your code where some calls are enclosed by createSegment() + flush(), while for others (ok, I only see one more) creation and flush are separate.
The problem is that LiveIntervals::computeLiveInRegUnits calls createDeadDef before calling computeRegUnitRange.

================
Comment at: lib/CodeGen/LiveInterval.cpp:55
@@ -54,1 +54,3 @@
   assert(!Def.isDead() && "Cannot define a value at the dead slot");
+
+  // if segmentSet exists use it instead of the vector
----------------
Gerolf wrote:
> This is for the createDeadDef() call in computeRegUnitRange() only, right? Why not replace the call there directly with the call to the segmentSet function and remove this check?
Yes, I think it should work. That would simplify a bit.

================
Comment at: lib/CodeGen/LiveInterval.cpp:606
@@ +605,3 @@
+// analogous to find, but works with segment set instead of segment vector
+LiveRange::SegmentSet::iterator LiveRange::segsetFind(SlotIndex Pos) {
+  SegmentSet::iterator I = segmentSet->upper_bound(Segment(Pos, Pos.getNextSlot(), NULL));
----------------
Gerolf wrote:
> I guess you could have templates for some of the segment set/segment utility routines if you wanted to push your design a bit. That would take care of some of the static code bloat.
Yes, templates is the only thing that comes to my mind for reduction of code repetition. Other techniques like object-oriented abstraction would be probably too heavyweight, because it is performance critical code. The problem with templates is however that they would introduce quite some additional complexity. I think I will need some helper classes for template instantiation. I will think about it.

================
Comment at: lib/CodeGen/LiveInterval.cpp:945
@@ -725,1 +944,3 @@
 
+  // fall back to the regular add method if the live range
+  // is using the segment set instead of the segment vector
----------------
Gerolf wrote:
> Hm. This looks like more changes than just adding a new data structure to handle live ranges calcs more efficiently. The existing updater checks for coalescing and spilling, while addSegment() does not. Please add a more detailed comment about the differences. Up until this point I was optimistic that the implementation could be cleaned up quite a bit, but now I'm not so sure anymore.
Are these coalescing and spilling checks also relevant for the LiveIntervals phase? Because in other cases, the segmentSet is not used.

http://reviews.llvm.org/D6013






More information about the llvm-commits mailing list