From cef896e50cf58e6b3dc3cd431693d78b8ebfa079 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 28 Mar 2006 22:19:47 +0000 Subject: [PATCH] When building a VVECTOR_SHUFFLE node from extract_element operations, make sure to build it as SHUFFLE(X, undef, mask), not SHUFFLE(X, X, mask). The later is not canonical form, and prevents the PPC splat pattern from matching. For a particular splat, we go from generating this: li r10, lo16(LCPI1_0) lis r11, ha16(LCPI1_0) lvx v3, r11, r10 vperm v3, v2, v2, v3 to generating: vspltw v3, v2, 3 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27236 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 1c90f784358..a559d3e469e 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -2419,7 +2419,17 @@ SDOperand DAGCombiner::visitVBUILD_VECTOR(SDNode *N) { // Return the new VVECTOR_SHUFFLE node. std::vector Ops; Ops.push_back(VecIn1); - Ops.push_back(VecIn2.Val ? VecIn2 : VecIn1); // Use V1 twice if no V2. + if (VecIn2.Val) { + Ops.push_back(VecIn2); + } else { + // Use an undef vbuild_vector as input for the second operand. + std::vector UnOps(NumInScalars, + DAG.getNode(ISD::UNDEF, + cast(EltType)->getVT())); + UnOps.push_back(NumElts); + UnOps.push_back(EltType); + Ops.push_back(DAG.getNode(ISD::VBUILD_VECTOR, MVT::Vector, UnOps)); + } Ops.push_back(DAG.getNode(ISD::VBUILD_VECTOR,MVT::Vector, BuildVecIndices)); Ops.push_back(NumElts); Ops.push_back(EltType); -- 2.34.1