[Mlir-commits] [mlir] Verify element type in SPIR-V's vector-type verifier (PR #177787)

Gabriel Dehame llvmlistbot at llvm.org
Sat Jan 24 11:10:25 PST 2026


https://github.com/gdehame updated https://github.com/llvm/llvm-project/pull/177787

>From 6225c240f4374035a52ffe27ee04d3f17b43e0b9 Mon Sep 17 00:00:00 2001
From: gdehame <gabrieldehame at gmail.com>
Date: Sat, 24 Jan 2026 20:01:55 +0100
Subject: [PATCH] Verify element type in SPIR-V's vector-type verifier

---
 mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp
index 7c3bfd72115e6..24d3bcfd9cee3 100644
--- a/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp
+++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp
@@ -186,6 +186,13 @@ static Type parseAndVerifyType(SPIRVDialect const &dialect,
       parser.emitError(typeLoc, "only 1-D vector allowed but found ") << t;
       return Type();
     }
+    if (!isa<ScalarType>(t.getElementType())) {
+      parser.emitError(typeLoc,
+                       "vector element type has to be SPIR-V compatible "
+                       "integer, float or boolean but found ")
+          << t.getElementType();
+      return Type();
+    }
     if (t.getNumElements() > 4) {
       parser.emitError(
           typeLoc, "vector length has to be less than or equal to 4 but found ")



More information about the Mlir-commits mailing list