From: Craig Topper Date: Sun, 26 Jun 2016 05:10:49 +0000 (+0000) Subject: [SelectionDAG] Use DAG.getCommutedVectorShuffle instead of reimplementing it. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=63e75c45f10f3d32a513643c3a5c7b456a641bdb;p=llvm [SelectionDAG] Use DAG.getCommutedVectorShuffle instead of reimplementing it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273802 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 1da1f0acb39..66a4b427a2d 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -13420,21 +13420,8 @@ SDValue DAGCombiner::visitVECTOR_SHUFFLE(SDNode *N) { } // Canonicalize shuffle undef, v -> v, undef. Commute the shuffle mask. - if (N0.isUndef()) { - SmallVector 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()) {