[llvm-branch-commits] [llvm] DAG: Add assert to getNode for EXTRACT_SUBVECTOR indexes (PR #154099)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Aug 18 04:36:05 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-amdgpu
Author: Matt Arsenault (arsenm)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/154099.diff
2 Files Affected:
- (modified) llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (-2)
- (modified) llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (+2)
``````````diff
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 785245b2d9e74..a8985b0a0fd56 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -26094,8 +26094,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)
``````````
</details>
https://github.com/llvm/llvm-project/pull/154099
More information about the llvm-branch-commits
mailing list