diff --git a/src/tint/intrinsics.def b/src/tint/intrinsics.def index 953000b356..b533770a17 100644 --- a/src/tint/intrinsics.def +++ b/src/tint/intrinsics.def @@ -886,11 +886,11 @@ op ! (vec) -> vec //////////////////////////////////////////////////////////////////////////////// // Binary Operators // //////////////////////////////////////////////////////////////////////////////// -op + (T, T) -> T -op + (vec, vec) -> vec -op + (vec, T) -> vec -op + (T, vec) -> vec -op + (mat, mat) -> mat +@const op + (T, T) -> T +@const op + (vec, vec) -> vec +@const op + (vec, T) -> vec +@const op + (T, vec) -> vec +@const op + (mat, mat) -> mat op - (T, T) -> T op - (vec, vec) -> vec diff --git a/src/tint/resolver/const_eval.cc b/src/tint/resolver/const_eval.cc index 4c9808b907..26a040396d 100644 --- a/src/tint/resolver/const_eval.cc +++ b/src/tint/resolver/const_eval.cc @@ -458,7 +458,7 @@ const Constant* CreateComposite(ProgramBuilder& builder, } /// TransformElements constructs a new constant by applying the transformation function 'f' on each -/// of the most deeply nested elements of 'cs'. +/// of the most deeply nested elements of 'cs'. Assumes that all constants are the same type. template const Constant* TransformElements(ProgramBuilder& builder, F&& f, CONSTANTS&&... cs) { uint32_t n = 0; @@ -470,11 +470,54 @@ const Constant* TransformElements(ProgramBuilder& builder, F&& f, CONSTANTS&&... utils::Vector els; els.Reserve(n); for (uint32_t i = 0; i < n; i++) { - els.Push(TransformElements(builder, f, cs->Index(i)...)); + els.Push(TransformElements(builder, std::forward(f), cs->Index(i)...)); } return CreateComposite(builder, ty, std::move(els)); } +/// TransformBinaryElements constructs a new constant by applying the transformation function 'f' on +/// each of the most deeply nested elements of both `c0` and `c1`. Unlike TransformElements, this +/// function handles the constants being of different types, e.g. vector-scalar, scalar-vector. +template +const Constant* TransformBinaryElements(ProgramBuilder& builder, + F&& f, + const sem::Constant* c0, + const sem::Constant* c1) { + uint32_t n0 = 0, n1 = 0; + sem::Type::ElementOf(c0->Type(), &n0); + sem::Type::ElementOf(c1->Type(), &n1); + uint32_t max_n = std::max(n0, n1); + // If arity of both constants is 1, invoke callback + if (max_n == 1u) { + return f(c0, c1); + } + + utils::Vector els; + els.Reserve(max_n); + for (uint32_t i = 0; i < max_n; i++) { + auto nested_or_self = [&](auto& c, uint32_t num_elems) { + if (num_elems == 1) { + return c; + } + return c->Index(i); + }; + els.Push(TransformBinaryElements(builder, std::forward(f), nested_or_self(c0, n0), + nested_or_self(c1, n1))); + } + // Use larger type + auto* ty = n0 > n1 ? c0->Type() : c1->Type(); + return CreateComposite(builder, ty, std::move(els)); +} + +/// CombineSource returns the combined `Source`s of each expression in `exprs`. +Source CombineSource(utils::VectorRef exprs) { + Source result = exprs[0]->Declaration()->source; + for (size_t i = 1; i < exprs.Length(); ++i) { + result = result.Combine(result, exprs[i]->Declaration()->source); + } + return result; +} + } // namespace ConstEval::ConstEval(ProgramBuilder& b) : builder(b) {} @@ -722,6 +765,51 @@ ConstEval::ConstantResult ConstEval::OpMinus(const sem::Type*, return TransformElements(builder, transform, args[0]->ConstantValue()); } +ConstEval::ConstantResult ConstEval::OpPlus(const sem::Type* ty, + utils::VectorRef args) { + auto transform = [&](const sem::Constant* c0, const sem::Constant* c1) { + auto create = [&](auto i, auto j) -> const Constant* { + using NumberT = decltype(i); + using T = UnwrapNumber; + + auto add_values = [](T lhs, T rhs) { + if constexpr (std::is_integral_v && std::is_signed_v) { + // Ensure no UB for signed overflow + using UT = std::make_unsigned_t; + return static_cast(static_cast(lhs) + static_cast(rhs)); + } else { + return lhs + rhs; + } + }; + + NumberT result; + if constexpr (std::is_same_v || std::is_same_v) { + // Check for over/underflow for abstract values + if (auto r = CheckedAdd(i, j)) { + result = r->value; + } else { + AddError("'" + std::to_string(add_values(i.value, j.value)) + + "' cannot be represented as '" + + ty->FriendlyName(builder.Symbols()) + "'", + CombineSource(args)); + return nullptr; + } + } else { + result = add_values(i.value, j.value); + } + return CreateElement(builder, c0->Type(), result); + }; + return Dispatch_fia_fiu32_f16(create, c0, c1); + }; + + auto r = TransformBinaryElements(builder, transform, args[0]->ConstantValue(), + args[1]->ConstantValue()); + if (builder.Diagnostics().contains_errors()) { + return utils::Failure; + } + return r; +} + ConstEval::ConstantResult ConstEval::atan2(const sem::Type*, utils::VectorRef args) { auto transform = [&](const sem::Constant* c0, const sem::Constant* c1) { diff --git a/src/tint/resolver/const_eval.h b/src/tint/resolver/const_eval.h index 2059731005..38bde53c8e 100644 --- a/src/tint/resolver/const_eval.h +++ b/src/tint/resolver/const_eval.h @@ -177,6 +177,16 @@ class ConstEval { /// @return the result value, or null if the value cannot be calculated ConstantResult OpMinus(const sem::Type* ty, utils::VectorRef args); + //////////////////////////////////////////////////////////////////////////// + // Binary Operators + //////////////////////////////////////////////////////////////////////////// + + /// Plus operator '+' + /// @param ty the expression type + /// @param args the input arguments + /// @return the result value, or null if the value cannot be calculated + ConstantResult OpPlus(const sem::Type* ty, utils::VectorRef args); + //////////////////////////////////////////////////////////////////////////// // Builtins //////////////////////////////////////////////////////////////////////////// diff --git a/src/tint/resolver/const_eval_test.cc b/src/tint/resolver/const_eval_test.cc index 6bc07b069d..e7c342d21a 100644 --- a/src/tint/resolver/const_eval_test.cc +++ b/src/tint/resolver/const_eval_test.cc @@ -43,15 +43,26 @@ const auto k3PiOver4 = T(UnwrapNumber(2.356194490192344928846)); template constexpr auto Negate(const Number& v) { - // For signed integrals, avoid C++ UB by not negating the smallest negative number. In - // WGSL, this operation is well defined to return the same value, see: - // https://gpuweb.github.io/gpuweb/wgsl/#arithmetic-expr. - if constexpr (std::is_integral_v && std::is_signed_v) { - if (v == std::numeric_limits::min()) { - return v; + if constexpr (std::is_integral_v) { + if constexpr (std::is_signed_v) { + // For signed integrals, avoid C++ UB by not negating the smallest negative number. In + // WGSL, this operation is well defined to return the same value, see: + // https://gpuweb.github.io/gpuweb/wgsl/#arithmetic-expr. + if (v == std::numeric_limits::min()) { + return v; + } + return -v; + + } else { + // Allow negating unsigned values + using ST = std::make_signed_t; + auto as_signed = Number{static_cast(v)}; + return Number{static_cast(Negate(as_signed))}; } + } else { + // float case + return -v; } - return -v; } template @@ -65,7 +76,7 @@ auto Abs(const Number& v) { // Concats any number of std::vectors template -auto Concat(Vec&& v1, Vecs&&... vs) { +[[nodiscard]] auto Concat(Vec&& v1, Vecs&&... vs) { auto total_size = v1.size() + (vs.size() + ...); v1.reserve(total_size); (std::move(vs.begin(), vs.end(), std::back_inserter(v1)), ...); @@ -3115,6 +3126,140 @@ TEST_F(ResolverConstEvalTest, UnaryNegateLowestAbstract) { } // namespace unary_op +//////////////////////////////////////////////////////////////////////////////////////////////////// +// Binary op +//////////////////////////////////////////////////////////////////////////////////////////////////// +namespace binary_op { + +template +struct Values { + T lhs; + T rhs; + T expect; + bool is_overflow; +}; + +struct Case { + std::variant, Values, Values, Values, Values, Values> + values; +}; + +static std::ostream& operator<<(std::ostream& o, const Case& c) { + std::visit([&](auto&& v) { o << v.lhs << " " << v.rhs; }, c.values); + return o; +} + +template +Case C(T lhs, T rhs, T expect, bool is_overflow = false) { + return Case{Values{lhs, rhs, expect, is_overflow}}; +} + +using ResolverConstEvalBinaryOpTest = ResolverTestWithParam>; +TEST_P(ResolverConstEvalBinaryOpTest, Test) { + Enable(ast::Extension::kF16); + + auto op = std::get<0>(GetParam()); + auto c = std::get<1>(GetParam()); + std::visit( + [&](auto&& values) { + using T = decltype(values.expect); + + if constexpr (std::is_same_v || std::is_same_v) { + if (values.is_overflow) { + return; + } + } + + auto* expr = create(op, Expr(values.lhs), Expr(values.rhs)); + GlobalConst("C", nullptr, expr); + + EXPECT_TRUE(r()->Resolve()) << r()->error(); + + auto* sem = Sem().Get(expr); + const sem::Constant* value = sem->ConstantValue(); + ASSERT_NE(value, nullptr); + EXPECT_TYPE(value->Type(), sem->Type()); + EXPECT_EQ(value->As(), values.expect); + + if constexpr (IsInteger>) { + // Check that the constant's integer doesn't contain unexpected data in the MSBs + // that are outside of the bit-width of T. + EXPECT_EQ(value->As(), AInt(values.expect)); + } + }, + c.values); +} + +template +std::vector OpAddIntCases() { + static_assert(IsInteger>); + return { + C(T{0}, T{0}, T{0}), + C(T{1}, T{2}, T{3}), + C(T::Lowest(), T{1}, T{T::Lowest() + 1}), + C(T::Highest(), Negate(T{1}), T{T::Highest() - 1}), + C(T::Lowest(), T::Highest(), Negate(T{1})), + C(T::Highest(), T{1}, T::Lowest(), true), + C(T::Lowest(), Negate(T{1}), T::Highest(), true), + }; +} +template +std::vector OpAddFloatCases() { + static_assert(IsFloatingPoint>); + return { + C(T{0}, T{0}, T{0}), + C(T{1}, T{2}, T{3}), + C(T::Lowest(), T{1}, T{T::Lowest() + 1}), + C(T::Highest(), Negate(T{1}), T{T::Highest() - 1}), + C(T::Lowest(), T::Highest(), T{0}), + C(T::Highest(), T::Highest(), T::Inf(), true), + C(T::Lowest(), Negate(T::Highest()), -T::Inf(), true), + }; +} +INSTANTIATE_TEST_SUITE_P(Add, + ResolverConstEvalBinaryOpTest, + testing::Combine(testing::Values(ast::BinaryOp::kAdd), + testing::ValuesIn(Concat( // + OpAddIntCases(), + OpAddIntCases(), + OpAddIntCases(), + OpAddFloatCases(), + OpAddFloatCases(), + OpAddFloatCases() // + )))); + +TEST_F(ResolverConstEvalTest, BinaryAbstractAddOverflow_AInt) { + GlobalConst("c", nullptr, Add(Expr(Source{{1, 1}}, AInt::Highest()), 1_a)); + EXPECT_FALSE(r()->Resolve()); + EXPECT_EQ(r()->error(), + "1:1 error: '-9223372036854775808' cannot be represented as 'abstract-int'"); +} + +TEST_F(ResolverConstEvalTest, BinaryAbstractAddUnderflow_AInt) { + GlobalConst("c", nullptr, Add(Expr(Source{{1, 1}}, AInt::Lowest()), -1_a)); + EXPECT_FALSE(r()->Resolve()); + EXPECT_EQ(r()->error(), + "1:1 error: '9223372036854775807' cannot be represented as 'abstract-int'"); +} + +TEST_F(ResolverConstEvalTest, BinaryAbstractAddOverflow_AFloat) { + GlobalConst("c", nullptr, Add(Expr(Source{{1, 1}}, AFloat::Highest()), AFloat::Highest())); + EXPECT_FALSE(r()->Resolve()); + EXPECT_EQ(r()->error(), "1:1 error: 'inf' cannot be represented as 'abstract-float'"); +} + +TEST_F(ResolverConstEvalTest, BinaryAbstractAddUnderflow_AFloat) { + GlobalConst("c", nullptr, Add(Expr(Source{{1, 1}}, AFloat::Lowest()), AFloat::Lowest())); + EXPECT_FALSE(r()->Resolve()); + EXPECT_EQ(r()->error(), "1:1 error: '-inf' cannot be represented as 'abstract-float'"); +} + +} // namespace binary_op + +//////////////////////////////////////////////////////////////////////////////////////////////////// +// Builtin +//////////////////////////////////////////////////////////////////////////////////////////////////// + namespace builtin { template diff --git a/src/tint/resolver/intrinsic_table.inl b/src/tint/resolver/intrinsic_table.inl index 28bcc51ec2..103ec3d402 100644 --- a/src/tint/resolver/intrinsic_table.inl +++ b/src/tint/resolver/intrinsic_table.inl @@ -11040,60 +11040,60 @@ constexpr OverloadInfo kOverloads[] = { /* num parameters */ 2, /* num template types */ 1, /* num template numbers */ 0, - /* template types */ &kTemplateTypes[14], + /* template types */ &kTemplateTypes[13], /* template numbers */ &kTemplateNumbers[10], /* parameters */ &kParameters[749], /* return matcher indices */ &kMatcherIndices[1], /* flags */ OverloadFlags(OverloadFlag::kIsOperator, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), - /* const eval */ nullptr, + /* const eval */ &ConstEval::OpPlus, }, { /* [243] */ /* num parameters */ 2, /* num template types */ 1, /* num template numbers */ 1, - /* template types */ &kTemplateTypes[14], + /* template types */ &kTemplateTypes[13], /* template numbers */ &kTemplateNumbers[6], /* parameters */ &kParameters[747], /* return matcher indices */ &kMatcherIndices[30], /* flags */ OverloadFlags(OverloadFlag::kIsOperator, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), - /* const eval */ nullptr, + /* const eval */ &ConstEval::OpPlus, }, { /* [244] */ /* num parameters */ 2, /* num template types */ 1, /* num template numbers */ 1, - /* template types */ &kTemplateTypes[14], + /* template types */ &kTemplateTypes[13], /* template numbers */ &kTemplateNumbers[6], /* parameters */ &kParameters[745], /* return matcher indices */ &kMatcherIndices[30], /* flags */ OverloadFlags(OverloadFlag::kIsOperator, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), - /* const eval */ nullptr, + /* const eval */ &ConstEval::OpPlus, }, { /* [245] */ /* num parameters */ 2, /* num template types */ 1, /* num template numbers */ 1, - /* template types */ &kTemplateTypes[14], + /* template types */ &kTemplateTypes[13], /* template numbers */ &kTemplateNumbers[6], /* parameters */ &kParameters[743], /* return matcher indices */ &kMatcherIndices[30], /* flags */ OverloadFlags(OverloadFlag::kIsOperator, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), - /* const eval */ nullptr, + /* const eval */ &ConstEval::OpPlus, }, { /* [246] */ /* num parameters */ 2, /* num template types */ 1, /* num template numbers */ 2, - /* template types */ &kTemplateTypes[11], + /* template types */ &kTemplateTypes[12], /* template numbers */ &kTemplateNumbers[6], /* parameters */ &kParameters[741], /* return matcher indices */ &kMatcherIndices[10], /* flags */ OverloadFlags(OverloadFlag::kIsOperator, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), - /* const eval */ nullptr, + /* const eval */ &ConstEval::OpPlus, }, { /* [247] */ @@ -14578,11 +14578,11 @@ constexpr uint8_t kUnaryOperatorMinus = 2; constexpr IntrinsicInfo kBinaryOperators[] = { { /* [0] */ - /* op +(T, T) -> T */ - /* op +(vec, vec) -> vec */ - /* op +(vec, T) -> vec */ - /* op +(T, vec) -> vec */ - /* op +(mat, mat) -> mat */ + /* op +(T, T) -> T */ + /* op +(vec, vec) -> vec */ + /* op +(vec, T) -> vec */ + /* op +(T, vec) -> vec */ + /* op +(mat, mat) -> mat */ /* num overloads */ 5, /* overloads */ &kOverloads[242], }, diff --git a/src/tint/resolver/intrinsic_table_test.cc b/src/tint/resolver/intrinsic_table_test.cc index 9301386903..02c97f7aac 100644 --- a/src/tint/resolver/intrinsic_table_test.cc +++ b/src/tint/resolver/intrinsic_table_test.cc @@ -886,20 +886,21 @@ INSTANTIATE_TEST_SUITE_P(AFloat_AInt, IntrinsicTableAbstractBinaryTest, testing::Values( // clang-format off // result | param lhs | param rhs | arg lhs | arg rhs -Case::Create(), -Case::Create(), -Case::Create(), -Case::Create() +Case::Create(), +Case::Create(), +Case::Create(), +Case::Create() )); // clang-format on -INSTANTIATE_TEST_SUITE_P(VecAFloat_VecAInt, - IntrinsicTableAbstractBinaryTest, - testing::Values( // clang-format off +INSTANTIATE_TEST_SUITE_P( + VecAFloat_VecAInt, + IntrinsicTableAbstractBinaryTest, + testing::Values( // clang-format off // result | param lhs | param rhs | arg lhs | arg rhs -Case::Create(), -Case::Create(), -Case::Create(), -Case::Create() +Case::Create(), +Case::Create(), +Case::Create(), +Case::Create() )); // clang-format on INSTANTIATE_TEST_SUITE_P(AFloat_f32, diff --git a/src/tint/writer/glsl/generator_impl_member_accessor_test.cc b/src/tint/writer/glsl/generator_impl_member_accessor_test.cc index bc9fafb56e..ba6dc43f4d 100644 --- a/src/tint/writer/glsl/generator_impl_member_accessor_test.cc +++ b/src/tint/writer/glsl/generator_impl_member_accessor_test.cc @@ -405,8 +405,11 @@ TEST_F(GlslGeneratorImplTest_MemberAccessor, }); SetupFunction(utils::Vector{ + Decl(Var("a", nullptr, Expr(2_i))), + Decl(Var("b", nullptr, Expr(4_i))), + Decl(Var("c", nullptr, Expr(3_i))), Decl(Var("x", nullptr, ast::StorageClass::kNone, - IndexAccessor(MemberAccessor("data", "a"), Sub(Add(2_i, 4_i), 3_i)))), + IndexAccessor(MemberAccessor("data", "a"), Sub(Add("a", "b"), "c")))), }); GeneratorImpl& gen = SanitizeAndBuild(); @@ -426,7 +429,10 @@ layout(binding = 0, std430) buffer Data_1 { int a[5]; } data; void tint_symbol() { - int x = data.a[((2 + 4) - 3)]; + int a = 2; + int b = 4; + int c = 3; + int x = data.a[((a + b) - c)]; } void main() { diff --git a/src/tint/writer/hlsl/generator_impl_member_accessor_test.cc b/src/tint/writer/hlsl/generator_impl_member_accessor_test.cc index 2cb8f71e6d..a0068b969a 100644 --- a/src/tint/writer/hlsl/generator_impl_member_accessor_test.cc +++ b/src/tint/writer/hlsl/generator_impl_member_accessor_test.cc @@ -418,8 +418,11 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, }); SetupFunction(utils::Vector{ + Decl(Var("a", nullptr, Expr(2_i))), + Decl(Var("b", nullptr, Expr(4_i))), + Decl(Var("c", nullptr, Expr(3_i))), Decl(Var("x", nullptr, ast::StorageClass::kNone, - IndexAccessor(MemberAccessor("data", "a"), Sub(Add(2_i, Expr(4_i)), Expr(3_i))))), + IndexAccessor(MemberAccessor("data", "a"), Sub(Add("a", "b"), "c")))), }); GeneratorImpl& gen = SanitizeAndBuild(); @@ -429,7 +432,10 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, R"(RWByteAddressBuffer data : register(u0, space1); void main() { - int x = asint(data.Load((4u + (4u * uint(((2 + 4) - 3)))))); + int a = 2; + int b = 4; + int c = 3; + int x = asint(data.Load((4u + (4u * uint(((a + b) - c)))))); return; } )"; diff --git a/src/tint/writer/spirv/builder_accessor_expression_test.cc b/src/tint/writer/spirv/builder_accessor_expression_test.cc index 0a30cbd49f..0c0dc3f124 100644 --- a/src/tint/writer/spirv/builder_accessor_expression_test.cc +++ b/src/tint/writer/spirv/builder_accessor_expression_test.cc @@ -162,10 +162,10 @@ OpReturn TEST_F(BuilderTest, Const_IndexAccessor_Vector2) { // let ary : vec3(1, 2, 3); - // var x = ary[1i + 2i]; + // var x = ary[1i + 1i]; auto* ary = Let("ary", nullptr, vec3(1_i, 2_i, 3_i)); - auto* x = Var("x", nullptr, IndexAccessor(ary, Add(1_i, 2_i))); + auto* x = Var("x", nullptr, IndexAccessor(ary, Add(1_i, 1_i))); WrapInFunction(ary, x); spirv::Builder& b = SanitizeAndBuild(); @@ -180,14 +180,14 @@ TEST_F(BuilderTest, Const_IndexAccessor_Vector2) { %8 = OpConstant %6 2 %9 = OpConstant %6 3 %10 = OpConstantComposite %5 %7 %8 %9 -%14 = OpTypePointer Function %6 -%15 = OpConstantNull %6 +%13 = OpTypePointer Function %6 +%14 = OpConstantNull %6 )"); - EXPECT_EQ(DumpInstructions(b.functions()[0].variables()), R"(%13 = OpVariable %14 Function %15 + EXPECT_EQ(DumpInstructions(b.functions()[0].variables()), R"(%12 = OpVariable %13 Function %14 )"); - EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"(%11 = OpIAdd %6 %7 %8 -%12 = OpVectorExtractDynamic %6 %10 %11 -OpStore %13 %12 + EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), + R"(%11 = OpCompositeExtract %6 %10 2 +OpStore %12 %11 OpReturn )"); @@ -196,10 +196,10 @@ OpReturn TEST_F(BuilderTest, Runtime_IndexAccessor_Vector2) { // var ary : vec3; - // var x = ary[1i + 2i]; + // var x = ary[1i + 1i]; auto* ary = Var("ary", ty.vec3()); - auto* x = Var("x", nullptr, IndexAccessor(ary, Add(1_i, 2_i))); + auto* x = Var("x", nullptr, IndexAccessor(ary, Add(1_i, 1_i))); WrapInFunction(ary, x); spirv::Builder& b = SanitizeAndBuild(); @@ -213,18 +213,16 @@ TEST_F(BuilderTest, Runtime_IndexAccessor_Vector2) { %6 = OpTypePointer Function %7 %9 = OpConstantNull %7 %10 = OpTypeInt 32 1 -%11 = OpConstant %10 1 -%12 = OpConstant %10 2 -%14 = OpTypePointer Function %8 -%18 = OpConstantNull %8 +%11 = OpConstant %10 2 +%12 = OpTypePointer Function %8 +%16 = OpConstantNull %8 )"); EXPECT_EQ(DumpInstructions(b.functions()[0].variables()), R"(%5 = OpVariable %6 Function %9 -%17 = OpVariable %14 Function %18 +%15 = OpVariable %12 Function %16 )"); - EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"(%13 = OpIAdd %10 %11 %12 -%15 = OpAccessChain %14 %5 %13 -%16 = OpLoad %8 %15 -OpStore %17 %16 + EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"(%13 = OpAccessChain %12 %5 %11 +%14 = OpLoad %8 %13 +OpStore %15 %14 OpReturn )"); diff --git a/src/tint/writer/spirv/builder_binary_expression_test.cc b/src/tint/writer/spirv/builder_binary_expression_test.cc index 9a2709e18c..922473eb43 100644 --- a/src/tint/writer/spirv/builder_binary_expression_test.cc +++ b/src/tint/writer/spirv/builder_binary_expression_test.cc @@ -1219,30 +1219,48 @@ namespace BinaryArithVectorScalar { enum class Type { f32, f16, i32, u32 }; static const ast::Expression* MakeVectorExpr(ProgramBuilder* builder, Type type) { + auto name = builder->Symbols().New(); switch (type) { case Type::f32: - return builder->vec3(1_f, 1_f, 1_f); + builder->GlobalVar(name, builder->ty.vec3(), builder->vec3(1_f, 1_f, 1_f), + ast::StorageClass::kPrivate); + break; case Type::f16: - return builder->vec3(1_h, 1_h, 1_h); + builder->GlobalVar(name, builder->ty.vec3(), builder->vec3(1_h, 1_h, 1_h), + ast::StorageClass::kPrivate); + break; case Type::i32: - return builder->vec3(1_i, 1_i, 1_i); + builder->GlobalVar(name, builder->ty.vec3(), builder->vec3(1_i, 1_i, 1_i), + ast::StorageClass::kPrivate); + break; case Type::u32: - return builder->vec3(1_u, 1_u, 1_u); + builder->GlobalVar(name, builder->ty.vec3(), builder->vec3(1_u, 1_u, 1_u), + ast::StorageClass::kPrivate); + break; } - return nullptr; + return builder->Expr(name); } static const ast::Expression* MakeScalarExpr(ProgramBuilder* builder, Type type) { + auto name = builder->Symbols().New(); switch (type) { case Type::f32: - return builder->Expr(1_f); + builder->GlobalVar(name, builder->ty.f32(), builder->Expr(1_f), + ast::StorageClass::kPrivate); + break; case Type::f16: - return builder->Expr(1_h); + builder->GlobalVar(name, builder->ty.f16(), builder->Expr(1_h), + ast::StorageClass::kPrivate); + break; case Type::i32: - return builder->Expr(1_i); + builder->GlobalVar(name, builder->ty.i32(), builder->Expr(1_i), + ast::StorageClass::kPrivate); + break; case Type::u32: - return builder->Expr(1_u); + builder->GlobalVar(name, builder->ty.u32(), builder->Expr(1_u), + ast::StorageClass::kPrivate); + break; } - return nullptr; + return builder->Expr(name); } static std::string OpTypeDecl(Type type) { switch (type) { @@ -1310,26 +1328,33 @@ TEST_P(BinaryArithVectorScalarTest, VectorScalar) { spirv::Builder& b = Build(); ASSERT_TRUE(b.Build()) << b.error(); - EXPECT_EQ(DumpBuilder(b), capability_decl + R"( OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %3 "test_function" -OpExecutionMode %3 LocalSize 1 1 1 -OpName %3 "test_function" -%2 = OpTypeVoid -%1 = OpTypeFunction %2 -%6 = )" + op_type_decl + R"( -%5 = OpTypeVector %6 3 -%7 = OpConstant %6 )" + constant_value + +OpEntryPoint GLCompute %11 "test_function" +OpExecutionMode %11 LocalSize 1 1 1 +OpName %5 "tint_symbol" +OpName %7 "tint_symbol_1" +OpName %11 "test_function" +%2 = )" + op_type_decl + R"( +%1 = OpTypeVector %2 3 +%3 = OpConstant %2 )" + constant_value + R"( -%8 = OpConstantComposite %5 %7 %7 %7 -%11 = OpTypePointer Function %5 -%12 = OpConstantNull %5 -%3 = OpFunction %2 None %1 -%4 = OpLabel -%10 = OpVariable %11 Function %12 -%13 = OpCompositeConstruct %5 %7 %7 %7 -%9 = )" + param.name + R"( %5 %8 %13 +%4 = OpConstantComposite %1 %3 %3 %3 +%6 = OpTypePointer Private %1 +%5 = OpVariable %6 Private %4 +%8 = OpTypePointer Private %2 +%7 = OpVariable %8 Private %3 +%10 = OpTypeVoid +%9 = OpTypeFunction %10 +%17 = OpTypePointer Function %1 +%18 = OpConstantNull %1 +%11 = OpFunction %10 None %9 +%12 = OpLabel +%16 = OpVariable %17 Function %18 +%13 = OpLoad %1 %5 +%14 = OpLoad %2 %7 +%19 = OpCompositeConstruct %1 %14 %14 %14 +%15 = )" + param.name + R"( %1 %13 %19 OpReturn OpFunctionEnd )"); @@ -1355,26 +1380,33 @@ TEST_P(BinaryArithVectorScalarTest, ScalarVector) { spirv::Builder& b = Build(); ASSERT_TRUE(b.Build()) << b.error(); - EXPECT_EQ(DumpBuilder(b), capability_decl + R"( OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %3 "test_function" -OpExecutionMode %3 LocalSize 1 1 1 -OpName %3 "test_function" -%2 = OpTypeVoid -%1 = OpTypeFunction %2 -%5 = )" + op_type_decl + R"( -%6 = OpConstant %5 )" + constant_value + +OpEntryPoint GLCompute %11 "test_function" +OpExecutionMode %11 LocalSize 1 1 1 +OpName %3 "tint_symbol" +OpName %7 "tint_symbol_1" +OpName %11 "test_function" +%1 = )" + op_type_decl + R"( +%2 = OpConstant %1 )" + constant_value + R"( -%7 = OpTypeVector %5 3 -%8 = OpConstantComposite %7 %6 %6 %6 -%11 = OpTypePointer Function %7 -%12 = OpConstantNull %7 -%3 = OpFunction %2 None %1 -%4 = OpLabel -%10 = OpVariable %11 Function %12 -%13 = OpCompositeConstruct %7 %6 %6 %6 -%9 = )" + param.name + R"( %7 %13 %8 +%4 = OpTypePointer Private %1 +%3 = OpVariable %4 Private %2 +%5 = OpTypeVector %1 3 +%6 = OpConstantComposite %5 %2 %2 %2 +%8 = OpTypePointer Private %5 +%7 = OpVariable %8 Private %6 +%10 = OpTypeVoid +%9 = OpTypeFunction %10 +%17 = OpTypePointer Function %5 +%18 = OpConstantNull %5 +%11 = OpFunction %10 None %9 +%12 = OpLabel +%16 = OpVariable %17 Function %18 +%13 = OpLoad %1 %3 +%14 = OpLoad %5 %7 +%19 = OpCompositeConstruct %5 %13 %13 %13 +%15 = )" + param.name + R"( %5 %19 %14 OpReturn OpFunctionEnd )"); @@ -1428,22 +1460,29 @@ TEST_P(BinaryArithVectorScalarMultiplyTest, VectorScalar) { spirv::Builder& b = Build(); ASSERT_TRUE(b.Build()) << b.error(); - EXPECT_EQ(DumpBuilder(b), capability_decl + R"( OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %3 "test_function" -OpExecutionMode %3 LocalSize 1 1 1 -OpName %3 "test_function" -%2 = OpTypeVoid -%1 = OpTypeFunction %2 -%6 = )" + op_type_decl + R"( -%5 = OpTypeVector %6 3 -%7 = OpConstant %6 )" + constant_value + +OpEntryPoint GLCompute %11 "test_function" +OpExecutionMode %11 LocalSize 1 1 1 +OpName %5 "tint_symbol" +OpName %7 "tint_symbol_1" +OpName %11 "test_function" +%2 = )" + op_type_decl + R"( +%1 = OpTypeVector %2 3 +%3 = OpConstant %2 )" + constant_value + R"( -%8 = OpConstantComposite %5 %7 %7 %7 -%3 = OpFunction %2 None %1 -%4 = OpLabel -%9 = OpVectorTimesScalar %5 %8 %7 +%4 = OpConstantComposite %1 %3 %3 %3 +%6 = OpTypePointer Private %1 +%5 = OpVariable %6 Private %4 +%8 = OpTypePointer Private %2 +%7 = OpVariable %8 Private %3 +%10 = OpTypeVoid +%9 = OpTypeFunction %10 +%11 = OpFunction %10 None %9 +%12 = OpLabel +%13 = OpLoad %1 %5 +%14 = OpLoad %2 %7 +%15 = OpVectorTimesScalar %1 %13 %14 OpReturn OpFunctionEnd )"); @@ -1469,22 +1508,29 @@ TEST_P(BinaryArithVectorScalarMultiplyTest, ScalarVector) { spirv::Builder& b = Build(); ASSERT_TRUE(b.Build()) << b.error(); - EXPECT_EQ(DumpBuilder(b), capability_decl + R"( OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %3 "test_function" -OpExecutionMode %3 LocalSize 1 1 1 -OpName %3 "test_function" -%2 = OpTypeVoid -%1 = OpTypeFunction %2 -%5 = )" + op_type_decl + R"( -%6 = OpConstant %5 )" + constant_value + +OpEntryPoint GLCompute %11 "test_function" +OpExecutionMode %11 LocalSize 1 1 1 +OpName %3 "tint_symbol" +OpName %7 "tint_symbol_1" +OpName %11 "test_function" +%1 = )" + op_type_decl + R"( +%2 = OpConstant %1 )" + constant_value + R"( -%7 = OpTypeVector %5 3 -%8 = OpConstantComposite %7 %6 %6 %6 -%3 = OpFunction %2 None %1 -%4 = OpLabel -%9 = OpVectorTimesScalar %7 %8 %6 +%4 = OpTypePointer Private %1 +%3 = OpVariable %4 Private %2 +%5 = OpTypeVector %1 3 +%6 = OpConstantComposite %5 %2 %2 %2 +%8 = OpTypePointer Private %5 +%7 = OpVariable %8 Private %6 +%10 = OpTypeVoid +%9 = OpTypeFunction %10 +%11 = OpFunction %10 None %9 +%12 = OpLabel +%13 = OpLoad %1 %3 +%14 = OpLoad %5 %7 +%15 = OpVectorTimesScalar %5 %14 %13 OpReturn OpFunctionEnd )"); @@ -1502,22 +1548,31 @@ namespace BinaryArithMatrixMatrix { enum class Type { f32, f16 }; static const ast::Expression* MakeMat3x4Expr(ProgramBuilder* builder, Type type) { + auto name = builder->Symbols().New(); switch (type) { case Type::f32: - return builder->mat3x4(); + builder->GlobalVar(name, builder->ty.mat3x4(), builder->mat3x4(), + ast::StorageClass::kPrivate); + break; case Type::f16: - return builder->mat3x4(); + builder->GlobalVar(name, builder->ty.mat3x4(), builder->mat3x4(), + ast::StorageClass::kPrivate); + break; } - return nullptr; + return builder->Expr(name); } static const ast::Expression* MakeMat4x3Expr(ProgramBuilder* builder, Type type) { + auto name = builder->Symbols().New(); switch (type) { case Type::f32: - return builder->mat4x3(); + builder->GlobalVar(name, builder->ty.mat4x3(), builder->mat4x3(), + ast::StorageClass::kPrivate); + break; case Type::f16: - return builder->mat4x3(); + builder->GlobalVar(name, builder->ty.mat4x3(), builder->mat4x3(), + ast::StorageClass::kPrivate); } - return nullptr; + return builder->Expr(name); } static std::string OpTypeDecl(Type type) { switch (type) { @@ -1567,30 +1622,36 @@ TEST_P(BinaryArithMatrixMatrix, AddOrSubtract) { spirv::Builder& b = Build(); ASSERT_TRUE(b.Build()) << b.error(); - EXPECT_EQ(DumpBuilder(b), capability_decl + R"( OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %3 "test_function" -OpExecutionMode %3 LocalSize 1 1 1 -OpName %3 "test_function" -%2 = OpTypeVoid -%1 = OpTypeFunction %2 -%7 = )" + op_type_decl + R"( -%6 = OpTypeVector %7 4 -%5 = OpTypeMatrix %6 3 -%8 = OpConstantNull %5 -%3 = OpFunction %2 None %1 -%4 = OpLabel -%10 = OpCompositeExtract %6 %8 0 -%11 = OpCompositeExtract %6 %8 0 -%12 = )" + param.name + R"( %6 %10 %11 -%13 = OpCompositeExtract %6 %8 1 -%14 = OpCompositeExtract %6 %8 1 -%15 = )" + param.name + R"( %6 %13 %14 -%16 = OpCompositeExtract %6 %8 2 -%17 = OpCompositeExtract %6 %8 2 -%18 = )" + param.name + R"( %6 %16 %17 -%19 = OpCompositeConstruct %5 %12 %15 %18 +OpEntryPoint GLCompute %10 "test_function" +OpExecutionMode %10 LocalSize 1 1 1 +OpName %5 "tint_symbol" +OpName %7 "tint_symbol_1" +OpName %10 "test_function" +%3 = )" + op_type_decl + R"( +%2 = OpTypeVector %3 4 +%1 = OpTypeMatrix %2 3 +%4 = OpConstantNull %1 +%6 = OpTypePointer Private %1 +%5 = OpVariable %6 Private %4 +%7 = OpVariable %6 Private %4 +%9 = OpTypeVoid +%8 = OpTypeFunction %9 +%10 = OpFunction %9 None %8 +%11 = OpLabel +%12 = OpLoad %1 %5 +%13 = OpLoad %1 %7 +%15 = OpCompositeExtract %2 %12 0 +%16 = OpCompositeExtract %2 %13 0 +%17 = )" + param.name + R"( %2 %15 %16 +%18 = OpCompositeExtract %2 %12 1 +%19 = OpCompositeExtract %2 %13 1 +%20 = )" + param.name + R"( %2 %18 %19 +%21 = OpCompositeExtract %2 %12 2 +%22 = OpCompositeExtract %2 %13 2 +%23 = )" + param.name + R"( %2 %21 %22 +%24 = OpCompositeConstruct %1 %17 %20 %23 OpReturn OpFunctionEnd )"); @@ -1624,25 +1685,32 @@ TEST_P(BinaryArithMatrixMatrixMultiply, Multiply) { spirv::Builder& b = Build(); ASSERT_TRUE(b.Build()) << b.error(); - EXPECT_EQ(DumpBuilder(b), capability_decl + R"( OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %3 "test_function" -OpExecutionMode %3 LocalSize 1 1 1 -OpName %3 "test_function" -%2 = OpTypeVoid -%1 = OpTypeFunction %2 -%7 = )" + op_type_decl + R"( -%6 = OpTypeVector %7 4 -%5 = OpTypeMatrix %6 3 -%8 = OpConstantNull %5 -%10 = OpTypeVector %7 3 -%9 = OpTypeMatrix %10 4 -%11 = OpConstantNull %9 -%13 = OpTypeMatrix %6 4 -%3 = OpFunction %2 None %1 -%4 = OpLabel -%12 = OpMatrixTimesMatrix %13 %8 %11 +OpEntryPoint GLCompute %14 "test_function" +OpExecutionMode %14 LocalSize 1 1 1 +OpName %5 "tint_symbol" +OpName %10 "tint_symbol_1" +OpName %14 "test_function" +%3 = )" + op_type_decl + R"( +%2 = OpTypeVector %3 4 +%1 = OpTypeMatrix %2 3 +%4 = OpConstantNull %1 +%6 = OpTypePointer Private %1 +%5 = OpVariable %6 Private %4 +%8 = OpTypeVector %3 3 +%7 = OpTypeMatrix %8 4 +%9 = OpConstantNull %7 +%11 = OpTypePointer Private %7 +%10 = OpVariable %11 Private %9 +%13 = OpTypeVoid +%12 = OpTypeFunction %13 +%19 = OpTypeMatrix %2 4 +%14 = OpFunction %13 None %12 +%15 = OpLabel +%16 = OpLoad %1 %5 +%17 = OpLoad %7 %10 +%18 = OpMatrixTimesMatrix %19 %16 %17 OpReturn OpFunctionEnd )"); diff --git a/src/tint/writer/spirv/builder_function_variable_test.cc b/src/tint/writer/spirv/builder_function_variable_test.cc index 4a7026a930..4045f4c6b0 100644 --- a/src/tint/writer/spirv/builder_function_variable_test.cc +++ b/src/tint/writer/spirv/builder_function_variable_test.cc @@ -73,32 +73,34 @@ TEST_F(BuilderTest, FunctionVar_WithConstantConstructor) { } TEST_F(BuilderTest, FunctionVar_WithNonConstantConstructor) { - auto* init = vec2(1_f, Add(3_f, 3_f)); + auto* a = Let("a", nullptr, Expr(3_f)); + auto* init = vec2(1_f, Add(Expr("a"), 3_f)); auto* v = Var("var", ty.vec2(), ast::StorageClass::kNone, init); - WrapInFunction(v); + WrapInFunction(a, v); spirv::Builder& b = Build(); b.push_function(Function{}); + EXPECT_TRUE(b.GenerateFunctionVariable(a)) << b.error(); EXPECT_TRUE(b.GenerateFunctionVariable(v)) << b.error(); ASSERT_FALSE(b.has_error()) << b.error(); EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %7 "var" )"); - EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32 -%1 = OpTypeVector %2 2 -%3 = OpConstant %2 1 -%4 = OpConstant %2 3 -%8 = OpTypePointer Function %1 -%9 = OpConstantNull %1 + EXPECT_EQ(DumpInstructions(b.types()), R"(%1 = OpTypeFloat 32 +%2 = OpConstant %1 3 +%3 = OpTypeVector %1 2 +%4 = OpConstant %1 1 +%8 = OpTypePointer Function %3 +%9 = OpConstantNull %3 )"); EXPECT_EQ(DumpInstructions(b.functions()[0].variables()), R"(%7 = OpVariable %8 Function %9 )"); EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), - R"(%5 = OpFAdd %2 %4 %4 -%6 = OpCompositeConstruct %1 %3 %5 + R"(%5 = OpFAdd %1 %2 %2 +%6 = OpCompositeConstruct %3 %4 %5 OpStore %7 %6 )"); } diff --git a/test/tint/expressions/binary/add/scalar-scalar/f16.wgsl.expected.dxc.hlsl b/test/tint/expressions/binary/add/scalar-scalar/f16.wgsl.expected.dxc.hlsl index 1547f328a6..14fbe55c12 100644 --- a/test/tint/expressions/binary/add/scalar-scalar/f16.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/binary/add/scalar-scalar/f16.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ [numthreads(1, 1, 1)] void f() { - const float16_t r = (float16_t(1.0h) + float16_t(2.0h)); + const float16_t r = float16_t(3.0h); return; } diff --git a/test/tint/expressions/binary/add/scalar-scalar/f16.wgsl.expected.glsl b/test/tint/expressions/binary/add/scalar-scalar/f16.wgsl.expected.glsl index 473a59328a..5cf03c78a7 100644 --- a/test/tint/expressions/binary/add/scalar-scalar/f16.wgsl.expected.glsl +++ b/test/tint/expressions/binary/add/scalar-scalar/f16.wgsl.expected.glsl @@ -2,7 +2,7 @@ #extension GL_AMD_gpu_shader_half_float : require void f() { - float16_t r = (1.0hf + 2.0hf); + float16_t r = 3.0hf; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; diff --git a/test/tint/expressions/binary/add/scalar-scalar/f32.wgsl.expected.dxc.hlsl b/test/tint/expressions/binary/add/scalar-scalar/f32.wgsl.expected.dxc.hlsl index 7d73fa9945..66a8434b2e 100644 --- a/test/tint/expressions/binary/add/scalar-scalar/f32.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/binary/add/scalar-scalar/f32.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ [numthreads(1, 1, 1)] void f() { - const float r = (1.0f + 2.0f); + const float r = 3.0f; return; } diff --git a/test/tint/expressions/binary/add/scalar-scalar/f32.wgsl.expected.fxc.hlsl b/test/tint/expressions/binary/add/scalar-scalar/f32.wgsl.expected.fxc.hlsl index 7d73fa9945..66a8434b2e 100644 --- a/test/tint/expressions/binary/add/scalar-scalar/f32.wgsl.expected.fxc.hlsl +++ b/test/tint/expressions/binary/add/scalar-scalar/f32.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ [numthreads(1, 1, 1)] void f() { - const float r = (1.0f + 2.0f); + const float r = 3.0f; return; } diff --git a/test/tint/expressions/binary/add/scalar-scalar/f32.wgsl.expected.glsl b/test/tint/expressions/binary/add/scalar-scalar/f32.wgsl.expected.glsl index f12c446992..75e8dd683e 100644 --- a/test/tint/expressions/binary/add/scalar-scalar/f32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/add/scalar-scalar/f32.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void f() { - float r = (1.0f + 2.0f); + float r = 3.0f; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; diff --git a/test/tint/expressions/binary/add/scalar-scalar/i32.wgsl.expected.dxc.hlsl b/test/tint/expressions/binary/add/scalar-scalar/i32.wgsl.expected.dxc.hlsl index 9a9dd1f034..6202d8b57b 100644 --- a/test/tint/expressions/binary/add/scalar-scalar/i32.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/binary/add/scalar-scalar/i32.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ [numthreads(1, 1, 1)] void f() { - const int r = (1 + 2); + const int r = 3; return; } diff --git a/test/tint/expressions/binary/add/scalar-scalar/i32.wgsl.expected.fxc.hlsl b/test/tint/expressions/binary/add/scalar-scalar/i32.wgsl.expected.fxc.hlsl index 9a9dd1f034..6202d8b57b 100644 --- a/test/tint/expressions/binary/add/scalar-scalar/i32.wgsl.expected.fxc.hlsl +++ b/test/tint/expressions/binary/add/scalar-scalar/i32.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ [numthreads(1, 1, 1)] void f() { - const int r = (1 + 2); + const int r = 3; return; } diff --git a/test/tint/expressions/binary/add/scalar-scalar/i32.wgsl.expected.glsl b/test/tint/expressions/binary/add/scalar-scalar/i32.wgsl.expected.glsl index 884b5ac6b9..aa5e335278 100644 --- a/test/tint/expressions/binary/add/scalar-scalar/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/add/scalar-scalar/i32.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void f() { - int r = (1 + 2); + int r = 3; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; diff --git a/test/tint/expressions/binary/add/scalar-scalar/u32.wgsl.expected.dxc.hlsl b/test/tint/expressions/binary/add/scalar-scalar/u32.wgsl.expected.dxc.hlsl index f540a8170e..8a5e6557bb 100644 --- a/test/tint/expressions/binary/add/scalar-scalar/u32.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/binary/add/scalar-scalar/u32.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ [numthreads(1, 1, 1)] void f() { - const uint r = (1u + 2u); + const uint r = 3u; return; } diff --git a/test/tint/expressions/binary/add/scalar-scalar/u32.wgsl.expected.fxc.hlsl b/test/tint/expressions/binary/add/scalar-scalar/u32.wgsl.expected.fxc.hlsl index f540a8170e..8a5e6557bb 100644 --- a/test/tint/expressions/binary/add/scalar-scalar/u32.wgsl.expected.fxc.hlsl +++ b/test/tint/expressions/binary/add/scalar-scalar/u32.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ [numthreads(1, 1, 1)] void f() { - const uint r = (1u + 2u); + const uint r = 3u; return; } diff --git a/test/tint/expressions/binary/add/scalar-scalar/u32.wgsl.expected.glsl b/test/tint/expressions/binary/add/scalar-scalar/u32.wgsl.expected.glsl index e5c3783a16..936c36da95 100644 --- a/test/tint/expressions/binary/add/scalar-scalar/u32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/add/scalar-scalar/u32.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void f() { - uint r = (1u + 2u); + uint r = 3u; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; diff --git a/test/tint/expressions/literals/intmin.wgsl.expected.dxc.hlsl b/test/tint/expressions/literals/intmin.wgsl.expected.dxc.hlsl index 90844e8065..eef47c82b5 100644 --- a/test/tint/expressions/literals/intmin.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/literals/intmin.wgsl.expected.dxc.hlsl @@ -6,6 +6,6 @@ void unused_entry_point() { int add_int_min_explicit() { int a = -2147483648; int b = (a + 1); - int c = (-2147483648 + 1); + int c = -2147483647; return c; } diff --git a/test/tint/expressions/literals/intmin.wgsl.expected.fxc.hlsl b/test/tint/expressions/literals/intmin.wgsl.expected.fxc.hlsl index 90844e8065..eef47c82b5 100644 --- a/test/tint/expressions/literals/intmin.wgsl.expected.fxc.hlsl +++ b/test/tint/expressions/literals/intmin.wgsl.expected.fxc.hlsl @@ -6,6 +6,6 @@ void unused_entry_point() { int add_int_min_explicit() { int a = -2147483648; int b = (a + 1); - int c = (-2147483648 + 1); + int c = -2147483647; return c; } diff --git a/test/tint/expressions/literals/intmin.wgsl.expected.glsl b/test/tint/expressions/literals/intmin.wgsl.expected.glsl index 06eeb7c4c4..410c45d2a7 100644 --- a/test/tint/expressions/literals/intmin.wgsl.expected.glsl +++ b/test/tint/expressions/literals/intmin.wgsl.expected.glsl @@ -7,7 +7,7 @@ void unused_entry_point() { int add_int_min_explicit() { int a = -2147483648; int b = (a + 1); - int c = (-2147483648 + 1); + int c = -2147483647; return c; } diff --git a/test/tint/expressions/literals/intmin.wgsl.expected.msl b/test/tint/expressions/literals/intmin.wgsl.expected.msl index c51ac85827..3910d7808b 100644 --- a/test/tint/expressions/literals/intmin.wgsl.expected.msl +++ b/test/tint/expressions/literals/intmin.wgsl.expected.msl @@ -4,7 +4,7 @@ using namespace metal; int add_int_min_explicit() { int a = (-2147483647 - 1); int b = as_type((as_type(a) + as_type(1))); - int c = as_type((as_type((-2147483647 - 1)) + as_type(1))); + int c = -2147483647; return c; } diff --git a/test/tint/expressions/literals/intmin.wgsl.expected.spvasm b/test/tint/expressions/literals/intmin.wgsl.expected.spvasm index b7eb829642..9ddfafeb10 100644 --- a/test/tint/expressions/literals/intmin.wgsl.expected.spvasm +++ b/test/tint/expressions/literals/intmin.wgsl.expected.spvasm @@ -20,6 +20,7 @@ %_ptr_Function_int = OpTypePointer Function %int %12 = OpConstantNull %int %int_1 = OpConstant %int 1 +%int_n2147483647 = OpConstant %int -2147483647 %unused_entry_point = OpFunction %void None %1 %4 = OpLabel OpReturn @@ -33,8 +34,7 @@ %13 = OpLoad %int %a %15 = OpIAdd %int %13 %int_1 OpStore %b %15 - %17 = OpIAdd %int %int_n2147483648 %int_1 - OpStore %c %17 + OpStore %c %int_n2147483647 %19 = OpLoad %int %c OpReturnValue %19 OpFunctionEnd diff --git a/test/tint/expressions/splat/expression/f16.wgsl.expected.dxc.hlsl b/test/tint/expressions/splat/expression/f16.wgsl.expected.dxc.hlsl index c56460a1d9..0635dcb2fd 100644 --- a/test/tint/expressions/splat/expression/f16.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/splat/expression/f16.wgsl.expected.dxc.hlsl @@ -4,7 +4,7 @@ void unused_entry_point() { } void f() { - vector v2 = vector(((float16_t(1.0h) + float16_t(2.0h))).xx); - vector v3 = vector(((float16_t(1.0h) + float16_t(2.0h))).xxx); - vector v4 = vector(((float16_t(1.0h) + float16_t(2.0h))).xxxx); + vector v2 = (float16_t(3.0h)).xx; + vector v3 = (float16_t(3.0h)).xxx; + vector v4 = (float16_t(3.0h)).xxxx; } diff --git a/test/tint/expressions/splat/expression/f16.wgsl.expected.glsl b/test/tint/expressions/splat/expression/f16.wgsl.expected.glsl index e8be274616..6b832129d6 100644 --- a/test/tint/expressions/splat/expression/f16.wgsl.expected.glsl +++ b/test/tint/expressions/splat/expression/f16.wgsl.expected.glsl @@ -6,8 +6,8 @@ void unused_entry_point() { return; } void f() { - f16vec2 v2 = f16vec2((1.0hf + 2.0hf)); - f16vec3 v3 = f16vec3((1.0hf + 2.0hf)); - f16vec4 v4 = f16vec4((1.0hf + 2.0hf)); + f16vec2 v2 = f16vec2(3.0hf); + f16vec3 v3 = f16vec3(3.0hf); + f16vec4 v4 = f16vec4(3.0hf); } diff --git a/test/tint/expressions/splat/expression/f16.wgsl.expected.msl b/test/tint/expressions/splat/expression/f16.wgsl.expected.msl index ef5613971d..6ce49cd97b 100644 --- a/test/tint/expressions/splat/expression/f16.wgsl.expected.msl +++ b/test/tint/expressions/splat/expression/f16.wgsl.expected.msl @@ -2,8 +2,8 @@ using namespace metal; void f() { - half2 v2 = half2((1.0h + 2.0h)); - half3 v3 = half3((1.0h + 2.0h)); - half4 v4 = half4((1.0h + 2.0h)); + half2 v2 = half2(3.0h); + half3 v3 = half3(3.0h); + half4 v4 = half4(3.0h); } diff --git a/test/tint/expressions/splat/expression/f16.wgsl.expected.spvasm b/test/tint/expressions/splat/expression/f16.wgsl.expected.spvasm index b5b102df4f..629dfca5fa 100644 --- a/test/tint/expressions/splat/expression/f16.wgsl.expected.spvasm +++ b/test/tint/expressions/splat/expression/f16.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 28 +; Bound: 24 ; Schema: 0 OpCapability Shader OpCapability Float16 @@ -20,33 +20,29 @@ %1 = OpTypeFunction %void %half = OpTypeFloat 16 %v2half = OpTypeVector %half 2 -%half_0x1p_0 = OpConstant %half 0x1p+0 -%half_0x1p_1 = OpConstant %half 0x1p+1 +%half_0x1_8p_1 = OpConstant %half 0x1.8p+1 + %10 = OpConstantComposite %v2half %half_0x1_8p_1 %half_0x1_8p_1 %_ptr_Function_v2half = OpTypePointer Function %v2half - %15 = OpConstantNull %v2half + %13 = OpConstantNull %v2half %v3half = OpTypeVector %half 3 + %15 = OpConstantComposite %v3half %half_0x1_8p_1 %half_0x1_8p_1 %half_0x1_8p_1 %_ptr_Function_v3half = OpTypePointer Function %v3half - %21 = OpConstantNull %v3half + %18 = OpConstantNull %v3half %v4half = OpTypeVector %half 4 + %20 = OpConstantComposite %v4half %half_0x1_8p_1 %half_0x1_8p_1 %half_0x1_8p_1 %half_0x1_8p_1 %_ptr_Function_v4half = OpTypePointer Function %v4half - %27 = OpConstantNull %v4half + %23 = OpConstantNull %v4half %unused_entry_point = OpFunction %void None %1 %4 = OpLabel OpReturn OpFunctionEnd %f = OpFunction %void None %1 %6 = OpLabel - %v2 = OpVariable %_ptr_Function_v2half Function %15 - %v3 = OpVariable %_ptr_Function_v3half Function %21 - %v4 = OpVariable %_ptr_Function_v4half Function %27 - %11 = OpFAdd %half %half_0x1p_0 %half_0x1p_1 - %12 = OpCompositeConstruct %v2half %11 %11 - OpStore %v2 %12 - %17 = OpFAdd %half %half_0x1p_0 %half_0x1p_1 - %18 = OpCompositeConstruct %v3half %17 %17 %17 - OpStore %v3 %18 - %23 = OpFAdd %half %half_0x1p_0 %half_0x1p_1 - %24 = OpCompositeConstruct %v4half %23 %23 %23 %23 - OpStore %v4 %24 + %v2 = OpVariable %_ptr_Function_v2half Function %13 + %v3 = OpVariable %_ptr_Function_v3half Function %18 + %v4 = OpVariable %_ptr_Function_v4half Function %23 + OpStore %v2 %10 + OpStore %v3 %15 + OpStore %v4 %20 OpReturn OpFunctionEnd diff --git a/test/tint/expressions/splat/expression/f32.wgsl.expected.dxc.hlsl b/test/tint/expressions/splat/expression/f32.wgsl.expected.dxc.hlsl index 9ed6e5ab17..399b318407 100644 --- a/test/tint/expressions/splat/expression/f32.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/splat/expression/f32.wgsl.expected.dxc.hlsl @@ -4,7 +4,7 @@ void unused_entry_point() { } void f() { - float2 v2 = float2(((1.0f + 2.0f)).xx); - float3 v3 = float3(((1.0f + 2.0f)).xxx); - float4 v4 = float4(((1.0f + 2.0f)).xxxx); + float2 v2 = (3.0f).xx; + float3 v3 = (3.0f).xxx; + float4 v4 = (3.0f).xxxx; } diff --git a/test/tint/expressions/splat/expression/f32.wgsl.expected.fxc.hlsl b/test/tint/expressions/splat/expression/f32.wgsl.expected.fxc.hlsl index 9ed6e5ab17..399b318407 100644 --- a/test/tint/expressions/splat/expression/f32.wgsl.expected.fxc.hlsl +++ b/test/tint/expressions/splat/expression/f32.wgsl.expected.fxc.hlsl @@ -4,7 +4,7 @@ void unused_entry_point() { } void f() { - float2 v2 = float2(((1.0f + 2.0f)).xx); - float3 v3 = float3(((1.0f + 2.0f)).xxx); - float4 v4 = float4(((1.0f + 2.0f)).xxxx); + float2 v2 = (3.0f).xx; + float3 v3 = (3.0f).xxx; + float4 v4 = (3.0f).xxxx; } diff --git a/test/tint/expressions/splat/expression/f32.wgsl.expected.glsl b/test/tint/expressions/splat/expression/f32.wgsl.expected.glsl index 2efc43d677..8952aadc5d 100644 --- a/test/tint/expressions/splat/expression/f32.wgsl.expected.glsl +++ b/test/tint/expressions/splat/expression/f32.wgsl.expected.glsl @@ -5,8 +5,8 @@ void unused_entry_point() { return; } void f() { - vec2 v2 = vec2((1.0f + 2.0f)); - vec3 v3 = vec3((1.0f + 2.0f)); - vec4 v4 = vec4((1.0f + 2.0f)); + vec2 v2 = vec2(3.0f); + vec3 v3 = vec3(3.0f); + vec4 v4 = vec4(3.0f); } diff --git a/test/tint/expressions/splat/expression/f32.wgsl.expected.msl b/test/tint/expressions/splat/expression/f32.wgsl.expected.msl index 9dd8768fb6..691c7e399d 100644 --- a/test/tint/expressions/splat/expression/f32.wgsl.expected.msl +++ b/test/tint/expressions/splat/expression/f32.wgsl.expected.msl @@ -2,8 +2,8 @@ using namespace metal; void f() { - float2 v2 = float2((1.0f + 2.0f)); - float3 v3 = float3((1.0f + 2.0f)); - float4 v4 = float4((1.0f + 2.0f)); + float2 v2 = float2(3.0f); + float3 v3 = float3(3.0f); + float4 v4 = float4(3.0f); } diff --git a/test/tint/expressions/splat/expression/f32.wgsl.expected.spvasm b/test/tint/expressions/splat/expression/f32.wgsl.expected.spvasm index 286c6bace5..7e44ab8340 100644 --- a/test/tint/expressions/splat/expression/f32.wgsl.expected.spvasm +++ b/test/tint/expressions/splat/expression/f32.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 28 +; Bound: 24 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -16,33 +16,29 @@ %1 = OpTypeFunction %void %float = OpTypeFloat 32 %v2float = OpTypeVector %float 2 - %float_1 = OpConstant %float 1 - %float_2 = OpConstant %float 2 + %float_3 = OpConstant %float 3 + %10 = OpConstantComposite %v2float %float_3 %float_3 %_ptr_Function_v2float = OpTypePointer Function %v2float - %15 = OpConstantNull %v2float + %13 = OpConstantNull %v2float %v3float = OpTypeVector %float 3 + %15 = OpConstantComposite %v3float %float_3 %float_3 %float_3 %_ptr_Function_v3float = OpTypePointer Function %v3float - %21 = OpConstantNull %v3float + %18 = OpConstantNull %v3float %v4float = OpTypeVector %float 4 + %20 = OpConstantComposite %v4float %float_3 %float_3 %float_3 %float_3 %_ptr_Function_v4float = OpTypePointer Function %v4float - %27 = OpConstantNull %v4float + %23 = OpConstantNull %v4float %unused_entry_point = OpFunction %void None %1 %4 = OpLabel OpReturn OpFunctionEnd %f = OpFunction %void None %1 %6 = OpLabel - %v2 = OpVariable %_ptr_Function_v2float Function %15 - %v3 = OpVariable %_ptr_Function_v3float Function %21 - %v4 = OpVariable %_ptr_Function_v4float Function %27 - %11 = OpFAdd %float %float_1 %float_2 - %12 = OpCompositeConstruct %v2float %11 %11 - OpStore %v2 %12 - %17 = OpFAdd %float %float_1 %float_2 - %18 = OpCompositeConstruct %v3float %17 %17 %17 - OpStore %v3 %18 - %23 = OpFAdd %float %float_1 %float_2 - %24 = OpCompositeConstruct %v4float %23 %23 %23 %23 - OpStore %v4 %24 + %v2 = OpVariable %_ptr_Function_v2float Function %13 + %v3 = OpVariable %_ptr_Function_v3float Function %18 + %v4 = OpVariable %_ptr_Function_v4float Function %23 + OpStore %v2 %10 + OpStore %v3 %15 + OpStore %v4 %20 OpReturn OpFunctionEnd diff --git a/test/tint/expressions/splat/expression/i32.wgsl.expected.dxc.hlsl b/test/tint/expressions/splat/expression/i32.wgsl.expected.dxc.hlsl index 1a1fa76f6a..21fee65307 100644 --- a/test/tint/expressions/splat/expression/i32.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/splat/expression/i32.wgsl.expected.dxc.hlsl @@ -4,7 +4,7 @@ void unused_entry_point() { } void f() { - int2 v2 = int2(((1 + 2)).xx); - int3 v3 = int3(((1 + 2)).xxx); - int4 v4 = int4(((1 + 2)).xxxx); + int2 v2 = (3).xx; + int3 v3 = (3).xxx; + int4 v4 = (3).xxxx; } diff --git a/test/tint/expressions/splat/expression/i32.wgsl.expected.fxc.hlsl b/test/tint/expressions/splat/expression/i32.wgsl.expected.fxc.hlsl index 1a1fa76f6a..21fee65307 100644 --- a/test/tint/expressions/splat/expression/i32.wgsl.expected.fxc.hlsl +++ b/test/tint/expressions/splat/expression/i32.wgsl.expected.fxc.hlsl @@ -4,7 +4,7 @@ void unused_entry_point() { } void f() { - int2 v2 = int2(((1 + 2)).xx); - int3 v3 = int3(((1 + 2)).xxx); - int4 v4 = int4(((1 + 2)).xxxx); + int2 v2 = (3).xx; + int3 v3 = (3).xxx; + int4 v4 = (3).xxxx; } diff --git a/test/tint/expressions/splat/expression/i32.wgsl.expected.glsl b/test/tint/expressions/splat/expression/i32.wgsl.expected.glsl index aec2f1dc24..3e05824b61 100644 --- a/test/tint/expressions/splat/expression/i32.wgsl.expected.glsl +++ b/test/tint/expressions/splat/expression/i32.wgsl.expected.glsl @@ -5,8 +5,8 @@ void unused_entry_point() { return; } void f() { - ivec2 v2 = ivec2((1 + 2)); - ivec3 v3 = ivec3((1 + 2)); - ivec4 v4 = ivec4((1 + 2)); + ivec2 v2 = ivec2(3); + ivec3 v3 = ivec3(3); + ivec4 v4 = ivec4(3); } diff --git a/test/tint/expressions/splat/expression/i32.wgsl.expected.msl b/test/tint/expressions/splat/expression/i32.wgsl.expected.msl index afbc9b28ba..9fbac03820 100644 --- a/test/tint/expressions/splat/expression/i32.wgsl.expected.msl +++ b/test/tint/expressions/splat/expression/i32.wgsl.expected.msl @@ -2,8 +2,8 @@ using namespace metal; void f() { - int2 v2 = int2(as_type((as_type(1) + as_type(2)))); - int3 v3 = int3(as_type((as_type(1) + as_type(2)))); - int4 v4 = int4(as_type((as_type(1) + as_type(2)))); + int2 v2 = int2(3); + int3 v3 = int3(3); + int4 v4 = int4(3); } diff --git a/test/tint/expressions/splat/expression/i32.wgsl.expected.spvasm b/test/tint/expressions/splat/expression/i32.wgsl.expected.spvasm index 83c14c2da8..a6e58e03ad 100644 --- a/test/tint/expressions/splat/expression/i32.wgsl.expected.spvasm +++ b/test/tint/expressions/splat/expression/i32.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 28 +; Bound: 24 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -16,33 +16,29 @@ %1 = OpTypeFunction %void %int = OpTypeInt 32 1 %v2int = OpTypeVector %int 2 - %int_1 = OpConstant %int 1 - %int_2 = OpConstant %int 2 + %int_3 = OpConstant %int 3 + %10 = OpConstantComposite %v2int %int_3 %int_3 %_ptr_Function_v2int = OpTypePointer Function %v2int - %15 = OpConstantNull %v2int + %13 = OpConstantNull %v2int %v3int = OpTypeVector %int 3 + %15 = OpConstantComposite %v3int %int_3 %int_3 %int_3 %_ptr_Function_v3int = OpTypePointer Function %v3int - %21 = OpConstantNull %v3int + %18 = OpConstantNull %v3int %v4int = OpTypeVector %int 4 + %20 = OpConstantComposite %v4int %int_3 %int_3 %int_3 %int_3 %_ptr_Function_v4int = OpTypePointer Function %v4int - %27 = OpConstantNull %v4int + %23 = OpConstantNull %v4int %unused_entry_point = OpFunction %void None %1 %4 = OpLabel OpReturn OpFunctionEnd %f = OpFunction %void None %1 %6 = OpLabel - %v2 = OpVariable %_ptr_Function_v2int Function %15 - %v3 = OpVariable %_ptr_Function_v3int Function %21 - %v4 = OpVariable %_ptr_Function_v4int Function %27 - %11 = OpIAdd %int %int_1 %int_2 - %12 = OpCompositeConstruct %v2int %11 %11 - OpStore %v2 %12 - %17 = OpIAdd %int %int_1 %int_2 - %18 = OpCompositeConstruct %v3int %17 %17 %17 - OpStore %v3 %18 - %23 = OpIAdd %int %int_1 %int_2 - %24 = OpCompositeConstruct %v4int %23 %23 %23 %23 - OpStore %v4 %24 + %v2 = OpVariable %_ptr_Function_v2int Function %13 + %v3 = OpVariable %_ptr_Function_v3int Function %18 + %v4 = OpVariable %_ptr_Function_v4int Function %23 + OpStore %v2 %10 + OpStore %v3 %15 + OpStore %v4 %20 OpReturn OpFunctionEnd diff --git a/test/tint/expressions/splat/expression/u32.wgsl.expected.dxc.hlsl b/test/tint/expressions/splat/expression/u32.wgsl.expected.dxc.hlsl index afbc8e2e88..a1689f7263 100644 --- a/test/tint/expressions/splat/expression/u32.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/splat/expression/u32.wgsl.expected.dxc.hlsl @@ -4,7 +4,7 @@ void unused_entry_point() { } void f() { - uint2 v2 = uint2(((1u + 2u)).xx); - uint3 v3 = uint3(((1u + 2u)).xxx); - uint4 v4 = uint4(((1u + 2u)).xxxx); + uint2 v2 = (3u).xx; + uint3 v3 = (3u).xxx; + uint4 v4 = (3u).xxxx; } diff --git a/test/tint/expressions/splat/expression/u32.wgsl.expected.fxc.hlsl b/test/tint/expressions/splat/expression/u32.wgsl.expected.fxc.hlsl index afbc8e2e88..a1689f7263 100644 --- a/test/tint/expressions/splat/expression/u32.wgsl.expected.fxc.hlsl +++ b/test/tint/expressions/splat/expression/u32.wgsl.expected.fxc.hlsl @@ -4,7 +4,7 @@ void unused_entry_point() { } void f() { - uint2 v2 = uint2(((1u + 2u)).xx); - uint3 v3 = uint3(((1u + 2u)).xxx); - uint4 v4 = uint4(((1u + 2u)).xxxx); + uint2 v2 = (3u).xx; + uint3 v3 = (3u).xxx; + uint4 v4 = (3u).xxxx; } diff --git a/test/tint/expressions/splat/expression/u32.wgsl.expected.glsl b/test/tint/expressions/splat/expression/u32.wgsl.expected.glsl index b88947064f..004883ea02 100644 --- a/test/tint/expressions/splat/expression/u32.wgsl.expected.glsl +++ b/test/tint/expressions/splat/expression/u32.wgsl.expected.glsl @@ -5,8 +5,8 @@ void unused_entry_point() { return; } void f() { - uvec2 v2 = uvec2((1u + 2u)); - uvec3 v3 = uvec3((1u + 2u)); - uvec4 v4 = uvec4((1u + 2u)); + uvec2 v2 = uvec2(3u); + uvec3 v3 = uvec3(3u); + uvec4 v4 = uvec4(3u); } diff --git a/test/tint/expressions/splat/expression/u32.wgsl.expected.msl b/test/tint/expressions/splat/expression/u32.wgsl.expected.msl index 0bec34dd33..1d35ae0658 100644 --- a/test/tint/expressions/splat/expression/u32.wgsl.expected.msl +++ b/test/tint/expressions/splat/expression/u32.wgsl.expected.msl @@ -2,8 +2,8 @@ using namespace metal; void f() { - uint2 v2 = uint2((1u + 2u)); - uint3 v3 = uint3((1u + 2u)); - uint4 v4 = uint4((1u + 2u)); + uint2 v2 = uint2(3u); + uint3 v3 = uint3(3u); + uint4 v4 = uint4(3u); } diff --git a/test/tint/expressions/splat/expression/u32.wgsl.expected.spvasm b/test/tint/expressions/splat/expression/u32.wgsl.expected.spvasm index 209c60ed3e..459d127a0f 100644 --- a/test/tint/expressions/splat/expression/u32.wgsl.expected.spvasm +++ b/test/tint/expressions/splat/expression/u32.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 28 +; Bound: 24 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -16,33 +16,29 @@ %1 = OpTypeFunction %void %uint = OpTypeInt 32 0 %v2uint = OpTypeVector %uint 2 - %uint_1 = OpConstant %uint 1 - %uint_2 = OpConstant %uint 2 + %uint_3 = OpConstant %uint 3 + %10 = OpConstantComposite %v2uint %uint_3 %uint_3 %_ptr_Function_v2uint = OpTypePointer Function %v2uint - %15 = OpConstantNull %v2uint + %13 = OpConstantNull %v2uint %v3uint = OpTypeVector %uint 3 + %15 = OpConstantComposite %v3uint %uint_3 %uint_3 %uint_3 %_ptr_Function_v3uint = OpTypePointer Function %v3uint - %21 = OpConstantNull %v3uint + %18 = OpConstantNull %v3uint %v4uint = OpTypeVector %uint 4 + %20 = OpConstantComposite %v4uint %uint_3 %uint_3 %uint_3 %uint_3 %_ptr_Function_v4uint = OpTypePointer Function %v4uint - %27 = OpConstantNull %v4uint + %23 = OpConstantNull %v4uint %unused_entry_point = OpFunction %void None %1 %4 = OpLabel OpReturn OpFunctionEnd %f = OpFunction %void None %1 %6 = OpLabel - %v2 = OpVariable %_ptr_Function_v2uint Function %15 - %v3 = OpVariable %_ptr_Function_v3uint Function %21 - %v4 = OpVariable %_ptr_Function_v4uint Function %27 - %11 = OpIAdd %uint %uint_1 %uint_2 - %12 = OpCompositeConstruct %v2uint %11 %11 - OpStore %v2 %12 - %17 = OpIAdd %uint %uint_1 %uint_2 - %18 = OpCompositeConstruct %v3uint %17 %17 %17 - OpStore %v3 %18 - %23 = OpIAdd %uint %uint_1 %uint_2 - %24 = OpCompositeConstruct %v4uint %23 %23 %23 %23 - OpStore %v4 %24 + %v2 = OpVariable %_ptr_Function_v2uint Function %13 + %v3 = OpVariable %_ptr_Function_v3uint Function %18 + %v4 = OpVariable %_ptr_Function_v4uint Function %23 + OpStore %v2 %10 + OpStore %v3 %15 + OpStore %v4 %20 OpReturn OpFunctionEnd diff --git a/test/tint/expressions/splat/var/f16.wgsl.expected.dxc.hlsl b/test/tint/expressions/splat/var/f16.wgsl.expected.dxc.hlsl index d02707aa7a..6b06f88b7f 100644 --- a/test/tint/expressions/splat/var/f16.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/splat/var/f16.wgsl.expected.dxc.hlsl @@ -4,7 +4,7 @@ void unused_entry_point() { } void f() { - float16_t v = (float16_t(1.0h) + float16_t(2.0h)); + float16_t v = float16_t(3.0h); vector v2 = vector((v).xx); vector v3 = vector((v).xxx); vector v4 = vector((v).xxxx); diff --git a/test/tint/expressions/splat/var/f16.wgsl.expected.glsl b/test/tint/expressions/splat/var/f16.wgsl.expected.glsl index 9c28ead0a1..90ac38564e 100644 --- a/test/tint/expressions/splat/var/f16.wgsl.expected.glsl +++ b/test/tint/expressions/splat/var/f16.wgsl.expected.glsl @@ -6,7 +6,7 @@ void unused_entry_point() { return; } void f() { - float16_t v = (1.0hf + 2.0hf); + float16_t v = 3.0hf; f16vec2 v2 = f16vec2(v); f16vec3 v3 = f16vec3(v); f16vec4 v4 = f16vec4(v); diff --git a/test/tint/expressions/splat/var/f16.wgsl.expected.msl b/test/tint/expressions/splat/var/f16.wgsl.expected.msl index 054066e9d1..dbb362ecf1 100644 --- a/test/tint/expressions/splat/var/f16.wgsl.expected.msl +++ b/test/tint/expressions/splat/var/f16.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void f() { - half v = (1.0h + 2.0h); + half v = 3.0h; half2 v2 = half2(v); half3 v3 = half3(v); half4 v4 = half4(v); diff --git a/test/tint/expressions/splat/var/f16.wgsl.expected.spvasm b/test/tint/expressions/splat/var/f16.wgsl.expected.spvasm index 22e1b85200..e10ce9922d 100644 --- a/test/tint/expressions/splat/var/f16.wgsl.expected.spvasm +++ b/test/tint/expressions/splat/var/f16.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 32 +; Bound: 30 ; Schema: 0 OpCapability Shader OpCapability Float16 @@ -20,39 +20,37 @@ %void = OpTypeVoid %1 = OpTypeFunction %void %half = OpTypeFloat 16 -%half_0x1p_0 = OpConstant %half 0x1p+0 -%half_0x1p_1 = OpConstant %half 0x1p+1 +%half_0x1_8p_1 = OpConstant %half 0x1.8p+1 %_ptr_Function_half = OpTypePointer Function %half - %13 = OpConstantNull %half + %11 = OpConstantNull %half %v2half = OpTypeVector %half 2 %_ptr_Function_v2half = OpTypePointer Function %v2half - %19 = OpConstantNull %v2half + %17 = OpConstantNull %v2half %v3half = OpTypeVector %half 3 %_ptr_Function_v3half = OpTypePointer Function %v3half - %25 = OpConstantNull %v3half + %23 = OpConstantNull %v3half %v4half = OpTypeVector %half 4 %_ptr_Function_v4half = OpTypePointer Function %v4half - %31 = OpConstantNull %v4half + %29 = OpConstantNull %v4half %unused_entry_point = OpFunction %void None %1 %4 = OpLabel OpReturn OpFunctionEnd %f = OpFunction %void None %1 %6 = OpLabel - %v = OpVariable %_ptr_Function_half Function %13 - %v2 = OpVariable %_ptr_Function_v2half Function %19 - %v3 = OpVariable %_ptr_Function_v3half Function %25 - %v4 = OpVariable %_ptr_Function_v4half Function %31 - %10 = OpFAdd %half %half_0x1p_0 %half_0x1p_1 - OpStore %v %10 - %15 = OpLoad %half %v - %16 = OpCompositeConstruct %v2half %15 %15 - OpStore %v2 %16 - %21 = OpLoad %half %v - %22 = OpCompositeConstruct %v3half %21 %21 %21 - OpStore %v3 %22 - %27 = OpLoad %half %v - %28 = OpCompositeConstruct %v4half %27 %27 %27 %27 - OpStore %v4 %28 + %v = OpVariable %_ptr_Function_half Function %11 + %v2 = OpVariable %_ptr_Function_v2half Function %17 + %v3 = OpVariable %_ptr_Function_v3half Function %23 + %v4 = OpVariable %_ptr_Function_v4half Function %29 + OpStore %v %half_0x1_8p_1 + %13 = OpLoad %half %v + %14 = OpCompositeConstruct %v2half %13 %13 + OpStore %v2 %14 + %19 = OpLoad %half %v + %20 = OpCompositeConstruct %v3half %19 %19 %19 + OpStore %v3 %20 + %25 = OpLoad %half %v + %26 = OpCompositeConstruct %v4half %25 %25 %25 %25 + OpStore %v4 %26 OpReturn OpFunctionEnd diff --git a/test/tint/expressions/splat/var/f32.wgsl.expected.dxc.hlsl b/test/tint/expressions/splat/var/f32.wgsl.expected.dxc.hlsl index 00091d7f6e..1f921ec9ef 100644 --- a/test/tint/expressions/splat/var/f32.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/splat/var/f32.wgsl.expected.dxc.hlsl @@ -4,7 +4,7 @@ void unused_entry_point() { } void f() { - float v = (1.0f + 2.0f); + float v = 3.0f; float2 v2 = float2((v).xx); float3 v3 = float3((v).xxx); float4 v4 = float4((v).xxxx); diff --git a/test/tint/expressions/splat/var/f32.wgsl.expected.fxc.hlsl b/test/tint/expressions/splat/var/f32.wgsl.expected.fxc.hlsl index 00091d7f6e..1f921ec9ef 100644 --- a/test/tint/expressions/splat/var/f32.wgsl.expected.fxc.hlsl +++ b/test/tint/expressions/splat/var/f32.wgsl.expected.fxc.hlsl @@ -4,7 +4,7 @@ void unused_entry_point() { } void f() { - float v = (1.0f + 2.0f); + float v = 3.0f; float2 v2 = float2((v).xx); float3 v3 = float3((v).xxx); float4 v4 = float4((v).xxxx); diff --git a/test/tint/expressions/splat/var/f32.wgsl.expected.glsl b/test/tint/expressions/splat/var/f32.wgsl.expected.glsl index fc53821972..3d79f3eede 100644 --- a/test/tint/expressions/splat/var/f32.wgsl.expected.glsl +++ b/test/tint/expressions/splat/var/f32.wgsl.expected.glsl @@ -5,7 +5,7 @@ void unused_entry_point() { return; } void f() { - float v = (1.0f + 2.0f); + float v = 3.0f; vec2 v2 = vec2(v); vec3 v3 = vec3(v); vec4 v4 = vec4(v); diff --git a/test/tint/expressions/splat/var/f32.wgsl.expected.msl b/test/tint/expressions/splat/var/f32.wgsl.expected.msl index 101d125c0d..4d66e56a07 100644 --- a/test/tint/expressions/splat/var/f32.wgsl.expected.msl +++ b/test/tint/expressions/splat/var/f32.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void f() { - float v = (1.0f + 2.0f); + float v = 3.0f; float2 v2 = float2(v); float3 v3 = float3(v); float4 v4 = float4(v); diff --git a/test/tint/expressions/splat/var/f32.wgsl.expected.spvasm b/test/tint/expressions/splat/var/f32.wgsl.expected.spvasm index 5d45b4a412..73d8a78b08 100644 --- a/test/tint/expressions/splat/var/f32.wgsl.expected.spvasm +++ b/test/tint/expressions/splat/var/f32.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 32 +; Bound: 30 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -16,39 +16,37 @@ %void = OpTypeVoid %1 = OpTypeFunction %void %float = OpTypeFloat 32 - %float_1 = OpConstant %float 1 - %float_2 = OpConstant %float 2 + %float_3 = OpConstant %float 3 %_ptr_Function_float = OpTypePointer Function %float - %13 = OpConstantNull %float + %11 = OpConstantNull %float %v2float = OpTypeVector %float 2 %_ptr_Function_v2float = OpTypePointer Function %v2float - %19 = OpConstantNull %v2float + %17 = OpConstantNull %v2float %v3float = OpTypeVector %float 3 %_ptr_Function_v3float = OpTypePointer Function %v3float - %25 = OpConstantNull %v3float + %23 = OpConstantNull %v3float %v4float = OpTypeVector %float 4 %_ptr_Function_v4float = OpTypePointer Function %v4float - %31 = OpConstantNull %v4float + %29 = OpConstantNull %v4float %unused_entry_point = OpFunction %void None %1 %4 = OpLabel OpReturn OpFunctionEnd %f = OpFunction %void None %1 %6 = OpLabel - %v = OpVariable %_ptr_Function_float Function %13 - %v2 = OpVariable %_ptr_Function_v2float Function %19 - %v3 = OpVariable %_ptr_Function_v3float Function %25 - %v4 = OpVariable %_ptr_Function_v4float Function %31 - %10 = OpFAdd %float %float_1 %float_2 - OpStore %v %10 - %15 = OpLoad %float %v - %16 = OpCompositeConstruct %v2float %15 %15 - OpStore %v2 %16 - %21 = OpLoad %float %v - %22 = OpCompositeConstruct %v3float %21 %21 %21 - OpStore %v3 %22 - %27 = OpLoad %float %v - %28 = OpCompositeConstruct %v4float %27 %27 %27 %27 - OpStore %v4 %28 + %v = OpVariable %_ptr_Function_float Function %11 + %v2 = OpVariable %_ptr_Function_v2float Function %17 + %v3 = OpVariable %_ptr_Function_v3float Function %23 + %v4 = OpVariable %_ptr_Function_v4float Function %29 + OpStore %v %float_3 + %13 = OpLoad %float %v + %14 = OpCompositeConstruct %v2float %13 %13 + OpStore %v2 %14 + %19 = OpLoad %float %v + %20 = OpCompositeConstruct %v3float %19 %19 %19 + OpStore %v3 %20 + %25 = OpLoad %float %v + %26 = OpCompositeConstruct %v4float %25 %25 %25 %25 + OpStore %v4 %26 OpReturn OpFunctionEnd diff --git a/test/tint/expressions/splat/var/i32.wgsl.expected.dxc.hlsl b/test/tint/expressions/splat/var/i32.wgsl.expected.dxc.hlsl index c9905a8e6b..d0b1d2b38a 100644 --- a/test/tint/expressions/splat/var/i32.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/splat/var/i32.wgsl.expected.dxc.hlsl @@ -4,7 +4,7 @@ void unused_entry_point() { } void f() { - int v = (1 + 2); + int v = 3; int2 v2 = int2((v).xx); int3 v3 = int3((v).xxx); int4 v4 = int4((v).xxxx); diff --git a/test/tint/expressions/splat/var/i32.wgsl.expected.fxc.hlsl b/test/tint/expressions/splat/var/i32.wgsl.expected.fxc.hlsl index c9905a8e6b..d0b1d2b38a 100644 --- a/test/tint/expressions/splat/var/i32.wgsl.expected.fxc.hlsl +++ b/test/tint/expressions/splat/var/i32.wgsl.expected.fxc.hlsl @@ -4,7 +4,7 @@ void unused_entry_point() { } void f() { - int v = (1 + 2); + int v = 3; int2 v2 = int2((v).xx); int3 v3 = int3((v).xxx); int4 v4 = int4((v).xxxx); diff --git a/test/tint/expressions/splat/var/i32.wgsl.expected.glsl b/test/tint/expressions/splat/var/i32.wgsl.expected.glsl index 7c1f53d2cd..d908df81f8 100644 --- a/test/tint/expressions/splat/var/i32.wgsl.expected.glsl +++ b/test/tint/expressions/splat/var/i32.wgsl.expected.glsl @@ -5,7 +5,7 @@ void unused_entry_point() { return; } void f() { - int v = (1 + 2); + int v = 3; ivec2 v2 = ivec2(v); ivec3 v3 = ivec3(v); ivec4 v4 = ivec4(v); diff --git a/test/tint/expressions/splat/var/i32.wgsl.expected.msl b/test/tint/expressions/splat/var/i32.wgsl.expected.msl index 7e62e14488..10524ad183 100644 --- a/test/tint/expressions/splat/var/i32.wgsl.expected.msl +++ b/test/tint/expressions/splat/var/i32.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void f() { - int v = as_type((as_type(1) + as_type(2))); + int v = 3; int2 v2 = int2(v); int3 v3 = int3(v); int4 v4 = int4(v); diff --git a/test/tint/expressions/splat/var/i32.wgsl.expected.spvasm b/test/tint/expressions/splat/var/i32.wgsl.expected.spvasm index 157b2da2c6..4ac3a5198d 100644 --- a/test/tint/expressions/splat/var/i32.wgsl.expected.spvasm +++ b/test/tint/expressions/splat/var/i32.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 32 +; Bound: 30 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -16,39 +16,37 @@ %void = OpTypeVoid %1 = OpTypeFunction %void %int = OpTypeInt 32 1 - %int_1 = OpConstant %int 1 - %int_2 = OpConstant %int 2 + %int_3 = OpConstant %int 3 %_ptr_Function_int = OpTypePointer Function %int - %13 = OpConstantNull %int + %11 = OpConstantNull %int %v2int = OpTypeVector %int 2 %_ptr_Function_v2int = OpTypePointer Function %v2int - %19 = OpConstantNull %v2int + %17 = OpConstantNull %v2int %v3int = OpTypeVector %int 3 %_ptr_Function_v3int = OpTypePointer Function %v3int - %25 = OpConstantNull %v3int + %23 = OpConstantNull %v3int %v4int = OpTypeVector %int 4 %_ptr_Function_v4int = OpTypePointer Function %v4int - %31 = OpConstantNull %v4int + %29 = OpConstantNull %v4int %unused_entry_point = OpFunction %void None %1 %4 = OpLabel OpReturn OpFunctionEnd %f = OpFunction %void None %1 %6 = OpLabel - %v = OpVariable %_ptr_Function_int Function %13 - %v2 = OpVariable %_ptr_Function_v2int Function %19 - %v3 = OpVariable %_ptr_Function_v3int Function %25 - %v4 = OpVariable %_ptr_Function_v4int Function %31 - %10 = OpIAdd %int %int_1 %int_2 - OpStore %v %10 - %15 = OpLoad %int %v - %16 = OpCompositeConstruct %v2int %15 %15 - OpStore %v2 %16 - %21 = OpLoad %int %v - %22 = OpCompositeConstruct %v3int %21 %21 %21 - OpStore %v3 %22 - %27 = OpLoad %int %v - %28 = OpCompositeConstruct %v4int %27 %27 %27 %27 - OpStore %v4 %28 + %v = OpVariable %_ptr_Function_int Function %11 + %v2 = OpVariable %_ptr_Function_v2int Function %17 + %v3 = OpVariable %_ptr_Function_v3int Function %23 + %v4 = OpVariable %_ptr_Function_v4int Function %29 + OpStore %v %int_3 + %13 = OpLoad %int %v + %14 = OpCompositeConstruct %v2int %13 %13 + OpStore %v2 %14 + %19 = OpLoad %int %v + %20 = OpCompositeConstruct %v3int %19 %19 %19 + OpStore %v3 %20 + %25 = OpLoad %int %v + %26 = OpCompositeConstruct %v4int %25 %25 %25 %25 + OpStore %v4 %26 OpReturn OpFunctionEnd diff --git a/test/tint/expressions/splat/var/u32.wgsl.expected.dxc.hlsl b/test/tint/expressions/splat/var/u32.wgsl.expected.dxc.hlsl index 5e51b8dc15..413a7ace51 100644 --- a/test/tint/expressions/splat/var/u32.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/splat/var/u32.wgsl.expected.dxc.hlsl @@ -4,7 +4,7 @@ void unused_entry_point() { } void f() { - uint v = (1u + 2u); + uint v = 3u; uint2 v2 = uint2((v).xx); uint3 v3 = uint3((v).xxx); uint4 v4 = uint4((v).xxxx); diff --git a/test/tint/expressions/splat/var/u32.wgsl.expected.fxc.hlsl b/test/tint/expressions/splat/var/u32.wgsl.expected.fxc.hlsl index 5e51b8dc15..413a7ace51 100644 --- a/test/tint/expressions/splat/var/u32.wgsl.expected.fxc.hlsl +++ b/test/tint/expressions/splat/var/u32.wgsl.expected.fxc.hlsl @@ -4,7 +4,7 @@ void unused_entry_point() { } void f() { - uint v = (1u + 2u); + uint v = 3u; uint2 v2 = uint2((v).xx); uint3 v3 = uint3((v).xxx); uint4 v4 = uint4((v).xxxx); diff --git a/test/tint/expressions/splat/var/u32.wgsl.expected.glsl b/test/tint/expressions/splat/var/u32.wgsl.expected.glsl index 5ce7291b39..5649868172 100644 --- a/test/tint/expressions/splat/var/u32.wgsl.expected.glsl +++ b/test/tint/expressions/splat/var/u32.wgsl.expected.glsl @@ -5,7 +5,7 @@ void unused_entry_point() { return; } void f() { - uint v = (1u + 2u); + uint v = 3u; uvec2 v2 = uvec2(v); uvec3 v3 = uvec3(v); uvec4 v4 = uvec4(v); diff --git a/test/tint/expressions/splat/var/u32.wgsl.expected.msl b/test/tint/expressions/splat/var/u32.wgsl.expected.msl index 28df296595..435cfc0bab 100644 --- a/test/tint/expressions/splat/var/u32.wgsl.expected.msl +++ b/test/tint/expressions/splat/var/u32.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void f() { - uint v = (1u + 2u); + uint v = 3u; uint2 v2 = uint2(v); uint3 v3 = uint3(v); uint4 v4 = uint4(v); diff --git a/test/tint/expressions/splat/var/u32.wgsl.expected.spvasm b/test/tint/expressions/splat/var/u32.wgsl.expected.spvasm index ed6444af1d..9a92f8113d 100644 --- a/test/tint/expressions/splat/var/u32.wgsl.expected.spvasm +++ b/test/tint/expressions/splat/var/u32.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 32 +; Bound: 30 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -16,39 +16,37 @@ %void = OpTypeVoid %1 = OpTypeFunction %void %uint = OpTypeInt 32 0 - %uint_1 = OpConstant %uint 1 - %uint_2 = OpConstant %uint 2 + %uint_3 = OpConstant %uint 3 %_ptr_Function_uint = OpTypePointer Function %uint - %13 = OpConstantNull %uint + %11 = OpConstantNull %uint %v2uint = OpTypeVector %uint 2 %_ptr_Function_v2uint = OpTypePointer Function %v2uint - %19 = OpConstantNull %v2uint + %17 = OpConstantNull %v2uint %v3uint = OpTypeVector %uint 3 %_ptr_Function_v3uint = OpTypePointer Function %v3uint - %25 = OpConstantNull %v3uint + %23 = OpConstantNull %v3uint %v4uint = OpTypeVector %uint 4 %_ptr_Function_v4uint = OpTypePointer Function %v4uint - %31 = OpConstantNull %v4uint + %29 = OpConstantNull %v4uint %unused_entry_point = OpFunction %void None %1 %4 = OpLabel OpReturn OpFunctionEnd %f = OpFunction %void None %1 %6 = OpLabel - %v = OpVariable %_ptr_Function_uint Function %13 - %v2 = OpVariable %_ptr_Function_v2uint Function %19 - %v3 = OpVariable %_ptr_Function_v3uint Function %25 - %v4 = OpVariable %_ptr_Function_v4uint Function %31 - %10 = OpIAdd %uint %uint_1 %uint_2 - OpStore %v %10 - %15 = OpLoad %uint %v - %16 = OpCompositeConstruct %v2uint %15 %15 - OpStore %v2 %16 - %21 = OpLoad %uint %v - %22 = OpCompositeConstruct %v3uint %21 %21 %21 - OpStore %v3 %22 - %27 = OpLoad %uint %v - %28 = OpCompositeConstruct %v4uint %27 %27 %27 %27 - OpStore %v4 %28 + %v = OpVariable %_ptr_Function_uint Function %11 + %v2 = OpVariable %_ptr_Function_v2uint Function %17 + %v3 = OpVariable %_ptr_Function_v3uint Function %23 + %v4 = OpVariable %_ptr_Function_v4uint Function %29 + OpStore %v %uint_3 + %13 = OpLoad %uint %v + %14 = OpCompositeConstruct %v2uint %13 %13 + OpStore %v2 %14 + %19 = OpLoad %uint %v + %20 = OpCompositeConstruct %v3uint %19 %19 %19 + OpStore %v3 %20 + %25 = OpLoad %uint %v + %26 = OpCompositeConstruct %v4uint %25 %25 %25 %25 + OpStore %v4 %26 OpReturn OpFunctionEnd diff --git a/test/tint/ptr_ref/store/global/i32.spvasm.expected.dxc.hlsl b/test/tint/ptr_ref/store/global/i32.spvasm.expected.dxc.hlsl index ffe06339c1..b0598203cc 100644 --- a/test/tint/ptr_ref/store/global/i32.spvasm.expected.dxc.hlsl +++ b/test/tint/ptr_ref/store/global/i32.spvasm.expected.dxc.hlsl @@ -2,7 +2,7 @@ static int I = 0; void main_1() { I = 123; - I = ((100 + 20) + 3); + I = 123; return; } diff --git a/test/tint/ptr_ref/store/global/i32.spvasm.expected.fxc.hlsl b/test/tint/ptr_ref/store/global/i32.spvasm.expected.fxc.hlsl index ffe06339c1..b0598203cc 100644 --- a/test/tint/ptr_ref/store/global/i32.spvasm.expected.fxc.hlsl +++ b/test/tint/ptr_ref/store/global/i32.spvasm.expected.fxc.hlsl @@ -2,7 +2,7 @@ static int I = 0; void main_1() { I = 123; - I = ((100 + 20) + 3); + I = 123; return; } diff --git a/test/tint/ptr_ref/store/global/i32.spvasm.expected.glsl b/test/tint/ptr_ref/store/global/i32.spvasm.expected.glsl index d5fb2c0a95..d32281bed3 100644 --- a/test/tint/ptr_ref/store/global/i32.spvasm.expected.glsl +++ b/test/tint/ptr_ref/store/global/i32.spvasm.expected.glsl @@ -3,7 +3,7 @@ int I = 0; void main_1() { I = 123; - I = ((100 + 20) + 3); + I = 123; return; } diff --git a/test/tint/ptr_ref/store/global/i32.spvasm.expected.msl b/test/tint/ptr_ref/store/global/i32.spvasm.expected.msl index b2d2143085..5325510d02 100644 --- a/test/tint/ptr_ref/store/global/i32.spvasm.expected.msl +++ b/test/tint/ptr_ref/store/global/i32.spvasm.expected.msl @@ -4,7 +4,7 @@ using namespace metal; void main_1() { thread int tint_symbol_1 = 0; tint_symbol_1 = 123; - tint_symbol_1 = as_type((as_type(as_type((as_type(100) + as_type(20)))) + as_type(3))); + tint_symbol_1 = 123; return; } diff --git a/test/tint/ptr_ref/store/global/i32.spvasm.expected.spvasm b/test/tint/ptr_ref/store/global/i32.spvasm.expected.spvasm index 2925d52ba2..c38d8d434e 100644 --- a/test/tint/ptr_ref/store/global/i32.spvasm.expected.spvasm +++ b/test/tint/ptr_ref/store/global/i32.spvasm.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 18 +; Bound: 13 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -17,19 +17,14 @@ %void = OpTypeVoid %5 = OpTypeFunction %void %int_123 = OpConstant %int 123 - %int_100 = OpConstant %int 100 - %int_20 = OpConstant %int 20 - %int_3 = OpConstant %int 3 %main_1 = OpFunction %void None %5 %8 = OpLabel OpStore %I %int_123 - %12 = OpIAdd %int %int_100 %int_20 - %14 = OpIAdd %int %12 %int_3 - OpStore %I %14 + OpStore %I %int_123 OpReturn OpFunctionEnd %main = OpFunction %void None %5 - %16 = OpLabel - %17 = OpFunctionCall %void %main_1 + %11 = OpLabel + %12 = OpFunctionCall %void %main_1 OpReturn OpFunctionEnd diff --git a/test/tint/ptr_ref/store/global/i32.wgsl.expected.dxc.hlsl b/test/tint/ptr_ref/store/global/i32.wgsl.expected.dxc.hlsl index cb1bb3dbd8..5ee58400f9 100644 --- a/test/tint/ptr_ref/store/global/i32.wgsl.expected.dxc.hlsl +++ b/test/tint/ptr_ref/store/global/i32.wgsl.expected.dxc.hlsl @@ -3,6 +3,6 @@ static int I = 0; [numthreads(1, 1, 1)] void main() { I = 123; - I = ((100 + 20) + 3); + I = 123; return; } diff --git a/test/tint/ptr_ref/store/global/i32.wgsl.expected.fxc.hlsl b/test/tint/ptr_ref/store/global/i32.wgsl.expected.fxc.hlsl index cb1bb3dbd8..5ee58400f9 100644 --- a/test/tint/ptr_ref/store/global/i32.wgsl.expected.fxc.hlsl +++ b/test/tint/ptr_ref/store/global/i32.wgsl.expected.fxc.hlsl @@ -3,6 +3,6 @@ static int I = 0; [numthreads(1, 1, 1)] void main() { I = 123; - I = ((100 + 20) + 3); + I = 123; return; } diff --git a/test/tint/ptr_ref/store/global/i32.wgsl.expected.glsl b/test/tint/ptr_ref/store/global/i32.wgsl.expected.glsl index 0ea572e997..e1eb76606a 100644 --- a/test/tint/ptr_ref/store/global/i32.wgsl.expected.glsl +++ b/test/tint/ptr_ref/store/global/i32.wgsl.expected.glsl @@ -3,7 +3,7 @@ int I = 0; void tint_symbol() { I = 123; - I = ((100 + 20) + 3); + I = 123; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; diff --git a/test/tint/ptr_ref/store/global/i32.wgsl.expected.msl b/test/tint/ptr_ref/store/global/i32.wgsl.expected.msl index f68ac56077..7c4f8ee01b 100644 --- a/test/tint/ptr_ref/store/global/i32.wgsl.expected.msl +++ b/test/tint/ptr_ref/store/global/i32.wgsl.expected.msl @@ -4,7 +4,7 @@ using namespace metal; kernel void tint_symbol() { thread int tint_symbol_1 = 0; tint_symbol_1 = 123; - tint_symbol_1 = as_type((as_type(as_type((as_type(100) + as_type(20)))) + as_type(3))); + tint_symbol_1 = 123; return; } diff --git a/test/tint/ptr_ref/store/global/i32.wgsl.expected.spvasm b/test/tint/ptr_ref/store/global/i32.wgsl.expected.spvasm index 8c25a15a92..c1009db9a8 100644 --- a/test/tint/ptr_ref/store/global/i32.wgsl.expected.spvasm +++ b/test/tint/ptr_ref/store/global/i32.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 15 +; Bound: 10 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -16,14 +16,9 @@ %void = OpTypeVoid %5 = OpTypeFunction %void %int_123 = OpConstant %int 123 - %int_100 = OpConstant %int 100 - %int_20 = OpConstant %int 20 - %int_3 = OpConstant %int 3 %main = OpFunction %void None %5 %8 = OpLabel OpStore %I %int_123 - %12 = OpIAdd %int %int_100 %int_20 - %14 = OpIAdd %int %12 %int_3 - OpStore %I %14 + OpStore %I %int_123 OpReturn OpFunctionEnd diff --git a/test/tint/ptr_ref/store/local/i32.spvasm.expected.dxc.hlsl b/test/tint/ptr_ref/store/local/i32.spvasm.expected.dxc.hlsl index 5a9d251b30..497729077b 100644 --- a/test/tint/ptr_ref/store/local/i32.spvasm.expected.dxc.hlsl +++ b/test/tint/ptr_ref/store/local/i32.spvasm.expected.dxc.hlsl @@ -2,7 +2,7 @@ void main_1() { int i = 0; i = 123; i = 123; - i = ((100 + 20) + 3); + i = 123; return; } diff --git a/test/tint/ptr_ref/store/local/i32.spvasm.expected.fxc.hlsl b/test/tint/ptr_ref/store/local/i32.spvasm.expected.fxc.hlsl index 5a9d251b30..497729077b 100644 --- a/test/tint/ptr_ref/store/local/i32.spvasm.expected.fxc.hlsl +++ b/test/tint/ptr_ref/store/local/i32.spvasm.expected.fxc.hlsl @@ -2,7 +2,7 @@ void main_1() { int i = 0; i = 123; i = 123; - i = ((100 + 20) + 3); + i = 123; return; } diff --git a/test/tint/ptr_ref/store/local/i32.spvasm.expected.glsl b/test/tint/ptr_ref/store/local/i32.spvasm.expected.glsl index ef59ef5655..d74e398002 100644 --- a/test/tint/ptr_ref/store/local/i32.spvasm.expected.glsl +++ b/test/tint/ptr_ref/store/local/i32.spvasm.expected.glsl @@ -4,7 +4,7 @@ void main_1() { int i = 0; i = 123; i = 123; - i = ((100 + 20) + 3); + i = 123; return; } diff --git a/test/tint/ptr_ref/store/local/i32.spvasm.expected.msl b/test/tint/ptr_ref/store/local/i32.spvasm.expected.msl index 1e56158829..4737bb042c 100644 --- a/test/tint/ptr_ref/store/local/i32.spvasm.expected.msl +++ b/test/tint/ptr_ref/store/local/i32.spvasm.expected.msl @@ -5,7 +5,7 @@ void main_1() { int i = 0; i = 123; i = 123; - i = as_type((as_type(as_type((as_type(100) + as_type(20)))) + as_type(3))); + i = 123; return; } diff --git a/test/tint/ptr_ref/store/local/i32.spvasm.expected.spvasm b/test/tint/ptr_ref/store/local/i32.spvasm.expected.spvasm index 424e127e6f..64019e9be6 100644 --- a/test/tint/ptr_ref/store/local/i32.spvasm.expected.spvasm +++ b/test/tint/ptr_ref/store/local/i32.spvasm.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 18 +; Bound: 13 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -16,22 +16,17 @@ %6 = OpConstantNull %int %_ptr_Function_int = OpTypePointer Function %int %int_123 = OpConstant %int 123 - %int_100 = OpConstant %int 100 - %int_20 = OpConstant %int 20 - %int_3 = OpConstant %int 3 %main_1 = OpFunction %void None %1 %4 = OpLabel %i = OpVariable %_ptr_Function_int Function %6 OpStore %i %6 OpStore %i %int_123 OpStore %i %int_123 - %12 = OpIAdd %int %int_100 %int_20 - %14 = OpIAdd %int %12 %int_3 - OpStore %i %14 + OpStore %i %int_123 OpReturn OpFunctionEnd %main = OpFunction %void None %1 - %16 = OpLabel - %17 = OpFunctionCall %void %main_1 + %11 = OpLabel + %12 = OpFunctionCall %void %main_1 OpReturn OpFunctionEnd diff --git a/test/tint/ptr_ref/store/local/i32.wgsl.expected.dxc.hlsl b/test/tint/ptr_ref/store/local/i32.wgsl.expected.dxc.hlsl index 31873655bd..e5949b66ef 100644 --- a/test/tint/ptr_ref/store/local/i32.wgsl.expected.dxc.hlsl +++ b/test/tint/ptr_ref/store/local/i32.wgsl.expected.dxc.hlsl @@ -2,6 +2,6 @@ void main() { int i = 123; i = 123; - i = ((100 + 20) + 3); + i = 123; return; } diff --git a/test/tint/ptr_ref/store/local/i32.wgsl.expected.fxc.hlsl b/test/tint/ptr_ref/store/local/i32.wgsl.expected.fxc.hlsl index 31873655bd..e5949b66ef 100644 --- a/test/tint/ptr_ref/store/local/i32.wgsl.expected.fxc.hlsl +++ b/test/tint/ptr_ref/store/local/i32.wgsl.expected.fxc.hlsl @@ -2,6 +2,6 @@ void main() { int i = 123; i = 123; - i = ((100 + 20) + 3); + i = 123; return; } diff --git a/test/tint/ptr_ref/store/local/i32.wgsl.expected.glsl b/test/tint/ptr_ref/store/local/i32.wgsl.expected.glsl index 1ccce1c71a..0fb9035f68 100644 --- a/test/tint/ptr_ref/store/local/i32.wgsl.expected.glsl +++ b/test/tint/ptr_ref/store/local/i32.wgsl.expected.glsl @@ -3,7 +3,7 @@ void tint_symbol() { int i = 123; i = 123; - i = ((100 + 20) + 3); + i = 123; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; diff --git a/test/tint/ptr_ref/store/local/i32.wgsl.expected.msl b/test/tint/ptr_ref/store/local/i32.wgsl.expected.msl index fc37fba94b..5c7e7b4031 100644 --- a/test/tint/ptr_ref/store/local/i32.wgsl.expected.msl +++ b/test/tint/ptr_ref/store/local/i32.wgsl.expected.msl @@ -4,7 +4,7 @@ using namespace metal; kernel void tint_symbol() { int i = 123; i = 123; - i = as_type((as_type(as_type((as_type(100) + as_type(20)))) + as_type(3))); + i = 123; return; } diff --git a/test/tint/ptr_ref/store/local/i32.wgsl.expected.spvasm b/test/tint/ptr_ref/store/local/i32.wgsl.expected.spvasm index d4738a2447..11ba7fc027 100644 --- a/test/tint/ptr_ref/store/local/i32.wgsl.expected.spvasm +++ b/test/tint/ptr_ref/store/local/i32.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 15 +; Bound: 10 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -15,16 +15,11 @@ %int_123 = OpConstant %int 123 %_ptr_Function_int = OpTypePointer Function %int %9 = OpConstantNull %int - %int_100 = OpConstant %int 100 - %int_20 = OpConstant %int 20 - %int_3 = OpConstant %int 3 %main = OpFunction %void None %1 %4 = OpLabel %i = OpVariable %_ptr_Function_int Function %9 OpStore %i %int_123 OpStore %i %int_123 - %12 = OpIAdd %int %int_100 %int_20 - %14 = OpIAdd %int %12 %int_3 - OpStore %i %14 + OpStore %i %int_123 OpReturn OpFunctionEnd