Don't leave newly created nodes around if it turns out they are not needed.
authorEvan Cheng <evan.cheng@apple.com>
Wed, 19 Dec 2007 01:34:38 +0000 (01:34 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Wed, 19 Dec 2007 01:34:38 +0000 (01:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45186 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/DAGCombiner.cpp

index 1400c3ee4f92428abedcd8a80931315d6ca29709..a1d8ad95de5198491879d17e5453e26261388f91 100644 (file)
@@ -1446,7 +1446,8 @@ bool DAGCombiner::SimplifyNodeWithTwoResults(SDNode *N,
         TLI.isOperationLegal(LoOpt.getOpcode(), LoOpt.getValueType())) {
       RetVal = true;
       DAG.ReplaceAllUsesOfValueWith(SDOperand(N, 0), LoOpt);
-    }
+    } else
+      DAG.DeleteNode(Lo.Val);
   }
 
   if (HiExists) {
@@ -1457,7 +1458,8 @@ bool DAGCombiner::SimplifyNodeWithTwoResults(SDNode *N,
         TLI.isOperationLegal(HiOpt.getOpcode(), HiOpt.getValueType())) {
       RetVal = true;
       DAG.ReplaceAllUsesOfValueWith(SDOperand(N, 1), HiOpt);
-    }
+    } else
+      DAG.DeleteNode(Hi.Val);
   }
 
   return RetVal;