some trivial microoptimizations.
authorChris Lattner <sabre@nondot.org>
Mon, 1 Mar 2010 07:43:08 +0000 (07:43 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 1 Mar 2010 07:43:08 +0000 (07:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97441 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/SelectionDAG.cpp
lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

index f008fad3467833d11d808feaea5417016213b2c6..a3f5f39f6f03a5a9ef950e8fdbbe1cadbeb8dde9 100644 (file)
@@ -4736,12 +4736,14 @@ SDNode *SelectionDAG::MorphNodeTo(SDNode *N, unsigned Opc,
 
   // Delete any nodes that are still dead after adding the uses for the
   // new operands.
-  SmallVector<SDNode *, 16> DeadNodes;
-  for (SmallPtrSet<SDNode *, 16>::iterator I = DeadNodeSet.begin(),
-       E = DeadNodeSet.end(); I != E; ++I)
-    if ((*I)->use_empty())
-      DeadNodes.push_back(*I);
-  RemoveDeadNodes(DeadNodes);
+  if (!DeadNodeSet.empty()) {
+    SmallVector<SDNode *, 16> DeadNodes;
+    for (SmallPtrSet<SDNode *, 16>::iterator I = DeadNodeSet.begin(),
+         E = DeadNodeSet.end(); I != E; ++I)
+      if ((*I)->use_empty())
+        DeadNodes.push_back(*I);
+    RemoveDeadNodes(DeadNodes);
+  }
 
   if (IP)
     CSEMap.InsertNode(N, IP);   // Memoize the new node.
index f1e6b960ee097cc22116bb20dee76f1d8359ae8f..03cbe22c0c53107fdc87144b2a1fc283b66def5c 100644 (file)
@@ -1760,7 +1760,7 @@ SelectCodeCommon(SDNode *NodeToMatch, const unsigned char *MatcherTable,
     case OPC_SwitchOpcode: {
       unsigned CurNodeOpcode = N.getOpcode();
 
-      unsigned SwitchStart = MatcherIndex-1;
+      unsigned SwitchStart = MatcherIndex-1; (void)SwitchStart;
       
       unsigned CaseSize;
       while (1) {
@@ -2060,8 +2060,15 @@ SelectCodeCommon(SDNode *NodeToMatch, const unsigned char *MatcherTable,
       if (EmitNodeInfo & OPFL_FlagOutput)
         VTs.push_back(MVT::Flag);
       
-      // FIXME: Use faster version for the common 'one VT' case?
-      SDVTList VTList = CurDAG->getVTList(VTs.data(), VTs.size());
+      // This is hot code, so optimize the two most common cases of 1 and 2
+      // results.
+      SDVTList VTList;
+      if (VTs.size() == 1)
+        VTList = CurDAG->getVTList(VTs[0]);
+      else if (VTs.size() == 2)
+        VTList = CurDAG->getVTList(VTs[0], VTs[1]);
+      else
+        VTList = CurDAG->getVTList(VTs.data(), VTs.size());
 
       // Get the operand list.
       unsigned NumOps = MatcherTable[MatcherIndex++];