[llvm] r293152 - [DAGCombiner] Fold extract_subvector of undef to undef. Fold away inserting undef subvectors.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 25 21:38:46 PST 2017


Author: ctopper
Date: Wed Jan 25 23:38:46 2017
New Revision: 293152

URL: http://llvm.org/viewvc/llvm-project?rev=293152&view=rev
Log:
[DAGCombiner] Fold extract_subvector of undef to undef. Fold away inserting undef subvectors.

Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=293152&r1=293151&r2=293152&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Wed Jan 25 23:38:46 2017
@@ -13880,6 +13880,10 @@ SDValue DAGCombiner::visitEXTRACT_SUBVEC
   EVT NVT = N->getValueType(0);
   SDValue V = N->getOperand(0);
 
+  // Extract from UNDEF is UNDEF.
+  if (V.isUndef())
+    return DAG.getUNDEF(NVT);
+
   if (V->getOpcode() == ISD::CONCAT_VECTORS) {
     // Combine:
     //    (extract_subvec (concat V1, V2, ...), i)
@@ -14522,6 +14526,10 @@ SDValue DAGCombiner::visitINSERT_SUBVECT
   SDValue N1 = N->getOperand(1);
   SDValue N2 = N->getOperand(2);
 
+  // If inserting an UNDEF, just return the original vector.
+  if (N1.isUndef())
+    return N0;
+
   // Combine INSERT_SUBVECTORs where we are inserting to the same index.
   // INSERT_SUBVECTOR( INSERT_SUBVECTOR( Vec, SubOld, Idx ), SubNew, Idx )
   // --> INSERT_SUBVECTOR( Vec, SubNew, Idx )




More information about the llvm-commits mailing list