[Mlir-commits] [mlir] 6edb49e - [mlir][arith][spirv] Remove duplicate test cases
Jakub Kuderski
llvmlistbot at llvm.org
Fri Nov 4 12:11:45 PDT 2022
Author: Jakub Kuderski
Date: 2022-11-04T15:11:09-04:00
New Revision: 6edb49eee2fd05c35642110f35766584428857b7
URL: https://github.com/llvm/llvm-project/commit/6edb49eee2fd05c35642110f35766584428857b7
DIFF: https://github.com/llvm/llvm-project/commit/6edb49eee2fd05c35642110f35766584428857b7.diff
LOG: [mlir][arith][spirv] Remove duplicate test cases
Reviewed By: antiagainst
Differential Revision: https://reviews.llvm.org/D137166
Added:
Modified:
mlir/test/Conversion/ArithToSPIRV/arith-to-spirv.mlir
Removed:
################################################################################
diff --git a/mlir/test/Conversion/ArithToSPIRV/arith-to-spirv.mlir b/mlir/test/Conversion/ArithToSPIRV/arith-to-spirv.mlir
index d561cd2c26f29..2f7fb592c896a 100644
--- a/mlir/test/Conversion/ArithToSPIRV/arith-to-spirv.mlir
+++ b/mlir/test/Conversion/ArithToSPIRV/arith-to-spirv.mlir
@@ -282,6 +282,15 @@ func.func @cmpf(%arg0 : f32, %arg1 : f32) {
return
}
+// CHECK-LABEL: @vec1cmpf
+func.func @vec1cmpf(%arg0 : vector<1xf32>, %arg1 : vector<1xf32>) {
+ // CHECK: spirv.FOrdGreaterThan
+ %0 = arith.cmpf ogt, %arg0, %arg1 : vector<1xf32>
+ // CHECK: spirv.FUnordLessThan
+ %1 = arith.cmpf ult, %arg0, %arg1 : vector<1xf32>
+ return
+}
+
} // end module
// -----
@@ -466,9 +475,9 @@ func.func @constant() {
// CHECK: spirv.Constant dense<{{\[}}1, 2, 3, 4, 5, 6]> : tensor<6xi32> : !spirv.array<6 x i32>
%8 = arith.constant dense<[[1, 2, 3], [4, 5, 6]]> : tensor<2x3xi32>
// CHECK: spirv.Constant dense<{{\[}}1, 2, 3, 4, 5, 6]> : tensor<6xi32> : !spirv.array<6 x i32>
- %9 = arith.constant dense<[[1, 2], [3, 4], [5, 6]]> : tensor<3x2xi32>
+ %9 = arith.constant dense<[[1, 2], [3, 4], [5, 6]]> : tensor<3x2xi32>
// CHECK: spirv.Constant dense<{{\[}}1, 2, 3, 4, 5, 6]> : tensor<6xi32> : !spirv.array<6 x i32>
- %10 = arith.constant dense<[1, 2, 3, 4, 5, 6]> : tensor<6xi32>
+ %10 = arith.constant dense<[1, 2, 3, 4, 5, 6]> : tensor<6xi32>
return
}
@@ -1175,564 +1184,3 @@ func.func @float_scalar(%arg0: f16) {
}
} // end module
-
-// -----
-
-//===----------------------------------------------------------------------===//
-// std bit ops
-//===----------------------------------------------------------------------===//
-
-module attributes {
- spirv.target_env = #spirv.target_env<#spirv.vce<v1.0, [], []>, #spirv.resource_limits<>>
-} {
-
-// CHECK-LABEL: @bitwise_scalar
-func.func @bitwise_scalar(%arg0 : i32, %arg1 : i32) {
- // CHECK: spirv.BitwiseAnd
- %0 = arith.andi %arg0, %arg1 : i32
- // CHECK: spirv.BitwiseOr
- %1 = arith.ori %arg0, %arg1 : i32
- // CHECK: spirv.BitwiseXor
- %2 = arith.xori %arg0, %arg1 : i32
- return
-}
-
-// CHECK-LABEL: @bitwise_vector
-func.func @bitwise_vector(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) {
- // CHECK: spirv.BitwiseAnd
- %0 = arith.andi %arg0, %arg1 : vector<4xi32>
- // CHECK: spirv.BitwiseOr
- %1 = arith.ori %arg0, %arg1 : vector<4xi32>
- // CHECK: spirv.BitwiseXor
- %2 = arith.xori %arg0, %arg1 : vector<4xi32>
- return
-}
-
-// CHECK-LABEL: @logical_scalar
-func.func @logical_scalar(%arg0 : i1, %arg1 : i1) {
- // CHECK: spirv.LogicalAnd
- %0 = arith.andi %arg0, %arg1 : i1
- // CHECK: spirv.LogicalOr
- %1 = arith.ori %arg0, %arg1 : i1
- // CHECK: spirv.LogicalNotEqual
- %2 = arith.xori %arg0, %arg1 : i1
- return
-}
-
-// CHECK-LABEL: @logical_vector
-func.func @logical_vector(%arg0 : vector<4xi1>, %arg1 : vector<4xi1>) {
- // CHECK: spirv.LogicalAnd
- %0 = arith.andi %arg0, %arg1 : vector<4xi1>
- // CHECK: spirv.LogicalOr
- %1 = arith.ori %arg0, %arg1 : vector<4xi1>
- // CHECK: spirv.LogicalNotEqual
- %2 = arith.xori %arg0, %arg1 : vector<4xi1>
- return
-}
-
-// CHECK-LABEL: @shift_scalar
-func.func @shift_scalar(%arg0 : i32, %arg1 : i32) {
- // CHECK: spirv.ShiftLeftLogical
- %0 = arith.shli %arg0, %arg1 : i32
- // CHECK: spirv.ShiftRightArithmetic
- %1 = arith.shrsi %arg0, %arg1 : i32
- // CHECK: spirv.ShiftRightLogical
- %2 = arith.shrui %arg0, %arg1 : i32
- return
-}
-
-// CHECK-LABEL: @shift_vector
-func.func @shift_vector(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) {
- // CHECK: spirv.ShiftLeftLogical
- %0 = arith.shli %arg0, %arg1 : vector<4xi32>
- // CHECK: spirv.ShiftRightArithmetic
- %1 = arith.shrsi %arg0, %arg1 : vector<4xi32>
- // CHECK: spirv.ShiftRightLogical
- %2 = arith.shrui %arg0, %arg1 : vector<4xi32>
- return
-}
-
-} // end module
-
-// -----
-
-//===----------------------------------------------------------------------===//
-// arith.cmpf
-//===----------------------------------------------------------------------===//
-
-module attributes {
- spirv.target_env = #spirv.target_env<#spirv.vce<v1.0, [], []>, #spirv.resource_limits<>>
-} {
-
-// CHECK-LABEL: @cmpf
-func.func @cmpf(%arg0 : f32, %arg1 : f32) {
- // CHECK: spirv.FOrdEqual
- %1 = arith.cmpf oeq, %arg0, %arg1 : f32
- // CHECK: spirv.FOrdGreaterThan
- %2 = arith.cmpf ogt, %arg0, %arg1 : f32
- // CHECK: spirv.FOrdGreaterThanEqual
- %3 = arith.cmpf oge, %arg0, %arg1 : f32
- // CHECK: spirv.FOrdLessThan
- %4 = arith.cmpf olt, %arg0, %arg1 : f32
- // CHECK: spirv.FOrdLessThanEqual
- %5 = arith.cmpf ole, %arg0, %arg1 : f32
- // CHECK: spirv.FOrdNotEqual
- %6 = arith.cmpf one, %arg0, %arg1 : f32
- // CHECK: spirv.FUnordEqual
- %7 = arith.cmpf ueq, %arg0, %arg1 : f32
- // CHECK: spirv.FUnordGreaterThan
- %8 = arith.cmpf ugt, %arg0, %arg1 : f32
- // CHECK: spirv.FUnordGreaterThanEqual
- %9 = arith.cmpf uge, %arg0, %arg1 : f32
- // CHECK: spirv.FUnordLessThan
- %10 = arith.cmpf ult, %arg0, %arg1 : f32
- // CHECK: FUnordLessThanEqual
- %11 = arith.cmpf ule, %arg0, %arg1 : f32
- // CHECK: spirv.FUnordNotEqual
- %12 = arith.cmpf une, %arg0, %arg1 : f32
- return
-}
-
-// CHECK-LABEL: @vec1cmpf
-func.func @vec1cmpf(%arg0 : vector<1xf32>, %arg1 : vector<1xf32>) {
- // CHECK: spirv.FOrdGreaterThan
- %0 = arith.cmpf ogt, %arg0, %arg1 : vector<1xf32>
- // CHECK: spirv.FUnordLessThan
- %1 = arith.cmpf ult, %arg0, %arg1 : vector<1xf32>
- return
-}
-
-} // end module
-
-// -----
-
-// With Kernel capability, we can convert NaN check to spirv.Ordered/spirv.Unordered.
-module attributes {
- spirv.target_env = #spirv.target_env<#spirv.vce<v1.0, [Kernel], []>, #spirv.resource_limits<>>
-} {
-
-// CHECK-LABEL: @cmpf
-func.func @cmpf(%arg0 : f32, %arg1 : f32) {
- // CHECK: spirv.Ordered
- %0 = arith.cmpf ord, %arg0, %arg1 : f32
- // CHECK: spirv.Unordered
- %1 = arith.cmpf uno, %arg0, %arg1 : f32
- return
-}
-
-} // end module
-
-// -----
-
-// Without Kernel capability, we need to convert NaN check to spirv.IsNan.
-module attributes {
- spirv.target_env = #spirv.target_env<#spirv.vce<v1.0, [], []>, #spirv.resource_limits<>>
-} {
-
-// CHECK-LABEL: @cmpf
-// CHECK-SAME: %[[LHS:.+]]: f32, %[[RHS:.+]]: f32
-func.func @cmpf(%arg0 : f32, %arg1 : f32) {
- // CHECK: %[[LHS_NAN:.+]] = spirv.IsNan %[[LHS]] : f32
- // CHECK-NEXT: %[[RHS_NAN:.+]] = spirv.IsNan %[[RHS]] : f32
- // CHECK-NEXT: %[[OR:.+]] = spirv.LogicalOr %[[LHS_NAN]], %[[RHS_NAN]] : i1
- // CHECK-NEXT: %{{.+}} = spirv.LogicalNot %[[OR]] : i1
- %0 = arith.cmpf ord, %arg0, %arg1 : f32
-
- // CHECK-NEXT: %[[LHS_NAN:.+]] = spirv.IsNan %[[LHS]] : f32
- // CHECK-NEXT: %[[RHS_NAN:.+]] = spirv.IsNan %[[RHS]] : f32
- // CHECK-NEXT: %{{.+}} = spirv.LogicalOr %[[LHS_NAN]], %[[RHS_NAN]] : i1
- %1 = arith.cmpf uno, %arg0, %arg1 : f32
- return
-}
-
-} // end module
-
-// -----
-
-//===----------------------------------------------------------------------===//
-// arith.cmpi
-//===----------------------------------------------------------------------===//
-
-module attributes {
- spirv.target_env = #spirv.target_env<#spirv.vce<v1.0, [], []>, #spirv.resource_limits<>>
-} {
-
-// CHECK-LABEL: @cmpi
-func.func @cmpi(%arg0 : i32, %arg1 : i32) {
- // CHECK: spirv.IEqual
- %0 = arith.cmpi eq, %arg0, %arg1 : i32
- // CHECK: spirv.INotEqual
- %1 = arith.cmpi ne, %arg0, %arg1 : i32
- // CHECK: spirv.SLessThan
- %2 = arith.cmpi slt, %arg0, %arg1 : i32
- // CHECK: spirv.SLessThanEqual
- %3 = arith.cmpi sle, %arg0, %arg1 : i32
- // CHECK: spirv.SGreaterThan
- %4 = arith.cmpi sgt, %arg0, %arg1 : i32
- // CHECK: spirv.SGreaterThanEqual
- %5 = arith.cmpi sge, %arg0, %arg1 : i32
- // CHECK: spirv.ULessThan
- %6 = arith.cmpi ult, %arg0, %arg1 : i32
- // CHECK: spirv.ULessThanEqual
- %7 = arith.cmpi ule, %arg0, %arg1 : i32
- // CHECK: spirv.UGreaterThan
- %8 = arith.cmpi ugt, %arg0, %arg1 : i32
- // CHECK: spirv.UGreaterThanEqual
- %9 = arith.cmpi uge, %arg0, %arg1 : i32
- return
-}
-
-// CHECK-LABEL: @boolcmpi
-func.func @boolcmpi(%arg0 : i1, %arg1 : i1) {
- // CHECK: spirv.LogicalEqual
- %0 = arith.cmpi eq, %arg0, %arg1 : i1
- // CHECK: spirv.LogicalNotEqual
- %1 = arith.cmpi ne, %arg0, %arg1 : i1
- return
-}
-
-// CHECK-LABEL: @vecboolcmpi
-func.func @vecboolcmpi(%arg0 : vector<4xi1>, %arg1 : vector<4xi1>) {
- // CHECK: spirv.LogicalEqual
- %0 = arith.cmpi eq, %arg0, %arg1 : vector<4xi1>
- // CHECK: spirv.LogicalNotEqual
- %1 = arith.cmpi ne, %arg0, %arg1 : vector<4xi1>
- return
-}
-
-} // end module
-
-// -----
-
-//===----------------------------------------------------------------------===//
-// arith.constant
-//===----------------------------------------------------------------------===//
-
-module attributes {
- spirv.target_env = #spirv.target_env<
- #spirv.vce<v1.0, [Int8, Int16, Int64, Float16, Float64], []>, #spirv.resource_limits<>>
-} {
-
-// CHECK-LABEL: @constant
-func.func @constant() {
- // CHECK: spirv.Constant true
- %0 = arith.constant true
- // CHECK: spirv.Constant 42 : i32
- %1 = arith.constant 42 : i32
- // CHECK: spirv.Constant 5.000000e-01 : f32
- %2 = arith.constant 0.5 : f32
- // CHECK: spirv.Constant dense<[2, 3]> : vector<2xi32>
- %3 = arith.constant dense<[2, 3]> : vector<2xi32>
- // CHECK: spirv.Constant 1 : i32
- %4 = arith.constant 1 : index
- // CHECK: spirv.Constant dense<1> : tensor<6xi32> : !spirv.array<6 x i32>
- %5 = arith.constant dense<1> : tensor<2x3xi32>
- // CHECK: spirv.Constant dense<1.000000e+00> : tensor<6xf32> : !spirv.array<6 x f32>
- %6 = arith.constant dense<1.0> : tensor<2x3xf32>
- // CHECK: spirv.Constant dense<{{\[}}1.000000e+00, 2.000000e+00, 3.000000e+00, 4.000000e+00, 5.000000e+00, 6.000000e+00]> : tensor<6xf32> : !spirv.array<6 x f32>
- %7 = arith.constant dense<[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]> : tensor<2x3xf32>
- // CHECK: spirv.Constant dense<{{\[}}1, 2, 3, 4, 5, 6]> : tensor<6xi32> : !spirv.array<6 x i32>
- %8 = arith.constant dense<[[1, 2, 3], [4, 5, 6]]> : tensor<2x3xi32>
- // CHECK: spirv.Constant dense<{{\[}}1, 2, 3, 4, 5, 6]> : tensor<6xi32> : !spirv.array<6 x i32>
- %9 = arith.constant dense<[[1, 2], [3, 4], [5, 6]]> : tensor<3x2xi32>
- // CHECK: spirv.Constant dense<{{\[}}1, 2, 3, 4, 5, 6]> : tensor<6xi32> : !spirv.array<6 x i32>
- %10 = arith.constant dense<[1, 2, 3, 4, 5, 6]> : tensor<6xi32>
- return
-}
-
-// CHECK-LABEL: @constant_16bit
-func.func @constant_16bit() {
- // CHECK: spirv.Constant 4 : i16
- %0 = arith.constant 4 : i16
- // CHECK: spirv.Constant 5.000000e+00 : f16
- %1 = arith.constant 5.0 : f16
- // CHECK: spirv.Constant dense<[2, 3]> : vector<2xi16>
- %2 = arith.constant dense<[2, 3]> : vector<2xi16>
- // CHECK: spirv.Constant dense<4.000000e+00> : tensor<5xf16> : !spirv.array<5 x f16>
- %3 = arith.constant dense<4.0> : tensor<5xf16>
- return
-}
-
-// CHECK-LABEL: @constant_64bit
-func.func @constant_64bit() {
- // CHECK: spirv.Constant 4 : i64
- %0 = arith.constant 4 : i64
- // CHECK: spirv.Constant 5.000000e+00 : f64
- %1 = arith.constant 5.0 : f64
- // CHECK: spirv.Constant dense<[2, 3]> : vector<2xi64>
- %2 = arith.constant dense<[2, 3]> : vector<2xi64>
- // CHECK: spirv.Constant dense<4.000000e+00> : tensor<5xf64> : !spirv.array<5 x f64>
- %3 = arith.constant dense<4.0> : tensor<5xf64>
- return
-}
-
-} // end module
-
-// -----
-
-//===----------------------------------------------------------------------===//
-// std cast ops
-//===----------------------------------------------------------------------===//
-
-module attributes {
- spirv.target_env = #spirv.target_env<
- #spirv.vce<v1.0, [Int8, Int16, Int64, Float16, Float64], []>, #spirv.resource_limits<>>
-} {
-
-// CHECK-LABEL: index_cast1
-func.func @index_cast1(%arg0: i16) {
- // CHECK: spirv.SConvert %{{.+}} : i16 to i32
- %0 = arith.index_cast %arg0 : i16 to index
- return
-}
-
-// CHECK-LABEL: index_cast2
-func.func @index_cast2(%arg0: index) {
- // CHECK: spirv.SConvert %{{.+}} : i32 to i16
- %0 = arith.index_cast %arg0 : index to i16
- return
-}
-
-// CHECK-LABEL: index_cast3
-func.func @index_cast3(%arg0: i32) {
- // CHECK-NOT: spirv.SConvert
- %0 = arith.index_cast %arg0 : i32 to index
- return
-}
-
-// CHECK-LABEL: index_cast4
-func.func @index_cast4(%arg0: index) {
- // CHECK-NOT: spirv.SConvert
- %0 = arith.index_cast %arg0 : index to i32
- return
-}
-
-// CHECK-LABEL: @fpext1
-func.func @fpext1(%arg0: f16) -> f64 {
- // CHECK: spirv.FConvert %{{.*}} : f16 to f64
- %0 = arith.extf %arg0 : f16 to f64
- return %0 : f64
-}
-
-// CHECK-LABEL: @fpext2
-func.func @fpext2(%arg0 : f32) -> f64 {
- // CHECK: spirv.FConvert %{{.*}} : f32 to f64
- %0 = arith.extf %arg0 : f32 to f64
- return %0 : f64
-}
-
-// CHECK-LABEL: @fptrunc1
-func.func @fptrunc1(%arg0 : f64) -> f16 {
- // CHECK: spirv.FConvert %{{.*}} : f64 to f16
- %0 = arith.truncf %arg0 : f64 to f16
- return %0 : f16
-}
-
-// CHECK-LABEL: @fptrunc2
-func.func @fptrunc2(%arg0: f32) -> f16 {
- // CHECK: spirv.FConvert %{{.*}} : f32 to f16
- %0 = arith.truncf %arg0 : f32 to f16
- return %0 : f16
-}
-
-// CHECK-LABEL: @sitofp1
-func.func @sitofp1(%arg0 : i32) -> f32 {
- // CHECK: spirv.ConvertSToF %{{.*}} : i32 to f32
- %0 = arith.sitofp %arg0 : i32 to f32
- return %0 : f32
-}
-
-// CHECK-LABEL: @sitofp2
-func.func @sitofp2(%arg0 : i64) -> f64 {
- // CHECK: spirv.ConvertSToF %{{.*}} : i64 to f64
- %0 = arith.sitofp %arg0 : i64 to f64
- return %0 : f64
-}
-
-// CHECK-LABEL: @uitofp_i16_f32
-func.func @uitofp_i16_f32(%arg0: i16) -> f32 {
- // CHECK: spirv.ConvertUToF %{{.*}} : i16 to f32
- %0 = arith.uitofp %arg0 : i16 to f32
- return %0 : f32
-}
-
-// CHECK-LABEL: @uitofp_i32_f32
-func.func @uitofp_i32_f32(%arg0 : i32) -> f32 {
- // CHECK: spirv.ConvertUToF %{{.*}} : i32 to f32
- %0 = arith.uitofp %arg0 : i32 to f32
- return %0 : f32
-}
-
-// CHECK-LABEL: @uitofp_i1_f32
-func.func @uitofp_i1_f32(%arg0 : i1) -> f32 {
- // CHECK: %[[ZERO:.+]] = spirv.Constant 0.000000e+00 : f32
- // CHECK: %[[ONE:.+]] = spirv.Constant 1.000000e+00 : f32
- // CHECK: spirv.Select %{{.*}}, %[[ONE]], %[[ZERO]] : i1, f32
- %0 = arith.uitofp %arg0 : i1 to f32
- return %0 : f32
-}
-
-// CHECK-LABEL: @uitofp_i1_f64
-func.func @uitofp_i1_f64(%arg0 : i1) -> f64 {
- // CHECK: %[[ZERO:.+]] = spirv.Constant 0.000000e+00 : f64
- // CHECK: %[[ONE:.+]] = spirv.Constant 1.000000e+00 : f64
- // CHECK: spirv.Select %{{.*}}, %[[ONE]], %[[ZERO]] : i1, f64
- %0 = arith.uitofp %arg0 : i1 to f64
- return %0 : f64
-}
-
-// CHECK-LABEL: @uitofp_vec_i1_f32
-func.func @uitofp_vec_i1_f32(%arg0 : vector<4xi1>) -> vector<4xf32> {
- // CHECK: %[[ZERO:.+]] = spirv.Constant dense<0.000000e+00> : vector<4xf32>
- // CHECK: %[[ONE:.+]] = spirv.Constant dense<1.000000e+00> : vector<4xf32>
- // CHECK: spirv.Select %{{.*}}, %[[ONE]], %[[ZERO]] : vector<4xi1>, vector<4xf32>
- %0 = arith.uitofp %arg0 : vector<4xi1> to vector<4xf32>
- return %0 : vector<4xf32>
-}
-
-// CHECK-LABEL: @uitofp_vec_i1_f64
-spirv.func @uitofp_vec_i1_f64(%arg0: vector<4xi1>) -> vector<4xf64> "None" {
- // CHECK: %[[ZERO:.+]] = spirv.Constant dense<0.000000e+00> : vector<4xf64>
- // CHECK: %[[ONE:.+]] = spirv.Constant dense<1.000000e+00> : vector<4xf64>
- // CHECK: spirv.Select %{{.*}}, %[[ONE]], %[[ZERO]] : vector<4xi1>, vector<4xf64>
- %0 = spirv.Constant dense<0.000000e+00> : vector<4xf64>
- %1 = spirv.Constant dense<1.000000e+00> : vector<4xf64>
- %2 = spirv.Select %arg0, %1, %0 : vector<4xi1>, vector<4xf64>
- spirv.ReturnValue %2 : vector<4xf64>
-}
-
-// CHECK-LABEL: @sexti1
-func.func @sexti1(%arg0: i16) -> i64 {
- // CHECK: spirv.SConvert %{{.*}} : i16 to i64
- %0 = arith.extsi %arg0 : i16 to i64
- return %0 : i64
-}
-
-// CHECK-LABEL: @sexti2
-func.func @sexti2(%arg0 : i32) -> i64 {
- // CHECK: spirv.SConvert %{{.*}} : i32 to i64
- %0 = arith.extsi %arg0 : i32 to i64
- return %0 : i64
-}
-
-// CHECK-LABEL: @zexti1
-func.func @zexti1(%arg0: i16) -> i64 {
- // CHECK: spirv.UConvert %{{.*}} : i16 to i64
- %0 = arith.extui %arg0 : i16 to i64
- return %0 : i64
-}
-
-// CHECK-LABEL: @zexti2
-func.func @zexti2(%arg0 : i32) -> i64 {
- // CHECK: spirv.UConvert %{{.*}} : i32 to i64
- %0 = arith.extui %arg0 : i32 to i64
- return %0 : i64
-}
-
-// CHECK-LABEL: @zexti3
-func.func @zexti3(%arg0 : i1) -> i32 {
- // CHECK: %[[ZERO:.+]] = spirv.Constant 0 : i32
- // CHECK: %[[ONE:.+]] = spirv.Constant 1 : i32
- // CHECK: spirv.Select %{{.*}}, %[[ONE]], %[[ZERO]] : i1, i32
- %0 = arith.extui %arg0 : i1 to i32
- return %0 : i32
-}
-
-// CHECK-LABEL: @zexti4
-func.func @zexti4(%arg0 : vector<4xi1>) -> vector<4xi32> {
- // CHECK: %[[ZERO:.+]] = spirv.Constant dense<0> : vector<4xi32>
- // CHECK: %[[ONE:.+]] = spirv.Constant dense<1> : vector<4xi32>
- // CHECK: spirv.Select %{{.*}}, %[[ONE]], %[[ZERO]] : vector<4xi1>, vector<4xi32>
- %0 = arith.extui %arg0 : vector<4xi1> to vector<4xi32>
- return %0 : vector<4xi32>
-}
-
-// CHECK-LABEL: @zexti5
-func.func @zexti5(%arg0 : vector<4xi1>) -> vector<4xi64> {
- // CHECK: %[[ZERO:.+]] = spirv.Constant dense<0> : vector<4xi64>
- // CHECK: %[[ONE:.+]] = spirv.Constant dense<1> : vector<4xi64>
- // CHECK: spirv.Select %{{.*}}, %[[ONE]], %[[ZERO]] : vector<4xi1>, vector<4xi64>
- %0 = arith.extui %arg0 : vector<4xi1> to vector<4xi64>
- return %0 : vector<4xi64>
-}
-
-// CHECK-LABEL: @trunci1
-func.func @trunci1(%arg0 : i64) -> i16 {
- // CHECK: spirv.SConvert %{{.*}} : i64 to i16
- %0 = arith.trunci %arg0 : i64 to i16
- return %0 : i16
-}
-
-// CHECK-LABEL: @trunci2
-func.func @trunci2(%arg0: i32) -> i16 {
- // CHECK: spirv.SConvert %{{.*}} : i32 to i16
- %0 = arith.trunci %arg0 : i32 to i16
- return %0 : i16
-}
-
-// CHECK-LABEL: @trunc_to_i1
-func.func @trunc_to_i1(%arg0: i32) -> i1 {
- // CHECK: %[[MASK:.*]] = spirv.Constant 1 : i32
- // CHECK: %[[MASKED_SRC:.*]] = spirv.BitwiseAnd %{{.*}}, %[[MASK]] : i32
- // CHECK: %[[IS_ONE:.*]] = spirv.IEqual %[[MASKED_SRC]], %[[MASK]] : i32
- // CHECK-DAG: %[[TRUE:.*]] = spirv.Constant true
- // CHECK-DAG: %[[FALSE:.*]] = spirv.Constant false
- // CHECK: spirv.Select %[[IS_ONE]], %[[TRUE]], %[[FALSE]] : i1, i1
- %0 = arith.trunci %arg0 : i32 to i1
- return %0 : i1
-}
-
-// CHECK-LABEL: @trunc_to_veci1
-func.func @trunc_to_veci1(%arg0: vector<4xi32>) -> vector<4xi1> {
- // CHECK: %[[MASK:.*]] = spirv.Constant dense<1> : vector<4xi32>
- // CHECK: %[[MASKED_SRC:.*]] = spirv.BitwiseAnd %{{.*}}, %[[MASK]] : vector<4xi32>
- // CHECK: %[[IS_ONE:.*]] = spirv.IEqual %[[MASKED_SRC]], %[[MASK]] : vector<4xi32>
- // CHECK-DAG: %[[TRUE:.*]] = spirv.Constant dense<true> : vector<4xi1>
- // CHECK-DAG: %[[FALSE:.*]] = spirv.Constant dense<false> : vector<4xi1>
- // CHECK: spirv.Select %[[IS_ONE]], %[[TRUE]], %[[FALSE]] : vector<4xi1>, vector<4xi1>
- %0 = arith.trunci %arg0 : vector<4xi32> to vector<4xi1>
- return %0 : vector<4xi1>
-}
-
-// CHECK-LABEL: @fptosi1
-func.func @fptosi1(%arg0 : f32) -> i32 {
- // CHECK: spirv.ConvertFToS %{{.*}} : f32 to i32
- %0 = arith.fptosi %arg0 : f32 to i32
- return %0 : i32
-}
-
-// CHECK-LABEL: @fptosi2
-func.func @fptosi2(%arg0 : f16) -> i16 {
- // CHECK: spirv.ConvertFToS %{{.*}} : f16 to i16
- %0 = arith.fptosi %arg0 : f16 to i16
- return %0 : i16
-}
-
-} // end module
-
-// -----
-
-// Checks that cast types will be adjusted when missing special capabilities for
-// certain non-32-bit scalar types.
-module attributes {
- spirv.target_env = #spirv.target_env<#spirv.vce<v1.0, [Float64], []>, #spirv.resource_limits<>>
-} {
-
-// CHECK-LABEL: @fpext1
-// CHECK-SAME: %[[A:.*]]: f16
-func.func @fpext1(%arg0: f16) -> f64 {
- // CHECK: %[[ARG:.+]] = builtin.unrealized_conversion_cast %[[A]] : f16 to f32
- // CHECK-NEXT: spirv.FConvert %[[ARG]] : f32 to f64
- %0 = arith.extf %arg0 : f16 to f64
- return %0: f64
-}
-
-// CHECK-LABEL: @fpext2
-// CHECK-SAME: %[[ARG:.*]]: f32
-func.func @fpext2(%arg0 : f32) -> f64 {
- // CHECK-NEXT: spirv.FConvert %[[ARG]] : f32 to f64
- %0 = arith.extf %arg0 : f32 to f64
- return %0: f64
-}
-
-} // end module
More information about the Mlir-commits
mailing list