[llvm-commits] [llvm] r52477 - in /llvm/trunk: include/llvm/CodeGen/LiveIntervalAnalysis.h include/llvm/CodeGen/MachineRegisterInfo.h lib/CodeGen/LiveIntervalAnalysis.cpp

Evan Cheng evan.cheng at apple.com
Wed Jun 18 18:16:17 PDT 2008


Author: evancheng
Date: Wed Jun 18 20:16:17 2008
New Revision: 52477

URL: http://llvm.org/viewvc/llvm-project?rev=52477&view=rev
Log:
Minor spiller tweak to unfavor reload into load/store instructions.

Modified:
    llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h
    llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h
    llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp

Modified: llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h?rev=52477&r1=52476&r2=52477&view=diff

==============================================================================
--- llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h (original)
+++ llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h Wed Jun 18 20:16:17 2008
@@ -121,8 +121,12 @@
       return getBaseIndex(index) + InstrSlots::STORE;
     }
 
-    static float getSpillWeight(bool isDef, bool isUse, unsigned loopDepth) {
-      return (isDef + isUse) * powf(10.0F, (float)loopDepth);
+    static float getSpillWeight(bool isDef, bool isUse, bool isMem,
+                                unsigned loopDepth) {
+      float Weight = isDef;
+      if (isUse)
+        Weight += isMem ? 1.2f : 1.0f;
+      return Weight * powf(10.0F, (float)loopDepth);
     }
 
     typedef Reg2IntervalMap::iterator iterator;

Modified: llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h?rev=52477&r1=52476&r2=52477&view=diff

==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h Wed Jun 18 20:16:17 2008
@@ -135,6 +135,13 @@
     assert(Reg < VRegInfo.size() && "Invalid vreg!");
     return VRegInfo[Reg].first;
   }
+
+  /// setRegClass - Set the register class of the specified virtual register.
+  void setRegClass(unsigned Reg, const TargetRegisterClass *RC) {
+    Reg -= TargetRegisterInfo::FirstVirtualRegister;
+    assert(Reg < VRegInfo.size() && "Invalid vreg!");
+    VRegInfo[Reg].first = RC;
+  }
   
   /// createVirtualRegister - Create and return a new virtual register in the
   /// function with the specified register class.

Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=52477&r1=52476&r2=52477&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original)
+++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Wed Jun 18 20:16:17 2008
@@ -988,6 +988,7 @@
   unsigned loopDepth = loopInfo->getLoopDepth(MBB);
   bool CanFold = false;
  RestartInstruction:
+  bool isMem = MI->getDesc().mayLoad() || MI->getDesc().mayStore();
   for (unsigned i = 0; i != MI->getNumOperands(); ++i) {
     MachineOperand& mop = MI->getOperand(i);
     if (!mop.isRegister())
@@ -1055,7 +1056,7 @@
     }
 
     // Update stack slot spill weight if we are splitting.
-    float Weight = getSpillWeight(HasDef, HasUse, loopDepth);
+    float Weight = getSpillWeight(HasDef, HasUse, isMem, loopDepth);
       if (!TrySplit)
       SSWeight += Weight;
 
@@ -1248,6 +1249,7 @@
     bool MIHasUse = rwi.HasUse;
     bool MIHasDef = rwi.HasDef;
     MachineInstr *MI = rwi.MI;
+    bool isMem = MI->getDesc().mayLoad() || MI->getDesc().mayStore();
     // If MI def and/or use the same register multiple times, then there
     // are multiple entries.
     unsigned NumUses = MIHasUse;
@@ -1395,7 +1397,7 @@
 
     // Update spill weight.
     unsigned loopDepth = loopInfo->getLoopDepth(MBB);
-    nI.weight += getSpillWeight(HasDef, HasUse, loopDepth);
+    nI.weight += getSpillWeight(HasDef, HasUse, isMem, loopDepth);
   }
 
   if (NewVReg && TrySplit && AllCanFold) {
@@ -1637,6 +1639,7 @@
         LiveInterval &nI = getOrCreateInterval(VReg);
         bool isReMat = vrm.isReMaterialized(VReg);
         MachineInstr *MI = getInstructionFromIndex(index);
+        bool isMem = MI->getDesc().mayLoad() || MI->getDesc().mayStore();
         bool CanFold = false;
         bool FoundUse = false;
         Ops.clear();
@@ -1689,7 +1692,7 @@
 
         // Update spill slot weight.
         if (!isReMat)
-          SSWeight += getSpillWeight(true, false, loopDepth);
+          SSWeight += getSpillWeight(true, false, isMem, loopDepth);
       }
       Id = SpillMBBs.find_next(Id);
     }
@@ -1709,6 +1712,7 @@
       LiveInterval &nI = getOrCreateInterval(VReg);
       bool isReMat = vrm.isReMaterialized(VReg);
       MachineInstr *MI = getInstructionFromIndex(index);
+      bool isMem = MI->getDesc().mayLoad() || MI->getDesc().mayStore();
       bool CanFold = false;
       Ops.clear();
       if (restores[i].canFold) {
@@ -1762,7 +1766,7 @@
 
       // Update spill slot weight.
       if (!isReMat)
-        SSWeight += getSpillWeight(false, true, loopDepth);
+        SSWeight += getSpillWeight(false, true, isMem, loopDepth);
     }
     Id = RestoreMBBs.find_next(Id);
   }





More information about the llvm-commits mailing list