tint: const eval of logical AND and OR

Bug: tint:1581
Change-Id: I3921041613cb1c9fa3365d4cb1fc8c81bab92003
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/113101
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
Antonio Maiorano 2022-12-07 13:29:58 +00:00 committed by Dawn LUCI CQ
parent 6198bea2ac
commit 4c8f5a1ac2
34 changed files with 255 additions and 307 deletions

View File

@ -51,7 +51,7 @@ enum extension {
chromium_disable_uniformity_analysis
// A Chromium-specific extension for push constants
chromium_experimental_push_constant
// A Chromium-specific extension that enables passing of uniform, storage and workgroup
// A Chromium-specific extension that enables passing of uniform, storage and workgroup
// address-spaced pointers as parameters, as well as pointers into sub-objects.
chromium_experimental_full_ptr_parameters
}
@ -969,8 +969,8 @@ init mat4x4<T: fa_f32_f16>(vec4<T>, vec4<T>, vec4<T>, vec4<T>) -> mat4x4<T>
@const op | <T: ia_iu32>(T, T) -> T
@const op | <T: ia_iu32, N: num> (vec<N, T>, vec<N, T>) -> vec<N, T>
op && (bool, bool) -> bool
op || (bool, bool) -> bool
@const op && (bool, bool) -> bool
@const op || (bool, bool) -> bool
@const op == <T: scalar>(T, T) -> bool
@const op == <T: scalar, N: num> (vec<N, T>, vec<N, T>) -> vec<N, bool>

View File

@ -1810,6 +1810,18 @@ ConstEval::Result ConstEval::OpGreaterThanEqual(const sem::Type* ty,
return TransformElements(builder, ty, transform, args[0], args[1]);
}
ConstEval::Result ConstEval::OpLogicalAnd(const sem::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
return CreateElement(builder, source, ty, args[0]->As<bool>() && args[1]->As<bool>());
}
ConstEval::Result ConstEval::OpLogicalOr(const sem::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
return CreateElement(builder, source, ty, args[0]->As<bool>() || args[1]->As<bool>());
}
ConstEval::Result ConstEval::OpAnd(const sem::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {

View File

@ -346,6 +346,24 @@ class ConstEval {
utils::VectorRef<const sem::Constant*> args,
const Source& source);
/// Logical and operator '&&'
/// @param ty the expression type
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
Result OpLogicalAnd(const sem::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
/// Logical or operator '||'
/// @param ty the expression type
/// @param args the input arguments
/// @param source the source location
/// @return the result value, or null if the value cannot be calculated
Result OpLogicalOr(const sem::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
/// Bitwise and operator '&'
/// @param ty the expression type
/// @param args the input arguments

View File

@ -749,6 +749,34 @@ INSTANTIATE_TEST_SUITE_P(LessThanEqual,
OpGreaterThanCases<f32, false>(),
OpGreaterThanCases<f16, false>()))));
static std::vector<Case> OpLogicalAndCases() {
return {
C(true, true, true),
C(true, false, false),
C(false, true, false),
C(false, false, false),
};
}
INSTANTIATE_TEST_SUITE_P(LogicalAnd,
ResolverConstEvalBinaryOpTest,
testing::Combine( //
testing::Values(ast::BinaryOp::kLogicalAnd),
testing::ValuesIn(OpLogicalAndCases())));
static std::vector<Case> OpLogicalOrCases() {
return {
C(true, true, true),
C(true, false, true),
C(false, true, true),
C(false, false, false),
};
}
INSTANTIATE_TEST_SUITE_P(LogicalOr,
ResolverConstEvalBinaryOpTest,
testing::Combine( //
testing::Values(ast::BinaryOp::kLogicalOr),
testing::ValuesIn(OpLogicalOrCases())));
static std::vector<Case> OpAndBoolCases() {
return {
C(true, true, true),

View File

@ -13918,7 +13918,7 @@ constexpr OverloadInfo kOverloads[] = {
/* parameters */ &kParameters[746],
/* return matcher indices */ &kMatcherIndices[35],
/* flags */ OverloadFlags(OverloadFlag::kIsOperator, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
/* const eval */ nullptr,
/* const eval */ &ConstEval::OpLogicalAnd,
},
{
/* [469] */
@ -13930,7 +13930,7 @@ constexpr OverloadInfo kOverloads[] = {
/* parameters */ &kParameters[748],
/* return matcher indices */ &kMatcherIndices[35],
/* flags */ OverloadFlags(OverloadFlag::kIsOperator, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
/* const eval */ nullptr,
/* const eval */ &ConstEval::OpLogicalOr,
},
};

View File

@ -212,14 +212,15 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleInit) {
}
TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtInit) {
// for(var b = true && false; ; ) {
// let t = true;
// for(var b = t && false; ; ) {
// return;
// }
auto* multi_stmt =
create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd, Expr(true), Expr(false));
auto* t = Let("t", Expr(true));
auto* multi_stmt = LogicalAnd(t, false);
auto* f = For(Decl(Var("b", multi_stmt)), nullptr, nullptr, Block(Return()));
WrapInFunction(f);
WrapInFunction(t, f);
GeneratorImpl& gen = Build();
@ -227,7 +228,7 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtInit) {
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
EXPECT_EQ(gen.result(), R"( {
bool tint_tmp = true;
bool tint_tmp = t;
if (tint_tmp) {
tint_tmp = false;
}
@ -263,16 +264,16 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleCond) {
}
TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtCond) {
// for(; true && false; ) {
// let t = true;
// for(; t && false; ) {
// return;
// }
Func("a_statement", {}, ty.void_(), {});
auto* multi_stmt =
create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd, Expr(true), Expr(false));
auto* t = Let("t", Expr(true));
auto* multi_stmt = LogicalAnd(t, false);
auto* f = For(nullptr, multi_stmt, nullptr, Block(CallStmt(Call("a_statement"))));
WrapInFunction(f);
WrapInFunction(t, f);
GeneratorImpl& gen = Build();
@ -281,7 +282,7 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtCond) {
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
EXPECT_EQ(gen.result(), R"( {
while (true) {
bool tint_tmp = true;
bool tint_tmp = t;
if (tint_tmp) {
tint_tmp = false;
}
@ -316,16 +317,17 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleCont) {
}
TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtCont) {
// for(; ; i = true && false) {
// let t = true;
// for(; ; i = t && false) {
// return;
// }
auto* multi_stmt =
create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd, Expr(true), Expr(false));
auto* t = Let("t", Expr(true));
auto* multi_stmt = LogicalAnd(t, false);
auto* v = Decl(Var("i", ty.bool_()));
auto* f = For(nullptr, nullptr, Assign("i", multi_stmt), //
Block(Return()));
WrapInFunction(v, f);
WrapInFunction(t, v, f);
GeneratorImpl& gen = Build();
@ -335,7 +337,7 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtCont) {
EXPECT_EQ(gen.result(), R"( {
while (true) {
return;
bool tint_tmp = true;
bool tint_tmp = t;
if (tint_tmp) {
tint_tmp = false;
}
@ -367,20 +369,19 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleInitCondCont) {
}
TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtInitCondCont) {
// for(var i = true && false; true && false; i = true && false) {
// let t = true;
// for(var i = t && false; t && false; i = t && false) {
// return;
// }
auto* multi_stmt_a =
create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd, Expr(true), Expr(false));
auto* multi_stmt_b =
create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd, Expr(true), Expr(false));
auto* multi_stmt_c =
create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd, Expr(true), Expr(false));
auto* t = Let("t", Expr(true));
auto* multi_stmt_a = LogicalAnd(t, false);
auto* multi_stmt_b = LogicalAnd(t, false);
auto* multi_stmt_c = LogicalAnd(t, false);
auto* f = For(Decl(Var("i", multi_stmt_a)), multi_stmt_b, Assign("i", multi_stmt_c), //
Block(Return()));
WrapInFunction(f);
WrapInFunction(t, f);
GeneratorImpl& gen = Build();
@ -388,19 +389,19 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtInitCondCont) {
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
EXPECT_EQ(gen.result(), R"( {
bool tint_tmp = true;
bool tint_tmp = t;
if (tint_tmp) {
tint_tmp = false;
}
bool i = (tint_tmp);
while (true) {
bool tint_tmp_1 = true;
bool tint_tmp_1 = t;
if (tint_tmp_1) {
tint_tmp_1 = false;
}
if (!((tint_tmp_1))) { break; }
return;
bool tint_tmp_2 = true;
bool tint_tmp_2 = t;
if (tint_tmp_2) {
tint_tmp_2 = false;
}
@ -449,16 +450,17 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_While_WithContinue) {
}
TEST_F(GlslGeneratorImplTest_Loop, Emit_WhileWithMultiStmtCond) {
// while(true && false) {
// let t = true;
// while(t && false) {
// return;
// }
Func("a_statement", {}, ty.void_(), {});
auto* multi_stmt =
create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd, Expr(true), Expr(false));
auto* t = Let("t", Expr(true));
auto* multi_stmt = LogicalAnd(t, false);
auto* f = While(multi_stmt, Block(CallStmt(Call("a_statement"))));
WrapInFunction(f);
WrapInFunction(t, f);
GeneratorImpl& gen = Build();
@ -466,7 +468,7 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_WhileWithMultiStmtCond) {
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
EXPECT_EQ(gen.result(), R"( while (true) {
bool tint_tmp = true;
bool tint_tmp = t;
if (tint_tmp) {
tint_tmp = false;
}

View File

@ -211,14 +211,15 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleInit) {
}
TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtInit) {
// for(var b = true && false; ; ) {
// let t = true;
// for(var b = t && false; ; ) {
// return;
// }
auto* multi_stmt =
create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd, Expr(true), Expr(false));
auto* t = Let("t", Expr(true));
auto* multi_stmt = LogicalAnd(t, false);
auto* f = For(Decl(Var("b", multi_stmt)), nullptr, nullptr, Block(Return()));
WrapInFunction(f);
WrapInFunction(t, f);
GeneratorImpl& gen = Build();
@ -226,7 +227,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtInit) {
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
EXPECT_EQ(gen.result(), R"( {
bool tint_tmp = true;
bool tint_tmp = t;
if (tint_tmp) {
tint_tmp = false;
}
@ -260,14 +261,16 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleCond) {
}
TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtCond) {
// for(; true && false; ) {
// let t = true;
// for(; t && false; ) {
// return;
// }
auto* multi_stmt =
create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd, Expr(true), Expr(false));
auto* f = For(nullptr, multi_stmt, nullptr, Block(Return()));
WrapInFunction(f);
Func("a_statement", {}, ty.void_(), {});
auto* t = Let("t", Expr(true));
auto* multi_stmt = LogicalAnd(t, false);
auto* f = For(nullptr, multi_stmt, nullptr, Block(CallStmt(Call("a_statement"))));
WrapInFunction(t, f);
GeneratorImpl& gen = Build();
@ -276,12 +279,12 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtCond) {
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
EXPECT_EQ(gen.result(), R"( {
while (true) {
bool tint_tmp = true;
bool tint_tmp = t;
if (tint_tmp) {
tint_tmp = false;
}
if (!((tint_tmp))) { break; }
return;
a_statement();
}
}
)");
@ -310,15 +313,17 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleCont) {
}
TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtCont) {
// for(; ; i = true && false) {
// let t = true;
// for(; ; i = t && false) {
// return;
// }
auto* multi_stmt =
create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd, Expr(true), Expr(false));
auto* t = Let("t", Expr(true));
auto* multi_stmt = LogicalAnd(t, false);
auto* v = Decl(Var("i", ty.bool_()));
auto* f = For(nullptr, nullptr, Assign("i", multi_stmt), Block(Return()));
WrapInFunction(v, f);
auto* f = For(nullptr, nullptr, Assign("i", multi_stmt), //
Block(Return()));
WrapInFunction(t, v, f);
GeneratorImpl& gen = Build();
@ -328,7 +333,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtCont) {
EXPECT_EQ(gen.result(), R"( {
while (true) {
return;
bool tint_tmp = true;
bool tint_tmp = t;
if (tint_tmp) {
tint_tmp = false;
}
@ -360,20 +365,19 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithSimpleInitCondCont) {
}
TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtInitCondCont) {
// for(var i = true && false; true && false; i = true && false) {
// let t = true;
// for(var i = t && false; t && false; i = t && false) {
// return;
// }
auto* multi_stmt_a =
create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd, Expr(true), Expr(false));
auto* multi_stmt_b =
create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd, Expr(true), Expr(false));
auto* multi_stmt_c =
create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd, Expr(true), Expr(false));
auto* t = Let("t", Expr(true));
auto* multi_stmt_a = LogicalAnd(t, false);
auto* multi_stmt_b = LogicalAnd(t, false);
auto* multi_stmt_c = LogicalAnd(t, false);
auto* f =
For(Decl(Var("i", multi_stmt_a)), multi_stmt_b, Assign("i", multi_stmt_c), Block(Return()));
WrapInFunction(f);
auto* f = For(Decl(Var("i", multi_stmt_a)), multi_stmt_b, Assign("i", multi_stmt_c), //
Block(Return()));
WrapInFunction(t, f);
GeneratorImpl& gen = Build();
@ -381,19 +385,19 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_ForLoopWithMultiStmtInitCondCont) {
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
EXPECT_EQ(gen.result(), R"( {
bool tint_tmp = true;
bool tint_tmp = t;
if (tint_tmp) {
tint_tmp = false;
}
bool i = (tint_tmp);
while (true) {
bool tint_tmp_1 = true;
bool tint_tmp_1 = t;
if (tint_tmp_1) {
tint_tmp_1 = false;
}
if (!((tint_tmp_1))) { break; }
return;
bool tint_tmp_2 = true;
bool tint_tmp_2 = t;
if (tint_tmp_2) {
tint_tmp_2 = false;
}
@ -442,14 +446,17 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_While_WithContinue) {
}
TEST_F(HlslGeneratorImplTest_Loop, Emit_WhileWithMultiStmtCond) {
// while(true && false) {
// let t = true;
// while(t && false) {
// return;
// }
auto* multi_stmt =
create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd, Expr(true), Expr(false));
auto* f = While(multi_stmt, Block(Return()));
WrapInFunction(f);
Func("a_statement", {}, ty.void_(), {});
auto* t = Let("t", Expr(true));
auto* multi_stmt = LogicalAnd(t, false);
auto* f = While(multi_stmt, Block(CallStmt(Call("a_statement"))));
WrapInFunction(t, f);
GeneratorImpl& gen = Build();
@ -457,12 +464,12 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_WhileWithMultiStmtCond) {
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
EXPECT_EQ(gen.result(), R"( while (true) {
bool tint_tmp = true;
bool tint_tmp = t;
if (tint_tmp) {
tint_tmp = false;
}
if (!((tint_tmp))) { break; }
return;
a_statement();
}
)");
}

View File

@ -419,17 +419,18 @@ TEST_F(MslGeneratorImplTest, Emit_WhileWithMultiCond) {
// return;
// }
auto* multi_stmt =
create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd, Expr(true), Expr(false));
auto* t = Let("t", Expr(true));
auto* multi_stmt = LogicalAnd(t, false);
// create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd, Expr(t), Expr(false));
auto* f = While(multi_stmt, Block(Return()));
WrapInFunction(f);
WrapInFunction(t, f);
GeneratorImpl& gen = Build();
gen.increment_indent();
ASSERT_TRUE(gen.EmitStatement(f)) << gen.error();
EXPECT_EQ(gen.result(), R"( while((true && false)) {
EXPECT_EQ(gen.result(), R"( while((t && false)) {
return;
}
)");

View File

@ -1071,38 +1071,43 @@ TEST_F(BuilderTest, Binary_logicalOr_Nested_LogicalAnd) {
// a || (b && c)
// From: crbug.com/tint/355
auto* t = Let("t", Expr(true));
auto* f = Let("f", Expr(false));
auto* logical_and_expr =
create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd, Expr(true), Expr(false));
create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd, Expr(t), Expr(f));
auto* expr =
create<ast::BinaryExpression>(ast::BinaryOp::kLogicalOr, Expr(true), logical_and_expr);
create<ast::BinaryExpression>(ast::BinaryOp::kLogicalOr, Expr(t), logical_and_expr);
WrapInFunction(expr);
WrapInFunction(t, f, expr);
spirv::Builder& b = Build();
b.push_function(Function{});
ASSERT_TRUE(b.GenerateFunctionVariable(t)) << b.error();
ASSERT_TRUE(b.GenerateFunctionVariable(f)) << b.error();
b.GenerateLabel(b.next_id());
EXPECT_EQ(b.GenerateBinaryExpression(expr), 10u) << b.error();
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeBool
%3 = OpConstantTrue %2
%8 = OpConstantNull %2
EXPECT_EQ(DumpInstructions(b.types()), R"(%1 = OpTypeBool
%2 = OpConstantTrue %1
%3 = OpConstantNull %1
)");
EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()),
R"(%1 = OpLabel
OpSelectionMerge %4 None
OpBranchConditional %3 %4 %5
%5 = OpLabel
OpSelectionMerge %6 None
OpBranchConditional %3 %7 %6
%7 = OpLabel
OpBranch %6
R"(%4 = OpLabel
OpSelectionMerge %5 None
OpBranchConditional %2 %5 %6
%6 = OpLabel
%9 = OpPhi %2 %3 %5 %8 %7
OpBranch %4
%4 = OpLabel
%10 = OpPhi %2 %3 %1 %9 %6
OpSelectionMerge %7 None
OpBranchConditional %2 %8 %7
%8 = OpLabel
OpBranch %7
%7 = OpLabel
%9 = OpPhi %1 %2 %6 %3 %8
OpBranch %5
%5 = OpLabel
%10 = OpPhi %1 %2 %4 %9 %7
)");
}
@ -1111,38 +1116,43 @@ TEST_F(BuilderTest, Binary_logicalAnd_Nested_LogicalOr) {
// a && (b || c)
// From: crbug.com/tint/355
auto* t = Let("t", Expr(true));
auto* f = Let("f", Expr(false));
auto* logical_or_expr =
create<ast::BinaryExpression>(ast::BinaryOp::kLogicalOr, Expr(true), Expr(false));
create<ast::BinaryExpression>(ast::BinaryOp::kLogicalOr, Expr(t), Expr(f));
auto* expr =
create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd, Expr(true), logical_or_expr);
create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd, Expr(t), logical_or_expr);
WrapInFunction(expr);
WrapInFunction(t, f, expr);
spirv::Builder& b = Build();
b.push_function(Function{});
ASSERT_TRUE(b.GenerateFunctionVariable(t)) << b.error();
ASSERT_TRUE(b.GenerateFunctionVariable(f)) << b.error();
b.GenerateLabel(b.next_id());
EXPECT_EQ(b.GenerateBinaryExpression(expr), 10u) << b.error();
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeBool
%3 = OpConstantTrue %2
%8 = OpConstantNull %2
EXPECT_EQ(DumpInstructions(b.types()), R"(%1 = OpTypeBool
%2 = OpConstantTrue %1
%3 = OpConstantNull %1
)");
EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()),
R"(%1 = OpLabel
OpSelectionMerge %4 None
OpBranchConditional %3 %5 %4
%5 = OpLabel
OpSelectionMerge %6 None
OpBranchConditional %3 %6 %7
%7 = OpLabel
OpBranch %6
R"(%4 = OpLabel
OpSelectionMerge %5 None
OpBranchConditional %2 %6 %5
%6 = OpLabel
%9 = OpPhi %2 %3 %5 %8 %7
OpBranch %4
%4 = OpLabel
%10 = OpPhi %2 %3 %1 %9 %6
OpSelectionMerge %7 None
OpBranchConditional %2 %7 %8
%8 = OpLabel
OpBranch %7
%7 = OpLabel
%9 = OpPhi %1 %2 %6 %3 %8
OpBranch %5
%5 = OpLabel
%10 = OpPhi %1 %2 %4 %9 %7
)");
}

View File

@ -4,19 +4,7 @@ void unused_entry_point() {
}
void f() {
bool tint_tmp = true;
if (!tint_tmp) {
tint_tmp = false;
}
bool2 v2 = bool2(((tint_tmp)).xx);
bool tint_tmp_1 = true;
if (!tint_tmp_1) {
tint_tmp_1 = false;
}
bool3 v3 = bool3(((tint_tmp_1)).xxx);
bool tint_tmp_2 = true;
if (!tint_tmp_2) {
tint_tmp_2 = false;
}
bool4 v4 = bool4(((tint_tmp_2)).xxxx);
bool2 v2 = (true).xx;
bool3 v3 = (true).xxx;
bool4 v4 = (true).xxxx;
}

View File

@ -4,19 +4,7 @@ void unused_entry_point() {
}
void f() {
bool tint_tmp = true;
if (!tint_tmp) {
tint_tmp = false;
}
bool2 v2 = bool2(((tint_tmp)).xx);
bool tint_tmp_1 = true;
if (!tint_tmp_1) {
tint_tmp_1 = false;
}
bool3 v3 = bool3(((tint_tmp_1)).xxx);
bool tint_tmp_2 = true;
if (!tint_tmp_2) {
tint_tmp_2 = false;
}
bool4 v4 = bool4(((tint_tmp_2)).xxxx);
bool2 v2 = (true).xx;
bool3 v3 = (true).xxx;
bool4 v4 = (true).xxxx;
}

View File

@ -5,20 +5,8 @@ void unused_entry_point() {
return;
}
void f() {
bool tint_tmp = true;
if (!tint_tmp) {
tint_tmp = false;
}
bvec2 v2 = bvec2((tint_tmp));
bool tint_tmp_1 = true;
if (!tint_tmp_1) {
tint_tmp_1 = false;
}
bvec3 v3 = bvec3((tint_tmp_1));
bool tint_tmp_2 = true;
if (!tint_tmp_2) {
tint_tmp_2 = false;
}
bvec4 v4 = bvec4((tint_tmp_2));
bvec2 v2 = bvec2(true);
bvec3 v3 = bvec3(true);
bvec4 v4 = bvec4(true);
}

View File

@ -2,8 +2,8 @@
using namespace metal;
void f() {
bool2 v2 = bool2((true || false));
bool3 v3 = bool3((true || false));
bool4 v4 = bool4((true || false));
bool2 v2 = bool2(true);
bool3 v3 = bool3(true);
bool4 v4 = bool4(true);
}

View File

@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 34
; Bound: 24
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@ -17,47 +17,28 @@
%bool = OpTypeBool
%v2bool = OpTypeVector %bool 2
%true = OpConstantTrue %bool
%12 = OpConstantNull %bool
%10 = OpConstantComposite %v2bool %true %true
%_ptr_Function_v2bool = OpTypePointer Function %v2bool
%17 = OpConstantNull %v2bool
%13 = OpConstantNull %v2bool
%v3bool = OpTypeVector %bool 3
%15 = OpConstantComposite %v3bool %true %true %true
%_ptr_Function_v3bool = OpTypePointer Function %v3bool
%25 = OpConstantNull %v3bool
%18 = OpConstantNull %v3bool
%v4bool = OpTypeVector %bool 4
%20 = OpConstantComposite %v4bool %true %true %true %true
%_ptr_Function_v4bool = OpTypePointer Function %v4bool
%33 = OpConstantNull %v4bool
%23 = OpConstantNull %v4bool
%unused_entry_point = OpFunction %void None %1
%4 = OpLabel
OpReturn
OpFunctionEnd
%f = OpFunction %void None %1
%6 = OpLabel
%v2 = OpVariable %_ptr_Function_v2bool Function %17
%v3 = OpVariable %_ptr_Function_v3bool Function %25
%v4 = OpVariable %_ptr_Function_v4bool Function %33
OpSelectionMerge %10 None
OpBranchConditional %true %10 %11
%11 = OpLabel
OpBranch %10
%10 = OpLabel
%13 = OpPhi %bool %true %6 %12 %11
%14 = OpCompositeConstruct %v2bool %13 %13
OpStore %v2 %14
OpSelectionMerge %19 None
OpBranchConditional %true %19 %20
%20 = OpLabel
OpBranch %19
%19 = OpLabel
%21 = OpPhi %bool %true %10 %12 %20
%22 = OpCompositeConstruct %v3bool %21 %21 %21
OpStore %v3 %22
OpSelectionMerge %27 None
OpBranchConditional %true %27 %28
%28 = OpLabel
OpBranch %27
%27 = OpLabel
%29 = OpPhi %bool %true %19 %12 %28
%30 = OpCompositeConstruct %v4bool %29 %29 %29 %29
OpStore %v4 %30
%v2 = OpVariable %_ptr_Function_v2bool Function %13
%v3 = OpVariable %_ptr_Function_v3bool Function %18
%v4 = OpVariable %_ptr_Function_v4bool Function %23
OpStore %v2 %10
OpStore %v3 %15
OpStore %v4 %20
OpReturn
OpFunctionEnd

View File

@ -4,11 +4,7 @@ void unused_entry_point() {
}
void f() {
bool tint_tmp = true;
if (!tint_tmp) {
tint_tmp = false;
}
bool v = (tint_tmp);
bool v = true;
bool2 v2 = bool2((v).xx);
bool3 v3 = bool3((v).xxx);
bool4 v4 = bool4((v).xxxx);

View File

@ -4,11 +4,7 @@ void unused_entry_point() {
}
void f() {
bool tint_tmp = true;
if (!tint_tmp) {
tint_tmp = false;
}
bool v = (tint_tmp);
bool v = true;
bool2 v2 = bool2((v).xx);
bool3 v3 = bool3((v).xxx);
bool4 v4 = bool4((v).xxxx);

View File

@ -5,11 +5,7 @@ void unused_entry_point() {
return;
}
void f() {
bool tint_tmp = true;
if (!tint_tmp) {
tint_tmp = false;
}
bool v = (tint_tmp);
bool v = true;
bvec2 v2 = bvec2(v);
bvec3 v3 = bvec3(v);
bvec4 v4 = bvec4(v);

View File

@ -2,7 +2,7 @@
using namespace metal;
void f() {
bool v = (true || false);
bool v = true;
bool2 v2 = bool2(v);
bool3 v3 = bool3(v);
bool4 v4 = bool4(v);

View File

@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 33
; Bound: 30
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@ -17,17 +17,17 @@
%1 = OpTypeFunction %void
%bool = OpTypeBool
%true = OpConstantTrue %bool
%11 = OpConstantNull %bool
%_ptr_Function_bool = OpTypePointer Function %bool
%11 = OpConstantNull %bool
%v2bool = OpTypeVector %bool 2
%_ptr_Function_v2bool = OpTypePointer Function %v2bool
%20 = OpConstantNull %v2bool
%17 = OpConstantNull %v2bool
%v3bool = OpTypeVector %bool 3
%_ptr_Function_v3bool = OpTypePointer Function %v3bool
%26 = OpConstantNull %v3bool
%23 = OpConstantNull %v3bool
%v4bool = OpTypeVector %bool 4
%_ptr_Function_v4bool = OpTypePointer Function %v4bool
%32 = OpConstantNull %v4bool
%29 = OpConstantNull %v4bool
%unused_entry_point = OpFunction %void None %1
%4 = OpLabel
OpReturn
@ -35,24 +35,18 @@
%f = OpFunction %void None %1
%6 = OpLabel
%v = OpVariable %_ptr_Function_bool Function %11
%v2 = OpVariable %_ptr_Function_v2bool Function %20
%v3 = OpVariable %_ptr_Function_v3bool Function %26
%v4 = OpVariable %_ptr_Function_v4bool Function %32
OpSelectionMerge %9 None
OpBranchConditional %true %9 %10
%10 = OpLabel
OpBranch %9
%9 = OpLabel
%12 = OpPhi %bool %true %6 %11 %10
OpStore %v %12
%16 = OpLoad %bool %v
%17 = OpCompositeConstruct %v2bool %16 %16
OpStore %v2 %17
%22 = OpLoad %bool %v
%23 = OpCompositeConstruct %v3bool %22 %22 %22
OpStore %v3 %23
%28 = OpLoad %bool %v
%29 = OpCompositeConstruct %v4bool %28 %28 %28 %28
OpStore %v4 %29
%v2 = OpVariable %_ptr_Function_v2bool Function %17
%v3 = OpVariable %_ptr_Function_v3bool Function %23
%v4 = OpVariable %_ptr_Function_v4bool Function %29
OpStore %v %true
%13 = OpLoad %bool %v
%14 = OpCompositeConstruct %v2bool %13 %13
OpStore %v2 %14
%19 = OpLoad %bool %v
%20 = OpCompositeConstruct %v3bool %19 %19 %19
OpStore %v3 %20
%25 = OpLoad %bool %v
%26 = OpCompositeConstruct %v4bool %25 %25 %25 %25
OpStore %v4 %26
OpReturn
OpFunctionEnd

View File

@ -1,10 +1,6 @@
[numthreads(1, 1, 1)]
void main() {
bool tint_tmp = false;
if (tint_tmp) {
tint_tmp = true;
}
if ((tint_tmp)) {
if (false) {
}
return;
}

View File

@ -1,10 +1,6 @@
[numthreads(1, 1, 1)]
void main() {
bool tint_tmp = false;
if (tint_tmp) {
tint_tmp = true;
}
if ((tint_tmp)) {
if (false) {
}
return;
}

View File

@ -1,11 +1,7 @@
#version 310 es
void tint_symbol() {
bool tint_tmp = false;
if (tint_tmp) {
tint_tmp = true;
}
if ((tint_tmp)) {
if (false) {
}
}

View File

@ -2,7 +2,7 @@
using namespace metal;
kernel void tint_symbol() {
if ((false && true)) {
if (false) {
}
return;
}

View File

@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 13
; Bound: 9
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@ -12,7 +12,6 @@
%1 = OpTypeFunction %void
%bool = OpTypeBool
%6 = OpConstantNull %bool
%true = OpConstantTrue %bool
%main = OpFunction %void None %1
%4 = OpLabel
OpSelectionMerge %7 None
@ -20,11 +19,5 @@
%8 = OpLabel
OpBranch %7
%7 = OpLabel
%10 = OpPhi %bool %6 %4 %true %8
OpSelectionMerge %11 None
OpBranchConditional %10 %12 %11
%12 = OpLabel
OpBranch %11
%11 = OpLabel
OpReturn
OpFunctionEnd

View File

@ -1,10 +1,6 @@
[numthreads(1, 1, 1)]
void main() {
bool tint_tmp = false;
if (tint_tmp) {
tint_tmp = true;
}
if ((tint_tmp)) {
if (false) {
}
return;
}

View File

@ -1,10 +1,6 @@
[numthreads(1, 1, 1)]
void main() {
bool tint_tmp = false;
if (tint_tmp) {
tint_tmp = true;
}
if ((tint_tmp)) {
if (false) {
}
return;
}

View File

@ -1,11 +1,7 @@
#version 310 es
void tint_symbol() {
bool tint_tmp = false;
if (tint_tmp) {
tint_tmp = true;
}
if ((tint_tmp)) {
if (false) {
}
}

View File

@ -2,7 +2,7 @@
using namespace metal;
kernel void tint_symbol() {
if ((false && true)) {
if (false) {
}
return;
}

View File

@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 13
; Bound: 9
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@ -12,7 +12,6 @@
%1 = OpTypeFunction %void
%bool = OpTypeBool
%6 = OpConstantNull %bool
%true = OpConstantTrue %bool
%main = OpFunction %void None %1
%4 = OpLabel
OpSelectionMerge %7 None
@ -20,11 +19,5 @@
%8 = OpLabel
OpBranch %7
%7 = OpLabel
%10 = OpPhi %bool %6 %4 %true %8
OpSelectionMerge %11 None
OpBranchConditional %10 %12 %11
%12 = OpLabel
OpBranch %11
%11 = OpLabel
OpReturn
OpFunctionEnd

View File

@ -1,10 +1,6 @@
[numthreads(1, 1, 1)]
void main() {
bool tint_tmp = false;
if (tint_tmp) {
tint_tmp = true;
}
if ((tint_tmp)) {
if (false) {
}
return;
}

View File

@ -1,10 +1,6 @@
[numthreads(1, 1, 1)]
void main() {
bool tint_tmp = false;
if (tint_tmp) {
tint_tmp = true;
}
if ((tint_tmp)) {
if (false) {
}
return;
}

View File

@ -1,11 +1,7 @@
#version 310 es
void tint_symbol() {
bool tint_tmp = false;
if (tint_tmp) {
tint_tmp = true;
}
if ((tint_tmp)) {
if (false) {
}
}

View File

@ -2,7 +2,7 @@
using namespace metal;
kernel void tint_symbol() {
if ((false && true)) {
if (false) {
}
return;
}

View File

@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 13
; Bound: 9
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
@ -12,7 +12,6 @@
%1 = OpTypeFunction %void
%bool = OpTypeBool
%6 = OpConstantNull %bool
%true = OpConstantTrue %bool
%main = OpFunction %void None %1
%4 = OpLabel
OpSelectionMerge %7 None
@ -20,11 +19,5 @@
%8 = OpLabel
OpBranch %7
%7 = OpLabel
%10 = OpPhi %bool %6 %4 %true %8
OpSelectionMerge %11 None
OpBranchConditional %10 %12 %11
%12 = OpLabel
OpBranch %11
%11 = OpLabel
OpReturn
OpFunctionEnd