Debian Codegraph @

llvm/test/CodeGen/SPIRV/opencl/clamp.ll

raw
1 ; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s
2 ; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s
3 ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}
4 ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %}
5
6 ; CHECK-DAG: %[[#op_ext:]] = OpExtInstImport "OpenCL.std"
7
8 ; CHECK-DAG: %[[#float_64:]] = OpTypeFloat 64
9 ; CHECK-DAG: %[[#float_32:]] = OpTypeFloat 32
10 ; CHECK-DAG: %[[#float_16:]] = OpTypeFloat 16
11
12 ; CHECK-DAG: %[[#int_64:]] = OpTypeInt 64
13 ; CHECK-DAG: %[[#int_32:]] = OpTypeInt 32
14 ; CHECK-DAG: %[[#int_16:]] = OpTypeInt 16
15
16 ; CHECK-DAG: %[[#vec4_float_64:]] = OpTypeVector %[[#float_64]] 4
17 ; CHECK-DAG: %[[#vec4_float_32:]] = OpTypeVector %[[#float_32]] 4
18 ; CHECK-DAG: %[[#vec4_float_16:]] = OpTypeVector %[[#float_16]] 4
19
20 ; CHECK-DAG: %[[#vec4_int_64:]] = OpTypeVector %[[#int_64]] 4
21 ; CHECK-DAG: %[[#vec4_int_32:]] = OpTypeVector %[[#int_32]] 4
22 ; CHECK-DAG: %[[#vec4_int_16:]] = OpTypeVector %[[#int_16]] 4
23
24 ; CHECK-LABEL: Begin function test_sclamp_i16
25 define noundef i16 @test_sclamp_i16(i16 noundef %a, i16 noundef %b, i16 noundef %c) {
26 entry:
27 ; CHECK: %[[#i16_arg0:]] = OpFunctionParameter %[[#int_16]]
28 ; CHECK: %[[#i16_arg1:]] = OpFunctionParameter %[[#int_16]]
29 ; CHECK: %[[#i16_arg2:]] = OpFunctionParameter %[[#int_16]]
30 ; CHECK: %[[#]] = OpExtInst %[[#int_16]] %[[#op_ext]] s_clamp %[[#i16_arg0]] %[[#i16_arg1]] %[[#i16_arg2]]
31 %0 = call i16 @llvm.spv.sclamp.i16(i16 %a, i16 %b, i16 %c)
32 ret i16 %0
33 }
34
35 ; CHECK-LABEL: Begin function test_sclamp_i32
36 define noundef i32 @test_sclamp_i32(i32 noundef %a, i32 noundef %b, i32 noundef %c) {
37 entry:
38 ; CHECK: %[[#i32_arg0:]] = OpFunctionParameter %[[#int_32]]
39 ; CHECK: %[[#i32_arg1:]] = OpFunctionParameter %[[#int_32]]
40 ; CHECK: %[[#i32_arg2:]] = OpFunctionParameter %[[#int_32]]
41 ; CHECK: %[[#]] = OpExtInst %[[#int_32]] %[[#op_ext]] s_clamp %[[#i32_arg0]] %[[#i32_arg1]] %[[#i32_arg2]]
42 %0 = call i32 @llvm.spv.sclamp.i32(i32 %a, i32 %b, i32 %c)
43 ret i32 %0
44 }
45
46 ; CHECK-LABEL: Begin function test_sclamp_i64
47 define noundef i64 @test_sclamp_i64(i64 noundef %a, i64 noundef %b, i64 noundef %c) {
48 entry:
49 ; CHECK: %[[#i64_arg0:]] = OpFunctionParameter %[[#int_64]]
50 ; CHECK: %[[#i64_arg1:]] = OpFunctionParameter %[[#int_64]]
51 ; CHECK: %[[#i64_arg2:]] = OpFunctionParameter %[[#int_64]]
52 ; CHECK: %[[#]] = OpExtInst %[[#int_64]] %[[#op_ext]] s_clamp %[[#i64_arg0]] %[[#i64_arg1]] %[[#i64_arg2]]
53 %0 = call i64 @llvm.spv.sclamp.i64(i64 %a, i64 %b, i64 %c)
54 ret i64 %0
55 }
56
57 ; CHECK-LABEL: Begin function test_nclamp_half
58 define noundef half @test_nclamp_half(half noundef %a, half noundef %b, half noundef %c) {
59 entry:
60 ; CHECK: %[[#f16_arg0:]] = OpFunctionParameter %[[#float_16]]
61 ; CHECK: %[[#f16_arg1:]] = OpFunctionParameter %[[#float_16]]
62 ; CHECK: %[[#f16_arg2:]] = OpFunctionParameter %[[#float_16]]
63 ; CHECK: %[[#]] = OpExtInst %[[#float_16]] %[[#op_ext]] fclamp %[[#f16_arg0]] %[[#f16_arg1]] %[[#f16_arg2]]
64 %0 = call half @llvm.spv.nclamp.f16(half %a, half %b, half %c)
65 ret half %0
66 }
67
68 ; CHECK-LABEL: Begin function test_nclamp_float
69 define noundef float @test_nclamp_float(float noundef %a, float noundef %b, float noundef %c) {
70 entry:
71 ; CHECK: %[[#f32_arg0:]] = OpFunctionParameter %[[#float_32]]
72 ; CHECK: %[[#f32_arg1:]] = OpFunctionParameter %[[#float_32]]
73 ; CHECK: %[[#f32_arg2:]] = OpFunctionParameter %[[#float_32]]
74 ; CHECK: %[[#]] = OpExtInst %[[#float_32]] %[[#op_ext]] fclamp %[[#f32_arg0]] %[[#f32_arg1]] %[[#f32_arg2]]
75 %0 = call float @llvm.spv.nclamp.f32(float %a, float %b, float %c)
76 ret float %0
77 }
78
79 ; CHECK-LABEL: Begin function test_nclamp_double
80 define noundef double @test_nclamp_double(double noundef %a, double noundef %b, double noundef %c) {
81 entry:
82 ; CHECK: %[[#f64_arg0:]] = OpFunctionParameter %[[#float_64]]
83 ; CHECK: %[[#f64_arg1:]] = OpFunctionParameter %[[#float_64]]
84 ; CHECK: %[[#f64_arg2:]] = OpFunctionParameter %[[#float_64]]
85 ; CHECK: %[[#]] = OpExtInst %[[#float_64]] %[[#op_ext]] fclamp %[[#f64_arg0]] %[[#f64_arg1]] %[[#f64_arg2]]
86 %0 = call double @llvm.spv.nclamp.f64(double %a, double %b, double %c)
87 ret double %0
88 }
89
90 ; CHECK-LABEL: Begin function test_uclamp_i16
91 define noundef i16 @test_uclamp_i16(i16 noundef %a, i16 noundef %b, i16 noundef %c) {
92 entry:
93 ; CHECK: %[[#i16_arg0:]] = OpFunctionParameter %[[#int_16]]
94 ; CHECK: %[[#i16_arg1:]] = OpFunctionParameter %[[#int_16]]
95 ; CHECK: %[[#i16_arg2:]] = OpFunctionParameter %[[#int_16]]
96 ; CHECK: %[[#]] = OpExtInst %[[#int_16]] %[[#op_ext]] u_clamp %[[#i16_arg0]] %[[#i16_arg1]] %[[#i16_arg2]]
97 %0 = call i16 @llvm.spv.uclamp.i16(i16 %a, i16 %b, i16 %c)
98 ret i16 %0
99 }
100
101 ; CHECK-LABEL: Begin function test_uclamp_i32
102 define noundef i32 @test_uclamp_i32(i32 noundef %a, i32 noundef %b, i32 noundef %c) {
103 entry:
104 ; CHECK: %[[#i32_arg0:]] = OpFunctionParameter %[[#int_32]]
105 ; CHECK: %[[#i32_arg1:]] = OpFunctionParameter %[[#int_32]]
106 ; CHECK: %[[#i32_arg2:]] = OpFunctionParameter %[[#int_32]]
107 ; CHECK: %[[#]] = OpExtInst %[[#int_32]] %[[#op_ext]] u_clamp %[[#i32_arg0]] %[[#i32_arg1]] %[[#i32_arg2]]
108 %0 = call i32 @llvm.spv.uclamp.i32(i32 %a, i32 %b, i32 %c)
109 ret i32 %0
110 }
111
112 ; CHECK-LABEL: Begin function test_uclamp_i64
113 define noundef i64 @test_uclamp_i64(i64 noundef %a, i64 noundef %b, i64 noundef %c) {
114 entry:
115 ; CHECK: %[[#i64_arg0:]] = OpFunctionParameter %[[#int_64]]
116 ; CHECK: %[[#i64_arg1:]] = OpFunctionParameter %[[#int_64]]
117 ; CHECK: %[[#i64_arg2:]] = OpFunctionParameter %[[#int_64]]
118 ; CHECK: %[[#]] = OpExtInst %[[#int_64]] %[[#op_ext]] u_clamp %[[#i64_arg0]] %[[#i64_arg1]] %[[#i64_arg2]]
119 %0 = call i64 @llvm.spv.uclamp.i64(i64 %a, i64 %b, i64 %c)
120 ret i64 %0
121 }
122
123 declare half @llvm.spv.nclamp.f16(half, half, half)
124 declare float @llvm.spv.nclamp.f32(float, float, float)
125 declare double @llvm.spv.nclamp.f64(double, double, double)
126 declare i16 @llvm.spv.sclamp.i16(i16, i16, i16)
127 declare i32 @llvm.spv.sclamp.i32(i32, i32, i32)
128 declare i64 @llvm.spv.sclamp.i64(i64, i64, i64)
129 declare i16 @llvm.spv.uclamp.i16(i16, i16, i16)
130 declare i32 @llvm.spv.uclamp.i32(i32, i32, i32)
131 declare i64 @llvm.spv.uclamp.i64(i64, i64, i64)
132
133 ; CHECK-LABEL: Begin function test_sclamp_v4i16
134 define noundef <4 x i16> @test_sclamp_v4i16(<4 x i16> noundef %a, <4 x i16> noundef %b, <4 x i16> noundef %c) {
135 entry:
136 ; CHECK: %[[#vec4_i16_arg0:]] = OpFunctionParameter %[[#vec4_int_16]]
137 ; CHECK: %[[#vec4_i16_arg1:]] = OpFunctionParameter %[[#vec4_int_16]]
138 ; CHECK: %[[#vec4_i16_arg2:]] = OpFunctionParameter %[[#vec4_int_16]]
139 ; CHECK: %[[#]] = OpExtInst %[[#vec4_int_16]] %[[#op_ext]] s_clamp %[[#vec4_i16_arg0]] %[[#vec4_i16_arg1]] %[[#vec4_i16_arg2]]
140 %0 = call <4 x i16> @llvm.spv.sclamp.v4i16(<4 x i16> %a, <4 x i16> %b, <4 x i16> %c)
141 ret <4 x i16> %0
142 }
143
144 ; CHECK-LABEL: Begin function test_sclamp_v4i32
145 define noundef <4 x i32> @test_sclamp_v4i32(<4 x i32> noundef %a, <4 x i32> noundef %b, <4 x i32> noundef %c) {
146 entry:
147 ; CHECK: %[[#vec4_i32_arg0:]] = OpFunctionParameter %[[#vec4_int_32]]
148 ; CHECK: %[[#vec4_i32_arg1:]] = OpFunctionParameter %[[#vec4_int_32]]
149 ; CHECK: %[[#vec4_i32_arg2:]] = OpFunctionParameter %[[#vec4_int_32]]
150 ; CHECK: %[[#]] = OpExtInst %[[#vec4_int_32]] %[[#op_ext]] s_clamp %[[#vec4_i32_arg0]] %[[#vec4_i32_arg1]] %[[#vec4_i32_arg2]]
151 %0 = call <4 x i32> @llvm.spv.sclamp.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c)
152 ret <4 x i32> %0
153 }
154
155 ; CHECK-LABEL: Begin function test_sclamp_v4i64
156 define noundef <4 x i64> @test_sclamp_v4i64(<4 x i64> noundef %a, <4 x i64> noundef %b, <4 x i64> noundef %c) {
157 entry:
158 ; CHECK: %[[#vec4_i64_arg0:]] = OpFunctionParameter %[[#vec4_int_64]]
159 ; CHECK: %[[#vec4_i64_arg1:]] = OpFunctionParameter %[[#vec4_int_64]]
160 ; CHECK: %[[#vec4_i64_arg2:]] = OpFunctionParameter %[[#vec4_int_64]]
161 ; CHECK: %[[#]] = OpExtInst %[[#vec4_int_64]] %[[#op_ext]] s_clamp %[[#vec4_i64_arg0]] %[[#vec4_i64_arg1]] %[[#vec4_i64_arg2]]
162 %0 = call <4 x i64> @llvm.spv.sclamp.v4i64(<4 x i64> %a, <4 x i64> %b, <4 x i64> %c)
163 ret <4 x i64> %0
164 }
165
166 ; CHECK-LABEL: Begin function test_nclamp_v4half
167 define noundef <4 x half> @test_nclamp_v4half(<4 x half> noundef %a, <4 x half> noundef %b, <4 x half> noundef %c) {
168 entry:
169 ; CHECK: %[[#vec4_f16_arg0:]] = OpFunctionParameter %[[#vec4_float_16]]
170 ; CHECK: %[[#vec4_f16_arg1:]] = OpFunctionParameter %[[#vec4_float_16]]
171 ; CHECK: %[[#vec4_f16_arg2:]] = OpFunctionParameter %[[#vec4_float_16]]
172 ; CHECK: %[[#]] = OpExtInst %[[#vec4_float_16]] %[[#op_ext]] fclamp %[[#vec4_f16_arg0]] %[[#vec4_f16_arg1]] %[[#vec4_f16_arg2]]
173 %0 = call <4 x half> @llvm.spv.nclamp.v4f16(<4 x half> %a, <4 x half> %b, <4 x half> %c)
174 ret <4 x half> %0
175 }
176
177 ; CHECK-LABEL: Begin function test_nclamp_v4float
178 define noundef <4 x float> @test_nclamp_v4float(<4 x float> noundef %a, <4 x float> noundef %b, <4 x float> noundef %c) {
179 entry:
180 ; CHECK: %[[#vec4_f32_arg0:]] = OpFunctionParameter %[[#vec4_float_32]]
181 ; CHECK: %[[#vec4_f32_arg1:]] = OpFunctionParameter %[[#vec4_float_32]]
182 ; CHECK: %[[#vec4_f32_arg2:]] = OpFunctionParameter %[[#vec4_float_32]]
183 ; CHECK: %[[#]] = OpExtInst %[[#vec4_float_32]] %[[#op_ext]] fclamp %[[#vec4_f32_arg0]] %[[#vec4_f32_arg1]] %[[#vec4_f32_arg2]]
184 %0 = call <4 x float> @llvm.spv.nclamp.v4f32(<4 x float> %a, <4 x float> %b, <4 x float> %c)
185 ret <4 x float> %0
186 }
187
188 ; CHECK-LABEL: Begin function test_nclamp_v4double
189 define noundef <4 x double> @test_nclamp_v4double(<4 x double> noundef %a, <4 x double> noundef %b, <4 x double> noundef %c) {
190 entry:
191 ; CHECK: %[[#vec4_f64_arg0:]] = OpFunctionParameter %[[#vec4_float_64]]
192 ; CHECK: %[[#vec4_f64_arg1:]] = OpFunctionParameter %[[#vec4_float_64]]
193 ; CHECK: %[[#vec4_f64_arg2:]] = OpFunctionParameter %[[#vec4_float_64]]
194 ; CHECK: %[[#]] = OpExtInst %[[#vec4_float_64]] %[[#op_ext]] fclamp %[[#vec4_f64_arg0]] %[[#vec4_f64_arg1]] %[[#vec4_f64_arg2]]
195 %0 = call <4 x double> @llvm.spv.nclamp.v4f64(<4 x double> %a, <4 x double> %b, <4 x double> %c)
196 ret <4 x double> %0
197 }
198
199 ; CHECK-LABEL: Begin function test_uclamp_v4i16
200 define noundef <4 x i16> @test_uclamp_v4i16(<4 x i16> noundef %a, <4 x i16> noundef %b, <4 x i16> noundef %c) {
201 entry:
202 ; CHECK: %[[#vec4_i16_arg0:]] = OpFunctionParameter %[[#vec4_int_16]]
203 ; CHECK: %[[#vec4_i16_arg1:]] = OpFunctionParameter %[[#vec4_int_16]]
204 ; CHECK: %[[#vec4_i16_arg2:]] = OpFunctionParameter %[[#vec4_int_16]]
205 ; CHECK: %[[#]] = OpExtInst %[[#vec4_int_16]] %[[#op_ext]] u_clamp %[[#vec4_i16_arg0]] %[[#vec4_i16_arg1]] %[[#vec4_i16_arg2]]
206 %0 = call <4 x i16> @llvm.spv.uclamp.v4i16(<4 x i16> %a, <4 x i16> %b, <4 x i16> %c)
207 ret <4 x i16> %0
208 }
209
210 ; CHECK-LABEL: Begin function test_uclamp_v4i32
211 define noundef <4 x i32> @test_uclamp_v4i32(<4 x i32> noundef %a, <4 x i32> noundef %b, <4 x i32> noundef %c) {
212 entry:
213 ; CHECK: %[[#vec4_i32_arg0:]] = OpFunctionParameter %[[#vec4_int_32]]
214 ; CHECK: %[[#vec4_i32_arg1:]] = OpFunctionParameter %[[#vec4_int_32]]
215 ; CHECK: %[[#vec4_i32_arg2:]] = OpFunctionParameter %[[#vec4_int_32]]
216 ; CHECK: %[[#]] = OpExtInst %[[#vec4_int_32]] %[[#op_ext]] u_clamp %[[#vec4_i32_arg0]] %[[#vec4_i32_arg1]] %[[#vec4_i32_arg2]]
217 %0 = call <4 x i32> @llvm.spv.uclamp.v4i32(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c)
218 ret <4 x i32> %0
219 }
220
221 ; CHECK-LABEL: Begin function test_uclamp_v4i64
222 define noundef <4 x i64> @test_uclamp_v4i64(<4 x i64> noundef %a, <4 x i64> noundef %b, <4 x i64> noundef %c) {
223 entry:
224 ; CHECK: %[[#vec4_i64_arg0:]] = OpFunctionParameter %[[#vec4_int_64]]
225 ; CHECK: %[[#vec4_i64_arg1:]] = OpFunctionParameter %[[#vec4_int_64]]
226 ; CHECK: %[[#vec4_i64_arg2:]] = OpFunctionParameter %[[#vec4_int_64]]
227 ; CHECK: %[[#]] = OpExtInst %[[#vec4_int_64]] %[[#op_ext]] u_clamp %[[#vec4_i64_arg0]] %[[#vec4_i64_arg1]] %[[#vec4_i64_arg2]]
228 %0 = call <4 x i64> @llvm.spv.uclamp.v4i64(<4 x i64> %a, <4 x i64> %b, <4 x i64> %c)
229 ret <4 x i64> %0
230 }
231
232 declare <4 x half> @llvm.spv.nclamp.v4f16(<4 x half>, <4 x half>, <4 x half>)
233 declare <4 x float> @llvm.spv.nclamp.v4f32(<4 x float>, <4 x float>, <4 x float>)
234 declare <4 x double> @llvm.spv.nclamp.v4f64(<4 x double>, <4 x double>, <4 x double>)
235 declare <4 x i16> @llvm.spv.sclamp.v4i16(<4 x i16>, <4 x i16>, <4 x i16>)
236 declare <4 x i32> @llvm.spv.sclamp.v4i32(<4 x i32>, <4 x i32>, <4 x i32>)
237 declare <4 x i64> @llvm.spv.sclamp.v4i64(<4 x i64>, <4 x i64>, <4 x i64>)
238 declare <4 x i16> @llvm.spv.uclamp.v4i16(<4 x i16>, <4 x i16>, <4 x i16>)
239 declare <4 x i32> @llvm.spv.uclamp.v4i32(<4 x i32>, <4 x i32>, <4 x i32>)
240 declare <4 x i64> @llvm.spv.uclamp.v4i64(<4 x i64>, <4 x i64>, <4 x i64>)
241
242