[Mlir-commits] [mlir] ac691c4 - [mlir][StandardToSPIRV] Add support for lowering FPToSIOp to SPIR-V.

Hanhan Wang llvmlistbot at llvm.org
Mon May 11 01:28:24 PDT 2020


Author: Hanhan Wang
Date: 2020-05-11T01:27:54-07:00
New Revision: ac691c4fe7f645c5d31fdf5318fcc6b995370f77

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

LOG: [mlir][StandardToSPIRV] Add support for lowering FPToSIOp to SPIR-V.

Summary: Depends On D79373

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

Added: 
    

Modified: 
    mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
    mlir/test/Conversion/StandardToSPIRV/std-ops-to-spirv.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
index 2f7868e89336..ea006c9b7684 100644
--- a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
+++ b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
@@ -870,6 +870,7 @@ void populateStandardToSPIRVPatterns(MLIRContext *context,
       TypeCastingOpPattern<SIToFPOp, spirv::ConvertSToFOp>,
       TypeCastingOpPattern<ZeroExtendIOp, spirv::UConvertOp>,
       TypeCastingOpPattern<TruncateIOp, spirv::SConvertOp>,
+      TypeCastingOpPattern<FPToSIOp, spirv::ConvertFToSOp>,
       TypeCastingOpPattern<FPExtOp, spirv::FConvertOp>,
       TypeCastingOpPattern<FPTruncOp, spirv::FConvertOp>, XOrOpPattern>(
       context, typeConverter);

diff  --git a/mlir/test/Conversion/StandardToSPIRV/std-ops-to-spirv.mlir b/mlir/test/Conversion/StandardToSPIRV/std-ops-to-spirv.mlir
index 3dcc3cdb2115..b6e81a427252 100644
--- a/mlir/test/Conversion/StandardToSPIRV/std-ops-to-spirv.mlir
+++ b/mlir/test/Conversion/StandardToSPIRV/std-ops-to-spirv.mlir
@@ -531,6 +531,20 @@ func @trunci2(%arg0: i32) -> i16 {
   return %0 : i16
 }
 
+// CHECK-LABEL: @fptosi1
+func @fptosi1(%arg0 : f32) -> i32 {
+  // CHECK: spv.ConvertFToS %{{.*}} : f32 to i32
+  %0 = std.fptosi %arg0 : f32 to i32
+  return %0 : i32
+}
+
+// CHECK-LABEL: @fptosi2
+func @fptosi2(%arg0 : f16) -> i16 {
+  // CHECK: spv.ConvertFToS %{{.*}} : f16 to i16
+  %0 = std.fptosi %arg0 : f16 to i16
+  return %0 : i16
+}
+
 } // end module
 
 // -----


        


More information about the Mlir-commits mailing list