130 lines · plain
1// RUN: mlir-opt %s -convert-arith-to-arm-sme -split-input-file -allow-unregistered-dialect | FileCheck %s2 3// =============================================================================4// arith.constant dense<0> to arm_sme.zero5// =============================================================================6 7// -----8 9// CHECK-LABEL: @arith_constant_dense_2d_zero_i810// CHECK: %[[ZERO:.*]] = arm_sme.zero : vector<[16]x[16]xi8>11func.func @arith_constant_dense_2d_zero_i8() {12 %zero = arith.constant dense<0> : vector<[16]x[16]xi8>13 "prevent.dce"(%zero) : (vector<[16]x[16]xi8>) -> ()14 return15}16 17// -----18 19// CHECK-LABEL: @arith_constant_dense_2d_zero_i1620// CHECK: %[[ZERO:.*]] = arm_sme.zero : vector<[8]x[8]xi16>21func.func @arith_constant_dense_2d_zero_i16() {22 %zero = arith.constant dense<0> : vector<[8]x[8]xi16>23 "prevent.dce"(%zero) : (vector<[8]x[8]xi16>) -> ()24 return25}26 27// -----28 29// CHECK-LABEL: @arith_constant_dense_2d_zero_i3230// CHECK: %[[ZERO:.*]] = arm_sme.zero : vector<[4]x[4]xi32>31func.func @arith_constant_dense_2d_zero_i32() {32 %zero = arith.constant dense<0> : vector<[4]x[4]xi32>33 "prevent.dce"(%zero) : (vector<[4]x[4]xi32>) -> ()34 return35}36 37// -----38 39// CHECK-LABEL: @arith_constant_dense_2d_zero_i6440// CHECK: %[[ZERO:.*]] = arm_sme.zero : vector<[2]x[2]xi64>41func.func @arith_constant_dense_2d_zero_i64() {42 %zero = arith.constant dense<0> : vector<[2]x[2]xi64>43 "prevent.dce"(%zero) : (vector<[2]x[2]xi64>) -> ()44 return45}46 47// -----48 49// CHECK-LABEL: @arith_constant_dense_2d_zero_f1650// CHECK: %[[ZERO:.*]] = arm_sme.zero : vector<[8]x[8]xf16>51func.func @arith_constant_dense_2d_zero_f16() {52 %zero = arith.constant dense<0.0> : vector<[8]x[8]xf16>53 "prevent.dce"(%zero) : (vector<[8]x[8]xf16>) -> ()54 return55}56 57// -----58 59// CHECK-LABEL: @arith_constant_dense_2d_zero_bf1660// CHECK: %[[ZERO:.*]] = arm_sme.zero : vector<[8]x[8]xbf16>61func.func @arith_constant_dense_2d_zero_bf16() {62 %zero = arith.constant dense<0.0> : vector<[8]x[8]xbf16>63 "prevent.dce"(%zero) : (vector<[8]x[8]xbf16>) -> ()64 return65}66 67// -----68 69// CHECK-LABEL: @arith_constant_dense_2d_zero_f3270// CHECK: %[[ZERO:.*]] = arm_sme.zero : vector<[4]x[4]xf32>71func.func @arith_constant_dense_2d_zero_f32() {72 %zero = arith.constant dense<0.0> : vector<[4]x[4]xf32>73 "prevent.dce"(%zero) : (vector<[4]x[4]xf32>) -> ()74 return75}76 77// -----78 79// CHECK-LABEL: @arith_constant_dense_2d_zero_f6480// CHECK: %[[ZERO:.*]] = arm_sme.zero : vector<[2]x[2]xf64>81func.func @arith_constant_dense_2d_zero_f64() {82 %zero = arith.constant dense<0.0> : vector<[2]x[2]xf64>83 "prevent.dce"(%zero) : (vector<[2]x[2]xf64>) -> ()84 return85}86 87// =============================================================================88// Non-zero arith.constant dense to SME89// =============================================================================90 91// -----92 93// CHECK-LABEL: func.func @arith_constant_dense_2d_nonzero_i8() {94// CHECK-DAG: %[[C2_SPLAT:.*]] = arith.constant dense<2> : vector<[16]xi8>95// CHECK-DAG: %[[C1:.*]] = arith.constant 1 : index96// CHECK-DAG: %[[C16:.*]] = arith.constant 16 : index97// CHECK-DAG: %[[C0:.*]] = arith.constant 0 : index98// CHECK: %[[INIT_TILE:.*]] = arm_sme.get_tile : vector<[16]x[16]xi8>99// CHECK: %[[VSCALE:.*]] = vector.vscale100// CHECK: %[[NUM_TILE_SLICES:.*]] = arith.muli %[[VSCALE]], %[[C16]] : index101// CHECK: %[[TILE:.*]] = scf.for %[[TILE_SLICE_INDEX:.*]] = %[[C0]] to %[[NUM_TILE_SLICES]] step %[[C1]] iter_args(%[[CURRENT_TILE:.*]] = %[[INIT_TILE]]) -> (vector<[16]x[16]xi8>) {102// CHECK: %[[TILE_UPDATE:.*]] = arm_sme.insert_tile_slice %[[C2_SPLAT]], %[[CURRENT_TILE]][%[[TILE_SLICE_INDEX]]] : vector<[16]xi8> into vector<[16]x[16]xi8>103// CHECK: scf.yield %[[TILE_UPDATE]] : vector<[16]x[16]xi8>104// CHECK: "prevent.dce"(%[[TILE]]) : (vector<[16]x[16]xi8>) -> ()105func.func @arith_constant_dense_2d_nonzero_i8() {106 %two = arith.constant dense<2> : vector<[16]x[16]xi8>107 "prevent.dce"(%two) : (vector<[16]x[16]xi8>) -> ()108 return109}110 111// -----112 113// CHECK-LABEL: func.func @arith_constant_dense_2d_nonzero_f64() {114// CHECK-DAG: %[[C2_SPLAT:.*]] = arith.constant dense<2.000000e+00> : vector<[2]xf64>115// CHECK-DAG: %[[C1:.*]] = arith.constant 1 : index116// CHECK-DAG: %[[C2:.*]] = arith.constant 2 : index117// CHECK-DAG: %[[C0:.*]] = arith.constant 0 : index118// CHECK: %[[INIT_TILE:.*]] = arm_sme.get_tile : vector<[2]x[2]xf64>119// CHECK: %[[VSCALE:.*]] = vector.vscale120// CHECK: %[[NUM_TILE_SLICES:.*]] = arith.muli %[[VSCALE]], %[[C2]] : index121// CHECK: %[[TILE:.*]] = scf.for %[[TILE_SLICE_INDEX:.*]] = %[[C0]] to %[[NUM_TILE_SLICES]] step %[[C1]] iter_args(%[[CURRENT_TILE:.*]] = %[[INIT_TILE]]) -> (vector<[2]x[2]xf64>) {122// CHECK: %[[TILE_UPDATE:.*]] = arm_sme.insert_tile_slice %[[C2_SPLAT]], %[[CURRENT_TILE]][%[[TILE_SLICE_INDEX]]] : vector<[2]xf64> into vector<[2]x[2]xf64>123// CHECK: scf.yield %[[TILE_UPDATE]] : vector<[2]x[2]xf64>124// CHECK: "prevent.dce"(%[[TILE]]) : (vector<[2]x[2]xf64>) -> ()125func.func @arith_constant_dense_2d_nonzero_f64() {126 %two = arith.constant dense<2.0> : vector<[2]x[2]xf64>127 "prevent.dce"(%two) : (vector<[2]x[2]xf64>) -> ()128 return129}130