Fix slightly too aggressive conact_vector optimization.
[oota-llvm.git] / lib / CodeGen / SelectionDAG / DAGCombiner.cpp
index 85f5df911dbc7d59f53182498511d15a04a9e0ad..2e09ec08fdb1602ae9c3b7500e82d76179d64b22 100644 (file)
@@ -9145,6 +9145,12 @@ SDValue DAGCombiner::visitCONCAT_VECTORS(SDNode *N) {
         return SDValue();
     } else {
       SingleSource = Op.getOperand(0);
+
+      // Check the source type is the same as the type of the result.
+      // If not, this concat may extend the vector, so we can not
+      // optimize it away.
+      if (SingleSource.getValueType() != N->getValueType(0))
+        return SDValue();
     }
 
     unsigned IdentityIndex = i * PartNumElem;