@@ -180,13 +180,14 @@ func.func @negative_not_elementwise() -> vector<2x2xf32> {
180
180
181
181
// -----
182
182
183
- // The source and the result for arith.cmp have different types - not supported
184
-
185
- // CHECK-LABEL: func.func @negative_source_and_result_mismatch
186
- // CHECK: %[[BROADCAST:.+]] = vector.broadcast
187
- // CHECK: %[[RETURN:.+]] = arith.cmpf uno, %[[BROADCAST]], %[[BROADCAST]]
188
- // CHECK: return %[[RETURN]]
189
- func.func @negative_source_and_result_mismatch (%arg0 : f32 , %arg1 : vector <1 xf32 >) -> vector <1 xi1 > {
183
+ // The source and the result for arith.cmp have different types
184
+
185
+ // CHECK-LABEL: func.func @source_and_result_mismatch(
186
+ // CHECK-SAME: %[[ARG0:.+]]: f32)
187
+ // CHECK: %[[COMPARE:.+]] = arith.cmpf uno, %[[ARG0]], %[[ARG0]]
188
+ // CHECK: %[[BROADCAST:.+]] = vector.broadcast %[[COMPARE]] : i1 to vector<1xi1>
189
+ // CHECK: return %[[BROADCAST]]
190
+ func.func @source_and_result_mismatch (%arg0 : f32 ) -> vector <1 xi1 > {
190
191
%0 = vector.broadcast %arg0 : f32 to vector <1 xf32 >
191
192
%1 = arith.cmpf uno , %0 , %0 : vector <1 xf32 >
192
193
return %1 : vector <1 xi1 >
@@ -210,53 +211,6 @@ func.func @negative_op_only_supports_vectors(%arg0 : f32) -> vector<1xf32> {
210
211
return %1 : vector <1 xf32 >
211
212
}
212
213
213
- //===----------------------------------------------------------------------===//
214
- // [Pattern: ReorderCastOpsOnBroadcast]
215
- //
216
- // Reorder casting ops and vector ops. The casting ops have almost identical
217
- // pattern, so only arith.extsi op is tested.
218
- //===----------------------------------------------------------------------===//
219
-
220
- // -----
221
-
222
- func.func @broadcast_vector_extsi (%a : vector <4 xi8 >) -> vector <2 x4 xi32 > {
223
- // CHECK: %[[EXT:.+]] = arith.extsi %{{.+}} : vector<4xi8> to vector<4xi32>
224
- // CHECK: vector.broadcast %[[EXT:.+]] : vector<4xi32> to vector<2x4xi32>
225
- %b = vector.broadcast %a : vector <4 xi8 > to vector <2 x4 xi8 >
226
- %r = arith.extsi %b : vector <2 x4 xi8 > to vector <2 x4 xi32 >
227
- return %r : vector <2 x4 xi32 >
228
- }
229
-
230
- // -----
231
-
232
- func.func @broadcast_vector_extsi_scalable (%a : vector <[4 ]xi8 >) -> vector <2 x[4 ]xi32 > {
233
- // CHECK: %[[EXT:.+]] = arith.extsi %{{.+}} : vector<[4]xi8> to vector<[4]xi32>
234
- // CHECK: vector.broadcast %[[EXT:.+]] : vector<[4]xi32> to vector<2x[4]xi32>
235
- %b = vector.broadcast %a : vector <[4 ]xi8 > to vector <2 x[4 ]xi8 >
236
- %r = arith.extsi %b : vector <2 x[4 ]xi8 > to vector <2 x[4 ]xi32 >
237
- return %r : vector <2 x[4 ]xi32 >
238
- }
239
-
240
- // -----
241
-
242
- func.func @broadcast_scalar_extsi (%a : i8 ) -> vector <2 x4 xi32 > {
243
- // CHECK: %[[EXT:.+]] = arith.extsi %{{.+}} : i8 to i32
244
- // CHECK: vector.broadcast %[[EXT]] : i32 to vector<2x4xi32>
245
- %b = vector.broadcast %a : i8 to vector <2 x4 xi8 >
246
- %r = arith.extsi %b : vector <2 x4 xi8 > to vector <2 x4 xi32 >
247
- return %r : vector <2 x4 xi32 >
248
- }
249
-
250
- // -----
251
-
252
- func.func @broadcast_scalar_extsi_scalable (%a : i8 ) -> vector <2 x[4 ]xi32 > {
253
- // CHECK: %[[EXT:.+]] = arith.extsi %{{.+}} : i8 to i32
254
- // CHECK: vector.broadcast %[[EXT]] : i32 to vector<2x[4]xi32>
255
- %b = vector.broadcast %a : i8 to vector <2 x[4 ]xi8 >
256
- %r = arith.extsi %b : vector <2 x[4 ]xi8 > to vector <2 x[4 ]xi32 >
257
- return %r : vector <2 x[4 ]xi32 >
258
- }
259
-
260
214
// -----
261
215
262
216
// CHECK-LABEL: func.func @broadcast_scalar_and_splat_const(
@@ -321,6 +275,113 @@ func.func @negative_broadcast_with_non_splat_const(%arg0: index) -> vector<1x4xi
321
275
return %2 : vector <1 x4 xindex >
322
276
}
323
277
278
+ // -----
279
+
280
+ // CHECK-LABEL: func.func @broadcast_scalar_mixed_type(
281
+ // CHECK-SAME: %[[ARG_0:.*]]: f16) -> vector<1x4xf32> {
282
+ // CHECK: %[[EXTF:.*]] = arith.extf %[[ARG_0]] : f16 to f32
283
+ // CHECK: %[[BCAST:.*]] = vector.broadcast %[[EXTF]] : f32 to vector<1x4xf32>
284
+ // CHECK: return %[[BCAST]] : vector<1x4xf32>
285
+
286
+ func.func @broadcast_scalar_mixed_type (%arg0: f16 ) -> vector <1 x4 xf32 > {
287
+ %0 = vector.broadcast %arg0 : f16 to vector <1 x4 xf16 >
288
+ %1 = arith.extf %0 : vector <1 x4 xf16 > to vector <1 x4 xf32 >
289
+ return %1 : vector <1 x4 xf32 >
290
+ }
291
+
292
+ // -----
293
+
294
+ // CHECK-LABEL: func.func @broadcast_vector_mixed_type(
295
+ // CHECK-SAME: %[[ARG_0:.*]]: vector<4xf16>) -> vector<3x4xf32> {
296
+ // CHECK: %[[EXTF:.*]] = arith.extf %[[ARG_0]] : vector<4xf16> to vector<4xf32>
297
+ // CHECK: %[[BCAST:.*]] = vector.broadcast %[[EXTF]] : vector<4xf32> to vector<3x4xf32>
298
+ // CHECK: return %[[BCAST]] : vector<3x4xf32>
299
+
300
+ func.func @broadcast_vector_mixed_type (%arg0: vector <4 xf16 >) -> vector <3 x4 xf32 > {
301
+ %0 = vector.broadcast %arg0 : vector <4 xf16 > to vector <3 x4 xf16 >
302
+ %1 = arith.extf %0 : vector <3 x4 xf16 > to vector <3 x4 xf32 >
303
+ return %1 : vector <3 x4 xf32 >
304
+ }
305
+
306
+ // -----
307
+
308
+ // CHECK-LABEL: func.func @broadcast_scalar_and_splat_const_mixed_type(
309
+ // CHECK-SAME: %[[ARG_0:.*]]: f32) -> vector<1x4xf32> {
310
+ // CHECK: %[[NEW_CST:.*]] = arith.constant 3 : i32
311
+ // CHECK: %[[POW:.*]] = math.fpowi %[[ARG_0]], %[[NEW_CST]] : f32, i32
312
+ // CHECK: %[[BCAST:.*]] = vector.broadcast %[[POW]] : f32 to vector<1x4xf32>
313
+ // CHECK: return %[[BCAST]] : vector<1x4xf32>
314
+
315
+ func.func @broadcast_scalar_and_splat_const_mixed_type (%arg0: f32 ) -> vector <1 x4 xf32 > {
316
+ %0 = vector.broadcast %arg0 : f32 to vector <1 x4 xf32 >
317
+ %cst = arith.constant dense <3 > : vector <1 x4 xi32 >
318
+ %2 = math.fpowi %0 , %cst : vector <1 x4 xf32 >, vector <1 x4 xi32 >
319
+ return %2 : vector <1 x4 xf32 >
320
+ }
321
+
322
+ // -----
323
+
324
+ // CHECK-LABEL: func.func @broadcast_vector_and_splat_const_mixed_type(
325
+ // CHECK-SAME: %[[ARG_0:.*]]: vector<4xf32>) -> vector<3x4xf32> {
326
+ // CHECK: %[[NEW_CST:.*]] = arith.constant dense<3> : vector<4xi32>
327
+ // CHECK: %[[POW:.*]] = math.fpowi %[[ARG_0]], %[[NEW_CST]] : vector<4xf32>, vector<4xi32>
328
+ // CHECK: %[[BCAST:.*]] = vector.broadcast %[[POW]] : vector<4xf32> to vector<3x4xf32>
329
+ // CHECK: return %[[BCAST]] : vector<3x4xf32>
330
+
331
+ func.func @broadcast_vector_and_splat_const_mixed_type (%arg0: vector <4 xf32 >) -> vector <3 x4 xf32 > {
332
+ %0 = vector.broadcast %arg0 : vector <4 xf32 > to vector <3 x4 xf32 >
333
+ %cst = arith.constant dense <3 > : vector <3 x4 xi32 >
334
+ %2 = math.fpowi %0 , %cst : vector <3 x4 xf32 >, vector <3 x4 xi32 >
335
+ return %2 : vector <3 x4 xf32 >
336
+ }
337
+
338
+ //===----------------------------------------------------------------------===//
339
+ // [Pattern: ReorderCastOpsOnBroadcast]
340
+ //
341
+ // Reorder casting ops and vector ops. The casting ops have almost identical
342
+ // pattern, so only arith.extsi op is tested.
343
+ //===----------------------------------------------------------------------===//
344
+
345
+ // -----
346
+
347
+ func.func @broadcast_vector_extsi (%a : vector <4 xi8 >) -> vector <2 x4 xi32 > {
348
+ // CHECK: %[[EXT:.+]] = arith.extsi %{{.+}} : vector<4xi8> to vector<4xi32>
349
+ // CHECK: vector.broadcast %[[EXT:.+]] : vector<4xi32> to vector<2x4xi32>
350
+ %b = vector.broadcast %a : vector <4 xi8 > to vector <2 x4 xi8 >
351
+ %r = arith.extsi %b : vector <2 x4 xi8 > to vector <2 x4 xi32 >
352
+ return %r : vector <2 x4 xi32 >
353
+ }
354
+
355
+ // -----
356
+
357
+ func.func @broadcast_vector_extsi_scalable (%a : vector <[4 ]xi8 >) -> vector <2 x[4 ]xi32 > {
358
+ // CHECK: %[[EXT:.+]] = arith.extsi %{{.+}} : vector<[4]xi8> to vector<[4]xi32>
359
+ // CHECK: vector.broadcast %[[EXT:.+]] : vector<[4]xi32> to vector<2x[4]xi32>
360
+ %b = vector.broadcast %a : vector <[4 ]xi8 > to vector <2 x[4 ]xi8 >
361
+ %r = arith.extsi %b : vector <2 x[4 ]xi8 > to vector <2 x[4 ]xi32 >
362
+ return %r : vector <2 x[4 ]xi32 >
363
+ }
364
+
365
+ // -----
366
+
367
+ func.func @broadcast_scalar_extsi (%a : i8 ) -> vector <2 x4 xi32 > {
368
+ // CHECK: %[[EXT:.+]] = arith.extsi %{{.+}} : i8 to i32
369
+ // CHECK: vector.broadcast %[[EXT]] : i32 to vector<2x4xi32>
370
+ %b = vector.broadcast %a : i8 to vector <2 x4 xi8 >
371
+ %r = arith.extsi %b : vector <2 x4 xi8 > to vector <2 x4 xi32 >
372
+ return %r : vector <2 x4 xi32 >
373
+ }
374
+
375
+ // -----
376
+
377
+ func.func @broadcast_scalar_extsi_scalable (%a : i8 ) -> vector <2 x[4 ]xi32 > {
378
+ // CHECK: %[[EXT:.+]] = arith.extsi %{{.+}} : i8 to i32
379
+ // CHECK: vector.broadcast %[[EXT]] : i32 to vector<2x[4]xi32>
380
+ %b = vector.broadcast %a : i8 to vector <2 x[4 ]xi8 >
381
+ %r = arith.extsi %b : vector <2 x[4 ]xi8 > to vector <2 x[4 ]xi32 >
382
+ return %r : vector <2 x[4 ]xi32 >
383
+ }
384
+
324
385
//===----------------------------------------------------------------------===//
325
386
// [Pattern: ReorderElementwiseOpsOnTranspose]
326
387
//===----------------------------------------------------------------------===//
0 commit comments