Skip to content

Commit e092268

Browse files
committed
DAG: Add assert to getNode for EXTRACT_SUBVECTOR indexes
Verify it's a multiple of the result vector element count instead of asserting this in random combines. The testcase in #153808 fails in the wrong point. Add an assert to getNode so the invalid extract asserts at construction instead of use.
1 parent 7bdd4ac commit e092268

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26094,8 +26094,6 @@ SDValue DAGCombiner::visitEXTRACT_SUBVECTOR(SDNode *N) {
2609426094
EVT ConcatSrcVT = V.getOperand(0).getValueType();
2609526095
assert(ConcatSrcVT.getVectorElementType() == NVT.getVectorElementType() &&
2609626096
"Concat and extract subvector do not change element type");
26097-
assert((ExtIdx % ExtNumElts) == 0 &&
26098-
"Extract index is not a multiple of the input vector length.");
2609926097

2610026098
unsigned ConcatSrcNumElts = ConcatSrcVT.getVectorMinNumElements();
2610126099
unsigned ConcatOpIdx = ExtIdx / ConcatSrcNumElts;

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7956,6 +7956,8 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
79567956
assert(N2C->getAPIntValue().getBitWidth() ==
79577957
TLI->getVectorIdxWidth(getDataLayout()) &&
79587958
"Constant index for EXTRACT_SUBVECTOR has an invalid size");
7959+
assert(N2C->getZExtValue() % VT.getVectorMinNumElements() == 0 &&
7960+
"Extract index is not a multiple of the output vector length");
79597961

79607962
// Trivial extraction.
79617963
if (VT == N1VT)

0 commit comments

Comments
 (0)