[llvm-commits] CVS: llvm/include/llvm/CodeGen/LiveVariables.h

Chris Lattner lattner at cs.uiuc.edu
Tue Aug 23 17:09:14 PDT 2005



Changes in directory llvm/include/llvm/CodeGen:

LiveVariables.h updated: 1.24 -> 1.25
---
Log message:

Keep the killed/dead sets sorted, so that "KillsRegister" can do a quick
binary search to test for membership.  This speeds up LLC a bit more on KC++,
e.g. on itanium from 16.6974s to 14.8272s, PPC from 11.4926s to 10.7089s and
X86 from 10.8128s to 9.7943s, with no difference in generated code (like all 
of the RA patches).

With these changes, isel is the slowest pass for PPC/X86, but linscan+live
intervals is still > 50% of the compile time for itanium.  More work could
be done, but this is the last for now.


---
Diffs of the changes:  (+26 -22)

 LiveVariables.h |   48 ++++++++++++++++++++++++++----------------------
 1 files changed, 26 insertions(+), 22 deletions(-)


Index: llvm/include/llvm/CodeGen/LiveVariables.h
diff -u llvm/include/llvm/CodeGen/LiveVariables.h:1.24 llvm/include/llvm/CodeGen/LiveVariables.h:1.25
--- llvm/include/llvm/CodeGen/LiveVariables.h:1.24	Tue Aug 23 18:40:41 2005
+++ llvm/include/llvm/CodeGen/LiveVariables.h	Tue Aug 23 19:09:02 2005
@@ -145,16 +145,8 @@
 
   /// KillsRegister - Return true if the specified instruction kills the
   /// specified register.
-  bool KillsRegister(MachineInstr *MI, unsigned Reg) const {
-    std::map<MachineInstr*, std::vector<unsigned> >::const_iterator I = 
-      RegistersKilled.find(MI);
-    if (I != RegistersKilled.end())
-      for (std::vector<unsigned>::const_iterator CI = I->second.begin(),
-           E = I->second.end(); CI != E; ++CI)
-        if (*CI == Reg) return true;
-    return false;
-  }
-
+  bool KillsRegister(MachineInstr *MI, unsigned Reg) const;
+  
   killed_iterator dead_begin(MachineInstr *MI) {
     return getDeadDefsVector(MI).begin();
   }
@@ -169,16 +161,8 @@
   
   /// RegisterDefIsDead - Return true if the specified instruction defines the
   /// specified register, but that definition is dead.
-  bool RegisterDefIsDead(MachineInstr *MI, unsigned Reg) const {
-    std::map<MachineInstr*, std::vector<unsigned> >::const_iterator I = 
-      RegistersDead.find(MI);
-    if (I != RegistersDead.end())
-      for (std::vector<unsigned>::const_iterator CI = I->second.begin(),
-           E = I->second.end(); CI != E; ++CI)
-        if (*CI == Reg) return true;
-    return false;
-  }
-
+  bool RegisterDefIsDead(MachineInstr *MI, unsigned Reg) const;
+  
   //===--------------------------------------------------------------------===//
   //  API to update live variable information
 
@@ -193,7 +177,17 @@
   /// instruction.
   ///
   void addVirtualRegisterKilled(unsigned IncomingReg, MachineInstr *MI) {
-    RegistersKilled.insert(std::make_pair(MI, IncomingReg));
+    std::vector<unsigned> &V = RegistersKilled[MI];
+    // Insert in a sorted order.
+    if (V.empty() || IncomingReg > V.back()) {
+      V.push_back(IncomingReg);
+    } else {
+      std::vector<unsigned>::iterator I = V.begin();
+      for (; *I < IncomingReg; ++I)
+        /*empty*/;
+      if (*I != IncomingReg)   // Don't insert duplicates.
+        V.insert(I, IncomingReg);
+    }
     getVarInfo(IncomingReg).Kills.push_back(MI);
   }
 
@@ -226,7 +220,17 @@
   /// register is dead after being used by the specified instruction.
   ///
   void addVirtualRegisterDead(unsigned IncomingReg, MachineInstr *MI) {
-    RegistersDead.insert(std::make_pair(MI, IncomingReg));
+    std::vector<unsigned> &V = RegistersDead[MI];
+    // Insert in a sorted order.
+    if (V.empty() || IncomingReg > V.back()) {
+      V.push_back(IncomingReg);
+    } else {
+      std::vector<unsigned>::iterator I = V.begin();
+      for (; *I < IncomingReg; ++I)
+        /*empty*/;
+      if (*I != IncomingReg)   // Don't insert duplicates.
+        V.insert(I, IncomingReg);
+    }
     getVarInfo(IncomingReg).Kills.push_back(MI);
   }
 






More information about the llvm-commits mailing list