[llvm] [DAGCombine] Fix an incorrect folding of extract_subvector (PR #153709)

Min-Yih Hsu via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 14 16:04:21 PDT 2025


================
@@ -26020,7 +26020,10 @@ SDValue DAGCombiner::visitEXTRACT_SUBVECTOR(SDNode *N) {
   if (ExtIdx == 0 && V.getOpcode() == ISD::EXTRACT_SUBVECTOR && V.hasOneUse()) {
     if (TLI.isExtractSubvectorCheap(NVT, V.getOperand(0).getValueType(),
                                     V.getConstantOperandVal(1)) &&
-        TLI.isOperationLegalOrCustom(ISD::EXTRACT_SUBVECTOR, NVT)) {
+        TLI.isOperationLegalOrCustom(ISD::EXTRACT_SUBVECTOR, NVT) &&
+        // The index has to be a multiple of the new result type's known minimum
+        // vector length.
+        V.getConstantOperandVal(1) % NVT.getVectorMinNumElements() == 0) {
----------------
mshockwave wrote:

oh yeah that'll be better, it's fixed now.

https://github.com/llvm/llvm-project/pull/153709


More information about the llvm-commits mailing list