From c7934b3e37bbe353579987407c7cd7b5f4d38787 Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Tue, 30 Jul 2013 19:59:19 +0000 Subject: [PATCH] Down-scale slot index distance to save bits. llvm-svn: 187438 --- llvm/include/llvm/CodeGen/SlotIndexes.h | 7 +++++++ llvm/lib/CodeGen/RegAllocGreedy.cpp | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/llvm/include/llvm/CodeGen/SlotIndexes.h b/llvm/include/llvm/CodeGen/SlotIndexes.h index 1c7bdb2..984796a 100644 --- a/llvm/include/llvm/CodeGen/SlotIndexes.h +++ b/llvm/include/llvm/CodeGen/SlotIndexes.h @@ -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; } diff --git a/llvm/lib/CodeGen/RegAllocGreedy.cpp b/llvm/lib/CodeGen/RegAllocGreedy.cpp index 87b11a5..f9e363b 100644 --- a/llvm/lib/CodeGen/RegAllocGreedy.cpp +++ b/llvm/lib/CodeGen/RegAllocGreedy.cpp @@ -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 -- 2.7.4