[PATCH] D79143: [mlir][StandardToSPIRV] Add support for lowering integer casting.
Han-Chung Wang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 29 17:18:03 PDT 2020
hanchung updated this revision to Diff 261098.
hanchung added a comment.
Add tests.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D79143/new/
https://reviews.llvm.org/D79143
Files:
mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
mlir/test/Conversion/StandardToSPIRV/std-ops-to-spirv.mlir
Index: mlir/test/Conversion/StandardToSPIRV/std-ops-to-spirv.mlir
===================================================================
--- mlir/test/Conversion/StandardToSPIRV/std-ops-to-spirv.mlir
+++ mlir/test/Conversion/StandardToSPIRV/std-ops-to-spirv.mlir
@@ -501,6 +501,34 @@
return %0 : f64
}
+// CHECK-LABEL: @zexti1
+func @zexti1(%arg0: i16) -> i64 {
+ // CHECK: spv.SConvert %{{.*}} : i16 to i64
+ %0 = std.zexti %arg0 : i16 to i64
+ return %0 : i64
+}
+
+// CHECK-LABEL: @zexti2
+func @zexti2(%arg0 : i32) -> i64 {
+ // CHECK: spv.SConvert %{{.*}} : i32 to i64
+ %0 = std.zexti %arg0 : i32 to i64
+ return %0 : i64
+}
+
+// CHECK-LABEL: @trunci1
+func @trunci1(%arg0 : i64) -> i16 {
+ // CHECK: spv.SConvert %{{.*}} : i64 to i16
+ %0 = std.trunci %arg0 : i64 to i16
+ return %0 : i16
+}
+
+// CHECK-LABEL: @trunci2
+func @trunci2(%arg0: i32) -> i16 {
+ // CHECK: spv.SConvert %{{.*}} : i32 to i16
+ %0 = std.trunci %arg0 : i32 to i16
+ return %0 : i16
+}
+
} // end module
// -----
Index: mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
===================================================================
--- mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
+++ mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
@@ -754,6 +754,8 @@
CmpFOpPattern, CmpIOpPattern, IntLoadOpPattern, LoadOpPattern,
ReturnOpPattern, SelectOpPattern, StoreOpPattern,
TypeCastingOpPattern<SIToFPOp, spirv::ConvertSToFOp>,
+ TypeCastingOpPattern<ZeroExtendIOp, spirv::SConvertOp>,
+ TypeCastingOpPattern<TruncateIOp, spirv::SConvertOp>,
TypeCastingOpPattern<FPExtOp, spirv::FConvertOp>,
TypeCastingOpPattern<FPTruncOp, spirv::FConvertOp>, XOrOpPattern>(
context, typeConverter);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79143.261098.patch
Type: text/x-patch
Size: 1781 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200430/0eb8af49/attachment.bin>
More information about the llvm-commits
mailing list