]> granicus.if.org Git - llvm/commitdiff
Revert "[DAG] Cleanup of unused node in SimplifySelectCC."
authorNirav Dave <niravd@google.com>
Thu, 7 Feb 2019 18:31:05 +0000 (18:31 +0000)
committerNirav Dave <niravd@google.com>
Thu, 7 Feb 2019 18:31:05 +0000 (18:31 +0000)
Causes ASAN use-after-poison errors.

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

lib/CodeGen/SelectionDAG/DAGCombiner.cpp

index a3ad2c2f3eee599c22a48ea49036544c08c6de17..dabb8afd104ee7ac8809634293a12298f6cb2eae 100644 (file)
@@ -18673,21 +18673,14 @@ SDValue DAGCombiner::SimplifySelectCC(const SDLoc &DL, SDValue N0, SDValue N1,
   auto *N3C = dyn_cast<ConstantSDNode>(N3.getNode());
 
   // Determine if the condition we're dealing with is constant.
-  if (SDValue SCC =
-          SimplifySetCC(getSetCCResultType(CmpOpVT), N0, N1, CC, DL, false)) {
-    AddToWorklist(SCC.getNode());
-    if (auto *SCCC = dyn_cast<ConstantSDNode>(SCC.getNode())) {
-      // fold select_cc true, x, y -> x
-      // fold select_cc false, x, y -> y
-      bool isNull = SCCC->isNullValue();
-      SDValue RV = isNull ? N3 : N2;
-      // Delete SCC if we don't use it.
-      if (SCCC != RV.getNode())
-        recursivelyDeleteUnusedNodes(SCCC);
-      return RV;
-    }
-    // Don't combine. Cleanup SCC.
-    recursivelyDeleteUnusedNodes(SCC.getNode());
+  SDValue SCC = SimplifySetCC(getSetCCResultType(CmpOpVT), N0, N1, CC, DL,
+                              false);
+  if (SCC.getNode()) AddToWorklist(SCC.getNode());
+
+  if (auto *SCCC = dyn_cast_or_null<ConstantSDNode>(SCC.getNode())) {
+    // fold select_cc true, x, y -> x
+    // fold select_cc false, x, y -> y
+    return !SCCC->isNullValue() ? N2 : N3;
   }
 
   if (SDValue V =