1// RUN: mlir-translate -split-input-file -test-spirv-roundtrip %s | FileCheck %s
2
3spv.module Logical GLSL450 requires #spv.vce<v1.0, [Shader], []> {
4  spv.func @iequal_scalar(%arg0: i32, %arg1: i32)  "None" {
5    // CHECK: {{.*}} = spv.IEqual {{.*}}, {{.*}} : i32
6    %0 = spv.IEqual %arg0, %arg1 : i32
7    spv.Return
8  }
9  spv.func @inotequal_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) "None" {
10    // CHECK: {{.*}} = spv.INotEqual {{.*}}, {{.*}} : vector<4xi32>
11    %0 = spv.INotEqual %arg0, %arg1 : vector<4xi32>
12    spv.Return
13  }
14  spv.func @sgt_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) "None" {
15    // CHECK: {{.*}} = spv.SGreaterThan {{.*}}, {{.*}} : vector<4xi32>
16    %0 = spv.SGreaterThan %arg0, %arg1 : vector<4xi32>
17    spv.Return
18  }
19  spv.func @sge_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) "None" {
20    // CHECK: {{.*}} = spv.SGreaterThanEqual {{.*}}, {{.*}} : vector<4xi32>
21    %0 = spv.SGreaterThanEqual %arg0, %arg1 : vector<4xi32>
22    spv.Return
23  }
24  spv.func @slt_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) "None" {
25    // CHECK: {{.*}} = spv.SLessThan {{.*}}, {{.*}} : vector<4xi32>
26    %0 = spv.SLessThan %arg0, %arg1 : vector<4xi32>
27    spv.Return
28  }
29  spv.func @slte_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) "None" {
30    // CHECK: {{.*}} = spv.SLessThanEqual {{.*}}, {{.*}} : vector<4xi32>
31    %0 = spv.SLessThanEqual %arg0, %arg1 : vector<4xi32>
32    spv.Return
33  }
34  spv.func @ugt_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) "None" {
35    // CHECK: {{.*}} = spv.UGreaterThan {{.*}}, {{.*}} : vector<4xi32>
36    %0 = spv.UGreaterThan %arg0, %arg1 : vector<4xi32>
37    spv.Return
38  }
39  spv.func @ugte_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) "None" {
40    // CHECK: {{.*}} = spv.UGreaterThanEqual {{.*}}, {{.*}} : vector<4xi32>
41    %0 = spv.UGreaterThanEqual %arg0, %arg1 : vector<4xi32>
42    spv.Return
43  }
44  spv.func @ult_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) "None" {
45    // CHECK: {{.*}} = spv.ULessThan {{.*}}, {{.*}} : vector<4xi32>
46    %0 = spv.ULessThan %arg0, %arg1 : vector<4xi32>
47    spv.Return
48  }
49  spv.func @ulte_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>)  "None" {
50    // CHECK: {{.*}} = spv.ULessThanEqual {{.*}}, {{.*}} : vector<4xi32>
51    %0 = spv.ULessThanEqual %arg0, %arg1 : vector<4xi32>
52    spv.Return
53  }
54  spv.func @cmpf(%arg0 : f32, %arg1 : f32) "None" {
55    // CHECK: spv.FOrdEqual
56    %1 = spv.FOrdEqual %arg0, %arg1 : f32
57    // CHECK: spv.FOrdGreaterThan
58    %2 = spv.FOrdGreaterThan %arg0, %arg1 : f32
59    // CHECK: spv.FOrdGreaterThanEqual
60    %3 = spv.FOrdGreaterThanEqual %arg0, %arg1 : f32
61    // CHECK: spv.FOrdLessThan
62    %4 = spv.FOrdLessThan %arg0, %arg1 : f32
63    // CHECK: spv.FOrdLessThanEqual
64    %5 = spv.FOrdLessThanEqual %arg0, %arg1 : f32
65    // CHECK: spv.FOrdNotEqual
66    %6 = spv.FOrdNotEqual %arg0, %arg1 : f32
67    // CHECK: spv.FUnordEqual
68    %7 = spv.FUnordEqual %arg0, %arg1 : f32
69    // CHECK: spv.FUnordGreaterThan
70    %8 = spv.FUnordGreaterThan %arg0, %arg1 : f32
71    // CHECK: spv.FUnordGreaterThanEqual
72    %9 = spv.FUnordGreaterThanEqual %arg0, %arg1 : f32
73    // CHECK: spv.FUnordLessThan
74    %10 = spv.FUnordLessThan %arg0, %arg1 : f32
75    // CHECK: spv.FUnordLessThanEqual
76    %11 = spv.FUnordLessThanEqual %arg0, %arg1 : f32
77    // CHECK: spv.FUnordNotEqual
78    %12 = spv.FUnordNotEqual %arg0, %arg1 : f32
79    spv.Return
80  }
81}
82
83// -----
84
85spv.module Logical GLSL450 requires #spv.vce<v1.0, [Shader], []> {
86  spv.specConstant @condition_scalar = true
87  spv.func @select() -> () "None" {
88    %0 = spv.constant 4.0 : f32
89    %1 = spv.constant 5.0 : f32
90    %2 = spv.mlir.referenceof @condition_scalar : i1
91    // CHECK: spv.Select {{.*}}, {{.*}}, {{.*}} : i1, f32
92    %3 = spv.Select %2, %0, %1 : i1, f32
93    %4 = spv.constant dense<[2.0, 3.0, 4.0, 5.0]> : vector<4xf32>
94    %5 = spv.constant dense<[6.0, 7.0, 8.0, 9.0]> : vector<4xf32>
95    // CHECK: spv.Select {{.*}}, {{.*}}, {{.*}} : i1, vector<4xf32>
96    %6 = spv.Select %2, %4, %5 : i1, vector<4xf32>
97    %7 = spv.constant dense<[true, true, true, true]> : vector<4xi1>
98    // CHECK: spv.Select {{.*}}, {{.*}}, {{.*}} : vector<4xi1>, vector<4xf32>
99    %8 = spv.Select %7, %4, %5 : vector<4xi1>, vector<4xf32>
100    spv.Return
101  }
102}
103