[llvm-commits] CVS: llvm/lib/Target/X86/X86ISelDAGToDAG.cpp

Evan Cheng evan.cheng at apple.com
Wed Aug 2 02:18:48 PDT 2006



Changes in directory llvm/lib/Target/X86:

X86ISelDAGToDAG.cpp updated: 1.86 -> 1.87
---
Log message:

Use of vector<bool> causes some horrendous compile time regression (2x)!
Looks like libstdc++ implementation does not scale very well. Switch back
to using directly managed arrays.


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

 X86ISelDAGToDAG.cpp |   39 ++++++++++++++++++++++++++-------------
 1 files changed, 26 insertions(+), 13 deletions(-)


Index: llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
diff -u llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:1.86 llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:1.87
--- llvm/lib/Target/X86/X86ISelDAGToDAG.cpp:1.86	Tue Aug  1 03:17:22 2006
+++ llvm/lib/Target/X86/X86ISelDAGToDAG.cpp	Wed Aug  2 04:18:33 2006
@@ -99,7 +99,7 @@
       : SelectionDAGISel(X86Lowering),
         X86Lowering(*TM.getTargetLowering()),
         Subtarget(&TM.getSubtarget<X86Subtarget>()),
-        DAGSize(0) {}
+        DAGSize(0), ReachabilityMatrix(NULL), ReachMatrixRange(NULL) {}
 
     virtual bool runOnFunction(Function &Fn) {
       // Make sure we re-emit a set of the global base reg if necessary
@@ -189,33 +189,35 @@
 
     /// ReachabilityMatrix - A N x N matrix representing all pairs reachability
     /// information. One bit per potential edge.
-    std::vector<bool> ReachabilityMatrix;
+    unsigned char *ReachabilityMatrix;
 
-    /// RMRange - The range of reachability information available for the
-    /// particular source node.
-    std::vector<unsigned> ReachMatrixRange;
+    /// ReachMatrixRange - The range of reachability information available for
+    /// the particular source node.
+    unsigned *ReachMatrixRange;
 
     inline void setReachable(SDNode *f, SDNode *t) {
       unsigned Idx = f->getNodeId() * DAGSize + t->getNodeId();
-      ReachabilityMatrix[Idx] = true;
+      ReachabilityMatrix[Idx / 8] |= 1 << (Idx % 8);
     }
 
     inline bool isReachable(SDNode *f, SDNode *t) {
       unsigned Idx = f->getNodeId() * DAGSize + t->getNodeId();
-      return ReachabilityMatrix[Idx];
+      return ReachabilityMatrix[Idx / 8] & (1 << (Idx % 8));
     }
 
     /// UnfoldableSet - An boolean array representing nodes which have been
     /// folded into addressing modes and therefore should not be folded in
     /// another operation.
-    std::vector<bool> UnfoldableSet;
+    unsigned char *UnfoldableSet;
 
     inline void setUnfoldable(SDNode *N) {
-      UnfoldableSet[N->getNodeId()] = true;
+      unsigned Id = N->getNodeId();
+      UnfoldableSet[Id / 8] |= 1 << (Id % 8);
     }
 
     inline bool isUnfoldable(SDNode *N) {
-      return UnfoldableSet[N->getNodeId()];
+      unsigned Id = N->getNodeId();
+      return UnfoldableSet[Id / 8] & (1 << (Id % 8));
     }
 
 #ifndef NDEBUG
@@ -291,9 +293,14 @@
 
   TopOrder = DAG.AssignTopologicalOrder();
   DAGSize = TopOrder.size();
-  ReachabilityMatrix.assign(DAGSize*DAGSize, false);
-  ReachMatrixRange.assign(DAGSize, 0);
-  UnfoldableSet.assign(DAGSize, false);
+  unsigned RMSize = (DAGSize * DAGSize + 7) / 8;
+  ReachabilityMatrix = new unsigned char[RMSize];
+  memset(ReachabilityMatrix, 0, RMSize);
+  ReachMatrixRange = new unsigned[DAGSize];
+  memset(ReachMatrixRange, 0, DAGSize * sizeof(unsigned));
+  unsigned NumBytes = (DAGSize + 7) / 8;
+  UnfoldableSet = new unsigned char[NumBytes];
+  memset(UnfoldableSet, 0, NumBytes);
 
   // Codegen the basic block.
 #ifndef NDEBUG
@@ -305,6 +312,12 @@
   DEBUG(std::cerr << "===== Instruction selection ends:\n");
 #endif
 
+  delete[] ReachabilityMatrix;
+  delete[] ReachMatrixRange;
+  delete[] UnfoldableSet;
+  ReachabilityMatrix = NULL;
+  ReachMatrixRange = NULL;
+  UnfoldableSet = NULL;
   CodeGenMap.clear();
   HandleMap.clear();
   ReplaceMap.clear();






More information about the llvm-commits mailing list