aboutsummaryrefslogtreecommitdiff
path: root/llvm/test/CodeGen/SPIRV/transcoding/RelationalOperators.ll
blob: 7877b4ea8ac22a15e9c8ebbd96b4ec3c45678956 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV

; CHECK-SPIRV:      %[[#bool:]] = OpTypeBool
; CHECK-SPIRV:      %[[#bool2:]] = OpTypeVector %[[#bool]] 2

; CHECK-SPIRV:      OpFunction
; CHECK-SPIRV-NEXT: %[[#A:]] = OpFunctionParameter %[[#]]
; CHECK-SPIRV-NEXT: %[[#B:]] = OpFunctionParameter %[[#]]
; CHECK-SPIRV:      %[[#]] = OpUGreaterThan %[[#bool2]] %[[#A]] %[[#B]]
; CHECK-SPIRV:      OpFunctionEnd

;; kernel void testUGreaterThan(uint2 a, uint2 b, global int2 *res) {
;;   res[0] = a > b;
;; }

define 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 {
entry:
  %cmp = icmp ugt <2 x i32> %a, %b
  %sext = sext <2 x i1> %cmp to <2 x i32>
  store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8
  ret void
}

; CHECK-SPIRV:      OpFunction
; CHECK-SPIRV-NEXT: %[[#A:]] = OpFunctionParameter %[[#]]
; CHECK-SPIRV-NEXT: %[[#B:]] = OpFunctionParameter %[[#]]
; CHECK-SPIRV:      %[[#]] = OpSGreaterThan %[[#bool2]] %[[#A]] %[[#B]]
; CHECK-SPIRV:      OpFunctionEnd

;; kernel void testSGreaterThan(int2 a, int2 b, global int2 *res) {
;;   res[0] = a > b;
;; }

define 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 {
entry:
  %cmp = icmp sgt <2 x i32> %a, %b
  %sext = sext <2 x i1> %cmp to <2 x i32>
  store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8
  ret void
}

; CHECK-SPIRV:      OpFunction
; CHECK-SPIRV-NEXT: %[[#A:]] = OpFunctionParameter %[[#]]
; CHECK-SPIRV-NEXT: %[[#B:]] = OpFunctionParameter %[[#]]
; CHECK-SPIRV:      %[[#]] = OpUGreaterThanEqual %[[#bool2]] %[[#A]] %[[#B]]
; CHECK-SPIRV:      OpFunctionEnd

;; kernel void testUGreaterThanEqual(uint2 a, uint2 b, global int2 *res) {
;;   res[0] = a >= b;
;; }

define 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 {
entry:
  %cmp = icmp uge <2 x i32> %a, %b
  %sext = sext <2 x i1> %cmp to <2 x i32>
  store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8
  ret void
}

; CHECK-SPIRV:      OpFunction
; CHECK-SPIRV-NEXT: %[[#A:]] = OpFunctionParameter %[[#]]
; CHECK-SPIRV-NEXT: %[[#B:]] = OpFunctionParameter %[[#]]
; CHECK-SPIRV:      %[[#]] = OpSGreaterThanEqual %[[#bool2]] %[[#A]] %[[#B]]
; CHECK-SPIRV:      OpFunctionEnd

;; kernel void testSGreaterThanEqual(int2 a, int2 b, global int2 *res) {
;;   res[0] = a >= b;
;; }

define 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 {
entry:
  %cmp = icmp sge <2 x i32> %a, %b
  %sext = sext <2 x i1> %cmp to <2 x i32>
  store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8
  ret void
}

; CHECK-SPIRV:      OpFunction
; CHECK-SPIRV-NEXT: %[[#A:]] = OpFunctionParameter %[[#]]
; CHECK-SPIRV-NEXT: %[[#B:]] = OpFunctionParameter %[[#]]
; CHECK-SPIRV:      %[[#]] = OpULessThan %[[#bool2]] %[[#A]] %[[#B]]
; CHECK-SPIRV:      OpFunctionEnd

;; kernel void testULessThan(uint2 a, uint2 b, global int2 *res) {
;;   res[0] = a < b;
;; }

define 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 {
entry:
  %cmp = icmp ult <2 x i32> %a, %b
  %sext = sext <2 x i1> %cmp to <2 x i32>
  store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8
  ret void
}

; CHECK-SPIRV:      OpFunction
; CHECK-SPIRV-NEXT: %[[#A:]] = OpFunctionParameter %[[#]]
; CHECK-SPIRV-NEXT: %[[#B:]] = OpFunctionParameter %[[#]]
; CHECK-SPIRV:      %[[#]] = OpSLessThan %[[#bool2]] %[[#A]] %[[#B]]
; CHECK-SPIRV:      OpFunctionEnd

;; kernel void testSLessThan(int2 a, int2 b, global int2 *res) {
;;   res[0] = a < b;
;; }

define 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 {
entry:
  %cmp = icmp slt <2 x i32> %a, %b
  %sext = sext <2 x i1> %cmp to <2 x i32>
  store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8
  ret void
}

; CHECK-SPIRV:      OpFunction
; CHECK-SPIRV-NEXT: %[[#A:]] = OpFunctionParameter %[[#]]
; CHECK-SPIRV-NEXT: %[[#B:]] = OpFunctionParameter %[[#]]
; CHECK-SPIRV:      %[[#]] = OpULessThanEqual %[[#bool2]] %[[#A]] %[[#B]]
; CHECK-SPIRV:      OpFunctionEnd

;; kernel void testULessThanEqual(uint2 a, uint2 b, global int2 *res) {
;;   res[0] = a <= b;
;; }

define 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 {
entry:
  %cmp = icmp ule <2 x i32> %a, %b
  %sext = sext <2 x i1> %cmp to <2 x i32>
  store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8
  ret void
}

; CHECK-SPIRV:      OpFunction
; CHECK-SPIRV-NEXT: %[[#A:]] = OpFunctionParameter %[[#]]
; CHECK-SPIRV-NEXT: %[[#B:]] = OpFunctionParameter %[[#]]
; CHECK-SPIRV:      %[[#]] = OpSLessThanEqual %[[#bool2]] %[[#A]] %[[#B]]
; CHECK-SPIRV:      OpFunctionEnd

;; kernel void testSLessThanEqual(int2 a, int2 b, global int2 *res) {
;;   res[0] = a <= b;
;; }

define 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 {
entry:
  %cmp = icmp sle <2 x i32> %a, %b
  %sext = sext <2 x i1> %cmp to <2 x i32>
  store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8
  ret void
}

; CHECK-SPIRV:      OpFunction
; CHECK-SPIRV-NEXT: %[[#A:]] = OpFunctionParameter %[[#]]
; CHECK-SPIRV-NEXT: %[[#B:]] = OpFunctionParameter %[[#]]
; CHECK-SPIRV:      %[[#]] = OpFOrdEqual %[[#bool2]] %[[#A]] %[[#B]]
; CHECK-SPIRV:      OpFunctionEnd

;; kernel void testFOrdEqual(float2 a, float2 b, global int2 *res) {
;;   res[0] = a == b;
;; }

define 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 {
entry:
  %cmp = fcmp oeq <2 x float> %a, %b
  %sext = sext <2 x i1> %cmp to <2 x i32>
  store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8
  ret void
}

; CHECK-SPIRV:      OpFunction
; CHECK-SPIRV-NEXT: %[[#A:]] = OpFunctionParameter %[[#]]
; CHECK-SPIRV-NEXT: %[[#B:]] = OpFunctionParameter %[[#]]
; CHECK-SPIRV:      %[[#]] = OpFUnordNotEqual %[[#bool2]] %[[#A]] %[[#B]]
; CHECK-SPIRV:      OpFunctionEnd

;; kernel void testFUnordNotEqual(float2 a, float2 b, global int2 *res) {
;;   res[0] = a != b;
;; }

define 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 {
entry:
  %cmp = fcmp une <2 x float> %a, %b
  %sext = sext <2 x i1> %cmp to <2 x i32>
  store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8
  ret void
}

; CHECK-SPIRV:      OpFunction
; CHECK-SPIRV-NEXT: %[[#A:]] = OpFunctionParameter %[[#]]
; CHECK-SPIRV-NEXT: %[[#B:]] = OpFunctionParameter %[[#]]
; CHECK-SPIRV:      %[[#]] = OpFOrdGreaterThan %[[#bool2]] %[[#A]] %[[#B]]
; CHECK-SPIRV:      OpFunctionEnd

;; kernel void testFOrdGreaterThan(float2 a, float2 b, global int2 *res) {
;;   res[0] = a > b;
;; }

define 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 {
entry:
  %cmp = fcmp ogt <2 x float> %a, %b
  %sext = sext <2 x i1> %cmp to <2 x i32>
  store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8
  ret void
}

; CHECK-SPIRV:      OpFunction
; CHECK-SPIRV-NEXT: %[[#A:]] = OpFunctionParameter %[[#]]
; CHECK-SPIRV-NEXT: %[[#B:]] = OpFunctionParameter %[[#]]
; CHECK-SPIRV:      %[[#]] = OpFOrdGreaterThanEqual %[[#bool2]] %[[#A]] %[[#B]]
; CHECK-SPIRV:      OpFunctionEnd

;; kernel void testFOrdGreaterThanEqual(float2 a, float2 b, global int2 *res) {
;;   res[0] = a >= b;
;; }

define 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 {
entry:
  %cmp = fcmp oge <2 x float> %a, %b
  %sext = sext <2 x i1> %cmp to <2 x i32>
  store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8
  ret void
}

; CHECK-SPIRV:      OpFunction
; CHECK-SPIRV-NEXT: %[[#A:]] = OpFunctionParameter %[[#]]
; CHECK-SPIRV-NEXT: %[[#B:]] = OpFunctionParameter %[[#]]
; CHECK-SPIRV:      %[[#]] = OpFOrdLessThan %[[#bool2]] %[[#A]] %[[#B]]
; CHECK-SPIRV:      OpFunctionEnd

;; kernel void testFOrdLessThan(float2 a, float2 b, global int2 *res) {
;;   res[0] = a < b;
;; }

define 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 {
entry:
  %cmp = fcmp olt <2 x float> %a, %b
  %sext = sext <2 x i1> %cmp to <2 x i32>
  store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8
  ret void
}

; CHECK-SPIRV:      OpFunction
; CHECK-SPIRV-NEXT: %[[#A:]] = OpFunctionParameter %[[#]]
; CHECK-SPIRV-NEXT: %[[#B:]] = OpFunctionParameter %[[#]]
; CHECK-SPIRV:      %[[#]] = OpFOrdLessThanEqual %[[#bool2]] %[[#A]] %[[#B]]
; CHECK-SPIRV:      OpFunctionEnd

;; kernel void testFOrdLessThanEqual(float2 a, float2 b, global int2 *res) {
;;   res[0] = a <= b;
;; }

define 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 {
entry:
  %cmp = fcmp ole <2 x float> %a, %b
  %sext = sext <2 x i1> %cmp to <2 x i32>
  store <2 x i32> %sext, <2 x i32> addrspace(1)* %res, align 8
  ret void
}