Skip to content

Commit 3fd9c57

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 ce7657b commit 3fd9c57

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
@@ -26091,8 +26091,6 @@ SDValue DAGCombiner::visitEXTRACT_SUBVECTOR(SDNode *N) {
2609126091
EVT ConcatSrcVT = V.getOperand(0).getValueType();
2609226092
assert(ConcatSrcVT.getVectorElementType() == NVT.getVectorElementType() &&
2609326093
"Concat and extract subvector do not change element type");
26094-
assert((ExtIdx % ExtNumElts) == 0 &&
26095-
"Extract index is not a multiple of the input vector length.");
2609626094

2609726095
unsigned ConcatSrcNumElts = ConcatSrcVT.getVectorMinNumElements();
2609826096
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)