Skip to content

Commit 276c1d8

Browse files
authored
DAG: Add assert to getNode for EXTRACT_SUBVECTOR indexes (#154099)
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 c97322d commit 276c1d8

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

2610326101
unsigned ConcatSrcNumElts = ConcatSrcVT.getVectorMinNumElements();
2610426102
unsigned ConcatOpIdx = ExtIdx / ConcatSrcNumElts;

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

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

79647966
// Trivial extraction.
79657967
if (VT == N1VT)

0 commit comments

Comments
 (0)