[SelectionDAG] Add additional checks to CONCAT_VECTORS creation
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Fri, 9 Dec 2016 14:27:52 +0000 (14:27 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Fri, 9 Dec 2016 14:27:52 +0000 (14:27 +0000)
Part of the work for PR31323 - add extra asserts checking that the input vectors are of consistent type and result in the correct number of vector elements.

llvm-svn: 289214

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

index cbe5a24..4656bd6 100644 (file)
@@ -3051,6 +3051,16 @@ bool SelectionDAG::haveNoCommonBitsSet(SDValue A, SDValue B) const {
 static SDValue FoldCONCAT_VECTORS(const SDLoc &DL, EVT VT,
                                   ArrayRef<SDValue> Ops,
                                   llvm::SelectionDAG &DAG) {
+  assert(!Ops.empty() && "Can't concatenate an empty list of vectors!");
+  assert(llvm::all_of(Ops,
+                      [Ops](SDValue Op) {
+                        return Ops[0].getValueType() == Op.getValueType();
+                      }) &&
+         "Concatenation of vectors with inconsistent value types!");
+  assert((Ops.size() * Ops[0].getValueType().getVectorNumElements()) ==
+             VT.getVectorNumElements() &&
+         "Incorrect element count in vector concatenation!");
+
   if (Ops.size() == 1)
     return Ops[0];