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-fixed-from-scalable-vector.ll =================================================================== --- /dev/null +++ llvm/test/CodeGen/AArch64/sve-extract-fixed-from-scalable-vector.ll @@ -0,0 +1,11 @@ +; RUN: not --crash llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s -o - 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR + +; Extracting a fixed-length vector from an illegal subvector + +; CHECK-ERROR: ERROR: Extracting a fixed-length vector from an illegal scalable vector is not yet supported +define <4 x i32> @extract_v4i32_nxv16i32_12( %arg) { + %ext = call <4 x i32> @llvm.experimental.vector.extract.v4i32.nxv16i32( %arg, i64 12) + ret <4 x i32> %ext +} + +declare <4 x i32> @llvm.experimental.vector.extract.v4i32.nxv16i32(, i64)