[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
This commit is contained in:
Hanhan Wang 2020-11-16 06:50:45 -08:00
parent 02bdbdc760
commit 47fd19f22e
2 changed files with 11 additions and 4 deletions

View File

@ -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()) {

View File

@ -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
// -----