[Mlir-commits] [mlir] 47fd19f - [mlir][StandardToSPIRV] Extend support for lowering cmpi to SPIRV.
Hanhan Wang
llvmlistbot at llvm.org
Mon Nov 16 06:51:21 PST 2020
Author: Hanhan Wang
Date: 2020-11-16T06:51:05-08:00
New Revision: 47fd19f22eb5e6a7e711ca44f0414e2de7614f4b
URL: https://github.com/llvm/llvm-project/commit/47fd19f22eb5e6a7e711ca44f0414e2de7614f4b
DIFF: https://github.com/llvm/llvm-project/commit/47fd19f22eb5e6a7e711ca44f0414e2de7614f4b.diff
LOG: [mlir][StandardToSPIRV] Extend support for lowering cmpi to SPIRV.
The logic of vector on boolean was missed. This patch adds the logic and test on
it.
Reviewed By: mravishankar
Differential Revision: https://reviews.llvm.org/D91403
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 8736ad4f3343..ac8b82dde9b1 100644
--- a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
+++ b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
@@ -767,8 +767,7 @@ BoolCmpIOpPattern::matchAndRewrite(CmpIOp cmpIOp, ArrayRef<Value> operands,
CmpIOpAdaptor cmpIOpOperands(operands);
Type operandType = cmpIOp.lhs().getType();
- if (!operandType.isa<IntegerType>() ||
- operandType.cast<IntegerType>().getWidth() != 1)
+ if (!isBoolScalarOrVector(operandType))
return failure();
switch (cmpIOp.getPredicate()) {
@@ -794,8 +793,7 @@ CmpIOpPattern::matchAndRewrite(CmpIOp cmpIOp, ArrayRef<Value> operands,
CmpIOpAdaptor cmpIOpOperands(operands);
Type operandType = cmpIOp.lhs().getType();
- if (operandType.isa<IntegerType>() &&
- operandType.cast<IntegerType>().getWidth() == 1)
+ if (isBoolScalarOrVector(operandType))
return failure();
switch (cmpIOp.getPredicate()) {
diff --git a/mlir/test/Conversion/StandardToSPIRV/std-ops-to-spirv.mlir b/mlir/test/Conversion/StandardToSPIRV/std-ops-to-spirv.mlir
index 9f112bb8a6ac..10e43ef4acd7 100644
--- a/mlir/test/Conversion/StandardToSPIRV/std-ops-to-spirv.mlir
+++ b/mlir/test/Conversion/StandardToSPIRV/std-ops-to-spirv.mlir
@@ -327,6 +327,15 @@ func @boolcmpi(%arg0 : i1, %arg1 : i1) {
return
}
+// CHECK-LABEL: @vecboolcmpi
+func @vecboolcmpi(%arg0 : vector<4xi1>, %arg1 : vector<4xi1>) {
+ // CHECK: spv.LogicalEqual
+ %0 = cmpi "eq", %arg0, %arg1 : vector<4xi1>
+ // CHECK: spv.LogicalNotEqual
+ %1 = cmpi "ne", %arg0, %arg1 : vector<4xi1>
+ return
+}
+
} // end module
// -----
More information about the Mlir-commits
mailing list