diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp index ac62ffa0ef13f3..dab1c336c4194b 100644 --- a/llvm/lib/IR/Function.cpp +++ b/llvm/lib/IR/Function.cpp @@ -1180,7 +1180,9 @@ static bool matchIntrinsicType( case IITDescriptor::Quad: return !Ty->isFP128Ty(); case IITDescriptor::Integer: return !Ty->isIntegerTy(D.Integer_Width); case IITDescriptor::Vector: { - VectorType *VT = dyn_cast(Ty); + // FIXME: We shouldn't be assuming all Vector types are fixed width. + // This will be fixed soon in another future patch. + FixedVectorType *VT = dyn_cast(Ty); return !VT || VT->getNumElements() != D.Vector_Width || matchIntrinsicType(VT->getElementType(), Infos, ArgTys, DeferredChecks, IsDeferredCheck); @@ -1357,7 +1359,11 @@ static bool matchIntrinsicType( case IITDescriptor::ScalableVecArgument: { if (!isa(Ty)) return true; - return matchIntrinsicType(Ty, Infos, ArgTys, DeferredChecks, + ScalableVectorType *STy = cast(Ty); + unsigned MinElts = STy->getMinNumElements(); + FixedVectorType *FVTy = + FixedVectorType::get(STy->getElementType(), MinElts); + return matchIntrinsicType(FVTy, Infos, ArgTys, DeferredChecks, IsDeferredCheck); } case IITDescriptor::VecOfBitcastsToInt: { diff --git a/llvm/test/CodeGen/AArch64/sve-bad-intrinsics.ll b/llvm/test/CodeGen/AArch64/sve-bad-intrinsics.ll new file mode 100644 index 00000000000000..1b37ea372b9836 --- /dev/null +++ b/llvm/test/CodeGen/AArch64/sve-bad-intrinsics.ll @@ -0,0 +1,17 @@ +; RUN: not llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s 2>%t +; RUN: FileCheck --check-prefix=CHECK-ERROR %s <%t + +declare <4 x float> @llvm.arm.neon.vcvthf2fp() +declare @llvm.arm.neon.vcvtfp2hf() + +; CHECK-ERROR: Intrinsic has incorrect return type! +define @bad1() { + %r = call @llvm.arm.neon.vcvtfp2hf( zeroinitializer) + ret %r +} + +; CHECK-ERROR: Intrinsic has incorrect argument type! +define <4 x float> @bad2() { + %r = call <4 x float> @llvm.arm.neon.vcvthf2fp( zeroinitializer) + ret <4 x float> %r +}