[llvm] [IR] fix parser crash on AArch64 NEON intrinsics with mismatched element types (PR #177321)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 22 01:26:00 PST 2026


https://github.com/nataliakokoromyti updated https://github.com/llvm/llvm-project/pull/177321

>From 65c9d4da88d2f5b4bfd5a4197732be98f7c5b0c9 Mon Sep 17 00:00:00 2001
From: nataliakokoromyti <nataliakokoromyti at gmail.com>
Date: Thu, 22 Jan 2026 00:30:07 -0800
Subject: [PATCH 1/4] [IR] fix parser crash on AArch64 NEON intrinsics with
 mismatched element types

---
 llvm/lib/IR/Intrinsics.cpp                      | 16 ++++++++++++----
 .../intrinsic-aarch64-neon-type-mismatch.ll     | 17 +++++++++++++++++
 2 files changed, 29 insertions(+), 4 deletions(-)
 create mode 100644 llvm/test/Verifier/intrinsic-aarch64-neon-type-mismatch.ll

diff --git a/llvm/lib/IR/Intrinsics.cpp b/llvm/lib/IR/Intrinsics.cpp
index f46d3e5063e43..1f70c7dc5a583 100644
--- a/llvm/lib/IR/Intrinsics.cpp
+++ b/llvm/lib/IR/Intrinsics.cpp
@@ -950,9 +950,11 @@ matchIntrinsicType(Type *Ty, ArrayRef<Intrinsic::IITDescriptor> &Infos,
       return IsDeferredCheck || DeferCheck(Ty);
 
     Type *NewTy = ArgTys[D.getArgumentNumber()];
-    if (VectorType *VTy = dyn_cast<VectorType>(NewTy))
+    if (VectorType *VTy = dyn_cast<VectorType>(NewTy)) {
+      if (!VTy->getElementType()->isIntegerTy())
+        return true;
       NewTy = VectorType::getExtendedElementVectorType(VTy);
-    else if (IntegerType *ITy = dyn_cast<IntegerType>(NewTy))
+    } else if (IntegerType *ITy = dyn_cast<IntegerType>(NewTy))
       NewTy = IntegerType::get(ITy->getContext(), 2 * ITy->getBitWidth());
     else
       return true;
@@ -965,9 +967,15 @@ matchIntrinsicType(Type *Ty, ArrayRef<Intrinsic::IITDescriptor> &Infos,
       return IsDeferredCheck || DeferCheck(Ty);
 
     Type *NewTy = ArgTys[D.getArgumentNumber()];
-    if (VectorType *VTy = dyn_cast<VectorType>(NewTy))
+    if (VectorType *VTy = dyn_cast<VectorType>(NewTy)) {
+      Type *EltTy = VTy->getElementType();
+      if (!EltTy->isIntegerTy() && !EltTy->isFloatingPointTy())
+        return true;
+      if (EltTy->isFloatingPointTy() &&
+          (EltTy->isHalfTy() || EltTy->isBFloatTy()))
+        return true;
       NewTy = VectorType::getTruncatedElementVectorType(VTy);
-    else if (IntegerType *ITy = dyn_cast<IntegerType>(NewTy))
+    } else if (IntegerType *ITy = dyn_cast<IntegerType>(NewTy))
       NewTy = IntegerType::get(ITy->getContext(), ITy->getBitWidth() / 2);
     else
       return true;
diff --git a/llvm/test/Verifier/intrinsic-aarch64-neon-type-mismatch.ll b/llvm/test/Verifier/intrinsic-aarch64-neon-type-mismatch.ll
new file mode 100644
index 0000000000000..dc569f7673342
--- /dev/null
+++ b/llvm/test/Verifier/intrinsic-aarch64-neon-type-mismatch.ll
@@ -0,0 +1,17 @@
+; RUN: not opt -S < %s 2>&1 | FileCheck %s
+
+; Test that AArch64 NEON intrinsics with incorrect vector element types
+; are rejected with a proper error instead of causing assertion failures.
+; This is a regression test for GitHub issue #176847.
+
+; CHECK: invalid intrinsic signature
+define <vscale x 4 x float> @test_raddhn_float_instead_of_int(<vscale x 4 x float> %arg0) {
+  %i = call <vscale x 4 x float> @llvm.aarch64.neon.raddhn.v4f32(<vscale x 4 x float> %arg0, i32 0)
+  ret <vscale x 4 x float> %i
+}
+
+; CHECK: invalid intrinsic signature
+define <8 x half> @test_sqdmull_half_instead_of_int(<8 x half> %arg0, <8 x half> %arg1) {
+  %i = call <8 x half> @llvm.aarch64.neon.sqdmull.v8f16(<8 x half> %arg0, <8 x half> %arg1)
+  ret <8 x half> %i
+}

>From df9bc5aa65cb689cfa8c382815a6a3acf11760ec Mon Sep 17 00:00:00 2001
From: nataliakokoromyti <nataliakokoromyti at gmail.com>
Date: Thu, 22 Jan 2026 00:44:09 -0800
Subject: [PATCH 2/4] rm not

---
 llvm/test/Verifier/intrinsic-aarch64-neon-type-mismatch.ll | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/test/Verifier/intrinsic-aarch64-neon-type-mismatch.ll b/llvm/test/Verifier/intrinsic-aarch64-neon-type-mismatch.ll
index dc569f7673342..801e16cb99200 100644
--- a/llvm/test/Verifier/intrinsic-aarch64-neon-type-mismatch.ll
+++ b/llvm/test/Verifier/intrinsic-aarch64-neon-type-mismatch.ll
@@ -1,4 +1,4 @@
-; RUN: not opt -S < %s 2>&1 | FileCheck %s
+; RUN: opt -S < %s 2>&1 | FileCheck %s
 
 ; Test that AArch64 NEON intrinsics with incorrect vector element types
 ; are rejected with a proper error instead of causing assertion failures.

>From fd849a767492e5b9ee66e72f9e8aaa90d158672f Mon Sep 17 00:00:00 2001
From: nataliakokoromyti <nataliakokoromyti at gmail.com>
Date: Thu, 22 Jan 2026 01:04:21 -0800
Subject: [PATCH 3/4] add not back in the RUN line

---
 llvm/test/Verifier/intrinsic-aarch64-neon-type-mismatch.ll | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/test/Verifier/intrinsic-aarch64-neon-type-mismatch.ll b/llvm/test/Verifier/intrinsic-aarch64-neon-type-mismatch.ll
index 801e16cb99200..dc569f7673342 100644
--- a/llvm/test/Verifier/intrinsic-aarch64-neon-type-mismatch.ll
+++ b/llvm/test/Verifier/intrinsic-aarch64-neon-type-mismatch.ll
@@ -1,4 +1,4 @@
-; RUN: opt -S < %s 2>&1 | FileCheck %s
+; RUN: not opt -S < %s 2>&1 | FileCheck %s
 
 ; Test that AArch64 NEON intrinsics with incorrect vector element types
 ; are rejected with a proper error instead of causing assertion failures.

>From 7f3da80f9f983d783020a7073426d4c1e9810a66 Mon Sep 17 00:00:00 2001
From: nataliakokoromyti <nataliakokoromyti at gmail.com>
Date: Thu, 22 Jan 2026 01:25:49 -0800
Subject: [PATCH 4/4] fix check lineds

---
 llvm/test/Verifier/intrinsic-aarch64-neon-type-mismatch.ll | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/test/Verifier/intrinsic-aarch64-neon-type-mismatch.ll b/llvm/test/Verifier/intrinsic-aarch64-neon-type-mismatch.ll
index dc569f7673342..f0ad8f10fb523 100644
--- a/llvm/test/Verifier/intrinsic-aarch64-neon-type-mismatch.ll
+++ b/llvm/test/Verifier/intrinsic-aarch64-neon-type-mismatch.ll
@@ -4,13 +4,13 @@
 ; are rejected with a proper error instead of causing assertion failures.
 ; This is a regression test for GitHub issue #176847.
 
-; CHECK: invalid intrinsic signature
+; CHECK: error: invalid intrinsic signature
 define <vscale x 4 x float> @test_raddhn_float_instead_of_int(<vscale x 4 x float> %arg0) {
   %i = call <vscale x 4 x float> @llvm.aarch64.neon.raddhn.v4f32(<vscale x 4 x float> %arg0, i32 0)
   ret <vscale x 4 x float> %i
 }
 
-; CHECK: invalid intrinsic signature
+; CHECK: error: invalid intrinsic signature
 define <8 x half> @test_sqdmull_half_instead_of_int(<8 x half> %arg0, <8 x half> %arg1) {
   %i = call <8 x half> @llvm.aarch64.neon.sqdmull.v8f16(<8 x half> %arg0, <8 x half> %arg1)
   ret <8 x half> %i



More information about the llvm-commits mailing list