https://github.com/arsenm updated https://github.com/llvm/llvm-project/pull/154099
>From 3fd9c57c7993fb1ad2651a6fe8681cda289e3e27 Mon Sep 17 00:00:00 2001 From: Matt Arsenault <matthew.arsena...@amd.com> Date: Mon, 18 Aug 2025 13:22:26 +0900 Subject: [PATCH] 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. --- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 2 -- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 43d4138df8b49..9aae043f822a3 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -26091,8 +26091,6 @@ SDValue DAGCombiner::visitEXTRACT_SUBVECTOR(SDNode *N) { EVT ConcatSrcVT = V.getOperand(0).getValueType(); assert(ConcatSrcVT.getVectorElementType() == NVT.getVectorElementType() && "Concat and extract subvector do not change element type"); - assert((ExtIdx % ExtNumElts) == 0 && - "Extract index is not a multiple of the input vector length."); unsigned ConcatSrcNumElts = ConcatSrcVT.getVectorMinNumElements(); unsigned ConcatOpIdx = ExtIdx / ConcatSrcNumElts; diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 84282d8a1c37b..fadf2c7a4b9bc 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -7956,6 +7956,8 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT, assert(N2C->getAPIntValue().getBitWidth() == TLI->getVectorIdxWidth(getDataLayout()) && "Constant index for EXTRACT_SUBVECTOR has an invalid size"); + assert(N2C->getZExtValue() % VT.getVectorMinNumElements() == 0 && + "Extract index is not a multiple of the output vector length"); // Trivial extraction. if (VT == N1VT) _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits