1 // RUN: mlir-opt -convert-spirv-to-llvm %s | FileCheck %s
3 //===----------------------------------------------------------------------===//
5 //===----------------------------------------------------------------------===//
7 // CHECK-LABEL: @iadd_scalar
8 spv.func @iadd_scalar(%arg0: i32, %arg1: i32) "None" {
9 // CHECK: llvm.add %{{.*}}, %{{.*}} : i32
10 %0 = spv.IAdd %arg0, %arg1 : i32
14 // CHECK-LABEL: @iadd_vector
15 spv.func @iadd_vector(%arg0: vector<4xi64>, %arg1: vector<4xi64>) "None" {
16 // CHECK: llvm.add %{{.*}}, %{{.*}} : vector<4xi64>
17 %0 = spv.IAdd %arg0, %arg1 : vector<4xi64>
21 //===----------------------------------------------------------------------===//
23 //===----------------------------------------------------------------------===//
25 // CHECK-LABEL: @isub_scalar
26 spv.func @isub_scalar(%arg0: i8, %arg1: i8) "None" {
27 // CHECK: llvm.sub %{{.*}}, %{{.*}} : i8
28 %0 = spv.ISub %arg0, %arg1 : i8
32 // CHECK-LABEL: @isub_vector
33 spv.func @isub_vector(%arg0: vector<2xi16>, %arg1: vector<2xi16>) "None" {
34 // CHECK: llvm.sub %{{.*}}, %{{.*}} : vector<2xi16>
35 %0 = spv.ISub %arg0, %arg1 : vector<2xi16>
39 //===----------------------------------------------------------------------===//
41 //===----------------------------------------------------------------------===//
43 // CHECK-LABEL: @imul_scalar
44 spv.func @imul_scalar(%arg0: i32, %arg1: i32) "None" {
45 // CHECK: llvm.mul %{{.*}}, %{{.*}} : i32
46 %0 = spv.IMul %arg0, %arg1 : i32
50 // CHECK-LABEL: @imul_vector
51 spv.func @imul_vector(%arg0: vector<3xi32>, %arg1: vector<3xi32>) "None" {
52 // CHECK: llvm.mul %{{.*}}, %{{.*}} : vector<3xi32>
53 %0 = spv.IMul %arg0, %arg1 : vector<3xi32>
57 //===----------------------------------------------------------------------===//
59 //===----------------------------------------------------------------------===//
61 // CHECK-LABEL: @fadd_scalar
62 spv.func @fadd_scalar(%arg0: f16, %arg1: f16) "None" {
63 // CHECK: llvm.fadd %{{.*}}, %{{.*}} : f16
64 %0 = spv.FAdd %arg0, %arg1 : f16
68 // CHECK-LABEL: @fadd_vector
69 spv.func @fadd_vector(%arg0: vector<4xf32>, %arg1: vector<4xf32>) "None" {
70 // CHECK: llvm.fadd %{{.*}}, %{{.*}} : vector<4xf32>
71 %0 = spv.FAdd %arg0, %arg1 : vector<4xf32>
75 //===----------------------------------------------------------------------===//
77 //===----------------------------------------------------------------------===//
79 // CHECK-LABEL: @fsub_scalar
80 spv.func @fsub_scalar(%arg0: f32, %arg1: f32) "None" {
81 // CHECK: llvm.fsub %{{.*}}, %{{.*}} : f32
82 %0 = spv.FSub %arg0, %arg1 : f32
86 // CHECK-LABEL: @fsub_vector
87 spv.func @fsub_vector(%arg0: vector<2xf32>, %arg1: vector<2xf32>) "None" {
88 // CHECK: llvm.fsub %{{.*}}, %{{.*}} : vector<2xf32>
89 %0 = spv.FSub %arg0, %arg1 : vector<2xf32>
93 //===----------------------------------------------------------------------===//
95 //===----------------------------------------------------------------------===//
97 // CHECK-LABEL: @fdiv_scalar
98 spv.func @fdiv_scalar(%arg0: f32, %arg1: f32) "None" {
99 // CHECK: llvm.fdiv %{{.*}}, %{{.*}} : f32
100 %0 = spv.FDiv %arg0, %arg1 : f32
104 // CHECK-LABEL: @fdiv_vector
105 spv.func @fdiv_vector(%arg0: vector<3xf64>, %arg1: vector<3xf64>) "None" {
106 // CHECK: llvm.fdiv %{{.*}}, %{{.*}} : vector<3xf64>
107 %0 = spv.FDiv %arg0, %arg1 : vector<3xf64>
111 //===----------------------------------------------------------------------===//
113 //===----------------------------------------------------------------------===//
115 // CHECK-LABEL: @fmul_scalar
116 spv.func @fmul_scalar(%arg0: f32, %arg1: f32) "None" {
117 // CHECK: llvm.fmul %{{.*}}, %{{.*}} : f32
118 %0 = spv.FMul %arg0, %arg1 : f32
122 // CHECK-LABEL: @fmul_vector
123 spv.func @fmul_vector(%arg0: vector<2xf32>, %arg1: vector<2xf32>) "None" {
124 // CHECK: llvm.fmul %{{.*}}, %{{.*}} : vector<2xf32>
125 %0 = spv.FMul %arg0, %arg1 : vector<2xf32>
129 //===----------------------------------------------------------------------===//
131 //===----------------------------------------------------------------------===//
133 // CHECK-LABEL: @frem_scalar
134 spv.func @frem_scalar(%arg0: f32, %arg1: f32) "None" {
135 // CHECK: llvm.frem %{{.*}}, %{{.*}} : f32
136 %0 = spv.FRem %arg0, %arg1 : f32
140 // CHECK-LABEL: @frem_vector
141 spv.func @frem_vector(%arg0: vector<3xf64>, %arg1: vector<3xf64>) "None" {
142 // CHECK: llvm.frem %{{.*}}, %{{.*}} : vector<3xf64>
143 %0 = spv.FRem %arg0, %arg1 : vector<3xf64>
147 //===----------------------------------------------------------------------===//
149 //===----------------------------------------------------------------------===//
151 // CHECK-LABEL: @fneg_scalar
152 spv.func @fneg_scalar(%arg: f64) "None" {
153 // CHECK: llvm.fneg %{{.*}} : f64
154 %0 = spv.FNegate %arg : f64
158 // CHECK-LABEL: @fneg_vector
159 spv.func @fneg_vector(%arg: vector<2xf32>) "None" {
160 // CHECK: llvm.fneg %{{.*}} : vector<2xf32>
161 %0 = spv.FNegate %arg : vector<2xf32>
165 //===----------------------------------------------------------------------===//
167 //===----------------------------------------------------------------------===//
169 // CHECK-LABEL: @udiv_scalar
170 spv.func @udiv_scalar(%arg0: i32, %arg1: i32) "None" {
171 // CHECK: llvm.udiv %{{.*}}, %{{.*}} : i32
172 %0 = spv.UDiv %arg0, %arg1 : i32
176 // CHECK-LABEL: @udiv_vector
177 spv.func @udiv_vector(%arg0: vector<3xi64>, %arg1: vector<3xi64>) "None" {
178 // CHECK: llvm.udiv %{{.*}}, %{{.*}} : vector<3xi64>
179 %0 = spv.UDiv %arg0, %arg1 : vector<3xi64>
183 //===----------------------------------------------------------------------===//
185 //===----------------------------------------------------------------------===//
187 // CHECK-LABEL: @umod_scalar
188 spv.func @umod_scalar(%arg0: i32, %arg1: i32) "None" {
189 // CHECK: llvm.urem %{{.*}}, %{{.*}} : i32
190 %0 = spv.UMod %arg0, %arg1 : i32
194 // CHECK-LABEL: @umod_vector
195 spv.func @umod_vector(%arg0: vector<3xi64>, %arg1: vector<3xi64>) "None" {
196 // CHECK: llvm.urem %{{.*}}, %{{.*}} : vector<3xi64>
197 %0 = spv.UMod %arg0, %arg1 : vector<3xi64>
201 //===----------------------------------------------------------------------===//
203 //===----------------------------------------------------------------------===//
205 // CHECK-LABEL: @sdiv_scalar
206 spv.func @sdiv_scalar(%arg0: i16, %arg1: i16) "None" {
207 // CHECK: llvm.sdiv %{{.*}}, %{{.*}} : i16
208 %0 = spv.SDiv %arg0, %arg1 : i16
212 // CHECK-LABEL: @sdiv_vector
213 spv.func @sdiv_vector(%arg0: vector<2xi64>, %arg1: vector<2xi64>) "None" {
214 // CHECK: llvm.sdiv %{{.*}}, %{{.*}} : vector<2xi64>
215 %0 = spv.SDiv %arg0, %arg1 : vector<2xi64>
219 //===----------------------------------------------------------------------===//
221 //===----------------------------------------------------------------------===//
223 // CHECK-LABEL: @srem_scalar
224 spv.func @srem_scalar(%arg0: i32, %arg1: i32) "None" {
225 // CHECK: llvm.srem %{{.*}}, %{{.*}} : i32
226 %0 = spv.SRem %arg0, %arg1 : i32
230 // CHECK-LABEL: @srem_vector
231 spv.func @srem_vector(%arg0: vector<4xi32>, %arg1: vector<4xi32>) "None" {
232 // CHECK: llvm.srem %{{.*}}, %{{.*}} : vector<4xi32>
233 %0 = spv.SRem %arg0, %arg1 : vector<4xi32>