[llvm-commits] [llvm] r136832 - in /llvm/trunk/lib/CodeGen: RegAllocGreedy.cpp SpillPlacement.cpp SpillPlacement.h

Jakob Stoklund Olesen stoklund at 2pi.dk
Wed Aug 3 16:09:39 PDT 2011


Author: stoklund
Date: Wed Aug  3 18:09:38 2011
New Revision: 136832

URL: http://llvm.org/viewvc/llvm-project?rev=136832&view=rev
Log:
Be more conservative when forming compact regions.

Apply twice the negative bias on transparent blocks when computing the
compact regions. This excludes loop backedges from the region when only
one of the loop blocks uses the register.

Previously, we would include the backedge in the region if the loop
preheader and the loop latch both used the register, but the loop header
didn't.

When both the header and latch blocks use the register, we still keep it
live on the backedge.

Modified:
    llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp
    llvm/trunk/lib/CodeGen/SpillPlacement.cpp
    llvm/trunk/lib/CodeGen/SpillPlacement.h

Modified: llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp?rev=136832&r1=136831&r2=136832&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp (original)
+++ llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp Wed Aug  3 18:09:38 2011
@@ -806,7 +806,9 @@
     if (Cand.PhysReg)
       addThroughConstraints(Cand.Intf, NewBlocks);
     else
-      SpillPlacer->addPrefSpill(NewBlocks);
+      // Provide a strong negative bias on through blocks to prevent unwanted
+      // liveness on loop backedges.
+      SpillPlacer->addPrefSpill(NewBlocks, /* Strong= */ true);
     AddedTo = ActiveBlocks.size();
 
     // Perhaps iterating can enable more bundles?

Modified: llvm/trunk/lib/CodeGen/SpillPlacement.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SpillPlacement.cpp?rev=136832&r1=136831&r2=136832&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SpillPlacement.cpp (original)
+++ llvm/trunk/lib/CodeGen/SpillPlacement.cpp Wed Aug  3 18:09:38 2011
@@ -241,10 +241,12 @@
 }
 
 /// addPrefSpill - Same as addConstraints(PrefSpill)
-void SpillPlacement::addPrefSpill(ArrayRef<unsigned> Blocks) {
+void SpillPlacement::addPrefSpill(ArrayRef<unsigned> Blocks, bool Strong) {
   for (ArrayRef<unsigned>::iterator I = Blocks.begin(), E = Blocks.end();
        I != E; ++I) {
     float Freq = getBlockFrequency(*I);
+    if (Strong)
+      Freq += Freq;
     unsigned ib = bundles->getBundle(*I, 0);
     unsigned ob = bundles->getBundle(*I, 1);
     activate(ib);

Modified: llvm/trunk/lib/CodeGen/SpillPlacement.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SpillPlacement.h?rev=136832&r1=136831&r2=136832&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SpillPlacement.h (original)
+++ llvm/trunk/lib/CodeGen/SpillPlacement.h Wed Aug  3 18:09:38 2011
@@ -107,7 +107,8 @@
   /// Entry = Exit = PrefSpill, and ChangesValue = false.
   ///
   /// @param Blocks Array of block numbers that prefer to spill in and out.
-  void addPrefSpill(ArrayRef<unsigned> Blocks);
+  /// @param Strong When true, double the negative bias for these blocks.
+  void addPrefSpill(ArrayRef<unsigned> Blocks, bool Strong);
 
   /// addLinks - Add transparent blocks with the given numbers.
   void addLinks(ArrayRef<unsigned> Links);





More information about the llvm-commits mailing list