Delete unnecessary elses.
[oota-llvm.git] / include / llvm / CodeGen / DAGISelHeader.h
index 3b4da6618e7dc8794aab8b4dbef1901f3d1a9642..6c040f47f60a4df60e806bd8472b7b14c8067359 100644 (file)
@@ -31,9 +31,9 @@ SelectionDAG::allnodes_iterator ISelPosition;
 static bool IsChainCompatible(SDNode *Chain, SDNode *Op) {
   if (Chain->getOpcode() == ISD::EntryToken)
     return true;
-  else if (Chain->getOpcode() == ISD::TokenFactor)
+  if (Chain->getOpcode() == ISD::TokenFactor)
     return false;
-  else if (Chain->getNumOperands() > 0) {
+  if (Chain->getNumOperands() > 0) {
     SDValue C0 = Chain->getOperand(0);
     if (C0.getValueType() == MVT::Other)
       return C0.getNode() != Op && IsChainCompatible(C0.getNode(), Op);
@@ -108,6 +108,11 @@ void SelectRoot(SelectionDAG &DAG) {
   // node).
   while (ISelPosition != CurDAG->allnodes_begin()) {
     SDNode *Node = --ISelPosition;
+    // Skip dead nodes. DAGCombiner is expected to eliminate all dead nodes,
+    // but there are currently some corner cases that it misses. Also, this
+    // makes it theoretically possible to disable the DAGCombiner.
+    if (Node->use_empty())
+      continue;
 #if 0
     DAG.setSubgraphColor(Node, "red");
 #endif