brintos

brintos / llvm-project-archived public Read only

0
0
Text · 31.6 KiB · fd8a2ff Raw
1069 lines · plain
1// RUN: mlir-opt -split-input-file -verify-diagnostics %s | FileCheck %s2 3//===----------------------------------------------------------------------===//4// spirv.GL.Exp5//===----------------------------------------------------------------------===//6 7func.func @exp(%arg0 : f32) -> () {8  // CHECK: spirv.GL.Exp {{%.*}} : f329  %2 = spirv.GL.Exp %arg0 : f3210  return11}12 13func.func @expvec(%arg0 : vector<3xf16>) -> () {14  // CHECK: spirv.GL.Exp {{%.*}} : vector<3xf16>15  %2 = spirv.GL.Exp %arg0 : vector<3xf16>16  return17}18 19// -----20 21func.func @exp(%arg0 : i32) -> () {22  // expected-error @+1 {{op operand #0 must be 16/32-bit float or fixed-length vector of 16/32-bit float values}}23  %2 = spirv.GL.Exp %arg0 : i3224  return25}26 27// -----28 29func.func @exp(%arg0 : vector<5xf32>) -> () {30  // expected-error @+1 {{op operand #0 must be 16/32-bit float or fixed-length vector of 16/32-bit float values of length 2/3/4}}31  %2 = spirv.GL.Exp %arg0 : vector<5xf32>32  return33}34 35// -----36 37func.func @exp(%arg0 : f32, %arg1 : f32) -> () {38  // expected-error @+1 {{expected ':'}}39  %2 = spirv.GL.Exp %arg0, %arg1 : i3240  return41}42 43// -----44 45func.func @exp(%arg0 : i32) -> () {46  // expected-error @+1 {{expected non-function type}}47  %2 = spirv.GL.Exp %arg0 :48  return49}50 51// -----52 53func.func @exp_bf16(%arg0 : bf16) -> () {54  // expected-error @+1 {{op operand #0 must be 16/32-bit float or fixed-length vector of 16/32-bit float values of length 2/3/4}}55  %2 = spirv.GL.Exp %arg0 : bf1656  return57}58 59// -----60 61//===----------------------------------------------------------------------===//62// spirv.GL.{F|S|U}{Max|Min}63//===----------------------------------------------------------------------===//64 65func.func @fmaxmin(%arg0 : f32, %arg1 : f32) {66  // CHECK: spirv.GL.FMax {{%.*}}, {{%.*}} : f3267  %1 = spirv.GL.FMax %arg0, %arg1 : f3268  // CHECK: spirv.GL.FMin {{%.*}}, {{%.*}} : f3269  %2 = spirv.GL.FMin %arg0, %arg1 : f3270  return71}72 73func.func @fmaxminvec(%arg0 : vector<3xf16>, %arg1 : vector<3xf16>) {74  // CHECK: spirv.GL.FMax {{%.*}}, {{%.*}} : vector<3xf16>75  %1 = spirv.GL.FMax %arg0, %arg1 : vector<3xf16>76  // CHECK: spirv.GL.FMin {{%.*}}, {{%.*}} : vector<3xf16>77  %2 = spirv.GL.FMin %arg0, %arg1 : vector<3xf16>78  return79}80 81func.func @fmaxminf64(%arg0 : f64, %arg1 : f64) {82  // CHECK: spirv.GL.FMax {{%.*}}, {{%.*}} : f6483  %1 = spirv.GL.FMax %arg0, %arg1 : f6484  // CHECK: spirv.GL.FMin {{%.*}}, {{%.*}} : f6485  %2 = spirv.GL.FMin %arg0, %arg1 : f6486  return87}88 89func.func @iminmax(%arg0: i32, %arg1: i32) {90  // CHECK: spirv.GL.SMax {{%.*}}, {{%.*}} : i3291  %1 = spirv.GL.SMax %arg0, %arg1 : i3292  // CHECK: spirv.GL.UMax {{%.*}}, {{%.*}} : i3293  %2 = spirv.GL.UMax %arg0, %arg1 : i3294  // CHECK: spirv.GL.SMin {{%.*}}, {{%.*}} : i3295  %3 = spirv.GL.SMin %arg0, %arg1 : i3296  // CHECK: spirv.GL.UMin {{%.*}}, {{%.*}} : i3297  %4 = spirv.GL.UMin %arg0, %arg1 : i3298  return99}100 101// -----102 103func.func @fmaxminbf16vec(%arg0 : vector<3xbf16>, %arg1 : vector<3xbf16>) {104  // expected-error @+1 {{operand #0 must be 16/32/64-bit float or fixed-length vector of 16/32/64-bit float values}}105  %1 = spirv.GL.FMax %arg0, %arg1 : vector<3xbf16>106  %2 = spirv.GL.FMin %arg0, %arg1 : vector<3xbf16>107  return108}109 110// -----111 112//===----------------------------------------------------------------------===//113// spirv.GL.InverseSqrt114//===----------------------------------------------------------------------===//115 116func.func @inversesqrt(%arg0 : f32) -> () {117  // CHECK: spirv.GL.InverseSqrt {{%.*}} : f32118  %2 = spirv.GL.InverseSqrt %arg0 : f32119  return120}121 122func.func @inversesqrtvec(%arg0 : vector<3xf16>) -> () {123  // CHECK: spirv.GL.InverseSqrt {{%.*}} : vector<3xf16>124  %2 = spirv.GL.InverseSqrt %arg0 : vector<3xf16>125  return126}127 128// -----129 130//===----------------------------------------------------------------------===//131// spirv.GL.Sqrt132//===----------------------------------------------------------------------===//133 134func.func @sqrt(%arg0 : f32) -> () {135  // CHECK: spirv.GL.Sqrt {{%.*}} : f32136  %2 = spirv.GL.Sqrt %arg0 : f32137  return138}139 140func.func @sqrtvec(%arg0 : vector<3xf16>) -> () {141  // CHECK: spirv.GL.Sqrt {{%.*}} : vector<3xf16>142  %2 = spirv.GL.Sqrt %arg0 : vector<3xf16>143  return144}145 146//===----------------------------------------------------------------------===//147// spirv.GL.Cos148//===----------------------------------------------------------------------===//149 150func.func @cos(%arg0 : f32) -> () {151  // CHECK: spirv.GL.Cos {{%.*}} : f32152  %2 = spirv.GL.Cos %arg0 : f32153  return154}155 156func.func @cosvec(%arg0 : vector<3xf16>) -> () {157  // CHECK: spirv.GL.Cos {{%.*}} : vector<3xf16>158  %2 = spirv.GL.Cos %arg0 : vector<3xf16>159  return160}161 162//===----------------------------------------------------------------------===//163// spirv.GL.Sin164//===----------------------------------------------------------------------===//165 166func.func @sin(%arg0 : f32) -> () {167  // CHECK: spirv.GL.Sin {{%.*}} : f32168  %2 = spirv.GL.Sin %arg0 : f32169  return170}171 172func.func @sinvec(%arg0 : vector<3xf16>) -> () {173  // CHECK: spirv.GL.Sin {{%.*}} : vector<3xf16>174  %2 = spirv.GL.Sin %arg0 : vector<3xf16>175  return176}177 178//===----------------------------------------------------------------------===//179// spirv.GL.Tan180//===----------------------------------------------------------------------===//181 182func.func @tan(%arg0 : f32) -> () {183  // CHECK: spirv.GL.Tan {{%.*}} : f32184  %2 = spirv.GL.Tan %arg0 : f32185  return186}187 188func.func @tanvec(%arg0 : vector<3xf16>) -> () {189  // CHECK: spirv.GL.Tan {{%.*}} : vector<3xf16>190  %2 = spirv.GL.Tan %arg0 : vector<3xf16>191  return192}193 194//===----------------------------------------------------------------------===//195// spirv.GL.Acos196//===----------------------------------------------------------------------===//197 198func.func @acos(%arg0 : f32) -> () {199  // CHECK: spirv.GL.Acos {{%.*}} : f32200  %2 = spirv.GL.Acos %arg0 : f32201  return202}203 204func.func @acosvec(%arg0 : vector<3xf16>) -> () {205  // CHECK: spirv.GL.Acos {{%.*}} : vector<3xf16>206  %2 = spirv.GL.Acos %arg0 : vector<3xf16>207  return208}209 210//===----------------------------------------------------------------------===//211// spirv.GL.Asin212//===----------------------------------------------------------------------===//213 214func.func @asin(%arg0 : f32) -> () {215  // CHECK: spirv.GL.Asin {{%.*}} : f32216  %2 = spirv.GL.Asin %arg0 : f32217  return218}219 220func.func @asinvec(%arg0 : vector<3xf16>) -> () {221  // CHECK: spirv.GL.Asin {{%.*}} : vector<3xf16>222  %2 = spirv.GL.Asin %arg0 : vector<3xf16>223  return224}225 226//===----------------------------------------------------------------------===//227// spirv.GL.Atan228//===----------------------------------------------------------------------===//229 230func.func @atan(%arg0 : f32) -> () {231  // CHECK: spirv.GL.Atan {{%.*}} : f32232  %2 = spirv.GL.Atan %arg0 : f32233  return234}235 236func.func @atanvec(%arg0 : vector<3xf16>) -> () {237  // CHECK: spirv.GL.Atan {{%.*}} : vector<3xf16>238  %2 = spirv.GL.Atan %arg0 : vector<3xf16>239  return240}241 242//===----------------------------------------------------------------------===//243// spirv.GL.Sinh244//===----------------------------------------------------------------------===//245 246func.func @sinh(%arg0 : f32) -> () {247  // CHECK: spirv.GL.Sinh {{%.*}} : f32248  %2 = spirv.GL.Sinh %arg0 : f32249  return250}251 252func.func @sinhvec(%arg0 : vector<3xf16>) -> () {253  // CHECK: spirv.GL.Sinh {{%.*}} : vector<3xf16>254  %2 = spirv.GL.Sinh %arg0 : vector<3xf16>255  return256}257 258//===----------------------------------------------------------------------===//259// spirv.GL.Cosh260//===----------------------------------------------------------------------===//261 262func.func @cosh(%arg0 : f32) -> () {263  // CHECK: spirv.GL.Cosh {{%.*}} : f32264  %2 = spirv.GL.Cosh %arg0 : f32265  return266}267 268func.func @coshvec(%arg0 : vector<3xf16>) -> () {269  // CHECK: spirv.GL.Cosh {{%.*}} : vector<3xf16>270  %2 = spirv.GL.Cosh %arg0 : vector<3xf16>271  return272}273 274//===----------------------------------------------------------------------===//275// spirv.GL.Asinh276//===----------------------------------------------------------------------===//277 278func.func @asinh(%arg0 : f32) -> () {279  // CHECK: spirv.GL.Asinh {{%.*}} : f32280  %2 = spirv.GL.Asinh %arg0 : f32281  return282}283 284func.func @asinhvec(%arg0 : vector<3xf16>) -> () {285  // CHECK: spirv.GL.Asinh {{%.*}} : vector<3xf16>286  %2 = spirv.GL.Asinh %arg0 : vector<3xf16>287  return288}289 290//===----------------------------------------------------------------------===//291// spirv.GL.Acosh292//===----------------------------------------------------------------------===//293 294func.func @acosh(%arg0 : f32) -> () {295  // CHECK: spirv.GL.Acosh {{%.*}} : f32296  %2 = spirv.GL.Acosh %arg0 : f32297  return298}299 300func.func @acoshvec(%arg0 : vector<3xf16>) -> () {301  // CHECK: spirv.GL.Acosh {{%.*}} : vector<3xf16>302  %2 = spirv.GL.Acosh %arg0 : vector<3xf16>303  return304}305 306//===----------------------------------------------------------------------===//307// spirv.GL.Atanh308//===----------------------------------------------------------------------===//309 310func.func @atanh(%arg0 : f32) -> () {311  // CHECK: spirv.GL.Atanh {{%.*}} : f32312  %2 = spirv.GL.Atanh %arg0 : f32313  return314}315 316func.func @atanhvec(%arg0 : vector<3xf16>) -> () {317  // CHECK: spirv.GL.Atanh {{%.*}} : vector<3xf16>318  %2 = spirv.GL.Atanh %arg0 : vector<3xf16>319  return320}321 322//===----------------------------------------------------------------------===//323// spirv.GL.Pow324//===----------------------------------------------------------------------===//325 326func.func @pow(%arg0 : f32, %arg1 : f32) -> () {327  // CHECK: spirv.GL.Pow {{%.*}}, {{%.*}} : f32328  %2 = spirv.GL.Pow %arg0, %arg1 : f32329  return330}331 332func.func @powvec(%arg0 : vector<3xf16>, %arg1 : vector<3xf16>) -> () {333  // CHECK: spirv.GL.Pow {{%.*}}, {{%.*}} : vector<3xf16>334  %2 = spirv.GL.Pow %arg0, %arg1 : vector<3xf16>335  return336}337 338// -----339 340//===----------------------------------------------------------------------===//341// spirv.GL.Round342//===----------------------------------------------------------------------===//343 344func.func @round(%arg0 : f32) -> () {345  // CHECK: spirv.GL.Round {{%.*}} : f32346  %2 = spirv.GL.Round %arg0 : f32347  return348}349 350func.func @roundvec(%arg0 : vector<3xf16>) -> () {351  // CHECK: spirv.GL.Round {{%.*}} : vector<3xf16>352  %2 = spirv.GL.Round %arg0 : vector<3xf16>353  return354}355 356//===----------------------------------------------------------------------===//357// spirv.GL.RoundEven358//===----------------------------------------------------------------------===//359 360func.func @round_even(%arg0 : f32) -> () {361  // CHECK: spirv.GL.RoundEven {{%.*}} : f32362  %2 = spirv.GL.RoundEven %arg0 : f32363  return364}365 366func.func @round_even_vec(%arg0 : vector<3xf16>) -> () {367  // CHECK: spirv.GL.RoundEven {{%.*}} : vector<3xf16>368  %2 = spirv.GL.RoundEven %arg0 : vector<3xf16>369  return370}371 372// -----373 374//===----------------------------------------------------------------------===//375// spirv.GL.FClamp376//===----------------------------------------------------------------------===//377 378func.func @fclamp(%arg0 : f32, %min : f32, %max : f32) -> () {379  // CHECK: spirv.GL.FClamp {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : f32380  %2 = spirv.GL.FClamp %arg0, %min, %max : f32381  return382}383 384// -----385 386func.func @fclamp(%arg0 : vector<3xf32>, %min : vector<3xf32>, %max : vector<3xf32>) -> () {387  // CHECK: spirv.GL.FClamp {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : vector<3xf32>388  %2 = spirv.GL.FClamp %arg0, %min, %max : vector<3xf32>389  return390}391 392// -----393 394//===----------------------------------------------------------------------===//395// spirv.GL.UClamp396//===----------------------------------------------------------------------===//397 398func.func @uclamp(%arg0 : ui32, %min : ui32, %max : ui32) -> () {399  // CHECK: spirv.GL.UClamp {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : ui32400  %2 = spirv.GL.UClamp %arg0, %min, %max : ui32401  return402}403 404// -----405 406func.func @uclamp(%arg0 : vector<4xi32>, %min : vector<4xi32>, %max : vector<4xi32>) -> () {407  // CHECK: spirv.GL.UClamp {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : vector<4xi32>408  %2 = spirv.GL.UClamp %arg0, %min, %max : vector<4xi32>409  return410}411 412// -----413 414func.func @uclamp(%arg0 : si32, %min : si32, %max : si32) -> () {415  // CHECK: spirv.GL.UClamp416  %2 = spirv.GL.UClamp %arg0, %min, %max : si32417  return418}419 420// -----421 422//===----------------------------------------------------------------------===//423// spirv.GL.SClamp424//===----------------------------------------------------------------------===//425 426func.func @sclamp(%arg0 : si32, %min : si32, %max : si32) -> () {427  // CHECK: spirv.GL.SClamp {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : si32428  %2 = spirv.GL.SClamp %arg0, %min, %max : si32429  return430}431 432// -----433 434func.func @sclamp(%arg0 : vector<4xsi32>, %min : vector<4xsi32>, %max : vector<4xsi32>) -> () {435  // CHECK: spirv.GL.SClamp {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : vector<4xsi32>436  %2 = spirv.GL.SClamp %arg0, %min, %max : vector<4xsi32>437  return438}439 440// -----441 442func.func @sclamp(%arg0 : i32, %min : i32, %max : i32) -> () {443  // CHECK: spirv.GL.SClamp444  %2 = spirv.GL.SClamp %arg0, %min, %max : i32445  return446}447 448// -----449 450//===----------------------------------------------------------------------===//451// spirv.GL.Fma452//===----------------------------------------------------------------------===//453 454func.func @fma(%a : f32, %b : f32, %c : f32) -> () {455  // CHECK: spirv.GL.Fma {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : f32456  %2 = spirv.GL.Fma %a, %b, %c : f32457  return458}459 460// -----461 462func.func @fma(%a : vector<3xf32>, %b : vector<3xf32>, %c : vector<3xf32>) -> () {463  // CHECK: spirv.GL.Fma {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : vector<3xf32>464  %2 = spirv.GL.Fma %a, %b, %c : vector<3xf32>465  return466}467// -----468 469//===----------------------------------------------------------------------===//470// spirv.GL.FrexpStruct471//===----------------------------------------------------------------------===//472 473func.func @frexp_struct(%arg0 : f32) -> () {474  // CHECK: spirv.GL.FrexpStruct {{%.*}} : f32 -> !spirv.struct<(f32, i32)>475  %2 = spirv.GL.FrexpStruct %arg0 : f32 -> !spirv.struct<(f32, i32)>476  return477}478 479func.func @frexp_struct_64(%arg0 : f64) -> () {480  // CHECK: spirv.GL.FrexpStruct {{%.*}} : f64 -> !spirv.struct<(f64, i32)>481  %2 = spirv.GL.FrexpStruct %arg0 : f64 -> !spirv.struct<(f64, i32)>482  return483}484 485func.func @frexp_struct_vec(%arg0 : vector<3xf32>) -> () {486  // CHECK: spirv.GL.FrexpStruct {{%.*}} : vector<3xf32> -> !spirv.struct<(vector<3xf32>, vector<3xi32>)>487  %2 = spirv.GL.FrexpStruct %arg0 : vector<3xf32> -> !spirv.struct<(vector<3xf32>, vector<3xi32>)>488  return489}490 491// -----492 493func.func @frexp_struct_mismatch_type(%arg0 : f32) -> () {494  // expected-error @+1 {{member zero of the resulting struct type must be the same type as the operand}}495  %2 = spirv.GL.FrexpStruct %arg0 : f32 -> !spirv.struct<(vector<3xf32>, i32)>496  return497}498 499// -----500 501func.func @frexp_struct_wrong_type(%arg0 : i32) -> () {502  // expected-error @+1 {{op operand #0 must be 16/32/64-bit float or fixed-length vector of 16/32/64-bit float values}}503  %2 = spirv.GL.FrexpStruct %arg0 : i32 -> !spirv.struct<(i32, i32)>504  return505}506 507// -----508 509func.func @frexp_struct_mismatch_num_components(%arg0 : vector<3xf32>) -> () {510  // expected-error @+1 {{member one of the resulting struct type must have the same number of components as the operand type}}511  %2 = spirv.GL.FrexpStruct %arg0 : vector<3xf32> -> !spirv.struct<(vector<3xf32>, vector<2xi32>)>512  return513}514 515// -----516 517func.func @frexp_struct_not_i32(%arg0 : f32) -> () {518  // expected-error @+1 {{member one of the resulting struct type must be a scalar or vector of 32 bit integer type}}519  %2 = spirv.GL.FrexpStruct %arg0 : f32 -> !spirv.struct<(f32, i64)>520  return521}522 523// -----524 525//===----------------------------------------------------------------------===//526// spirv.GL.Ldexp527//===----------------------------------------------------------------------===//528 529func.func @ldexp(%arg0 : f32, %arg1 : i32) -> () {530  // CHECK: {{%.*}} = spirv.GL.Ldexp {{%.*}} : f32, {{%.*}} : i32 -> f32531  %0 = spirv.GL.Ldexp %arg0 : f32, %arg1 : i32 -> f32532  return533}534 535// -----536func.func @ldexp_vec(%arg0 : vector<3xf32>, %arg1 : vector<3xi32>) -> () {537  // CHECK: {{%.*}} = spirv.GL.Ldexp {{%.*}} : vector<3xf32>, {{%.*}} : vector<3xi32> -> vector<3xf32>538  %0 = spirv.GL.Ldexp %arg0 : vector<3xf32>, %arg1 : vector<3xi32> -> vector<3xf32>539  return540}541 542// -----543 544func.func @ldexp_wrong_type_scalar(%arg0 : f32, %arg1 : vector<2xi32>) -> () {545  // expected-error @+1 {{operands must both be scalars or vectors}}546  %0 = spirv.GL.Ldexp %arg0 : f32, %arg1 : vector<2xi32> -> f32547  return548}549 550// -----551 552func.func @ldexp_wrong_type_vec_1(%arg0 : vector<3xf32>, %arg1 : i32) -> () {553  // expected-error @+1 {{operands must both be scalars or vectors}}554  %0 = spirv.GL.Ldexp %arg0 : vector<3xf32>, %arg1 : i32 -> vector<3xf32>555  return556}557 558// -----559 560func.func @ldexp_wrong_type_vec_2(%arg0 : vector<3xf32>, %arg1 : vector<2xi32>) -> () {561  // expected-error @+1 {{operands must have the same number of elements}}562  %0 = spirv.GL.Ldexp %arg0 : vector<3xf32>, %arg1 : vector<2xi32> -> vector<3xf32>563  return564}565 566// -----567 568//===----------------------------------------------------------------------===//569// spirv.GL.FMix570//===----------------------------------------------------------------------===//571 572func.func @fmix(%arg0 : f32, %arg1 : f32, %arg2 : f32) -> () {573  // CHECK: {{%.*}} = spirv.GL.FMix {{%.*}} : f32, {{%.*}} : f32, {{%.*}} : f32 -> f32574  %0 = spirv.GL.FMix %arg0 : f32, %arg1 : f32, %arg2 : f32 -> f32575  return576}577 578func.func @fmix_vector(%arg0 : vector<3xf32>, %arg1 : vector<3xf32>, %arg2 : vector<3xf32>) -> () {579  // CHECK: {{%.*}} = spirv.GL.FMix {{%.*}} : vector<3xf32>, {{%.*}} : vector<3xf32>, {{%.*}} : vector<3xf32> -> vector<3xf32>580  %0 = spirv.GL.FMix %arg0 : vector<3xf32>, %arg1 : vector<3xf32>, %arg2 : vector<3xf32> -> vector<3xf32>581  return582}583 584// -----585 586//===----------------------------------------------------------------------===//587// spirv.GL.FindILsb588//===----------------------------------------------------------------------===//589 590func.func @findimsb_scalar_i32(%arg0 : i32) -> () {591  // CHECK: spirv.GL.FindILsb {{%.*}} : i32592  %2 = spirv.GL.FindILsb %arg0 : i32593  return594}595 596func.func @findimsb_vector_i32(%arg0 : vector<3xi32>) -> () {597  // CHECK: spirv.GL.FindILsb {{%.*}} : vector<3xi32>598  %2 = spirv.GL.FindILsb %arg0 : vector<3xi32>599  return600}601 602func.func @findimsb_scalar_i16(%arg0 : i16) -> () {603  // CHECK: spirv.GL.FindILsb {{%.*}} : i16604  %2 = spirv.GL.FindILsb %arg0 : i16605  return606}607 608func.func @findimsb_vector_i64(%arg0 : vector<3xi64>) -> () {609  // CHECK: spirv.GL.FindILsb {{%.*}} : vector<3xi64>610  %2 = spirv.GL.FindILsb %arg0 : vector<3xi64>611  return612}613 614// -----615 616func.func @findimsb_error_scalar_float(%arg0 : f32) -> () {617  // expected-error @+1 {{operand #0 must be 8/16/32/64-bit integer or fixed-length vector of 8/16/32/64-bit integer values of length 2/3/4/8/1}}618  %2 = spirv.GL.FindILsb %arg0 : f32619  return620}621 622// -----623 624//===----------------------------------------------------------------------===//625// spirv.GL.FindSMsb626//===----------------------------------------------------------------------===//627 628func.func @findsmsb_scalar(%arg0 : i32) -> () {629  // CHECK: spirv.GL.FindSMsb {{%.*}} : i32630  %2 = spirv.GL.FindSMsb %arg0 : i32631  return632}633 634func.func @findsmsb_vector(%arg0 : vector<3xi32>) -> () {635  // CHECK: spirv.GL.FindSMsb {{%.*}} : vector<3xi32>636  %2 = spirv.GL.FindSMsb %arg0 : vector<3xi32>637  return638}639 640// -----641 642func.func @findsmsb_error_scalar_i64(%arg0 : i64) -> () {643  // expected-error @+1 {{operand #0 must be Int32 or fixed-length vector of Int32}}644  %2 = spirv.GL.FindSMsb %arg0 : i64645  return646}647 648// -----649 650//===----------------------------------------------------------------------===//651// spirv.GL.FindUMsb652//===----------------------------------------------------------------------===//653 654func.func @findumsb(%arg0 : i32) -> () {655  // CHECK: spirv.GL.FindUMsb {{%.*}} : i32656  %2 = spirv.GL.FindUMsb %arg0 : i32657  return658}659 660func.func @findumsb_vector(%arg0 : vector<3xi32>) -> () {661  // CHECK: spirv.GL.FindUMsb {{%.*}} : vector<3xi32>662  %2 = spirv.GL.FindUMsb %arg0 : vector<3xi32>663  return664}665 666// -----667 668func.func @findumsb(%arg0 : i64) -> () {669  // expected-error @+1 {{operand #0 must be Int32 or fixed-length vector of Int32}}670  %2 = spirv.GL.FindUMsb %arg0 : i64671  return672}673 674// -----675 676//===----------------------------------------------------------------------===//677// spirv.GL.Distance 678//===----------------------------------------------------------------------===//679 680func.func @distance_scalar(%arg0 : f32, %arg1 : f32) {681  // CHECK: spirv.GL.Distance {{%.*}}, {{%.*}} : f32, f32 -> f32682  %0 = spirv.GL.Distance %arg0, %arg1 : f32, f32 -> f32683  return684}685 686func.func @distance_vector(%arg0 : vector<3xf32>, %arg1 : vector<3xf32>) {687  // CHECK: spirv.GL.Distance {{%.*}}, {{%.*}} : vector<3xf32>, vector<3xf32> -> f32688  %0 = spirv.GL.Distance %arg0, %arg1 : vector<3xf32>, vector<3xf32> -> f32689  return690}691 692// -----693 694func.func @distance_invalid_type(%arg0 : i32, %arg1 : i32) {695  // expected-error @+1 {{'spirv.GL.Distance' op operand #0 must be 16/32/64-bit float or fixed-length vector of 16/32/64-bit float values of length 2/3/4/8/16}}696  %0 = spirv.GL.Distance %arg0, %arg1 : i32, i32 -> f32697  return698}699 700// -----701 702func.func @distance_arg_mismatch(%arg0 : vector<3xf32>, %arg1 : vector<4xf32>) {703  // expected-error @+1 {{'spirv.GL.Distance' op failed to verify that all of {p0, p1} have same type}}704  %0 = spirv.GL.Distance %arg0, %arg1 : vector<3xf32>, vector<4xf32> -> f32705  return706}707 708// -----709 710func.func @distance_invalid_vector_size(%arg0 : vector<5xf32>, %arg1 : vector<5xf32>) {711  // expected-error @+1 {{'spirv.GL.Distance' op operand #0 must be 16/32/64-bit float or fixed-length vector of 16/32/64-bit float values of length 2/3/4/8/16}}712  %0 = spirv.GL.Distance %arg0, %arg1 : vector<5xf32>, vector<5xf32> -> f32713  return714}715 716// -----717 718func.func @distance_invalid_result(%arg0 : f32, %arg1 : f32) {719  // expected-error @+1 {{'spirv.GL.Distance' op result #0 must be 16/32/64-bit float}}720  %0 = spirv.GL.Distance %arg0, %arg1 : f32, f32 -> i32721  return722}723 724// -----725 726//===----------------------------------------------------------------------===//727// spirv.GL.Cross728//===----------------------------------------------------------------------===//729 730func.func @cross(%arg0 : vector<3xf32>, %arg1 : vector<3xf32>) {731  %2 = spirv.GL.Cross %arg0, %arg1 : vector<3xf32>732  // CHECK: %{{.+}} = spirv.GL.Cross %{{.+}}, %{{.+}} : vector<3xf32>733  return734}735 736// -----737 738func.func @cross_invalid_type(%arg0 : vector<3xi32>, %arg1 : vector<3xi32>) {739  // expected-error @+1 {{'spirv.GL.Cross' op operand #0 must be 16/32/64-bit float or fixed-length vector of 16/32/64-bit float values of length 2/3/4/8/16, but got 'vector<3xi32>'}}740  %0 = spirv.GL.Cross %arg0, %arg1 : vector<3xi32>741  return742}743 744// -----745 746//===----------------------------------------------------------------------===//747// spirv.GL.Normalize748//===----------------------------------------------------------------------===//749 750func.func @normalize_scalar(%arg0 : f32) {751  %2 = spirv.GL.Normalize %arg0 : f32752  // CHECK: %{{.+}} = spirv.GL.Normalize %{{.+}} : f32753  return754}755 756func.func @normalize_vector(%arg0 : vector<3xf32>) {757  %2 = spirv.GL.Normalize %arg0 : vector<3xf32>758  // CHECK: %{{.+}} = spirv.GL.Normalize %{{.+}} : vector<3xf32>759  return760}761 762// -----763 764func.func @normalize_invalid_type(%arg0 : i32) {765  // expected-error @+1 {{'spirv.GL.Normalize' op operand #0 must be 16/32/64-bit float or fixed-length vector of 16/32/64-bit float values}}766  %0 = spirv.GL.Normalize %arg0 : i32767  return768}769 770// -----771 772//===----------------------------------------------------------------------===//773// spirv.GL.Reflect774//===----------------------------------------------------------------------===//775 776func.func @reflect_scalar(%arg0 : f32, %arg1 : f32) {777  %2 = spirv.GL.Reflect %arg0, %arg1 : f32778  // CHECK: %{{.+}} = spirv.GL.Reflect %{{.+}}, %{{.+}} : f32779  return780}781 782func.func @reflect_vector(%arg0 : vector<3xf32>, %arg1 : vector<3xf32>) {783  %2 = spirv.GL.Reflect %arg0, %arg1 : vector<3xf32>784  // CHECK: %{{.+}} = spirv.GL.Reflect %{{.+}}, %{{.+}} : vector<3xf32>785  return786}787 788// -----789 790func.func @reflect_invalid_type(%arg0 : i32, %arg1 : i32) {791  // expected-error @+1 {{'spirv.GL.Reflect' op operand #0 must be 16/32/64-bit float or fixed-length vector of 16/32/64-bit float values}}792  %0 = spirv.GL.Reflect %arg0, %arg1 : i32793  return794}795 796// -----797 798//===----------------------------------------------------------------------===//799// spirv.GL.Fract800//===----------------------------------------------------------------------===//801 802func.func @fract(%arg0 : f32) -> () {803  // CHECK: spirv.GL.Fract {{%.*}} : f32804  %0 = spirv.GL.Fract %arg0 : f32805  return806}807 808func.func @fractvec(%arg0 : vector<3xf16>) -> () {809  // CHECK: spirv.GL.Fract {{%.*}} : vector<3xf16>810  %0 = spirv.GL.Fract %arg0 : vector<3xf16>811  return812}813 814// -----815 816func.func @fract_invalid_type(%arg0 : i32) {817  // expected-error @+1 {{'spirv.GL.Fract' op operand #0 must be 16/32/64-bit float or fixed-length vector of 16/32/64-bit float values}}818  %0 = spirv.GL.Fract %arg0 : i32819  return820}821 822// -----823 824//===----------------------------------------------------------------------===//825// spirv.GL.Log2826//===----------------------------------------------------------------------===//827 828func.func @log2(%arg0 : f32) -> () {829  // CHECK: spirv.GL.Log2 {{%.*}} : f32830  %0 = spirv.GL.Log2 %arg0 : f32831  return832}833 834func.func @log2vec(%arg0 : vector<3xf16>) -> () {835  // CHECK: spirv.GL.Log2 {{%.*}} : vector<3xf16>836  %0 = spirv.GL.Log2 %arg0 : vector<3xf16>837  return838}839 840// -----841 842func.func @log2_invalid_type(%arg0 : i32) -> () {843  // expected-error @+1 {{op operand #0 must be 16/32-bit float or fixed-length vector of 16/32-bit float values}}844  %0 = spirv.GL.Log2 %arg0 : i32845  return846}847 848// -----849 850//===----------------------------------------------------------------------===//851// spirv.GL.Tanh852//===----------------------------------------------------------------------===//853 854func.func @tanh(%arg0 : f32) -> () {855  // CHECK: spirv.GL.Tanh {{%.*}} : f32856  %0 = spirv.GL.Tanh %arg0 : f32857  return858}859 860func.func @tanhvec(%arg0 : vector<3xf16>) -> () {861  // CHECK: spirv.GL.Tanh {{%.*}} : vector<3xf16>862  %0 = spirv.GL.Tanh %arg0 : vector<3xf16>863  return864}865 866// -----867 868func.func @tanh_invalid_type(%arg0 : i32) -> () {869  // expected-error @+1 {{op operand #0 must be 16/32-bit float or fixed-length vector of 16/32-bit float values}}870  %0 = spirv.GL.Tanh %arg0 : i32871  return872}873 874// -----875 876//===----------------------------------------------------------------------===//877// spirv.GL.Exp2878//===----------------------------------------------------------------------===//879 880func.func @exp2(%arg0 : f32) -> () {881  // CHECK: spirv.GL.Exp2 {{%.*}} : f32882  %0 = spirv.GL.Exp2 %arg0 : f32883  return884}885 886func.func @exp2vec(%arg0 : vector<3xf16>) -> () {887  // CHECK: spirv.GL.Exp2 {{%.*}} : vector<3xf16>888  %0 = spirv.GL.Exp2 %arg0 : vector<3xf16>889  return890}891 892// -----893 894func.func @exp2_invalid_type(%arg0 : i32) -> () {895  // expected-error @+1 {{op operand #0 must be 16/32-bit float or fixed-length vector of 16/32-bit float values}}896  %0 = spirv.GL.Exp2 %arg0 : i32897  return898}899 900// -----901 902//===----------------------------------------------------------------------===//903// spirv.GL.PackHalf2x16 904//===----------------------------------------------------------------------===//905 906func.func @pack_half_2x16(%arg0 : vector<2xf32>) -> () {907  // CHECK: spirv.GL.PackHalf2x16 {{%.*}} : vector<2xf32> -> i32908  %0 = spirv.GL.PackHalf2x16 %arg0 : vector<2xf32> -> i32909  return910}911 912// -----913 914func.func @pack_half_2x16_i16_output(%arg0 : vector<2xf32>) -> () {915  // expected-error @+1 {{op result #0 must be Int32, but got 'i16'}}916  %0 = spirv.GL.PackHalf2x16 %arg0 : vector<2xf32> -> i16917  return918}919 920// -----921 922func.func @pack_half_2x16_wrong_vec_size(%arg0 : vector<3xf32>) -> () {923  // expected-error @+1 {{op operand #0 must be vector of Float32 values of length 2, but got 'vector<3xf32>'}}924  %0 = spirv.GL.PackHalf2x16 %arg0 : vector<3xf32> -> i32925  return926}927 928// -----929 930func.func @pack_half_2x16_wrong_vec_type(%arg0 : vector<2xi32>) -> () {931  // expected-error @+1 {{op operand #0 must be vector of Float32 values of length 2, but got 'vector<2xi32>'}}932  %0 = spirv.GL.PackHalf2x16 %arg0 : vector<2xi32> -> i32933  return934}935 936// -----937 938func.func @pack_half_2x16_scalar_in(%arg0 : f32) -> () {939  // expected-error @+1 {{invalid kind of type specified: expected builtin.vector, but found 'f32'}}940  %0 = spirv.GL.PackHalf2x16 %arg0 : f32 -> i32941  return942}943 944// -----945 946func.func @unpack_half_2x16_vector_out(%arg0 : vector<2xf32>) -> () {947  // expected-error @+1 {{invalid kind of type specified: expected builtin.integer, but found 'vector<2xf32>'}}948  %0 = spirv.GL.UnpackHalf2x16 %arg0 : vector<2xf32> -> vector<2xi32>949  return950}951 952// -----953 954//===----------------------------------------------------------------------===//955// spirv.GL.UnpackHalf2x16 956//===----------------------------------------------------------------------===//957 958func.func @unpack_half_2x16(%arg0 : i32) -> () {959  // CHECK: spirv.GL.UnpackHalf2x16 {{%.*}} : i32 -> vector<2xf32>960  %0 = spirv.GL.UnpackHalf2x16 %arg0 : i32 -> vector<2xf32>961  return962}963 964// -----965 966func.func @unpack_half_2x16_i16_input(%arg0 : i16) -> () {967  // expected-error @+1 {{op operand #0 must be Int32, but got 'i16'}}968  %0 = spirv.GL.UnpackHalf2x16 %arg0 : i16 -> vector<2xf32>969  return970}971 972// -----973 974func.func @unpack_half_2x16_wrong_vec_size(%arg0 : i32) -> () {975  // expected-error @+1 {{op result #0 must be vector of Float32 values of length 2, but got 'vector<3xf32>'}}976  %0 = spirv.GL.UnpackHalf2x16 %arg0 : i32 -> vector<3xf32>977  return978}979 980// -----981 982func.func @unpack_half_2x16_wrong_vec_type(%arg0 : i32) -> () {983  // expected-error @+1 {{op result #0 must be vector of Float32 values of length 2, but got 'vector<2xi32>'}}984  %0 = spirv.GL.UnpackHalf2x16 %arg0 : i32 -> vector<2xi32>985  return986}987 988// -----989 990func.func @unpack_half_2x16_vec_in(%arg0 : vector<2xf32>) -> () {991  // expected-error @+1 {{invalid kind of type specified: expected builtin.integer, but found 'vector<2xf32>'}}992  %0 = spirv.GL.UnpackHalf2x16 %arg0 : vector<2xf32> -> vector<2xf32>993  return994}995 996// -----997 998func.func @unpack_half_2x16_scalar_out(%arg0 : i32) -> () {999  // expected-error @+1 {{invalid kind of type specified: expected builtin.vector, but found 'f32'}}1000  %0 = spirv.GL.UnpackHalf2x16 %arg0 : i32 -> f321001  return1002}1003 1004// -----1005 1006//===----------------------------------------------------------------------===//1007// spirv.GL.Length1008//===----------------------------------------------------------------------===//1009 1010func.func @length(%arg0 : f32) -> () {1011  // CHECK: spirv.GL.Length {{%.*}} : f32 -> f321012  %0 = spirv.GL.Length %arg0 : f32 -> f321013  return1014}1015 1016func.func @lengthvec(%arg0 : vector<3xf32>) -> () {1017  // CHECK: spirv.GL.Length {{%.*}} : vector<3xf32> -> f321018  %0 = spirv.GL.Length %arg0 : vector<3xf32> -> f321019  return1020}1021 1022// -----1023 1024func.func @length_i32_in(%arg0 : i32) -> () {1025  // expected-error @+1 {{op operand #0 must be 16/32/64-bit float or fixed-length vector of 16/32/64-bit float values of length 2/3/4/8/16, but got 'i32'}}1026  %0 = spirv.GL.Length %arg0 : i32 -> f321027  return1028}1029 1030// -----1031 1032func.func @length_f16_in(%arg0 : f16) -> () {1033  // expected-error @+1 {{op failed to verify that result type must match operand element type}}1034  %0 = spirv.GL.Length %arg0 : f16 -> f321035  return1036}1037 1038// -----1039 1040func.func @length_i32vec_in(%arg0 : vector<3xi32>) -> () {1041  // expected-error @+1 {{op operand #0 must be 16/32/64-bit float or fixed-length vector of 16/32/64-bit float values of length 2/3/4/8/16, but got 'vector<3xi32>'}}1042  %0 = spirv.GL.Length %arg0 : vector<3xi32> -> f321043  return1044}1045 1046// -----1047 1048func.func @length_f16vec_in(%arg0 : vector<3xf16>) -> () {1049  // expected-error @+1 {{op failed to verify that result type must match operand element type}}1050  %0 = spirv.GL.Length %arg0 : vector<3xf16> -> f321051  return1052}1053 1054// -----1055 1056func.func @length_i32_out(%arg0 : vector<3xf32>) -> () {1057  // expected-error @+1 {{op result #0 must be 16/32/64-bit float, but got 'i32'}}1058  %0 = spirv.GL.Length %arg0 : vector<3xf32> -> i321059  return1060}1061 1062// -----1063 1064func.func @length_vec_out(%arg0 : vector<3xf32>) -> () {1065  // expected-error @+1 {{op result #0 must be 16/32/64-bit float, but got 'vector<3xf32>'}}1066  %0 = spirv.GL.Length %arg0 : vector<3xf32> -> vector<3xf32>1067  return1068}1069