Fix DAG combine which creates illegal vector shuffles. Patch by Heikki Kultala.
authorDuncan Sands <baldrick@free.fr>
Mon, 19 Mar 2012 15:35:44 +0000 (15:35 +0000)
committerDuncan Sands <baldrick@free.fr>
Mon, 19 Mar 2012 15:35:44 +0000 (15:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153035 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/DAGCombiner.cpp

index 32b9fa4ec350cd38881988e32be217d1530a67b2..1bd1b95ad7d053003c2014b8effec4b12381bbff 100644 (file)
@@ -7473,6 +7473,12 @@ SDValue DAGCombiner::visitBUILD_VECTOR(SDNode *N) {
   // Check to see if this is a BUILD_VECTOR of a bunch of EXTRACT_VECTOR_ELT
   // operations.  If so, and if the EXTRACT_VECTOR_ELT vector inputs come from
   // at most two distinct vectors, turn this into a shuffle node.
+
+  // May only combine to shuffle after legalize if shuffle is legal.
+  if (LegalOperations &&
+      !TLI.isOperationLegalOrCustom(ISD::VECTOR_SHUFFLE, VT))
+    return SDValue();
+
   SDValue VecIn1, VecIn2;
   for (unsigned i = 0; i != NumInScalars; ++i) {
     // Ignore undef inputs.