spirv-writer: Fix | and & on bool and bool-vec
Fixed: tint:861 Change-Id: Ib9709b3793fb5c405f4ba519c189295999f556ee Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/53280 Auto-Submit: David Neto <dneto@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: James Price <jrprice@google.com> Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
parent
9834fefa7f
commit
6b22219798
|
@ -1892,7 +1892,14 @@ uint32_t Builder::GenerateBinaryExpression(ast::BinaryExpression* expr) {
|
|||
|
||||
spv::Op op = spv::Op::OpNop;
|
||||
if (expr->IsAnd()) {
|
||||
op = spv::Op::OpBitwiseAnd;
|
||||
if (lhs_is_integer_or_vec) {
|
||||
op = spv::Op::OpBitwiseAnd;
|
||||
} else if (lhs_is_bool_or_vec) {
|
||||
op = spv::Op::OpLogicalAnd;
|
||||
} else {
|
||||
error_ = "invalid and expression";
|
||||
return 0;
|
||||
}
|
||||
} else if (expr->IsAdd()) {
|
||||
op = lhs_is_float_or_vec ? spv::Op::OpFAdd : spv::Op::OpIAdd;
|
||||
} else if (expr->IsDivide()) {
|
||||
|
@ -2006,7 +2013,14 @@ uint32_t Builder::GenerateBinaryExpression(ast::BinaryExpression* expr) {
|
|||
return 0;
|
||||
}
|
||||
} else if (expr->IsOr()) {
|
||||
op = spv::Op::OpBitwiseOr;
|
||||
if (lhs_is_integer_or_vec) {
|
||||
op = spv::Op::OpBitwiseOr;
|
||||
} else if (lhs_is_bool_or_vec) {
|
||||
op = spv::Op::OpLogicalOr;
|
||||
} else {
|
||||
error_ = "invalid and expression";
|
||||
return 0;
|
||||
}
|
||||
} else if (expr->IsShiftLeft()) {
|
||||
op = spv::Op::OpShiftLeftLogical;
|
||||
} else if (expr->IsShiftRight() && lhs_type->is_signed_scalar_or_vector()) {
|
||||
|
|
|
@ -250,8 +250,8 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
BinaryData{ast::BinaryOp::kMultiply, "OpFMul"},
|
||||
BinaryData{ast::BinaryOp::kSubtract, "OpFSub"}));
|
||||
|
||||
using BinaryCompareBoolTest = TestParamHelper<BinaryData>;
|
||||
TEST_P(BinaryCompareBoolTest, Scalar) {
|
||||
using BinaryOperatorBoolTest = TestParamHelper<BinaryData>;
|
||||
TEST_P(BinaryOperatorBoolTest, Scalar) {
|
||||
auto param = GetParam();
|
||||
|
||||
auto* lhs = Expr(true);
|
||||
|
@ -274,7 +274,7 @@ TEST_P(BinaryCompareBoolTest, Scalar) {
|
|||
"%4 = " + param.name + " %1 %2 %3\n");
|
||||
}
|
||||
|
||||
TEST_P(BinaryCompareBoolTest, Vector) {
|
||||
TEST_P(BinaryOperatorBoolTest, Vector) {
|
||||
auto param = GetParam();
|
||||
|
||||
auto* lhs = vec3<bool>(false, true, false);
|
||||
|
@ -301,9 +301,11 @@ TEST_P(BinaryCompareBoolTest, Vector) {
|
|||
}
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
BuilderTest,
|
||||
BinaryCompareBoolTest,
|
||||
BinaryOperatorBoolTest,
|
||||
testing::Values(BinaryData{ast::BinaryOp::kEqual, "OpLogicalEqual"},
|
||||
BinaryData{ast::BinaryOp::kNotEqual, "OpLogicalNotEqual"}));
|
||||
BinaryData{ast::BinaryOp::kNotEqual, "OpLogicalNotEqual"},
|
||||
BinaryData{ast::BinaryOp::kAnd, "OpLogicalAnd"},
|
||||
BinaryData{ast::BinaryOp::kOr, "OpLogicalOr"}));
|
||||
|
||||
using BinaryCompareUnsignedIntegerTest = TestParamHelper<BinaryData>;
|
||||
TEST_P(BinaryCompareUnsignedIntegerTest, Scalar) {
|
||||
|
|
Loading…
Reference in New Issue