[Mlir-commits] [mlir] e866fb8 - [mlir][spirv] Add support for fptoui conversion in ArithToSPIRV

Andrzej Warzynski llvmlistbot at llvm.org
Thu Jan 12 08:38:08 PST 2023


Author: Steve Suzuki
Date: 2023-01-12T16:35:50Z
New Revision: e866fb8606d7ed2e27b194c97a4896e7680da2e0

URL: https://github.com/llvm/llvm-project/commit/e866fb8606d7ed2e27b194c97a4896e7680da2e0
DIFF: https://github.com/llvm/llvm-project/commit/e866fb8606d7ed2e27b194c97a4896e7680da2e0.diff

LOG: [mlir][spirv] Add support for fptoui conversion in ArithToSPIRV

To enable the conversion of arith.fptoui to SPIRV OpConvertFToU

Reviewed By: kuhar

Differential Revision: https://reviews.llvm.org/D141582

Added: 
    

Modified: 
    mlir/lib/Conversion/ArithToSPIRV/ArithToSPIRV.cpp
    mlir/test/Conversion/ArithToSPIRV/arith-to-spirv.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Conversion/ArithToSPIRV/ArithToSPIRV.cpp b/mlir/lib/Conversion/ArithToSPIRV/ArithToSPIRV.cpp
index d48cae30629d1..be46a06ba53ab 100644
--- a/mlir/lib/Conversion/ArithToSPIRV/ArithToSPIRV.cpp
+++ b/mlir/lib/Conversion/ArithToSPIRV/ArithToSPIRV.cpp
@@ -1100,6 +1100,7 @@ void mlir::arith::populateArithToSPIRVPatterns(
     TypeCastingOpPattern<arith::TruncFOp, spirv::FConvertOp>,
     TypeCastingOpPattern<arith::UIToFPOp, spirv::ConvertUToFOp>, UIToFPI1Pattern,
     TypeCastingOpPattern<arith::SIToFPOp, spirv::ConvertSToFOp>,
+    TypeCastingOpPattern<arith::FPToUIOp, spirv::ConvertFToUOp>,
     TypeCastingOpPattern<arith::FPToSIOp, spirv::ConvertFToSOp>,
     TypeCastingOpPattern<arith::IndexCastOp, spirv::SConvertOp>,
     TypeCastingOpPattern<arith::IndexCastUIOp, spirv::UConvertOp>,

diff  --git a/mlir/test/Conversion/ArithToSPIRV/arith-to-spirv.mlir b/mlir/test/Conversion/ArithToSPIRV/arith-to-spirv.mlir
index 3b18295326dab..4c32a8648bd1c 100644
--- a/mlir/test/Conversion/ArithToSPIRV/arith-to-spirv.mlir
+++ b/mlir/test/Conversion/ArithToSPIRV/arith-to-spirv.mlir
@@ -903,6 +903,20 @@ func.func @trunc_to_veci1(%arg0: vector<4xi32>) -> vector<4xi1> {
   return %0 : vector<4xi1>
 }
 
+// CHECK-LABEL: @fptoui1
+func.func @fptoui1(%arg0 : f32) -> i32 {
+  // CHECK: spirv.ConvertFToU %{{.*}} : f32 to i32
+  %0 = arith.fptoui %arg0 : f32 to i32
+  return %0 : i32
+}
+
+// CHECK-LABEL: @fptoui2
+func.func @fptoui2(%arg0 : f16) -> i16 {
+  // CHECK: spirv.ConvertFToU %{{.*}} : f16 to i16
+  %0 = arith.fptoui %arg0 : f16 to i16
+  return %0 : i16
+}
+
 // CHECK-LABEL: @fptosi1
 func.func @fptosi1(%arg0 : f32) -> i32 {
   // CHECK: spirv.ConvertFToS %{{.*}} : f32 to i32


        


More information about the Mlir-commits mailing list