No need to use std::distance. We can just count the number of operands
authorOwen Anderson <resistor@mac.com>
Tue, 1 Jul 2008 22:34:11 +0000 (22:34 +0000)
committerOwen Anderson <resistor@mac.com>
Tue, 1 Jul 2008 22:34:11 +0000 (22:34 +0000)
much more cheaply.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52990 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/SelectionDAG.cpp

index 17a5fa7d84630b8e9c72e500100ef0d4246686ee..0a23966f31f550b26468076a548d14492e873db0 100644 (file)
@@ -527,13 +527,16 @@ void SelectionDAG::RemoveDeadNode(SDNode *N, DAGUpdateListener *UpdateListener){
 
     // Next, brutally remove the operand list.  This is safe to do, as there are
     // no cycles in the graph.
+    unsigned op_num = 0;
     for (SDNode::op_iterator I = N->op_begin(), E = N->op_end(); I != E; ++I) {
       SDNode *Operand = I->getVal();
-      Operand->removeUser(std::distance(N->op_begin(), I), N);
+      Operand->removeUser(op_num, N);
       
       // Now that we removed this operand, see if there are no uses of it left.
       if (Operand->use_empty())
         DeadNodes.push_back(Operand);
+      
+      op_num++;
     }
     if (N->OperandsNeedDelete) {
       delete[] N->OperandList;