[PATCH] RegAllocGreedy: Improve live interval order in ReverseLocal mode

Matthias Braun matze at braunis.de
Wed Mar 25 20:10:18 PDT 2015


- RegAllocGreedy: Allow target to specify register class ordering.


http://reviews.llvm.org/D8625

Files:
  include/llvm/Target/TargetRegisterInfo.h
  lib/CodeGen/RegAllocGreedy.cpp

Index: include/llvm/Target/TargetRegisterInfo.h
===================================================================
--- include/llvm/Target/TargetRegisterInfo.h
+++ include/llvm/Target/TargetRegisterInfo.h
@@ -713,6 +713,14 @@
   /// (3) Bottom-up allocation is no longer guaranteed to optimally color.
   virtual bool reverseLocalAssignment() const { return false; }
 
+  /// Allow the target to define an ordering for its register classes. This is
+  /// used in the greedy register allocator heuristic, it is often beneficial to
+  /// color "big" (each register aliases 2 or more registers of a smaller
+  /// register class) or very constrained classes first.
+  virtual uint8_t getClassPriority(const TargetRegisterClass *cls) const {
+    return 0;
+  }
+
   /// Allow the target to override the cost of using a callee-saved register for
   /// the first time. Default value of 0 means we will use a callee-saved
   /// register if it is available.
Index: lib/CodeGen/RegAllocGreedy.cpp
===================================================================
--- lib/CodeGen/RegAllocGreedy.cpp
+++ lib/CodeGen/RegAllocGreedy.cpp
@@ -552,8 +552,9 @@
         // Allocating bottom up may allow many short LRGs to be assigned first
         // to one of the cheap registers. This could be much faster for very
         // large blocks on targets with many physical registers.
-        Prio = Indexes->getZeroIndex().getInstrDistance(LI->beginIndex());
+        Prio = Indexes->getZeroIndex().getInstrDistance(LI->endIndex());
       }
+      Prio |= TRI->getClassPriority(MRI->getRegClass(Reg)) << 24;
     }
     else {
       // Allocate global and split ranges in long->short order. Long ranges that

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8625.22696.patch
Type: text/x-patch
Size: 1703 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150326/3315f566/attachment.bin>


More information about the llvm-commits mailing list