1// RUN: mlir-opt -convert-spirv-to-llvm %s | FileCheck %s 2 3//===----------------------------------------------------------------------===// 4// spv.IAdd 5//===----------------------------------------------------------------------===// 6 7// CHECK-LABEL: @iadd_scalar 8spv.func @iadd_scalar(%arg0: i32, %arg1: i32) "None" { 9 // CHECK: llvm.add %{{.*}}, %{{.*}} : !llvm.i32 10 %0 = spv.IAdd %arg0, %arg1 : i32 11 spv.Return 12} 13 14// CHECK-LABEL: @iadd_vector 15spv.func @iadd_vector(%arg0: vector<4xi64>, %arg1: vector<4xi64>) "None" { 16 // CHECK: llvm.add %{{.*}}, %{{.*}} : !llvm.vec<4 x i64> 17 %0 = spv.IAdd %arg0, %arg1 : vector<4xi64> 18 spv.Return 19} 20 21//===----------------------------------------------------------------------===// 22// spv.ISub 23//===----------------------------------------------------------------------===// 24 25// CHECK-LABEL: @isub_scalar 26spv.func @isub_scalar(%arg0: i8, %arg1: i8) "None" { 27 // CHECK: llvm.sub %{{.*}}, %{{.*}} : !llvm.i8 28 %0 = spv.ISub %arg0, %arg1 : i8 29 spv.Return 30} 31 32// CHECK-LABEL: @isub_vector 33spv.func @isub_vector(%arg0: vector<2xi16>, %arg1: vector<2xi16>) "None" { 34 // CHECK: llvm.sub %{{.*}}, %{{.*}} : !llvm.vec<2 x i16> 35 %0 = spv.ISub %arg0, %arg1 : vector<2xi16> 36 spv.Return 37} 38 39//===----------------------------------------------------------------------===// 40// spv.IMul 41//===----------------------------------------------------------------------===// 42 43// CHECK-LABEL: @imul_scalar 44spv.func @imul_scalar(%arg0: i32, %arg1: i32) "None" { 45 // CHECK: llvm.mul %{{.*}}, %{{.*}} : !llvm.i32 46 %0 = spv.IMul %arg0, %arg1 : i32 47 spv.Return 48} 49 50// CHECK-LABEL: @imul_vector 51spv.func @imul_vector(%arg0: vector<3xi32>, %arg1: vector<3xi32>) "None" { 52 // CHECK: llvm.mul %{{.*}}, %{{.*}} : !llvm.vec<3 x i32> 53 %0 = spv.IMul %arg0, %arg1 : vector<3xi32> 54 spv.Return 55} 56 57//===----------------------------------------------------------------------===// 58// spv.FAdd 59//===----------------------------------------------------------------------===// 60 61// CHECK-LABEL: @fadd_scalar 62spv.func @fadd_scalar(%arg0: f16, %arg1: f16) "None" { 63 // CHECK: llvm.fadd %{{.*}}, %{{.*}} : !llvm.half 64 %0 = spv.FAdd %arg0, %arg1 : f16 65 spv.Return 66} 67 68// CHECK-LABEL: @fadd_vector 69spv.func @fadd_vector(%arg0: vector<4xf32>, %arg1: vector<4xf32>) "None" { 70 // CHECK: llvm.fadd %{{.*}}, %{{.*}} : !llvm.vec<4 x float> 71 %0 = spv.FAdd %arg0, %arg1 : vector<4xf32> 72 spv.Return 73} 74 75//===----------------------------------------------------------------------===// 76// spv.FSub 77//===----------------------------------------------------------------------===// 78 79// CHECK-LABEL: @fsub_scalar 80spv.func @fsub_scalar(%arg0: f32, %arg1: f32) "None" { 81 // CHECK: llvm.fsub %{{.*}}, %{{.*}} : !llvm.float 82 %0 = spv.FSub %arg0, %arg1 : f32 83 spv.Return 84} 85 86// CHECK-LABEL: @fsub_vector 87spv.func @fsub_vector(%arg0: vector<2xf32>, %arg1: vector<2xf32>) "None" { 88 // CHECK: llvm.fsub %{{.*}}, %{{.*}} : !llvm.vec<2 x float> 89 %0 = spv.FSub %arg0, %arg1 : vector<2xf32> 90 spv.Return 91} 92 93//===----------------------------------------------------------------------===// 94// spv.FDiv 95//===----------------------------------------------------------------------===// 96 97// CHECK-LABEL: @fdiv_scalar 98spv.func @fdiv_scalar(%arg0: f32, %arg1: f32) "None" { 99 // CHECK: llvm.fdiv %{{.*}}, %{{.*}} : !llvm.float 100 %0 = spv.FDiv %arg0, %arg1 : f32 101 spv.Return 102} 103 104// CHECK-LABEL: @fdiv_vector 105spv.func @fdiv_vector(%arg0: vector<3xf64>, %arg1: vector<3xf64>) "None" { 106 // CHECK: llvm.fdiv %{{.*}}, %{{.*}} : !llvm.vec<3 x double> 107 %0 = spv.FDiv %arg0, %arg1 : vector<3xf64> 108 spv.Return 109} 110 111//===----------------------------------------------------------------------===// 112// spv.FMul 113//===----------------------------------------------------------------------===// 114 115// CHECK-LABEL: @fmul_scalar 116spv.func @fmul_scalar(%arg0: f32, %arg1: f32) "None" { 117 // CHECK: llvm.fmul %{{.*}}, %{{.*}} : !llvm.float 118 %0 = spv.FMul %arg0, %arg1 : f32 119 spv.Return 120} 121 122// CHECK-LABEL: @fmul_vector 123spv.func @fmul_vector(%arg0: vector<2xf32>, %arg1: vector<2xf32>) "None" { 124 // CHECK: llvm.fmul %{{.*}}, %{{.*}} : !llvm.vec<2 x float> 125 %0 = spv.FMul %arg0, %arg1 : vector<2xf32> 126 spv.Return 127} 128 129//===----------------------------------------------------------------------===// 130// spv.FRem 131//===----------------------------------------------------------------------===// 132 133// CHECK-LABEL: @frem_scalar 134spv.func @frem_scalar(%arg0: f32, %arg1: f32) "None" { 135 // CHECK: llvm.frem %{{.*}}, %{{.*}} : !llvm.float 136 %0 = spv.FRem %arg0, %arg1 : f32 137 spv.Return 138} 139 140// CHECK-LABEL: @frem_vector 141spv.func @frem_vector(%arg0: vector<3xf64>, %arg1: vector<3xf64>) "None" { 142 // CHECK: llvm.frem %{{.*}}, %{{.*}} : !llvm.vec<3 x double> 143 %0 = spv.FRem %arg0, %arg1 : vector<3xf64> 144 spv.Return 145} 146 147//===----------------------------------------------------------------------===// 148// spv.FNegate 149//===----------------------------------------------------------------------===// 150 151// CHECK-LABEL: @fneg_scalar 152spv.func @fneg_scalar(%arg: f64) "None" { 153 // CHECK: llvm.fneg %{{.*}} : !llvm.double 154 %0 = spv.FNegate %arg : f64 155 spv.Return 156} 157 158// CHECK-LABEL: @fneg_vector 159spv.func @fneg_vector(%arg: vector<2xf32>) "None" { 160 // CHECK: llvm.fneg %{{.*}} : !llvm.vec<2 x float> 161 %0 = spv.FNegate %arg : vector<2xf32> 162 spv.Return 163} 164 165//===----------------------------------------------------------------------===// 166// spv.UDiv 167//===----------------------------------------------------------------------===// 168 169// CHECK-LABEL: @udiv_scalar 170spv.func @udiv_scalar(%arg0: i32, %arg1: i32) "None" { 171 // CHECK: llvm.udiv %{{.*}}, %{{.*}} : !llvm.i32 172 %0 = spv.UDiv %arg0, %arg1 : i32 173 spv.Return 174} 175 176// CHECK-LABEL: @udiv_vector 177spv.func @udiv_vector(%arg0: vector<3xi64>, %arg1: vector<3xi64>) "None" { 178 // CHECK: llvm.udiv %{{.*}}, %{{.*}} : !llvm.vec<3 x i64> 179 %0 = spv.UDiv %arg0, %arg1 : vector<3xi64> 180 spv.Return 181} 182 183//===----------------------------------------------------------------------===// 184// spv.UMod 185//===----------------------------------------------------------------------===// 186 187// CHECK-LABEL: @umod_scalar 188spv.func @umod_scalar(%arg0: i32, %arg1: i32) "None" { 189 // CHECK: llvm.urem %{{.*}}, %{{.*}} : !llvm.i32 190 %0 = spv.UMod %arg0, %arg1 : i32 191 spv.Return 192} 193 194// CHECK-LABEL: @umod_vector 195spv.func @umod_vector(%arg0: vector<3xi64>, %arg1: vector<3xi64>) "None" { 196 // CHECK: llvm.urem %{{.*}}, %{{.*}} : !llvm.vec<3 x i64> 197 %0 = spv.UMod %arg0, %arg1 : vector<3xi64> 198 spv.Return 199} 200 201//===----------------------------------------------------------------------===// 202// spv.SDiv 203//===----------------------------------------------------------------------===// 204 205// CHECK-LABEL: @sdiv_scalar 206spv.func @sdiv_scalar(%arg0: i16, %arg1: i16) "None" { 207 // CHECK: llvm.sdiv %{{.*}}, %{{.*}} : !llvm.i16 208 %0 = spv.SDiv %arg0, %arg1 : i16 209 spv.Return 210} 211 212// CHECK-LABEL: @sdiv_vector 213spv.func @sdiv_vector(%arg0: vector<2xi64>, %arg1: vector<2xi64>) "None" { 214 // CHECK: llvm.sdiv %{{.*}}, %{{.*}} : !llvm.vec<2 x i64> 215 %0 = spv.SDiv %arg0, %arg1 : vector<2xi64> 216 spv.Return 217} 218 219//===----------------------------------------------------------------------===// 220// spv.SRem 221//===----------------------------------------------------------------------===// 222 223// CHECK-LABEL: @srem_scalar 224spv.func @srem_scalar(%arg0: i32, %arg1: i32) "None" { 225 // CHECK: llvm.srem %{{.*}}, %{{.*}} : !llvm.i32 226 %0 = spv.SRem %arg0, %arg1 : i32 227 spv.Return 228} 229 230// CHECK-LABEL: @srem_vector 231spv.func @srem_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) "None" { 232 // CHECK: llvm.srem %{{.*}}, %{{.*}} : !llvm.vec<4 x i32> 233 %0 = spv.SRem %arg0, %arg1 : vector<4xi32> 234 spv.Return 235} 236