[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Chris Lattner lattner at cs.uiuc.edu
Tue Nov 8 14:07:15 PST 2005



Changes in directory llvm/lib/CodeGen/SelectionDAG:

SelectionDAG.cpp updated: 1.208 -> 1.209
---
Log message:

Switch the operandlist/valuelist from being vectors to being just an array.This saves 12 bytes from SDNode, but doesn't speed things up substantially
(our graphs apparently already fit within the cache on my g5).  In any case
this reduces memory usage.


---
Diffs of the changes:  (+33 -23)

 SelectionDAG.cpp |   56 ++++++++++++++++++++++++++++++++-----------------------
 1 files changed, 33 insertions(+), 23 deletions(-)


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.208 llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.209
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.208	Tue Nov  8 12:52:27 2005
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp	Tue Nov  8 16:07:03 2005
@@ -214,15 +214,17 @@
   
   // Next, brutally remove the operand list.  This is safe to do, as there are
   // no cycles in the graph.
-  while (!N->Operands.empty()) {
-    SDNode *O = N->Operands.back().Val;
-    N->Operands.pop_back();
+  for (SDNode::op_iterator I = N->op_begin(), E = N->op_end(); I != E; ++I) {
+    SDNode *O = I->Val;
     O->removeUser(N);
     
     // Now that we removed this operand, see if there are no uses of it left.
     if (O->use_empty())
       DestroyDeadNode(O);
   }
+  delete[] N->OperandList;
+  N->OperandList = 0;
+  N->NumOperands = 0;
 
   // Mark the node as dead.
   N->MorphNodeTo(65535);
@@ -253,11 +255,11 @@
   }
     
   // Drop all of the operands and decrement used nodes use counts.
-  while (!N->Operands.empty()) {
-    SDNode *O = N->Operands.back().Val;
-    N->Operands.pop_back();
-    O->removeUser(N);
-  }
+  for (SDNode::op_iterator I = N->op_begin(), E = N->op_end(); I != E; ++I)
+    I->Val->removeUser(N);
+  delete[] N->OperandList;
+  N->OperandList = 0;
+  N->NumOperands = 0;
   
   delete N;
 }
@@ -430,8 +432,13 @@
 
 
 SelectionDAG::~SelectionDAG() {
-  for (unsigned i = 0, e = AllNodes.size(); i != e; ++i)
-    delete AllNodes[i];
+  for (unsigned i = 0, e = AllNodes.size(); i != e; ++i) {
+    SDNode *N = AllNodes[i];
+    delete [] N->OperandList;
+    N->OperandList = 0;
+    N->NumOperands = 0;
+    delete N;
+  }
 }
 
 SDOperand SelectionDAG::getZeroExtendInReg(SDOperand Op, MVT::ValueType VT) {
@@ -1078,9 +1085,9 @@
   assert((getOpcode() == ISD::CALLSEQ_START ||
           getOpcode() == ISD::CALLSEQ_END) && "Cannot adjust this node!");
 
-  Operands[0].Val->removeUser(this);
-  Operands[0] = N;
-  N.Val->Uses.push_back(this);
+  OperandList[0].Val->removeUser(this);
+  OperandList[0] = N;
+  OperandList[0].Val->Uses.push_back(this);
 }
 
 
@@ -1430,10 +1437,11 @@
     // This node is about to morph, remove its old self from the CSE maps.
     RemoveNodeFromCSEMaps(U);
     
-    for (unsigned i = 0, e = U->getNumOperands(); i != e; ++i)
-      if (U->getOperand(i).Val == From) {
+    for (SDOperand *I = U->OperandList, *E = U->OperandList+U->NumOperands;
+         I != E; ++I)
+      if (I->Val == From) {
         From->removeUser(U);
-        U->Operands[i].Val = To;
+        I->Val = To;
         To->addUser(U);
       }
 
@@ -1471,10 +1479,11 @@
     // This node is about to morph, remove its old self from the CSE maps.
     RemoveNodeFromCSEMaps(U);
     
-    for (unsigned i = 0, e = U->getNumOperands(); i != e; ++i)
-      if (U->getOperand(i).Val == From) {
+    for (SDOperand *I = U->OperandList, *E = U->OperandList+U->NumOperands;
+         I != E; ++I)
+      if (I->Val == From) {
         From->removeUser(U);
-        U->Operands[i].Val = To;
+        I->Val = To;
         To->addUser(U);
       }
         
@@ -1512,11 +1521,12 @@
     // This node is about to morph, remove its old self from the CSE maps.
     RemoveNodeFromCSEMaps(U);
     
-    for (unsigned i = 0, e = U->getNumOperands(); i != e; ++i)
-      if (U->getOperand(i).Val == From) {
-        const SDOperand &ToOp = To[U->getOperand(i).ResNo];
+    for (SDOperand *I = U->OperandList, *E = U->OperandList+U->NumOperands;
+         I != E; ++I)
+      if (I->Val == From) {
+        const SDOperand &ToOp = To[I->ResNo];
         From->removeUser(U);
-        U->Operands[i] = ToOp;
+        *I = ToOp;
         ToOp.Val->addUser(U);
       }
         






More information about the llvm-commits mailing list