[PATCH] D71881: [mlir] Convert std.and/std.or ops to spv.LogicalAnd/spv.LogicalOr
Mahesh Ravishankar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 27 11:39:45 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc3d3569d4ca6: [mlir] Convert std.and/std.or ops to spv.LogicalAnd/spv.LogicalOr (authored by mravishankar).
Changed prior to commit:
https://reviews.llvm.org/D71881?vs=235306&id=235440#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D71881/new/
https://reviews.llvm.org/D71881
Files:
mlir/lib/Conversion/StandardToSPIRV/StandardToSPIRV.td
mlir/test/Conversion/StandardToSPIRV/std-to-spirv.mlir
Index: mlir/test/Conversion/StandardToSPIRV/std-to-spirv.mlir
===================================================================
--- mlir/test/Conversion/StandardToSPIRV/std-to-spirv.mlir
+++ mlir/test/Conversion/StandardToSPIRV/std-to-spirv.mlir
@@ -135,6 +135,46 @@
}
//===----------------------------------------------------------------------===//
+// std logical binary operations
+//===----------------------------------------------------------------------===//
+
+// CHECK-LABEL: @logical_scalar
+func @logical_scalar(%arg0 : i1, %arg1 : i1) {
+ // CHECK: spv.LogicalAnd
+ %0 = and %arg0, %arg1 : i1
+ // CHECK: spv.LogicalOr
+ %1 = or %arg0, %arg1 : i1
+ return
+}
+
+// CHECK-LABEL: @logical_vector
+func @logical_vector(%arg0 : vector<4xi1>, %arg1 : vector<4xi1>) {
+ // CHECK: spv.LogicalAnd
+ %0 = and %arg0, %arg1 : vector<4xi1>
+ // CHECK: spv.LogicalOr
+ %1 = or %arg0, %arg1 : vector<4xi1>
+ return
+}
+
+// CHECK-LABEL: @logical_scalar_fail
+func @logical_scalar_fail(%arg0 : i32, %arg1 : i32) {
+ // CHECK-NOT: spv.LogicalAnd
+ %0 = and %arg0, %arg1 : i32
+ // CHECK-NOT: spv.LogicalOr
+ %1 = or %arg0, %arg1 : i32
+ return
+}
+
+// CHECK-LABEL: @logical_vector_fail
+func @logical_vector_fail(%arg0 : vector<4xi32>, %arg1 : vector<4xi32>) {
+ // CHECK-NOT: spv.LogicalAnd
+ %0 = and %arg0, %arg1 : vector<4xi32>
+ // CHECK-NOT: spv.LogicalOr
+ %1 = or %arg0, %arg1 : vector<4xi32>
+ return
+}
+
+//===----------------------------------------------------------------------===//
// std.select
//===----------------------------------------------------------------------===//
Index: mlir/lib/Conversion/StandardToSPIRV/StandardToSPIRV.td
===================================================================
--- mlir/lib/Conversion/StandardToSPIRV/StandardToSPIRV.td
+++ mlir/lib/Conversion/StandardToSPIRV/StandardToSPIRV.td
@@ -16,15 +16,17 @@
include "mlir/Dialect/StandardOps/Ops.td"
include "mlir/Dialect/SPIRV/SPIRVOps.td"
-class BinaryOpPattern<Op src, Op tgt> :
- Pat<(src SPV_ScalarOrVector:$l, SPV_ScalarOrVector:$r),
+class BinaryOpPattern<Type type, Op src, Op tgt> :
+ Pat<(src SPV_ScalarOrVectorOf<type>:$l, SPV_ScalarOrVectorOf<type>:$r),
(tgt $l, $r)>;
-def : BinaryOpPattern<AddFOp, SPV_FAddOp>;
-def : BinaryOpPattern<DivFOp, SPV_FDivOp>;
-def : BinaryOpPattern<MulFOp, SPV_FMulOp>;
-def : BinaryOpPattern<RemFOp, SPV_FRemOp>;
-def : BinaryOpPattern<SubFOp, SPV_FSubOp>;
+def : BinaryOpPattern<SPV_Bool, AndOp, SPV_LogicalAndOp>;
+def : BinaryOpPattern<SPV_Bool, OrOp, SPV_LogicalOrOp>;
+def : BinaryOpPattern<SPV_Float, AddFOp, SPV_FAddOp>;
+def : BinaryOpPattern<SPV_Float, DivFOp, SPV_FDivOp>;
+def : BinaryOpPattern<SPV_Float, MulFOp, SPV_FMulOp>;
+def : BinaryOpPattern<SPV_Float, RemFOp, SPV_FRemOp>;
+def : BinaryOpPattern<SPV_Float, SubFOp, SPV_FSubOp>;
// Constant Op
// TODO(ravishankarm): Handle lowering other constant types.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71881.235440.patch
Type: text/x-patch
Size: 2928 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191227/7fa97a96/attachment.bin>
More information about the llvm-commits
mailing list