[llvm] r214021 - [SDAG] Simplify the code for handling single-value nodes and add

Chandler Carruth chandlerc at gmail.com
Fri Jul 25 22:52:51 PDT 2014


Author: chandlerc
Date: Sat Jul 26 00:52:51 2014
New Revision: 214021

URL: http://llvm.org/viewvc/llvm-project?rev=214021&view=rev
Log:
[SDAG] Simplify the code for handling single-value nodes and add
a missing transfer of debug information (without which tests fail).

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

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=214021&r1=214020&r2=214021&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Sat Jul 26 00:52:51 2014
@@ -1344,15 +1344,19 @@ void SelectionDAGLegalize::LegalizeOp(SD
       // a complete mess.
       SDValue Res = TLI.LowerOperation(SDValue(Node, 0), DAG);
       if (Res.getNode()) {
-        SmallVector<SDValue, 8> ResultVals;
-        for (unsigned i = 0, e = Node->getNumValues(); i != e; ++i) {
-          if (e == 1)
-            ResultVals.push_back(Res);
-          else
-            ResultVals.push_back(Res.getValue(i));
+        if (!(Res.getNode() != Node || Res.getResNo() != 0))
+          return;
+
+        if (Node->getNumValues() == 1) {
+          // We can just directly replace this node with the lowered value.
+          ReplaceNode(SDValue(Node, 0), Res);
+          return;
         }
-        if (Res.getNode() != Node || Res.getResNo() != 0)
-          ReplaceNode(Node, ResultVals.data());
+
+        SmallVector<SDValue, 8> ResultVals;
+        for (unsigned i = 0, e = Node->getNumValues(); i != e; ++i)
+          ResultVals.push_back(Res.getValue(i));
+        ReplaceNode(Node, ResultVals.data());
         return;
       }
     }





More information about the llvm-commits mailing list