[llvm] r271429 - SDAG: Drop a redundant replace and move the dead node removal closer. NFC

Justin Bogner via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 1 13:55:26 PDT 2016


Author: bogner
Date: Wed Jun  1 15:55:26 2016
New Revision: 271429

URL: http://llvm.org/viewvc/llvm-project?rev=271429&view=rev
Log:
SDAG: Drop a redundant replace and move the dead node removal closer. NFC

Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=271429&r1=271428&r2=271429&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Wed Jun  1 15:55:26 2016
@@ -2437,8 +2437,10 @@ MorphNode(SDNode *Node, unsigned TargetO
 
   // Otherwise, no replacement happened because the node already exists. Replace
   // Uses of the old node with the new one.
-  if (Res != Node)
+  if (Res != Node) {
     CurDAG->ReplaceAllUsesWith(Node, Res);
+    CurDAG->RemoveDeadNode(Node);
+  }
 
   return Res;
 }
@@ -3436,11 +3438,7 @@ void SelectionDAGISel::SelectCodeCommon(
       // If this was a MorphNodeTo then we're completely done!
       if (IsMorphNodeTo) {
         // Update chain uses.
-        UpdateChains(NodeToMatch, InputChain, ChainNodesMatched, true);
-        if (Res != NodeToMatch) {
-          ReplaceUses(NodeToMatch, Res);
-          CurDAG->RemoveDeadNode(NodeToMatch);
-        }
+        UpdateChains(Res, InputChain, ChainNodesMatched, true);
         return;
       }
       continue;




More information about the llvm-commits mailing list