Skip to content

Commit e8a1cde

Browse files
committed
[SelectionDAG] Add asserts to verify the vectorness of input and output types of TRUNCATE/ZERO_EXTEND/ANY_EXTEND/SIGN_EXTEND agree
As a result of the underlying cause of PR41678 we created an ANY_EXTEND node with a scalar result type and v1i1 input type. Ideally we would have asserted for this instead of letting it go through to instruction selection and generate bad machine IR Differential Revision: https://reviews.llvm.org/D61463 llvm-svn: 359836
1 parent 3961507 commit e8a1cde

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4339,6 +4339,9 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
43394339
case ISD::SIGN_EXTEND:
43404340
assert(VT.isInteger() && Operand.getValueType().isInteger() &&
43414341
"Invalid SIGN_EXTEND!");
4342+
assert(VT.isVector() == Operand.getValueType().isVector() &&
4343+
"SIGN_EXTEND result type type should be vector iff the operand "
4344+
"type is vector!");
43424345
if (Operand.getValueType() == VT) return Operand; // noop extension
43434346
assert((!VT.isVector() ||
43444347
VT.getVectorNumElements() ==
@@ -4355,6 +4358,9 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
43554358
case ISD::ZERO_EXTEND:
43564359
assert(VT.isInteger() && Operand.getValueType().isInteger() &&
43574360
"Invalid ZERO_EXTEND!");
4361+
assert(VT.isVector() == Operand.getValueType().isVector() &&
4362+
"ZERO_EXTEND result type type should be vector iff the operand "
4363+
"type is vector!");
43584364
if (Operand.getValueType() == VT) return Operand; // noop extension
43594365
assert((!VT.isVector() ||
43604366
VT.getVectorNumElements() ==
@@ -4371,6 +4377,9 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
43714377
case ISD::ANY_EXTEND:
43724378
assert(VT.isInteger() && Operand.getValueType().isInteger() &&
43734379
"Invalid ANY_EXTEND!");
4380+
assert(VT.isVector() == Operand.getValueType().isVector() &&
4381+
"ANY_EXTEND result type type should be vector iff the operand "
4382+
"type is vector!");
43744383
if (Operand.getValueType() == VT) return Operand; // noop extension
43754384
assert((!VT.isVector() ||
43764385
VT.getVectorNumElements() ==
@@ -4398,6 +4407,9 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
43984407
case ISD::TRUNCATE:
43994408
assert(VT.isInteger() && Operand.getValueType().isInteger() &&
44004409
"Invalid TRUNCATE!");
4410+
assert(VT.isVector() == Operand.getValueType().isVector() &&
4411+
"TRUNCATE result type type should be vector iff the operand "
4412+
"type is vector!");
44014413
if (Operand.getValueType() == VT) return Operand; // noop truncate
44024414
assert((!VT.isVector() ||
44034415
VT.getVectorNumElements() ==

0 commit comments

Comments
 (0)