[PATCH] D79416: [SVE] Fix wrong usage of getNumElements() in matchIntrinsicType

David Sherwood via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 13 01:02:43 PDT 2020


david-arm updated this revision to Diff 263636.
david-arm edited the summary of this revision.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79416/new/

https://reviews.llvm.org/D79416

Files:
  llvm/lib/IR/Function.cpp
  llvm/test/CodeGen/AArch64/sve-bad-intrinsics.ll


Index: llvm/test/CodeGen/AArch64/sve-bad-intrinsics.ll
===================================================================
--- /dev/null
+++ 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(<vscale x 4 x i16>)
+declare <vscale x 4 x i16> @llvm.arm.neon.vcvtfp2hf(<vscale x 4 x float>)
+
+; CHECK-ERROR: Intrinsic has incorrect return type!
+define <vscale x 4 x i16> @bad1() {
+  %r = call <vscale x 4 x i16> @llvm.arm.neon.vcvtfp2hf(<vscale x 4 x float> zeroinitializer)
+  ret <vscale x 4 x i16> %r
+}
+
+; CHECK-ERROR: Intrinsic has incorrect argument type!
+define <4 x float> @bad2() {
+  %r = call <4 x float> @llvm.arm.neon.vcvthf2fp(<vscale x 4 x i16> zeroinitializer)
+  ret <4 x float> %r
+}
Index: llvm/lib/IR/Function.cpp
===================================================================
--- llvm/lib/IR/Function.cpp
+++ llvm/lib/IR/Function.cpp
@@ -1180,7 +1180,9 @@
     case IITDescriptor::Quad: return !Ty->isFP128Ty();
     case IITDescriptor::Integer: return !Ty->isIntegerTy(D.Integer_Width);
     case IITDescriptor::Vector: {
-      VectorType *VT = dyn_cast<VectorType>(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<FixedVectorType>(Ty);
       return !VT || VT->getNumElements() != D.Vector_Width ||
              matchIntrinsicType(VT->getElementType(), Infos, ArgTys,
                                 DeferredChecks, IsDeferredCheck);
@@ -1357,7 +1359,11 @@
     case IITDescriptor::ScalableVecArgument: {
       if (!isa<ScalableVectorType>(Ty))
         return true;
-      return matchIntrinsicType(Ty, Infos, ArgTys, DeferredChecks,
+      ScalableVectorType *STy = cast<ScalableVectorType>(Ty);
+      unsigned MinElts = STy->getMinNumElements();
+      FixedVectorType *FVTy =
+          FixedVectorType::get(STy->getElementType(), MinElts);
+      return matchIntrinsicType(FVTy, Infos, ArgTys, DeferredChecks,
                                 IsDeferredCheck);
     }
     case IITDescriptor::VecOfBitcastsToInt: {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79416.263636.patch
Type: text/x-patch
Size: 2263 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200513/88e134b5/attachment.bin>


More information about the llvm-commits mailing list