From f528d33d52340ec0855354cd48bea241d7ed6f57 Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Fri, 9 Dec 2022 12:34:36 +0000 Subject: [PATCH] tint/transform: fix PromoteInitializersToLet for constant expressions Fix more edge cases uncovered with tint:1781 Fixed: tint:1781 Change-Id: I58d120185f47c10bc9fe55dd95a198d496c4ec94 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/113024 Reviewed-by: Antonio Maiorano Kokoro: Kokoro Commit-Queue: Ben Clayton Auto-Submit: Ben Clayton --- src/tint/ast/node_id.h | 7 +- .../transform/promote_initializers_to_let.cc | 153 +++++--- .../promote_initializers_to_let_test.cc | 369 ++++++++++-------- src/tint/utils/hashset.h | 12 + src/tint/utils/hashset_test.cc | 10 + .../glsl/generator_impl_sanitizer_test.cc | 7 +- .../hlsl/generator_impl_sanitizer_test.cc | 7 +- .../type_initializer.wgsl.expected.dxc.hlsl | 42 +- .../type_initializer.wgsl.expected.fxc.hlsl | 42 +- .../array/type_initializer.wgsl.expected.glsl | 42 +- .../array/type_initializer.wgsl.expected.msl | 42 +- test/tint/bug/tint/1641.wgsl | 3 +- .../tint/bug/tint/1641.wgsl.expected.dxc.hlsl | 3 +- .../tint/bug/tint/1641.wgsl.expected.fxc.hlsl | 3 +- test/tint/bug/tint/1641.wgsl.expected.glsl | 3 +- test/tint/bug/tint/1641.wgsl.expected.msl | 3 +- test/tint/bug/tint/1641.wgsl.expected.spvasm | 42 +- test/tint/bug/tint/1641.wgsl.expected.wgsl | 3 +- test/tint/bug/tint/1781.wgsl | 7 + .../tint/bug/tint/1781.wgsl.expected.dxc.hlsl | 7 + .../tint/bug/tint/1781.wgsl.expected.fxc.hlsl | 7 + test/tint/bug/tint/1781.wgsl.expected.glsl | 14 + test/tint/bug/tint/1781.wgsl.expected.msl | 11 + test/tint/bug/tint/1781.wgsl.expected.spvasm | 21 + test/tint/bug/tint/1781.wgsl.expected.wgsl | 8 + .../const_members.wgsl.expected.dxc.hlsl | 10 +- .../const_members.wgsl.expected.fxc.hlsl | 10 +- .../scalar/const_members.wgsl.expected.glsl | 12 +- .../scalar/const_members.wgsl.expected.msl | 11 +- .../const_members.wgsl.expected.dxc.hlsl | 10 +- .../const_members.wgsl.expected.fxc.hlsl | 10 +- .../vector/const_members.wgsl.expected.glsl | 12 +- .../vector/const_members.wgsl.expected.msl | 11 +- .../const_members.wgsl.expected.dxc.hlsl | 10 +- .../const_members.wgsl.expected.fxc.hlsl | 10 +- .../scalar/const_members.wgsl.expected.glsl | 12 +- .../scalar/const_members.wgsl.expected.msl | 11 +- .../const_members.wgsl.expected.dxc.hlsl | 10 +- .../const_members.wgsl.expected.fxc.hlsl | 10 +- .../vector/const_members.wgsl.expected.glsl | 12 +- .../vector/const_members.wgsl.expected.msl | 11 +- .../array_ctor.wgsl.expected.dxc.hlsl | 8 +- .../array_ctor.wgsl.expected.fxc.hlsl | 8 +- .../condition/array_ctor.wgsl.expected.glsl | 8 +- .../condition/array_ctor.wgsl.expected.msl | 21 +- .../struct_ctor.wgsl.expected.dxc.hlsl | 12 +- .../struct_ctor.wgsl.expected.fxc.hlsl | 12 +- .../condition/struct_ctor.wgsl.expected.glsl | 8 +- .../condition/struct_ctor.wgsl.expected.msl | 8 +- .../array_ctor.wgsl.expected.dxc.hlsl | 11 +- .../array_ctor.wgsl.expected.fxc.hlsl | 11 +- .../continuing/array_ctor.wgsl.expected.glsl | 11 +- .../continuing/array_ctor.wgsl.expected.msl | 24 +- .../struct_ctor.wgsl.expected.dxc.hlsl | 16 +- .../struct_ctor.wgsl.expected.fxc.hlsl | 16 +- .../continuing/struct_ctor.wgsl.expected.glsl | 12 +- .../continuing/struct_ctor.wgsl.expected.msl | 14 +- .../array_ctor.wgsl.expected.dxc.hlsl | 3 +- .../array_ctor.wgsl.expected.fxc.hlsl | 3 +- .../initializer/array_ctor.wgsl.expected.glsl | 3 +- .../initializer/array_ctor.wgsl.expected.msl | 16 +- .../struct_ctor.wgsl.expected.dxc.hlsl | 7 +- .../struct_ctor.wgsl.expected.fxc.hlsl | 7 +- .../struct_ctor.wgsl.expected.glsl | 3 +- .../initializer/struct_ctor.wgsl.expected.msl | 3 +- .../type_initializer.wgsl.expected.dxc.hlsl | 44 +-- .../type_initializer.wgsl.expected.fxc.hlsl | 44 +-- .../type_initializer.wgsl.expected.glsl | 44 +-- .../struct/type_initializer.wgsl.expected.msl | 44 +-- .../array/array_i32.wgsl.expected.dxc.hlsl | 4 +- .../array/array_i32.wgsl.expected.fxc.hlsl | 4 +- .../array/array_i32.wgsl.expected.glsl | 4 +- .../array/array_i32.wgsl.expected.msl | 4 +- 73 files changed, 653 insertions(+), 824 deletions(-) create mode 100644 test/tint/bug/tint/1781.wgsl create mode 100644 test/tint/bug/tint/1781.wgsl.expected.dxc.hlsl create mode 100644 test/tint/bug/tint/1781.wgsl.expected.fxc.hlsl create mode 100644 test/tint/bug/tint/1781.wgsl.expected.glsl create mode 100644 test/tint/bug/tint/1781.wgsl.expected.msl create mode 100644 test/tint/bug/tint/1781.wgsl.expected.spvasm create mode 100644 test/tint/bug/tint/1781.wgsl.expected.wgsl diff --git a/src/tint/ast/node_id.h b/src/tint/ast/node_id.h index 79683b0348..f6bddb13c4 100644 --- a/src/tint/ast/node_id.h +++ b/src/tint/ast/node_id.h @@ -25,7 +25,12 @@ struct NodeID { /// Equality operator /// @param other the other NodeID /// @returns true if the NodeIDs are the same - bool operator==(const NodeID& other) const { return value == other.value; } + bool operator==(NodeID other) const { return value == other.value; } + + /// Less-than comparison operator + /// @param other the other NodeID + /// @returns true if the other comes before this node + bool operator<(NodeID other) const { return value < other.value; } /// The numerical value for the node identifier size_t value = 0; diff --git a/src/tint/transform/promote_initializers_to_let.cc b/src/tint/transform/promote_initializers_to_let.cc index a6a5cf698c..3b1ea7fdf7 100644 --- a/src/tint/transform/promote_initializers_to_let.cc +++ b/src/tint/transform/promote_initializers_to_let.cc @@ -16,11 +16,14 @@ #include +#include "src/tint/ast/traverse_expressions.h" #include "src/tint/program_builder.h" #include "src/tint/sem/call.h" #include "src/tint/sem/statement.h" #include "src/tint/sem/type_initializer.h" #include "src/tint/transform/utils/hoist_to_decl_before.h" +#include "src/tint/type/struct.h" +#include "src/tint/utils/hashset.h" TINT_INSTANTIATE_TYPEINFO(tint::transform::PromoteInitializersToLet); @@ -36,87 +39,111 @@ Transform::ApplyResult PromoteInitializersToLet::Apply(const Program* src, ProgramBuilder b; CloneContext ctx{&b, src, /* auto_clone_symbols */ true}; - HoistToDeclBefore hoist_to_decl_before(ctx); - - bool any_promoted = false; - - // Hoists array and structure initializers to a constant variable, declared - // just before the statement of usage. - auto promote = [&](const sem::Expression* expr) { - auto* sem_stmt = expr->Stmt(); - if (!sem_stmt) { - // Expression is outside of a statement. This usually means the - // expression is part of a global (module-scope) constant declaration. - // These must be constexpr, and so cannot contain the type of - // expressions that must be sanitized. - return true; + // Returns true if the expression should be hoisted to a new let statement before the + // expression's statement. + auto should_hoist = [&](const sem::Expression* expr) { + if (!expr->Type()->IsAnyOf()) { + // We only care about array and struct initializers + return false; } - auto* stmt = sem_stmt->Declaration(); + // Check whether the expression is an array or structure constructor + { + // Follow const-chains + auto* root_expr = expr; + if (expr->Stage() == sem::EvaluationStage::kConstant) { + while (auto* user = root_expr->UnwrapMaterialize()->As()) { + root_expr = user->Variable()->Initializer(); + } + } - if (auto* src_var_decl = stmt->As()) { - if (src_var_decl->variable->initializer == expr->Declaration()) { - // This statement is just a variable declaration with the - // initializer as the initializer value. This is what we're - // attempting to transform to, and so ignore. - return true; + auto* ctor = root_expr->UnwrapMaterialize()->As(); + if (!ctor || !ctor->Target()->Is()) { + // Root expression is not a type constructor. Not interested in this. + return false; } } - auto* src_ty = expr->Type(); - if (!src_ty->IsAnyOf()) { - // We only care about array and struct initializers - return true; + if (auto* src_var_decl = expr->Stmt()->Declaration()->As()) { + if (src_var_decl->variable->initializer == expr->Declaration()) { + // This statement is just a variable declaration with the initializer as the + // initializer value. This is what we're attempting to transform to, and so + // ignore. + return false; + } } - any_promoted = true; - return hoist_to_decl_before.Add(expr, expr->Declaration(), - HoistToDeclBefore::VariableKind::kLet); + return true; }; + // A list of expressions that should be hoisted. + utils::Vector to_hoist; + // A set of expressions that are constant, which _may_ need to be hoisted. + utils::Hashset const_chains; + + // Walk the AST nodes. This order guarantees that leaf-expressions are visited first. for (auto* node : src->ASTNodes().Objects()) { - bool ok = Switch( - node, // - [&](const ast::CallExpression* expr) { - if (auto* sem = src->Sem().Get(expr)) { - auto* ctor = sem->UnwrapMaterialize()->As(); - if (ctor->Target()->Is()) { - return promote(sem); - } + if (auto* sem = src->Sem().Get(node)) { + auto* stmt = sem->Stmt(); + if (!stmt) { + // Expression is outside of a statement. This usually means the expression is part + // of a global (module-scope) constant declaration. These must be constexpr, and so + // cannot contain the type of expressions that must be sanitized. + continue; + } + + if (sem->Stage() == sem::EvaluationStage::kConstant) { + // Expression is constant. We only need to hoist expressions if they're the + // outermost constant expression in a chain. Remove the immediate child nodes of the + // expression from const_chains, and add this expression to the const_chains. As we + // visit leaf-expressions first, this means the content of const_chains only + // contains the outer-most constant expressions. + auto* expr = sem->Declaration(); + bool ok = ast::TraverseExpressions( + expr, b.Diagnostics(), [&](const ast::Expression* child) { + const_chains.Remove(child); + return child == expr ? ast::TraverseAction::Descend + : ast::TraverseAction::Skip; + }); + if (!ok) { + return Program(std::move(b)); } - return true; - }, - [&](const ast::IdentifierExpression* expr) { - if (auto* sem = src->Sem().Get(expr)) { - if (auto* user = sem->UnwrapMaterialize()->As()) { - // Identifier resolves to a variable - if (auto* stmt = user->Stmt()) { - if (auto* decl = stmt->Declaration()->As(); - decl && decl->variable->Is()) { - // The identifier is used on the RHS of a 'const' declaration. - // Ignore. - return true; - } - } - if (user->Variable()->Declaration()->Is()) { - // The identifier resolves to a 'const' variable, but isn't used to - // initialize another 'const'. This needs promoting. - return promote(user); - } - } - } - return true; - }, - [&](Default) { return true; }); - if (!ok) { - return Program(std::move(b)); + const_chains.Add(expr); + } else if (should_hoist(sem)) { + to_hoist.Push(sem); + } } } - if (!any_promoted) { + // After walking the full AST, const_chains only contains the outer-most constant expressions. + // Check if any of these need hoisting, and append those to to_hoist. + for (auto* expr : const_chains) { + if (auto* sem = src->Sem().Get(expr); should_hoist(sem)) { + to_hoist.Push(sem); + } + } + + if (to_hoist.IsEmpty()) { + // Nothing to do. Skip. return SkipTransform; } + // The order of to_hoist is currently undefined. Sort by AST node id, which will make this + // deterministic. + to_hoist.Sort([&](auto* expr_a, auto* expr_b) { + return expr_a->Declaration()->node_id < expr_b->Declaration()->node_id; + }); + + // Hoist all the expression in to_hoist to a constant variable, declared just before the + // statement of usage. + HoistToDeclBefore hoist_to_decl_before(ctx); + for (auto* expr : to_hoist) { + if (!hoist_to_decl_before.Add(expr, expr->Declaration(), + HoistToDeclBefore::VariableKind::kLet)) { + return Program(std::move(b)); + } + } + ctx.Clone(); return Program(std::move(b)); } diff --git a/src/tint/transform/promote_initializers_to_let_test.cc b/src/tint/transform/promote_initializers_to_let_test.cc index 536d04a29e..dd726710c6 100644 --- a/src/tint/transform/promote_initializers_to_let_test.cc +++ b/src/tint/transform/promote_initializers_to_let_test.cc @@ -30,7 +30,21 @@ TEST_F(PromoteInitializersToLetTest, EmptyModule) { EXPECT_EQ(expect, str(got)); } -TEST_F(PromoteInitializersToLetTest, BasicArray) { +TEST_F(PromoteInitializersToLetTest, BasicConstArray) { + auto* src = R"( +fn f() { + const f0 = 1.0; + const f1 = 2.0; + const f2 = 3.0; + const f3 = 4.0; + var i = array(f0, f1, f2, f3)[2]; +} +)"; + + EXPECT_FALSE(ShouldRun(src)); +} + +TEST_F(PromoteInitializersToLetTest, BasicRuntimeArray) { auto* src = R"( fn f() { var f0 = 1.0; @@ -52,13 +66,12 @@ fn f() { } )"; - DataMap data; auto got = Run(src); EXPECT_EQ(expect, str(got)); } -TEST_F(PromoteInitializersToLetTest, BasicStruct) { +TEST_F(PromoteInitializersToLetTest, BasicConstStruct) { auto* src = R"( struct S { a : i32, @@ -69,6 +82,23 @@ struct S { fn f() { var x = S(1, 2.0, vec3()).b; } +)"; + + EXPECT_FALSE(ShouldRun(src)); +} + +TEST_F(PromoteInitializersToLetTest, BasicRuntimeStruct) { + auto* src = R"( +struct S { + a : i32, + b : f32, + c : vec3, +}; + +fn f() { + let runtime_value = 1; + var x = S(runtime_value, 2.0, vec3()).b; +} )"; auto* expect = R"( @@ -79,12 +109,12 @@ struct S { } fn f() { - let tint_symbol = S(1, 2.0, vec3()); + let runtime_value = 1; + let tint_symbol = S(runtime_value, 2.0, vec3()); var x = tint_symbol.b; } )"; - DataMap data; auto got = Run(src); EXPECT_EQ(expect, str(got)); @@ -93,7 +123,8 @@ fn f() { TEST_F(PromoteInitializersToLetTest, BasicStruct_OutOfOrder) { auto* src = R"( fn f() { - var x = S(1, 2.0, vec3()).b; + let runtime_value = 1; + var x = S(runtime_value, 2.0, vec3()).b; } struct S { @@ -105,7 +136,8 @@ struct S { auto* expect = R"( fn f() { - let tint_symbol = S(1, 2.0, vec3()); + let runtime_value = 1; + let tint_symbol = S(runtime_value, 2.0, vec3()); var x = tint_symbol.b; } @@ -116,7 +148,6 @@ struct S { } )"; - DataMap data; auto got = Run(src); EXPECT_EQ(expect, str(got)); @@ -133,29 +164,29 @@ const C = array(f0, f1); fn f() { var f0 = 100.0; var f1 = 100.0; - var i = C[1]; + var i = C[1]; // Not hoisted, as the final const value is not an array } )"; - auto* expect = R"( -const f0 = 1.0; - -const f1 = 2.0; - -const C = array(f0, f1); + EXPECT_FALSE(ShouldRun(src)); +} +TEST_F(PromoteInitializersToLetTest, GlobalConstBasicArray_OutOfOrder) { + auto* src = R"( fn f() { var f0 = 100.0; var f1 = 100.0; - let tint_symbol = C; - var i = tint_symbol[1]; + var i = C[1]; } + +const C = array(f0, f1); + +const f0 = 1.0; + +const f1 = 2.0; )"; - DataMap data; - auto got = Run(src); - - EXPECT_EQ(expect, str(got)); + EXPECT_FALSE(ShouldRun(src)); } TEST_F(PromoteInitializersToLetTest, GlobalConstArrayDynamicIndex) { @@ -183,43 +214,6 @@ fn vs_main(@builtin(vertex_index) in_vertex_index : u32) -> @builtin(position) v } )"; - DataMap data; - auto got = Run(src); - - EXPECT_EQ(expect, str(got)); -} - -TEST_F(PromoteInitializersToLetTest, GlobalConstBasicArray_OutOfOrder) { - auto* src = R"( -fn f() { - var f0 = 100.0; - var f1 = 100.0; - var i = C[1]; -} - -const C = array(f0, f1); - -const f0 = 1.0; - -const f1 = 2.0; -)"; - - auto* expect = R"( -fn f() { - var f0 = 100.0; - var f1 = 100.0; - let tint_symbol = C; - var i = tint_symbol[1]; -} - -const C = array(f0, f1); - -const f0 = 1.0; - -const f1 = 2.0; -)"; - - DataMap data; auto got = Run(src); EXPECT_EQ(expect, str(got)); @@ -231,7 +225,21 @@ fn f() { const f0 = 1.0; const f1 = 2.0; const C = array(f0, f1); - var i = C[1]; + var i = C[1]; // Not hoisted, as the final const value is not an array +} +)"; + + EXPECT_FALSE(ShouldRun(src)); +} + +TEST_F(PromoteInitializersToLetTest, LocalConstBasicArrayRuntimeIndex) { + auto* src = R"( +fn f() { + const f0 = 1.0; + const f1 = 2.0; + const C = array(f0, f1); + let runtime_value = 1; + var i = C[runtime_value]; } )"; @@ -240,12 +248,12 @@ fn f() { const f0 = 1.0; const f1 = 2.0; const C = array(f0, f1); + let runtime_value = 1; let tint_symbol = C; - var i = tint_symbol[1]; + var i = tint_symbol[runtime_value]; } )"; - DataMap data; auto got = Run(src); EXPECT_EQ(expect, str(got)); @@ -255,7 +263,7 @@ TEST_F(PromoteInitializersToLetTest, ArrayInForLoopInit) { auto* src = R"( fn f() { var insert_after = 1; - for(var i = array(0.0, 1.0, 2.0, 3.0)[2]; ; ) { + for(var i = array(0.0, 1.0, 2.0, 3.0)[insert_after]; ; ) { break; } } @@ -265,13 +273,12 @@ fn f() { fn f() { var insert_after = 1; let tint_symbol = array(0.0, 1.0, 2.0, 3.0); - for(var i = tint_symbol[2]; ; ) { + for(var i = tint_symbol[insert_after]; ; ) { break; } } )"; - DataMap data; auto got = Run(src); EXPECT_EQ(expect, str(got)); @@ -281,8 +288,9 @@ TEST_F(PromoteInitializersToLetTest, LocalConstArrayInForLoopInit) { auto* src = R"( fn f() { const arr = array(0.0, 1.0, 2.0, 3.0); + let runtime_value = 1; var insert_after = 1; - for(var i = arr[2]; ; ) { + for(var i = arr[runtime_value]; ; ) { break; } } @@ -291,15 +299,15 @@ fn f() { auto* expect = R"( fn f() { const arr = array(0.0, 1.0, 2.0, 3.0); + let runtime_value = 1; var insert_after = 1; let tint_symbol = arr; - for(var i = tint_symbol[2]; ; ) { + for(var i = tint_symbol[runtime_value]; ; ) { break; } } )"; - DataMap data; auto got = Run(src); EXPECT_EQ(expect, str(got)); @@ -310,8 +318,9 @@ TEST_F(PromoteInitializersToLetTest, GlobalConstArrayInForLoopInit) { const arr = array(0.0, 1.0, 2.0, 3.0); fn f() { + let runtime_value = 1; var insert_after = 1; - for(var i = arr[2]; ; ) { + for(var i = arr[runtime_value]; ; ) { break; } } @@ -321,15 +330,15 @@ fn f() { const arr = array(0.0, 1.0, 2.0, 3.0); fn f() { + let runtime_value = 1; var insert_after = 1; let tint_symbol = arr; - for(var i = tint_symbol[2]; ; ) { + for(var i = tint_symbol[runtime_value]; ; ) { break; } } )"; - DataMap data; auto got = Run(src); EXPECT_EQ(expect, str(got)); @@ -343,9 +352,13 @@ struct S { c : vec3, }; +fn get_b_runtime(s : S) -> f32 { + return s.b; +} + fn f() { var insert_after = 1; - for(var x = S(1, 2.0, vec3()).b; ; ) { + for(var x = get_b_runtime(S(1, 2.0, vec3())); ; ) { break; } } @@ -358,16 +371,19 @@ struct S { c : vec3, } +fn get_b_runtime(s : S) -> f32 { + return s.b; +} + fn f() { var insert_after = 1; let tint_symbol = S(1, 2.0, vec3()); - for(var x = tint_symbol.b; ; ) { + for(var x = get_b_runtime(tint_symbol); ; ) { break; } } )"; - DataMap data; auto got = Run(src); EXPECT_EQ(expect, str(got)); @@ -377,11 +393,15 @@ TEST_F(PromoteInitializersToLetTest, StructInForLoopInit_OutOfOrder) { auto* src = R"( fn f() { var insert_after = 1; - for(var x = S(1, 2.0, vec3()).b; ; ) { + for(var x = get_b_runtime(S(1, 2.0, vec3())); ; ) { break; } } +fn get_b_runtime(s : S) -> f32 { + return s.b; +} + struct S { a : i32, b : f32, @@ -393,11 +413,15 @@ struct S { fn f() { var insert_after = 1; let tint_symbol = S(1, 2.0, vec3()); - for(var x = tint_symbol.b; ; ) { + for(var x = get_b_runtime(tint_symbol); ; ) { break; } } +fn get_b_runtime(s : S) -> f32 { + return s.b; +} + struct S { a : i32, b : f32, @@ -405,7 +429,6 @@ struct S { } )"; - DataMap data; auto got = Run(src); EXPECT_EQ(expect, str(got)); @@ -440,7 +463,6 @@ fn f() { } )"; - DataMap data; auto got = Run(src); EXPECT_EQ(expect, str(got)); @@ -449,9 +471,10 @@ fn f() { TEST_F(PromoteInitializersToLetTest, LocalConstArrayInForLoopCond) { auto* src = R"( fn f() { + let runtime_value = 0; const f = 1.0; const arr = array(f); - for(var i = f; i == arr[0]; i = i + 1.0) { + for(var i = f; i == arr[runtime_value]; i = i + 1.0) { var marker = 1; } } @@ -459,13 +482,14 @@ fn f() { auto* expect = R"( fn f() { + let runtime_value = 0; const f = 1.0; const arr = array(f); { var i = f; loop { let tint_symbol = arr; - if (!((i == tint_symbol[0]))) { + if (!((i == tint_symbol[runtime_value]))) { break; } { @@ -480,7 +504,6 @@ fn f() { } )"; - DataMap data; auto got = Run(src); EXPECT_EQ(expect, str(got)); @@ -493,7 +516,8 @@ const f = 1.0; const arr = array(f); fn F() { - for(var i = f; i == arr[0]; i = i + 1.0) { + let runtime_value = 0; + for(var i = f; i == arr[runtime_value]; i = i + 1.0) { var marker = 1; } } @@ -505,11 +529,12 @@ const f = 1.0; const arr = array(f); fn F() { + let runtime_value = 0; { var i = f; loop { let tint_symbol = arr; - if (!((i == tint_symbol[0]))) { + if (!((i == tint_symbol[runtime_value]))) { break; } { @@ -524,7 +549,6 @@ fn F() { } )"; - DataMap data; auto got = Run(src); EXPECT_EQ(expect, str(got)); @@ -533,8 +557,9 @@ fn F() { TEST_F(PromoteInitializersToLetTest, ArrayInForLoopCont) { auto* src = R"( fn f() { + let runtime_value = 0; var f = 0.0; - for(; f < 10.0; f = f + array(1.0)[0]) { + for(; f < 10.0; f = f + array(1.0)[runtime_value]) { var marker = 1; } } @@ -542,6 +567,7 @@ fn f() { auto* expect = R"( fn f() { + let runtime_value = 0; var f = 0.0; loop { if (!((f < 10.0))) { @@ -553,13 +579,12 @@ fn f() { continuing { let tint_symbol = array(1.0); - f = (f + tint_symbol[0]); + f = (f + tint_symbol[runtime_value]); } } } )"; - DataMap data; auto got = Run(src); EXPECT_EQ(expect, str(got)); @@ -568,9 +593,10 @@ fn f() { TEST_F(PromoteInitializersToLetTest, LocalConstArrayInForLoopCont) { auto* src = R"( fn f() { + let runtime_value = 0; const arr = array(1.0); var f = 0.0; - for(; f < 10.0; f = f + arr[0]) { + for(; f < 10.0; f = f + arr[runtime_value]) { var marker = 1; } } @@ -578,6 +604,7 @@ fn f() { auto* expect = R"( fn f() { + let runtime_value = 0; const arr = array(1.0); var f = 0.0; loop { @@ -590,13 +617,12 @@ fn f() { continuing { let tint_symbol = arr; - f = (f + tint_symbol[0]); + f = (f + tint_symbol[runtime_value]); } } } )"; - DataMap data; auto got = Run(src); EXPECT_EQ(expect, str(got)); @@ -607,8 +633,9 @@ TEST_F(PromoteInitializersToLetTest, GlobalConstArrayInForLoopCont) { const arr = array(1.0); fn f() { + let runtime_value = 0; var f = 0.0; - for(; f < 10.0; f = f + arr[0]) { + for(; f < 10.0; f = f + arr[runtime_value]) { var marker = 1; } } @@ -618,6 +645,7 @@ fn f() { const arr = array(1.0); fn f() { + let runtime_value = 0; var f = 0.0; loop { if (!((f < 10.0))) { @@ -629,13 +657,12 @@ fn f() { continuing { let tint_symbol = arr; - f = (f + tint_symbol[0]); + f = (f + tint_symbol[runtime_value]); } } } )"; - DataMap data; auto got = Run(src); EXPECT_EQ(expect, str(got)); @@ -644,9 +671,10 @@ fn f() { TEST_F(PromoteInitializersToLetTest, ArrayInForLoopInitCondCont) { auto* src = R"( fn f() { - for(var f = array(0.0)[0]; - f < array(1.0)[0]; - f = f + array(2.0)[0]) { + let runtime_value = 0; + for(var f = array(0.0)[runtime_value]; + f < array(1.0)[runtime_value]; + f = f + array(2.0)[runtime_value]) { var marker = 1; } } @@ -654,12 +682,13 @@ fn f() { auto* expect = R"( fn f() { + let runtime_value = 0; let tint_symbol = array(0.0); { - var f = tint_symbol[0]; + var f = tint_symbol[runtime_value]; loop { let tint_symbol_1 = array(1.0); - if (!((f < tint_symbol_1[0]))) { + if (!((f < tint_symbol_1[runtime_value]))) { break; } { @@ -668,14 +697,13 @@ fn f() { continuing { let tint_symbol_2 = array(2.0); - f = (f + tint_symbol_2[0]); + f = (f + tint_symbol_2[runtime_value]); } } } } )"; - DataMap data; auto got = Run(src); EXPECT_EQ(expect, str(got)); @@ -684,10 +712,11 @@ fn f() { TEST_F(PromoteInitializersToLetTest, LocalConstArrayInForLoopInitCondCont) { auto* src = R"( fn f() { + let runtime_value = 0; const arr_a = array(0.0); const arr_b = array(1.0); const arr_c = array(2.0); - for(var f = arr_a[0]; f < arr_b[0]; f = f + arr_c[0]) { + for(var f = arr_a[runtime_value]; f < arr_b[runtime_value]; f = f + arr_c[runtime_value]) { var marker = 1; } } @@ -695,15 +724,16 @@ fn f() { auto* expect = R"( fn f() { + let runtime_value = 0; const arr_a = array(0.0); const arr_b = array(1.0); const arr_c = array(2.0); let tint_symbol = arr_a; { - var f = tint_symbol[0]; + var f = tint_symbol[runtime_value]; loop { let tint_symbol_1 = arr_b; - if (!((f < tint_symbol_1[0]))) { + if (!((f < tint_symbol_1[runtime_value]))) { break; } { @@ -712,14 +742,13 @@ fn f() { continuing { let tint_symbol_2 = arr_c; - f = (f + tint_symbol_2[0]); + f = (f + tint_symbol_2[runtime_value]); } } } } )"; - DataMap data; auto got = Run(src); EXPECT_EQ(expect, str(got)); @@ -751,7 +780,6 @@ fn f() { } )"; - DataMap data; auto got = Run(src); EXPECT_EQ(expect, str(got)); @@ -802,7 +830,6 @@ fn f() { } )"; - DataMap data; auto got = Run(src); EXPECT_EQ(expect, str(got)); @@ -811,15 +838,16 @@ fn f() { TEST_F(PromoteInitializersToLetTest, LocalConstArrayInElseIfChain) { auto* src = R"( fn f() { + let runtime_value = 0; const f = 1.0; const arr = array(f, f); if (true) { var marker = 0; } else if (true) { var marker = 1; - } else if (f == arr[0]) { + } else if (f == arr[runtime_value]) { var marker = 2; - } else if (f == arr[1]) { + } else if (f == arr[runtime_value + 1]) { var marker = 3; } else if (true) { var marker = 4; @@ -831,6 +859,7 @@ fn f() { auto* expect = R"( fn f() { + let runtime_value = 0; const f = 1.0; const arr = array(f, f); if (true) { @@ -839,11 +868,11 @@ fn f() { var marker = 1; } else { let tint_symbol = arr; - if ((f == tint_symbol[0])) { + if ((f == tint_symbol[runtime_value])) { var marker = 2; } else { let tint_symbol_1 = arr; - if ((f == tint_symbol_1[1])) { + if ((f == tint_symbol_1[(runtime_value + 1)])) { var marker = 3; } else if (true) { var marker = 4; @@ -855,7 +884,6 @@ fn f() { } )"; - DataMap data; auto got = Run(src); EXPECT_EQ(expect, str(got)); @@ -868,13 +896,14 @@ const f = 1.0; const arr = array(f, f); fn F() { + let runtime_value = 0; if (true) { var marker = 0; } else if (true) { var marker = 1; - } else if (f == arr[0]) { + } else if (f == arr[runtime_value]) { var marker = 2; - } else if (f == arr[1]) { + } else if (f == arr[runtime_value + 1]) { var marker = 3; } else if (true) { var marker = 4; @@ -890,17 +919,18 @@ const f = 1.0; const arr = array(f, f); fn F() { + let runtime_value = 0; if (true) { var marker = 0; } else if (true) { var marker = 1; } else { let tint_symbol = arr; - if ((f == tint_symbol[0])) { + if ((f == tint_symbol[runtime_value])) { var marker = 2; } else { let tint_symbol_1 = arr; - if ((f == tint_symbol_1[1])) { + if ((f == tint_symbol_1[(runtime_value + 1)])) { var marker = 3; } else if (true) { var marker = 4; @@ -912,35 +942,43 @@ fn F() { } )"; - DataMap data; auto got = Run(src); EXPECT_EQ(expect, str(got)); } -TEST_F(PromoteInitializersToLetTest, ArrayInArrayArray) { +TEST_F(PromoteInitializersToLetTest, ArrayInArrayArrayConstIndex) { auto* src = R"( fn f() { var i = array, 2u>(array(1.0, 2.0), array(3.0, 4.0))[0][1]; } )"; - auto* expect = R"( + EXPECT_FALSE(ShouldRun(src)); +} + +TEST_F(PromoteInitializersToLetTest, ArrayInArrayArrayRuntimeIndex) { + auto* src = R"( fn f() { - let tint_symbol = array(1.0, 2.0); - let tint_symbol_1 = array(3.0, 4.0); - let tint_symbol_2 = array, 2u>(tint_symbol, tint_symbol_1); - var i = tint_symbol_2[0][1]; + let runtime_value = 1; + var i = array, 2u>(array(1.0, 2.0), array(3.0, 4.0))[runtime_value][runtime_value + 1]; +} +)"; + + auto* expect = R"( +fn f() { + let runtime_value = 1; + let tint_symbol = array, 2u>(array(1.0, 2.0), array(3.0, 4.0)); + var i = tint_symbol[runtime_value][(runtime_value + 1)]; } )"; - DataMap data; auto got = Run(src); EXPECT_EQ(expect, str(got)); } -TEST_F(PromoteInitializersToLetTest, LocalConstArrayInArrayArray) { +TEST_F(PromoteInitializersToLetTest, LocalConstArrayInArrayArrayConstIndex) { auto* src = R"( fn f() { const arr_0 = array(1.0, 2.0); @@ -948,19 +986,33 @@ fn f() { const arr_2 = array, 2u>(arr_0, arr_1); var i = arr_2[0][1]; } +)"; + + EXPECT_FALSE(ShouldRun(src)); +} + +TEST_F(PromoteInitializersToLetTest, LocalConstArrayInArrayArrayRuntimeIndex) { + auto* src = R"( +fn f() { + let runtime_value = 1; + const arr_0 = array(1.0, 2.0); + const arr_1 = array(3.0, 4.0); + const arr_2 = array, 2u>(arr_0, arr_1); + var i = arr_2[runtime_value][runtime_value + 1]; +} )"; auto* expect = R"( fn f() { + let runtime_value = 1; const arr_0 = array(1.0, 2.0); const arr_1 = array(3.0, 4.0); const arr_2 = array, 2u>(arr_0, arr_1); let tint_symbol = arr_2; - var i = tint_symbol[0][1]; + var i = tint_symbol[runtime_value][(runtime_value + 1)]; } )"; - DataMap data; auto got = Run(src); EXPECT_EQ(expect, str(got)); @@ -975,7 +1027,8 @@ const arr_1 = array(3.0, 4.0); const arr_2 = array, 2u>(arr_0, arr_1); fn f() { - var i = arr_2[0][1]; + let runtime_value = 1; + var i = arr_2[runtime_value][runtime_value + 1]; } )"; @@ -987,12 +1040,12 @@ const arr_1 = array(3.0, 4.0); const arr_2 = array, 2u>(arr_0, arr_1); fn f() { + let runtime_value = 1; let tint_symbol = arr_2; - var i = tint_symbol[0][1]; + var i = tint_symbol[runtime_value][(runtime_value + 1)]; } )"; - DataMap data; auto got = Run(src); EXPECT_EQ(expect, str(got)); @@ -1014,8 +1067,12 @@ struct S3 { a : S2, }; +fn get_a(s : S3) -> S2 { + return s.a; +} + fn f() { - var x = S3(S2(1, S1(2), 3)).a.b.a; + var x = get_a(S3(S2(1, S1(2), 3))).b.a; } )"; @@ -1034,15 +1091,16 @@ struct S3 { a : S2, } +fn get_a(s : S3) -> S2 { + return s.a; +} + fn f() { - let tint_symbol = S1(2); - let tint_symbol_1 = S2(1, tint_symbol, 3); - let tint_symbol_2 = S3(tint_symbol_1); - var x = tint_symbol_2.a.b.a; + let tint_symbol = S3(S2(1, S1(2), 3)); + var x = get_a(tint_symbol).b.a; } )"; - DataMap data; auto got = Run(src); EXPECT_EQ(expect, str(got)); @@ -1058,8 +1116,12 @@ struct S2 { a : array, }; +fn get_a(s : S2) -> array { + return s.a; +} + fn f() { - var x = S2(array(S1(1), S1(2), S1(3))).a[1].a; + var x = get_a(S2(array(S1(1), S1(2), S1(3))))[1].a; } )"; @@ -1072,17 +1134,16 @@ struct S2 { a : array, } +fn get_a(s : S2) -> array { + return s.a; +} + fn f() { - let tint_symbol = S1(1); - let tint_symbol_1 = S1(2); - let tint_symbol_2 = S1(3); - let tint_symbol_3 = array(tint_symbol, tint_symbol_1, tint_symbol_2); - let tint_symbol_4 = S2(tint_symbol_3); - var x = tint_symbol_4.a[1].a; + let tint_symbol = S2(array(S1(1), S1(2), S1(3))); + var x = get_a(tint_symbol)[1].a; } )"; - DataMap data; auto got = Run(src); EXPECT_EQ(expect, str(got)); @@ -1091,7 +1152,11 @@ fn f() { TEST_F(PromoteInitializersToLetTest, Mixed_OutOfOrder) { auto* src = R"( fn f() { - var x = S2(array(S1(1), S1(2), S1(3))).a[1].a; + var x = get_a(S2(array(S1(1), S1(2), S1(3))))[1].a; +} + +fn get_a(s : S2) -> array { + return s.a; } struct S2 { @@ -1105,12 +1170,12 @@ struct S1 { auto* expect = R"( fn f() { - let tint_symbol = S1(1); - let tint_symbol_1 = S1(2); - let tint_symbol_2 = S1(3); - let tint_symbol_3 = array(tint_symbol, tint_symbol_1, tint_symbol_2); - let tint_symbol_4 = S2(tint_symbol_3); - var x = tint_symbol_4.a[1].a; + let tint_symbol = S2(array(S1(1), S1(2), S1(3))); + var x = get_a(tint_symbol)[1].a; +} + +fn get_a(s : S2) -> array { + return s.a; } struct S2 { @@ -1122,7 +1187,6 @@ struct S1 { } )"; - DataMap data; auto got = Run(src); EXPECT_EQ(expect, str(got)); @@ -1144,7 +1208,6 @@ const module_str : F = F(2.0); auto* expect = src; - DataMap data; auto got = Run(src); EXPECT_EQ(expect, str(got)); @@ -1166,7 +1229,6 @@ const module_arr : array = array(0.0, 1.0, 2.0, 3.0); auto* expect = src; - DataMap data; auto got = Run(src); EXPECT_EQ(expect, str(got)); @@ -1246,7 +1308,6 @@ fn Z() { } )"; - DataMap data; auto got = Run(src); EXPECT_EQ(expect, str(got)); diff --git a/src/tint/utils/hashset.h b/src/tint/utils/hashset.h index 53f71f5d65..2d427a1da1 100644 --- a/src/tint/utils/hashset.h +++ b/src/tint/utils/hashset.h @@ -43,6 +43,18 @@ class Hashset : public HashmapBase { struct NoValue {}; return this->template Put(std::forward(value), NoValue{}); } + + /// @returns the set entries of the map as a vector + /// @note the order of the returned vector is non-deterministic between compilers. + template + utils::Vector Vector() const { + utils::Vector out; + out.Reserve(this->Count()); + for (auto& value : *this) { + out.Push(value); + } + return out; + } }; } // namespace tint::utils diff --git a/src/tint/utils/hashset_test.cc b/src/tint/utils/hashset_test.cc index 64f0da3518..c541fb59d9 100644 --- a/src/tint/utils/hashset_test.cc +++ b/src/tint/utils/hashset_test.cc @@ -91,6 +91,16 @@ TEST(Hashset, Iterator) { EXPECT_THAT(set, testing::UnorderedElementsAre("one", "two", "three", "four")); } +TEST(Hashset, Vector) { + Hashset set; + set.Add("one"); + set.Add("four"); + set.Add("three"); + set.Add("two"); + auto vec = set.Vector(); + EXPECT_THAT(vec, testing::UnorderedElementsAre("one", "two", "three", "four")); +} + TEST(Hashset, Soak) { std::mt19937 rnd; std::unordered_set reference; diff --git a/src/tint/writer/glsl/generator_impl_sanitizer_test.cc b/src/tint/writer/glsl/generator_impl_sanitizer_test.cc index 9c425a8639..6bcca219de 100644 --- a/src/tint/writer/glsl/generator_impl_sanitizer_test.cc +++ b/src/tint/writer/glsl/generator_impl_sanitizer_test.cc @@ -186,12 +186,14 @@ TEST_F(GlslSanitizerTest, PromoteStructInitializerToConstVar) { Member("b", ty.vec3()), Member("c", ty.i32()), }); - auto* struct_init = Construct(ty.Of(str), 1_i, vec3(2_f, 3_f, 4_f), 4_i); + auto* runtime_value = Var("runtime_value", Expr(3_f)); + auto* struct_init = Construct(ty.Of(str), 1_i, vec3(2_f, runtime_value, 4_f), 4_i); auto* struct_access = MemberAccessor(struct_init, "b"); auto* pos = Var("pos", ty.vec3(), struct_access); Func("main", utils::Empty, ty.void_(), utils::Vector{ + Decl(runtime_value), Decl(pos), }, utils::Vector{ @@ -213,7 +215,8 @@ struct S { }; void tint_symbol() { - S tint_symbol_1 = S(1, vec3(2.0f, 3.0f, 4.0f), 4); + float runtime_value = 3.0f; + S tint_symbol_1 = S(1, vec3(2.0f, runtime_value, 4.0f), 4); vec3 pos = tint_symbol_1.b; } diff --git a/src/tint/writer/hlsl/generator_impl_sanitizer_test.cc b/src/tint/writer/hlsl/generator_impl_sanitizer_test.cc index dbe8a51e5b..761eb82de6 100644 --- a/src/tint/writer/hlsl/generator_impl_sanitizer_test.cc +++ b/src/tint/writer/hlsl/generator_impl_sanitizer_test.cc @@ -197,17 +197,19 @@ TEST_F(HlslSanitizerTest, PromoteArrayInitializerToConstVar) { } TEST_F(HlslSanitizerTest, PromoteStructInitializerToConstVar) { + auto* runtime_value = Var("runtime_value", Expr(3_f)); auto* str = Structure("S", utils::Vector{ Member("a", ty.i32()), Member("b", ty.vec3()), Member("c", ty.i32()), }); - auto* struct_init = Construct(ty.Of(str), 1_i, vec3(2_f, 3_f, 4_f), 4_i); + auto* struct_init = Construct(ty.Of(str), 1_i, vec3(2_f, runtime_value, 4_f), 4_i); auto* struct_access = MemberAccessor(struct_init, "b"); auto* pos = Var("pos", ty.vec3(), struct_access); Func("main", utils::Empty, ty.void_(), utils::Vector{ + Decl(runtime_value), Decl(pos), }, utils::Vector{ @@ -226,7 +228,8 @@ TEST_F(HlslSanitizerTest, PromoteStructInitializerToConstVar) { }; void main() { - const S tint_symbol = {1, float3(2.0f, 3.0f, 4.0f), 4}; + float runtime_value = 3.0f; + const S tint_symbol = {1, float3(2.0f, runtime_value, 4.0f), 4}; float3 pos = tint_symbol.b; return; } diff --git a/test/tint/array/type_initializer.wgsl.expected.dxc.hlsl b/test/tint/array/type_initializer.wgsl.expected.dxc.hlsl index 8640324cbc..eb59a88713 100644 --- a/test/tint/array/type_initializer.wgsl.expected.dxc.hlsl +++ b/test/tint/array/type_initializer.wgsl.expected.dxc.hlsl @@ -5,33 +5,19 @@ void main() { const int nonempty[4] = {1, 2, 3, 4}; const int nonempty_with_expr[4] = {1, x, (x + 1), nonempty[3]}; const int nested_empty[2][3][4] = (int[2][3][4])0; - const int tint_symbol[4] = {1, 2, 3, 4}; - const int tint_symbol_1[4] = {5, 6, 7, 8}; - const int tint_symbol_2[4] = {9, 10, 11, 12}; - const int tint_symbol_3[3][4] = {tint_symbol, tint_symbol_1, tint_symbol_2}; - const int tint_symbol_4[4] = {13, 14, 15, 16}; - const int tint_symbol_5[4] = {17, 18, 19, 20}; - const int tint_symbol_6[4] = {21, 22, 23, 24}; - const int tint_symbol_7[3][4] = {tint_symbol_4, tint_symbol_5, tint_symbol_6}; - const int nested_nonempty[2][3][4] = {tint_symbol_3, tint_symbol_7}; - const int tint_symbol_8[4] = {1, 2, x, (x + 1)}; - const int tint_symbol_9[4] = {5, 6, nonempty[2], (nonempty[3] + 1)}; - const int tint_symbol_10[3][4] = {tint_symbol_8, tint_symbol_9, nonempty}; - const int nested_nonempty_with_expr[2][3][4] = {tint_symbol_10, nested_nonempty[1]}; - const int tint_symbol_11[4] = (int[4])0; - const int subexpr_empty = tint_symbol_11[1]; - const int tint_symbol_12[4] = {1, 2, 3, 4}; - const int subexpr_nonempty = tint_symbol_12[2]; - const int tint_symbol_13[4] = {1, x, (x + 1), nonempty[3]}; - const int subexpr_nonempty_with_expr = tint_symbol_13[2]; - const int tint_symbol_14[2][4] = (int[2][4])0; - const int subexpr_nested_empty[4] = tint_symbol_14[1]; - const int tint_symbol_15[4] = {1, 2, 3, 4}; - const int tint_symbol_16[4] = {5, 6, 7, 8}; - const int tint_symbol_17[2][4] = {tint_symbol_15, tint_symbol_16}; - const int subexpr_nested_nonempty[4] = tint_symbol_17[1]; - const int tint_symbol_18[4] = {1, x, (x + 1), nonempty[3]}; - const int tint_symbol_19[2][4] = {tint_symbol_18, nested_nonempty[1][2]}; - const int subexpr_nested_nonempty_with_expr[4] = tint_symbol_19[1]; + const int nested_nonempty[2][3][4] = {{{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}}, {{13, 14, 15, 16}, {17, 18, 19, 20}, {21, 22, 23, 24}}}; + const int tint_symbol[4] = {1, 2, x, (x + 1)}; + const int tint_symbol_1[4] = {5, 6, nonempty[2], (nonempty[3] + 1)}; + const int tint_symbol_2[3][4] = {tint_symbol, tint_symbol_1, nonempty}; + const int nested_nonempty_with_expr[2][3][4] = {tint_symbol_2, nested_nonempty[1]}; + const int subexpr_empty = 0; + const int subexpr_nonempty = 3; + const int tint_symbol_3[4] = {1, x, (x + 1), nonempty[3]}; + const int subexpr_nonempty_with_expr = tint_symbol_3[2]; + const int subexpr_nested_empty[4] = (int[4])0; + const int subexpr_nested_nonempty[4] = {5, 6, 7, 8}; + const int tint_symbol_4[4] = {1, x, (x + 1), nonempty[3]}; + const int tint_symbol_5[2][4] = {tint_symbol_4, nested_nonempty[1][2]}; + const int subexpr_nested_nonempty_with_expr[4] = tint_symbol_5[1]; return; } diff --git a/test/tint/array/type_initializer.wgsl.expected.fxc.hlsl b/test/tint/array/type_initializer.wgsl.expected.fxc.hlsl index 8640324cbc..eb59a88713 100644 --- a/test/tint/array/type_initializer.wgsl.expected.fxc.hlsl +++ b/test/tint/array/type_initializer.wgsl.expected.fxc.hlsl @@ -5,33 +5,19 @@ void main() { const int nonempty[4] = {1, 2, 3, 4}; const int nonempty_with_expr[4] = {1, x, (x + 1), nonempty[3]}; const int nested_empty[2][3][4] = (int[2][3][4])0; - const int tint_symbol[4] = {1, 2, 3, 4}; - const int tint_symbol_1[4] = {5, 6, 7, 8}; - const int tint_symbol_2[4] = {9, 10, 11, 12}; - const int tint_symbol_3[3][4] = {tint_symbol, tint_symbol_1, tint_symbol_2}; - const int tint_symbol_4[4] = {13, 14, 15, 16}; - const int tint_symbol_5[4] = {17, 18, 19, 20}; - const int tint_symbol_6[4] = {21, 22, 23, 24}; - const int tint_symbol_7[3][4] = {tint_symbol_4, tint_symbol_5, tint_symbol_6}; - const int nested_nonempty[2][3][4] = {tint_symbol_3, tint_symbol_7}; - const int tint_symbol_8[4] = {1, 2, x, (x + 1)}; - const int tint_symbol_9[4] = {5, 6, nonempty[2], (nonempty[3] + 1)}; - const int tint_symbol_10[3][4] = {tint_symbol_8, tint_symbol_9, nonempty}; - const int nested_nonempty_with_expr[2][3][4] = {tint_symbol_10, nested_nonempty[1]}; - const int tint_symbol_11[4] = (int[4])0; - const int subexpr_empty = tint_symbol_11[1]; - const int tint_symbol_12[4] = {1, 2, 3, 4}; - const int subexpr_nonempty = tint_symbol_12[2]; - const int tint_symbol_13[4] = {1, x, (x + 1), nonempty[3]}; - const int subexpr_nonempty_with_expr = tint_symbol_13[2]; - const int tint_symbol_14[2][4] = (int[2][4])0; - const int subexpr_nested_empty[4] = tint_symbol_14[1]; - const int tint_symbol_15[4] = {1, 2, 3, 4}; - const int tint_symbol_16[4] = {5, 6, 7, 8}; - const int tint_symbol_17[2][4] = {tint_symbol_15, tint_symbol_16}; - const int subexpr_nested_nonempty[4] = tint_symbol_17[1]; - const int tint_symbol_18[4] = {1, x, (x + 1), nonempty[3]}; - const int tint_symbol_19[2][4] = {tint_symbol_18, nested_nonempty[1][2]}; - const int subexpr_nested_nonempty_with_expr[4] = tint_symbol_19[1]; + const int nested_nonempty[2][3][4] = {{{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}}, {{13, 14, 15, 16}, {17, 18, 19, 20}, {21, 22, 23, 24}}}; + const int tint_symbol[4] = {1, 2, x, (x + 1)}; + const int tint_symbol_1[4] = {5, 6, nonempty[2], (nonempty[3] + 1)}; + const int tint_symbol_2[3][4] = {tint_symbol, tint_symbol_1, nonempty}; + const int nested_nonempty_with_expr[2][3][4] = {tint_symbol_2, nested_nonempty[1]}; + const int subexpr_empty = 0; + const int subexpr_nonempty = 3; + const int tint_symbol_3[4] = {1, x, (x + 1), nonempty[3]}; + const int subexpr_nonempty_with_expr = tint_symbol_3[2]; + const int subexpr_nested_empty[4] = (int[4])0; + const int subexpr_nested_nonempty[4] = {5, 6, 7, 8}; + const int tint_symbol_4[4] = {1, x, (x + 1), nonempty[3]}; + const int tint_symbol_5[2][4] = {tint_symbol_4, nested_nonempty[1][2]}; + const int subexpr_nested_nonempty_with_expr[4] = tint_symbol_5[1]; return; } diff --git a/test/tint/array/type_initializer.wgsl.expected.glsl b/test/tint/array/type_initializer.wgsl.expected.glsl index 82b9843538..65a79d4e7e 100644 --- a/test/tint/array/type_initializer.wgsl.expected.glsl +++ b/test/tint/array/type_initializer.wgsl.expected.glsl @@ -6,34 +6,20 @@ void tint_symbol() { int nonempty[4] = int[4](1, 2, 3, 4); int nonempty_with_expr[4] = int[4](1, x, (x + 1), nonempty[3]); int nested_empty[2][3][4] = int[2][3][4](int[3][4](int[4](0, 0, 0, 0), int[4](0, 0, 0, 0), int[4](0, 0, 0, 0)), int[3][4](int[4](0, 0, 0, 0), int[4](0, 0, 0, 0), int[4](0, 0, 0, 0))); - int tint_symbol_1[4] = int[4](1, 2, 3, 4); - int tint_symbol_2[4] = int[4](5, 6, 7, 8); - int tint_symbol_3[4] = int[4](9, 10, 11, 12); - int tint_symbol_4[3][4] = int[3][4](tint_symbol_1, tint_symbol_2, tint_symbol_3); - int tint_symbol_5[4] = int[4](13, 14, 15, 16); - int tint_symbol_6[4] = int[4](17, 18, 19, 20); - int tint_symbol_7[4] = int[4](21, 22, 23, 24); - int tint_symbol_8[3][4] = int[3][4](tint_symbol_5, tint_symbol_6, tint_symbol_7); - int nested_nonempty[2][3][4] = int[2][3][4](tint_symbol_4, tint_symbol_8); - int tint_symbol_9[4] = int[4](1, 2, x, (x + 1)); - int tint_symbol_10[4] = int[4](5, 6, nonempty[2], (nonempty[3] + 1)); - int tint_symbol_11[3][4] = int[3][4](tint_symbol_9, tint_symbol_10, nonempty); - int nested_nonempty_with_expr[2][3][4] = int[2][3][4](tint_symbol_11, nested_nonempty[1]); - int tint_symbol_12[4] = int[4](0, 0, 0, 0); - int subexpr_empty = tint_symbol_12[1]; - int tint_symbol_13[4] = int[4](1, 2, 3, 4); - int subexpr_nonempty = tint_symbol_13[2]; - int tint_symbol_14[4] = int[4](1, x, (x + 1), nonempty[3]); - int subexpr_nonempty_with_expr = tint_symbol_14[2]; - int tint_symbol_15[2][4] = int[2][4](int[4](0, 0, 0, 0), int[4](0, 0, 0, 0)); - int subexpr_nested_empty[4] = tint_symbol_15[1]; - int tint_symbol_16[4] = int[4](1, 2, 3, 4); - int tint_symbol_17[4] = int[4](5, 6, 7, 8); - int tint_symbol_18[2][4] = int[2][4](tint_symbol_16, tint_symbol_17); - int subexpr_nested_nonempty[4] = tint_symbol_18[1]; - int tint_symbol_19[4] = int[4](1, x, (x + 1), nonempty[3]); - int tint_symbol_20[2][4] = int[2][4](tint_symbol_19, nested_nonempty[1][2]); - int subexpr_nested_nonempty_with_expr[4] = tint_symbol_20[1]; + int nested_nonempty[2][3][4] = int[2][3][4](int[3][4](int[4](1, 2, 3, 4), int[4](5, 6, 7, 8), int[4](9, 10, 11, 12)), int[3][4](int[4](13, 14, 15, 16), int[4](17, 18, 19, 20), int[4](21, 22, 23, 24))); + int tint_symbol_1[4] = int[4](1, 2, x, (x + 1)); + int tint_symbol_2[4] = int[4](5, 6, nonempty[2], (nonempty[3] + 1)); + int tint_symbol_3[3][4] = int[3][4](tint_symbol_1, tint_symbol_2, nonempty); + int nested_nonempty_with_expr[2][3][4] = int[2][3][4](tint_symbol_3, nested_nonempty[1]); + int subexpr_empty = 0; + int subexpr_nonempty = 3; + int tint_symbol_4[4] = int[4](1, x, (x + 1), nonempty[3]); + int subexpr_nonempty_with_expr = tint_symbol_4[2]; + int subexpr_nested_empty[4] = int[4](0, 0, 0, 0); + int subexpr_nested_nonempty[4] = int[4](5, 6, 7, 8); + int tint_symbol_5[4] = int[4](1, x, (x + 1), nonempty[3]); + int tint_symbol_6[2][4] = int[2][4](tint_symbol_5, nested_nonempty[1][2]); + int subexpr_nested_nonempty_with_expr[4] = tint_symbol_6[1]; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; diff --git a/test/tint/array/type_initializer.wgsl.expected.msl b/test/tint/array/type_initializer.wgsl.expected.msl index d2ca398fe1..266d4b18a4 100644 --- a/test/tint/array/type_initializer.wgsl.expected.msl +++ b/test/tint/array/type_initializer.wgsl.expected.msl @@ -20,34 +20,20 @@ kernel void tint_symbol() { tint_array const nonempty = tint_array{1, 2, 3, 4}; tint_array const nonempty_with_expr = tint_array{1, x, as_type((as_type(x) + as_type(1))), nonempty[3]}; tint_array, 3>, 2> const nested_empty = tint_array, 3>, 2>{}; - tint_array const tint_symbol_1 = tint_array{1, 2, 3, 4}; - tint_array const tint_symbol_2 = tint_array{5, 6, 7, 8}; - tint_array const tint_symbol_3 = tint_array{9, 10, 11, 12}; - tint_array, 3> const tint_symbol_4 = tint_array, 3>{tint_symbol_1, tint_symbol_2, tint_symbol_3}; - tint_array const tint_symbol_5 = tint_array{13, 14, 15, 16}; - tint_array const tint_symbol_6 = tint_array{17, 18, 19, 20}; - tint_array const tint_symbol_7 = tint_array{21, 22, 23, 24}; - tint_array, 3> const tint_symbol_8 = tint_array, 3>{tint_symbol_5, tint_symbol_6, tint_symbol_7}; - tint_array, 3>, 2> const nested_nonempty = tint_array, 3>, 2>{tint_symbol_4, tint_symbol_8}; - tint_array const tint_symbol_9 = tint_array{1, 2, x, as_type((as_type(x) + as_type(1)))}; - tint_array const tint_symbol_10 = tint_array{5, 6, nonempty[2], as_type((as_type(nonempty[3]) + as_type(1)))}; - tint_array, 3> const tint_symbol_11 = tint_array, 3>{tint_symbol_9, tint_symbol_10, nonempty}; - tint_array, 3>, 2> const nested_nonempty_with_expr = tint_array, 3>, 2>{tint_symbol_11, nested_nonempty[1]}; - tint_array const tint_symbol_12 = tint_array{}; - int const subexpr_empty = tint_symbol_12[1]; - tint_array const tint_symbol_13 = tint_array{1, 2, 3, 4}; - int const subexpr_nonempty = tint_symbol_13[2]; - tint_array const tint_symbol_14 = tint_array{1, x, as_type((as_type(x) + as_type(1))), nonempty[3]}; - int const subexpr_nonempty_with_expr = tint_symbol_14[2]; - tint_array, 2> const tint_symbol_15 = tint_array, 2>{}; - tint_array const subexpr_nested_empty = tint_symbol_15[1]; - tint_array const tint_symbol_16 = tint_array{1, 2, 3, 4}; - tint_array const tint_symbol_17 = tint_array{5, 6, 7, 8}; - tint_array, 2> const tint_symbol_18 = tint_array, 2>{tint_symbol_16, tint_symbol_17}; - tint_array const subexpr_nested_nonempty = tint_symbol_18[1]; - tint_array const tint_symbol_19 = tint_array{1, x, as_type((as_type(x) + as_type(1))), nonempty[3]}; - tint_array, 2> const tint_symbol_20 = tint_array, 2>{tint_symbol_19, nested_nonempty[1][2]}; - tint_array const subexpr_nested_nonempty_with_expr = tint_symbol_20[1]; + tint_array, 3>, 2> const nested_nonempty = tint_array, 3>, 2>{tint_array, 3>{tint_array{1, 2, 3, 4}, tint_array{5, 6, 7, 8}, tint_array{9, 10, 11, 12}}, tint_array, 3>{tint_array{13, 14, 15, 16}, tint_array{17, 18, 19, 20}, tint_array{21, 22, 23, 24}}}; + tint_array const tint_symbol_1 = tint_array{1, 2, x, as_type((as_type(x) + as_type(1)))}; + tint_array const tint_symbol_2 = tint_array{5, 6, nonempty[2], as_type((as_type(nonempty[3]) + as_type(1)))}; + tint_array, 3> const tint_symbol_3 = tint_array, 3>{tint_symbol_1, tint_symbol_2, nonempty}; + tint_array, 3>, 2> const nested_nonempty_with_expr = tint_array, 3>, 2>{tint_symbol_3, nested_nonempty[1]}; + int const subexpr_empty = 0; + int const subexpr_nonempty = 3; + tint_array const tint_symbol_4 = tint_array{1, x, as_type((as_type(x) + as_type(1))), nonempty[3]}; + int const subexpr_nonempty_with_expr = tint_symbol_4[2]; + tint_array const subexpr_nested_empty = tint_array{}; + tint_array const subexpr_nested_nonempty = tint_array{5, 6, 7, 8}; + tint_array const tint_symbol_5 = tint_array{1, x, as_type((as_type(x) + as_type(1))), nonempty[3]}; + tint_array, 2> const tint_symbol_6 = tint_array, 2>{tint_symbol_5, nested_nonempty[1][2]}; + tint_array const subexpr_nested_nonempty_with_expr = tint_symbol_6[1]; return; } diff --git a/test/tint/bug/tint/1641.wgsl b/test/tint/bug/tint/1641.wgsl index b2a7387dec..92b83db74d 100644 --- a/test/tint/bug/tint/1641.wgsl +++ b/test/tint/bug/tint/1641.wgsl @@ -7,5 +7,6 @@ const faceNormals = array( @vertex fn main() -> @builtin(position) vec4 { - return vec4(faceNormals[0].f, 1.); + let zero = 0; + return vec4(faceNormals[zero].f, 1.); } diff --git a/test/tint/bug/tint/1641.wgsl.expected.dxc.hlsl b/test/tint/bug/tint/1641.wgsl.expected.dxc.hlsl index 1c77da508d..afb8535333 100644 --- a/test/tint/bug/tint/1641.wgsl.expected.dxc.hlsl +++ b/test/tint/bug/tint/1641.wgsl.expected.dxc.hlsl @@ -7,8 +7,9 @@ struct tint_symbol { }; float4 main_inner() { + const int zero = 0; const Normals tint_symbol_1[1] = {{float3(0.0f, 0.0f, 1.0f)}}; - return float4(tint_symbol_1[0].f, 1.0f); + return float4(tint_symbol_1[zero].f, 1.0f); } tint_symbol main() { diff --git a/test/tint/bug/tint/1641.wgsl.expected.fxc.hlsl b/test/tint/bug/tint/1641.wgsl.expected.fxc.hlsl index 1c77da508d..afb8535333 100644 --- a/test/tint/bug/tint/1641.wgsl.expected.fxc.hlsl +++ b/test/tint/bug/tint/1641.wgsl.expected.fxc.hlsl @@ -7,8 +7,9 @@ struct tint_symbol { }; float4 main_inner() { + const int zero = 0; const Normals tint_symbol_1[1] = {{float3(0.0f, 0.0f, 1.0f)}}; - return float4(tint_symbol_1[0].f, 1.0f); + return float4(tint_symbol_1[zero].f, 1.0f); } tint_symbol main() { diff --git a/test/tint/bug/tint/1641.wgsl.expected.glsl b/test/tint/bug/tint/1641.wgsl.expected.glsl index e5ac2be6ec..243d423e6c 100644 --- a/test/tint/bug/tint/1641.wgsl.expected.glsl +++ b/test/tint/bug/tint/1641.wgsl.expected.glsl @@ -5,8 +5,9 @@ struct Normals { }; vec4 tint_symbol() { + int zero = 0; Normals tint_symbol_1[1] = Normals[1](Normals(vec3(0.0f, 0.0f, 1.0f))); - return vec4(tint_symbol_1[0].f, 1.0f); + return vec4(tint_symbol_1[zero].f, 1.0f); } void main() { diff --git a/test/tint/bug/tint/1641.wgsl.expected.msl b/test/tint/bug/tint/1641.wgsl.expected.msl index 0d8c095f6a..b03793ae6a 100644 --- a/test/tint/bug/tint/1641.wgsl.expected.msl +++ b/test/tint/bug/tint/1641.wgsl.expected.msl @@ -23,8 +23,9 @@ struct tint_symbol_1 { }; float4 tint_symbol_inner() { + int const zero = 0; tint_array const tint_symbol_2 = tint_array{Normals{.f=float3(0.0f, 0.0f, 1.0f)}}; - return float4(tint_symbol_2[0].f, 1.0f); + return float4(tint_symbol_2[zero].f, 1.0f); } vertex tint_symbol_1 tint_symbol() { diff --git a/test/tint/bug/tint/1641.wgsl.expected.spvasm b/test/tint/bug/tint/1641.wgsl.expected.spvasm index b73e967c20..778978f3b5 100644 --- a/test/tint/bug/tint/1641.wgsl.expected.spvasm +++ b/test/tint/bug/tint/1641.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 19 +; Bound: 39 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -9,9 +9,14 @@ OpName %value "value" OpName %vertex_point_size "vertex_point_size" OpName %main_inner "main_inner" + OpName %Normals "Normals" + OpMemberName %Normals 0 "f" + OpName %var_for_index "var_for_index" OpName %main "main" OpDecorate %value BuiltIn Position OpDecorate %vertex_point_size BuiltIn PointSize + OpMemberDecorate %Normals 0 Offset 0 + OpDecorate %_arr_Normals_uint_1 ArrayStride 16 %float = OpTypeFloat 32 %v4float = OpTypeVector %float 4 %_ptr_Output_v4float = OpTypePointer Output %v4float @@ -21,18 +26,39 @@ %8 = OpConstantNull %float %vertex_point_size = OpVariable %_ptr_Output_float Output %8 %9 = OpTypeFunction %v4float + %int = OpTypeInt 32 1 + %13 = OpConstantNull %int + %v3float = OpTypeVector %float 3 + %Normals = OpTypeStruct %v3float + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 +%_arr_Normals_uint_1 = OpTypeArray %Normals %uint_1 %float_1 = OpConstant %float 1 - %13 = OpConstantComposite %v4float %8 %8 %float_1 %float_1 + %20 = OpConstantComposite %v3float %8 %8 %float_1 + %21 = OpConstantComposite %Normals %20 + %22 = OpConstantComposite %_arr_Normals_uint_1 %21 +%_ptr_Function__arr_Normals_uint_1 = OpTypePointer Function %_arr_Normals_uint_1 + %25 = OpConstantNull %_arr_Normals_uint_1 + %uint_0 = OpConstant %uint 0 +%_ptr_Function_v3float = OpTypePointer Function %v3float %void = OpTypeVoid - %14 = OpTypeFunction %void + %34 = OpTypeFunction %void %main_inner = OpFunction %v4float None %9 %11 = OpLabel - OpReturnValue %13 +%var_for_index = OpVariable %_ptr_Function__arr_Normals_uint_1 Function %25 + OpStore %var_for_index %22 + %28 = OpAccessChain %_ptr_Function_v3float %var_for_index %13 %uint_0 + %29 = OpLoad %v3float %28 + %30 = OpCompositeExtract %float %29 0 + %31 = OpCompositeExtract %float %29 1 + %32 = OpCompositeExtract %float %29 2 + %33 = OpCompositeConstruct %v4float %30 %31 %32 %float_1 + OpReturnValue %33 OpFunctionEnd - %main = OpFunction %void None %14 - %17 = OpLabel - %18 = OpFunctionCall %v4float %main_inner - OpStore %value %18 + %main = OpFunction %void None %34 + %37 = OpLabel + %38 = OpFunctionCall %v4float %main_inner + OpStore %value %38 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd diff --git a/test/tint/bug/tint/1641.wgsl.expected.wgsl b/test/tint/bug/tint/1641.wgsl.expected.wgsl index 3f235e7561..42f84f593d 100644 --- a/test/tint/bug/tint/1641.wgsl.expected.wgsl +++ b/test/tint/bug/tint/1641.wgsl.expected.wgsl @@ -6,5 +6,6 @@ const faceNormals = array(Normals(vec3(0, 0, 1))); @vertex fn main() -> @builtin(position) vec4 { - return vec4(faceNormals[0].f, 1.0); + let zero = 0; + return vec4(faceNormals[zero].f, 1.0); } diff --git a/test/tint/bug/tint/1781.wgsl b/test/tint/bug/tint/1781.wgsl new file mode 100644 index 0000000000..bbb776c24b --- /dev/null +++ b/test/tint/bug/tint/1781.wgsl @@ -0,0 +1,7 @@ +struct S { + a : i32, b : f32 +} + +fn f() { + const v = S(1, 2.0).a == 0; +} diff --git a/test/tint/bug/tint/1781.wgsl.expected.dxc.hlsl b/test/tint/bug/tint/1781.wgsl.expected.dxc.hlsl new file mode 100644 index 0000000000..7412e64899 --- /dev/null +++ b/test/tint/bug/tint/1781.wgsl.expected.dxc.hlsl @@ -0,0 +1,7 @@ +[numthreads(1, 1, 1)] +void unused_entry_point() { + return; +} + +void f() { +} diff --git a/test/tint/bug/tint/1781.wgsl.expected.fxc.hlsl b/test/tint/bug/tint/1781.wgsl.expected.fxc.hlsl new file mode 100644 index 0000000000..7412e64899 --- /dev/null +++ b/test/tint/bug/tint/1781.wgsl.expected.fxc.hlsl @@ -0,0 +1,7 @@ +[numthreads(1, 1, 1)] +void unused_entry_point() { + return; +} + +void f() { +} diff --git a/test/tint/bug/tint/1781.wgsl.expected.glsl b/test/tint/bug/tint/1781.wgsl.expected.glsl new file mode 100644 index 0000000000..20a43221a9 --- /dev/null +++ b/test/tint/bug/tint/1781.wgsl.expected.glsl @@ -0,0 +1,14 @@ +#version 310 es + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void unused_entry_point() { + return; +} +struct S { + int a; + float b; +}; + +void f() { +} + diff --git a/test/tint/bug/tint/1781.wgsl.expected.msl b/test/tint/bug/tint/1781.wgsl.expected.msl new file mode 100644 index 0000000000..c9d57243ce --- /dev/null +++ b/test/tint/bug/tint/1781.wgsl.expected.msl @@ -0,0 +1,11 @@ +#include + +using namespace metal; +struct S { + int a; + float b; +}; + +void f() { +} + diff --git a/test/tint/bug/tint/1781.wgsl.expected.spvasm b/test/tint/bug/tint/1781.wgsl.expected.spvasm new file mode 100644 index 0000000000..1c4d684e74 --- /dev/null +++ b/test/tint/bug/tint/1781.wgsl.expected.spvasm @@ -0,0 +1,21 @@ +; SPIR-V +; Version: 1.3 +; Generator: Google Tint Compiler; 0 +; Bound: 7 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + OpName %unused_entry_point "unused_entry_point" + OpName %f "f" + %void = OpTypeVoid + %1 = OpTypeFunction %void +%unused_entry_point = OpFunction %void None %1 + %4 = OpLabel + OpReturn + OpFunctionEnd + %f = OpFunction %void None %1 + %6 = OpLabel + OpReturn + OpFunctionEnd diff --git a/test/tint/bug/tint/1781.wgsl.expected.wgsl b/test/tint/bug/tint/1781.wgsl.expected.wgsl new file mode 100644 index 0000000000..9faf8d9387 --- /dev/null +++ b/test/tint/bug/tint/1781.wgsl.expected.wgsl @@ -0,0 +1,8 @@ +struct S { + a : i32, + b : f32, +} + +fn f() { + const v = (S(1, 2.0).a == 0); +} diff --git a/test/tint/builtins/frexp/scalar/const_members.wgsl.expected.dxc.hlsl b/test/tint/builtins/frexp/scalar/const_members.wgsl.expected.dxc.hlsl index c925f5c6b7..9f166c2503 100644 --- a/test/tint/builtins/frexp/scalar/const_members.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/frexp/scalar/const_members.wgsl.expected.dxc.hlsl @@ -1,12 +1,6 @@ -struct frexp_result_f32 { - float fract; - int exp; -}; [numthreads(1, 1, 1)] void main() { - const frexp_result_f32 tint_symbol_1 = {0.625f, 1}; - const float fract = tint_symbol_1.fract; - const frexp_result_f32 tint_symbol_2 = {0.625f, 1}; - const int exp = tint_symbol_2.exp; + const float fract = 0.625f; + const int exp = 1; return; } diff --git a/test/tint/builtins/frexp/scalar/const_members.wgsl.expected.fxc.hlsl b/test/tint/builtins/frexp/scalar/const_members.wgsl.expected.fxc.hlsl index c925f5c6b7..9f166c2503 100644 --- a/test/tint/builtins/frexp/scalar/const_members.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/frexp/scalar/const_members.wgsl.expected.fxc.hlsl @@ -1,12 +1,6 @@ -struct frexp_result_f32 { - float fract; - int exp; -}; [numthreads(1, 1, 1)] void main() { - const frexp_result_f32 tint_symbol_1 = {0.625f, 1}; - const float fract = tint_symbol_1.fract; - const frexp_result_f32 tint_symbol_2 = {0.625f, 1}; - const int exp = tint_symbol_2.exp; + const float fract = 0.625f; + const int exp = 1; return; } diff --git a/test/tint/builtins/frexp/scalar/const_members.wgsl.expected.glsl b/test/tint/builtins/frexp/scalar/const_members.wgsl.expected.glsl index d84878f5e9..9a038fb7b3 100644 --- a/test/tint/builtins/frexp/scalar/const_members.wgsl.expected.glsl +++ b/test/tint/builtins/frexp/scalar/const_members.wgsl.expected.glsl @@ -1,16 +1,8 @@ #version 310 es -struct frexp_result_f32 { - float fract; - int exp; -}; - - void tint_symbol() { - frexp_result_f32 tint_symbol_4 = frexp_result_f32(0.625f, 1); - float tint_symbol_2 = tint_symbol_4.fract; - frexp_result_f32 tint_symbol_5 = frexp_result_f32(0.625f, 1); - int tint_symbol_3 = tint_symbol_5.exp; + float tint_symbol_2 = 0.625f; + int tint_symbol_3 = 1; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; diff --git a/test/tint/builtins/frexp/scalar/const_members.wgsl.expected.msl b/test/tint/builtins/frexp/scalar/const_members.wgsl.expected.msl index cbc89a2e54..903873f6f8 100644 --- a/test/tint/builtins/frexp/scalar/const_members.wgsl.expected.msl +++ b/test/tint/builtins/frexp/scalar/const_members.wgsl.expected.msl @@ -1,16 +1,9 @@ #include using namespace metal; - -struct frexp_result_f32 { - float fract; - int exp; -}; kernel void tint_symbol() { - frexp_result_f32 const tint_symbol_1 = frexp_result_f32{.fract=0.625f, .exp=1}; - float const fract = tint_symbol_1.fract; - frexp_result_f32 const tint_symbol_2 = frexp_result_f32{.fract=0.625f, .exp=1}; - int const exp = tint_symbol_2.exp; + float const fract = 0.625f; + int const exp = 1; return; } diff --git a/test/tint/builtins/frexp/vector/const_members.wgsl.expected.dxc.hlsl b/test/tint/builtins/frexp/vector/const_members.wgsl.expected.dxc.hlsl index 78e98c7bab..89217b2723 100644 --- a/test/tint/builtins/frexp/vector/const_members.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/frexp/vector/const_members.wgsl.expected.dxc.hlsl @@ -1,12 +1,6 @@ -struct frexp_result_vec2_f32 { - float2 fract; - int2 exp; -}; [numthreads(1, 1, 1)] void main() { - const frexp_result_vec2_f32 tint_symbol_1 = {float2(0.625f, 0.9375f), int2(1, 2)}; - const float2 fract = tint_symbol_1.fract; - const frexp_result_vec2_f32 tint_symbol_2 = {float2(0.625f, 0.9375f), int2(1, 2)}; - const int2 exp = tint_symbol_2.exp; + const float2 fract = float2(0.625f, 0.9375f); + const int2 exp = int2(1, 2); return; } diff --git a/test/tint/builtins/frexp/vector/const_members.wgsl.expected.fxc.hlsl b/test/tint/builtins/frexp/vector/const_members.wgsl.expected.fxc.hlsl index 78e98c7bab..89217b2723 100644 --- a/test/tint/builtins/frexp/vector/const_members.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/frexp/vector/const_members.wgsl.expected.fxc.hlsl @@ -1,12 +1,6 @@ -struct frexp_result_vec2_f32 { - float2 fract; - int2 exp; -}; [numthreads(1, 1, 1)] void main() { - const frexp_result_vec2_f32 tint_symbol_1 = {float2(0.625f, 0.9375f), int2(1, 2)}; - const float2 fract = tint_symbol_1.fract; - const frexp_result_vec2_f32 tint_symbol_2 = {float2(0.625f, 0.9375f), int2(1, 2)}; - const int2 exp = tint_symbol_2.exp; + const float2 fract = float2(0.625f, 0.9375f); + const int2 exp = int2(1, 2); return; } diff --git a/test/tint/builtins/frexp/vector/const_members.wgsl.expected.glsl b/test/tint/builtins/frexp/vector/const_members.wgsl.expected.glsl index 89ca9c4230..e61268483a 100644 --- a/test/tint/builtins/frexp/vector/const_members.wgsl.expected.glsl +++ b/test/tint/builtins/frexp/vector/const_members.wgsl.expected.glsl @@ -1,16 +1,8 @@ #version 310 es -struct frexp_result_vec2_f32 { - vec2 fract; - ivec2 exp; -}; - - void tint_symbol() { - frexp_result_vec2_f32 tint_symbol_4 = frexp_result_vec2_f32(vec2(0.625f, 0.9375f), ivec2(1, 2)); - vec2 tint_symbol_2 = tint_symbol_4.fract; - frexp_result_vec2_f32 tint_symbol_5 = frexp_result_vec2_f32(vec2(0.625f, 0.9375f), ivec2(1, 2)); - ivec2 tint_symbol_3 = tint_symbol_5.exp; + vec2 tint_symbol_2 = vec2(0.625f, 0.9375f); + ivec2 tint_symbol_3 = ivec2(1, 2); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; diff --git a/test/tint/builtins/frexp/vector/const_members.wgsl.expected.msl b/test/tint/builtins/frexp/vector/const_members.wgsl.expected.msl index a675b6a6f2..c8c1c12979 100644 --- a/test/tint/builtins/frexp/vector/const_members.wgsl.expected.msl +++ b/test/tint/builtins/frexp/vector/const_members.wgsl.expected.msl @@ -1,16 +1,9 @@ #include using namespace metal; - -struct frexp_result_vec2_f32 { - float2 fract; - int2 exp; -}; kernel void tint_symbol() { - frexp_result_vec2_f32 const tint_symbol_1 = frexp_result_vec2_f32{.fract=float2(0.625f, 0.9375f), .exp=int2(1, 2)}; - float2 const fract = tint_symbol_1.fract; - frexp_result_vec2_f32 const tint_symbol_2 = frexp_result_vec2_f32{.fract=float2(0.625f, 0.9375f), .exp=int2(1, 2)}; - int2 const exp = tint_symbol_2.exp; + float2 const fract = float2(0.625f, 0.9375f); + int2 const exp = int2(1, 2); return; } diff --git a/test/tint/builtins/modf/scalar/const_members.wgsl.expected.dxc.hlsl b/test/tint/builtins/modf/scalar/const_members.wgsl.expected.dxc.hlsl index 60ad2a9c6b..b9f7ea3d41 100644 --- a/test/tint/builtins/modf/scalar/const_members.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/modf/scalar/const_members.wgsl.expected.dxc.hlsl @@ -1,12 +1,6 @@ -struct modf_result_f32 { - float fract; - float whole; -}; [numthreads(1, 1, 1)] void main() { - const modf_result_f32 tint_symbol_1 = {0.25f, 1.0f}; - const float fract = tint_symbol_1.fract; - const modf_result_f32 tint_symbol_2 = {0.25f, 1.0f}; - const float whole = tint_symbol_2.whole; + const float fract = 0.25f; + const float whole = 1.0f; return; } diff --git a/test/tint/builtins/modf/scalar/const_members.wgsl.expected.fxc.hlsl b/test/tint/builtins/modf/scalar/const_members.wgsl.expected.fxc.hlsl index 60ad2a9c6b..b9f7ea3d41 100644 --- a/test/tint/builtins/modf/scalar/const_members.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/modf/scalar/const_members.wgsl.expected.fxc.hlsl @@ -1,12 +1,6 @@ -struct modf_result_f32 { - float fract; - float whole; -}; [numthreads(1, 1, 1)] void main() { - const modf_result_f32 tint_symbol_1 = {0.25f, 1.0f}; - const float fract = tint_symbol_1.fract; - const modf_result_f32 tint_symbol_2 = {0.25f, 1.0f}; - const float whole = tint_symbol_2.whole; + const float fract = 0.25f; + const float whole = 1.0f; return; } diff --git a/test/tint/builtins/modf/scalar/const_members.wgsl.expected.glsl b/test/tint/builtins/modf/scalar/const_members.wgsl.expected.glsl index 27a3ab34c4..70ef050717 100644 --- a/test/tint/builtins/modf/scalar/const_members.wgsl.expected.glsl +++ b/test/tint/builtins/modf/scalar/const_members.wgsl.expected.glsl @@ -1,16 +1,8 @@ #version 310 es -struct modf_result_f32 { - float fract; - float whole; -}; - - void tint_symbol() { - modf_result_f32 tint_symbol_3 = modf_result_f32(0.25f, 1.0f); - float tint_symbol_2 = tint_symbol_3.fract; - modf_result_f32 tint_symbol_4 = modf_result_f32(0.25f, 1.0f); - float whole = tint_symbol_4.whole; + float tint_symbol_2 = 0.25f; + float whole = 1.0f; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; diff --git a/test/tint/builtins/modf/scalar/const_members.wgsl.expected.msl b/test/tint/builtins/modf/scalar/const_members.wgsl.expected.msl index fc8f220d3d..77f57076ea 100644 --- a/test/tint/builtins/modf/scalar/const_members.wgsl.expected.msl +++ b/test/tint/builtins/modf/scalar/const_members.wgsl.expected.msl @@ -1,16 +1,9 @@ #include using namespace metal; - -struct modf_result_f32 { - float fract; - float whole; -}; kernel void tint_symbol() { - modf_result_f32 const tint_symbol_1 = modf_result_f32{.fract=0.25f, .whole=1.0f}; - float const fract = tint_symbol_1.fract; - modf_result_f32 const tint_symbol_2 = modf_result_f32{.fract=0.25f, .whole=1.0f}; - float const whole = tint_symbol_2.whole; + float const fract = 0.25f; + float const whole = 1.0f; return; } diff --git a/test/tint/builtins/modf/vector/const_members.wgsl.expected.dxc.hlsl b/test/tint/builtins/modf/vector/const_members.wgsl.expected.dxc.hlsl index b73168e1f8..0096aa41dd 100644 --- a/test/tint/builtins/modf/vector/const_members.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/modf/vector/const_members.wgsl.expected.dxc.hlsl @@ -1,12 +1,6 @@ -struct modf_result_vec2_f32 { - float2 fract; - float2 whole; -}; [numthreads(1, 1, 1)] void main() { - const modf_result_vec2_f32 tint_symbol_1 = {float2(0.25f, 0.75f), float2(1.0f, 3.0f)}; - const float2 fract = tint_symbol_1.fract; - const modf_result_vec2_f32 tint_symbol_2 = {float2(0.25f, 0.75f), float2(1.0f, 3.0f)}; - const float2 whole = tint_symbol_2.whole; + const float2 fract = float2(0.25f, 0.75f); + const float2 whole = float2(1.0f, 3.0f); return; } diff --git a/test/tint/builtins/modf/vector/const_members.wgsl.expected.fxc.hlsl b/test/tint/builtins/modf/vector/const_members.wgsl.expected.fxc.hlsl index b73168e1f8..0096aa41dd 100644 --- a/test/tint/builtins/modf/vector/const_members.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/modf/vector/const_members.wgsl.expected.fxc.hlsl @@ -1,12 +1,6 @@ -struct modf_result_vec2_f32 { - float2 fract; - float2 whole; -}; [numthreads(1, 1, 1)] void main() { - const modf_result_vec2_f32 tint_symbol_1 = {float2(0.25f, 0.75f), float2(1.0f, 3.0f)}; - const float2 fract = tint_symbol_1.fract; - const modf_result_vec2_f32 tint_symbol_2 = {float2(0.25f, 0.75f), float2(1.0f, 3.0f)}; - const float2 whole = tint_symbol_2.whole; + const float2 fract = float2(0.25f, 0.75f); + const float2 whole = float2(1.0f, 3.0f); return; } diff --git a/test/tint/builtins/modf/vector/const_members.wgsl.expected.glsl b/test/tint/builtins/modf/vector/const_members.wgsl.expected.glsl index 6c56009358..07cf1b5d68 100644 --- a/test/tint/builtins/modf/vector/const_members.wgsl.expected.glsl +++ b/test/tint/builtins/modf/vector/const_members.wgsl.expected.glsl @@ -1,16 +1,8 @@ #version 310 es -struct modf_result_vec2_f32 { - vec2 fract; - vec2 whole; -}; - - void tint_symbol() { - modf_result_vec2_f32 tint_symbol_3 = modf_result_vec2_f32(vec2(0.25f, 0.75f), vec2(1.0f, 3.0f)); - vec2 tint_symbol_2 = tint_symbol_3.fract; - modf_result_vec2_f32 tint_symbol_4 = modf_result_vec2_f32(vec2(0.25f, 0.75f), vec2(1.0f, 3.0f)); - vec2 whole = tint_symbol_4.whole; + vec2 tint_symbol_2 = vec2(0.25f, 0.75f); + vec2 whole = vec2(1.0f, 3.0f); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; diff --git a/test/tint/builtins/modf/vector/const_members.wgsl.expected.msl b/test/tint/builtins/modf/vector/const_members.wgsl.expected.msl index 22285817c7..025a6f310b 100644 --- a/test/tint/builtins/modf/vector/const_members.wgsl.expected.msl +++ b/test/tint/builtins/modf/vector/const_members.wgsl.expected.msl @@ -1,16 +1,9 @@ #include using namespace metal; - -struct modf_result_vec2_f32 { - float2 fract; - float2 whole; -}; kernel void tint_symbol() { - modf_result_vec2_f32 const tint_symbol_1 = modf_result_vec2_f32{.fract=float2(0.25f, 0.75f), .whole=float2(1.0f, 3.0f)}; - float2 const fract = tint_symbol_1.fract; - modf_result_vec2_f32 const tint_symbol_2 = modf_result_vec2_f32{.fract=float2(0.25f, 0.75f), .whole=float2(1.0f, 3.0f)}; - float2 const whole = tint_symbol_2.whole; + float2 const fract = float2(0.25f, 0.75f); + float2 const whole = float2(1.0f, 3.0f); return; } diff --git a/test/tint/statements/for/condition/array_ctor.wgsl.expected.dxc.hlsl b/test/tint/statements/for/condition/array_ctor.wgsl.expected.dxc.hlsl index 2447811533..69b7f10e4e 100644 --- a/test/tint/statements/for/condition/array_ctor.wgsl.expected.dxc.hlsl +++ b/test/tint/statements/for/condition/array_ctor.wgsl.expected.dxc.hlsl @@ -5,12 +5,8 @@ void unused_entry_point() { void f() { int i = 0; - while (true) { - const int tint_symbol[1] = {1}; - if (!((i < tint_symbol[0]))) { - break; - } - { + { + for(; (i < 1); ) { } } } diff --git a/test/tint/statements/for/condition/array_ctor.wgsl.expected.fxc.hlsl b/test/tint/statements/for/condition/array_ctor.wgsl.expected.fxc.hlsl index 2447811533..69b7f10e4e 100644 --- a/test/tint/statements/for/condition/array_ctor.wgsl.expected.fxc.hlsl +++ b/test/tint/statements/for/condition/array_ctor.wgsl.expected.fxc.hlsl @@ -5,12 +5,8 @@ void unused_entry_point() { void f() { int i = 0; - while (true) { - const int tint_symbol[1] = {1}; - if (!((i < tint_symbol[0]))) { - break; - } - { + { + for(; (i < 1); ) { } } } diff --git a/test/tint/statements/for/condition/array_ctor.wgsl.expected.glsl b/test/tint/statements/for/condition/array_ctor.wgsl.expected.glsl index bf6fed3376..e9faafaee6 100644 --- a/test/tint/statements/for/condition/array_ctor.wgsl.expected.glsl +++ b/test/tint/statements/for/condition/array_ctor.wgsl.expected.glsl @@ -6,12 +6,8 @@ void unused_entry_point() { } void f() { int i = 0; - while (true) { - int tint_symbol[1] = int[1](1); - if (!((i < tint_symbol[0]))) { - break; - } - { + { + for(; (i < 1); ) { } } } diff --git a/test/tint/statements/for/condition/array_ctor.wgsl.expected.msl b/test/tint/statements/for/condition/array_ctor.wgsl.expected.msl index db046461f6..31a0722012 100644 --- a/test/tint/statements/for/condition/array_ctor.wgsl.expected.msl +++ b/test/tint/statements/for/condition/array_ctor.wgsl.expected.msl @@ -1,28 +1,9 @@ #include using namespace metal; - -template -struct tint_array { - const constant T& operator[](size_t i) const constant { return elements[i]; } - device T& operator[](size_t i) device { return elements[i]; } - const device T& operator[](size_t i) const device { return elements[i]; } - thread T& operator[](size_t i) thread { return elements[i]; } - const thread T& operator[](size_t i) const thread { return elements[i]; } - threadgroup T& operator[](size_t i) threadgroup { return elements[i]; } - const threadgroup T& operator[](size_t i) const threadgroup { return elements[i]; } - T elements[N]; -}; - void f() { int i = 0; - while (true) { - tint_array const tint_symbol = tint_array{1}; - if (!((i < tint_symbol[0]))) { - break; - } - { - } + for(; (i < 1); ) { } } diff --git a/test/tint/statements/for/condition/struct_ctor.wgsl.expected.dxc.hlsl b/test/tint/statements/for/condition/struct_ctor.wgsl.expected.dxc.hlsl index 4b4d128c1e..69b7f10e4e 100644 --- a/test/tint/statements/for/condition/struct_ctor.wgsl.expected.dxc.hlsl +++ b/test/tint/statements/for/condition/struct_ctor.wgsl.expected.dxc.hlsl @@ -3,18 +3,10 @@ void unused_entry_point() { return; } -struct S { - int i; -}; - void f() { int i = 0; - while (true) { - const S tint_symbol = {1}; - if (!((i < tint_symbol.i))) { - break; - } - { + { + for(; (i < 1); ) { } } } diff --git a/test/tint/statements/for/condition/struct_ctor.wgsl.expected.fxc.hlsl b/test/tint/statements/for/condition/struct_ctor.wgsl.expected.fxc.hlsl index 4b4d128c1e..69b7f10e4e 100644 --- a/test/tint/statements/for/condition/struct_ctor.wgsl.expected.fxc.hlsl +++ b/test/tint/statements/for/condition/struct_ctor.wgsl.expected.fxc.hlsl @@ -3,18 +3,10 @@ void unused_entry_point() { return; } -struct S { - int i; -}; - void f() { int i = 0; - while (true) { - const S tint_symbol = {1}; - if (!((i < tint_symbol.i))) { - break; - } - { + { + for(; (i < 1); ) { } } } diff --git a/test/tint/statements/for/condition/struct_ctor.wgsl.expected.glsl b/test/tint/statements/for/condition/struct_ctor.wgsl.expected.glsl index f092079a73..47db939c28 100644 --- a/test/tint/statements/for/condition/struct_ctor.wgsl.expected.glsl +++ b/test/tint/statements/for/condition/struct_ctor.wgsl.expected.glsl @@ -10,12 +10,8 @@ struct S { void f() { int i = 0; - while (true) { - S tint_symbol = S(1); - if (!((i < tint_symbol.i))) { - break; - } - { + { + for(; (i < 1); ) { } } } diff --git a/test/tint/statements/for/condition/struct_ctor.wgsl.expected.msl b/test/tint/statements/for/condition/struct_ctor.wgsl.expected.msl index 7ce803aa4b..a0a3bf0ee1 100644 --- a/test/tint/statements/for/condition/struct_ctor.wgsl.expected.msl +++ b/test/tint/statements/for/condition/struct_ctor.wgsl.expected.msl @@ -7,13 +7,7 @@ struct S { void f() { int i = 0; - while (true) { - S const tint_symbol = S{.i=1}; - if (!((i < tint_symbol.i))) { - break; - } - { - } + for(; (i < 1); ) { } } diff --git a/test/tint/statements/for/continuing/array_ctor.wgsl.expected.dxc.hlsl b/test/tint/statements/for/continuing/array_ctor.wgsl.expected.dxc.hlsl index 3e2c222f70..600b64d357 100644 --- a/test/tint/statements/for/continuing/array_ctor.wgsl.expected.dxc.hlsl +++ b/test/tint/statements/for/continuing/array_ctor.wgsl.expected.dxc.hlsl @@ -5,15 +5,8 @@ void unused_entry_point() { void f() { int i = 0; - while (true) { - if (true) { - break; - } - { - } - { - const int tint_symbol[1] = {1}; - i = (i + tint_symbol[0]); + { + for(; false; i = (i + 1)) { } } } diff --git a/test/tint/statements/for/continuing/array_ctor.wgsl.expected.fxc.hlsl b/test/tint/statements/for/continuing/array_ctor.wgsl.expected.fxc.hlsl index 3e2c222f70..600b64d357 100644 --- a/test/tint/statements/for/continuing/array_ctor.wgsl.expected.fxc.hlsl +++ b/test/tint/statements/for/continuing/array_ctor.wgsl.expected.fxc.hlsl @@ -5,15 +5,8 @@ void unused_entry_point() { void f() { int i = 0; - while (true) { - if (true) { - break; - } - { - } - { - const int tint_symbol[1] = {1}; - i = (i + tint_symbol[0]); + { + for(; false; i = (i + 1)) { } } } diff --git a/test/tint/statements/for/continuing/array_ctor.wgsl.expected.glsl b/test/tint/statements/for/continuing/array_ctor.wgsl.expected.glsl index a7aeccfe43..1789f6c579 100644 --- a/test/tint/statements/for/continuing/array_ctor.wgsl.expected.glsl +++ b/test/tint/statements/for/continuing/array_ctor.wgsl.expected.glsl @@ -6,15 +6,8 @@ void unused_entry_point() { } void f() { int i = 0; - while (true) { - if (true) { - break; - } - { - } - { - int tint_symbol[1] = int[1](1); - i = (i + tint_symbol[0]); + { + for(; false; i = (i + 1)) { } } } diff --git a/test/tint/statements/for/continuing/array_ctor.wgsl.expected.msl b/test/tint/statements/for/continuing/array_ctor.wgsl.expected.msl index a33ba157a9..3130ddd8fd 100644 --- a/test/tint/statements/for/continuing/array_ctor.wgsl.expected.msl +++ b/test/tint/statements/for/continuing/array_ctor.wgsl.expected.msl @@ -1,31 +1,9 @@ #include using namespace metal; - -template -struct tint_array { - const constant T& operator[](size_t i) const constant { return elements[i]; } - device T& operator[](size_t i) device { return elements[i]; } - const device T& operator[](size_t i) const device { return elements[i]; } - thread T& operator[](size_t i) thread { return elements[i]; } - const thread T& operator[](size_t i) const thread { return elements[i]; } - threadgroup T& operator[](size_t i) threadgroup { return elements[i]; } - const threadgroup T& operator[](size_t i) const threadgroup { return elements[i]; } - T elements[N]; -}; - void f() { int i = 0; - while (true) { - if (true) { - break; - } - { - } - { - tint_array const tint_symbol = tint_array{1}; - i = as_type((as_type(i) + as_type(tint_symbol[0]))); - } + for(; false; i = as_type((as_type(i) + as_type(1)))) { } } diff --git a/test/tint/statements/for/continuing/struct_ctor.wgsl.expected.dxc.hlsl b/test/tint/statements/for/continuing/struct_ctor.wgsl.expected.dxc.hlsl index aa5a75c711..79e5ce9266 100644 --- a/test/tint/statements/for/continuing/struct_ctor.wgsl.expected.dxc.hlsl +++ b/test/tint/statements/for/continuing/struct_ctor.wgsl.expected.dxc.hlsl @@ -3,23 +3,9 @@ void unused_entry_point() { return; } -struct S { - int i; -}; - void f() { { - int i = 0; - while (true) { - if (true) { - break; - } - { - } - { - const S tint_symbol = {1}; - i = (i + tint_symbol.i); - } + for(int i = 0; false; i = (i + 1)) { } } } diff --git a/test/tint/statements/for/continuing/struct_ctor.wgsl.expected.fxc.hlsl b/test/tint/statements/for/continuing/struct_ctor.wgsl.expected.fxc.hlsl index aa5a75c711..79e5ce9266 100644 --- a/test/tint/statements/for/continuing/struct_ctor.wgsl.expected.fxc.hlsl +++ b/test/tint/statements/for/continuing/struct_ctor.wgsl.expected.fxc.hlsl @@ -3,23 +3,9 @@ void unused_entry_point() { return; } -struct S { - int i; -}; - void f() { { - int i = 0; - while (true) { - if (true) { - break; - } - { - } - { - const S tint_symbol = {1}; - i = (i + tint_symbol.i); - } + for(int i = 0; false; i = (i + 1)) { } } } diff --git a/test/tint/statements/for/continuing/struct_ctor.wgsl.expected.glsl b/test/tint/statements/for/continuing/struct_ctor.wgsl.expected.glsl index e473af08bb..2c97128e73 100644 --- a/test/tint/statements/for/continuing/struct_ctor.wgsl.expected.glsl +++ b/test/tint/statements/for/continuing/struct_ctor.wgsl.expected.glsl @@ -10,17 +10,7 @@ struct S { void f() { { - int i = 0; - while (true) { - if (true) { - break; - } - { - } - { - S tint_symbol = S(1); - i = (i + tint_symbol.i); - } + for(int i = 0; false; i = (i + 1)) { } } } diff --git a/test/tint/statements/for/continuing/struct_ctor.wgsl.expected.msl b/test/tint/statements/for/continuing/struct_ctor.wgsl.expected.msl index 353f1ff319..fd9b90b631 100644 --- a/test/tint/statements/for/continuing/struct_ctor.wgsl.expected.msl +++ b/test/tint/statements/for/continuing/struct_ctor.wgsl.expected.msl @@ -6,19 +6,7 @@ struct S { }; void f() { - { - int i = 0; - while (true) { - if (true) { - break; - } - { - } - { - S const tint_symbol = S{.i=1}; - i = as_type((as_type(i) + as_type(tint_symbol.i))); - } - } + for(int i = 0; false; i = as_type((as_type(i) + as_type(1)))) { } } diff --git a/test/tint/statements/for/initializer/array_ctor.wgsl.expected.dxc.hlsl b/test/tint/statements/for/initializer/array_ctor.wgsl.expected.dxc.hlsl index 832b29f7bd..cc11a9f38d 100644 --- a/test/tint/statements/for/initializer/array_ctor.wgsl.expected.dxc.hlsl +++ b/test/tint/statements/for/initializer/array_ctor.wgsl.expected.dxc.hlsl @@ -4,9 +4,8 @@ void unused_entry_point() { } void f() { - const int tint_symbol[1] = {1}; { - for(int i = tint_symbol[0]; false; ) { + for(int i = 1; false; ) { } } } diff --git a/test/tint/statements/for/initializer/array_ctor.wgsl.expected.fxc.hlsl b/test/tint/statements/for/initializer/array_ctor.wgsl.expected.fxc.hlsl index 832b29f7bd..cc11a9f38d 100644 --- a/test/tint/statements/for/initializer/array_ctor.wgsl.expected.fxc.hlsl +++ b/test/tint/statements/for/initializer/array_ctor.wgsl.expected.fxc.hlsl @@ -4,9 +4,8 @@ void unused_entry_point() { } void f() { - const int tint_symbol[1] = {1}; { - for(int i = tint_symbol[0]; false; ) { + for(int i = 1; false; ) { } } } diff --git a/test/tint/statements/for/initializer/array_ctor.wgsl.expected.glsl b/test/tint/statements/for/initializer/array_ctor.wgsl.expected.glsl index eeb0109bce..6e4dc8e45c 100644 --- a/test/tint/statements/for/initializer/array_ctor.wgsl.expected.glsl +++ b/test/tint/statements/for/initializer/array_ctor.wgsl.expected.glsl @@ -5,9 +5,8 @@ void unused_entry_point() { return; } void f() { - int tint_symbol[1] = int[1](1); { - for(int i = tint_symbol[0]; false; ) { + for(int i = 1; false; ) { } } } diff --git a/test/tint/statements/for/initializer/array_ctor.wgsl.expected.msl b/test/tint/statements/for/initializer/array_ctor.wgsl.expected.msl index 7600e084ff..ee30daf963 100644 --- a/test/tint/statements/for/initializer/array_ctor.wgsl.expected.msl +++ b/test/tint/statements/for/initializer/array_ctor.wgsl.expected.msl @@ -1,22 +1,8 @@ #include using namespace metal; - -template -struct tint_array { - const constant T& operator[](size_t i) const constant { return elements[i]; } - device T& operator[](size_t i) device { return elements[i]; } - const device T& operator[](size_t i) const device { return elements[i]; } - thread T& operator[](size_t i) thread { return elements[i]; } - const thread T& operator[](size_t i) const thread { return elements[i]; } - threadgroup T& operator[](size_t i) threadgroup { return elements[i]; } - const threadgroup T& operator[](size_t i) const threadgroup { return elements[i]; } - T elements[N]; -}; - void f() { - tint_array const tint_symbol = tint_array{1}; - for(int i = tint_symbol[0]; false; ) { + for(int i = 1; false; ) { } } diff --git a/test/tint/statements/for/initializer/struct_ctor.wgsl.expected.dxc.hlsl b/test/tint/statements/for/initializer/struct_ctor.wgsl.expected.dxc.hlsl index 54957fba53..cc11a9f38d 100644 --- a/test/tint/statements/for/initializer/struct_ctor.wgsl.expected.dxc.hlsl +++ b/test/tint/statements/for/initializer/struct_ctor.wgsl.expected.dxc.hlsl @@ -3,14 +3,9 @@ void unused_entry_point() { return; } -struct S { - int i; -}; - void f() { - const S tint_symbol = {1}; { - for(int i = tint_symbol.i; false; ) { + for(int i = 1; false; ) { } } } diff --git a/test/tint/statements/for/initializer/struct_ctor.wgsl.expected.fxc.hlsl b/test/tint/statements/for/initializer/struct_ctor.wgsl.expected.fxc.hlsl index 54957fba53..cc11a9f38d 100644 --- a/test/tint/statements/for/initializer/struct_ctor.wgsl.expected.fxc.hlsl +++ b/test/tint/statements/for/initializer/struct_ctor.wgsl.expected.fxc.hlsl @@ -3,14 +3,9 @@ void unused_entry_point() { return; } -struct S { - int i; -}; - void f() { - const S tint_symbol = {1}; { - for(int i = tint_symbol.i; false; ) { + for(int i = 1; false; ) { } } } diff --git a/test/tint/statements/for/initializer/struct_ctor.wgsl.expected.glsl b/test/tint/statements/for/initializer/struct_ctor.wgsl.expected.glsl index 4c3a2cb1d9..c62dd46831 100644 --- a/test/tint/statements/for/initializer/struct_ctor.wgsl.expected.glsl +++ b/test/tint/statements/for/initializer/struct_ctor.wgsl.expected.glsl @@ -9,9 +9,8 @@ struct S { }; void f() { - S tint_symbol = S(1); { - for(int i = tint_symbol.i; false; ) { + for(int i = 1; false; ) { } } } diff --git a/test/tint/statements/for/initializer/struct_ctor.wgsl.expected.msl b/test/tint/statements/for/initializer/struct_ctor.wgsl.expected.msl index 555f775246..a4977208ac 100644 --- a/test/tint/statements/for/initializer/struct_ctor.wgsl.expected.msl +++ b/test/tint/statements/for/initializer/struct_ctor.wgsl.expected.msl @@ -6,8 +6,7 @@ struct S { }; void f() { - S const tint_symbol = S{.i=1}; - for(int i = tint_symbol.i; false; ) { + for(int i = 1; false; ) { } } diff --git a/test/tint/struct/type_initializer.wgsl.expected.dxc.hlsl b/test/tint/struct/type_initializer.wgsl.expected.dxc.hlsl index f6285aaa88..83e59e08bc 100644 --- a/test/tint/struct/type_initializer.wgsl.expected.dxc.hlsl +++ b/test/tint/struct/type_initializer.wgsl.expected.dxc.hlsl @@ -24,35 +24,23 @@ void main() { const S1 nonempty = {1, 2, 3, 4}; const S1 nonempty_with_expr = {1, x, (x + 1), nonempty.d}; const S3 nested_empty = (S3)0; - const S1 tint_symbol = {2, 3, 4, 5}; - const S1 tint_symbol_1 = {7, 8, 9, 10}; - const S2 tint_symbol_2 = {6, tint_symbol_1}; - const S3 nested_nonempty = {1, tint_symbol, tint_symbol_2}; + const S3 nested_nonempty = {1, {2, 3, 4, 5}, {6, {7, 8, 9, 10}}}; + const S1 tint_symbol = {2, x, (x + 1), nested_nonempty.i.f.d}; + const S2 tint_symbol_1 = {6, nonempty}; + const S3 nested_nonempty_with_expr = {1, tint_symbol, tint_symbol_1}; + const int subexpr_empty = 0; + const int subexpr_nonempty = 2; + const S1 tint_symbol_2 = {1, x, (x + 1), nonempty.d}; + const int subexpr_nonempty_with_expr = tint_symbol_2.c; + const S1 subexpr_nested_empty = (S1)0; + const S1 subexpr_nested_nonempty = {2, 3, 4, 5}; const S1 tint_symbol_3 = {2, x, (x + 1), nested_nonempty.i.f.d}; - const S2 tint_symbol_4 = {6, nonempty}; - const S3 nested_nonempty_with_expr = {1, tint_symbol_3, tint_symbol_4}; - const S1 tint_symbol_5 = (S1)0; - const int subexpr_empty = tint_symbol_5.a; - const S1 tint_symbol_6 = {1, 2, 3, 4}; - const int subexpr_nonempty = tint_symbol_6.b; - const S1 tint_symbol_7 = {1, x, (x + 1), nonempty.d}; - const int subexpr_nonempty_with_expr = tint_symbol_7.c; - const S2 tint_symbol_8 = (S2)0; - const S1 subexpr_nested_empty = tint_symbol_8.f; - const S1 tint_symbol_9 = {2, 3, 4, 5}; - const S2 tint_symbol_10 = {1, tint_symbol_9}; - const S1 subexpr_nested_nonempty = tint_symbol_10.f; - const S1 tint_symbol_11 = {2, x, (x + 1), nested_nonempty.i.f.d}; - const S2 tint_symbol_12 = {1, tint_symbol_11}; - const S1 subexpr_nested_nonempty_with_expr = tint_symbol_12.f; + const S2 tint_symbol_4 = {1, tint_symbol_3}; + const S1 subexpr_nested_nonempty_with_expr = tint_symbol_4.f; const T aosoa_empty[2] = (T[2])0; - const int tint_symbol_13[2] = {1, 2}; - const T tint_symbol_14 = {tint_symbol_13}; - const int tint_symbol_15[2] = {3, 4}; - const T tint_symbol_16 = {tint_symbol_15}; - const T aosoa_nonempty[2] = {tint_symbol_14, tint_symbol_16}; - const int tint_symbol_17[2] = {1, (aosoa_nonempty[0].a[0] + 1)}; - const T tint_symbol_18 = {tint_symbol_17}; - const T aosoa_nonempty_with_expr[2] = {tint_symbol_18, aosoa_nonempty[1]}; + const T aosoa_nonempty[2] = {{{1, 2}}, {{3, 4}}}; + const int tint_symbol_5[2] = {1, (aosoa_nonempty[0].a[0] + 1)}; + const T tint_symbol_6 = {tint_symbol_5}; + const T aosoa_nonempty_with_expr[2] = {tint_symbol_6, aosoa_nonempty[1]}; return; } diff --git a/test/tint/struct/type_initializer.wgsl.expected.fxc.hlsl b/test/tint/struct/type_initializer.wgsl.expected.fxc.hlsl index f6285aaa88..83e59e08bc 100644 --- a/test/tint/struct/type_initializer.wgsl.expected.fxc.hlsl +++ b/test/tint/struct/type_initializer.wgsl.expected.fxc.hlsl @@ -24,35 +24,23 @@ void main() { const S1 nonempty = {1, 2, 3, 4}; const S1 nonempty_with_expr = {1, x, (x + 1), nonempty.d}; const S3 nested_empty = (S3)0; - const S1 tint_symbol = {2, 3, 4, 5}; - const S1 tint_symbol_1 = {7, 8, 9, 10}; - const S2 tint_symbol_2 = {6, tint_symbol_1}; - const S3 nested_nonempty = {1, tint_symbol, tint_symbol_2}; + const S3 nested_nonempty = {1, {2, 3, 4, 5}, {6, {7, 8, 9, 10}}}; + const S1 tint_symbol = {2, x, (x + 1), nested_nonempty.i.f.d}; + const S2 tint_symbol_1 = {6, nonempty}; + const S3 nested_nonempty_with_expr = {1, tint_symbol, tint_symbol_1}; + const int subexpr_empty = 0; + const int subexpr_nonempty = 2; + const S1 tint_symbol_2 = {1, x, (x + 1), nonempty.d}; + const int subexpr_nonempty_with_expr = tint_symbol_2.c; + const S1 subexpr_nested_empty = (S1)0; + const S1 subexpr_nested_nonempty = {2, 3, 4, 5}; const S1 tint_symbol_3 = {2, x, (x + 1), nested_nonempty.i.f.d}; - const S2 tint_symbol_4 = {6, nonempty}; - const S3 nested_nonempty_with_expr = {1, tint_symbol_3, tint_symbol_4}; - const S1 tint_symbol_5 = (S1)0; - const int subexpr_empty = tint_symbol_5.a; - const S1 tint_symbol_6 = {1, 2, 3, 4}; - const int subexpr_nonempty = tint_symbol_6.b; - const S1 tint_symbol_7 = {1, x, (x + 1), nonempty.d}; - const int subexpr_nonempty_with_expr = tint_symbol_7.c; - const S2 tint_symbol_8 = (S2)0; - const S1 subexpr_nested_empty = tint_symbol_8.f; - const S1 tint_symbol_9 = {2, 3, 4, 5}; - const S2 tint_symbol_10 = {1, tint_symbol_9}; - const S1 subexpr_nested_nonempty = tint_symbol_10.f; - const S1 tint_symbol_11 = {2, x, (x + 1), nested_nonempty.i.f.d}; - const S2 tint_symbol_12 = {1, tint_symbol_11}; - const S1 subexpr_nested_nonempty_with_expr = tint_symbol_12.f; + const S2 tint_symbol_4 = {1, tint_symbol_3}; + const S1 subexpr_nested_nonempty_with_expr = tint_symbol_4.f; const T aosoa_empty[2] = (T[2])0; - const int tint_symbol_13[2] = {1, 2}; - const T tint_symbol_14 = {tint_symbol_13}; - const int tint_symbol_15[2] = {3, 4}; - const T tint_symbol_16 = {tint_symbol_15}; - const T aosoa_nonempty[2] = {tint_symbol_14, tint_symbol_16}; - const int tint_symbol_17[2] = {1, (aosoa_nonempty[0].a[0] + 1)}; - const T tint_symbol_18 = {tint_symbol_17}; - const T aosoa_nonempty_with_expr[2] = {tint_symbol_18, aosoa_nonempty[1]}; + const T aosoa_nonempty[2] = {{{1, 2}}, {{3, 4}}}; + const int tint_symbol_5[2] = {1, (aosoa_nonempty[0].a[0] + 1)}; + const T tint_symbol_6 = {tint_symbol_5}; + const T aosoa_nonempty_with_expr[2] = {tint_symbol_6, aosoa_nonempty[1]}; return; } diff --git a/test/tint/struct/type_initializer.wgsl.expected.glsl b/test/tint/struct/type_initializer.wgsl.expected.glsl index e300f8de73..4a5d7964af 100644 --- a/test/tint/struct/type_initializer.wgsl.expected.glsl +++ b/test/tint/struct/type_initializer.wgsl.expected.glsl @@ -28,36 +28,24 @@ void tint_symbol() { S1 nonempty = S1(1, 2, 3, 4); S1 nonempty_with_expr = S1(1, x, (x + 1), nonempty.d); S3 nested_empty = S3(0, S1(0, 0, 0, 0), S2(0, S1(0, 0, 0, 0))); - S1 tint_symbol_1 = S1(2, 3, 4, 5); - S1 tint_symbol_2 = S1(7, 8, 9, 10); - S2 tint_symbol_3 = S2(6, tint_symbol_2); - S3 nested_nonempty = S3(1, tint_symbol_1, tint_symbol_3); + S3 nested_nonempty = S3(1, S1(2, 3, 4, 5), S2(6, S1(7, 8, 9, 10))); + S1 tint_symbol_1 = S1(2, x, (x + 1), nested_nonempty.i.f.d); + S2 tint_symbol_2 = S2(6, nonempty); + S3 nested_nonempty_with_expr = S3(1, tint_symbol_1, tint_symbol_2); + int subexpr_empty = 0; + int subexpr_nonempty = 2; + S1 tint_symbol_3 = S1(1, x, (x + 1), nonempty.d); + int subexpr_nonempty_with_expr = tint_symbol_3.c; + S1 subexpr_nested_empty = S1(0, 0, 0, 0); + S1 subexpr_nested_nonempty = S1(2, 3, 4, 5); S1 tint_symbol_4 = S1(2, x, (x + 1), nested_nonempty.i.f.d); - S2 tint_symbol_5 = S2(6, nonempty); - S3 nested_nonempty_with_expr = S3(1, tint_symbol_4, tint_symbol_5); - S1 tint_symbol_6 = S1(0, 0, 0, 0); - int subexpr_empty = tint_symbol_6.a; - S1 tint_symbol_7 = S1(1, 2, 3, 4); - int subexpr_nonempty = tint_symbol_7.b; - S1 tint_symbol_8 = S1(1, x, (x + 1), nonempty.d); - int subexpr_nonempty_with_expr = tint_symbol_8.c; - S2 tint_symbol_9 = S2(0, S1(0, 0, 0, 0)); - S1 subexpr_nested_empty = tint_symbol_9.f; - S1 tint_symbol_10 = S1(2, 3, 4, 5); - S2 tint_symbol_11 = S2(1, tint_symbol_10); - S1 subexpr_nested_nonempty = tint_symbol_11.f; - S1 tint_symbol_12 = S1(2, x, (x + 1), nested_nonempty.i.f.d); - S2 tint_symbol_13 = S2(1, tint_symbol_12); - S1 subexpr_nested_nonempty_with_expr = tint_symbol_13.f; + S2 tint_symbol_5 = S2(1, tint_symbol_4); + S1 subexpr_nested_nonempty_with_expr = tint_symbol_5.f; T aosoa_empty[2] = T[2](T(int[2](0, 0)), T(int[2](0, 0))); - int tint_symbol_14[2] = int[2](1, 2); - T tint_symbol_15 = T(tint_symbol_14); - int tint_symbol_16[2] = int[2](3, 4); - T tint_symbol_17 = T(tint_symbol_16); - T aosoa_nonempty[2] = T[2](tint_symbol_15, tint_symbol_17); - int tint_symbol_18[2] = int[2](1, (aosoa_nonempty[0].a[0] + 1)); - T tint_symbol_19 = T(tint_symbol_18); - T aosoa_nonempty_with_expr[2] = T[2](tint_symbol_19, aosoa_nonempty[1]); + T aosoa_nonempty[2] = T[2](T(int[2](1, 2)), T(int[2](3, 4))); + int tint_symbol_6[2] = int[2](1, (aosoa_nonempty[0].a[0] + 1)); + T tint_symbol_7 = T(tint_symbol_6); + T aosoa_nonempty_with_expr[2] = T[2](tint_symbol_7, aosoa_nonempty[1]); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; diff --git a/test/tint/struct/type_initializer.wgsl.expected.msl b/test/tint/struct/type_initializer.wgsl.expected.msl index 55e2b9b0c0..0b63ad8b6f 100644 --- a/test/tint/struct/type_initializer.wgsl.expected.msl +++ b/test/tint/struct/type_initializer.wgsl.expected.msl @@ -42,36 +42,24 @@ kernel void tint_symbol() { S1 const nonempty = S1{.a=1, .b=2, .c=3, .d=4}; S1 const nonempty_with_expr = {.a=1, .b=x, .c=as_type((as_type(x) + as_type(1))), .d=nonempty.d}; S3 const nested_empty = S3{}; - S1 const tint_symbol_1 = S1{.a=2, .b=3, .c=4, .d=5}; - S1 const tint_symbol_2 = S1{.a=7, .b=8, .c=9, .d=10}; - S2 const tint_symbol_3 = {.e=6, .f=tint_symbol_2}; - S3 const nested_nonempty = {.g=1, .h=tint_symbol_1, .i=tint_symbol_3}; + S3 const nested_nonempty = S3{.g=1, .h=S1{.a=2, .b=3, .c=4, .d=5}, .i=S2{.e=6, .f=S1{.a=7, .b=8, .c=9, .d=10}}}; + S1 const tint_symbol_1 = {.a=2, .b=x, .c=as_type((as_type(x) + as_type(1))), .d=nested_nonempty.i.f.d}; + S2 const tint_symbol_2 = {.e=6, .f=nonempty}; + S3 const nested_nonempty_with_expr = {.g=1, .h=tint_symbol_1, .i=tint_symbol_2}; + int const subexpr_empty = 0; + int const subexpr_nonempty = 2; + S1 const tint_symbol_3 = {.a=1, .b=x, .c=as_type((as_type(x) + as_type(1))), .d=nonempty.d}; + int const subexpr_nonempty_with_expr = tint_symbol_3.c; + S1 const subexpr_nested_empty = S1{}; + S1 const subexpr_nested_nonempty = S1{.a=2, .b=3, .c=4, .d=5}; S1 const tint_symbol_4 = {.a=2, .b=x, .c=as_type((as_type(x) + as_type(1))), .d=nested_nonempty.i.f.d}; - S2 const tint_symbol_5 = {.e=6, .f=nonempty}; - S3 const nested_nonempty_with_expr = {.g=1, .h=tint_symbol_4, .i=tint_symbol_5}; - S1 const tint_symbol_6 = S1{}; - int const subexpr_empty = tint_symbol_6.a; - S1 const tint_symbol_7 = S1{.a=1, .b=2, .c=3, .d=4}; - int const subexpr_nonempty = tint_symbol_7.b; - S1 const tint_symbol_8 = {.a=1, .b=x, .c=as_type((as_type(x) + as_type(1))), .d=nonempty.d}; - int const subexpr_nonempty_with_expr = tint_symbol_8.c; - S2 const tint_symbol_9 = S2{}; - S1 const subexpr_nested_empty = tint_symbol_9.f; - S1 const tint_symbol_10 = S1{.a=2, .b=3, .c=4, .d=5}; - S2 const tint_symbol_11 = {.e=1, .f=tint_symbol_10}; - S1 const subexpr_nested_nonempty = tint_symbol_11.f; - S1 const tint_symbol_12 = {.a=2, .b=x, .c=as_type((as_type(x) + as_type(1))), .d=nested_nonempty.i.f.d}; - S2 const tint_symbol_13 = {.e=1, .f=tint_symbol_12}; - S1 const subexpr_nested_nonempty_with_expr = tint_symbol_13.f; + S2 const tint_symbol_5 = {.e=1, .f=tint_symbol_4}; + S1 const subexpr_nested_nonempty_with_expr = tint_symbol_5.f; tint_array const aosoa_empty = tint_array{}; - tint_array const tint_symbol_14 = tint_array{1, 2}; - T const tint_symbol_15 = {.a=tint_symbol_14}; - tint_array const tint_symbol_16 = tint_array{3, 4}; - T const tint_symbol_17 = {.a=tint_symbol_16}; - tint_array const aosoa_nonempty = tint_array{tint_symbol_15, tint_symbol_17}; - tint_array const tint_symbol_18 = tint_array{1, as_type((as_type(aosoa_nonempty[0].a[0]) + as_type(1)))}; - T const tint_symbol_19 = {.a=tint_symbol_18}; - tint_array const aosoa_nonempty_with_expr = tint_array{tint_symbol_19, aosoa_nonempty[1]}; + tint_array const aosoa_nonempty = tint_array{T{.a=tint_array{1, 2}}, T{.a=tint_array{3, 4}}}; + tint_array const tint_symbol_6 = tint_array{1, as_type((as_type(aosoa_nonempty[0].a[0]) + as_type(1)))}; + T const tint_symbol_7 = {.a=tint_symbol_6}; + tint_array const aosoa_nonempty_with_expr = tint_array{tint_symbol_7, aosoa_nonempty[1]}; return; } diff --git a/test/tint/var/initialization/function/array/array_i32.wgsl.expected.dxc.hlsl b/test/tint/var/initialization/function/array/array_i32.wgsl.expected.dxc.hlsl index 88d2dd3adc..e562e7ecb7 100644 --- a/test/tint/var/initialization/function/array/array_i32.wgsl.expected.dxc.hlsl +++ b/test/tint/var/initialization/function/array/array_i32.wgsl.expected.dxc.hlsl @@ -1,8 +1,6 @@ [numthreads(1, 1, 1)] void main() { int zero[2][3] = (int[2][3])0; - const int tint_symbol[3] = {1, 2, 3}; - const int tint_symbol_1[3] = {4, 5, 6}; - int init[2][3] = {tint_symbol, tint_symbol_1}; + int init[2][3] = {{1, 2, 3}, {4, 5, 6}}; return; } diff --git a/test/tint/var/initialization/function/array/array_i32.wgsl.expected.fxc.hlsl b/test/tint/var/initialization/function/array/array_i32.wgsl.expected.fxc.hlsl index 88d2dd3adc..e562e7ecb7 100644 --- a/test/tint/var/initialization/function/array/array_i32.wgsl.expected.fxc.hlsl +++ b/test/tint/var/initialization/function/array/array_i32.wgsl.expected.fxc.hlsl @@ -1,8 +1,6 @@ [numthreads(1, 1, 1)] void main() { int zero[2][3] = (int[2][3])0; - const int tint_symbol[3] = {1, 2, 3}; - const int tint_symbol_1[3] = {4, 5, 6}; - int init[2][3] = {tint_symbol, tint_symbol_1}; + int init[2][3] = {{1, 2, 3}, {4, 5, 6}}; return; } diff --git a/test/tint/var/initialization/function/array/array_i32.wgsl.expected.glsl b/test/tint/var/initialization/function/array/array_i32.wgsl.expected.glsl index 132ba505a4..9ca34ee5e6 100644 --- a/test/tint/var/initialization/function/array/array_i32.wgsl.expected.glsl +++ b/test/tint/var/initialization/function/array/array_i32.wgsl.expected.glsl @@ -2,9 +2,7 @@ void tint_symbol() { int zero[2][3] = int[2][3](int[3](0, 0, 0), int[3](0, 0, 0)); - int tint_symbol_1[3] = int[3](1, 2, 3); - int tint_symbol_2[3] = int[3](4, 5, 6); - int init[2][3] = int[2][3](tint_symbol_1, tint_symbol_2); + int init[2][3] = int[2][3](int[3](1, 2, 3), int[3](4, 5, 6)); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; diff --git a/test/tint/var/initialization/function/array/array_i32.wgsl.expected.msl b/test/tint/var/initialization/function/array/array_i32.wgsl.expected.msl index 7ad097e56b..978d5c71ff 100644 --- a/test/tint/var/initialization/function/array/array_i32.wgsl.expected.msl +++ b/test/tint/var/initialization/function/array/array_i32.wgsl.expected.msl @@ -16,9 +16,7 @@ struct tint_array { kernel void tint_symbol() { tint_array, 2> zero = {}; - tint_array const tint_symbol_1 = tint_array{1, 2, 3}; - tint_array const tint_symbol_2 = tint_array{4, 5, 6}; - tint_array, 2> init = tint_array, 2>{tint_symbol_1, tint_symbol_2}; + tint_array, 2> init = tint_array, 2>{tint_array{1, 2, 3}, tint_array{4, 5, 6}}; return; }