]> granicus.if.org Git - llvm/commitdiff
[SelectionDAG] Use DAG.getCommutedVectorShuffle instead of reimplementing it.
authorCraig Topper <craig.topper@gmail.com>
Sun, 26 Jun 2016 05:10:49 +0000 (05:10 +0000)
committerCraig Topper <craig.topper@gmail.com>
Sun, 26 Jun 2016 05:10:49 +0000 (05:10 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273802 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/DAGCombiner.cpp

index 1da1f0acb3924ec83de9d0c0e84d874726342ebd..66a4b427a2d1de4a684d399faa4d1e8663414b8a 100644 (file)
@@ -13420,21 +13420,8 @@ SDValue DAGCombiner::visitVECTOR_SHUFFLE(SDNode *N) {
   }
 
   // Canonicalize shuffle undef, v -> v, undef.  Commute the shuffle mask.
-  if (N0.isUndef()) {
-    SmallVector<int, 8> NewMask;
-    for (unsigned i = 0; i != NumElts; ++i) {
-      int Idx = SVN->getMaskElt(i);
-      if (Idx >= 0) {
-        if (Idx >= (int)NumElts)
-          Idx -= NumElts;
-        else
-          Idx = -1; // remove reference to lhs
-      }
-      NewMask.push_back(Idx);
-    }
-    return DAG.getVectorShuffle(VT, SDLoc(N), N1, DAG.getUNDEF(VT),
-                                &NewMask[0]);
-  }
+  if (N0.isUndef())
+    return DAG.getCommutedVectorShuffle(*SVN);
 
   // Remove references to rhs if it is undef
   if (N1.isUndef()) {