[Mlir-commits] [mlir] [mlir][spirv] Fix entry point, logical ops and sampled image Target tests (PR #159376)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Sep 17 07:55:40 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir

Author: Igor Wodiany (IgWod-IMG)

<details>
<summary>Changes</summary>

For the entry point an incorrect combination of execution model and mode was used as well as arguments were specified for the entry function (the function should take no arguments). For logical ops the test was failing as using scalar condition and vector objects is not supported in spv1.0. Sampled image test was using incorrect *Sampled* and *Dim* values. Sampled images need to have *Sampled* operand of 0 or 1, but not 2 (`NoSampler`), and `SubpassData` is not allowed.

---
Full diff: https://github.com/llvm/llvm-project/pull/159376.diff


3 Files Affected:

- (modified) mlir/test/Target/SPIRV/entry-point.mlir (+11-6) 
- (modified) mlir/test/Target/SPIRV/logical-ops.mlir (+8-3) 
- (modified) mlir/test/Target/SPIRV/sampled-image.mlir (+10-5) 


``````````diff
diff --git a/mlir/test/Target/SPIRV/entry-point.mlir b/mlir/test/Target/SPIRV/entry-point.mlir
index 88ad637fb7606..a7ec5290151ef 100644
--- a/mlir/test/Target/SPIRV/entry-point.mlir
+++ b/mlir/test/Target/SPIRV/entry-point.mlir
@@ -1,12 +1,17 @@
 // RUN: mlir-translate -no-implicit-module -test-spirv-roundtrip -split-input-file %s | FileCheck %s
 
-spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
+// RUN: %if spirv-tools %{ rm -rf %t %}
+// RUN: %if spirv-tools %{ mkdir %t %}
+// RUN: %if spirv-tools %{ mlir-translate --no-implicit-module --serialize-spirv --split-input-file --spirv-save-validation-files-with-prefix=%t/module %s %}
+// RUN: %if spirv-tools %{ spirv-val %t %}
+
+spirv.module Logical OpenCL requires #spirv.vce<v1.0, [Kernel], []> {
   spirv.func @noop() -> () "None" {
     spirv.Return
   }
-  // CHECK:      spirv.EntryPoint "GLCompute" @noop
+  // CHECK:      spirv.EntryPoint "Kernel" @noop
   // CHECK-NEXT: spirv.ExecutionMode @noop "ContractionOff"
-  spirv.EntryPoint "GLCompute" @noop
+  spirv.EntryPoint "Kernel" @noop
   spirv.ExecutionMode @noop "ContractionOff"
 }
 
@@ -15,13 +20,13 @@ spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
 spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
   // CHECK:       spirv.GlobalVariable @var2 : !spirv.ptr<f32, Input>
   // CHECK-NEXT:  spirv.GlobalVariable @var3 : !spirv.ptr<f32, Output>
-  // CHECK-NEXT:  spirv.func @noop({{%.*}}: !spirv.ptr<f32, Input>, {{%.*}}: !spirv.ptr<f32, Output>) "None"
+  // CHECK-NEXT:  spirv.func @noop() "None"
   // CHECK:       spirv.EntryPoint "GLCompute" @noop, @var2, @var3
   spirv.GlobalVariable @var2 : !spirv.ptr<f32, Input>
   spirv.GlobalVariable @var3 : !spirv.ptr<f32, Output>
-  spirv.func @noop(%arg0 : !spirv.ptr<f32, Input>, %arg1 : !spirv.ptr<f32, Output>) -> () "None" {
+  spirv.func @noop() -> () "None" {
     spirv.Return
   }
   spirv.EntryPoint "GLCompute" @noop, @var2, @var3
-  spirv.ExecutionMode @noop "ContractionOff"
+  spirv.ExecutionMode @noop "LocalSize", 1, 1, 1
 }
diff --git a/mlir/test/Target/SPIRV/logical-ops.mlir b/mlir/test/Target/SPIRV/logical-ops.mlir
index 05cbddc048151..d570815448b7c 100644
--- a/mlir/test/Target/SPIRV/logical-ops.mlir
+++ b/mlir/test/Target/SPIRV/logical-ops.mlir
@@ -1,6 +1,11 @@
 // RUN: mlir-translate -no-implicit-module -split-input-file -test-spirv-roundtrip %s | FileCheck %s
 
-spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
+// RUN: %if spirv-tools %{ rm -rf %t %}
+// RUN: %if spirv-tools %{ mkdir %t %}
+// RUN: %if spirv-tools %{ mlir-translate --no-implicit-module --serialize-spirv --split-input-file --spirv-save-validation-files-with-prefix=%t/module %s %}
+// RUN: %if spirv-tools %{ spirv-val %t %}
+
+spirv.module Logical OpenCL requires #spirv.vce<v1.0, [Kernel, Linkage], []> {
   spirv.func @iequal_scalar(%arg0: i32, %arg1: i32)  "None" {
     // CHECK: {{.*}} = spirv.IEqual {{.*}}, {{.*}} : i32
     %0 = spirv.IEqual %arg0, %arg1 : i32
@@ -92,7 +97,7 @@ spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
 
 // -----
 
-spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
+spirv.module Logical GLSL450 requires #spirv.vce<v1.4, [Shader, Linkage], []> {
   spirv.SpecConstant @condition_scalar = true
   spirv.func @select() -> () "None" {
     %0 = spirv.Constant 4.0 : f32
@@ -115,7 +120,7 @@ spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
 
 // Test select works with bf16 scalar and vectors.
 
-spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
+spirv.module Logical GLSL450 requires #spirv.vce<v1.4, [Shader, Linkage, BFloat16TypeKHR], [SPV_KHR_bfloat16]> {
   spirv.SpecConstant @condition_scalar = true
   spirv.func @select_bf16() -> () "None" {
     %0 = spirv.Constant 4.0 : bf16
diff --git a/mlir/test/Target/SPIRV/sampled-image.mlir b/mlir/test/Target/SPIRV/sampled-image.mlir
index 694862d943534..ff068208540f4 100644
--- a/mlir/test/Target/SPIRV/sampled-image.mlir
+++ b/mlir/test/Target/SPIRV/sampled-image.mlir
@@ -1,11 +1,16 @@
 // RUN: mlir-translate -no-implicit-module -test-spirv-roundtrip %s | FileCheck %s
 
-spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
-  // CHECK: !spirv.ptr<!spirv.sampled_image<!spirv.image<f32, Dim1D, NoDepth, NonArrayed, SingleSampled, NoSampler, Unknown>>, UniformConstant>
-  spirv.GlobalVariable @var0 bind(0, 1) : !spirv.ptr<!spirv.sampled_image<!spirv.image<f32, Dim1D, NoDepth, NonArrayed, SingleSampled, NoSampler, Unknown>>, UniformConstant>
+// RUN: %if spirv-tools %{ rm -rf %t %}
+// RUN: %if spirv-tools %{ mkdir %t %}
+// RUN: %if spirv-tools %{ mlir-translate --no-implicit-module --serialize-spirv --split-input-file --spirv-save-validation-files-with-prefix=%t/module %s %}
+// RUN: %if spirv-tools %{ spirv-val %t %}
 
-  // CHECK: !spirv.ptr<!spirv.sampled_image<!spirv.image<si32, SubpassData, DepthUnknown, Arrayed, MultiSampled, NoSampler, Unknown>>, UniformConstant>
-  spirv.GlobalVariable @var1 bind(0, 0) : !spirv.ptr<!spirv.sampled_image<!spirv.image<si32, SubpassData, DepthUnknown, Arrayed, MultiSampled, NoSampler, Unknown>>, UniformConstant>
+spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader, Sampled1D, SampledRect, StorageImageExtendedFormats, Linkage], []> {
+  // CHECK: !spirv.ptr<!spirv.sampled_image<!spirv.image<f32, Dim1D, NoDepth, NonArrayed, SingleSampled, NeedSampler, Unknown>>, UniformConstant>
+  spirv.GlobalVariable @var0 bind(0, 1) : !spirv.ptr<!spirv.sampled_image<!spirv.image<f32, Dim1D, NoDepth, NonArrayed, SingleSampled, NeedSampler, Unknown>>, UniformConstant>
+
+  // CHECK: !spirv.ptr<!spirv.sampled_image<!spirv.image<si32, Cube, DepthUnknown, Arrayed, MultiSampled, NeedSampler, Unknown>>, UniformConstant>
+  spirv.GlobalVariable @var1 bind(0, 0) : !spirv.ptr<!spirv.sampled_image<!spirv.image<si32, Cube, DepthUnknown, Arrayed, MultiSampled, NeedSampler, Unknown>>, UniformConstant>
 
   // CHECK: !spirv.ptr<!spirv.sampled_image<!spirv.image<i32, Rect, DepthUnknown, Arrayed, MultiSampled, NeedSampler, R8ui>>, UniformConstant>
   spirv.GlobalVariable @var2 bind(0, 0) : !spirv.ptr<!spirv.sampled_image<!spirv.image<i32, Rect, DepthUnknown, Arrayed, MultiSampled, NeedSampler, R8ui>>, UniformConstant>

``````````

</details>


https://github.com/llvm/llvm-project/pull/159376


More information about the Mlir-commits mailing list