Add a dagcombine optimization to convert concat_vectors of undefs into a single undef.
The unoptimized concat_vectors isd prevented the canonicalization of the vector_shuffle node.
llvm-svn: 160221
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index e2c7dec..1e87d51 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -7816,6 +7816,17 @@
if (N->getNumOperands() == 1)
return N->getOperand(0);
+ // Check if all of the operands are undefs.
+ bool AllUndef = true;
+ for (unsigned i = 0; i < N->getNumOperands(); ++i)
+ if (N->getOperand(i).getOpcode() != ISD::UNDEF) {
+ AllUndef = false;
+ break;
+ }
+
+ if (AllUndef)
+ return DAG.getUNDEF(N->getValueType(0));
+
return SDValue();
}