xref: /llvm-project/llvm/test/CodeGen/SPIRV/transcoding/RelationalOperators.ll (revision 4bd9d98bc2be3548418dc67accc662cbeb10a2e1)
1; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV
2
3; CHECK-SPIRV:      %[[#bool:]] = OpTypeBool
4; CHECK-SPIRV:      %[[#bool2:]] = OpTypeVector %[[#bool]] 2
5
6; CHECK-SPIRV:      OpFunction
7; CHECK-SPIRV-NEXT: %[[#A:]] = OpFunctionParameter %[[#]]
8; CHECK-SPIRV-NEXT: %[[#B:]] = OpFunctionParameter %[[#]]
9; CHECK-SPIRV:      %[[#]] = OpUGreaterThan %[[#bool2]] %[[#A]] %[[#B]]
10; CHECK-SPIRV:      OpFunctionEnd
11
12;; kernel void testUGreaterThan(uint2 a, uint2 b, global int2 *res) {
13;;   res[0] = a > b;
14;; }
15
16define dso_local spir_kernel void @testUGreaterThan(<2 x i32> noundef %a, <2 x i32> noundef %b, <2 x i32> addrspace(1)* nocapture noundef writeonly %res) local_unnamed_addr {
17entry:
18  %cmp = icmp ugt <2 x i32> %a, %b
19  %sext = sext <2 x i1> %cmp to <2 x i32>
20  store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8
21  ret void
22}
23
24; CHECK-SPIRV:      OpFunction
25; CHECK-SPIRV-NEXT: %[[#A:]] = OpFunctionParameter %[[#]]
26; CHECK-SPIRV-NEXT: %[[#B:]] = OpFunctionParameter %[[#]]
27; CHECK-SPIRV:      %[[#]] = OpSGreaterThan %[[#bool2]] %[[#A]] %[[#B]]
28; CHECK-SPIRV:      OpFunctionEnd
29
30;; kernel void testSGreaterThan(int2 a, int2 b, global int2 *res) {
31;;   res[0] = a > b;
32;; }
33
34define dso_local spir_kernel void @testSGreaterThan(<2 x i32> noundef %a, <2 x i32> noundef %b, <2 x i32> addrspace(1)* nocapture noundef writeonly %res) local_unnamed_addr {
35entry:
36  %cmp = icmp sgt <2 x i32> %a, %b
37  %sext = sext <2 x i1> %cmp to <2 x i32>
38  store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8
39  ret void
40}
41
42; CHECK-SPIRV:      OpFunction
43; CHECK-SPIRV-NEXT: %[[#A:]] = OpFunctionParameter %[[#]]
44; CHECK-SPIRV-NEXT: %[[#B:]] = OpFunctionParameter %[[#]]
45; CHECK-SPIRV:      %[[#]] = OpUGreaterThanEqual %[[#bool2]] %[[#A]] %[[#B]]
46; CHECK-SPIRV:      OpFunctionEnd
47
48;; kernel void testUGreaterThanEqual(uint2 a, uint2 b, global int2 *res) {
49;;   res[0] = a >= b;
50;; }
51
52define dso_local spir_kernel void @testUGreaterThanEqual(<2 x i32> noundef %a, <2 x i32> noundef %b, <2 x i32> addrspace(1)* nocapture noundef writeonly %res) local_unnamed_addr {
53entry:
54  %cmp = icmp uge <2 x i32> %a, %b
55  %sext = sext <2 x i1> %cmp to <2 x i32>
56  store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8
57  ret void
58}
59
60; CHECK-SPIRV:      OpFunction
61; CHECK-SPIRV-NEXT: %[[#A:]] = OpFunctionParameter %[[#]]
62; CHECK-SPIRV-NEXT: %[[#B:]] = OpFunctionParameter %[[#]]
63; CHECK-SPIRV:      %[[#]] = OpSGreaterThanEqual %[[#bool2]] %[[#A]] %[[#B]]
64; CHECK-SPIRV:      OpFunctionEnd
65
66;; kernel void testSGreaterThanEqual(int2 a, int2 b, global int2 *res) {
67;;   res[0] = a >= b;
68;; }
69
70define dso_local spir_kernel void @testSGreaterThanEqual(<2 x i32> noundef %a, <2 x i32> noundef %b, <2 x i32> addrspace(1)* nocapture noundef writeonly %res) local_unnamed_addr {
71entry:
72  %cmp = icmp sge <2 x i32> %a, %b
73  %sext = sext <2 x i1> %cmp to <2 x i32>
74  store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8
75  ret void
76}
77
78; CHECK-SPIRV:      OpFunction
79; CHECK-SPIRV-NEXT: %[[#A:]] = OpFunctionParameter %[[#]]
80; CHECK-SPIRV-NEXT: %[[#B:]] = OpFunctionParameter %[[#]]
81; CHECK-SPIRV:      %[[#]] = OpULessThan %[[#bool2]] %[[#A]] %[[#B]]
82; CHECK-SPIRV:      OpFunctionEnd
83
84;; kernel void testULessThan(uint2 a, uint2 b, global int2 *res) {
85;;   res[0] = a < b;
86;; }
87
88define dso_local spir_kernel void @testULessThan(<2 x i32> noundef %a, <2 x i32> noundef %b, <2 x i32> addrspace(1)* nocapture noundef writeonly %res) local_unnamed_addr {
89entry:
90  %cmp = icmp ult <2 x i32> %a, %b
91  %sext = sext <2 x i1> %cmp to <2 x i32>
92  store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8
93  ret void
94}
95
96; CHECK-SPIRV:      OpFunction
97; CHECK-SPIRV-NEXT: %[[#A:]] = OpFunctionParameter %[[#]]
98; CHECK-SPIRV-NEXT: %[[#B:]] = OpFunctionParameter %[[#]]
99; CHECK-SPIRV:      %[[#]] = OpSLessThan %[[#bool2]] %[[#A]] %[[#B]]
100; CHECK-SPIRV:      OpFunctionEnd
101
102;; kernel void testSLessThan(int2 a, int2 b, global int2 *res) {
103;;   res[0] = a < b;
104;; }
105
106define dso_local spir_kernel void @testSLessThan(<2 x i32> noundef %a, <2 x i32> noundef %b, <2 x i32> addrspace(1)* nocapture noundef writeonly %res) local_unnamed_addr {
107entry:
108  %cmp = icmp slt <2 x i32> %a, %b
109  %sext = sext <2 x i1> %cmp to <2 x i32>
110  store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8
111  ret void
112}
113
114; CHECK-SPIRV:      OpFunction
115; CHECK-SPIRV-NEXT: %[[#A:]] = OpFunctionParameter %[[#]]
116; CHECK-SPIRV-NEXT: %[[#B:]] = OpFunctionParameter %[[#]]
117; CHECK-SPIRV:      %[[#]] = OpULessThanEqual %[[#bool2]] %[[#A]] %[[#B]]
118; CHECK-SPIRV:      OpFunctionEnd
119
120;; kernel void testULessThanEqual(uint2 a, uint2 b, global int2 *res) {
121;;   res[0] = a <= b;
122;; }
123
124define dso_local spir_kernel void @testULessThanEqual(<2 x i32> noundef %a, <2 x i32> noundef %b, <2 x i32> addrspace(1)* nocapture noundef writeonly %res) local_unnamed_addr {
125entry:
126  %cmp = icmp ule <2 x i32> %a, %b
127  %sext = sext <2 x i1> %cmp to <2 x i32>
128  store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8
129  ret void
130}
131
132; CHECK-SPIRV:      OpFunction
133; CHECK-SPIRV-NEXT: %[[#A:]] = OpFunctionParameter %[[#]]
134; CHECK-SPIRV-NEXT: %[[#B:]] = OpFunctionParameter %[[#]]
135; CHECK-SPIRV:      %[[#]] = OpSLessThanEqual %[[#bool2]] %[[#A]] %[[#B]]
136; CHECK-SPIRV:      OpFunctionEnd
137
138;; kernel void testSLessThanEqual(int2 a, int2 b, global int2 *res) {
139;;   res[0] = a <= b;
140;; }
141
142define dso_local spir_kernel void @testSLessThanEqual(<2 x i32> noundef %a, <2 x i32> noundef %b, <2 x i32> addrspace(1)* nocapture noundef writeonly %res) local_unnamed_addr {
143entry:
144  %cmp = icmp sle <2 x i32> %a, %b
145  %sext = sext <2 x i1> %cmp to <2 x i32>
146  store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8
147  ret void
148}
149
150; CHECK-SPIRV:      OpFunction
151; CHECK-SPIRV-NEXT: %[[#A:]] = OpFunctionParameter %[[#]]
152; CHECK-SPIRV-NEXT: %[[#B:]] = OpFunctionParameter %[[#]]
153; CHECK-SPIRV:      %[[#]] = OpFOrdEqual %[[#bool2]] %[[#A]] %[[#B]]
154; CHECK-SPIRV:      OpFunctionEnd
155
156;; kernel void testFOrdEqual(float2 a, float2 b, global int2 *res) {
157;;   res[0] = a == b;
158;; }
159
160define dso_local spir_kernel void @testFOrdEqual(<2 x float> noundef %a, <2 x float> noundef %b, <2 x i32> addrspace(1)* nocapture noundef writeonly %res) local_unnamed_addr {
161entry:
162  %cmp = fcmp oeq <2 x float> %a, %b
163  %sext = sext <2 x i1> %cmp to <2 x i32>
164  store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8
165  ret void
166}
167
168; CHECK-SPIRV:      OpFunction
169; CHECK-SPIRV-NEXT: %[[#A:]] = OpFunctionParameter %[[#]]
170; CHECK-SPIRV-NEXT: %[[#B:]] = OpFunctionParameter %[[#]]
171; CHECK-SPIRV:      %[[#]] = OpFUnordNotEqual %[[#bool2]] %[[#A]] %[[#B]]
172; CHECK-SPIRV:      OpFunctionEnd
173
174;; kernel void testFUnordNotEqual(float2 a, float2 b, global int2 *res) {
175;;   res[0] = a != b;
176;; }
177
178define dso_local spir_kernel void @testFUnordNotEqual(<2 x float> noundef %a, <2 x float> noundef %b, <2 x i32> addrspace(1)* nocapture noundef writeonly %res) local_unnamed_addr {
179entry:
180  %cmp = fcmp une <2 x float> %a, %b
181  %sext = sext <2 x i1> %cmp to <2 x i32>
182  store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8
183  ret void
184}
185
186; CHECK-SPIRV:      OpFunction
187; CHECK-SPIRV-NEXT: %[[#A:]] = OpFunctionParameter %[[#]]
188; CHECK-SPIRV-NEXT: %[[#B:]] = OpFunctionParameter %[[#]]
189; CHECK-SPIRV:      %[[#]] = OpFOrdGreaterThan %[[#bool2]] %[[#A]] %[[#B]]
190; CHECK-SPIRV:      OpFunctionEnd
191
192;; kernel void testFOrdGreaterThan(float2 a, float2 b, global int2 *res) {
193;;   res[0] = a > b;
194;; }
195
196define dso_local spir_kernel void @testFOrdGreaterThan(<2 x float> noundef %a, <2 x float> noundef %b, <2 x i32> addrspace(1)* nocapture noundef writeonly %res) local_unnamed_addr {
197entry:
198  %cmp = fcmp ogt <2 x float> %a, %b
199  %sext = sext <2 x i1> %cmp to <2 x i32>
200  store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8
201  ret void
202}
203
204; CHECK-SPIRV:      OpFunction
205; CHECK-SPIRV-NEXT: %[[#A:]] = OpFunctionParameter %[[#]]
206; CHECK-SPIRV-NEXT: %[[#B:]] = OpFunctionParameter %[[#]]
207; CHECK-SPIRV:      %[[#]] = OpFOrdGreaterThanEqual %[[#bool2]] %[[#A]] %[[#B]]
208; CHECK-SPIRV:      OpFunctionEnd
209
210;; kernel void testFOrdGreaterThanEqual(float2 a, float2 b, global int2 *res) {
211;;   res[0] = a >= b;
212;; }
213
214define dso_local spir_kernel void @testFOrdGreaterThanEqual(<2 x float> noundef %a, <2 x float> noundef %b, <2 x i32> addrspace(1)* nocapture noundef writeonly %res) local_unnamed_addr {
215entry:
216  %cmp = fcmp oge <2 x float> %a, %b
217  %sext = sext <2 x i1> %cmp to <2 x i32>
218  store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8
219  ret void
220}
221
222; CHECK-SPIRV:      OpFunction
223; CHECK-SPIRV-NEXT: %[[#A:]] = OpFunctionParameter %[[#]]
224; CHECK-SPIRV-NEXT: %[[#B:]] = OpFunctionParameter %[[#]]
225; CHECK-SPIRV:      %[[#]] = OpFOrdLessThan %[[#bool2]] %[[#A]] %[[#B]]
226; CHECK-SPIRV:      OpFunctionEnd
227
228;; kernel void testFOrdLessThan(float2 a, float2 b, global int2 *res) {
229;;   res[0] = a < b;
230;; }
231
232define dso_local spir_kernel void @testFOrdLessThan(<2 x float> noundef %a, <2 x float> noundef %b, <2 x i32> addrspace(1)* nocapture noundef writeonly %res) local_unnamed_addr {
233entry:
234  %cmp = fcmp olt <2 x float> %a, %b
235  %sext = sext <2 x i1> %cmp to <2 x i32>
236  store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8
237  ret void
238}
239
240; CHECK-SPIRV:      OpFunction
241; CHECK-SPIRV-NEXT: %[[#A:]] = OpFunctionParameter %[[#]]
242; CHECK-SPIRV-NEXT: %[[#B:]] = OpFunctionParameter %[[#]]
243; CHECK-SPIRV:      %[[#]] = OpFOrdLessThanEqual %[[#bool2]] %[[#A]] %[[#B]]
244; CHECK-SPIRV:      OpFunctionEnd
245
246;; kernel void testFOrdLessThanEqual(float2 a, float2 b, global int2 *res) {
247;;   res[0] = a <= b;
248;; }
249
250define dso_local spir_kernel void @testFOrdLessThanEqual(<2 x float> noundef %a, <2 x float> noundef %b, <2 x i32> addrspace(1)* nocapture noundef writeonly %res) local_unnamed_addr {
251entry:
252  %cmp = fcmp ole <2 x float> %a, %b
253  %sext = sext <2 x i1> %cmp to <2 x i32>
254  store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8
255  ret void
256}
257