Debian Codegraph @

llvm/test/CodeGen/SPIRV/hlsl-intrinsics/imad.ll

raw
1 ; RUN: llc -O0 -verify-machineinstrs -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s
2 ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val %}
3
4 ; CHECK-DAG: %[[#int_16:]] = OpTypeInt 16 0
5 ; CHECK-DAG: %[[#vec2_16:]] = OpTypeVector %[[#int_16]] 2
6 ; CHECK-DAG: %[[#vec3_16:]] = OpTypeVector %[[#int_16]] 3
7 ; CHECK-DAG: %[[#vec4_16:]] = OpTypeVector %[[#int_16]] 4
8 ; CHECK-DAG: %[[#int_32:]] = OpTypeInt 32 0
9 ; CHECK-DAG: %[[#vec2_32:]] = OpTypeVector %[[#int_32]] 2
10 ; CHECK-DAG: %[[#vec3_32:]] = OpTypeVector %[[#int_32]] 3
11 ; CHECK-DAG: %[[#vec4_32:]] = OpTypeVector %[[#int_32]] 4
12 ; CHECK-DAG: %[[#int_64:]] = OpTypeInt 64 0
13 ; CHECK-DAG: %[[#vec2_64:]] = OpTypeVector %[[#int_64]] 2
14 ; CHECK-DAG: %[[#vec3_64:]] = OpTypeVector %[[#int_64]] 3
15 ; CHECK-DAG: %[[#vec4_64:]] = OpTypeVector %[[#int_64]] 4
16
17 define spir_func noundef i16 @test_mad_uint16_t(i16 noundef %p0, i16 noundef %p1, i16 noundef %p2) {
18 entry:
19 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]
20 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]
21 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]
22 ; CHECK: %[[#mul:]] = OpIMul %[[#int_16]] %[[#arg0]] %[[#arg1]]
23 ; CHECK: OpIAdd %[[#int_16]] %[[#mul]] %[[#arg2]]
24 %3 = mul nuw i16 %p0, %p1
25 %4 = add nuw i16 %3, %p2
26 ret i16 %4
27 }
28
29 define spir_func noundef <2 x i16> @test_mad_uint16_t2(<2 x i16> noundef %p0, <2 x i16> noundef %p1, <2 x i16> noundef %p2) {
30 entry:
31 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]
32 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]
33 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]
34 ; CHECK: %[[#mul:]] = OpIMul %[[#vec2_16]] %[[#arg0]] %[[#arg1]]
35 ; CHECK: OpIAdd %[[#vec2_16]] %[[#mul]] %[[#arg2]]
36 %3 = mul nuw <2 x i16> %p0, %p1
37 %4 = add nuw <2 x i16> %3, %p2
38 ret <2 x i16> %4
39 }
40
41 define spir_func noundef <3 x i16> @test_mad_uint16_t3(<3 x i16> noundef %p0, <3 x i16> noundef %p1, <3 x i16> noundef %p2) {
42 entry:
43 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]
44 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]
45 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]
46 ; CHECK: %[[#mul:]] = OpIMul %[[#vec3_16]] %[[#arg0]] %[[#arg1]]
47 ; CHECK: OpIAdd %[[#vec3_16]] %[[#mul]] %[[#arg2]]
48 %3 = mul nuw <3 x i16> %p0, %p1
49 %4 = add nuw <3 x i16> %3, %p2
50 ret <3 x i16> %4
51 }
52
53 define spir_func noundef <4 x i16> @test_mad_uint16_t4(<4 x i16> noundef %p0, <4 x i16> noundef %p1, <4 x i16> noundef %p2) {
54 entry:
55 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]
56 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]
57 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]
58 ; CHECK: %[[#mul:]] = OpIMul %[[#vec4_16]] %[[#arg0]] %[[#arg1]]
59 ; CHECK: OpIAdd %[[#vec4_16]] %[[#mul]] %[[#arg2]]
60 %3 = mul nuw <4 x i16> %p0, %p1
61 %4 = add nuw <4 x i16> %3, %p2
62 ret <4 x i16> %4
63 }
64
65 define spir_func noundef i16 @test_mad_int16_t(i16 noundef %p0, i16 noundef %p1, i16 noundef %p2) {
66 entry:
67 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]
68 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]
69 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]
70 ; CHECK: %[[#mul:]] = OpIMul %[[#int_16]] %[[#arg0]] %[[#arg1]]
71 ; CHECK: OpIAdd %[[#int_16]] %[[#mul]] %[[#arg2]]
72 %3 = mul nsw i16 %p0, %p1
73 %4 = add nsw i16 %3, %p2
74 ret i16 %4
75 }
76
77 define spir_func noundef <2 x i16> @test_mad_int16_t2(<2 x i16> noundef %p0, <2 x i16> noundef %p1, <2 x i16> noundef %p2) {
78 entry:
79 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]
80 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]
81 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]
82 ; CHECK: %[[#mul:]] = OpIMul %[[#vec2_16]] %[[#arg0]] %[[#arg1]]
83 ; CHECK: OpIAdd %[[#vec2_16]] %[[#mul]] %[[#arg2]]
84 %3 = mul nsw <2 x i16> %p0, %p1
85 %4 = add nsw <2 x i16> %3, %p2
86 ret <2 x i16> %4
87 }
88
89 define spir_func noundef <3 x i16> @test_mad_int16_t3(<3 x i16> noundef %p0, <3 x i16> noundef %p1, <3 x i16> noundef %p2) {
90 entry:
91 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]
92 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]
93 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]
94 ; CHECK: %[[#mul:]] = OpIMul %[[#vec3_16]] %[[#arg0]] %[[#arg1]]
95 ; CHECK: OpIAdd %[[#vec3_16]] %[[#mul]] %[[#arg2]]
96 %3 = mul nsw <3 x i16> %p0, %p1
97 %4 = add nsw <3 x i16> %3, %p2
98 ret <3 x i16> %4
99 }
100
101 define spir_func noundef <4 x i16> @test_mad_int16_t4(<4 x i16> noundef %p0, <4 x i16> noundef %p1, <4 x i16> noundef %p2) {
102 entry:
103 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]
104 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]
105 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]
106 ; CHECK: %[[#mul:]] = OpIMul %[[#vec4_16]] %[[#arg0]] %[[#arg1]]
107 ; CHECK: OpIAdd %[[#vec4_16]] %[[#mul]] %[[#arg2]]
108 %3 = mul nsw <4 x i16> %p0, %p1
109 %4 = add nsw <4 x i16> %3, %p2
110 ret <4 x i16> %4
111 }
112 define spir_func noundef i32 @test_mad_int(i32 noundef %p0, i32 noundef %p1, i32 noundef %p2) {
113 entry:
114 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]
115 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]
116 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]
117 ; CHECK: %[[#mul:]] = OpIMul %[[#int_32]] %[[#arg0]] %[[#arg1]]
118 ; CHECK: OpIAdd %[[#int_32]] %[[#mul]] %[[#arg2]]
119 %3 = mul nsw i32 %p0, %p1
120 %4 = add nsw i32 %3, %p2
121 ret i32 %4
122 }
123
124 define spir_func noundef <2 x i32> @test_mad_int2(<2 x i32> noundef %p0, <2 x i32> noundef %p1, <2 x i32> noundef %p2) {
125 entry:
126 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]
127 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]
128 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]
129 ; CHECK: %[[#mul:]] = OpIMul %[[#vec2_32]] %[[#arg0]] %[[#arg1]]
130 ; CHECK: OpIAdd %[[#vec2_32]] %[[#mul]] %[[#arg2]]
131 %3 = mul nsw <2 x i32> %p0, %p1
132 %4 = add nsw <2 x i32> %3, %p2
133 ret <2 x i32> %4
134 }
135
136 define spir_func noundef <3 x i32> @test_mad_int3(<3 x i32> noundef %p0, <3 x i32> noundef %p1, <3 x i32> noundef %p2) {
137 entry:
138 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]
139 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]
140 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]
141 ; CHECK: %[[#mul:]] = OpIMul %[[#vec3_32]] %[[#arg0]] %[[#arg1]]
142 ; CHECK: OpIAdd %[[#vec3_32]] %[[#mul]] %[[#arg2]]
143 %3 = mul nsw <3 x i32> %p0, %p1
144 %4 = add nsw <3 x i32> %3, %p2
145 ret <3 x i32> %4
146 }
147
148 define spir_func noundef <4 x i32> @test_mad_int4(<4 x i32> noundef %p0, <4 x i32> noundef %p1, <4 x i32> noundef %p2) {
149 entry:
150 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]
151 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]
152 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]
153 ; CHECK: %[[#mul:]] = OpIMul %[[#vec4_32]] %[[#arg0]] %[[#arg1]]
154 ; CHECK: OpIAdd %[[#vec4_32]] %[[#mul]] %[[#arg2]]
155 %3 = mul nsw <4 x i32> %p0, %p1
156 %4 = add nsw <4 x i32> %3, %p2
157 ret <4 x i32> %4
158 }
159
160 define spir_func noundef i64 @test_mad_int64_t(i64 noundef %p0, i64 noundef %p1, i64 noundef %p2) {
161 entry:
162 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]
163 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]
164 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]
165 ; CHECK: %[[#mul:]] = OpIMul %[[#int_64]] %[[#arg0]] %[[#arg1]]
166 ; CHECK: OpIAdd %[[#int_64]] %[[#mul]] %[[#arg2]]
167 %3 = mul nsw i64 %p0, %p1
168 %4 = add nsw i64 %3, %p2
169 ret i64 %4
170 }
171
172 define spir_func noundef <2 x i64> @test_mad_int64_t2(<2 x i64> noundef %p0, <2 x i64> noundef %p1, <2 x i64> noundef %p2) {
173 entry:
174 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]
175 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]
176 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]
177 ; CHECK: %[[#mul:]] = OpIMul %[[#vec2_64]] %[[#arg0]] %[[#arg1]]
178 ; CHECK: OpIAdd %[[#vec2_64]] %[[#mul]] %[[#arg2]]
179 %3 = mul nsw <2 x i64> %p0, %p1
180 %4 = add nsw <2 x i64> %3, %p2
181 ret <2 x i64> %4
182 }
183
184 define spir_func noundef <3 x i64> @test_mad_int64_t3(<3 x i64> noundef %p0, <3 x i64> noundef %p1, <3 x i64> noundef %p2) {
185 entry:
186 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]
187 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]
188 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]
189 ; CHECK: %[[#mul:]] = OpIMul %[[#vec3_64]] %[[#arg0]] %[[#arg1]]
190 ; CHECK: OpIAdd %[[#vec3_64]] %[[#mul]] %[[#arg2]]
191 %3 = mul nsw <3 x i64> %p0, %p1
192 %4 = add nsw <3 x i64> %3, %p2
193 ret <3 x i64> %4
194 }
195
196 define spir_func noundef <4 x i64> @test_mad_int64_t4(<4 x i64> noundef %p0, <4 x i64> noundef %p1, <4 x i64> noundef %p2) {
197 entry:
198 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]
199 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]
200 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]
201 ; CHECK: %[[#mul:]] = OpIMul %[[#vec4_64]] %[[#arg0]] %[[#arg1]]
202 ; CHECK: OpIAdd %[[#vec4_64]] %[[#mul]] %[[#arg2]]
203 %3 = mul nsw <4 x i64> %p0, %p1
204 %4 = add nsw <4 x i64> %3, %p2
205 ret <4 x i64> %4
206 }
207
208 define spir_func noundef i32 @test_mad_uint(i32 noundef %p0, i32 noundef %p1, i32 noundef %p2) {
209 entry:
210 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]
211 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]
212 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]
213 ; CHECK: %[[#mul:]] = OpIMul %[[#int_32]] %[[#arg0]] %[[#arg1]]
214 ; CHECK: OpIAdd %[[#int_32]] %[[#mul]] %[[#arg2]]
215 %3 = mul nuw i32 %p0, %p1
216 %4 = add nuw i32 %3, %p2
217 ret i32 %4
218 }
219
220 define spir_func noundef <2 x i32> @test_mad_uint2(<2 x i32> noundef %p0, <2 x i32> noundef %p1, <2 x i32> noundef %p2) {
221 entry:
222 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]
223 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]
224 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]
225 ; CHECK: %[[#mul:]] = OpIMul %[[#vec2_32]] %[[#arg0]] %[[#arg1]]
226 ; CHECK: OpIAdd %[[#vec2_32]] %[[#mul]] %[[#arg2]]
227 %3 = mul nuw <2 x i32> %p0, %p1
228 %4 = add nuw <2 x i32> %3, %p2
229 ret <2 x i32> %4
230 }
231
232 define spir_func noundef <3 x i32> @test_mad_uint3(<3 x i32> noundef %p0, <3 x i32> noundef %p1, <3 x i32> noundef %p2) {
233 entry:
234 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]
235 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]
236 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]
237 ; CHECK: %[[#mul:]] = OpIMul %[[#vec3_32]] %[[#arg0]] %[[#arg1]]
238 ; CHECK: OpIAdd %[[#vec3_32]] %[[#mul]] %[[#arg2]]
239 %3 = mul nuw <3 x i32> %p0, %p1
240 %4 = add nuw <3 x i32> %3, %p2
241 ret <3 x i32> %4
242 }
243
244 define spir_func noundef <4 x i32> @test_mad_uint4(<4 x i32> noundef %p0, <4 x i32> noundef %p1, <4 x i32> noundef %p2) {
245 entry:
246 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]
247 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]
248 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]
249 ; CHECK: %[[#mul:]] = OpIMul %[[#vec4_32]] %[[#arg0]] %[[#arg1]]
250 ; CHECK: OpIAdd %[[#vec4_32]] %[[#mul]] %[[#arg2]]
251 %3 = mul nuw <4 x i32> %p0, %p1
252 %4 = add nuw <4 x i32> %3, %p2
253 ret <4 x i32> %4
254 }
255
256 define spir_func noundef i64 @test_mad_uint64_t(i64 noundef %p0, i64 noundef %p1, i64 noundef %p2) {
257 entry:
258 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]
259 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]
260 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]
261 ; CHECK: %[[#mul:]] = OpIMul %[[#int_64]] %[[#arg0]] %[[#arg1]]
262 ; CHECK: OpIAdd %[[#int_64]] %[[#mul]] %[[#arg2]]
263 %3 = mul nuw i64 %p0, %p1
264 %4 = add nuw i64 %3, %p2
265 ret i64 %4
266 }
267
268 define spir_func noundef <2 x i64> @test_mad_uint64_t2(<2 x i64> noundef %p0, <2 x i64> noundef %p1, <2 x i64> noundef %p2) {
269 entry:
270 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]
271 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]
272 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]
273 ; CHECK: %[[#mul:]] = OpIMul %[[#vec2_64]] %[[#arg0]] %[[#arg1]]
274 ; CHECK: OpIAdd %[[#vec2_64]] %[[#mul]] %[[#arg2]]
275 %3 = mul nuw <2 x i64> %p0, %p1
276 %4 = add nuw <2 x i64> %3, %p2
277 ret <2 x i64> %4
278 }
279
280 define spir_func noundef <3 x i64> @test_mad_uint64_t3(<3 x i64> noundef %p0, <3 x i64> noundef %p1, <3 x i64> noundef %p2) {
281 entry:
282 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]
283 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]
284 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]
285 ; CHECK: %[[#mul:]] = OpIMul %[[#vec3_64]] %[[#arg0]] %[[#arg1]]
286 ; CHECK: OpIAdd %[[#vec3_64]] %[[#mul]] %[[#arg2]]
287 %3 = mul nuw <3 x i64> %p0, %p1
288 %4 = add nuw <3 x i64> %3, %p2
289 ret <3 x i64> %4
290 }
291
292 define spir_func noundef <4 x i64> @test_mad_uint64_t4(<4 x i64> noundef %p0, <4 x i64> noundef %p1, <4 x i64> noundef %p2) {
293 entry:
294 ; CHECK: %[[#arg0:]] = OpFunctionParameter %[[#]]
295 ; CHECK: %[[#arg1:]] = OpFunctionParameter %[[#]]
296 ; CHECK: %[[#arg2:]] = OpFunctionParameter %[[#]]
297 ; CHECK: %[[#mul:]] = OpIMul %[[#vec4_64]] %[[#arg0]] %[[#arg1]]
298 ; CHECK: OpIAdd %[[#vec4_64]] %[[#mul]] %[[#arg2]]
299 %3 = mul nuw <4 x i64> %p0, %p1
300 %4 = add nuw <4 x i64> %3, %p2
301 ret <4 x i64> %4
302 }