Index: llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp =================================================================== --- llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp +++ llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp @@ -3960,7 +3960,6 @@ SDValue DAGTypeLegalizer::WidenVecRes_EXTRACT_SUBVECTOR(SDNode *N) { EVT VT = N->getValueType(0); EVT WidenVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT); - unsigned WidenNumElts = WidenVT.getVectorNumElements(); SDValue InOp = N->getOperand(0); SDValue Idx = N->getOperand(1); SDLoc dl(N); @@ -3975,7 +3974,12 @@ if (IdxVal == 0 && InVT == WidenVT) return InOp; + if (VT.isScalableVector()) + report_fatal_error("Don't know how to widen the result of " + "EXTRACT_SUBVECTOR for scalable vectors"); + // Check if we can extract from the vector. + unsigned WidenNumElts = WidenVT.getVectorNumElements(); unsigned InNumElts = InVT.getVectorNumElements(); if (IdxVal % WidenNumElts == 0 && IdxVal + WidenNumElts < InNumElts) return DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, WidenVT, InOp, Idx); Index: llvm/test/CodeGen/AArch64/sve-calling-convention-mixed.ll =================================================================== --- llvm/test/CodeGen/AArch64/sve-calling-convention-mixed.ll +++ llvm/test/CodeGen/AArch64/sve-calling-convention-mixed.ll @@ -198,6 +198,18 @@ ret %1 } + +define @foo8( %a, %b) { +; CHECK-LABEL: foo8: +; CHECK: // %bb.0: // %entry +; CHECK-NEXT: add z0.s, z0.s, z1.s +; CHECK-NEXT: ret +entry: + %c = add %a, %b + ret %c +} + + declare float @callee1(float, , , ) declare float @callee2(i32, i32, i32, i32, i32, i32, i32, i32, float, , ) declare float @callee3(float, float, , , ) Index: llvm/test/CodeGen/AArch64/sve-extract-vector.ll =================================================================== --- llvm/test/CodeGen/AArch64/sve-extract-vector.ll +++ llvm/test/CodeGen/AArch64/sve-extract-vector.ll @@ -105,7 +105,30 @@ ret <16 x i8> %retval } + +; Extracting illegal subvectors + +define @extract_nxv1i32_nxv4i32( %vec) nounwind { +; CHECK-LABEL: extract_nxv1i32_nxv4i32: +; CHECK: // %bb.0: +; CHECK-NEXT: ret + %retval = call @llvm.experimental.vector.extract.nxv1i32.nxv4i32( %vec, i64 0) + ret %retval +} + +define @extract_nxv1i16_nxv6i16( %vec) nounwind { +; CHECK-LABEL: extract_nxv1i16_nxv6i16: +; CHECK: // %bb.0: +; CHECK-NEXT: ret + %retval = call @llvm.experimental.vector.extract.nxv1i16.nxv6i16( %vec, i64 0) + ret %retval +} + + declare <2 x i64> @llvm.experimental.vector.extract.v2i64.nxv2i64(, i64) declare <4 x i32> @llvm.experimental.vector.extract.v4i32.nxv4i32(, i64) declare <8 x i16> @llvm.experimental.vector.extract.v8i16.nxv8i16(, i64) declare <16 x i8> @llvm.experimental.vector.extract.v16i8.nxv16i8(, i64) + +declare @llvm.experimental.vector.extract.nxv1i32.nxv4i32(, i64) +declare @llvm.experimental.vector.extract.nxv1i16.nxv6i16(, i64)