Skip to content

Commit 3ddbece

Browse files
committed
[SelectionDAG] Add additional checks to CONCAT_VECTORS creation
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289214 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 366c08a commit 3ddbece

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3051,6 +3051,16 @@ bool SelectionDAG::haveNoCommonBitsSet(SDValue A, SDValue B) const {
30513051
static SDValue FoldCONCAT_VECTORS(const SDLoc &DL, EVT VT,
30523052
ArrayRef<SDValue> Ops,
30533053
llvm::SelectionDAG &DAG) {
3054+
assert(!Ops.empty() && "Can't concatenate an empty list of vectors!");
3055+
assert(llvm::all_of(Ops,
3056+
[Ops](SDValue Op) {
3057+
return Ops[0].getValueType() == Op.getValueType();
3058+
}) &&
3059+
"Concatenation of vectors with inconsistent value types!");
3060+
assert((Ops.size() * Ops[0].getValueType().getVectorNumElements()) ==
3061+
VT.getVectorNumElements() &&
3062+
"Incorrect element count in vector concatenation!");
3063+
30543064
if (Ops.size() == 1)
30553065
return Ops[0];
30563066

0 commit comments

Comments
 (0)