From 6bca8ef6670f3a524c30d68eb7962f4a1dd1b099 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Sun, 27 Apr 2014 11:41:06 +0000 Subject: SelectionDAG: Aggressively fold shuffles of constant splats. llvm-svn: 207352 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp') diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 3f68d49da68..46d0fcac410 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -1441,6 +1441,11 @@ SDValue SelectionDAG::getVectorShuffle(EVT VT, SDLoc dl, SDValue N1, if (Identity && NElts) return N1; + // Shuffling a constant splat doesn't change the result. + if (N2Undef && N1.getOpcode() == ISD::BUILD_VECTOR) + if (cast(N1)->getConstantSplatValue()) + return N1; + FoldingSetNodeID ID; SDValue Ops[2] = { N1, N2 }; AddNodeIDNode(ID, ISD::VECTOR_SHUFFLE, getVTList(VT), Ops, 2); -- cgit v1.2.3