Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp =================================================================== --- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -20602,7 +20602,7 @@ // If the concatenated source types match this extract, it's a direct // simplification: // extract_subvec (concat V1, V2, ...), i --> Vi - if (ConcatSrcNumElts == ExtNumElts) + if (NVT.isScalableVector() == ConcatSrcVT.isScalableVector() && ConcatSrcNumElts == ExtNumElts) return V.getOperand(ConcatOpIdx); // If the concatenated source vectors are a multiple length of this extract, @@ -20610,7 +20610,8 @@ // concat operand. Example: // v2i8 extract_subvec (v16i8 concat (v8i8 X), (v8i8 Y), 14 --> // v2i8 extract_subvec v8i8 Y, 6 - if (NVT.isFixedLengthVector() && ConcatSrcNumElts % ExtNumElts == 0) { + if (NVT.isFixedLengthVector() && ConcatSrcVT.isFixedLengthVector() && + ConcatSrcNumElts % ExtNumElts == 0) { SDLoc DL(N); unsigned NewExtIdx = ExtIdx - ConcatOpIdx * ConcatSrcNumElts; assert(NewExtIdx + ExtNumElts <= ConcatSrcNumElts && Index: llvm/test/CodeGen/AArch64/sve-extract-scalable-vector.ll =================================================================== --- llvm/test/CodeGen/AArch64/sve-extract-scalable-vector.ll +++ llvm/test/CodeGen/AArch64/sve-extract-scalable-vector.ll @@ -3,6 +3,16 @@ ; Extracting illegal subvectors +define <4 x i32> @extract_v4i32_nxv16i32( %arg) { +; CHECK-LABEL: extract_v4i32_nxv16i32: +; CHECK: // %bb.0: +; CHECK-NEXT: mov z0.d, z3.d +; CHECK-NEXT: // kill: def $q0 killed $q0 killed $z0 +; CHECK-NEXT: ret + %ext = call <4 x i32> @llvm.experimental.vector.extract.v4i32.nxv16i32( %arg, i64 12) + ret <4 x i32> %ext +} + define @extract_nxv1i32_nxv4i32( %vec) nounwind { ; CHECK-LABEL: extract_nxv1i32_nxv4i32: ; CHECK: // %bb.0: @@ -784,3 +794,4 @@ declare @llvm.experimental.vector.extract.nxv4bf16.nxv16bf16(, i64) +declare <4 x i32> @llvm.experimental.vector.extract.v4i32.nxv16i32(, i64)