diff --git a/src/writer/spirv/builder.cc b/src/writer/spirv/builder.cc index 93489a9d41..408ea4b2eb 100644 --- a/src/writer/spirv/builder.cc +++ b/src/writer/spirv/builder.cc @@ -575,7 +575,9 @@ uint32_t Builder::GenerateBinaryExpression(ast::BinaryExpression* expr) { (lhs_type->IsVector() && lhs_type->AsVector()->type()->IsU32()); spv::Op op = spv::Op::OpNop; - if (expr->IsAdd()) { + if (expr->IsAnd()) { + op = spv::Op::OpBitwiseAnd; + } else if (expr->IsAdd()) { op = lhs_is_float_or_vec ? spv::Op::OpFAdd : spv::Op::OpIAdd; } else if (expr->IsEqual()) { op = lhs_is_float_or_vec ? spv::Op::OpFOrdEqual : spv::Op::OpIEqual; diff --git a/src/writer/spirv/builder_binary_expression_test.cc b/src/writer/spirv/builder_binary_expression_test.cc index 9736ce2299..8da3eb8c49 100644 --- a/src/writer/spirv/builder_binary_expression_test.cc +++ b/src/writer/spirv/builder_binary_expression_test.cc @@ -118,10 +118,11 @@ TEST_P(BinaryArithIntegerTest, Vector) { EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), "%5 = " + param.name + " %1 %4 %4\n"); } -INSTANTIATE_TEST_SUITE_P(BuilderTest, - BinaryArithIntegerTest, - testing::Values(BinaryData{ast::BinaryOp::kAdd, - "OpIAdd"})); +INSTANTIATE_TEST_SUITE_P( + BuilderTest, + BinaryArithIntegerTest, + testing::Values(BinaryData{ast::BinaryOp::kAdd, "OpIAdd"}, + BinaryData{ast::BinaryOp::kAnd, "OpBitwiseAnd"})); using BinaryArithFloatTest = testing::TestWithParam; TEST_P(BinaryArithFloatTest, Scalar) {