Down-scale slot index distance to save bits.
authorAndrew Trick <atrick@apple.com>
Tue, 30 Jul 2013 19:59:19 +0000 (19:59 +0000)
committerAndrew Trick <atrick@apple.com>
Tue, 30 Jul 2013 19:59:19 +0000 (19:59 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187438 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/SlotIndexes.h
lib/CodeGen/RegAllocGreedy.cpp

index 1c7bdb2e586cc8e684f82d47bdfcb2c4b44bd217..984796af8644e6a77c93b526bc85d7718fe59c7b 100644 (file)
@@ -218,6 +218,13 @@ namespace llvm {
       return other.getIndex() - getIndex();
     }
 
+    /// Return the scaled distance from this index to the given one, where all
+    /// slots on the same instruction have zero distance.
+    int getInstrDistance(SlotIndex other) const {
+      return (other.listEntry()->getIndex() - listEntry()->getIndex())
+        / Slot_Count;
+    }
+
     /// isBlock - Returns true if this is a block boundary slot.
     bool isBlock() const { return getSlot() == Slot_Block; }
 
index 87b11a5f51c0691e05f73b5fa08dbfc3011bd755..f9e363b9f3acad6e1f60af4729ad96efecae01cd 100644 (file)
@@ -419,7 +419,7 @@ void RAGreedy::enqueue(LiveInterval *LI) {
       // Allocate original local ranges in linear instruction order. Since they
       // are singly defined, this produces optimal coloring in the absence of
       // global interference and other constraints.
-      Prio = LI->beginIndex().distance(Indexes->getLastIndex());
+      Prio = LI->beginIndex().getInstrDistance(Indexes->getLastIndex());
     }
     else {
       // Allocate global and split ranges in long->short order. Long ranges that