[tint] Signed integer polyfill for IR Bug: 426999765 Change-Id: Ifd354a8f5a8099bc0ef4aee5d487401688b371c2 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/249135 Reviewed-by: James Price <jrprice@google.com> Commit-Queue: Peter McNeeley <petermcneeley@google.com>
diff --git a/src/tint/lang/core/ir/transform/BUILD.bazel b/src/tint/lang/core/ir/transform/BUILD.bazel index 94705ce..7fef8ac 100644 --- a/src/tint/lang/core/ir/transform/BUILD.bazel +++ b/src/tint/lang/core/ir/transform/BUILD.bazel
@@ -61,6 +61,7 @@ "rename_conflicts.cc", "robustness.cc", "shader_io.cc", + "signed_integer_polyfill.cc", "single_entry_point.cc", "std140.cc", "substitute_overrides.cc", @@ -93,6 +94,7 @@ "rename_conflicts.h", "robustness.h", "shader_io.h", + "signed_integer_polyfill.h", "single_entry_point.h", "std140.h", "substitute_overrides.h", @@ -151,6 +153,7 @@ "remove_terminator_args_test.cc", "rename_conflicts_test.cc", "robustness_test.cc", + "signed_integer_polyfill_test.cc", "single_entry_point_test.cc", "std140_test.cc", "substitute_overrides_test.cc",
diff --git a/src/tint/lang/core/ir/transform/BUILD.cmake b/src/tint/lang/core/ir/transform/BUILD.cmake index c0cb68a..38c4c0a 100644 --- a/src/tint/lang/core/ir/transform/BUILD.cmake +++ b/src/tint/lang/core/ir/transform/BUILD.cmake
@@ -84,6 +84,8 @@ lang/core/ir/transform/robustness.h lang/core/ir/transform/shader_io.cc lang/core/ir/transform/shader_io.h + lang/core/ir/transform/signed_integer_polyfill.cc + lang/core/ir/transform/signed_integer_polyfill.h lang/core/ir/transform/single_entry_point.cc lang/core/ir/transform/single_entry_point.h lang/core/ir/transform/std140.cc @@ -152,6 +154,7 @@ lang/core/ir/transform/remove_terminator_args_test.cc lang/core/ir/transform/rename_conflicts_test.cc lang/core/ir/transform/robustness_test.cc + lang/core/ir/transform/signed_integer_polyfill_test.cc lang/core/ir/transform/single_entry_point_test.cc lang/core/ir/transform/std140_test.cc lang/core/ir/transform/substitute_overrides_test.cc
diff --git a/src/tint/lang/core/ir/transform/BUILD.gn b/src/tint/lang/core/ir/transform/BUILD.gn index 9e89f0a..da17ea9 100644 --- a/src/tint/lang/core/ir/transform/BUILD.gn +++ b/src/tint/lang/core/ir/transform/BUILD.gn
@@ -90,6 +90,8 @@ "robustness.h", "shader_io.cc", "shader_io.h", + "signed_integer_polyfill.cc", + "signed_integer_polyfill.h", "single_entry_point.cc", "single_entry_point.h", "std140.cc", @@ -152,6 +154,7 @@ "remove_terminator_args_test.cc", "rename_conflicts_test.cc", "robustness_test.cc", + "signed_integer_polyfill_test.cc", "single_entry_point_test.cc", "std140_test.cc", "substitute_overrides_test.cc",
diff --git a/src/tint/lang/core/ir/transform/signed_integer_polyfill.cc b/src/tint/lang/core/ir/transform/signed_integer_polyfill.cc new file mode 100644 index 0000000..e8bb1ce --- /dev/null +++ b/src/tint/lang/core/ir/transform/signed_integer_polyfill.cc
@@ -0,0 +1,174 @@ +// Copyright 2025 The Dawn & Tint Authors +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// 3. Neither the name of the copyright holder nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include "src/tint/lang/core/ir/transform/signed_integer_polyfill.h" + +#include "src/tint/lang/core/ir/builder.h" +#include "src/tint/lang/core/ir/core_binary.h" +#include "src/tint/lang/core/ir/module.h" +#include "src/tint/lang/core/ir/validator.h" + +using namespace tint::core::fluent_types; // NOLINT + +namespace tint::core::ir::transform { +namespace { + +/// PIMPL state for the transform. +struct State { + core::ir::Module& ir; + SignedIntegerPolyfillConfig cfg; + core::ir::Builder b{ir}; + + /// The type manager. + core::type::Manager& ty{ir.Types()}; + + /// Process the module. + void Process() { + Vector<core::ir::Unary*, 4> signed_int_negate_worklist; + Vector<core::ir::CoreBinary*, 4> signed_integer_arithmetic_worklist; + Vector<core::ir::CoreBinary*, 4> signed_integer_leftshift_worklist; + for (auto* inst : ir.Instructions()) { + if (auto* unary = inst->As<core::ir::Unary>()) { + auto op = unary->Op(); + auto* type = unary->Val()->Type(); + if (cfg.signed_negation && op == core::UnaryOp::kNegation && + type->IsSignedIntegerScalarOrVector()) { + signed_int_negate_worklist.Push(unary); + } + } else if (auto* binary = inst->As<core::ir::CoreBinary>()) { + auto op = binary->Op(); + auto* lhs_type = binary->LHS()->Type(); + if (cfg.signed_arithmetic && + (op == core::BinaryOp::kAdd || op == core::BinaryOp::kMultiply || + op == core::BinaryOp::kSubtract) && + lhs_type->IsSignedIntegerScalarOrVector()) { + signed_integer_arithmetic_worklist.Push(binary); + } else if (cfg.signed_shiftleft && op == core::BinaryOp::kShiftLeft && + lhs_type->IsSignedIntegerScalarOrVector()) { + signed_integer_leftshift_worklist.Push(binary); + } + } + } + + // Replace the instructions that we found. + for (auto* signed_int_negate : signed_int_negate_worklist) { + SignedIntegerNegation(signed_int_negate); + } + for (auto* signed_arith : signed_integer_arithmetic_worklist) { + SignedIntegerArithmetic(signed_arith); + } + for (auto* signed_shift_left : signed_integer_leftshift_worklist) { + SignedIntegerShiftLeft(signed_shift_left); + } + } + + /// Replace a signed integer negation to avoid undefined behavior. + /// @param unary the unary instruction + void SignedIntegerNegation(core::ir::Unary* unary) { + // Replace `-x` with `bitcast<int>((~bitcast<uint>(x)) + 1)`. + auto* signed_type = unary->Result()->Type(); + auto* unsigned_type = ty.MatchWidth(ty.u32(), signed_type); + b.InsertBefore(unary, [&] { + auto* unsigned_value = b.Bitcast(unsigned_type, unary->Val()); + auto* complement = b.Complement(unsigned_type, unsigned_value); + auto* plus_one = b.Add(unsigned_type, complement, b.MatchWidth(u32(1), unsigned_type)); + auto* result = b.Bitcast(signed_type, plus_one); + unary->Result()->ReplaceAllUsesWith(result->Result()); + }); + unary->Destroy(); + } + + /// Replace a signed integer arithmetic instruction. + /// @param binary the signed integer arithmetic instruction + void SignedIntegerArithmetic(core::ir::CoreBinary* binary) { + // MSL (HLSL/SPIR-V) does not define the behavior of signed integer overflow, so bitcast the + // operands to unsigned integers, perform the operation, and then bitcast the result back to + // a signed integer. + auto* signed_result_ty = binary->Result()->Type(); + auto* unsigned_result_ty = ty.MatchWidth(ty.u32(), signed_result_ty); + auto* unsigned_lhs_ty = ty.MatchWidth(ty.u32(), binary->LHS()->Type()); + auto* unsigned_rhs_ty = ty.MatchWidth(ty.u32(), binary->RHS()->Type()); + b.InsertBefore(binary, [&] { + auto* uint_lhs = b.Bitcast(unsigned_lhs_ty, binary->LHS()); + auto* uint_rhs = b.Bitcast(unsigned_rhs_ty, binary->RHS()); + auto* uint_binary = b.Binary(binary->Op(), unsigned_result_ty, uint_lhs, uint_rhs); + auto* bitcast = b.Bitcast(signed_result_ty, uint_binary); + binary->Result()->ReplaceAllUsesWith(bitcast->Result()); + }); + binary->Destroy(); + } + + /// Replace a signed integer shift left instruction. + /// @param binary the signed integer shift left instruction + void SignedIntegerShiftLeft(core::ir::CoreBinary* binary) { + // Left-shifting a negative integer is undefined behavior in C++14 and therefore potentially + // in MSL (HLSL/SPRI-V) too, so we bitcast to an unsigned integer, perform the shift, and + // bitcast the result back to a signed integer. + auto* signed_ty = binary->Result()->Type(); + auto* unsigned_ty = ty.MatchWidth(ty.u32(), signed_ty); + b.InsertBefore(binary, [&] { + auto* unsigned_lhs = b.Bitcast(unsigned_ty, binary->LHS()); + auto* unsigned_binary = + b.Binary(binary->Op(), unsigned_ty, unsigned_lhs, binary->RHS()); + auto* bitcast = b.Bitcast(signed_ty, unsigned_binary); + binary->Result()->ReplaceAllUsesWith(bitcast->Result()); + }); + binary->Destroy(); + } +}; + +} // namespace + +Result<SuccessType> SignedIntegerPolyfill(core::ir::Module& ir, + const SignedIntegerPolyfillConfig& cfg) { + auto result = + ValidateAndDumpIfNeeded(ir, "ir.SignedIntegerPolyfill", + core::ir::Capabilities{ + core::ir::Capability::kAllowPointersAndHandlesInStructures, + core::ir::Capability::kAllowDuplicateBindings, + core::ir::Capability::kAllow8BitIntegers, + core::ir::Capability::kAllow64BitIntegers, + core::ir::Capability::kAllowVectorElementPointer, + core::ir::Capability::kAllowHandleVarsWithoutBindings, + core::ir::Capability::kAllowClipDistancesOnF32, + core::ir::Capability::kAllowPrivateVarsInFunctions, + core::ir::Capability::kAllowAnyLetType, + core::ir::Capability::kAllowWorkspacePointerInputToEntryPoint, + core::ir::Capability::kAllowModuleScopeLets, + core::ir::Capability::kAllowAnyInputAttachmentIndexType, + core::ir::Capability::kAllowNonCoreTypes, + }); + if (result != Success) { + return result.Failure(); + } + + State{ir, cfg}.Process(); + + return Success; +} + +} // namespace tint::core::ir::transform
diff --git a/src/tint/lang/core/ir/transform/signed_integer_polyfill.h b/src/tint/lang/core/ir/transform/signed_integer_polyfill.h new file mode 100644 index 0000000..2cd5f0f --- /dev/null +++ b/src/tint/lang/core/ir/transform/signed_integer_polyfill.h
@@ -0,0 +1,65 @@ +// Copyright 2025 The Dawn & Tint Authors +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// 3. Neither the name of the copyright holder nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef SRC_TINT_LANG_CORE_IR_TRANSFORM_SIGNED_INTEGER_POLYFILL_H_ +#define SRC_TINT_LANG_CORE_IR_TRANSFORM_SIGNED_INTEGER_POLYFILL_H_ + +#include "src/tint/lang/core/ir/validator.h" +#include "src/tint/utils/reflection.h" +#include "src/tint/utils/result.h" + +// Forward declarations. +namespace tint::core::ir { +class Module; +} // namespace tint::core::ir + +namespace tint::core::ir::transform { + +/// The set of polyfills that should be applied. +struct SignedIntegerPolyfillConfig { + /// Should signed negation be polyfilled to avoid integer overflow? + bool signed_negation = false; + + /// Should signed arithmetic be polyfilled to avoid integer overflow? + bool signed_arithmetic = false; + + /// Should signed shiftleft be polyfilled to avoid integer overflow? + bool signed_shiftleft = false; + + /// Reflection for this class + TINT_REFLECT(SignedIntegerPolyfillConfig, signed_negation, signed_arithmetic, signed_shiftleft); +}; + +/// SignedIntegerPolyfill is a transform that replaces signed integer instructions with polyfills. +/// @param module the module to transform +/// @returns success or failure +Result<SuccessType> SignedIntegerPolyfill(core::ir::Module& module, + const SignedIntegerPolyfillConfig& cfg); + +} // namespace tint::core::ir::transform + +#endif // SRC_TINT_LANG_CORE_IR_TRANSFORM_SIGNED_INTEGER_POLYFILL_H_
diff --git a/src/tint/lang/core/ir/transform/signed_integer_polyfill_test.cc b/src/tint/lang/core/ir/transform/signed_integer_polyfill_test.cc new file mode 100644 index 0000000..2138882 --- /dev/null +++ b/src/tint/lang/core/ir/transform/signed_integer_polyfill_test.cc
@@ -0,0 +1,712 @@ +// Copyright 2025 The Dawn & Tint Authors +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// 3. Neither the name of the copyright holder nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include "src/tint/lang/core/ir/transform/signed_integer_polyfill.h" + +#include <utility> + +#include "gtest/gtest.h" +#include "src/tint/lang/core/fluent_types.h" +#include "src/tint/lang/core/ir/transform/helper_test.h" + +using namespace tint::core::fluent_types; // NOLINT +using namespace tint::core::number_suffixes; // NOLINT + +namespace tint::core::ir::transform { +namespace { + +using IR_SignedIntegerPolyfillTest = core::ir::transform::TransformTest; + +TEST_F(IR_SignedIntegerPolyfillTest, Negation_F32) { + auto* value = b.FunctionParam<f32>("value"); + auto* func = b.Function("foo", ty.f32()); + func->SetParams({value}); + b.Append(func->Block(), [&] { + auto* result = b.Negation<f32>(value); + b.Return(func, result); + }); + + auto* src = R"( +%foo = func(%value:f32):f32 { + $B1: { + %3:f32 = negation %value + ret %3 + } +} +)"; + EXPECT_EQ(src, str()); + + auto* expect = src; + SignedIntegerPolyfillConfig cfg{.signed_negation = true}; + Run(SignedIntegerPolyfill, cfg); + + EXPECT_EQ(expect, str()); +} + +TEST_F(IR_SignedIntegerPolyfillTest, Negation_I32_Scalar) { + auto* value = b.FunctionParam<i32>("value"); + auto* func = b.Function("foo", ty.i32()); + func->SetParams({value}); + b.Append(func->Block(), [&] { + auto* result = b.Negation<i32>(value); + b.Return(func, result); + }); + + auto* src = R"( +%foo = func(%value:i32):i32 { + $B1: { + %3:i32 = negation %value + ret %3 + } +} +)"; + EXPECT_EQ(src, str()); + + auto* expect = R"( +%foo = func(%value:i32):i32 { + $B1: { + %3:u32 = bitcast %value + %4:u32 = complement %3 + %5:u32 = add %4, 1u + %6:i32 = bitcast %5 + ret %6 + } +} +)"; + SignedIntegerPolyfillConfig cfg{.signed_negation = true}; + Run(SignedIntegerPolyfill, cfg); + + EXPECT_EQ(expect, str()); +} + +TEST_F(IR_SignedIntegerPolyfillTest, Disabled_Negation_I32_Scalar) { + auto* value = b.FunctionParam<i32>("value"); + auto* func = b.Function("foo", ty.i32()); + func->SetParams({value}); + b.Append(func->Block(), [&] { + auto* result = b.Negation<i32>(value); + b.Return(func, result); + }); + + auto* src = R"( +%foo = func(%value:i32):i32 { + $B1: { + %3:i32 = negation %value + ret %3 + } +} +)"; + EXPECT_EQ(src, str()); + + auto* expect = src; + SignedIntegerPolyfillConfig cfg{}; + Run(SignedIntegerPolyfill, cfg); + + EXPECT_EQ(expect, str()); +} + +TEST_F(IR_SignedIntegerPolyfillTest, Negation_I32_Vector) { + auto* value = b.FunctionParam<vec4<i32>>("value"); + auto* func = b.Function("foo", ty.vec4<i32>()); + func->SetParams({value}); + b.Append(func->Block(), [&] { + auto* result = b.Negation<vec4<i32>>(value); + b.Return(func, result); + }); + + auto* src = R"( +%foo = func(%value:vec4<i32>):vec4<i32> { + $B1: { + %3:vec4<i32> = negation %value + ret %3 + } +} +)"; + EXPECT_EQ(src, str()); + + auto* expect = R"( +%foo = func(%value:vec4<i32>):vec4<i32> { + $B1: { + %3:vec4<u32> = bitcast %value + %4:vec4<u32> = complement %3 + %5:vec4<u32> = add %4, vec4<u32>(1u) + %6:vec4<i32> = bitcast %5 + ret %6 + } +} +)"; + + SignedIntegerPolyfillConfig cfg{.signed_negation = true}; + Run(SignedIntegerPolyfill, cfg); + + EXPECT_EQ(expect, str()); +} + +TEST_F(IR_SignedIntegerPolyfillTest, Disabled_Negation_I32_Vector) { + auto* value = b.FunctionParam<vec4<i32>>("value"); + auto* func = b.Function("foo", ty.vec4<i32>()); + func->SetParams({value}); + b.Append(func->Block(), [&] { + auto* result = b.Negation<vec4<i32>>(value); + b.Return(func, result); + }); + + auto* src = R"( +%foo = func(%value:vec4<i32>):vec4<i32> { + $B1: { + %3:vec4<i32> = negation %value + ret %3 + } +} +)"; + EXPECT_EQ(src, str()); + + auto* expect = src; + SignedIntegerPolyfillConfig cfg{}; + Run(SignedIntegerPolyfill, cfg); + + EXPECT_EQ(expect, str()); +} + +TEST_F(IR_SignedIntegerPolyfillTest, IntAdd_Scalar) { + auto* lhs = b.FunctionParam<i32>("lhs"); + auto* rhs = b.FunctionParam<i32>("rhs"); + auto* func = b.Function("foo", ty.i32()); + func->SetParams({lhs, rhs}); + b.Append(func->Block(), [&] { + auto* result = b.Add<i32>(lhs, rhs); + b.Return(func, result); + }); + + auto* src = R"( +%foo = func(%lhs:i32, %rhs:i32):i32 { + $B1: { + %4:i32 = add %lhs, %rhs + ret %4 + } +} +)"; + EXPECT_EQ(src, str()); + + auto* expect = R"( +%foo = func(%lhs:i32, %rhs:i32):i32 { + $B1: { + %4:u32 = bitcast %lhs + %5:u32 = bitcast %rhs + %6:u32 = add %4, %5 + %7:i32 = bitcast %6 + ret %7 + } +} +)"; + + SignedIntegerPolyfillConfig cfg{.signed_arithmetic = true}; + Run(SignedIntegerPolyfill, cfg); + + EXPECT_EQ(expect, str()); +} + +TEST_F(IR_SignedIntegerPolyfillTest, Disabled_IntAdd_Scalar) { + auto* lhs = b.FunctionParam<i32>("lhs"); + auto* rhs = b.FunctionParam<i32>("rhs"); + auto* func = b.Function("foo", ty.i32()); + func->SetParams({lhs, rhs}); + b.Append(func->Block(), [&] { + auto* result = b.Add<i32>(lhs, rhs); + b.Return(func, result); + }); + + auto* src = R"( +%foo = func(%lhs:i32, %rhs:i32):i32 { + $B1: { + %4:i32 = add %lhs, %rhs + ret %4 + } +} +)"; + EXPECT_EQ(src, str()); + + auto* expect = src; + SignedIntegerPolyfillConfig cfg{}; + Run(SignedIntegerPolyfill, cfg); + + EXPECT_EQ(expect, str()); +} + +TEST_F(IR_SignedIntegerPolyfillTest, IntMul_Scalar) { + auto* lhs = b.FunctionParam<i32>("lhs"); + auto* rhs = b.FunctionParam<i32>("rhs"); + auto* func = b.Function("foo", ty.i32()); + func->SetParams({lhs, rhs}); + b.Append(func->Block(), [&] { + auto* result = b.Multiply<i32>(lhs, rhs); + b.Return(func, result); + }); + + auto* src = R"( +%foo = func(%lhs:i32, %rhs:i32):i32 { + $B1: { + %4:i32 = mul %lhs, %rhs + ret %4 + } +} +)"; + EXPECT_EQ(src, str()); + + auto* expect = R"( +%foo = func(%lhs:i32, %rhs:i32):i32 { + $B1: { + %4:u32 = bitcast %lhs + %5:u32 = bitcast %rhs + %6:u32 = mul %4, %5 + %7:i32 = bitcast %6 + ret %7 + } +} +)"; + + SignedIntegerPolyfillConfig cfg{.signed_arithmetic = true}; + Run(SignedIntegerPolyfill, cfg); + + EXPECT_EQ(expect, str()); +} + +TEST_F(IR_SignedIntegerPolyfillTest, Disabled_IntMul_Scalar) { + auto* lhs = b.FunctionParam<i32>("lhs"); + auto* rhs = b.FunctionParam<i32>("rhs"); + auto* func = b.Function("foo", ty.i32()); + func->SetParams({lhs, rhs}); + b.Append(func->Block(), [&] { + auto* result = b.Multiply<i32>(lhs, rhs); + b.Return(func, result); + }); + + auto* src = R"( +%foo = func(%lhs:i32, %rhs:i32):i32 { + $B1: { + %4:i32 = mul %lhs, %rhs + ret %4 + } +} +)"; + EXPECT_EQ(src, str()); + + auto* expect = src; + SignedIntegerPolyfillConfig cfg{}; + Run(SignedIntegerPolyfill, cfg); + + EXPECT_EQ(expect, str()); +} + +TEST_F(IR_SignedIntegerPolyfillTest, IntSub_Scalar) { + auto* lhs = b.FunctionParam<i32>("lhs"); + auto* rhs = b.FunctionParam<i32>("rhs"); + auto* func = b.Function("foo", ty.i32()); + func->SetParams({lhs, rhs}); + b.Append(func->Block(), [&] { + auto* result = b.Subtract<i32>(lhs, rhs); + b.Return(func, result); + }); + + auto* src = R"( +%foo = func(%lhs:i32, %rhs:i32):i32 { + $B1: { + %4:i32 = sub %lhs, %rhs + ret %4 + } +} +)"; + EXPECT_EQ(src, str()); + + auto* expect = R"( +%foo = func(%lhs:i32, %rhs:i32):i32 { + $B1: { + %4:u32 = bitcast %lhs + %5:u32 = bitcast %rhs + %6:u32 = sub %4, %5 + %7:i32 = bitcast %6 + ret %7 + } +} +)"; + + SignedIntegerPolyfillConfig cfg{.signed_arithmetic = true}; + Run(SignedIntegerPolyfill, cfg); + + EXPECT_EQ(expect, str()); +} + +TEST_F(IR_SignedIntegerPolyfillTest, Disabled_IntSub_Scalar) { + auto* lhs = b.FunctionParam<i32>("lhs"); + auto* rhs = b.FunctionParam<i32>("rhs"); + auto* func = b.Function("foo", ty.i32()); + func->SetParams({lhs, rhs}); + b.Append(func->Block(), [&] { + auto* result = b.Subtract<i32>(lhs, rhs); + b.Return(func, result); + }); + + auto* src = R"( +%foo = func(%lhs:i32, %rhs:i32):i32 { + $B1: { + %4:i32 = sub %lhs, %rhs + ret %4 + } +} +)"; + EXPECT_EQ(src, str()); + + auto* expect = src; + SignedIntegerPolyfillConfig cfg{}; + Run(SignedIntegerPolyfill, cfg); + + EXPECT_EQ(expect, str()); +} + +TEST_F(IR_SignedIntegerPolyfillTest, IntAdd_Vector) { + auto* lhs = b.FunctionParam<vec4<i32>>("lhs"); + auto* rhs = b.FunctionParam<vec4<i32>>("rhs"); + auto* func = b.Function("foo", ty.vec4<i32>()); + func->SetParams({lhs, rhs}); + b.Append(func->Block(), [&] { + auto* result = b.Add<vec4<i32>>(lhs, rhs); + b.Return(func, result); + }); + + auto* src = R"( +%foo = func(%lhs:vec4<i32>, %rhs:vec4<i32>):vec4<i32> { + $B1: { + %4:vec4<i32> = add %lhs, %rhs + ret %4 + } +} +)"; + EXPECT_EQ(src, str()); + + auto* expect = R"( +%foo = func(%lhs:vec4<i32>, %rhs:vec4<i32>):vec4<i32> { + $B1: { + %4:vec4<u32> = bitcast %lhs + %5:vec4<u32> = bitcast %rhs + %6:vec4<u32> = add %4, %5 + %7:vec4<i32> = bitcast %6 + ret %7 + } +} +)"; + + SignedIntegerPolyfillConfig cfg{.signed_arithmetic = true}; + Run(SignedIntegerPolyfill, cfg); + + EXPECT_EQ(expect, str()); +} + +TEST_F(IR_SignedIntegerPolyfillTest, Disabled_IntAdd_Vector) { + auto* lhs = b.FunctionParam<vec4<i32>>("lhs"); + auto* rhs = b.FunctionParam<vec4<i32>>("rhs"); + auto* func = b.Function("foo", ty.vec4<i32>()); + func->SetParams({lhs, rhs}); + b.Append(func->Block(), [&] { + auto* result = b.Add<vec4<i32>>(lhs, rhs); + b.Return(func, result); + }); + + auto* src = R"( +%foo = func(%lhs:vec4<i32>, %rhs:vec4<i32>):vec4<i32> { + $B1: { + %4:vec4<i32> = add %lhs, %rhs + ret %4 + } +} +)"; + EXPECT_EQ(src, str()); + + auto* expect = src; + SignedIntegerPolyfillConfig cfg{}; + Run(SignedIntegerPolyfill, cfg); + + EXPECT_EQ(expect, str()); +} + +TEST_F(IR_SignedIntegerPolyfillTest, IntAdd_ScalarVector) { + auto* lhs = b.FunctionParam<i32>("lhs"); + auto* rhs = b.FunctionParam<vec4<i32>>("rhs"); + auto* func = b.Function("foo", ty.vec4<i32>()); + func->SetParams({lhs, rhs}); + b.Append(func->Block(), [&] { + auto* result = b.Add<vec4<i32>>(lhs, rhs); + b.Return(func, result); + }); + + auto* src = R"( +%foo = func(%lhs:i32, %rhs:vec4<i32>):vec4<i32> { + $B1: { + %4:vec4<i32> = add %lhs, %rhs + ret %4 + } +} +)"; + EXPECT_EQ(src, str()); + + auto* expect = R"( +%foo = func(%lhs:i32, %rhs:vec4<i32>):vec4<i32> { + $B1: { + %4:u32 = bitcast %lhs + %5:vec4<u32> = bitcast %rhs + %6:vec4<u32> = add %4, %5 + %7:vec4<i32> = bitcast %6 + ret %7 + } +} +)"; + + SignedIntegerPolyfillConfig cfg{.signed_arithmetic = true}; + Run(SignedIntegerPolyfill, cfg); + + EXPECT_EQ(expect, str()); +} + +TEST_F(IR_SignedIntegerPolyfillTest, Disabled_IntAdd_ScalarVector) { + auto* lhs = b.FunctionParam<i32>("lhs"); + auto* rhs = b.FunctionParam<vec4<i32>>("rhs"); + auto* func = b.Function("foo", ty.vec4<i32>()); + func->SetParams({lhs, rhs}); + b.Append(func->Block(), [&] { + auto* result = b.Add<vec4<i32>>(lhs, rhs); + b.Return(func, result); + }); + + auto* src = R"( +%foo = func(%lhs:i32, %rhs:vec4<i32>):vec4<i32> { + $B1: { + %4:vec4<i32> = add %lhs, %rhs + ret %4 + } +} +)"; + EXPECT_EQ(src, str()); + + auto* expect = src; + SignedIntegerPolyfillConfig cfg{}; + Run(SignedIntegerPolyfill, cfg); + + EXPECT_EQ(expect, str()); +} + +TEST_F(IR_SignedIntegerPolyfillTest, IntAdd_VectorScalar) { + auto* lhs = b.FunctionParam<vec4<i32>>("lhs"); + auto* rhs = b.FunctionParam<i32>("rhs"); + auto* func = b.Function("foo", ty.vec4<i32>()); + func->SetParams({lhs, rhs}); + b.Append(func->Block(), [&] { + auto* result = b.Add<vec4<i32>>(lhs, rhs); + b.Return(func, result); + }); + + auto* src = R"( +%foo = func(%lhs:vec4<i32>, %rhs:i32):vec4<i32> { + $B1: { + %4:vec4<i32> = add %lhs, %rhs + ret %4 + } +} +)"; + EXPECT_EQ(src, str()); + + auto* expect = R"( +%foo = func(%lhs:vec4<i32>, %rhs:i32):vec4<i32> { + $B1: { + %4:vec4<u32> = bitcast %lhs + %5:u32 = bitcast %rhs + %6:vec4<u32> = add %4, %5 + %7:vec4<i32> = bitcast %6 + ret %7 + } +} +)"; + + SignedIntegerPolyfillConfig cfg{.signed_arithmetic = true}; + Run(SignedIntegerPolyfill, cfg); + + EXPECT_EQ(expect, str()); +} + +TEST_F(IR_SignedIntegerPolyfillTest, Disabled_IntAdd_VectorScalar) { + auto* lhs = b.FunctionParam<vec4<i32>>("lhs"); + auto* rhs = b.FunctionParam<i32>("rhs"); + auto* func = b.Function("foo", ty.vec4<i32>()); + func->SetParams({lhs, rhs}); + b.Append(func->Block(), [&] { + auto* result = b.Add<vec4<i32>>(lhs, rhs); + b.Return(func, result); + }); + + auto* src = R"( +%foo = func(%lhs:vec4<i32>, %rhs:i32):vec4<i32> { + $B1: { + %4:vec4<i32> = add %lhs, %rhs + ret %4 + } +} +)"; + EXPECT_EQ(src, str()); + + auto* expect = src; + SignedIntegerPolyfillConfig cfg{}; + Run(SignedIntegerPolyfill, cfg); + + EXPECT_EQ(expect, str()); +} + +TEST_F(IR_SignedIntegerPolyfillTest, IntShift_Scalar) { + auto* lhs = b.FunctionParam<i32>("lhs"); + auto* rhs = b.FunctionParam<u32>("rhs"); + auto* func = b.Function("foo", ty.i32()); + func->SetParams({lhs, rhs}); + b.Append(func->Block(), [&] { + auto* result = b.ShiftLeft<i32>(lhs, rhs); + b.Return(func, result); + }); + + auto* src = R"( +%foo = func(%lhs:i32, %rhs:u32):i32 { + $B1: { + %4:i32 = shl %lhs, %rhs + ret %4 + } +} +)"; + EXPECT_EQ(src, str()); + + auto* expect = R"( +%foo = func(%lhs:i32, %rhs:u32):i32 { + $B1: { + %4:u32 = bitcast %lhs + %5:u32 = shl %4, %rhs + %6:i32 = bitcast %5 + ret %6 + } +} +)"; + + SignedIntegerPolyfillConfig cfg{.signed_shiftleft = true}; + Run(SignedIntegerPolyfill, cfg); + EXPECT_EQ(expect, str()); +} + +TEST_F(IR_SignedIntegerPolyfillTest, Disabled_IntShift_Scalar) { + auto* lhs = b.FunctionParam<i32>("lhs"); + auto* rhs = b.FunctionParam<u32>("rhs"); + auto* func = b.Function("foo", ty.i32()); + func->SetParams({lhs, rhs}); + b.Append(func->Block(), [&] { + auto* result = b.ShiftLeft<i32>(lhs, rhs); + b.Return(func, result); + }); + + auto* src = R"( +%foo = func(%lhs:i32, %rhs:u32):i32 { + $B1: { + %4:i32 = shl %lhs, %rhs + ret %4 + } +} +)"; + EXPECT_EQ(src, str()); + + auto* expect = src; + SignedIntegerPolyfillConfig cfg{}; + Run(SignedIntegerPolyfill, cfg); + EXPECT_EQ(expect, str()); +} + +TEST_F(IR_SignedIntegerPolyfillTest, IntShift_Vector) { + auto* lhs = b.FunctionParam<vec4<i32>>("lhs"); + auto* rhs = b.FunctionParam<vec4<u32>>("rhs"); + auto* func = b.Function("foo", ty.vec4<i32>()); + func->SetParams({lhs, rhs}); + b.Append(func->Block(), [&] { + auto* result = b.ShiftLeft<vec4<i32>>(lhs, rhs); + b.Return(func, result); + }); + + auto* src = R"( +%foo = func(%lhs:vec4<i32>, %rhs:vec4<u32>):vec4<i32> { + $B1: { + %4:vec4<i32> = shl %lhs, %rhs + ret %4 + } +} +)"; + EXPECT_EQ(src, str()); + + auto* expect = R"( +%foo = func(%lhs:vec4<i32>, %rhs:vec4<u32>):vec4<i32> { + $B1: { + %4:vec4<u32> = bitcast %lhs + %5:vec4<u32> = shl %4, %rhs + %6:vec4<i32> = bitcast %5 + ret %6 + } +} +)"; + + SignedIntegerPolyfillConfig cfg{.signed_shiftleft = true}; + Run(SignedIntegerPolyfill, cfg); + + EXPECT_EQ(expect, str()); +} + +TEST_F(IR_SignedIntegerPolyfillTest, Disabled_IntShift_Vector) { + auto* lhs = b.FunctionParam<vec4<i32>>("lhs"); + auto* rhs = b.FunctionParam<vec4<u32>>("rhs"); + auto* func = b.Function("foo", ty.vec4<i32>()); + func->SetParams({lhs, rhs}); + b.Append(func->Block(), [&] { + auto* result = b.ShiftLeft<vec4<i32>>(lhs, rhs); + b.Return(func, result); + }); + + auto* src = R"( +%foo = func(%lhs:vec4<i32>, %rhs:vec4<u32>):vec4<i32> { + $B1: { + %4:vec4<i32> = shl %lhs, %rhs + ret %4 + } +} +)"; + EXPECT_EQ(src, str()); + + auto* expect = src; + SignedIntegerPolyfillConfig cfg{}; + Run(SignedIntegerPolyfill, cfg); + + EXPECT_EQ(expect, str()); +} + +} // namespace +} // namespace tint::core::ir::transform
diff --git a/src/tint/lang/glsl/writer/access_test.cc b/src/tint/lang/glsl/writer/access_test.cc index 1b647cc..dd874d4 100644 --- a/src/tint/lang/glsl/writer/access_test.cc +++ b/src/tint/lang/glsl/writer/access_test.cc
@@ -2354,9 +2354,10 @@ } void foo() { int arr[4] = int[4](0, 0, 0, 0); - uint v = min(uint((f() + 1)), 3u); + uint v = uint(f()); + uint v_1 = min(uint(int((v + uint(1)))), 3u); int y = g(); - int x = arr[v]; + int x = arr[v_1]; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/src/tint/lang/glsl/writer/builtin_test.cc b/src/tint/lang/glsl/writer/builtin_test.cc index 15a0364..d4f5b12 100644 --- a/src/tint/lang/glsl/writer/builtin_test.cc +++ b/src/tint/lang/glsl/writer/builtin_test.cc
@@ -325,7 +325,7 @@ atomicExchange(v.b, 0u); } barrier(); - int x = atomicAdd(v.a, -(123)); + int x = atomicAdd(v.a, int((~(uint(123)) + 1u))); uint y = atomicAdd(v.b, -(123u)); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; @@ -1492,7 +1492,20 @@ precision highp int; int tint_int_dot(ivec4 x, ivec4 y) { - return ((((x.x * y.x) + (x.y * y.y)) + (x.z * y.z)) + (x.w * y.w)); + uint v = uint(x.x); + int v_1 = int((v * uint(y.x))); + uint v_2 = uint(x.y); + int v_3 = int((v_2 * uint(y.y))); + uint v_4 = uint(v_1); + int v_5 = int((v_4 + uint(v_3))); + uint v_6 = uint(x.z); + int v_7 = int((v_6 * uint(y.z))); + uint v_8 = uint(v_5); + int v_9 = int((v_8 + uint(v_7))); + uint v_10 = uint(x.w); + int v_11 = int((v_10 * uint(y.w))); + uint v_12 = uint(v_9); + return int((v_12 + uint(v_11))); } void main() { ivec4 x = ivec4(2);
diff --git a/src/tint/lang/glsl/writer/raise/raise.cc b/src/tint/lang/glsl/writer/raise/raise.cc index 2baba12..f92a744 100644 --- a/src/tint/lang/glsl/writer/raise/raise.cc +++ b/src/tint/lang/glsl/writer/raise/raise.cc
@@ -46,6 +46,7 @@ #include "src/tint/lang/core/ir/transform/remove_terminator_args.h" #include "src/tint/lang/core/ir/transform/rename_conflicts.h" #include "src/tint/lang/core/ir/transform/robustness.h" +#include "src/tint/lang/core/ir/transform/signed_integer_polyfill.h" #include "src/tint/lang/core/ir/transform/std140.h" #include "src/tint/lang/core/ir/transform/value_to_let.h" #include "src/tint/lang/core/ir/transform/vectorize_scalar_matrix_constructors.h" @@ -195,6 +196,11 @@ RUN_TRANSFORM(raise::TexturePolyfill, module, tex_config); } + // must come before 'BitcastPolyfill' as this adds bitcasts + core::ir::transform::SignedIntegerPolyfillConfig signed_integer_cfg{ + .signed_negation = true, .signed_arithmetic = true, .signed_shiftleft = true}; + RUN_TRANSFORM(core::ir::transform::SignedIntegerPolyfill, module, signed_integer_cfg); + // Must come after BuiltinPolyfill as builtins can add bitcasts RUN_TRANSFORM(raise::BitcastPolyfill, module);
diff --git a/src/tint/lang/glsl/writer/unary_test.cc b/src/tint/lang/glsl/writer/unary_test.cc index f3e1a29..14bb73b 100644 --- a/src/tint/lang/glsl/writer/unary_test.cc +++ b/src/tint/lang/glsl/writer/unary_test.cc
@@ -106,7 +106,7 @@ layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { int left = 1; - int val = -(left); + int val = int((~(uint(left)) + 1u)); } )"); }
diff --git a/src/tint/lang/hlsl/writer/raise/raise.cc b/src/tint/lang/hlsl/writer/raise/raise.cc index 773b938..e263f2c 100644 --- a/src/tint/lang/hlsl/writer/raise/raise.cc +++ b/src/tint/lang/hlsl/writer/raise/raise.cc
@@ -46,6 +46,7 @@ #include "src/tint/lang/core/ir/transform/remove_terminator_args.h" #include "src/tint/lang/core/ir/transform/rename_conflicts.h" #include "src/tint/lang/core/ir/transform/robustness.h" +#include "src/tint/lang/core/ir/transform/signed_integer_polyfill.h" #include "src/tint/lang/core/ir/transform/value_to_let.h" #include "src/tint/lang/core/ir/transform/vectorize_scalar_matrix_constructors.h" #include "src/tint/lang/core/ir/transform/zero_init_workgroup_memory.h" @@ -248,6 +249,15 @@ } RUN_TRANSFORM(raise::BinaryPolyfill, module); + + // TODO(crbug.com/429211395): Resolve unsigned/signed casting issues with DXC. + constexpr bool kEnableSignedIntegerPolyfill = false; + if (kEnableSignedIntegerPolyfill) { + core::ir::transform::SignedIntegerPolyfillConfig signed_integer_cfg{ + .signed_negation = true, .signed_arithmetic = true, .signed_shiftleft = true}; + RUN_TRANSFORM(core::ir::transform::SignedIntegerPolyfill, module, signed_integer_cfg); + } + // BuiltinPolyfill must come after BinaryPolyfill and DecomposeStorageAccess as they add // builtins RUN_TRANSFORM(raise::BuiltinPolyfill, module);
diff --git a/src/tint/lang/msl/writer/raise/BUILD.bazel b/src/tint/lang/msl/writer/raise/BUILD.bazel index 0359e14..1507ef9 100644 --- a/src/tint/lang/msl/writer/raise/BUILD.bazel +++ b/src/tint/lang/msl/writer/raise/BUILD.bazel
@@ -48,7 +48,6 @@ "raise.cc", "shader_io.cc", "simd_ballot.cc", - "unary_polyfill.cc", ], hdrs = [ "argument_buffers.h", @@ -60,7 +59,6 @@ "raise.h", "shader_io.h", "simd_ballot.h", - "unary_polyfill.h", ], deps = [ "//src/tint/api/common", @@ -106,7 +104,6 @@ "packed_vec3_test.cc", "shader_io_test.cc", "simd_ballot_test.cc", - "unary_polyfill_test.cc", ], deps = [ "//src/tint/api/common",
diff --git a/src/tint/lang/msl/writer/raise/BUILD.cmake b/src/tint/lang/msl/writer/raise/BUILD.cmake index 0045e2c..d1d9bcd 100644 --- a/src/tint/lang/msl/writer/raise/BUILD.cmake +++ b/src/tint/lang/msl/writer/raise/BUILD.cmake
@@ -59,8 +59,6 @@ lang/msl/writer/raise/shader_io.h lang/msl/writer/raise/simd_ballot.cc lang/msl/writer/raise/simd_ballot.h - lang/msl/writer/raise/unary_polyfill.cc - lang/msl/writer/raise/unary_polyfill.h ) tint_target_add_dependencies(tint_lang_msl_writer_raise lib @@ -113,7 +111,6 @@ lang/msl/writer/raise/packed_vec3_test.cc lang/msl/writer/raise/shader_io_test.cc lang/msl/writer/raise/simd_ballot_test.cc - lang/msl/writer/raise/unary_polyfill_test.cc ) tint_target_add_dependencies(tint_lang_msl_writer_raise_test test
diff --git a/src/tint/lang/msl/writer/raise/BUILD.gn b/src/tint/lang/msl/writer/raise/BUILD.gn index b065074d0..71c53fc 100644 --- a/src/tint/lang/msl/writer/raise/BUILD.gn +++ b/src/tint/lang/msl/writer/raise/BUILD.gn
@@ -63,8 +63,6 @@ "shader_io.h", "simd_ballot.cc", "simd_ballot.h", - "unary_polyfill.cc", - "unary_polyfill.h", ] deps = [ "${dawn_root}/src/utils:utils", @@ -108,7 +106,6 @@ "packed_vec3_test.cc", "shader_io_test.cc", "simd_ballot_test.cc", - "unary_polyfill_test.cc", ] deps = [ "${dawn_root}/src/utils:utils",
diff --git a/src/tint/lang/msl/writer/raise/binary_polyfill.cc b/src/tint/lang/msl/writer/raise/binary_polyfill.cc index 3844a78..28081a6 100644 --- a/src/tint/lang/msl/writer/raise/binary_polyfill.cc +++ b/src/tint/lang/msl/writer/raise/binary_polyfill.cc
@@ -50,8 +50,7 @@ // Find the binary operators that need replacing. Vector<core::ir::CoreBinary*, 4> fmod_worklist; Vector<core::ir::CoreBinary*, 4> logical_bool_worklist; - Vector<core::ir::CoreBinary*, 4> signed_integer_arithmetic_worklist; - Vector<core::ir::CoreBinary*, 4> signed_integer_leftshift_worklist; + for (auto* inst : ir.Instructions()) { if (auto* binary = inst->As<core::ir::CoreBinary>()) { auto op = binary->Op(); @@ -61,13 +60,6 @@ } else if ((op == core::BinaryOp::kAnd || op == core::BinaryOp::kOr) && lhs_type->IsBoolScalarOrVector()) { logical_bool_worklist.Push(binary); - } else if ((op == core::BinaryOp::kAdd || op == core::BinaryOp::kMultiply || - op == core::BinaryOp::kSubtract) && - lhs_type->IsSignedIntegerScalarOrVector()) { - signed_integer_arithmetic_worklist.Push(binary); - } else if (op == core::BinaryOp::kShiftLeft && - lhs_type->IsSignedIntegerScalarOrVector()) { - signed_integer_leftshift_worklist.Push(binary); } } } @@ -79,12 +71,6 @@ for (auto* logical_bool : logical_bool_worklist) { LogicalBool(logical_bool); } - for (auto* signed_arith : signed_integer_arithmetic_worklist) { - SignedIntegerArithmetic(signed_arith); - } - for (auto* signed_shift_left : signed_integer_leftshift_worklist) { - SignedIntegerShiftLeft(signed_shift_left); - } } /// Replace a floating point modulo binary instruction with the equivalent MSL intrinsic. @@ -112,44 +98,6 @@ }); binary->Destroy(); } - - /// Replace a signed integer arithmetic instruction. - /// @param binary the signed integer arithmetic instruction - void SignedIntegerArithmetic(core::ir::CoreBinary* binary) { - // MSL does not define the behavior of signed integer overflow, so bitcast the operands to - // unsigned integers, perform the operation, and then bitcast the result back to a signed - // integer. - auto* signed_result_ty = binary->Result()->Type(); - auto* unsigned_result_ty = ty.MatchWidth(ty.u32(), signed_result_ty); - auto* unsigned_lhs_ty = ty.MatchWidth(ty.u32(), binary->LHS()->Type()); - auto* unsigned_rhs_ty = ty.MatchWidth(ty.u32(), binary->RHS()->Type()); - b.InsertBefore(binary, [&] { - auto* uint_lhs = b.Bitcast(unsigned_lhs_ty, binary->LHS()); - auto* uint_rhs = b.Bitcast(unsigned_rhs_ty, binary->RHS()); - auto* uint_binary = b.Binary(binary->Op(), unsigned_result_ty, uint_lhs, uint_rhs); - auto* bitcast = b.Bitcast(signed_result_ty, uint_binary); - binary->Result()->ReplaceAllUsesWith(bitcast->Result()); - }); - binary->Destroy(); - } - - /// Replace a signed integer shift left instruction. - /// @param binary the signed integer shift left instruction - void SignedIntegerShiftLeft(core::ir::CoreBinary* binary) { - // Left-shifting a negative integer is undefined behavior in C++14 and therefore potentially - // in MSL too, so we bitcast to an unsigned integer, perform the shift, and bitcast the - // result back to a signed integer. - auto* signed_ty = binary->Result()->Type(); - auto* unsigned_ty = ty.MatchWidth(ty.u32(), signed_ty); - b.InsertBefore(binary, [&] { - auto* unsigned_lhs = b.Bitcast(unsigned_ty, binary->LHS()); - auto* unsigned_binary = - b.Binary(binary->Op(), unsigned_ty, unsigned_lhs, binary->RHS()); - auto* bitcast = b.Bitcast(signed_ty, unsigned_binary); - binary->Result()->ReplaceAllUsesWith(bitcast->Result()); - }); - binary->Destroy(); - } }; } // namespace
diff --git a/src/tint/lang/msl/writer/raise/binary_polyfill_test.cc b/src/tint/lang/msl/writer/raise/binary_polyfill_test.cc index 5de21bf..20ceaaf 100644 --- a/src/tint/lang/msl/writer/raise/binary_polyfill_test.cc +++ b/src/tint/lang/msl/writer/raise/binary_polyfill_test.cc
@@ -285,299 +285,5 @@ EXPECT_EQ(expect, str()); } -TEST_F(MslWriter_BinaryPolyfillTest, IntAdd_Scalar) { - auto* lhs = b.FunctionParam<i32>("lhs"); - auto* rhs = b.FunctionParam<i32>("rhs"); - auto* func = b.Function("foo", ty.i32()); - func->SetParams({lhs, rhs}); - b.Append(func->Block(), [&] { - auto* result = b.Add<i32>(lhs, rhs); - b.Return(func, result); - }); - - auto* src = R"( -%foo = func(%lhs:i32, %rhs:i32):i32 { - $B1: { - %4:i32 = add %lhs, %rhs - ret %4 - } -} -)"; - EXPECT_EQ(src, str()); - - auto* expect = R"( -%foo = func(%lhs:i32, %rhs:i32):i32 { - $B1: { - %4:u32 = bitcast %lhs - %5:u32 = bitcast %rhs - %6:u32 = add %4, %5 - %7:i32 = bitcast %6 - ret %7 - } -} -)"; - - Run(BinaryPolyfill); - - EXPECT_EQ(expect, str()); -} - -TEST_F(MslWriter_BinaryPolyfillTest, IntMul_Scalar) { - auto* lhs = b.FunctionParam<i32>("lhs"); - auto* rhs = b.FunctionParam<i32>("rhs"); - auto* func = b.Function("foo", ty.i32()); - func->SetParams({lhs, rhs}); - b.Append(func->Block(), [&] { - auto* result = b.Multiply<i32>(lhs, rhs); - b.Return(func, result); - }); - - auto* src = R"( -%foo = func(%lhs:i32, %rhs:i32):i32 { - $B1: { - %4:i32 = mul %lhs, %rhs - ret %4 - } -} -)"; - EXPECT_EQ(src, str()); - - auto* expect = R"( -%foo = func(%lhs:i32, %rhs:i32):i32 { - $B1: { - %4:u32 = bitcast %lhs - %5:u32 = bitcast %rhs - %6:u32 = mul %4, %5 - %7:i32 = bitcast %6 - ret %7 - } -} -)"; - - Run(BinaryPolyfill); - - EXPECT_EQ(expect, str()); -} - -TEST_F(MslWriter_BinaryPolyfillTest, IntSub_Scalar) { - auto* lhs = b.FunctionParam<i32>("lhs"); - auto* rhs = b.FunctionParam<i32>("rhs"); - auto* func = b.Function("foo", ty.i32()); - func->SetParams({lhs, rhs}); - b.Append(func->Block(), [&] { - auto* result = b.Subtract<i32>(lhs, rhs); - b.Return(func, result); - }); - - auto* src = R"( -%foo = func(%lhs:i32, %rhs:i32):i32 { - $B1: { - %4:i32 = sub %lhs, %rhs - ret %4 - } -} -)"; - EXPECT_EQ(src, str()); - - auto* expect = R"( -%foo = func(%lhs:i32, %rhs:i32):i32 { - $B1: { - %4:u32 = bitcast %lhs - %5:u32 = bitcast %rhs - %6:u32 = sub %4, %5 - %7:i32 = bitcast %6 - ret %7 - } -} -)"; - - Run(BinaryPolyfill); - - EXPECT_EQ(expect, str()); -} - -TEST_F(MslWriter_BinaryPolyfillTest, IntAdd_Vector) { - auto* lhs = b.FunctionParam<vec4<i32>>("lhs"); - auto* rhs = b.FunctionParam<vec4<i32>>("rhs"); - auto* func = b.Function("foo", ty.vec4<i32>()); - func->SetParams({lhs, rhs}); - b.Append(func->Block(), [&] { - auto* result = b.Add<vec4<i32>>(lhs, rhs); - b.Return(func, result); - }); - - auto* src = R"( -%foo = func(%lhs:vec4<i32>, %rhs:vec4<i32>):vec4<i32> { - $B1: { - %4:vec4<i32> = add %lhs, %rhs - ret %4 - } -} -)"; - EXPECT_EQ(src, str()); - - auto* expect = R"( -%foo = func(%lhs:vec4<i32>, %rhs:vec4<i32>):vec4<i32> { - $B1: { - %4:vec4<u32> = bitcast %lhs - %5:vec4<u32> = bitcast %rhs - %6:vec4<u32> = add %4, %5 - %7:vec4<i32> = bitcast %6 - ret %7 - } -} -)"; - - Run(BinaryPolyfill); - - EXPECT_EQ(expect, str()); -} - -TEST_F(MslWriter_BinaryPolyfillTest, IntAdd_ScalarVector) { - auto* lhs = b.FunctionParam<i32>("lhs"); - auto* rhs = b.FunctionParam<vec4<i32>>("rhs"); - auto* func = b.Function("foo", ty.vec4<i32>()); - func->SetParams({lhs, rhs}); - b.Append(func->Block(), [&] { - auto* result = b.Add<vec4<i32>>(lhs, rhs); - b.Return(func, result); - }); - - auto* src = R"( -%foo = func(%lhs:i32, %rhs:vec4<i32>):vec4<i32> { - $B1: { - %4:vec4<i32> = add %lhs, %rhs - ret %4 - } -} -)"; - EXPECT_EQ(src, str()); - - auto* expect = R"( -%foo = func(%lhs:i32, %rhs:vec4<i32>):vec4<i32> { - $B1: { - %4:u32 = bitcast %lhs - %5:vec4<u32> = bitcast %rhs - %6:vec4<u32> = add %4, %5 - %7:vec4<i32> = bitcast %6 - ret %7 - } -} -)"; - - Run(BinaryPolyfill); - - EXPECT_EQ(expect, str()); -} - -TEST_F(MslWriter_BinaryPolyfillTest, IntAdd_VectorScalar) { - auto* lhs = b.FunctionParam<vec4<i32>>("lhs"); - auto* rhs = b.FunctionParam<i32>("rhs"); - auto* func = b.Function("foo", ty.vec4<i32>()); - func->SetParams({lhs, rhs}); - b.Append(func->Block(), [&] { - auto* result = b.Add<vec4<i32>>(lhs, rhs); - b.Return(func, result); - }); - - auto* src = R"( -%foo = func(%lhs:vec4<i32>, %rhs:i32):vec4<i32> { - $B1: { - %4:vec4<i32> = add %lhs, %rhs - ret %4 - } -} -)"; - EXPECT_EQ(src, str()); - - auto* expect = R"( -%foo = func(%lhs:vec4<i32>, %rhs:i32):vec4<i32> { - $B1: { - %4:vec4<u32> = bitcast %lhs - %5:u32 = bitcast %rhs - %6:vec4<u32> = add %4, %5 - %7:vec4<i32> = bitcast %6 - ret %7 - } -} -)"; - - Run(BinaryPolyfill); - - EXPECT_EQ(expect, str()); -} - -TEST_F(MslWriter_BinaryPolyfillTest, IntShift_Scalar) { - auto* lhs = b.FunctionParam<i32>("lhs"); - auto* rhs = b.FunctionParam<u32>("rhs"); - auto* func = b.Function("foo", ty.i32()); - func->SetParams({lhs, rhs}); - b.Append(func->Block(), [&] { - auto* result = b.ShiftLeft<i32>(lhs, rhs); - b.Return(func, result); - }); - - auto* src = R"( -%foo = func(%lhs:i32, %rhs:u32):i32 { - $B1: { - %4:i32 = shl %lhs, %rhs - ret %4 - } -} -)"; - EXPECT_EQ(src, str()); - - auto* expect = R"( -%foo = func(%lhs:i32, %rhs:u32):i32 { - $B1: { - %4:u32 = bitcast %lhs - %5:u32 = shl %4, %rhs - %6:i32 = bitcast %5 - ret %6 - } -} -)"; - - Run(BinaryPolyfill); - - EXPECT_EQ(expect, str()); -} - -TEST_F(MslWriter_BinaryPolyfillTest, IntShift_Vector) { - auto* lhs = b.FunctionParam<vec4<i32>>("lhs"); - auto* rhs = b.FunctionParam<vec4<u32>>("rhs"); - auto* func = b.Function("foo", ty.vec4<i32>()); - func->SetParams({lhs, rhs}); - b.Append(func->Block(), [&] { - auto* result = b.ShiftLeft<vec4<i32>>(lhs, rhs); - b.Return(func, result); - }); - - auto* src = R"( -%foo = func(%lhs:vec4<i32>, %rhs:vec4<u32>):vec4<i32> { - $B1: { - %4:vec4<i32> = shl %lhs, %rhs - ret %4 - } -} -)"; - EXPECT_EQ(src, str()); - - auto* expect = R"( -%foo = func(%lhs:vec4<i32>, %rhs:vec4<u32>):vec4<i32> { - $B1: { - %4:vec4<u32> = bitcast %lhs - %5:vec4<u32> = shl %4, %rhs - %6:vec4<i32> = bitcast %5 - ret %6 - } -} -)"; - - Run(BinaryPolyfill); - - EXPECT_EQ(expect, str()); -} - } // namespace } // namespace tint::msl::writer::raise
diff --git a/src/tint/lang/msl/writer/raise/raise.cc b/src/tint/lang/msl/writer/raise/raise.cc index aead774..004d8ae 100644 --- a/src/tint/lang/msl/writer/raise/raise.cc +++ b/src/tint/lang/msl/writer/raise/raise.cc
@@ -42,6 +42,7 @@ #include "src/tint/lang/core/ir/transform/remove_terminator_args.h" #include "src/tint/lang/core/ir/transform/rename_conflicts.h" #include "src/tint/lang/core/ir/transform/robustness.h" +#include "src/tint/lang/core/ir/transform/signed_integer_polyfill.h" #include "src/tint/lang/core/ir/transform/value_to_let.h" #include "src/tint/lang/core/ir/transform/vectorize_scalar_matrix_constructors.h" #include "src/tint/lang/core/ir/transform/vertex_pulling.h" @@ -55,7 +56,6 @@ #include "src/tint/lang/msl/writer/raise/packed_vec3.h" #include "src/tint/lang/msl/writer/raise/shader_io.h" #include "src/tint/lang/msl/writer/raise/simd_ballot.h" -#include "src/tint/lang/msl/writer/raise/unary_polyfill.h" namespace tint::msl::writer { @@ -157,9 +157,12 @@ } RUN_TRANSFORM(raise::ModuleScopeVars, module); - RUN_TRANSFORM(raise::UnaryPolyfill, module); RUN_TRANSFORM(raise::BinaryPolyfill, module); RUN_TRANSFORM(raise::BuiltinPolyfill, module); + // After 'BuiltinPolyfill' as that transform can introduce signed dot products. + core::ir::transform::SignedIntegerPolyfillConfig signed_integer_cfg{ + .signed_negation = true, .signed_arithmetic = true, .signed_shiftleft = true}; + RUN_TRANSFORM(core::ir::transform::SignedIntegerPolyfill, module, signed_integer_cfg); core::ir::transform::BuiltinScalarizeConfig scalarize_config{ .scalarize_clamp = options.scalarize_max_min_clamp,
diff --git a/src/tint/lang/msl/writer/raise/unary_polyfill.cc b/src/tint/lang/msl/writer/raise/unary_polyfill.cc deleted file mode 100644 index 2261207..0000000 --- a/src/tint/lang/msl/writer/raise/unary_polyfill.cc +++ /dev/null
@@ -1,106 +0,0 @@ -// Copyright 2024 The Dawn & Tint Authors -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// 3. Neither the name of the copyright holder nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#include "src/tint/lang/msl/writer/raise/unary_polyfill.h" - -#include "src/tint/lang/core/ir/builder.h" -#include "src/tint/lang/core/ir/validator.h" - -using namespace tint::core::fluent_types; // NOLINT - -namespace tint::msl::writer::raise { -namespace { - -/// PIMPL state for the transform. -struct State { - /// The IR module. - core::ir::Module& ir; - - /// The IR builder. - core::ir::Builder b{ir}; - - /// The type manager. - core::type::Manager& ty{ir.Types()}; - - /// Process the module. - void Process() { - // Find the unary operators that need replacing. - Vector<core::ir::Unary*, 4> signed_int_negate_worklist; - for (auto* inst : ir.Instructions()) { - if (auto* unary = inst->As<core::ir::Unary>()) { - auto op = unary->Op(); - auto* type = unary->Val()->Type(); - if (op == core::UnaryOp::kNegation && type->IsSignedIntegerScalarOrVector()) { - signed_int_negate_worklist.Push(unary); - } - } - } - - // Replace the instructions that we found. - for (auto* signed_int_negate : signed_int_negate_worklist) { - SignedIntegerNegation(signed_int_negate); - } - } - - /// Replace a signed integer negation to avoid undefined behavior. - /// @param unary the unary instruction - void SignedIntegerNegation(core::ir::Unary* unary) { - // Replace `-x` with `as_type<int>((~as_type<uint>(x)) + 1)`. - auto* signed_type = unary->Result()->Type(); - auto* unsigned_type = ty.MatchWidth(ty.u32(), signed_type); - b.InsertBefore(unary, [&] { - auto* unsigned_value = b.Bitcast(unsigned_type, unary->Val()); - auto* complement = b.Complement(unsigned_type, unsigned_value); - auto* plus_one = b.Add(unsigned_type, complement, b.MatchWidth(u32(1), unsigned_type)); - auto* result = b.Bitcast(signed_type, plus_one); - unary->Result()->ReplaceAllUsesWith(result->Result()); - }); - unary->Destroy(); - } -}; - -} // namespace - -Result<SuccessType> UnaryPolyfill(core::ir::Module& ir) { - auto result = - ValidateAndDumpIfNeeded(ir, "msl.UnaryPolyfill", - core::ir::Capabilities{ - core::ir::Capability::kAllowPointersAndHandlesInStructures, - core::ir::Capability::kAllowPrivateVarsInFunctions, - core::ir::Capability::kAllowAnyLetType, - core::ir::Capability::kAllowWorkspacePointerInputToEntryPoint, - }); - if (result != Success) { - return result.Failure(); - } - - State{ir}.Process(); - - return Success; -} - -} // namespace tint::msl::writer::raise
diff --git a/src/tint/lang/msl/writer/raise/unary_polyfill.h b/src/tint/lang/msl/writer/raise/unary_polyfill.h deleted file mode 100644 index 6d2820a..0000000 --- a/src/tint/lang/msl/writer/raise/unary_polyfill.h +++ /dev/null
@@ -1,48 +0,0 @@ -// Copyright 2024 The Dawn & Tint Authors -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// 3. Neither the name of the copyright holder nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#ifndef SRC_TINT_LANG_MSL_WRITER_RAISE_UNARY_POLYFILL_H_ -#define SRC_TINT_LANG_MSL_WRITER_RAISE_UNARY_POLYFILL_H_ - -#include "src/tint/utils/result.h" - -// Forward declarations. -namespace tint::core::ir { -class Module; -} // namespace tint::core::ir - -namespace tint::msl::writer::raise { - -/// UnaryPolyfill is a transform that replaces unary instructions with polyfills and calls to MSL -/// backend intrinsic functions. -/// @param module the module to transform -/// @returns success or failure -Result<SuccessType> UnaryPolyfill(core::ir::Module& module); - -} // namespace tint::msl::writer::raise - -#endif // SRC_TINT_LANG_MSL_WRITER_RAISE_UNARY_POLYFILL_H_
diff --git a/src/tint/lang/msl/writer/raise/unary_polyfill_test.cc b/src/tint/lang/msl/writer/raise/unary_polyfill_test.cc deleted file mode 100644 index 11088d1..0000000 --- a/src/tint/lang/msl/writer/raise/unary_polyfill_test.cc +++ /dev/null
@@ -1,143 +0,0 @@ -// Copyright 2024 The Dawn & Tint Authors -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// 3. Neither the name of the copyright holder nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#include "src/tint/lang/msl/writer/raise/unary_polyfill.h" - -#include <utility> - -#include "gtest/gtest.h" -#include "src/tint/lang/core/fluent_types.h" -#include "src/tint/lang/core/ir/transform/helper_test.h" - -using namespace tint::core::fluent_types; // NOLINT -using namespace tint::core::number_suffixes; // NOLINT - -namespace tint::msl::writer::raise { -namespace { - -using MslWriter_UnaryPolyfillTest = core::ir::transform::TransformTest; - -TEST_F(MslWriter_UnaryPolyfillTest, Negation_F32) { - auto* value = b.FunctionParam<f32>("value"); - auto* func = b.Function("foo", ty.f32()); - func->SetParams({value}); - b.Append(func->Block(), [&] { - auto* result = b.Negation<f32>(value); - b.Return(func, result); - }); - - auto* src = R"( -%foo = func(%value:f32):f32 { - $B1: { - %3:f32 = negation %value - ret %3 - } -} -)"; - EXPECT_EQ(src, str()); - - auto* expect = src; - - Run(UnaryPolyfill); - - EXPECT_EQ(expect, str()); -} - -TEST_F(MslWriter_UnaryPolyfillTest, Negation_I32_Scalar) { - auto* value = b.FunctionParam<i32>("value"); - auto* func = b.Function("foo", ty.i32()); - func->SetParams({value}); - b.Append(func->Block(), [&] { - auto* result = b.Negation<i32>(value); - b.Return(func, result); - }); - - auto* src = R"( -%foo = func(%value:i32):i32 { - $B1: { - %3:i32 = negation %value - ret %3 - } -} -)"; - EXPECT_EQ(src, str()); - - auto* expect = R"( -%foo = func(%value:i32):i32 { - $B1: { - %3:u32 = bitcast %value - %4:u32 = complement %3 - %5:u32 = add %4, 1u - %6:i32 = bitcast %5 - ret %6 - } -} -)"; - - Run(UnaryPolyfill); - - EXPECT_EQ(expect, str()); -} - -TEST_F(MslWriter_UnaryPolyfillTest, Negation_I32_Vector) { - auto* value = b.FunctionParam<vec4<i32>>("value"); - auto* func = b.Function("foo", ty.vec4<i32>()); - func->SetParams({value}); - b.Append(func->Block(), [&] { - auto* result = b.Negation<vec4<i32>>(value); - b.Return(func, result); - }); - - auto* src = R"( -%foo = func(%value:vec4<i32>):vec4<i32> { - $B1: { - %3:vec4<i32> = negation %value - ret %3 - } -} -)"; - EXPECT_EQ(src, str()); - - auto* expect = R"( -%foo = func(%value:vec4<i32>):vec4<i32> { - $B1: { - %3:vec4<u32> = bitcast %value - %4:vec4<u32> = complement %3 - %5:vec4<u32> = add %4, vec4<u32>(1u) - %6:vec4<i32> = bitcast %5 - ret %6 - } -} -)"; - - Run(UnaryPolyfill); - - EXPECT_EQ(expect, str()); -} - -} // namespace -} // namespace tint::msl::writer::raise
diff --git a/src/tint/lang/spirv/writer/binary_test.cc b/src/tint/lang/spirv/writer/binary_test.cc index a14b39b..489f952 100644 --- a/src/tint/lang/spirv/writer/binary_test.cc +++ b/src/tint/lang/spirv/writer/binary_test.cc
@@ -110,14 +110,9 @@ INSTANTIATE_TEST_SUITE_P( SpirvWriterTest_Binary_I32, Arithmetic_Bitwise, - testing::Values(BinaryTestCase{kI32, core::BinaryOp::kAdd, "OpIAdd", "int"}, - BinaryTestCase{kI32, core::BinaryOp::kSubtract, "OpISub", "int"}, - BinaryTestCase{kI32, core::BinaryOp::kMultiply, "OpIMul", "int"}, - BinaryTestCase{kI32, core::BinaryOp::kAnd, "OpBitwiseAnd", "int"}, + testing::Values(BinaryTestCase{kI32, core::BinaryOp::kAnd, "OpBitwiseAnd", "int"}, BinaryTestCase{kI32, core::BinaryOp::kOr, "OpBitwiseOr", "int"}, BinaryTestCase{kI32, core::BinaryOp::kXor, "OpBitwiseXor", "int"}, - BinaryTestCase{kI32, kI32, kU32, core::BinaryOp::kShiftLeft, - "OpShiftLeftLogical", "int"}, BinaryTestCase{kI32, kI32, kU32, core::BinaryOp::kShiftRight, "OpShiftRightArithmetic", "int"})); INSTANTIATE_TEST_SUITE_P( @@ -349,8 +344,10 @@ }); ASSERT_TRUE(Generate()) << Error() << output_; - EXPECT_INST("%sub = OpISub %int %int_1 %int_2"); - EXPECT_INST("%add = OpIAdd %int %sub %sub"); + EXPECT_INST("OpBitcast %uint %int_1"); + EXPECT_INST("OpBitcast %uint %int_2"); + EXPECT_INST("OpISub %uint %6 %9"); + EXPECT_INST("OpIAdd %uint %13 %14"); } TEST_F(SpirvWriterTest, Divide_u32_u32) { @@ -550,7 +547,6 @@ OpFunctionEnd )"); } - TEST_F(SpirvWriterTest, Modulo_i32_i32) { Vector<core::ir::FunctionParam*, 4> args; args.Push(b.FunctionParam("lhs", ty.i32())); @@ -586,10 +582,219 @@ %20 = OpLogicalOr %bool %12 %19 %21 = OpSelect %int %20 %int_1 %rhs_0 %23 = OpSDiv %int %lhs_0 %21 - %24 = OpIMul %int %23 %21 - %25 = OpISub %int %lhs_0 %24 - OpReturnValue %25 + %25 = OpBitcast %uint %23 + %26 = OpBitcast %uint %21 + %27 = OpIMul %uint %25 %26 + %28 = OpBitcast %int %27 + %29 = OpBitcast %uint %lhs_0 + %30 = OpBitcast %uint %28 + %31 = OpISub %uint %29 %30 + %32 = OpBitcast %int %31 + OpReturnValue %32 OpFunctionEnd + + ; Function unused_entry_point +%unused_entry_point = OpFunction %void None %35 + %36 = OpLabel + OpReturn + OpFunctionEnd +)"); +} + +TEST_F(SpirvWriterTest, Add_i32_i32) { + Vector<core::ir::FunctionParam*, 4> args; + args.Push(b.FunctionParam("lhs", ty.i32())); + args.Push(b.FunctionParam("rhs", ty.i32())); + auto* func = b.Function("foo", ty.i32()); + func->SetParams(args); + b.Append(func->Block(), [&] { + auto* result = b.Binary(core::BinaryOp::kAdd, ty.i32(), args[0], args[1]); + b.Return(func, result); + mod.SetName(result, "result"); + }); + + ASSERT_TRUE(Generate()) << Error() << output_; + EXPECT_INST(R"( + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + + ; Debug Information + OpName %foo "foo" ; id %1 + OpName %lhs "lhs" ; id %3 + OpName %rhs "rhs" ; id %4 + OpName %unused_entry_point "unused_entry_point" ; id %12 + + ; Types, variables and constants + %int = OpTypeInt 32 1 + %5 = OpTypeFunction %int %int %int + %uint = OpTypeInt 32 0 + %void = OpTypeVoid + %14 = OpTypeFunction %void + + ; Function foo + %foo = OpFunction %int None %5 + %lhs = OpFunctionParameter %int + %rhs = OpFunctionParameter %int + %6 = OpLabel + %8 = OpBitcast %uint %lhs + %9 = OpBitcast %uint %rhs + %10 = OpIAdd %uint %8 %9 + %11 = OpBitcast %int %10 + OpReturnValue %11 + OpFunctionEnd + + ; Function unused_entry_point +%unused_entry_point = OpFunction %void None %14 + %15 = OpLabel +)"); +} + +TEST_F(SpirvWriterTest, Sub_i32_i32) { + Vector<core::ir::FunctionParam*, 4> args; + args.Push(b.FunctionParam("lhs", ty.i32())); + args.Push(b.FunctionParam("rhs", ty.i32())); + auto* func = b.Function("foo", ty.i32()); + func->SetParams(args); + b.Append(func->Block(), [&] { + auto* result = b.Binary(core::BinaryOp::kSubtract, ty.i32(), args[0], args[1]); + b.Return(func, result); + mod.SetName(result, "result"); + }); + + ASSERT_TRUE(Generate()) << Error() << output_; + EXPECT_INST(R"( + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + + ; Debug Information + OpName %foo "foo" ; id %1 + OpName %lhs "lhs" ; id %3 + OpName %rhs "rhs" ; id %4 + OpName %unused_entry_point "unused_entry_point" ; id %12 + + ; Types, variables and constants + %int = OpTypeInt 32 1 + %5 = OpTypeFunction %int %int %int + %uint = OpTypeInt 32 0 + %void = OpTypeVoid + %14 = OpTypeFunction %void + + ; Function foo + %foo = OpFunction %int None %5 + %lhs = OpFunctionParameter %int + %rhs = OpFunctionParameter %int + %6 = OpLabel + %8 = OpBitcast %uint %lhs + %9 = OpBitcast %uint %rhs + %10 = OpISub %uint %8 %9 + %11 = OpBitcast %int %10 + OpReturnValue %11 + OpFunctionEnd + + ; Function unused_entry_point +%unused_entry_point = OpFunction %void None %14 + %15 = OpLabel +)"); +} + +TEST_F(SpirvWriterTest, Mul_i32_i32) { + Vector<core::ir::FunctionParam*, 4> args; + args.Push(b.FunctionParam("lhs", ty.i32())); + args.Push(b.FunctionParam("rhs", ty.i32())); + auto* func = b.Function("foo", ty.i32()); + func->SetParams(args); + b.Append(func->Block(), [&] { + auto* result = b.Binary(core::BinaryOp::kMultiply, ty.i32(), args[0], args[1]); + b.Return(func, result); + mod.SetName(result, "result"); + }); + + ASSERT_TRUE(Generate()) << Error() << output_; + EXPECT_INST(R"( + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + + ; Debug Information + OpName %foo "foo" ; id %1 + OpName %lhs "lhs" ; id %3 + OpName %rhs "rhs" ; id %4 + OpName %unused_entry_point "unused_entry_point" ; id %12 + + ; Types, variables and constants + %int = OpTypeInt 32 1 + %5 = OpTypeFunction %int %int %int + %uint = OpTypeInt 32 0 + %void = OpTypeVoid + %14 = OpTypeFunction %void + + ; Function foo + %foo = OpFunction %int None %5 + %lhs = OpFunctionParameter %int + %rhs = OpFunctionParameter %int + %6 = OpLabel + %8 = OpBitcast %uint %lhs + %9 = OpBitcast %uint %rhs + %10 = OpIMul %uint %8 %9 + %11 = OpBitcast %int %10 + OpReturnValue %11 + OpFunctionEnd + + ; Function unused_entry_point +%unused_entry_point = OpFunction %void None %14 + %15 = OpLabel +)"); +} + +TEST_F(SpirvWriterTest, ShiftLeft_i32_u32) { + Vector<core::ir::FunctionParam*, 4> args; + args.Push(b.FunctionParam("lhs", ty.i32())); + args.Push(b.FunctionParam("rhs", ty.u32())); + auto* func = b.Function("foo", ty.i32()); + func->SetParams(args); + b.Append(func->Block(), [&] { + auto* result = b.Binary(core::BinaryOp::kShiftLeft, ty.i32(), args[0], args[1]); + b.Return(func, result); + mod.SetName(result, "result"); + }); + + ASSERT_TRUE(Generate()) << Error() << output_; + EXPECT_INST(R"( + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" + OpExecutionMode %unused_entry_point LocalSize 1 1 1 + + ; Debug Information + OpName %foo "foo" ; id %1 + OpName %lhs "lhs" ; id %3 + OpName %rhs "rhs" ; id %5 + OpName %unused_entry_point "unused_entry_point" ; id %13 + + ; Types, variables and constants + %int = OpTypeInt 32 1 + %uint = OpTypeInt 32 0 + %6 = OpTypeFunction %int %int %uint + %uint_31 = OpConstant %uint 31 + %void = OpTypeVoid + %15 = OpTypeFunction %void + + ; Function foo + %foo = OpFunction %int None %6 + %lhs = OpFunctionParameter %int + %rhs = OpFunctionParameter %uint + %7 = OpLabel + %8 = OpBitwiseAnd %uint %rhs %uint_31 + %10 = OpBitcast %uint %lhs + %11 = OpShiftLeftLogical %uint %10 %8 + %12 = OpBitcast %int %11 + OpReturnValue %12 + OpFunctionEnd + + ; Function unused_entry_point +%unused_entry_point = OpFunction %void None %15 + %16 = OpLabel )"); } @@ -630,9 +835,21 @@ %26 = OpLogicalOr %v4bool %15 %25 %27 = OpSelect %v4int %26 %28 %rhs_0 %30 = OpSDiv %v4int %lhs_0 %27 - %31 = OpIMul %v4int %30 %27 - %32 = OpISub %v4int %lhs_0 %31 - OpReturnValue %32 + %33 = OpBitcast %v4uint %30 + %34 = OpBitcast %v4uint %27 + %35 = OpIMul %v4uint %33 %34 + %36 = OpBitcast %v4int %35 + %37 = OpBitcast %v4uint %lhs_0 + %38 = OpBitcast %v4uint %36 + %39 = OpISub %v4uint %37 %38 + %40 = OpBitcast %v4int %39 + OpReturnValue %40 + OpFunctionEnd + + ; Function unused_entry_point +%unused_entry_point = OpFunction %void None %43 + %44 = OpLabel + OpReturn OpFunctionEnd )"); } @@ -674,9 +891,21 @@ %26 = OpLogicalOr %v4bool %15 %25 %27 = OpSelect %v4int %26 %28 %rhs_0 %30 = OpSDiv %v4int %lhs_0 %27 - %31 = OpIMul %v4int %30 %27 - %32 = OpISub %v4int %lhs_0 %31 - OpReturnValue %32 + %33 = OpBitcast %v4uint %30 + %34 = OpBitcast %v4uint %27 + %35 = OpIMul %v4uint %33 %34 + %36 = OpBitcast %v4int %35 + %37 = OpBitcast %v4uint %lhs_0 + %38 = OpBitcast %v4uint %36 + %39 = OpISub %v4uint %37 %38 + %40 = OpBitcast %v4int %39 + OpReturnValue %40 + OpFunctionEnd + + ; Function unused_entry_point +%unused_entry_point = OpFunction %void None %43 + %44 = OpLabel + OpReturn OpFunctionEnd )"); }
diff --git a/src/tint/lang/spirv/writer/builtin_test.cc b/src/tint/lang/spirv/writer/builtin_test.cc index b799b74..f0965c5 100644 --- a/src/tint/lang/spirv/writer/builtin_test.cc +++ b/src/tint/lang/spirv/writer/builtin_test.cc
@@ -1287,11 +1287,20 @@ EXPECT_INST(R"( %8 = OpCompositeExtract %int %arg1 0 %9 = OpCompositeExtract %int %arg2 0 - %10 = OpIMul %int %8 %9 - %11 = OpCompositeExtract %int %arg1 1 - %12 = OpCompositeExtract %int %arg2 1 - %13 = OpIMul %int %11 %12 - %result = OpIAdd %int %10 %13 + %11 = OpBitcast %uint %8 + %12 = OpBitcast %uint %9 + %13 = OpIMul %uint %11 %12 + %14 = OpBitcast %int %13 + %15 = OpCompositeExtract %int %arg1 1 + %16 = OpCompositeExtract %int %arg2 1 + %17 = OpBitcast %uint %15 + %18 = OpBitcast %uint %16 + %19 = OpIMul %uint %17 %18 + %20 = OpBitcast %int %19 + %21 = OpBitcast %uint %14 + %22 = OpBitcast %uint %20 + %23 = OpIAdd %uint %21 %22 + %24 = OpBitcast %int %23 )"); }
diff --git a/src/tint/lang/spirv/writer/function_test.cc b/src/tint/lang/spirv/writer/function_test.cc index 8a9deae..bda26a9 100644 --- a/src/tint/lang/spirv/writer/function_test.cc +++ b/src/tint/lang/spirv/writer/function_test.cc
@@ -241,16 +241,26 @@ ASSERT_TRUE(Generate()) << Error() << output_; EXPECT_INST(R"( %5 = OpTypeFunction %int %int %int + %uint = OpTypeInt 32 0 %void = OpTypeVoid - %10 = OpTypeFunction %void + %14 = OpTypeFunction %void ; Function foo %foo = OpFunction %int None %5 %x = OpFunctionParameter %int %y = OpFunctionParameter %int %6 = OpLabel - %7 = OpIAdd %int %x %y - OpReturnValue %7 + %8 = OpBitcast %uint %x + %9 = OpBitcast %uint %y + %10 = OpIAdd %uint %8 %9 + %11 = OpBitcast %int %10 + OpReturnValue %11 + OpFunctionEnd + + ; Function unused_entry_point +%unused_entry_point = OpFunction %void None %14 + %15 = OpLabel + OpReturn OpFunctionEnd )"); }
diff --git a/src/tint/lang/spirv/writer/if_test.cc b/src/tint/lang/spirv/writer/if_test.cc index d9eae1e..641f748 100644 --- a/src/tint/lang/spirv/writer/if_test.cc +++ b/src/tint/lang/spirv/writer/if_test.cc
@@ -78,7 +78,10 @@ OpSelectionMerge %5 None OpBranchConditional %true %6 %5 %6 = OpLabel - %9 = OpIAdd %int %int_1 %int_1 + %10 = OpBitcast %uint %int_1 + %13 = OpBitcast %uint %int_1 + %14 = OpIAdd %uint %10 %13 + %15 = OpBitcast %int %14 OpBranch %5 %5 = OpLabel OpReturn @@ -106,7 +109,10 @@ OpSelectionMerge %5 None OpBranchConditional %true %5 %6 %6 = OpLabel - %9 = OpIAdd %int %int_1 %int_1 + %10 = OpBitcast %uint %int_1 + %13 = OpBitcast %uint %int_1 + %14 = OpIAdd %uint %10 %13 + %15 = OpBitcast %int %14 OpBranch %5 %5 = OpLabel OpReturn
diff --git a/src/tint/lang/spirv/writer/loop_test.cc b/src/tint/lang/spirv/writer/loop_test.cc index d4627ae..c3d3d7b 100644 --- a/src/tint/lang/spirv/writer/loop_test.cc +++ b/src/tint/lang/spirv/writer/loop_test.cc
@@ -594,12 +594,15 @@ OpLoopMerge %9 %7 None OpBranch %6 %6 = OpLabel - %14 = OpIAdd %int %11 %int_1 + %16 = OpBitcast %uint %11 + %17 = OpBitcast %uint %int_1 + %18 = OpIAdd %uint %16 %17 + %14 = OpBitcast %int %18 OpBranch %7 %7 = OpLabel %13 = OpPhi %int %14 %6 - %15 = OpSGreaterThan %bool %13 %int_5 - OpBranchConditional %15 %9 %8 + %19 = OpSGreaterThan %bool %13 %int_5 + OpBranchConditional %19 %9 %8 %9 = OpLabel OpReturn OpFunctionEnd @@ -649,14 +652,17 @@ OpLoopMerge %9 %7 None OpBranch %6 %6 = OpLabel - %18 = OpIAdd %int %11 %int_1 + %21 = OpBitcast %uint %11 + %22 = OpBitcast %uint %int_1 + %23 = OpIAdd %uint %21 %22 + %18 = OpBitcast %int %23 OpBranch %7 %7 = OpLabel %13 = OpPhi %int %18 %6 %19 = OpPhi %bool %15 %6 - %20 = OpSGreaterThan %bool %13 %int_5 + %24 = OpSGreaterThan %bool %13 %int_5 %17 = OpLogicalNot %bool %19 - OpBranchConditional %20 %9 %8 + OpBranchConditional %24 %9 %8 %9 = OpLabel OpReturn OpFunctionEnd
diff --git a/src/tint/lang/spirv/writer/raise/raise.cc b/src/tint/lang/spirv/writer/raise/raise.cc index 7506b7e..da2b0a8 100644 --- a/src/tint/lang/spirv/writer/raise/raise.cc +++ b/src/tint/lang/spirv/writer/raise/raise.cc
@@ -44,6 +44,7 @@ #include "src/tint/lang/core/ir/transform/preserve_padding.h" #include "src/tint/lang/core/ir/transform/prevent_infinite_loops.h" #include "src/tint/lang/core/ir/transform/robustness.h" +#include "src/tint/lang/core/ir/transform/signed_integer_polyfill.h" #include "src/tint/lang/core/ir/transform/std140.h" #include "src/tint/lang/core/ir/transform/vectorize_scalar_matrix_constructors.h" #include "src/tint/lang/core/ir/transform/zero_init_workgroup_memory.h" @@ -187,6 +188,10 @@ .scalarize_min = options.scalarize_max_min_clamp}; RUN_TRANSFORM(core::ir::transform::BuiltinScalarize, module, scalarize_config); + core::ir::transform::SignedIntegerPolyfillConfig signed_integer_cfg{ + .signed_negation = true, .signed_arithmetic = true, .signed_shiftleft = true}; + RUN_TRANSFORM(core::ir::transform::SignedIntegerPolyfill, module, signed_integer_cfg); + // kAllowAnyInputAttachmentIndexType required after ExpandImplicitSplats RUN_TRANSFORM(raise::HandleMatrixArithmetic, module); RUN_TRANSFORM(raise::MergeReturn, module);
diff --git a/src/tint/lang/spirv/writer/unary_test.cc b/src/tint/lang/spirv/writer/unary_test.cc index 43fb04e..0013c64 100644 --- a/src/tint/lang/spirv/writer/unary_test.cc +++ b/src/tint/lang/spirv/writer/unary_test.cc
@@ -82,9 +82,74 @@ Arithmetic, testing::Values(UnaryTestCase{kI32, core::UnaryOp::kComplement, "OpNot", "int"}, UnaryTestCase{kU32, core::UnaryOp::kComplement, "OpNot", "uint"}, - UnaryTestCase{kI32, core::UnaryOp::kNegation, "OpSNegate", "int"}, UnaryTestCase{kF32, core::UnaryOp::kNegation, "OpFNegate", "float"}, UnaryTestCase{kF16, core::UnaryOp::kNegation, "OpFNegate", "half"})); +TEST_F(SpirvWriterTest, Unary_Negate_i32) { + auto* arg = b.FunctionParam("arg", MakeVectorType(kI32)); + auto* func = b.Function("foo", ty.void_()); + func->SetParams({arg}); + b.Append(func->Block(), [&] { + auto* result = b.Unary(core::UnaryOp::kNegation, MakeVectorType(kI32), arg); + b.Return(func); + mod.SetName(result, "result"); + }); + + ASSERT_TRUE(Generate()) << Error() << output_; + EXPECT_INST(R"( + %void = OpTypeVoid + %int = OpTypeInt 32 1 + %v2int = OpTypeVector %int 2 + %6 = OpTypeFunction %void %v2int + %uint = OpTypeInt 32 0 + %v2uint = OpTypeVector %uint 2 + %uint_1 = OpConstant %uint 1 + %13 = OpConstantComposite %v2uint %uint_1 %uint_1 + %17 = OpTypeFunction %void + + ; Function foo + %foo = OpFunction %void None %6 + %arg = OpFunctionParameter %v2int + %7 = OpLabel + %10 = OpBitcast %v2uint %arg + %11 = OpNot %v2uint %10 + %12 = OpIAdd %v2uint %11 %13 + %15 = OpBitcast %v2int %12 + OpReturn + OpFunctionEnd + + ; Function unused_entry_point +%unused_entry_point = OpFunction %void None %17 + %18 = OpLabel + OpReturn + OpFunctionEnd +)"); +} + +TEST_F(SpirvWriterTest, Unary_Negate_Vector_i32) { + auto* arg = b.FunctionParam("arg", MakeScalarType(kI32)); + auto* func = b.Function("foo", ty.void_()); + func->SetParams({arg}); + b.Append(func->Block(), [&] { + auto* result = b.Unary(core::UnaryOp::kNegation, MakeScalarType(kI32), arg); + b.Return(func); + mod.SetName(result, "result"); + }); + + ASSERT_TRUE(Generate()) << Error() << output_; + EXPECT_INST(R"( + %foo = OpFunction %void None %5 + %arg = OpFunctionParameter %int + %6 = OpLabel + %8 = OpBitcast %uint %arg + %9 = OpNot %uint %8 + %10 = OpIAdd %uint %9 %uint_1 + %12 = OpBitcast %int %10 + OpReturn + OpFunctionEnd + + )"); +} + } // namespace } // namespace tint::spirv::writer
diff --git a/src/tint/lang/spirv/writer/var_test.cc b/src/tint/lang/spirv/writer/var_test.cc index 92ceba6..816d91d 100644 --- a/src/tint/lang/spirv/writer/var_test.cc +++ b/src/tint/lang/spirv/writer/var_test.cc
@@ -148,7 +148,11 @@ ASSERT_TRUE(Generate()) << Error() << output_; EXPECT_INST("%v = OpVariable %_ptr_Private_int Private %int_42"); EXPECT_INST("%load = OpLoad %int %v"); - EXPECT_INST("OpStore %v %add"); + EXPECT_INST("OpBitcast %uint %load"); + EXPECT_INST("OpBitcast %uint %int_1"); + EXPECT_INST("OpIAdd %uint %11 %12"); + EXPECT_INST("OpBitcast %int %14"); + EXPECT_INST("OpStore %v %15 None"); } TEST_F(SpirvWriterTest, WorkgroupVar) { @@ -174,7 +178,11 @@ ASSERT_TRUE(Generate()) << Error() << output_; EXPECT_INST("%v = OpVariable %_ptr_Workgroup_int Workgroup"); EXPECT_INST("%load = OpLoad %int %v"); - EXPECT_INST("OpStore %v %add"); + EXPECT_INST("OpBitcast %uint %load"); + EXPECT_INST("OpBitcast %uint %int_1"); + EXPECT_INST("OpIAdd %uint %21 %22"); + EXPECT_INST("OpBitcast %int %24"); + EXPECT_INST("OpStore %v %25 None"); } TEST_F(SpirvWriterTest, WorkgroupVar_ZeroInitializeWithExtension) { @@ -232,9 +240,12 @@ EXPECT_INST(R"( %9 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 %load = OpLoad %int %9 None - %add = OpIAdd %int %load %int_1 - %16 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 - OpStore %16 %add None + %14 = OpBitcast %uint %load + %15 = OpBitcast %uint %int_1 + %17 = OpIAdd %uint %14 %15 + %18 = OpBitcast %int %17 + %19 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 + OpStore %19 %18 None )"); } @@ -270,7 +281,6 @@ OpName %v_block "v_block" ; id %3 OpName %foo "foo" ; id %5 OpName %load "load" ; id %13 - OpName %add "add" ; id %14 ; Annotations OpMemberDecorate %v_block 0 Offset 0 @@ -295,9 +305,12 @@ %8 = OpLabel %9 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 %load = OpLoad %int %9 NonPrivatePointer - %add = OpIAdd %int %load %int_1 - %16 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 - OpStore %16 %add NonPrivatePointer + %14 = OpBitcast %uint %load + %15 = OpBitcast %uint %int_1 + %17 = OpIAdd %uint %14 %15 + %18 = OpBitcast %int %17 + %19 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 + OpStore %19 %18 NonPrivatePointer OpReturn OpFunctionEnd)"); } @@ -334,8 +347,7 @@ OpName %foo_inner "foo_inner" ; id %7 OpName %tint_local_index "tint_local_index" ; id %9 OpName %load "load" ; id %20 - OpName %add "add" ; id %21 - OpName %foo "foo" ; id %24 + OpName %foo "foo" ; id %27 ; Annotations OpDecorate %foo_local_invocation_index_Input BuiltIn LocalInvocationIndex @@ -355,7 +367,7 @@ %uint_24840 = OpConstant %uint 24840 %int_1 = OpConstant %int 1 %int_0 = OpConstant %int 0 - %25 = OpTypeFunction %void + %28 = OpTypeFunction %void ; Function foo_inner %foo_inner = OpFunction %void None %10 @@ -370,16 +382,19 @@ %15 = OpLabel OpControlBarrier %uint_2 %uint_2 %uint_24840 %load = OpLoad %int %v NonPrivatePointer - %add = OpIAdd %int %load %int_1 - OpStore %v %add NonPrivatePointer + %21 = OpBitcast %uint %load + %22 = OpBitcast %uint %int_1 + %24 = OpIAdd %uint %21 %22 + %25 = OpBitcast %int %24 + OpStore %v %25 NonPrivatePointer OpReturn OpFunctionEnd ; Function foo - %foo = OpFunction %void None %25 - %26 = OpLabel - %27 = OpLoad %uint %foo_local_invocation_index_Input None - %28 = OpFunctionCall %void %foo_inner %27 + %foo = OpFunction %void None %28 + %29 = OpLabel + %30 = OpLoad %uint %foo_local_invocation_index_Input None + %31 = OpFunctionCall %void %foo_inner %30 OpReturn OpFunctionEnd)"); }
diff --git a/test/tint/access/ptr.wgsl.expected.glsl b/test/tint/access/ptr.wgsl.expected.glsl index a61bac6..d47e4a8 100644 --- a/test/tint/access/ptr.wgsl.expected.glsl +++ b/test/tint/access/ptr.wgsl.expected.glsl
@@ -16,14 +16,20 @@ } int accept_ptr_deref_call_func(inout int val) { int v_1 = val; - return (v_1 + accept_value(val)); + int v_2 = accept_value(val); + uint v_3 = uint(v_1); + return int((v_3 + uint(v_2))); } int accept_ptr_deref_pass_through(inout int val) { - int v_2 = val; - return (v_2 + accept_ptr_deref_call_func(val)); + int v_4 = val; + int v_5 = accept_ptr_deref_call_func(val); + uint v_6 = uint(v_4); + return int((v_6 + uint(v_5))); } int accept_ptr_to_struct_and_access(inout S val) { - return (val.a + val.b); + int v_7 = val.b; + uint v_8 = uint(val.a); + return int((v_8 + uint(v_7))); } int accept_ptr_to_struct_access_pass_ptr(inout S val) { val.a = 2; @@ -48,12 +54,23 @@ S v2 = S(0, 0); vec3 v4 = vec3(0.0f); int t1 = atomicOr(g1, 0); - int v_3 = accept_ptr_deref_pass_through(v1); - int v_4 = (v_3 + accept_ptr_to_struct_and_access(v2)); - int v_5 = (v_4 + accept_ptr_to_struct_and_access(v2)); - int v_6 = (v_5 + accept_ptr_vec_access_elements(v4)); - int v_7 = (v_6 + accept_ptr_to_struct_access_pass_ptr(v2)); - v.inner = ((v_7 + call_builtin_with_mod_scope_ptr()) + t1); + int v_9 = accept_ptr_deref_pass_through(v1); + int v_10 = accept_ptr_to_struct_and_access(v2); + uint v_11 = uint(v_9); + int v_12 = int((v_11 + uint(v_10))); + int v_13 = accept_ptr_to_struct_and_access(v2); + uint v_14 = uint(v_12); + int v_15 = int((v_14 + uint(v_13))); + int v_16 = accept_ptr_vec_access_elements(v4); + uint v_17 = uint(v_15); + int v_18 = int((v_17 + uint(v_16))); + int v_19 = accept_ptr_to_struct_access_pass_ptr(v2); + uint v_20 = uint(v_18); + int v_21 = int((v_20 + uint(v_19))); + int v_22 = call_builtin_with_mod_scope_ptr(); + uint v_23 = uint(v_21); + uint v_24 = uint(int((v_23 + uint(v_22)))); + v.inner = int((v_24 + uint(t1))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/access/ptr.wgsl.expected.spvasm b/test/tint/access/ptr.wgsl.expected.spvasm index 37b709f..bf9fbb4 100644 --- a/test/tint/access/ptr.wgsl.expected.spvasm +++ b/test/tint/access/ptr.wgsl.expected.spvasm
@@ -1,10 +1,10 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 116 +; Bound: 143 ; Schema: 0 OpCapability Shader - %58 = OpExtInstImport "GLSL.std.450" + %67 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %main "main" %main_local_invocation_index_Input OpExecutionMode %main LocalSize 1 1 1 @@ -58,29 +58,29 @@ %17 = OpTypeFunction %int %_ptr_Function_int %S = OpTypeStruct %int %int %_ptr_Function_S = OpTypePointer Function %S - %33 = OpTypeFunction %int %_ptr_Function_S + %39 = OpTypeFunction %int %_ptr_Function_S %uint_0 = OpConstant %uint 0 %uint_1 = OpConstant %uint 1 %int_2 = OpConstant %int 2 %float = OpTypeFloat 32 %v3float = OpTypeVector %float 3 %_ptr_Function_v3float = OpTypePointer Function %v3float - %53 = OpTypeFunction %int %_ptr_Function_v3float + %62 = OpTypeFunction %int %_ptr_Function_v3float %_ptr_Function_float = OpTypePointer Function %float - %67 = OpTypeFunction %int + %76 = OpTypeFunction %int %uint_2 = OpConstant %uint 2 %void = OpTypeVoid - %74 = OpTypeFunction %void %uint + %83 = OpTypeFunction %void %uint %bool = OpTypeBool %uint_264 = OpConstant %uint 264 %int_0 = OpConstant %int 0 - %85 = OpConstantNull %S - %87 = OpConstantNull %v3float + %94 = OpConstantNull %S + %96 = OpConstantNull %v3float %_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int - %105 = OpTypeFunction %int %float + %132 = OpTypeFunction %int %float %float_n2_14748365e_09 = OpConstant %float -2.14748365e+09 %float_2_14748352e_09 = OpConstant %float 2.14748352e+09 - %112 = OpTypeFunction %void + %139 = OpTypeFunction %void %accept_value = OpFunction %int None %12 %val = OpFunctionParameter %int %13 = OpLabel @@ -92,98 +92,125 @@ %19 = OpLoad %int %val_root None %20 = OpLoad %int %val_root None %21 = OpFunctionCall %int %accept_value %20 - %22 = OpIAdd %int %19 %21 - OpReturnValue %22 + %22 = OpBitcast %uint %19 + %23 = OpBitcast %uint %21 + %24 = OpIAdd %uint %22 %23 + %25 = OpBitcast %int %24 + OpReturnValue %25 OpFunctionEnd %accept_ptr_deref_pass_through = OpFunction %int None %17 %val_root_0 = OpFunctionParameter %_ptr_Function_int - %25 = OpLabel - %26 = OpLoad %int %val_root_0 None - %27 = OpFunctionCall %int %accept_ptr_deref_call_func %val_root_0 - %28 = OpIAdd %int %26 %27 - OpReturnValue %28 + %28 = OpLabel + %29 = OpLoad %int %val_root_0 None + %30 = OpFunctionCall %int %accept_ptr_deref_call_func %val_root_0 + %31 = OpBitcast %uint %29 + %32 = OpBitcast %uint %30 + %33 = OpIAdd %uint %31 %32 + %34 = OpBitcast %int %33 + OpReturnValue %34 OpFunctionEnd -%accept_ptr_to_struct_and_access = OpFunction %int None %33 +%accept_ptr_to_struct_and_access = OpFunction %int None %39 %val_root_1 = OpFunctionParameter %_ptr_Function_S - %34 = OpLabel - %35 = OpAccessChain %_ptr_Function_int %val_root_1 %uint_0 - %37 = OpLoad %int %35 None - %38 = OpAccessChain %_ptr_Function_int %val_root_1 %uint_1 - %40 = OpLoad %int %38 None - %41 = OpIAdd %int %37 %40 - OpReturnValue %41 + %40 = OpLabel + %41 = OpAccessChain %_ptr_Function_int %val_root_1 %uint_0 + %43 = OpLoad %int %41 None + %44 = OpAccessChain %_ptr_Function_int %val_root_1 %uint_1 + %46 = OpLoad %int %44 None + %47 = OpBitcast %uint %43 + %48 = OpBitcast %uint %46 + %49 = OpIAdd %uint %47 %48 + %50 = OpBitcast %int %49 + OpReturnValue %50 OpFunctionEnd -%accept_ptr_to_struct_access_pass_ptr = OpFunction %int None %33 +%accept_ptr_to_struct_access_pass_ptr = OpFunction %int None %39 %val_root_2 = OpFunctionParameter %_ptr_Function_S - %44 = OpLabel + %53 = OpLabel %b = OpAccessChain %_ptr_Function_int %val_root_2 %uint_0 OpStore %b %int_2 None - %47 = OpLoad %int %b None - OpReturnValue %47 + %56 = OpLoad %int %b None + OpReturnValue %56 OpFunctionEnd -%accept_ptr_vec_access_elements = OpFunction %int None %53 +%accept_ptr_vec_access_elements = OpFunction %int None %62 %v1_root = OpFunctionParameter %_ptr_Function_v3float - %54 = OpLabel - %55 = OpLoad %v3float %v1_root None - %56 = OpLoad %v3float %v1_root None - %57 = OpExtInst %v3float %58 Cross %55 %56 - %59 = OpCompositeExtract %float %57 0 - %60 = OpAccessChain %_ptr_Function_float %v1_root %uint_0 - OpStore %60 %59 None - %62 = OpAccessChain %_ptr_Function_float %v1_root %uint_0 - %63 = OpLoad %float %62 None - %64 = OpFunctionCall %int %tint_f32_to_i32 %63 - OpReturnValue %64 + %63 = OpLabel + %64 = OpLoad %v3float %v1_root None + %65 = OpLoad %v3float %v1_root None + %66 = OpExtInst %v3float %67 Cross %64 %65 + %68 = OpCompositeExtract %float %66 0 + %69 = OpAccessChain %_ptr_Function_float %v1_root %uint_0 + OpStore %69 %68 None + %71 = OpAccessChain %_ptr_Function_float %v1_root %uint_0 + %72 = OpLoad %float %71 None + %73 = OpFunctionCall %int %tint_f32_to_i32 %72 + OpReturnValue %73 OpFunctionEnd -%call_builtin_with_mod_scope_ptr = OpFunction %int None %67 - %68 = OpLabel - %69 = OpAtomicLoad %int %g1 %uint_2 %uint_0 - OpReturnValue %69 +%call_builtin_with_mod_scope_ptr = OpFunction %int None %76 + %77 = OpLabel + %78 = OpAtomicLoad %int %g1 %uint_2 %uint_0 + OpReturnValue %78 OpFunctionEnd - %main_inner = OpFunction %void None %74 + %main_inner = OpFunction %void None %83 %tint_local_index = OpFunctionParameter %uint - %75 = OpLabel + %84 = OpLabel %v1 = OpVariable %_ptr_Function_int Function %v2 = OpVariable %_ptr_Function_S Function %v4 = OpVariable %_ptr_Function_v3float Function - %76 = OpULessThan %bool %tint_local_index %uint_1 - OpSelectionMerge %78 None - OpBranchConditional %76 %79 %78 - %79 = OpLabel + %85 = OpULessThan %bool %tint_local_index %uint_1 + OpSelectionMerge %87 None + OpBranchConditional %85 %88 %87 + %88 = OpLabel OpAtomicStore %g1 %uint_2 %uint_0 %int_0 - OpBranch %78 - %78 = OpLabel + OpBranch %87 + %87 = OpLabel OpControlBarrier %uint_2 %uint_2 %uint_264 OpStore %v1 %int_0 - OpStore %v2 %85 - OpStore %v4 %87 + OpStore %v2 %94 + OpStore %v4 %96 %t1 = OpAtomicLoad %int %g1 %uint_2 %uint_0 - %89 = OpFunctionCall %int %accept_ptr_deref_pass_through %v1 - %90 = OpFunctionCall %int %accept_ptr_to_struct_and_access %v2 - %91 = OpIAdd %int %89 %90 - %92 = OpFunctionCall %int %accept_ptr_to_struct_and_access %v2 - %93 = OpIAdd %int %91 %92 - %94 = OpFunctionCall %int %accept_ptr_vec_access_elements %v4 - %95 = OpIAdd %int %93 %94 - %96 = OpFunctionCall %int %accept_ptr_to_struct_access_pass_ptr %v2 - %97 = OpIAdd %int %95 %96 - %98 = OpFunctionCall %int %call_builtin_with_mod_scope_ptr - %99 = OpIAdd %int %97 %98 - %100 = OpIAdd %int %99 %t1 - %101 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 - OpStore %101 %100 None + %98 = OpFunctionCall %int %accept_ptr_deref_pass_through %v1 + %99 = OpFunctionCall %int %accept_ptr_to_struct_and_access %v2 + %100 = OpBitcast %uint %98 + %101 = OpBitcast %uint %99 + %102 = OpIAdd %uint %100 %101 + %103 = OpBitcast %int %102 + %104 = OpFunctionCall %int %accept_ptr_to_struct_and_access %v2 + %105 = OpBitcast %uint %103 + %106 = OpBitcast %uint %104 + %107 = OpIAdd %uint %105 %106 + %108 = OpBitcast %int %107 + %109 = OpFunctionCall %int %accept_ptr_vec_access_elements %v4 + %110 = OpBitcast %uint %108 + %111 = OpBitcast %uint %109 + %112 = OpIAdd %uint %110 %111 + %113 = OpBitcast %int %112 + %114 = OpFunctionCall %int %accept_ptr_to_struct_access_pass_ptr %v2 + %115 = OpBitcast %uint %113 + %116 = OpBitcast %uint %114 + %117 = OpIAdd %uint %115 %116 + %118 = OpBitcast %int %117 + %119 = OpFunctionCall %int %call_builtin_with_mod_scope_ptr + %120 = OpBitcast %uint %118 + %121 = OpBitcast %uint %119 + %122 = OpIAdd %uint %120 %121 + %123 = OpBitcast %int %122 + %124 = OpBitcast %uint %123 + %125 = OpBitcast %uint %t1 + %126 = OpIAdd %uint %124 %125 + %127 = OpBitcast %int %126 + %128 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 + OpStore %128 %127 None OpReturn OpFunctionEnd -%tint_f32_to_i32 = OpFunction %int None %105 +%tint_f32_to_i32 = OpFunction %int None %132 %value = OpFunctionParameter %float - %106 = OpLabel - %107 = OpExtInst %float %58 NClamp %value %float_n2_14748365e_09 %float_2_14748352e_09 - %110 = OpConvertFToS %int %107 - OpReturnValue %110 + %133 = OpLabel + %134 = OpExtInst %float %67 NClamp %value %float_n2_14748365e_09 %float_2_14748352e_09 + %137 = OpConvertFToS %int %134 + OpReturnValue %137 OpFunctionEnd - %main = OpFunction %void None %112 - %113 = OpLabel - %114 = OpLoad %uint %main_local_invocation_index_Input None - %115 = OpFunctionCall %void %main_inner %114 + %main = OpFunction %void None %139 + %140 = OpLabel + %141 = OpLoad %uint %main_local_invocation_index_Input None + %142 = OpFunctionCall %void %main_inner %141 OpReturn OpFunctionEnd
diff --git a/test/tint/array/assign_to_subexpr.wgsl.expected.glsl b/test/tint/array/assign_to_subexpr.wgsl.expected.glsl index 0aa0a19..513d1d1 100644 --- a/test/tint/array/assign_to_subexpr.wgsl.expected.glsl +++ b/test/tint/array/assign_to_subexpr.wgsl.expected.glsl
@@ -19,7 +19,12 @@ dst = src; dst_struct.arr = src; dst_array[0u] = src; - return ((dst[0u] + dst_struct.arr[0u]) + dst_array[0u][0u]); + int v_1 = dst_struct.arr[0u]; + uint v_2 = uint(dst[0u]); + int v_3 = int((v_2 + uint(v_1))); + int v_4 = dst_array[0u][0u]; + uint v_5 = uint(v_3); + return int((v_5 + uint(v_4))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/array/assign_to_subexpr.wgsl.expected.spvasm b/test/tint/array/assign_to_subexpr.wgsl.expected.spvasm index 91d5d4a..c91ebec 100644 --- a/test/tint/array/assign_to_subexpr.wgsl.expected.spvasm +++ b/test/tint/array/assign_to_subexpr.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 45 +; Bound: 51 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -46,7 +46,7 @@ %uint_1 = OpConstant %uint 1 %_ptr_Function_int = OpTypePointer Function %int %void = OpTypeVoid - %40 = OpTypeFunction %void + %46 = OpTypeFunction %void %_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int %foo = OpFunction %int None %6 %7 = OpLabel @@ -66,16 +66,22 @@ %31 = OpLoad %int %29 None %32 = OpAccessChain %_ptr_Function_int %dst_struct %uint_0 %uint_0 %33 = OpLoad %int %32 None - %34 = OpIAdd %int %31 %33 - %35 = OpAccessChain %_ptr_Function_int %dst_array %uint_0 %uint_0 - %36 = OpLoad %int %35 None - %37 = OpIAdd %int %34 %36 - OpReturnValue %37 + %34 = OpBitcast %uint %31 + %35 = OpBitcast %uint %33 + %36 = OpIAdd %uint %34 %35 + %37 = OpBitcast %int %36 + %38 = OpAccessChain %_ptr_Function_int %dst_array %uint_0 %uint_0 + %39 = OpLoad %int %38 None + %40 = OpBitcast %uint %37 + %41 = OpBitcast %uint %39 + %42 = OpIAdd %uint %40 %41 + %43 = OpBitcast %int %42 + OpReturnValue %43 OpFunctionEnd - %main = OpFunction %void None %40 - %41 = OpLabel - %42 = OpFunctionCall %int %foo - %43 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 - OpStore %43 %42 None + %main = OpFunction %void None %46 + %47 = OpLabel + %48 = OpFunctionCall %int %foo + %49 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 + OpStore %49 %48 None OpReturn OpFunctionEnd
diff --git a/test/tint/array/type_initializer.wgsl.expected.glsl b/test/tint/array/type_initializer.wgsl.expected.glsl index ac638e9..664998d 100644 --- a/test/tint/array/type_initializer.wgsl.expected.glsl +++ b/test/tint/array/type_initializer.wgsl.expected.glsl
@@ -9,16 +9,32 @@ int x = 42; int empty[4] = int[4](0, 0, 0, 0); int nonempty[4] = int[4](1, 2, 3, 4); - int nonempty_with_expr[4] = int[4](1, x, (x + 1), nonempty[3u]); + uint v_1 = uint(x); + int nonempty_with_expr[4] = int[4](1, x, int((v_1 + uint(1))), nonempty[3u]); 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 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 v_1[4] = int[4](1, 2, x, (x + 1)); - int nested_nonempty_with_expr[2][3][4] = int[2][3][4](int[3][4](v_1, int[4](5, 6, nonempty[2u], (nonempty[3u] + 1)), nonempty), nested_nonempty[1u]); + uint v_2 = uint(x); + int v_3[4] = int[4](1, 2, x, int((v_2 + uint(1)))); + uint v_4 = uint(nonempty[3u]); + int nested_nonempty_with_expr[2][3][4] = int[2][3][4](int[3][4](v_3, int[4](5, 6, nonempty[2u], int((v_4 + uint(1)))), nonempty), nested_nonempty[1u]); int subexpr_empty = 0; int subexpr_nonempty = 3; - int subexpr_nonempty_with_expr = int[4](1, x, (x + 1), nonempty[3u])[2u]; + uint v_5 = uint(x); + int subexpr_nonempty_with_expr = int[4](1, x, int((v_5 + uint(1))), nonempty[3u])[2u]; int subexpr_nested_empty[4] = int[4](0, 0, 0, 0); int subexpr_nested_nonempty[4] = int[4](5, 6, 7, 8); - int subexpr_nested_nonempty_with_expr[4] = int[2][4](int[4](1, x, (x + 1), nonempty[3u]), nested_nonempty[1u][2u])[1u]; - v.inner = (((((((((((empty[0u] + nonempty[0u]) + nonempty_with_expr[0u]) + nested_empty[0u][0u][0u]) + nested_nonempty[0u][0u][0u]) + nested_nonempty_with_expr[0u][0u][0u]) + subexpr_empty) + subexpr_nonempty) + subexpr_nonempty_with_expr) + subexpr_nested_empty[0u]) + subexpr_nested_nonempty[0u]) + subexpr_nested_nonempty_with_expr[0u]); + uint v_6 = uint(x); + int subexpr_nested_nonempty_with_expr[4] = int[2][4](int[4](1, x, int((v_6 + uint(1))), nonempty[3u]), nested_nonempty[1u][2u])[1u]; + uint v_7 = uint(empty[0u]); + uint v_8 = uint(int((v_7 + uint(nonempty[0u])))); + uint v_9 = uint(int((v_8 + uint(nonempty_with_expr[0u])))); + uint v_10 = uint(int((v_9 + uint(nested_empty[0u][0u][0u])))); + uint v_11 = uint(int((v_10 + uint(nested_nonempty[0u][0u][0u])))); + uint v_12 = uint(int((v_11 + uint(nested_nonempty_with_expr[0u][0u][0u])))); + uint v_13 = uint(int((v_12 + uint(subexpr_empty)))); + uint v_14 = uint(int((v_13 + uint(subexpr_nonempty)))); + uint v_15 = uint(int((v_14 + uint(subexpr_nonempty_with_expr)))); + uint v_16 = uint(int((v_15 + uint(subexpr_nested_empty[0u])))); + uint v_17 = uint(int((v_16 + uint(subexpr_nested_nonempty[0u])))); + v.inner = int((v_17 + uint(subexpr_nested_nonempty_with_expr[0u]))); }
diff --git a/test/tint/array/type_initializer.wgsl.expected.spvasm b/test/tint/array/type_initializer.wgsl.expected.spvasm index 1be5596..3a481ed 100644 --- a/test/tint/array/type_initializer.wgsl.expected.spvasm +++ b/test/tint/array/type_initializer.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 99 +; Bound: 147 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -58,74 +58,122 @@ %int_10 = OpConstant %int 10 %int_11 = OpConstant %int 11 %int_12 = OpConstant %int 12 - %34 = OpConstantComposite %_arr_int_uint_4 %int_9 %int_10 %int_11 %int_12 - %28 = OpConstantComposite %_arr__arr_int_uint_4_uint_3 %nonempty %subexpr_nested_nonempty %34 + %37 = OpConstantComposite %_arr_int_uint_4 %int_9 %int_10 %int_11 %int_12 + %31 = OpConstantComposite %_arr__arr_int_uint_4_uint_3 %nonempty %subexpr_nested_nonempty %37 %int_13 = OpConstant %int 13 %int_14 = OpConstant %int 14 %int_15 = OpConstant %int 15 %int_16 = OpConstant %int 16 - %40 = OpConstantComposite %_arr_int_uint_4 %int_13 %int_14 %int_15 %int_16 + %43 = OpConstantComposite %_arr_int_uint_4 %int_13 %int_14 %int_15 %int_16 %int_17 = OpConstant %int 17 %int_18 = OpConstant %int 18 %int_19 = OpConstant %int 19 %int_20 = OpConstant %int 20 - %45 = OpConstantComposite %_arr_int_uint_4 %int_17 %int_18 %int_19 %int_20 + %48 = OpConstantComposite %_arr_int_uint_4 %int_17 %int_18 %int_19 %int_20 %int_21 = OpConstant %int 21 %int_22 = OpConstant %int 22 %int_23 = OpConstant %int 23 %int_24 = OpConstant %int 24 - %50 = OpConstantComposite %_arr_int_uint_4 %int_21 %int_22 %int_23 %int_24 - %39 = OpConstantComposite %_arr__arr_int_uint_4_uint_3 %40 %45 %50 -%nested_nonempty = OpConstantComposite %_arr__arr__arr_int_uint_4_uint_3_uint_2 %28 %39 + %53 = OpConstantComposite %_arr_int_uint_4 %int_21 %int_22 %int_23 %int_24 + %42 = OpConstantComposite %_arr__arr_int_uint_4_uint_3 %43 %48 %53 +%nested_nonempty = OpConstantComposite %_arr__arr__arr_int_uint_4_uint_3_uint_2 %31 %42 %subexpr_empty = OpConstant %int 0 %_arr__arr_int_uint_4_uint_2 = OpTypeArray %_arr_int_uint_4 %uint_2 %_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int %uint_0 = OpConstant %uint 0 %main = OpFunction %void None %7 %8 = OpLabel - %19 = OpIAdd %int %x %int_1 - %20 = OpCompositeExtract %int %nonempty 3 -%nonempty_with_expr = OpCompositeConstruct %_arr_int_uint_4 %int_1 %x %19 %20 - %55 = OpIAdd %int %x %int_1 - %56 = OpCompositeConstruct %_arr_int_uint_4 %int_1 %int_2 %x %55 - %57 = OpCompositeExtract %int %nonempty 2 - %58 = OpCompositeExtract %int %nonempty 3 - %59 = OpIAdd %int %58 %int_1 - %60 = OpCompositeConstruct %_arr_int_uint_4 %int_5 %int_6 %57 %59 - %61 = OpCompositeConstruct %_arr__arr_int_uint_4_uint_3 %56 %60 %nonempty - %62 = OpCompositeExtract %_arr__arr_int_uint_4_uint_3 %nested_nonempty 1 -%nested_nonempty_with_expr = OpCompositeConstruct %_arr__arr__arr_int_uint_4_uint_3_uint_2 %61 %62 - %65 = OpIAdd %int %x %int_1 - %66 = OpCompositeExtract %int %nonempty 3 - %67 = OpCompositeConstruct %_arr_int_uint_4 %int_1 %x %65 %66 -%subexpr_nonempty_with_expr = OpCompositeExtract %int %67 2 - %69 = OpIAdd %int %x %int_1 - %70 = OpCompositeExtract %int %nonempty 3 - %71 = OpCompositeConstruct %_arr_int_uint_4 %int_1 %x %69 %70 - %72 = OpCompositeExtract %_arr_int_uint_4 %nested_nonempty 1 2 - %74 = OpCompositeConstruct %_arr__arr_int_uint_4_uint_2 %71 %72 -%subexpr_nested_nonempty_with_expr = OpCompositeExtract %_arr_int_uint_4 %74 1 - %76 = OpCompositeExtract %int %empty 0 - %77 = OpCompositeExtract %int %nonempty 0 - %78 = OpIAdd %int %76 %77 - %79 = OpCompositeExtract %int %nonempty_with_expr 0 - %80 = OpIAdd %int %78 %79 - %81 = OpCompositeExtract %int %nested_empty 0 0 0 - %82 = OpIAdd %int %80 %81 - %83 = OpCompositeExtract %int %nested_nonempty 0 0 0 - %84 = OpIAdd %int %82 %83 - %85 = OpCompositeExtract %int %nested_nonempty_with_expr 0 0 0 - %86 = OpIAdd %int %84 %85 - %87 = OpIAdd %int %86 %subexpr_empty - %88 = OpIAdd %int %87 %subexpr_nonempty - %89 = OpIAdd %int %88 %subexpr_nonempty_with_expr - %90 = OpCompositeExtract %int %empty 0 - %91 = OpIAdd %int %89 %90 - %92 = OpCompositeExtract %int %subexpr_nested_nonempty 0 - %93 = OpIAdd %int %91 %92 - %94 = OpCompositeExtract %int %subexpr_nested_nonempty_with_expr 0 - %95 = OpIAdd %int %93 %94 - %96 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 - OpStore %96 %95 None + %19 = OpBitcast %uint %x + %20 = OpBitcast %uint %int_1 + %21 = OpIAdd %uint %19 %20 + %22 = OpBitcast %int %21 + %23 = OpCompositeExtract %int %nonempty 3 +%nonempty_with_expr = OpCompositeConstruct %_arr_int_uint_4 %int_1 %x %22 %23 + %58 = OpBitcast %uint %x + %59 = OpBitcast %uint %int_1 + %60 = OpIAdd %uint %58 %59 + %61 = OpBitcast %int %60 + %62 = OpCompositeConstruct %_arr_int_uint_4 %int_1 %int_2 %x %61 + %63 = OpCompositeExtract %int %nonempty 2 + %64 = OpCompositeExtract %int %nonempty 3 + %65 = OpBitcast %uint %64 + %66 = OpBitcast %uint %int_1 + %67 = OpIAdd %uint %65 %66 + %68 = OpBitcast %int %67 + %69 = OpCompositeConstruct %_arr_int_uint_4 %int_5 %int_6 %63 %68 + %70 = OpCompositeConstruct %_arr__arr_int_uint_4_uint_3 %62 %69 %nonempty + %71 = OpCompositeExtract %_arr__arr_int_uint_4_uint_3 %nested_nonempty 1 +%nested_nonempty_with_expr = OpCompositeConstruct %_arr__arr__arr_int_uint_4_uint_3_uint_2 %70 %71 + %74 = OpBitcast %uint %x + %75 = OpBitcast %uint %int_1 + %76 = OpIAdd %uint %74 %75 + %77 = OpBitcast %int %76 + %78 = OpCompositeExtract %int %nonempty 3 + %79 = OpCompositeConstruct %_arr_int_uint_4 %int_1 %x %77 %78 +%subexpr_nonempty_with_expr = OpCompositeExtract %int %79 2 + %81 = OpBitcast %uint %x + %82 = OpBitcast %uint %int_1 + %83 = OpIAdd %uint %81 %82 + %84 = OpBitcast %int %83 + %85 = OpCompositeExtract %int %nonempty 3 + %86 = OpCompositeConstruct %_arr_int_uint_4 %int_1 %x %84 %85 + %87 = OpCompositeExtract %_arr_int_uint_4 %nested_nonempty 1 2 + %89 = OpCompositeConstruct %_arr__arr_int_uint_4_uint_2 %86 %87 +%subexpr_nested_nonempty_with_expr = OpCompositeExtract %_arr_int_uint_4 %89 1 + %91 = OpCompositeExtract %int %empty 0 + %92 = OpCompositeExtract %int %nonempty 0 + %93 = OpBitcast %uint %91 + %94 = OpBitcast %uint %92 + %95 = OpIAdd %uint %93 %94 + %96 = OpBitcast %int %95 + %97 = OpCompositeExtract %int %nonempty_with_expr 0 + %98 = OpBitcast %uint %96 + %99 = OpBitcast %uint %97 + %100 = OpIAdd %uint %98 %99 + %101 = OpBitcast %int %100 + %102 = OpCompositeExtract %int %nested_empty 0 0 0 + %103 = OpBitcast %uint %101 + %104 = OpBitcast %uint %102 + %105 = OpIAdd %uint %103 %104 + %106 = OpBitcast %int %105 + %107 = OpCompositeExtract %int %nested_nonempty 0 0 0 + %108 = OpBitcast %uint %106 + %109 = OpBitcast %uint %107 + %110 = OpIAdd %uint %108 %109 + %111 = OpBitcast %int %110 + %112 = OpCompositeExtract %int %nested_nonempty_with_expr 0 0 0 + %113 = OpBitcast %uint %111 + %114 = OpBitcast %uint %112 + %115 = OpIAdd %uint %113 %114 + %116 = OpBitcast %int %115 + %117 = OpBitcast %uint %116 + %118 = OpBitcast %uint %subexpr_empty + %119 = OpIAdd %uint %117 %118 + %120 = OpBitcast %int %119 + %121 = OpBitcast %uint %120 + %122 = OpBitcast %uint %subexpr_nonempty + %123 = OpIAdd %uint %121 %122 + %124 = OpBitcast %int %123 + %125 = OpBitcast %uint %124 + %126 = OpBitcast %uint %subexpr_nonempty_with_expr + %127 = OpIAdd %uint %125 %126 + %128 = OpBitcast %int %127 + %129 = OpCompositeExtract %int %empty 0 + %130 = OpBitcast %uint %128 + %131 = OpBitcast %uint %129 + %132 = OpIAdd %uint %130 %131 + %133 = OpBitcast %int %132 + %134 = OpCompositeExtract %int %subexpr_nested_nonempty 0 + %135 = OpBitcast %uint %133 + %136 = OpBitcast %uint %134 + %137 = OpIAdd %uint %135 %136 + %138 = OpBitcast %int %137 + %139 = OpCompositeExtract %int %subexpr_nested_nonempty_with_expr 0 + %140 = OpBitcast %uint %138 + %141 = OpBitcast %uint %139 + %142 = OpIAdd %uint %140 %141 + %143 = OpBitcast %int %142 + %144 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 + OpStore %144 %143 None OpReturn OpFunctionEnd
diff --git a/test/tint/buffer/storage/dynamic_index/read.wgsl.expected.glsl b/test/tint/buffer/storage/dynamic_index/read.wgsl.expected.glsl index 7f3474c..6ff42e1 100644 --- a/test/tint/buffer/storage/dynamic_index/read.wgsl.expected.glsl +++ b/test/tint/buffer/storage/dynamic_index/read.wgsl.expected.glsl
@@ -90,24 +90,62 @@ mat4 mat4x4_f32 = sb.arr[v_21].mat4x4_f32; uint v_22 = min(idx, (uint(sb.arr.length()) - 1u)); vec3 arr2_vec3_f32[2] = sb.arr[v_22].arr2_vec3_f32; - int v_23 = (tint_f32_to_i32(scalar_f32) + scalar_i32); - int v_24 = (v_23 + int(scalar_u32)); - int v_25 = ((v_24 + tint_f32_to_i32(vec2_f32.x)) + vec2_i32.x); - int v_26 = (v_25 + int(vec2_u32.x)); - int v_27 = ((v_26 + tint_f32_to_i32(vec3_f32.y)) + vec3_i32.y); - int v_28 = (v_27 + int(vec3_u32.y)); - int v_29 = ((v_28 + tint_f32_to_i32(vec4_f32.z)) + vec4_i32.z); - int v_30 = (v_29 + int(vec4_u32.z)); - int v_31 = (v_30 + tint_f32_to_i32(mat2x2_f32[0u].x)); - int v_32 = (v_31 + tint_f32_to_i32(mat2x3_f32[0u].x)); - int v_33 = (v_32 + tint_f32_to_i32(mat2x4_f32[0u].x)); - int v_34 = (v_33 + tint_f32_to_i32(mat3x2_f32[0u].x)); - int v_35 = (v_34 + tint_f32_to_i32(mat3x3_f32[0u].x)); - int v_36 = (v_35 + tint_f32_to_i32(mat3x4_f32[0u].x)); - int v_37 = (v_36 + tint_f32_to_i32(mat4x2_f32[0u].x)); - int v_38 = (v_37 + tint_f32_to_i32(mat4x3_f32[0u].x)); - int v_39 = (v_38 + tint_f32_to_i32(mat4x4_f32[0u].x)); - v.inner = (v_39 + tint_f32_to_i32(arr2_vec3_f32[0u].x)); + uint v_23 = uint(tint_f32_to_i32(scalar_f32)); + int v_24 = int((v_23 + uint(scalar_i32))); + int v_25 = int(scalar_u32); + uint v_26 = uint(v_24); + int v_27 = int((v_26 + uint(v_25))); + int v_28 = tint_f32_to_i32(vec2_f32.x); + uint v_29 = uint(v_27); + uint v_30 = uint(int((v_29 + uint(v_28)))); + int v_31 = int((v_30 + uint(vec2_i32.x))); + int v_32 = int(vec2_u32.x); + uint v_33 = uint(v_31); + int v_34 = int((v_33 + uint(v_32))); + int v_35 = tint_f32_to_i32(vec3_f32.y); + uint v_36 = uint(v_34); + uint v_37 = uint(int((v_36 + uint(v_35)))); + int v_38 = int((v_37 + uint(vec3_i32.y))); + int v_39 = int(vec3_u32.y); + uint v_40 = uint(v_38); + int v_41 = int((v_40 + uint(v_39))); + int v_42 = tint_f32_to_i32(vec4_f32.z); + uint v_43 = uint(v_41); + uint v_44 = uint(int((v_43 + uint(v_42)))); + int v_45 = int((v_44 + uint(vec4_i32.z))); + int v_46 = int(vec4_u32.z); + uint v_47 = uint(v_45); + int v_48 = int((v_47 + uint(v_46))); + int v_49 = tint_f32_to_i32(mat2x2_f32[0u].x); + uint v_50 = uint(v_48); + int v_51 = int((v_50 + uint(v_49))); + int v_52 = tint_f32_to_i32(mat2x3_f32[0u].x); + uint v_53 = uint(v_51); + int v_54 = int((v_53 + uint(v_52))); + int v_55 = tint_f32_to_i32(mat2x4_f32[0u].x); + uint v_56 = uint(v_54); + int v_57 = int((v_56 + uint(v_55))); + int v_58 = tint_f32_to_i32(mat3x2_f32[0u].x); + uint v_59 = uint(v_57); + int v_60 = int((v_59 + uint(v_58))); + int v_61 = tint_f32_to_i32(mat3x3_f32[0u].x); + uint v_62 = uint(v_60); + int v_63 = int((v_62 + uint(v_61))); + int v_64 = tint_f32_to_i32(mat3x4_f32[0u].x); + uint v_65 = uint(v_63); + int v_66 = int((v_65 + uint(v_64))); + int v_67 = tint_f32_to_i32(mat4x2_f32[0u].x); + uint v_68 = uint(v_66); + int v_69 = int((v_68 + uint(v_67))); + int v_70 = tint_f32_to_i32(mat4x3_f32[0u].x); + uint v_71 = uint(v_69); + int v_72 = int((v_71 + uint(v_70))); + int v_73 = tint_f32_to_i32(mat4x4_f32[0u].x); + uint v_74 = uint(v_72); + int v_75 = int((v_74 + uint(v_73))); + int v_76 = tint_f32_to_i32(arr2_vec3_f32[0u].x); + uint v_77 = uint(v_75); + v.inner = int((v_77 + uint(v_76))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/buffer/storage/dynamic_index/read.wgsl.expected.spvasm b/test/tint/buffer/storage/dynamic_index/read.wgsl.expected.spvasm index 3cc6552..e3c9932 100644 --- a/test/tint/buffer/storage/dynamic_index/read.wgsl.expected.spvasm +++ b/test/tint/buffer/storage/dynamic_index/read.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 316 +; Bound: 379 ; Schema: 0 OpCapability Shader %46 = OpExtInstImport "GLSL.std.450" @@ -200,14 +200,14 @@ %uint_21 = OpConstant %uint 21 %_arr_v3float_uint_2_0 = OpTypeArray %v3float %uint_2 %_ptr_StorageBuffer_int_0 = OpTypePointer StorageBuffer %int - %281 = OpTypeFunction %int %float + %344 = OpTypeFunction %int %float %float_n2_14748365e_09 = OpConstant %float -2.14748365e+09 %float_2_14748352e_09 = OpConstant %float 2.14748352e+09 - %288 = OpTypeFunction %void - %293 = OpTypeFunction %_arr_v3float_uint_2_0 %_arr_v3float_uint_2 + %351 = OpTypeFunction %void + %356 = OpTypeFunction %_arr_v3float_uint_2_0 %_arr_v3float_uint_2 %_ptr_Function__arr_v3float_uint_2 = OpTypePointer Function %_arr_v3float_uint_2 %_ptr_Function__arr_v3float_uint_2_0 = OpTypePointer Function %_arr_v3float_uint_2_0 - %299 = OpConstantNull %_arr_v3float_uint_2_0 + %362 = OpConstantNull %_arr_v3float_uint_2_0 %bool = OpTypeBool %_ptr_Function_v3float = OpTypePointer Function %v3float %main_inner = OpFunction %void None %37 @@ -347,109 +347,172 @@ %215 = OpLoad %_arr_v3float_uint_2 %212 None %arr2_vec3_f32 = OpFunctionCall %_arr_v3float_uint_2_0 %tint_convert_explicit_layout %215 %219 = OpFunctionCall %int %tint_f32_to_i32 %scalar_f32 - %221 = OpIAdd %int %219 %scalar_i32 - %222 = OpBitcast %int %scalar_u32 - %223 = OpIAdd %int %221 %222 - %224 = OpCompositeExtract %float %vec2_f32 0 - %225 = OpFunctionCall %int %tint_f32_to_i32 %224 - %226 = OpIAdd %int %223 %225 - %227 = OpCompositeExtract %int %vec2_i32 0 - %228 = OpIAdd %int %226 %227 - %229 = OpCompositeExtract %uint %vec2_u32 0 - %230 = OpBitcast %int %229 - %231 = OpIAdd %int %228 %230 - %232 = OpCompositeExtract %float %vec3_f32 1 - %233 = OpFunctionCall %int %tint_f32_to_i32 %232 - %234 = OpIAdd %int %231 %233 - %235 = OpCompositeExtract %int %vec3_i32 1 - %236 = OpIAdd %int %234 %235 - %237 = OpCompositeExtract %uint %vec3_u32 1 - %238 = OpBitcast %int %237 - %239 = OpIAdd %int %236 %238 - %240 = OpCompositeExtract %float %vec4_f32 2 - %241 = OpFunctionCall %int %tint_f32_to_i32 %240 - %242 = OpIAdd %int %239 %241 - %243 = OpCompositeExtract %int %vec4_i32 2 - %244 = OpIAdd %int %242 %243 - %245 = OpCompositeExtract %uint %vec4_u32 2 + %221 = OpBitcast %uint %219 + %222 = OpBitcast %uint %scalar_i32 + %223 = OpIAdd %uint %221 %222 + %224 = OpBitcast %int %223 + %225 = OpBitcast %int %scalar_u32 + %226 = OpBitcast %uint %224 + %227 = OpBitcast %uint %225 + %228 = OpIAdd %uint %226 %227 + %229 = OpBitcast %int %228 + %230 = OpCompositeExtract %float %vec2_f32 0 + %231 = OpFunctionCall %int %tint_f32_to_i32 %230 + %232 = OpBitcast %uint %229 + %233 = OpBitcast %uint %231 + %234 = OpIAdd %uint %232 %233 + %235 = OpBitcast %int %234 + %236 = OpCompositeExtract %int %vec2_i32 0 + %237 = OpBitcast %uint %235 + %238 = OpBitcast %uint %236 + %239 = OpIAdd %uint %237 %238 + %240 = OpBitcast %int %239 + %241 = OpCompositeExtract %uint %vec2_u32 0 + %242 = OpBitcast %int %241 + %243 = OpBitcast %uint %240 + %244 = OpBitcast %uint %242 + %245 = OpIAdd %uint %243 %244 %246 = OpBitcast %int %245 - %247 = OpIAdd %int %244 %246 - %248 = OpCompositeExtract %float %mat2x2_f32 0 0 - %249 = OpFunctionCall %int %tint_f32_to_i32 %248 - %250 = OpIAdd %int %247 %249 - %251 = OpCompositeExtract %float %mat2x3_f32 0 0 - %252 = OpFunctionCall %int %tint_f32_to_i32 %251 - %253 = OpIAdd %int %250 %252 - %254 = OpCompositeExtract %float %mat2x4_f32 0 0 - %255 = OpFunctionCall %int %tint_f32_to_i32 %254 - %256 = OpIAdd %int %253 %255 - %257 = OpCompositeExtract %float %mat3x2_f32 0 0 - %258 = OpFunctionCall %int %tint_f32_to_i32 %257 - %259 = OpIAdd %int %256 %258 - %260 = OpCompositeExtract %float %mat3x3_f32 0 0 - %261 = OpFunctionCall %int %tint_f32_to_i32 %260 - %262 = OpIAdd %int %259 %261 - %263 = OpCompositeExtract %float %mat3x4_f32 0 0 - %264 = OpFunctionCall %int %tint_f32_to_i32 %263 - %265 = OpIAdd %int %262 %264 - %266 = OpCompositeExtract %float %mat4x2_f32 0 0 - %267 = OpFunctionCall %int %tint_f32_to_i32 %266 - %268 = OpIAdd %int %265 %267 - %269 = OpCompositeExtract %float %mat4x3_f32 0 0 - %270 = OpFunctionCall %int %tint_f32_to_i32 %269 - %271 = OpIAdd %int %268 %270 - %272 = OpCompositeExtract %float %mat4x4_f32 0 0 - %273 = OpFunctionCall %int %tint_f32_to_i32 %272 - %274 = OpIAdd %int %271 %273 - %275 = OpCompositeExtract %float %arr2_vec3_f32 0 0 - %276 = OpFunctionCall %int %tint_f32_to_i32 %275 - %277 = OpIAdd %int %274 %276 - %278 = OpAccessChain %_ptr_StorageBuffer_int_0 %29 %uint_0 - OpStore %278 %277 None + %247 = OpCompositeExtract %float %vec3_f32 1 + %248 = OpFunctionCall %int %tint_f32_to_i32 %247 + %249 = OpBitcast %uint %246 + %250 = OpBitcast %uint %248 + %251 = OpIAdd %uint %249 %250 + %252 = OpBitcast %int %251 + %253 = OpCompositeExtract %int %vec3_i32 1 + %254 = OpBitcast %uint %252 + %255 = OpBitcast %uint %253 + %256 = OpIAdd %uint %254 %255 + %257 = OpBitcast %int %256 + %258 = OpCompositeExtract %uint %vec3_u32 1 + %259 = OpBitcast %int %258 + %260 = OpBitcast %uint %257 + %261 = OpBitcast %uint %259 + %262 = OpIAdd %uint %260 %261 + %263 = OpBitcast %int %262 + %264 = OpCompositeExtract %float %vec4_f32 2 + %265 = OpFunctionCall %int %tint_f32_to_i32 %264 + %266 = OpBitcast %uint %263 + %267 = OpBitcast %uint %265 + %268 = OpIAdd %uint %266 %267 + %269 = OpBitcast %int %268 + %270 = OpCompositeExtract %int %vec4_i32 2 + %271 = OpBitcast %uint %269 + %272 = OpBitcast %uint %270 + %273 = OpIAdd %uint %271 %272 + %274 = OpBitcast %int %273 + %275 = OpCompositeExtract %uint %vec4_u32 2 + %276 = OpBitcast %int %275 + %277 = OpBitcast %uint %274 + %278 = OpBitcast %uint %276 + %279 = OpIAdd %uint %277 %278 + %280 = OpBitcast %int %279 + %281 = OpCompositeExtract %float %mat2x2_f32 0 0 + %282 = OpFunctionCall %int %tint_f32_to_i32 %281 + %283 = OpBitcast %uint %280 + %284 = OpBitcast %uint %282 + %285 = OpIAdd %uint %283 %284 + %286 = OpBitcast %int %285 + %287 = OpCompositeExtract %float %mat2x3_f32 0 0 + %288 = OpFunctionCall %int %tint_f32_to_i32 %287 + %289 = OpBitcast %uint %286 + %290 = OpBitcast %uint %288 + %291 = OpIAdd %uint %289 %290 + %292 = OpBitcast %int %291 + %293 = OpCompositeExtract %float %mat2x4_f32 0 0 + %294 = OpFunctionCall %int %tint_f32_to_i32 %293 + %295 = OpBitcast %uint %292 + %296 = OpBitcast %uint %294 + %297 = OpIAdd %uint %295 %296 + %298 = OpBitcast %int %297 + %299 = OpCompositeExtract %float %mat3x2_f32 0 0 + %300 = OpFunctionCall %int %tint_f32_to_i32 %299 + %301 = OpBitcast %uint %298 + %302 = OpBitcast %uint %300 + %303 = OpIAdd %uint %301 %302 + %304 = OpBitcast %int %303 + %305 = OpCompositeExtract %float %mat3x3_f32 0 0 + %306 = OpFunctionCall %int %tint_f32_to_i32 %305 + %307 = OpBitcast %uint %304 + %308 = OpBitcast %uint %306 + %309 = OpIAdd %uint %307 %308 + %310 = OpBitcast %int %309 + %311 = OpCompositeExtract %float %mat3x4_f32 0 0 + %312 = OpFunctionCall %int %tint_f32_to_i32 %311 + %313 = OpBitcast %uint %310 + %314 = OpBitcast %uint %312 + %315 = OpIAdd %uint %313 %314 + %316 = OpBitcast %int %315 + %317 = OpCompositeExtract %float %mat4x2_f32 0 0 + %318 = OpFunctionCall %int %tint_f32_to_i32 %317 + %319 = OpBitcast %uint %316 + %320 = OpBitcast %uint %318 + %321 = OpIAdd %uint %319 %320 + %322 = OpBitcast %int %321 + %323 = OpCompositeExtract %float %mat4x3_f32 0 0 + %324 = OpFunctionCall %int %tint_f32_to_i32 %323 + %325 = OpBitcast %uint %322 + %326 = OpBitcast %uint %324 + %327 = OpIAdd %uint %325 %326 + %328 = OpBitcast %int %327 + %329 = OpCompositeExtract %float %mat4x4_f32 0 0 + %330 = OpFunctionCall %int %tint_f32_to_i32 %329 + %331 = OpBitcast %uint %328 + %332 = OpBitcast %uint %330 + %333 = OpIAdd %uint %331 %332 + %334 = OpBitcast %int %333 + %335 = OpCompositeExtract %float %arr2_vec3_f32 0 0 + %336 = OpFunctionCall %int %tint_f32_to_i32 %335 + %337 = OpBitcast %uint %334 + %338 = OpBitcast %uint %336 + %339 = OpIAdd %uint %337 %338 + %340 = OpBitcast %int %339 + %341 = OpAccessChain %_ptr_StorageBuffer_int_0 %29 %uint_0 + OpStore %341 %340 None OpReturn OpFunctionEnd -%tint_f32_to_i32 = OpFunction %int None %281 +%tint_f32_to_i32 = OpFunction %int None %344 %value = OpFunctionParameter %float - %282 = OpLabel - %283 = OpExtInst %float %46 NClamp %value %float_n2_14748365e_09 %float_2_14748352e_09 - %286 = OpConvertFToS %int %283 - OpReturnValue %286 + %345 = OpLabel + %346 = OpExtInst %float %46 NClamp %value %float_n2_14748365e_09 %float_2_14748352e_09 + %349 = OpConvertFToS %int %346 + OpReturnValue %349 OpFunctionEnd - %main = OpFunction %void None %288 - %289 = OpLabel - %290 = OpLoad %uint %main_local_invocation_index_Input None - %291 = OpFunctionCall %void %main_inner %290 + %main = OpFunction %void None %351 + %352 = OpLabel + %353 = OpLoad %uint %main_local_invocation_index_Input None + %354 = OpFunctionCall %void %main_inner %353 OpReturn OpFunctionEnd -%tint_convert_explicit_layout = OpFunction %_arr_v3float_uint_2_0 None %293 +%tint_convert_explicit_layout = OpFunction %_arr_v3float_uint_2_0 None %356 %tint_source = OpFunctionParameter %_arr_v3float_uint_2 - %294 = OpLabel - %295 = OpVariable %_ptr_Function__arr_v3float_uint_2 Function - %297 = OpVariable %_ptr_Function__arr_v3float_uint_2_0 Function %299 - OpStore %295 %tint_source - OpBranch %300 - %300 = OpLabel - OpBranch %303 - %303 = OpLabel - %305 = OpPhi %uint %uint_0 %300 %306 %302 - OpLoopMerge %304 %302 None - OpBranch %301 - %301 = OpLabel - %308 = OpUGreaterThanEqual %bool %305 %uint_2 - OpSelectionMerge %310 None - OpBranchConditional %308 %311 %310 - %311 = OpLabel - OpBranch %304 - %310 = OpLabel - %312 = OpAccessChain %_ptr_Function_v3float %295 %305 - %314 = OpLoad %v3float %312 None - %315 = OpAccessChain %_ptr_Function_v3float %297 %305 - OpStore %315 %314 None - OpBranch %302 - %302 = OpLabel - %306 = OpIAdd %uint %305 %uint_1 - OpBranch %303 - %304 = OpLabel - %307 = OpLoad %_arr_v3float_uint_2_0 %297 None - OpReturnValue %307 + %357 = OpLabel + %358 = OpVariable %_ptr_Function__arr_v3float_uint_2 Function + %360 = OpVariable %_ptr_Function__arr_v3float_uint_2_0 Function %362 + OpStore %358 %tint_source + OpBranch %363 + %363 = OpLabel + OpBranch %366 + %366 = OpLabel + %368 = OpPhi %uint %uint_0 %363 %369 %365 + OpLoopMerge %367 %365 None + OpBranch %364 + %364 = OpLabel + %371 = OpUGreaterThanEqual %bool %368 %uint_2 + OpSelectionMerge %373 None + OpBranchConditional %371 %374 %373 + %374 = OpLabel + OpBranch %367 + %373 = OpLabel + %375 = OpAccessChain %_ptr_Function_v3float %358 %368 + %377 = OpLoad %v3float %375 None + %378 = OpAccessChain %_ptr_Function_v3float %360 %368 + OpStore %378 %377 None + OpBranch %365 + %365 = OpLabel + %369 = OpIAdd %uint %368 %uint_1 + OpBranch %366 + %367 = OpLabel + %370 = OpLoad %_arr_v3float_uint_2_0 %360 None + OpReturnValue %370 OpFunctionEnd
diff --git a/test/tint/buffer/storage/dynamic_index/read_f16.wgsl.expected.glsl b/test/tint/buffer/storage/dynamic_index/read_f16.wgsl.expected.glsl index d1f797c..6a8887c 100644 --- a/test/tint/buffer/storage/dynamic_index/read_f16.wgsl.expected.glsl +++ b/test/tint/buffer/storage/dynamic_index/read_f16.wgsl.expected.glsl
@@ -141,38 +141,104 @@ vec3 arr2_vec3_f32[2] = sb.arr[v_35].arr2_vec3_f32; uint v_36 = min(idx, (uint(sb.arr.length()) - 1u)); f16mat4x2 arr2_mat4x2_f16[2] = sb.arr[v_36].arr2_mat4x2_f16; - int v_37 = (tint_f32_to_i32(scalar_f32) + scalar_i32); - int v_38 = (v_37 + int(scalar_u32)); - int v_39 = (v_38 + tint_f16_to_i32(scalar_f16)); - int v_40 = ((v_39 + tint_f32_to_i32(vec2_f32.x)) + vec2_i32.x); - int v_41 = (v_40 + int(vec2_u32.x)); - int v_42 = (v_41 + tint_f16_to_i32(vec2_f16.x)); - int v_43 = ((v_42 + tint_f32_to_i32(vec3_f32.y)) + vec3_i32.y); - int v_44 = (v_43 + int(vec3_u32.y)); - int v_45 = (v_44 + tint_f16_to_i32(vec3_f16.y)); - int v_46 = ((v_45 + tint_f32_to_i32(vec4_f32.z)) + vec4_i32.z); - int v_47 = (v_46 + int(vec4_u32.z)); - int v_48 = (v_47 + tint_f16_to_i32(vec4_f16.z)); - int v_49 = (v_48 + tint_f32_to_i32(mat2x2_f32[0u].x)); - int v_50 = (v_49 + tint_f32_to_i32(mat2x3_f32[0u].x)); - int v_51 = (v_50 + tint_f32_to_i32(mat2x4_f32[0u].x)); - int v_52 = (v_51 + tint_f32_to_i32(mat3x2_f32[0u].x)); - int v_53 = (v_52 + tint_f32_to_i32(mat3x3_f32[0u].x)); - int v_54 = (v_53 + tint_f32_to_i32(mat3x4_f32[0u].x)); - int v_55 = (v_54 + tint_f32_to_i32(mat4x2_f32[0u].x)); - int v_56 = (v_55 + tint_f32_to_i32(mat4x3_f32[0u].x)); - int v_57 = (v_56 + tint_f32_to_i32(mat4x4_f32[0u].x)); - int v_58 = (v_57 + tint_f16_to_i32(mat2x2_f16[0u].x)); - int v_59 = (v_58 + tint_f16_to_i32(mat2x3_f16[0u].x)); - int v_60 = (v_59 + tint_f16_to_i32(mat2x4_f16[0u].x)); - int v_61 = (v_60 + tint_f16_to_i32(mat3x2_f16[0u].x)); - int v_62 = (v_61 + tint_f16_to_i32(mat3x3_f16[0u].x)); - int v_63 = (v_62 + tint_f16_to_i32(mat3x4_f16[0u].x)); - int v_64 = (v_63 + tint_f16_to_i32(mat4x2_f16[0u].x)); - int v_65 = (v_64 + tint_f16_to_i32(mat4x3_f16[0u].x)); - int v_66 = (v_65 + tint_f16_to_i32(mat4x4_f16[0u].x)); - int v_67 = (v_66 + tint_f16_to_i32(arr2_mat4x2_f16[0u][0u].x)); - v.inner = (v_67 + tint_f32_to_i32(arr2_vec3_f32[0u].x)); + uint v_37 = uint(tint_f32_to_i32(scalar_f32)); + int v_38 = int((v_37 + uint(scalar_i32))); + int v_39 = int(scalar_u32); + uint v_40 = uint(v_38); + int v_41 = int((v_40 + uint(v_39))); + int v_42 = tint_f16_to_i32(scalar_f16); + uint v_43 = uint(v_41); + int v_44 = int((v_43 + uint(v_42))); + int v_45 = tint_f32_to_i32(vec2_f32.x); + uint v_46 = uint(v_44); + uint v_47 = uint(int((v_46 + uint(v_45)))); + int v_48 = int((v_47 + uint(vec2_i32.x))); + int v_49 = int(vec2_u32.x); + uint v_50 = uint(v_48); + int v_51 = int((v_50 + uint(v_49))); + int v_52 = tint_f16_to_i32(vec2_f16.x); + uint v_53 = uint(v_51); + int v_54 = int((v_53 + uint(v_52))); + int v_55 = tint_f32_to_i32(vec3_f32.y); + uint v_56 = uint(v_54); + uint v_57 = uint(int((v_56 + uint(v_55)))); + int v_58 = int((v_57 + uint(vec3_i32.y))); + int v_59 = int(vec3_u32.y); + uint v_60 = uint(v_58); + int v_61 = int((v_60 + uint(v_59))); + int v_62 = tint_f16_to_i32(vec3_f16.y); + uint v_63 = uint(v_61); + int v_64 = int((v_63 + uint(v_62))); + int v_65 = tint_f32_to_i32(vec4_f32.z); + uint v_66 = uint(v_64); + uint v_67 = uint(int((v_66 + uint(v_65)))); + int v_68 = int((v_67 + uint(vec4_i32.z))); + int v_69 = int(vec4_u32.z); + uint v_70 = uint(v_68); + int v_71 = int((v_70 + uint(v_69))); + int v_72 = tint_f16_to_i32(vec4_f16.z); + uint v_73 = uint(v_71); + int v_74 = int((v_73 + uint(v_72))); + int v_75 = tint_f32_to_i32(mat2x2_f32[0u].x); + uint v_76 = uint(v_74); + int v_77 = int((v_76 + uint(v_75))); + int v_78 = tint_f32_to_i32(mat2x3_f32[0u].x); + uint v_79 = uint(v_77); + int v_80 = int((v_79 + uint(v_78))); + int v_81 = tint_f32_to_i32(mat2x4_f32[0u].x); + uint v_82 = uint(v_80); + int v_83 = int((v_82 + uint(v_81))); + int v_84 = tint_f32_to_i32(mat3x2_f32[0u].x); + uint v_85 = uint(v_83); + int v_86 = int((v_85 + uint(v_84))); + int v_87 = tint_f32_to_i32(mat3x3_f32[0u].x); + uint v_88 = uint(v_86); + int v_89 = int((v_88 + uint(v_87))); + int v_90 = tint_f32_to_i32(mat3x4_f32[0u].x); + uint v_91 = uint(v_89); + int v_92 = int((v_91 + uint(v_90))); + int v_93 = tint_f32_to_i32(mat4x2_f32[0u].x); + uint v_94 = uint(v_92); + int v_95 = int((v_94 + uint(v_93))); + int v_96 = tint_f32_to_i32(mat4x3_f32[0u].x); + uint v_97 = uint(v_95); + int v_98 = int((v_97 + uint(v_96))); + int v_99 = tint_f32_to_i32(mat4x4_f32[0u].x); + uint v_100 = uint(v_98); + int v_101 = int((v_100 + uint(v_99))); + int v_102 = tint_f16_to_i32(mat2x2_f16[0u].x); + uint v_103 = uint(v_101); + int v_104 = int((v_103 + uint(v_102))); + int v_105 = tint_f16_to_i32(mat2x3_f16[0u].x); + uint v_106 = uint(v_104); + int v_107 = int((v_106 + uint(v_105))); + int v_108 = tint_f16_to_i32(mat2x4_f16[0u].x); + uint v_109 = uint(v_107); + int v_110 = int((v_109 + uint(v_108))); + int v_111 = tint_f16_to_i32(mat3x2_f16[0u].x); + uint v_112 = uint(v_110); + int v_113 = int((v_112 + uint(v_111))); + int v_114 = tint_f16_to_i32(mat3x3_f16[0u].x); + uint v_115 = uint(v_113); + int v_116 = int((v_115 + uint(v_114))); + int v_117 = tint_f16_to_i32(mat3x4_f16[0u].x); + uint v_118 = uint(v_116); + int v_119 = int((v_118 + uint(v_117))); + int v_120 = tint_f16_to_i32(mat4x2_f16[0u].x); + uint v_121 = uint(v_119); + int v_122 = int((v_121 + uint(v_120))); + int v_123 = tint_f16_to_i32(mat4x3_f16[0u].x); + uint v_124 = uint(v_122); + int v_125 = int((v_124 + uint(v_123))); + int v_126 = tint_f16_to_i32(mat4x4_f16[0u].x); + uint v_127 = uint(v_125); + int v_128 = int((v_127 + uint(v_126))); + int v_129 = tint_f16_to_i32(arr2_mat4x2_f16[0u][0u].x); + uint v_130 = uint(v_128); + int v_131 = int((v_130 + uint(v_129))); + int v_132 = tint_f32_to_i32(arr2_vec3_f32[0u].x); + uint v_133 = uint(v_131); + v.inner = int((v_133 + uint(v_132))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/buffer/storage/dynamic_index/read_f16.wgsl.expected.spvasm b/test/tint/buffer/storage/dynamic_index/read_f16.wgsl.expected.spvasm index 12ff1aa..c038cba 100644 --- a/test/tint/buffer/storage/dynamic_index/read_f16.wgsl.expected.spvasm +++ b/test/tint/buffer/storage/dynamic_index/read_f16.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 517 +; Bound: 622 ; Schema: 0 OpCapability Shader OpCapability Float16 @@ -313,23 +313,23 @@ %uint_35 = OpConstant %uint 35 %_arr_mat4v2half_uint_2_0 = OpTypeArray %mat4v2half %uint_2 %_ptr_StorageBuffer_int_0 = OpTypePointer StorageBuffer %int - %452 = OpTypeFunction %int %float + %557 = OpTypeFunction %int %float %float_n2_14748365e_09 = OpConstant %float -2.14748365e+09 %float_2_14748352e_09 = OpConstant %float 2.14748352e+09 - %459 = OpTypeFunction %int %half + %564 = OpTypeFunction %int %half %half_n0x1_ffcp_15 = OpConstant %half -0x1.ffcp+15 %half_0x1_ffcp_15 = OpConstant %half 0x1.ffcp+15 - %466 = OpTypeFunction %void - %471 = OpTypeFunction %_arr_v3float_uint_2_0 %_arr_v3float_uint_2 + %571 = OpTypeFunction %void + %576 = OpTypeFunction %_arr_v3float_uint_2_0 %_arr_v3float_uint_2 %_ptr_Function__arr_v3float_uint_2 = OpTypePointer Function %_arr_v3float_uint_2 %_ptr_Function__arr_v3float_uint_2_0 = OpTypePointer Function %_arr_v3float_uint_2_0 - %477 = OpConstantNull %_arr_v3float_uint_2_0 + %582 = OpConstantNull %_arr_v3float_uint_2_0 %bool = OpTypeBool %_ptr_Function_v3float = OpTypePointer Function %v3float - %495 = OpTypeFunction %_arr_mat4v2half_uint_2_0 %_arr_mat4v2half_uint_2 + %600 = OpTypeFunction %_arr_mat4v2half_uint_2_0 %_arr_mat4v2half_uint_2 %_ptr_Function__arr_mat4v2half_uint_2 = OpTypePointer Function %_arr_mat4v2half_uint_2 %_ptr_Function__arr_mat4v2half_uint_2_0 = OpTypePointer Function %_arr_mat4v2half_uint_2_0 - %501 = OpConstantNull %_arr_mat4v2half_uint_2_0 + %606 = OpConstantNull %_arr_mat4v2half_uint_2_0 %_ptr_Function_mat4v2half = OpTypePointer Function %mat4v2half %main_inner = OpFunction %void None %51 %idx = OpFunctionParameter %uint @@ -553,189 +553,294 @@ %344 = OpLoad %_arr_mat4v2half_uint_2 %341 None %arr2_mat4x2_f16 = OpFunctionCall %_arr_mat4v2half_uint_2_0 %tint_convert_explicit_layout_0 %344 %348 = OpFunctionCall %int %tint_f32_to_i32 %scalar_f32 - %350 = OpIAdd %int %348 %scalar_i32 - %351 = OpBitcast %int %scalar_u32 - %352 = OpIAdd %int %350 %351 - %353 = OpFunctionCall %int %tint_f16_to_i32 %scalar_f16 - %355 = OpIAdd %int %352 %353 - %356 = OpCompositeExtract %float %vec2_f32 0 - %357 = OpFunctionCall %int %tint_f32_to_i32 %356 - %358 = OpIAdd %int %355 %357 - %359 = OpCompositeExtract %int %vec2_i32 0 - %360 = OpIAdd %int %358 %359 - %361 = OpCompositeExtract %uint %vec2_u32 0 - %362 = OpBitcast %int %361 - %363 = OpIAdd %int %360 %362 - %364 = OpCompositeExtract %half %vec2_f16 0 - %365 = OpFunctionCall %int %tint_f16_to_i32 %364 - %366 = OpIAdd %int %363 %365 - %367 = OpCompositeExtract %float %vec3_f32 1 - %368 = OpFunctionCall %int %tint_f32_to_i32 %367 - %369 = OpIAdd %int %366 %368 - %370 = OpCompositeExtract %int %vec3_i32 1 - %371 = OpIAdd %int %369 %370 - %372 = OpCompositeExtract %uint %vec3_u32 1 - %373 = OpBitcast %int %372 - %374 = OpIAdd %int %371 %373 - %375 = OpCompositeExtract %half %vec3_f16 1 - %376 = OpFunctionCall %int %tint_f16_to_i32 %375 - %377 = OpIAdd %int %374 %376 - %378 = OpCompositeExtract %float %vec4_f32 2 - %379 = OpFunctionCall %int %tint_f32_to_i32 %378 - %380 = OpIAdd %int %377 %379 - %381 = OpCompositeExtract %int %vec4_i32 2 - %382 = OpIAdd %int %380 %381 - %383 = OpCompositeExtract %uint %vec4_u32 2 - %384 = OpBitcast %int %383 - %385 = OpIAdd %int %382 %384 - %386 = OpCompositeExtract %half %vec4_f16 2 - %387 = OpFunctionCall %int %tint_f16_to_i32 %386 - %388 = OpIAdd %int %385 %387 - %389 = OpCompositeExtract %float %mat2x2_f32 0 0 - %390 = OpFunctionCall %int %tint_f32_to_i32 %389 - %391 = OpIAdd %int %388 %390 - %392 = OpCompositeExtract %float %mat2x3_f32 0 0 - %393 = OpFunctionCall %int %tint_f32_to_i32 %392 - %394 = OpIAdd %int %391 %393 - %395 = OpCompositeExtract %float %mat2x4_f32 0 0 - %396 = OpFunctionCall %int %tint_f32_to_i32 %395 - %397 = OpIAdd %int %394 %396 - %398 = OpCompositeExtract %float %mat3x2_f32 0 0 - %399 = OpFunctionCall %int %tint_f32_to_i32 %398 - %400 = OpIAdd %int %397 %399 - %401 = OpCompositeExtract %float %mat3x3_f32 0 0 - %402 = OpFunctionCall %int %tint_f32_to_i32 %401 - %403 = OpIAdd %int %400 %402 - %404 = OpCompositeExtract %float %mat3x4_f32 0 0 - %405 = OpFunctionCall %int %tint_f32_to_i32 %404 - %406 = OpIAdd %int %403 %405 - %407 = OpCompositeExtract %float %mat4x2_f32 0 0 - %408 = OpFunctionCall %int %tint_f32_to_i32 %407 - %409 = OpIAdd %int %406 %408 - %410 = OpCompositeExtract %float %mat4x3_f32 0 0 - %411 = OpFunctionCall %int %tint_f32_to_i32 %410 - %412 = OpIAdd %int %409 %411 - %413 = OpCompositeExtract %float %mat4x4_f32 0 0 - %414 = OpFunctionCall %int %tint_f32_to_i32 %413 - %415 = OpIAdd %int %412 %414 - %416 = OpCompositeExtract %half %mat2x2_f16 0 0 - %417 = OpFunctionCall %int %tint_f16_to_i32 %416 - %418 = OpIAdd %int %415 %417 - %419 = OpCompositeExtract %half %mat2x3_f16 0 0 - %420 = OpFunctionCall %int %tint_f16_to_i32 %419 - %421 = OpIAdd %int %418 %420 - %422 = OpCompositeExtract %half %mat2x4_f16 0 0 - %423 = OpFunctionCall %int %tint_f16_to_i32 %422 - %424 = OpIAdd %int %421 %423 - %425 = OpCompositeExtract %half %mat3x2_f16 0 0 - %426 = OpFunctionCall %int %tint_f16_to_i32 %425 - %427 = OpIAdd %int %424 %426 - %428 = OpCompositeExtract %half %mat3x3_f16 0 0 + %350 = OpBitcast %uint %348 + %351 = OpBitcast %uint %scalar_i32 + %352 = OpIAdd %uint %350 %351 + %353 = OpBitcast %int %352 + %354 = OpBitcast %int %scalar_u32 + %355 = OpBitcast %uint %353 + %356 = OpBitcast %uint %354 + %357 = OpIAdd %uint %355 %356 + %358 = OpBitcast %int %357 + %359 = OpFunctionCall %int %tint_f16_to_i32 %scalar_f16 + %361 = OpBitcast %uint %358 + %362 = OpBitcast %uint %359 + %363 = OpIAdd %uint %361 %362 + %364 = OpBitcast %int %363 + %365 = OpCompositeExtract %float %vec2_f32 0 + %366 = OpFunctionCall %int %tint_f32_to_i32 %365 + %367 = OpBitcast %uint %364 + %368 = OpBitcast %uint %366 + %369 = OpIAdd %uint %367 %368 + %370 = OpBitcast %int %369 + %371 = OpCompositeExtract %int %vec2_i32 0 + %372 = OpBitcast %uint %370 + %373 = OpBitcast %uint %371 + %374 = OpIAdd %uint %372 %373 + %375 = OpBitcast %int %374 + %376 = OpCompositeExtract %uint %vec2_u32 0 + %377 = OpBitcast %int %376 + %378 = OpBitcast %uint %375 + %379 = OpBitcast %uint %377 + %380 = OpIAdd %uint %378 %379 + %381 = OpBitcast %int %380 + %382 = OpCompositeExtract %half %vec2_f16 0 + %383 = OpFunctionCall %int %tint_f16_to_i32 %382 + %384 = OpBitcast %uint %381 + %385 = OpBitcast %uint %383 + %386 = OpIAdd %uint %384 %385 + %387 = OpBitcast %int %386 + %388 = OpCompositeExtract %float %vec3_f32 1 + %389 = OpFunctionCall %int %tint_f32_to_i32 %388 + %390 = OpBitcast %uint %387 + %391 = OpBitcast %uint %389 + %392 = OpIAdd %uint %390 %391 + %393 = OpBitcast %int %392 + %394 = OpCompositeExtract %int %vec3_i32 1 + %395 = OpBitcast %uint %393 + %396 = OpBitcast %uint %394 + %397 = OpIAdd %uint %395 %396 + %398 = OpBitcast %int %397 + %399 = OpCompositeExtract %uint %vec3_u32 1 + %400 = OpBitcast %int %399 + %401 = OpBitcast %uint %398 + %402 = OpBitcast %uint %400 + %403 = OpIAdd %uint %401 %402 + %404 = OpBitcast %int %403 + %405 = OpCompositeExtract %half %vec3_f16 1 + %406 = OpFunctionCall %int %tint_f16_to_i32 %405 + %407 = OpBitcast %uint %404 + %408 = OpBitcast %uint %406 + %409 = OpIAdd %uint %407 %408 + %410 = OpBitcast %int %409 + %411 = OpCompositeExtract %float %vec4_f32 2 + %412 = OpFunctionCall %int %tint_f32_to_i32 %411 + %413 = OpBitcast %uint %410 + %414 = OpBitcast %uint %412 + %415 = OpIAdd %uint %413 %414 + %416 = OpBitcast %int %415 + %417 = OpCompositeExtract %int %vec4_i32 2 + %418 = OpBitcast %uint %416 + %419 = OpBitcast %uint %417 + %420 = OpIAdd %uint %418 %419 + %421 = OpBitcast %int %420 + %422 = OpCompositeExtract %uint %vec4_u32 2 + %423 = OpBitcast %int %422 + %424 = OpBitcast %uint %421 + %425 = OpBitcast %uint %423 + %426 = OpIAdd %uint %424 %425 + %427 = OpBitcast %int %426 + %428 = OpCompositeExtract %half %vec4_f16 2 %429 = OpFunctionCall %int %tint_f16_to_i32 %428 - %430 = OpIAdd %int %427 %429 - %431 = OpCompositeExtract %half %mat3x4_f16 0 0 - %432 = OpFunctionCall %int %tint_f16_to_i32 %431 - %433 = OpIAdd %int %430 %432 - %434 = OpCompositeExtract %half %mat4x2_f16 0 0 - %435 = OpFunctionCall %int %tint_f16_to_i32 %434 - %436 = OpIAdd %int %433 %435 - %437 = OpCompositeExtract %half %mat4x3_f16 0 0 - %438 = OpFunctionCall %int %tint_f16_to_i32 %437 - %439 = OpIAdd %int %436 %438 - %440 = OpCompositeExtract %half %mat4x4_f16 0 0 - %441 = OpFunctionCall %int %tint_f16_to_i32 %440 - %442 = OpIAdd %int %439 %441 - %443 = OpCompositeExtract %half %arr2_mat4x2_f16 0 0 0 - %444 = OpFunctionCall %int %tint_f16_to_i32 %443 - %445 = OpIAdd %int %442 %444 - %446 = OpCompositeExtract %float %arr2_vec3_f32 0 0 + %430 = OpBitcast %uint %427 + %431 = OpBitcast %uint %429 + %432 = OpIAdd %uint %430 %431 + %433 = OpBitcast %int %432 + %434 = OpCompositeExtract %float %mat2x2_f32 0 0 + %435 = OpFunctionCall %int %tint_f32_to_i32 %434 + %436 = OpBitcast %uint %433 + %437 = OpBitcast %uint %435 + %438 = OpIAdd %uint %436 %437 + %439 = OpBitcast %int %438 + %440 = OpCompositeExtract %float %mat2x3_f32 0 0 + %441 = OpFunctionCall %int %tint_f32_to_i32 %440 + %442 = OpBitcast %uint %439 + %443 = OpBitcast %uint %441 + %444 = OpIAdd %uint %442 %443 + %445 = OpBitcast %int %444 + %446 = OpCompositeExtract %float %mat2x4_f32 0 0 %447 = OpFunctionCall %int %tint_f32_to_i32 %446 - %448 = OpIAdd %int %445 %447 - %449 = OpAccessChain %_ptr_StorageBuffer_int_0 %43 %uint_0 - OpStore %449 %448 None + %448 = OpBitcast %uint %445 + %449 = OpBitcast %uint %447 + %450 = OpIAdd %uint %448 %449 + %451 = OpBitcast %int %450 + %452 = OpCompositeExtract %float %mat3x2_f32 0 0 + %453 = OpFunctionCall %int %tint_f32_to_i32 %452 + %454 = OpBitcast %uint %451 + %455 = OpBitcast %uint %453 + %456 = OpIAdd %uint %454 %455 + %457 = OpBitcast %int %456 + %458 = OpCompositeExtract %float %mat3x3_f32 0 0 + %459 = OpFunctionCall %int %tint_f32_to_i32 %458 + %460 = OpBitcast %uint %457 + %461 = OpBitcast %uint %459 + %462 = OpIAdd %uint %460 %461 + %463 = OpBitcast %int %462 + %464 = OpCompositeExtract %float %mat3x4_f32 0 0 + %465 = OpFunctionCall %int %tint_f32_to_i32 %464 + %466 = OpBitcast %uint %463 + %467 = OpBitcast %uint %465 + %468 = OpIAdd %uint %466 %467 + %469 = OpBitcast %int %468 + %470 = OpCompositeExtract %float %mat4x2_f32 0 0 + %471 = OpFunctionCall %int %tint_f32_to_i32 %470 + %472 = OpBitcast %uint %469 + %473 = OpBitcast %uint %471 + %474 = OpIAdd %uint %472 %473 + %475 = OpBitcast %int %474 + %476 = OpCompositeExtract %float %mat4x3_f32 0 0 + %477 = OpFunctionCall %int %tint_f32_to_i32 %476 + %478 = OpBitcast %uint %475 + %479 = OpBitcast %uint %477 + %480 = OpIAdd %uint %478 %479 + %481 = OpBitcast %int %480 + %482 = OpCompositeExtract %float %mat4x4_f32 0 0 + %483 = OpFunctionCall %int %tint_f32_to_i32 %482 + %484 = OpBitcast %uint %481 + %485 = OpBitcast %uint %483 + %486 = OpIAdd %uint %484 %485 + %487 = OpBitcast %int %486 + %488 = OpCompositeExtract %half %mat2x2_f16 0 0 + %489 = OpFunctionCall %int %tint_f16_to_i32 %488 + %490 = OpBitcast %uint %487 + %491 = OpBitcast %uint %489 + %492 = OpIAdd %uint %490 %491 + %493 = OpBitcast %int %492 + %494 = OpCompositeExtract %half %mat2x3_f16 0 0 + %495 = OpFunctionCall %int %tint_f16_to_i32 %494 + %496 = OpBitcast %uint %493 + %497 = OpBitcast %uint %495 + %498 = OpIAdd %uint %496 %497 + %499 = OpBitcast %int %498 + %500 = OpCompositeExtract %half %mat2x4_f16 0 0 + %501 = OpFunctionCall %int %tint_f16_to_i32 %500 + %502 = OpBitcast %uint %499 + %503 = OpBitcast %uint %501 + %504 = OpIAdd %uint %502 %503 + %505 = OpBitcast %int %504 + %506 = OpCompositeExtract %half %mat3x2_f16 0 0 + %507 = OpFunctionCall %int %tint_f16_to_i32 %506 + %508 = OpBitcast %uint %505 + %509 = OpBitcast %uint %507 + %510 = OpIAdd %uint %508 %509 + %511 = OpBitcast %int %510 + %512 = OpCompositeExtract %half %mat3x3_f16 0 0 + %513 = OpFunctionCall %int %tint_f16_to_i32 %512 + %514 = OpBitcast %uint %511 + %515 = OpBitcast %uint %513 + %516 = OpIAdd %uint %514 %515 + %517 = OpBitcast %int %516 + %518 = OpCompositeExtract %half %mat3x4_f16 0 0 + %519 = OpFunctionCall %int %tint_f16_to_i32 %518 + %520 = OpBitcast %uint %517 + %521 = OpBitcast %uint %519 + %522 = OpIAdd %uint %520 %521 + %523 = OpBitcast %int %522 + %524 = OpCompositeExtract %half %mat4x2_f16 0 0 + %525 = OpFunctionCall %int %tint_f16_to_i32 %524 + %526 = OpBitcast %uint %523 + %527 = OpBitcast %uint %525 + %528 = OpIAdd %uint %526 %527 + %529 = OpBitcast %int %528 + %530 = OpCompositeExtract %half %mat4x3_f16 0 0 + %531 = OpFunctionCall %int %tint_f16_to_i32 %530 + %532 = OpBitcast %uint %529 + %533 = OpBitcast %uint %531 + %534 = OpIAdd %uint %532 %533 + %535 = OpBitcast %int %534 + %536 = OpCompositeExtract %half %mat4x4_f16 0 0 + %537 = OpFunctionCall %int %tint_f16_to_i32 %536 + %538 = OpBitcast %uint %535 + %539 = OpBitcast %uint %537 + %540 = OpIAdd %uint %538 %539 + %541 = OpBitcast %int %540 + %542 = OpCompositeExtract %half %arr2_mat4x2_f16 0 0 0 + %543 = OpFunctionCall %int %tint_f16_to_i32 %542 + %544 = OpBitcast %uint %541 + %545 = OpBitcast %uint %543 + %546 = OpIAdd %uint %544 %545 + %547 = OpBitcast %int %546 + %548 = OpCompositeExtract %float %arr2_vec3_f32 0 0 + %549 = OpFunctionCall %int %tint_f32_to_i32 %548 + %550 = OpBitcast %uint %547 + %551 = OpBitcast %uint %549 + %552 = OpIAdd %uint %550 %551 + %553 = OpBitcast %int %552 + %554 = OpAccessChain %_ptr_StorageBuffer_int_0 %43 %uint_0 + OpStore %554 %553 None OpReturn OpFunctionEnd -%tint_f32_to_i32 = OpFunction %int None %452 +%tint_f32_to_i32 = OpFunction %int None %557 %value = OpFunctionParameter %float - %453 = OpLabel - %454 = OpExtInst %float %60 NClamp %value %float_n2_14748365e_09 %float_2_14748352e_09 - %457 = OpConvertFToS %int %454 - OpReturnValue %457 + %558 = OpLabel + %559 = OpExtInst %float %60 NClamp %value %float_n2_14748365e_09 %float_2_14748352e_09 + %562 = OpConvertFToS %int %559 + OpReturnValue %562 OpFunctionEnd -%tint_f16_to_i32 = OpFunction %int None %459 +%tint_f16_to_i32 = OpFunction %int None %564 %value_0 = OpFunctionParameter %half - %460 = OpLabel - %461 = OpExtInst %half %60 NClamp %value_0 %half_n0x1_ffcp_15 %half_0x1_ffcp_15 - %464 = OpConvertFToS %int %461 - OpReturnValue %464 + %565 = OpLabel + %566 = OpExtInst %half %60 NClamp %value_0 %half_n0x1_ffcp_15 %half_0x1_ffcp_15 + %569 = OpConvertFToS %int %566 + OpReturnValue %569 OpFunctionEnd - %main = OpFunction %void None %466 - %467 = OpLabel - %468 = OpLoad %uint %main_local_invocation_index_Input None - %469 = OpFunctionCall %void %main_inner %468 + %main = OpFunction %void None %571 + %572 = OpLabel + %573 = OpLoad %uint %main_local_invocation_index_Input None + %574 = OpFunctionCall %void %main_inner %573 OpReturn OpFunctionEnd -%tint_convert_explicit_layout = OpFunction %_arr_v3float_uint_2_0 None %471 +%tint_convert_explicit_layout = OpFunction %_arr_v3float_uint_2_0 None %576 %tint_source = OpFunctionParameter %_arr_v3float_uint_2 - %472 = OpLabel - %473 = OpVariable %_ptr_Function__arr_v3float_uint_2 Function - %475 = OpVariable %_ptr_Function__arr_v3float_uint_2_0 Function %477 - OpStore %473 %tint_source - OpBranch %478 - %478 = OpLabel - OpBranch %481 - %481 = OpLabel - %483 = OpPhi %uint %uint_0 %478 %484 %480 - OpLoopMerge %482 %480 None - OpBranch %479 - %479 = OpLabel - %486 = OpUGreaterThanEqual %bool %483 %uint_2 - OpSelectionMerge %488 None - OpBranchConditional %486 %489 %488 - %489 = OpLabel - OpBranch %482 - %488 = OpLabel - %490 = OpAccessChain %_ptr_Function_v3float %473 %483 - %492 = OpLoad %v3float %490 None - %493 = OpAccessChain %_ptr_Function_v3float %475 %483 - OpStore %493 %492 None - OpBranch %480 - %480 = OpLabel - %484 = OpIAdd %uint %483 %uint_1 - OpBranch %481 - %482 = OpLabel - %485 = OpLoad %_arr_v3float_uint_2_0 %475 None - OpReturnValue %485 + %577 = OpLabel + %578 = OpVariable %_ptr_Function__arr_v3float_uint_2 Function + %580 = OpVariable %_ptr_Function__arr_v3float_uint_2_0 Function %582 + OpStore %578 %tint_source + OpBranch %583 + %583 = OpLabel + OpBranch %586 + %586 = OpLabel + %588 = OpPhi %uint %uint_0 %583 %589 %585 + OpLoopMerge %587 %585 None + OpBranch %584 + %584 = OpLabel + %591 = OpUGreaterThanEqual %bool %588 %uint_2 + OpSelectionMerge %593 None + OpBranchConditional %591 %594 %593 + %594 = OpLabel + OpBranch %587 + %593 = OpLabel + %595 = OpAccessChain %_ptr_Function_v3float %578 %588 + %597 = OpLoad %v3float %595 None + %598 = OpAccessChain %_ptr_Function_v3float %580 %588 + OpStore %598 %597 None + OpBranch %585 + %585 = OpLabel + %589 = OpIAdd %uint %588 %uint_1 + OpBranch %586 + %587 = OpLabel + %590 = OpLoad %_arr_v3float_uint_2_0 %580 None + OpReturnValue %590 OpFunctionEnd -%tint_convert_explicit_layout_0 = OpFunction %_arr_mat4v2half_uint_2_0 None %495 +%tint_convert_explicit_layout_0 = OpFunction %_arr_mat4v2half_uint_2_0 None %600 %tint_source_0 = OpFunctionParameter %_arr_mat4v2half_uint_2 - %496 = OpLabel - %497 = OpVariable %_ptr_Function__arr_mat4v2half_uint_2 Function - %499 = OpVariable %_ptr_Function__arr_mat4v2half_uint_2_0 Function %501 - OpStore %497 %tint_source_0 - OpBranch %502 - %502 = OpLabel - OpBranch %505 - %505 = OpLabel - %507 = OpPhi %uint %uint_0 %502 %508 %504 - OpLoopMerge %506 %504 None - OpBranch %503 - %503 = OpLabel - %510 = OpUGreaterThanEqual %bool %507 %uint_2 - OpSelectionMerge %511 None - OpBranchConditional %510 %512 %511 - %512 = OpLabel - OpBranch %506 - %511 = OpLabel - %513 = OpAccessChain %_ptr_Function_mat4v2half %497 %507 - %515 = OpLoad %mat4v2half %513 None - %516 = OpAccessChain %_ptr_Function_mat4v2half %499 %507 - OpStore %516 %515 None - OpBranch %504 - %504 = OpLabel - %508 = OpIAdd %uint %507 %uint_1 - OpBranch %505 - %506 = OpLabel - %509 = OpLoad %_arr_mat4v2half_uint_2_0 %499 None - OpReturnValue %509 + %601 = OpLabel + %602 = OpVariable %_ptr_Function__arr_mat4v2half_uint_2 Function + %604 = OpVariable %_ptr_Function__arr_mat4v2half_uint_2_0 Function %606 + OpStore %602 %tint_source_0 + OpBranch %607 + %607 = OpLabel + OpBranch %610 + %610 = OpLabel + %612 = OpPhi %uint %uint_0 %607 %613 %609 + OpLoopMerge %611 %609 None + OpBranch %608 + %608 = OpLabel + %615 = OpUGreaterThanEqual %bool %612 %uint_2 + OpSelectionMerge %616 None + OpBranchConditional %615 %617 %616 + %617 = OpLabel + OpBranch %611 + %616 = OpLabel + %618 = OpAccessChain %_ptr_Function_mat4v2half %602 %612 + %620 = OpLoad %mat4v2half %618 None + %621 = OpAccessChain %_ptr_Function_mat4v2half %604 %612 + OpStore %621 %620 None + OpBranch %609 + %609 = OpLabel + %613 = OpIAdd %uint %612 %uint_1 + OpBranch %610 + %611 = OpLabel + %614 = OpLoad %_arr_mat4v2half_uint_2_0 %604 None + OpReturnValue %614 OpFunctionEnd
diff --git a/test/tint/buffer/storage/static_index/read.wgsl.expected.glsl b/test/tint/buffer/storage/static_index/read.wgsl.expected.glsl index ec2ec82..c36b600 100644 --- a/test/tint/buffer/storage/static_index/read.wgsl.expected.glsl +++ b/test/tint/buffer/storage/static_index/read.wgsl.expected.glsl
@@ -80,22 +80,62 @@ vec3 arr2_vec3_f32[2] = v.inner.arr2_vec3_f32; Inner struct_inner = v.inner.struct_inner; Inner array_struct_inner[4] = v.inner.array_struct_inner; - int v_2 = (tint_f32_to_i32(scalar_f32) + scalar_i32); - int v_3 = (v_2 + int(scalar_u32)); - int v_4 = ((v_3 + tint_f32_to_i32(vec2_f32.x)) + vec2_i32.x); - int v_5 = (v_4 + int(vec2_u32.x)); - int v_6 = ((v_5 + tint_f32_to_i32(vec3_f32.y)) + vec3_i32.y); - int v_7 = (v_6 + int(vec3_u32.y)); - int v_8 = ((v_7 + tint_f32_to_i32(vec4_f32.z)) + vec4_i32.z); - int v_9 = (v_8 + int(vec4_u32.z)); - int v_10 = (v_9 + tint_f32_to_i32(mat2x2_f32[0u].x)); - int v_11 = (v_10 + tint_f32_to_i32(mat2x3_f32[0u].x)); - int v_12 = (v_11 + tint_f32_to_i32(mat2x4_f32[0u].x)); - int v_13 = (v_12 + tint_f32_to_i32(mat3x2_f32[0u].x)); - int v_14 = (v_13 + tint_f32_to_i32(mat3x3_f32[0u].x)); - int v_15 = (v_14 + tint_f32_to_i32(mat3x4_f32[0u].x)); - int v_16 = (v_15 + tint_f32_to_i32(mat4x2_f32[0u].x)); - int v_17 = (v_16 + tint_f32_to_i32(mat4x3_f32[0u].x)); - int v_18 = (v_17 + tint_f32_to_i32(mat4x4_f32[0u].x)); - v_1.inner = (((v_18 + tint_f32_to_i32(arr2_vec3_f32[0u].x)) + struct_inner.scalar_i32) + array_struct_inner[0u].scalar_i32); + uint v_2 = uint(tint_f32_to_i32(scalar_f32)); + int v_3 = int((v_2 + uint(scalar_i32))); + int v_4 = int(scalar_u32); + uint v_5 = uint(v_3); + int v_6 = int((v_5 + uint(v_4))); + int v_7 = tint_f32_to_i32(vec2_f32.x); + uint v_8 = uint(v_6); + uint v_9 = uint(int((v_8 + uint(v_7)))); + int v_10 = int((v_9 + uint(vec2_i32.x))); + int v_11 = int(vec2_u32.x); + uint v_12 = uint(v_10); + int v_13 = int((v_12 + uint(v_11))); + int v_14 = tint_f32_to_i32(vec3_f32.y); + uint v_15 = uint(v_13); + uint v_16 = uint(int((v_15 + uint(v_14)))); + int v_17 = int((v_16 + uint(vec3_i32.y))); + int v_18 = int(vec3_u32.y); + uint v_19 = uint(v_17); + int v_20 = int((v_19 + uint(v_18))); + int v_21 = tint_f32_to_i32(vec4_f32.z); + uint v_22 = uint(v_20); + uint v_23 = uint(int((v_22 + uint(v_21)))); + int v_24 = int((v_23 + uint(vec4_i32.z))); + int v_25 = int(vec4_u32.z); + uint v_26 = uint(v_24); + int v_27 = int((v_26 + uint(v_25))); + int v_28 = tint_f32_to_i32(mat2x2_f32[0u].x); + uint v_29 = uint(v_27); + int v_30 = int((v_29 + uint(v_28))); + int v_31 = tint_f32_to_i32(mat2x3_f32[0u].x); + uint v_32 = uint(v_30); + int v_33 = int((v_32 + uint(v_31))); + int v_34 = tint_f32_to_i32(mat2x4_f32[0u].x); + uint v_35 = uint(v_33); + int v_36 = int((v_35 + uint(v_34))); + int v_37 = tint_f32_to_i32(mat3x2_f32[0u].x); + uint v_38 = uint(v_36); + int v_39 = int((v_38 + uint(v_37))); + int v_40 = tint_f32_to_i32(mat3x3_f32[0u].x); + uint v_41 = uint(v_39); + int v_42 = int((v_41 + uint(v_40))); + int v_43 = tint_f32_to_i32(mat3x4_f32[0u].x); + uint v_44 = uint(v_42); + int v_45 = int((v_44 + uint(v_43))); + int v_46 = tint_f32_to_i32(mat4x2_f32[0u].x); + uint v_47 = uint(v_45); + int v_48 = int((v_47 + uint(v_46))); + int v_49 = tint_f32_to_i32(mat4x3_f32[0u].x); + uint v_50 = uint(v_48); + int v_51 = int((v_50 + uint(v_49))); + int v_52 = tint_f32_to_i32(mat4x4_f32[0u].x); + uint v_53 = uint(v_51); + int v_54 = int((v_53 + uint(v_52))); + int v_55 = tint_f32_to_i32(arr2_vec3_f32[0u].x); + uint v_56 = uint(v_54); + uint v_57 = uint(int((v_56 + uint(v_55)))); + uint v_58 = uint(int((v_57 + uint(struct_inner.scalar_i32)))); + v_1.inner = int((v_58 + uint(array_struct_inner[0u].scalar_i32))); }
diff --git a/test/tint/buffer/storage/static_index/read.wgsl.expected.spvasm b/test/tint/buffer/storage/static_index/read.wgsl.expected.spvasm index d34c40e..d89004f 100644 --- a/test/tint/buffer/storage/static_index/read.wgsl.expected.spvasm +++ b/test/tint/buffer/storage/static_index/read.wgsl.expected.spvasm
@@ -1,10 +1,10 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 258 +; Bound: 327 ; Schema: 0 OpCapability Shader - %207 = OpExtInstImport "GLSL.std.450" + %276 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %main "main" OpExecutionMode %main LocalSize 1 1 1 @@ -211,19 +211,19 @@ %uint_23 = OpConstant %uint 23 %_arr_Inner_uint_4_0 = OpTypeArray %Inner %uint_4 %_ptr_StorageBuffer_int_0 = OpTypePointer StorageBuffer %int - %204 = OpTypeFunction %int %float + %273 = OpTypeFunction %int %float %float_n2_14748365e_09 = OpConstant %float -2.14748365e+09 %float_2_14748352e_09 = OpConstant %float 2.14748352e+09 - %212 = OpTypeFunction %_arr_v3float_uint_2_0 %_arr_v3float_uint_2 + %281 = OpTypeFunction %_arr_v3float_uint_2_0 %_arr_v3float_uint_2 %_ptr_Function__arr_v3float_uint_2 = OpTypePointer Function %_arr_v3float_uint_2 %_ptr_Function__arr_v3float_uint_2_0 = OpTypePointer Function %_arr_v3float_uint_2_0 - %218 = OpConstantNull %_arr_v3float_uint_2_0 + %287 = OpConstantNull %_arr_v3float_uint_2_0 %bool = OpTypeBool %_ptr_Function_v3float = OpTypePointer Function %v3float - %236 = OpTypeFunction %_arr_Inner_uint_4_0 %_arr_Inner_uint_4 + %305 = OpTypeFunction %_arr_Inner_uint_4_0 %_arr_Inner_uint_4 %_ptr_Function__arr_Inner_uint_4 = OpTypePointer Function %_arr_Inner_uint_4 %_ptr_Function__arr_Inner_uint_4_0 = OpTypePointer Function %_arr_Inner_uint_4_0 - %242 = OpConstantNull %_arr_Inner_uint_4_0 + %311 = OpConstantNull %_arr_Inner_uint_4_0 %_ptr_Function_Inner = OpTypePointer Function %Inner %main = OpFunction %void None %36 %37 = OpLabel @@ -278,139 +278,208 @@ %134 = OpLoad %_arr_Inner_uint_4 %131 None %array_struct_inner = OpFunctionCall %_arr_Inner_uint_4_0 %tint_convert_explicit_layout_0 %134 %138 = OpFunctionCall %int %tint_f32_to_i32 %scalar_f32 - %140 = OpIAdd %int %138 %scalar_i32 - %141 = OpBitcast %int %scalar_u32 - %142 = OpIAdd %int %140 %141 - %143 = OpCompositeExtract %float %vec2_f32 0 - %144 = OpFunctionCall %int %tint_f32_to_i32 %143 - %145 = OpIAdd %int %142 %144 - %146 = OpCompositeExtract %int %vec2_i32 0 - %147 = OpIAdd %int %145 %146 - %148 = OpCompositeExtract %uint %vec2_u32 0 - %149 = OpBitcast %int %148 - %150 = OpIAdd %int %147 %149 - %151 = OpCompositeExtract %float %vec3_f32 1 - %152 = OpFunctionCall %int %tint_f32_to_i32 %151 - %153 = OpIAdd %int %150 %152 - %154 = OpCompositeExtract %int %vec3_i32 1 - %155 = OpIAdd %int %153 %154 - %156 = OpCompositeExtract %uint %vec3_u32 1 - %157 = OpBitcast %int %156 - %158 = OpIAdd %int %155 %157 - %159 = OpCompositeExtract %float %vec4_f32 2 - %160 = OpFunctionCall %int %tint_f32_to_i32 %159 - %161 = OpIAdd %int %158 %160 - %162 = OpCompositeExtract %int %vec4_i32 2 - %163 = OpIAdd %int %161 %162 - %164 = OpCompositeExtract %uint %vec4_u32 2 + %140 = OpBitcast %uint %138 + %141 = OpBitcast %uint %scalar_i32 + %142 = OpIAdd %uint %140 %141 + %143 = OpBitcast %int %142 + %144 = OpBitcast %int %scalar_u32 + %145 = OpBitcast %uint %143 + %146 = OpBitcast %uint %144 + %147 = OpIAdd %uint %145 %146 + %148 = OpBitcast %int %147 + %149 = OpCompositeExtract %float %vec2_f32 0 + %150 = OpFunctionCall %int %tint_f32_to_i32 %149 + %151 = OpBitcast %uint %148 + %152 = OpBitcast %uint %150 + %153 = OpIAdd %uint %151 %152 + %154 = OpBitcast %int %153 + %155 = OpCompositeExtract %int %vec2_i32 0 + %156 = OpBitcast %uint %154 + %157 = OpBitcast %uint %155 + %158 = OpIAdd %uint %156 %157 + %159 = OpBitcast %int %158 + %160 = OpCompositeExtract %uint %vec2_u32 0 + %161 = OpBitcast %int %160 + %162 = OpBitcast %uint %159 + %163 = OpBitcast %uint %161 + %164 = OpIAdd %uint %162 %163 %165 = OpBitcast %int %164 - %166 = OpIAdd %int %163 %165 - %167 = OpCompositeExtract %float %mat2x2_f32 0 0 - %168 = OpFunctionCall %int %tint_f32_to_i32 %167 - %169 = OpIAdd %int %166 %168 - %170 = OpCompositeExtract %float %mat2x3_f32 0 0 - %171 = OpFunctionCall %int %tint_f32_to_i32 %170 - %172 = OpIAdd %int %169 %171 - %173 = OpCompositeExtract %float %mat2x4_f32 0 0 - %174 = OpFunctionCall %int %tint_f32_to_i32 %173 - %175 = OpIAdd %int %172 %174 - %176 = OpCompositeExtract %float %mat3x2_f32 0 0 - %177 = OpFunctionCall %int %tint_f32_to_i32 %176 - %178 = OpIAdd %int %175 %177 - %179 = OpCompositeExtract %float %mat3x3_f32 0 0 - %180 = OpFunctionCall %int %tint_f32_to_i32 %179 - %181 = OpIAdd %int %178 %180 - %182 = OpCompositeExtract %float %mat3x4_f32 0 0 - %183 = OpFunctionCall %int %tint_f32_to_i32 %182 - %184 = OpIAdd %int %181 %183 - %185 = OpCompositeExtract %float %mat4x2_f32 0 0 - %186 = OpFunctionCall %int %tint_f32_to_i32 %185 - %187 = OpIAdd %int %184 %186 - %188 = OpCompositeExtract %float %mat4x3_f32 0 0 - %189 = OpFunctionCall %int %tint_f32_to_i32 %188 - %190 = OpIAdd %int %187 %189 - %191 = OpCompositeExtract %float %mat4x4_f32 0 0 - %192 = OpFunctionCall %int %tint_f32_to_i32 %191 - %193 = OpIAdd %int %190 %192 - %194 = OpCompositeExtract %float %arr2_vec3_f32 0 0 - %195 = OpFunctionCall %int %tint_f32_to_i32 %194 - %196 = OpIAdd %int %193 %195 - %197 = OpCompositeExtract %int %struct_inner 0 - %198 = OpIAdd %int %196 %197 - %199 = OpCompositeExtract %int %array_struct_inner 0 0 - %200 = OpIAdd %int %198 %199 - %201 = OpAccessChain %_ptr_StorageBuffer_int_0 %31 %uint_0 - OpStore %201 %200 None + %166 = OpCompositeExtract %float %vec3_f32 1 + %167 = OpFunctionCall %int %tint_f32_to_i32 %166 + %168 = OpBitcast %uint %165 + %169 = OpBitcast %uint %167 + %170 = OpIAdd %uint %168 %169 + %171 = OpBitcast %int %170 + %172 = OpCompositeExtract %int %vec3_i32 1 + %173 = OpBitcast %uint %171 + %174 = OpBitcast %uint %172 + %175 = OpIAdd %uint %173 %174 + %176 = OpBitcast %int %175 + %177 = OpCompositeExtract %uint %vec3_u32 1 + %178 = OpBitcast %int %177 + %179 = OpBitcast %uint %176 + %180 = OpBitcast %uint %178 + %181 = OpIAdd %uint %179 %180 + %182 = OpBitcast %int %181 + %183 = OpCompositeExtract %float %vec4_f32 2 + %184 = OpFunctionCall %int %tint_f32_to_i32 %183 + %185 = OpBitcast %uint %182 + %186 = OpBitcast %uint %184 + %187 = OpIAdd %uint %185 %186 + %188 = OpBitcast %int %187 + %189 = OpCompositeExtract %int %vec4_i32 2 + %190 = OpBitcast %uint %188 + %191 = OpBitcast %uint %189 + %192 = OpIAdd %uint %190 %191 + %193 = OpBitcast %int %192 + %194 = OpCompositeExtract %uint %vec4_u32 2 + %195 = OpBitcast %int %194 + %196 = OpBitcast %uint %193 + %197 = OpBitcast %uint %195 + %198 = OpIAdd %uint %196 %197 + %199 = OpBitcast %int %198 + %200 = OpCompositeExtract %float %mat2x2_f32 0 0 + %201 = OpFunctionCall %int %tint_f32_to_i32 %200 + %202 = OpBitcast %uint %199 + %203 = OpBitcast %uint %201 + %204 = OpIAdd %uint %202 %203 + %205 = OpBitcast %int %204 + %206 = OpCompositeExtract %float %mat2x3_f32 0 0 + %207 = OpFunctionCall %int %tint_f32_to_i32 %206 + %208 = OpBitcast %uint %205 + %209 = OpBitcast %uint %207 + %210 = OpIAdd %uint %208 %209 + %211 = OpBitcast %int %210 + %212 = OpCompositeExtract %float %mat2x4_f32 0 0 + %213 = OpFunctionCall %int %tint_f32_to_i32 %212 + %214 = OpBitcast %uint %211 + %215 = OpBitcast %uint %213 + %216 = OpIAdd %uint %214 %215 + %217 = OpBitcast %int %216 + %218 = OpCompositeExtract %float %mat3x2_f32 0 0 + %219 = OpFunctionCall %int %tint_f32_to_i32 %218 + %220 = OpBitcast %uint %217 + %221 = OpBitcast %uint %219 + %222 = OpIAdd %uint %220 %221 + %223 = OpBitcast %int %222 + %224 = OpCompositeExtract %float %mat3x3_f32 0 0 + %225 = OpFunctionCall %int %tint_f32_to_i32 %224 + %226 = OpBitcast %uint %223 + %227 = OpBitcast %uint %225 + %228 = OpIAdd %uint %226 %227 + %229 = OpBitcast %int %228 + %230 = OpCompositeExtract %float %mat3x4_f32 0 0 + %231 = OpFunctionCall %int %tint_f32_to_i32 %230 + %232 = OpBitcast %uint %229 + %233 = OpBitcast %uint %231 + %234 = OpIAdd %uint %232 %233 + %235 = OpBitcast %int %234 + %236 = OpCompositeExtract %float %mat4x2_f32 0 0 + %237 = OpFunctionCall %int %tint_f32_to_i32 %236 + %238 = OpBitcast %uint %235 + %239 = OpBitcast %uint %237 + %240 = OpIAdd %uint %238 %239 + %241 = OpBitcast %int %240 + %242 = OpCompositeExtract %float %mat4x3_f32 0 0 + %243 = OpFunctionCall %int %tint_f32_to_i32 %242 + %244 = OpBitcast %uint %241 + %245 = OpBitcast %uint %243 + %246 = OpIAdd %uint %244 %245 + %247 = OpBitcast %int %246 + %248 = OpCompositeExtract %float %mat4x4_f32 0 0 + %249 = OpFunctionCall %int %tint_f32_to_i32 %248 + %250 = OpBitcast %uint %247 + %251 = OpBitcast %uint %249 + %252 = OpIAdd %uint %250 %251 + %253 = OpBitcast %int %252 + %254 = OpCompositeExtract %float %arr2_vec3_f32 0 0 + %255 = OpFunctionCall %int %tint_f32_to_i32 %254 + %256 = OpBitcast %uint %253 + %257 = OpBitcast %uint %255 + %258 = OpIAdd %uint %256 %257 + %259 = OpBitcast %int %258 + %260 = OpCompositeExtract %int %struct_inner 0 + %261 = OpBitcast %uint %259 + %262 = OpBitcast %uint %260 + %263 = OpIAdd %uint %261 %262 + %264 = OpBitcast %int %263 + %265 = OpCompositeExtract %int %array_struct_inner 0 0 + %266 = OpBitcast %uint %264 + %267 = OpBitcast %uint %265 + %268 = OpIAdd %uint %266 %267 + %269 = OpBitcast %int %268 + %270 = OpAccessChain %_ptr_StorageBuffer_int_0 %31 %uint_0 + OpStore %270 %269 None OpReturn OpFunctionEnd -%tint_f32_to_i32 = OpFunction %int None %204 +%tint_f32_to_i32 = OpFunction %int None %273 %value = OpFunctionParameter %float - %205 = OpLabel - %206 = OpExtInst %float %207 NClamp %value %float_n2_14748365e_09 %float_2_14748352e_09 - %210 = OpConvertFToS %int %206 - OpReturnValue %210 + %274 = OpLabel + %275 = OpExtInst %float %276 NClamp %value %float_n2_14748365e_09 %float_2_14748352e_09 + %279 = OpConvertFToS %int %275 + OpReturnValue %279 OpFunctionEnd -%tint_convert_explicit_layout = OpFunction %_arr_v3float_uint_2_0 None %212 +%tint_convert_explicit_layout = OpFunction %_arr_v3float_uint_2_0 None %281 %tint_source = OpFunctionParameter %_arr_v3float_uint_2 - %213 = OpLabel - %214 = OpVariable %_ptr_Function__arr_v3float_uint_2 Function - %216 = OpVariable %_ptr_Function__arr_v3float_uint_2_0 Function %218 - OpStore %214 %tint_source - OpBranch %219 - %219 = OpLabel - OpBranch %222 - %222 = OpLabel - %224 = OpPhi %uint %uint_0 %219 %225 %221 - OpLoopMerge %223 %221 None - OpBranch %220 - %220 = OpLabel - %227 = OpUGreaterThanEqual %bool %224 %uint_2 - OpSelectionMerge %229 None - OpBranchConditional %227 %230 %229 - %230 = OpLabel - OpBranch %223 - %229 = OpLabel - %231 = OpAccessChain %_ptr_Function_v3float %214 %224 - %233 = OpLoad %v3float %231 None - %234 = OpAccessChain %_ptr_Function_v3float %216 %224 - OpStore %234 %233 None - OpBranch %221 - %221 = OpLabel - %225 = OpIAdd %uint %224 %uint_1 - OpBranch %222 - %223 = OpLabel - %226 = OpLoad %_arr_v3float_uint_2_0 %216 None - OpReturnValue %226 + %282 = OpLabel + %283 = OpVariable %_ptr_Function__arr_v3float_uint_2 Function + %285 = OpVariable %_ptr_Function__arr_v3float_uint_2_0 Function %287 + OpStore %283 %tint_source + OpBranch %288 + %288 = OpLabel + OpBranch %291 + %291 = OpLabel + %293 = OpPhi %uint %uint_0 %288 %294 %290 + OpLoopMerge %292 %290 None + OpBranch %289 + %289 = OpLabel + %296 = OpUGreaterThanEqual %bool %293 %uint_2 + OpSelectionMerge %298 None + OpBranchConditional %296 %299 %298 + %299 = OpLabel + OpBranch %292 + %298 = OpLabel + %300 = OpAccessChain %_ptr_Function_v3float %283 %293 + %302 = OpLoad %v3float %300 None + %303 = OpAccessChain %_ptr_Function_v3float %285 %293 + OpStore %303 %302 None + OpBranch %290 + %290 = OpLabel + %294 = OpIAdd %uint %293 %uint_1 + OpBranch %291 + %292 = OpLabel + %295 = OpLoad %_arr_v3float_uint_2_0 %285 None + OpReturnValue %295 OpFunctionEnd -%tint_convert_explicit_layout_0 = OpFunction %_arr_Inner_uint_4_0 None %236 +%tint_convert_explicit_layout_0 = OpFunction %_arr_Inner_uint_4_0 None %305 %tint_source_0 = OpFunctionParameter %_arr_Inner_uint_4 - %237 = OpLabel - %238 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function - %240 = OpVariable %_ptr_Function__arr_Inner_uint_4_0 Function %242 - OpStore %238 %tint_source_0 - OpBranch %243 - %243 = OpLabel - OpBranch %246 - %246 = OpLabel - %248 = OpPhi %uint %uint_0 %243 %249 %245 - OpLoopMerge %247 %245 None - OpBranch %244 - %244 = OpLabel - %251 = OpUGreaterThanEqual %bool %248 %uint_4 - OpSelectionMerge %252 None - OpBranchConditional %251 %253 %252 - %253 = OpLabel - OpBranch %247 - %252 = OpLabel - %254 = OpAccessChain %_ptr_Function_Inner %238 %248 - %256 = OpLoad %Inner %254 None - %257 = OpAccessChain %_ptr_Function_Inner %240 %248 - OpStore %257 %256 None - OpBranch %245 - %245 = OpLabel - %249 = OpIAdd %uint %248 %uint_1 - OpBranch %246 - %247 = OpLabel - %250 = OpLoad %_arr_Inner_uint_4_0 %240 None - OpReturnValue %250 + %306 = OpLabel + %307 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function + %309 = OpVariable %_ptr_Function__arr_Inner_uint_4_0 Function %311 + OpStore %307 %tint_source_0 + OpBranch %312 + %312 = OpLabel + OpBranch %315 + %315 = OpLabel + %317 = OpPhi %uint %uint_0 %312 %318 %314 + OpLoopMerge %316 %314 None + OpBranch %313 + %313 = OpLabel + %320 = OpUGreaterThanEqual %bool %317 %uint_4 + OpSelectionMerge %321 None + OpBranchConditional %320 %322 %321 + %322 = OpLabel + OpBranch %316 + %321 = OpLabel + %323 = OpAccessChain %_ptr_Function_Inner %307 %317 + %325 = OpLoad %Inner %323 None + %326 = OpAccessChain %_ptr_Function_Inner %309 %317 + OpStore %326 %325 None + OpBranch %314 + %314 = OpLabel + %318 = OpIAdd %uint %317 %uint_1 + OpBranch %315 + %316 = OpLabel + %319 = OpLoad %_arr_Inner_uint_4_0 %309 None + OpReturnValue %319 OpFunctionEnd
diff --git a/test/tint/buffer/storage/static_index/read_f16.wgsl.expected.glsl b/test/tint/buffer/storage/static_index/read_f16.wgsl.expected.glsl index b2afae2..9485cd2 100644 --- a/test/tint/buffer/storage/static_index/read_f16.wgsl.expected.glsl +++ b/test/tint/buffer/storage/static_index/read_f16.wgsl.expected.glsl
@@ -117,36 +117,104 @@ f16mat4x2 arr2_mat4x2_f16[2] = v.inner.arr2_mat4x2_f16; Inner struct_inner = v.inner.struct_inner; Inner array_struct_inner[4] = v.inner.array_struct_inner; - int v_2 = (tint_f32_to_i32(scalar_f32) + scalar_i32); - int v_3 = (v_2 + int(scalar_u32)); - int v_4 = (v_3 + tint_f16_to_i32(scalar_f16)); - int v_5 = ((v_4 + tint_f32_to_i32(vec2_f32.x)) + vec2_i32.x); - int v_6 = (v_5 + int(vec2_u32.x)); - int v_7 = (v_6 + tint_f16_to_i32(vec2_f16.x)); - int v_8 = ((v_7 + tint_f32_to_i32(vec3_f32.y)) + vec3_i32.y); - int v_9 = (v_8 + int(vec3_u32.y)); - int v_10 = (v_9 + tint_f16_to_i32(vec3_f16.y)); - int v_11 = ((v_10 + tint_f32_to_i32(vec4_f32.z)) + vec4_i32.z); - int v_12 = (v_11 + int(vec4_u32.z)); - int v_13 = (v_12 + tint_f16_to_i32(vec4_f16.z)); - int v_14 = (v_13 + tint_f32_to_i32(mat2x2_f32[0u].x)); - int v_15 = (v_14 + tint_f32_to_i32(mat2x3_f32[0u].x)); - int v_16 = (v_15 + tint_f32_to_i32(mat2x4_f32[0u].x)); - int v_17 = (v_16 + tint_f32_to_i32(mat3x2_f32[0u].x)); - int v_18 = (v_17 + tint_f32_to_i32(mat3x3_f32[0u].x)); - int v_19 = (v_18 + tint_f32_to_i32(mat3x4_f32[0u].x)); - int v_20 = (v_19 + tint_f32_to_i32(mat4x2_f32[0u].x)); - int v_21 = (v_20 + tint_f32_to_i32(mat4x3_f32[0u].x)); - int v_22 = (v_21 + tint_f32_to_i32(mat4x4_f32[0u].x)); - int v_23 = (v_22 + tint_f16_to_i32(mat2x2_f16[0u].x)); - int v_24 = (v_23 + tint_f16_to_i32(mat2x3_f16[0u].x)); - int v_25 = (v_24 + tint_f16_to_i32(mat2x4_f16[0u].x)); - int v_26 = (v_25 + tint_f16_to_i32(mat3x2_f16[0u].x)); - int v_27 = (v_26 + tint_f16_to_i32(mat3x3_f16[0u].x)); - int v_28 = (v_27 + tint_f16_to_i32(mat3x4_f16[0u].x)); - int v_29 = (v_28 + tint_f16_to_i32(mat4x2_f16[0u].x)); - int v_30 = (v_29 + tint_f16_to_i32(mat4x3_f16[0u].x)); - int v_31 = (v_30 + tint_f16_to_i32(mat4x4_f16[0u].x)); - int v_32 = (v_31 + tint_f32_to_i32(arr2_vec3_f32[0u].x)); - v_1.inner = (((v_32 + tint_f16_to_i32(arr2_mat4x2_f16[0u][0u].x)) + struct_inner.scalar_i32) + array_struct_inner[0u].scalar_i32); + uint v_2 = uint(tint_f32_to_i32(scalar_f32)); + int v_3 = int((v_2 + uint(scalar_i32))); + int v_4 = int(scalar_u32); + uint v_5 = uint(v_3); + int v_6 = int((v_5 + uint(v_4))); + int v_7 = tint_f16_to_i32(scalar_f16); + uint v_8 = uint(v_6); + int v_9 = int((v_8 + uint(v_7))); + int v_10 = tint_f32_to_i32(vec2_f32.x); + uint v_11 = uint(v_9); + uint v_12 = uint(int((v_11 + uint(v_10)))); + int v_13 = int((v_12 + uint(vec2_i32.x))); + int v_14 = int(vec2_u32.x); + uint v_15 = uint(v_13); + int v_16 = int((v_15 + uint(v_14))); + int v_17 = tint_f16_to_i32(vec2_f16.x); + uint v_18 = uint(v_16); + int v_19 = int((v_18 + uint(v_17))); + int v_20 = tint_f32_to_i32(vec3_f32.y); + uint v_21 = uint(v_19); + uint v_22 = uint(int((v_21 + uint(v_20)))); + int v_23 = int((v_22 + uint(vec3_i32.y))); + int v_24 = int(vec3_u32.y); + uint v_25 = uint(v_23); + int v_26 = int((v_25 + uint(v_24))); + int v_27 = tint_f16_to_i32(vec3_f16.y); + uint v_28 = uint(v_26); + int v_29 = int((v_28 + uint(v_27))); + int v_30 = tint_f32_to_i32(vec4_f32.z); + uint v_31 = uint(v_29); + uint v_32 = uint(int((v_31 + uint(v_30)))); + int v_33 = int((v_32 + uint(vec4_i32.z))); + int v_34 = int(vec4_u32.z); + uint v_35 = uint(v_33); + int v_36 = int((v_35 + uint(v_34))); + int v_37 = tint_f16_to_i32(vec4_f16.z); + uint v_38 = uint(v_36); + int v_39 = int((v_38 + uint(v_37))); + int v_40 = tint_f32_to_i32(mat2x2_f32[0u].x); + uint v_41 = uint(v_39); + int v_42 = int((v_41 + uint(v_40))); + int v_43 = tint_f32_to_i32(mat2x3_f32[0u].x); + uint v_44 = uint(v_42); + int v_45 = int((v_44 + uint(v_43))); + int v_46 = tint_f32_to_i32(mat2x4_f32[0u].x); + uint v_47 = uint(v_45); + int v_48 = int((v_47 + uint(v_46))); + int v_49 = tint_f32_to_i32(mat3x2_f32[0u].x); + uint v_50 = uint(v_48); + int v_51 = int((v_50 + uint(v_49))); + int v_52 = tint_f32_to_i32(mat3x3_f32[0u].x); + uint v_53 = uint(v_51); + int v_54 = int((v_53 + uint(v_52))); + int v_55 = tint_f32_to_i32(mat3x4_f32[0u].x); + uint v_56 = uint(v_54); + int v_57 = int((v_56 + uint(v_55))); + int v_58 = tint_f32_to_i32(mat4x2_f32[0u].x); + uint v_59 = uint(v_57); + int v_60 = int((v_59 + uint(v_58))); + int v_61 = tint_f32_to_i32(mat4x3_f32[0u].x); + uint v_62 = uint(v_60); + int v_63 = int((v_62 + uint(v_61))); + int v_64 = tint_f32_to_i32(mat4x4_f32[0u].x); + uint v_65 = uint(v_63); + int v_66 = int((v_65 + uint(v_64))); + int v_67 = tint_f16_to_i32(mat2x2_f16[0u].x); + uint v_68 = uint(v_66); + int v_69 = int((v_68 + uint(v_67))); + int v_70 = tint_f16_to_i32(mat2x3_f16[0u].x); + uint v_71 = uint(v_69); + int v_72 = int((v_71 + uint(v_70))); + int v_73 = tint_f16_to_i32(mat2x4_f16[0u].x); + uint v_74 = uint(v_72); + int v_75 = int((v_74 + uint(v_73))); + int v_76 = tint_f16_to_i32(mat3x2_f16[0u].x); + uint v_77 = uint(v_75); + int v_78 = int((v_77 + uint(v_76))); + int v_79 = tint_f16_to_i32(mat3x3_f16[0u].x); + uint v_80 = uint(v_78); + int v_81 = int((v_80 + uint(v_79))); + int v_82 = tint_f16_to_i32(mat3x4_f16[0u].x); + uint v_83 = uint(v_81); + int v_84 = int((v_83 + uint(v_82))); + int v_85 = tint_f16_to_i32(mat4x2_f16[0u].x); + uint v_86 = uint(v_84); + int v_87 = int((v_86 + uint(v_85))); + int v_88 = tint_f16_to_i32(mat4x3_f16[0u].x); + uint v_89 = uint(v_87); + int v_90 = int((v_89 + uint(v_88))); + int v_91 = tint_f16_to_i32(mat4x4_f16[0u].x); + uint v_92 = uint(v_90); + int v_93 = int((v_92 + uint(v_91))); + int v_94 = tint_f32_to_i32(arr2_vec3_f32[0u].x); + uint v_95 = uint(v_93); + int v_96 = int((v_95 + uint(v_94))); + int v_97 = tint_f16_to_i32(arr2_mat4x2_f16[0u][0u].x); + uint v_98 = uint(v_96); + uint v_99 = uint(int((v_98 + uint(v_97)))); + uint v_100 = uint(int((v_99 + uint(struct_inner.scalar_i32)))); + v_1.inner = int((v_100 + uint(array_struct_inner[0u].scalar_i32))); }
diff --git a/test/tint/buffer/storage/static_index/read_f16.wgsl.expected.spvasm b/test/tint/buffer/storage/static_index/read_f16.wgsl.expected.spvasm index c413419..329ac8c 100644 --- a/test/tint/buffer/storage/static_index/read_f16.wgsl.expected.spvasm +++ b/test/tint/buffer/storage/static_index/read_f16.wgsl.expected.spvasm
@@ -1,13 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 403 +; Bound: 514 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess - %322 = OpExtInstImport "GLSL.std.450" + %433 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %main "main" OpExecutionMode %main LocalSize 1 1 1 @@ -326,27 +326,27 @@ %uint_37 = OpConstant %uint 37 %_arr_Inner_uint_4_0 = OpTypeArray %Inner %uint_4 %_ptr_StorageBuffer_int_0 = OpTypePointer StorageBuffer %int - %319 = OpTypeFunction %int %float + %430 = OpTypeFunction %int %float %float_n2_14748365e_09 = OpConstant %float -2.14748365e+09 %float_2_14748352e_09 = OpConstant %float 2.14748352e+09 - %327 = OpTypeFunction %int %half + %438 = OpTypeFunction %int %half %half_n0x1_ffcp_15 = OpConstant %half -0x1.ffcp+15 %half_0x1_ffcp_15 = OpConstant %half 0x1.ffcp+15 - %334 = OpTypeFunction %_arr_v3float_uint_2_0 %_arr_v3float_uint_2 + %445 = OpTypeFunction %_arr_v3float_uint_2_0 %_arr_v3float_uint_2 %_ptr_Function__arr_v3float_uint_2 = OpTypePointer Function %_arr_v3float_uint_2 %_ptr_Function__arr_v3float_uint_2_0 = OpTypePointer Function %_arr_v3float_uint_2_0 - %340 = OpConstantNull %_arr_v3float_uint_2_0 + %451 = OpConstantNull %_arr_v3float_uint_2_0 %bool = OpTypeBool %_ptr_Function_v3float = OpTypePointer Function %v3float - %358 = OpTypeFunction %_arr_mat4v2half_uint_2_0 %_arr_mat4v2half_uint_2 + %469 = OpTypeFunction %_arr_mat4v2half_uint_2_0 %_arr_mat4v2half_uint_2 %_ptr_Function__arr_mat4v2half_uint_2 = OpTypePointer Function %_arr_mat4v2half_uint_2 %_ptr_Function__arr_mat4v2half_uint_2_0 = OpTypePointer Function %_arr_mat4v2half_uint_2_0 - %364 = OpConstantNull %_arr_mat4v2half_uint_2_0 + %475 = OpConstantNull %_arr_mat4v2half_uint_2_0 %_ptr_Function_mat4v2half = OpTypePointer Function %mat4v2half - %381 = OpTypeFunction %_arr_Inner_uint_4_0 %_arr_Inner_uint_4 + %492 = OpTypeFunction %_arr_Inner_uint_4_0 %_arr_Inner_uint_4 %_ptr_Function__arr_Inner_uint_4 = OpTypePointer Function %_arr_Inner_uint_4 %_ptr_Function__arr_Inner_uint_4_0 = OpTypePointer Function %_arr_Inner_uint_4_0 - %387 = OpConstantNull %_arr_Inner_uint_4_0 + %498 = OpConstantNull %_arr_Inner_uint_4_0 %_ptr_Function_Inner = OpTypePointer Function %Inner %main = OpFunction %void None %50 %51 = OpLabel @@ -430,219 +430,330 @@ %207 = OpLoad %_arr_Inner_uint_4 %204 None %array_struct_inner = OpFunctionCall %_arr_Inner_uint_4_0 %tint_convert_explicit_layout_1 %207 %211 = OpFunctionCall %int %tint_f32_to_i32 %scalar_f32 - %213 = OpIAdd %int %211 %scalar_i32 - %214 = OpBitcast %int %scalar_u32 - %215 = OpIAdd %int %213 %214 - %216 = OpFunctionCall %int %tint_f16_to_i32 %scalar_f16 - %218 = OpIAdd %int %215 %216 - %219 = OpCompositeExtract %float %vec2_f32 0 - %220 = OpFunctionCall %int %tint_f32_to_i32 %219 - %221 = OpIAdd %int %218 %220 - %222 = OpCompositeExtract %int %vec2_i32 0 - %223 = OpIAdd %int %221 %222 - %224 = OpCompositeExtract %uint %vec2_u32 0 - %225 = OpBitcast %int %224 - %226 = OpIAdd %int %223 %225 - %227 = OpCompositeExtract %half %vec2_f16 0 - %228 = OpFunctionCall %int %tint_f16_to_i32 %227 - %229 = OpIAdd %int %226 %228 - %230 = OpCompositeExtract %float %vec3_f32 1 - %231 = OpFunctionCall %int %tint_f32_to_i32 %230 - %232 = OpIAdd %int %229 %231 - %233 = OpCompositeExtract %int %vec3_i32 1 - %234 = OpIAdd %int %232 %233 - %235 = OpCompositeExtract %uint %vec3_u32 1 - %236 = OpBitcast %int %235 - %237 = OpIAdd %int %234 %236 - %238 = OpCompositeExtract %half %vec3_f16 1 - %239 = OpFunctionCall %int %tint_f16_to_i32 %238 - %240 = OpIAdd %int %237 %239 - %241 = OpCompositeExtract %float %vec4_f32 2 - %242 = OpFunctionCall %int %tint_f32_to_i32 %241 - %243 = OpIAdd %int %240 %242 - %244 = OpCompositeExtract %int %vec4_i32 2 - %245 = OpIAdd %int %243 %244 - %246 = OpCompositeExtract %uint %vec4_u32 2 - %247 = OpBitcast %int %246 - %248 = OpIAdd %int %245 %247 - %249 = OpCompositeExtract %half %vec4_f16 2 - %250 = OpFunctionCall %int %tint_f16_to_i32 %249 - %251 = OpIAdd %int %248 %250 - %252 = OpCompositeExtract %float %mat2x2_f32 0 0 - %253 = OpFunctionCall %int %tint_f32_to_i32 %252 - %254 = OpIAdd %int %251 %253 - %255 = OpCompositeExtract %float %mat2x3_f32 0 0 - %256 = OpFunctionCall %int %tint_f32_to_i32 %255 - %257 = OpIAdd %int %254 %256 - %258 = OpCompositeExtract %float %mat2x4_f32 0 0 - %259 = OpFunctionCall %int %tint_f32_to_i32 %258 - %260 = OpIAdd %int %257 %259 - %261 = OpCompositeExtract %float %mat3x2_f32 0 0 - %262 = OpFunctionCall %int %tint_f32_to_i32 %261 - %263 = OpIAdd %int %260 %262 - %264 = OpCompositeExtract %float %mat3x3_f32 0 0 - %265 = OpFunctionCall %int %tint_f32_to_i32 %264 - %266 = OpIAdd %int %263 %265 - %267 = OpCompositeExtract %float %mat3x4_f32 0 0 - %268 = OpFunctionCall %int %tint_f32_to_i32 %267 - %269 = OpIAdd %int %266 %268 - %270 = OpCompositeExtract %float %mat4x2_f32 0 0 - %271 = OpFunctionCall %int %tint_f32_to_i32 %270 - %272 = OpIAdd %int %269 %271 - %273 = OpCompositeExtract %float %mat4x3_f32 0 0 - %274 = OpFunctionCall %int %tint_f32_to_i32 %273 - %275 = OpIAdd %int %272 %274 - %276 = OpCompositeExtract %float %mat4x4_f32 0 0 - %277 = OpFunctionCall %int %tint_f32_to_i32 %276 - %278 = OpIAdd %int %275 %277 - %279 = OpCompositeExtract %half %mat2x2_f16 0 0 - %280 = OpFunctionCall %int %tint_f16_to_i32 %279 - %281 = OpIAdd %int %278 %280 - %282 = OpCompositeExtract %half %mat2x3_f16 0 0 - %283 = OpFunctionCall %int %tint_f16_to_i32 %282 - %284 = OpIAdd %int %281 %283 - %285 = OpCompositeExtract %half %mat2x4_f16 0 0 - %286 = OpFunctionCall %int %tint_f16_to_i32 %285 - %287 = OpIAdd %int %284 %286 - %288 = OpCompositeExtract %half %mat3x2_f16 0 0 - %289 = OpFunctionCall %int %tint_f16_to_i32 %288 - %290 = OpIAdd %int %287 %289 - %291 = OpCompositeExtract %half %mat3x3_f16 0 0 + %213 = OpBitcast %uint %211 + %214 = OpBitcast %uint %scalar_i32 + %215 = OpIAdd %uint %213 %214 + %216 = OpBitcast %int %215 + %217 = OpBitcast %int %scalar_u32 + %218 = OpBitcast %uint %216 + %219 = OpBitcast %uint %217 + %220 = OpIAdd %uint %218 %219 + %221 = OpBitcast %int %220 + %222 = OpFunctionCall %int %tint_f16_to_i32 %scalar_f16 + %224 = OpBitcast %uint %221 + %225 = OpBitcast %uint %222 + %226 = OpIAdd %uint %224 %225 + %227 = OpBitcast %int %226 + %228 = OpCompositeExtract %float %vec2_f32 0 + %229 = OpFunctionCall %int %tint_f32_to_i32 %228 + %230 = OpBitcast %uint %227 + %231 = OpBitcast %uint %229 + %232 = OpIAdd %uint %230 %231 + %233 = OpBitcast %int %232 + %234 = OpCompositeExtract %int %vec2_i32 0 + %235 = OpBitcast %uint %233 + %236 = OpBitcast %uint %234 + %237 = OpIAdd %uint %235 %236 + %238 = OpBitcast %int %237 + %239 = OpCompositeExtract %uint %vec2_u32 0 + %240 = OpBitcast %int %239 + %241 = OpBitcast %uint %238 + %242 = OpBitcast %uint %240 + %243 = OpIAdd %uint %241 %242 + %244 = OpBitcast %int %243 + %245 = OpCompositeExtract %half %vec2_f16 0 + %246 = OpFunctionCall %int %tint_f16_to_i32 %245 + %247 = OpBitcast %uint %244 + %248 = OpBitcast %uint %246 + %249 = OpIAdd %uint %247 %248 + %250 = OpBitcast %int %249 + %251 = OpCompositeExtract %float %vec3_f32 1 + %252 = OpFunctionCall %int %tint_f32_to_i32 %251 + %253 = OpBitcast %uint %250 + %254 = OpBitcast %uint %252 + %255 = OpIAdd %uint %253 %254 + %256 = OpBitcast %int %255 + %257 = OpCompositeExtract %int %vec3_i32 1 + %258 = OpBitcast %uint %256 + %259 = OpBitcast %uint %257 + %260 = OpIAdd %uint %258 %259 + %261 = OpBitcast %int %260 + %262 = OpCompositeExtract %uint %vec3_u32 1 + %263 = OpBitcast %int %262 + %264 = OpBitcast %uint %261 + %265 = OpBitcast %uint %263 + %266 = OpIAdd %uint %264 %265 + %267 = OpBitcast %int %266 + %268 = OpCompositeExtract %half %vec3_f16 1 + %269 = OpFunctionCall %int %tint_f16_to_i32 %268 + %270 = OpBitcast %uint %267 + %271 = OpBitcast %uint %269 + %272 = OpIAdd %uint %270 %271 + %273 = OpBitcast %int %272 + %274 = OpCompositeExtract %float %vec4_f32 2 + %275 = OpFunctionCall %int %tint_f32_to_i32 %274 + %276 = OpBitcast %uint %273 + %277 = OpBitcast %uint %275 + %278 = OpIAdd %uint %276 %277 + %279 = OpBitcast %int %278 + %280 = OpCompositeExtract %int %vec4_i32 2 + %281 = OpBitcast %uint %279 + %282 = OpBitcast %uint %280 + %283 = OpIAdd %uint %281 %282 + %284 = OpBitcast %int %283 + %285 = OpCompositeExtract %uint %vec4_u32 2 + %286 = OpBitcast %int %285 + %287 = OpBitcast %uint %284 + %288 = OpBitcast %uint %286 + %289 = OpIAdd %uint %287 %288 + %290 = OpBitcast %int %289 + %291 = OpCompositeExtract %half %vec4_f16 2 %292 = OpFunctionCall %int %tint_f16_to_i32 %291 - %293 = OpIAdd %int %290 %292 - %294 = OpCompositeExtract %half %mat3x4_f16 0 0 - %295 = OpFunctionCall %int %tint_f16_to_i32 %294 - %296 = OpIAdd %int %293 %295 - %297 = OpCompositeExtract %half %mat4x2_f16 0 0 - %298 = OpFunctionCall %int %tint_f16_to_i32 %297 - %299 = OpIAdd %int %296 %298 - %300 = OpCompositeExtract %half %mat4x3_f16 0 0 - %301 = OpFunctionCall %int %tint_f16_to_i32 %300 - %302 = OpIAdd %int %299 %301 - %303 = OpCompositeExtract %half %mat4x4_f16 0 0 - %304 = OpFunctionCall %int %tint_f16_to_i32 %303 - %305 = OpIAdd %int %302 %304 - %306 = OpCompositeExtract %float %arr2_vec3_f32 0 0 - %307 = OpFunctionCall %int %tint_f32_to_i32 %306 - %308 = OpIAdd %int %305 %307 - %309 = OpCompositeExtract %half %arr2_mat4x2_f16 0 0 0 - %310 = OpFunctionCall %int %tint_f16_to_i32 %309 - %311 = OpIAdd %int %308 %310 - %312 = OpCompositeExtract %int %struct_inner 0 - %313 = OpIAdd %int %311 %312 - %314 = OpCompositeExtract %int %array_struct_inner 0 0 - %315 = OpIAdd %int %313 %314 - %316 = OpAccessChain %_ptr_StorageBuffer_int_0 %45 %uint_0 - OpStore %316 %315 None + %293 = OpBitcast %uint %290 + %294 = OpBitcast %uint %292 + %295 = OpIAdd %uint %293 %294 + %296 = OpBitcast %int %295 + %297 = OpCompositeExtract %float %mat2x2_f32 0 0 + %298 = OpFunctionCall %int %tint_f32_to_i32 %297 + %299 = OpBitcast %uint %296 + %300 = OpBitcast %uint %298 + %301 = OpIAdd %uint %299 %300 + %302 = OpBitcast %int %301 + %303 = OpCompositeExtract %float %mat2x3_f32 0 0 + %304 = OpFunctionCall %int %tint_f32_to_i32 %303 + %305 = OpBitcast %uint %302 + %306 = OpBitcast %uint %304 + %307 = OpIAdd %uint %305 %306 + %308 = OpBitcast %int %307 + %309 = OpCompositeExtract %float %mat2x4_f32 0 0 + %310 = OpFunctionCall %int %tint_f32_to_i32 %309 + %311 = OpBitcast %uint %308 + %312 = OpBitcast %uint %310 + %313 = OpIAdd %uint %311 %312 + %314 = OpBitcast %int %313 + %315 = OpCompositeExtract %float %mat3x2_f32 0 0 + %316 = OpFunctionCall %int %tint_f32_to_i32 %315 + %317 = OpBitcast %uint %314 + %318 = OpBitcast %uint %316 + %319 = OpIAdd %uint %317 %318 + %320 = OpBitcast %int %319 + %321 = OpCompositeExtract %float %mat3x3_f32 0 0 + %322 = OpFunctionCall %int %tint_f32_to_i32 %321 + %323 = OpBitcast %uint %320 + %324 = OpBitcast %uint %322 + %325 = OpIAdd %uint %323 %324 + %326 = OpBitcast %int %325 + %327 = OpCompositeExtract %float %mat3x4_f32 0 0 + %328 = OpFunctionCall %int %tint_f32_to_i32 %327 + %329 = OpBitcast %uint %326 + %330 = OpBitcast %uint %328 + %331 = OpIAdd %uint %329 %330 + %332 = OpBitcast %int %331 + %333 = OpCompositeExtract %float %mat4x2_f32 0 0 + %334 = OpFunctionCall %int %tint_f32_to_i32 %333 + %335 = OpBitcast %uint %332 + %336 = OpBitcast %uint %334 + %337 = OpIAdd %uint %335 %336 + %338 = OpBitcast %int %337 + %339 = OpCompositeExtract %float %mat4x3_f32 0 0 + %340 = OpFunctionCall %int %tint_f32_to_i32 %339 + %341 = OpBitcast %uint %338 + %342 = OpBitcast %uint %340 + %343 = OpIAdd %uint %341 %342 + %344 = OpBitcast %int %343 + %345 = OpCompositeExtract %float %mat4x4_f32 0 0 + %346 = OpFunctionCall %int %tint_f32_to_i32 %345 + %347 = OpBitcast %uint %344 + %348 = OpBitcast %uint %346 + %349 = OpIAdd %uint %347 %348 + %350 = OpBitcast %int %349 + %351 = OpCompositeExtract %half %mat2x2_f16 0 0 + %352 = OpFunctionCall %int %tint_f16_to_i32 %351 + %353 = OpBitcast %uint %350 + %354 = OpBitcast %uint %352 + %355 = OpIAdd %uint %353 %354 + %356 = OpBitcast %int %355 + %357 = OpCompositeExtract %half %mat2x3_f16 0 0 + %358 = OpFunctionCall %int %tint_f16_to_i32 %357 + %359 = OpBitcast %uint %356 + %360 = OpBitcast %uint %358 + %361 = OpIAdd %uint %359 %360 + %362 = OpBitcast %int %361 + %363 = OpCompositeExtract %half %mat2x4_f16 0 0 + %364 = OpFunctionCall %int %tint_f16_to_i32 %363 + %365 = OpBitcast %uint %362 + %366 = OpBitcast %uint %364 + %367 = OpIAdd %uint %365 %366 + %368 = OpBitcast %int %367 + %369 = OpCompositeExtract %half %mat3x2_f16 0 0 + %370 = OpFunctionCall %int %tint_f16_to_i32 %369 + %371 = OpBitcast %uint %368 + %372 = OpBitcast %uint %370 + %373 = OpIAdd %uint %371 %372 + %374 = OpBitcast %int %373 + %375 = OpCompositeExtract %half %mat3x3_f16 0 0 + %376 = OpFunctionCall %int %tint_f16_to_i32 %375 + %377 = OpBitcast %uint %374 + %378 = OpBitcast %uint %376 + %379 = OpIAdd %uint %377 %378 + %380 = OpBitcast %int %379 + %381 = OpCompositeExtract %half %mat3x4_f16 0 0 + %382 = OpFunctionCall %int %tint_f16_to_i32 %381 + %383 = OpBitcast %uint %380 + %384 = OpBitcast %uint %382 + %385 = OpIAdd %uint %383 %384 + %386 = OpBitcast %int %385 + %387 = OpCompositeExtract %half %mat4x2_f16 0 0 + %388 = OpFunctionCall %int %tint_f16_to_i32 %387 + %389 = OpBitcast %uint %386 + %390 = OpBitcast %uint %388 + %391 = OpIAdd %uint %389 %390 + %392 = OpBitcast %int %391 + %393 = OpCompositeExtract %half %mat4x3_f16 0 0 + %394 = OpFunctionCall %int %tint_f16_to_i32 %393 + %395 = OpBitcast %uint %392 + %396 = OpBitcast %uint %394 + %397 = OpIAdd %uint %395 %396 + %398 = OpBitcast %int %397 + %399 = OpCompositeExtract %half %mat4x4_f16 0 0 + %400 = OpFunctionCall %int %tint_f16_to_i32 %399 + %401 = OpBitcast %uint %398 + %402 = OpBitcast %uint %400 + %403 = OpIAdd %uint %401 %402 + %404 = OpBitcast %int %403 + %405 = OpCompositeExtract %float %arr2_vec3_f32 0 0 + %406 = OpFunctionCall %int %tint_f32_to_i32 %405 + %407 = OpBitcast %uint %404 + %408 = OpBitcast %uint %406 + %409 = OpIAdd %uint %407 %408 + %410 = OpBitcast %int %409 + %411 = OpCompositeExtract %half %arr2_mat4x2_f16 0 0 0 + %412 = OpFunctionCall %int %tint_f16_to_i32 %411 + %413 = OpBitcast %uint %410 + %414 = OpBitcast %uint %412 + %415 = OpIAdd %uint %413 %414 + %416 = OpBitcast %int %415 + %417 = OpCompositeExtract %int %struct_inner 0 + %418 = OpBitcast %uint %416 + %419 = OpBitcast %uint %417 + %420 = OpIAdd %uint %418 %419 + %421 = OpBitcast %int %420 + %422 = OpCompositeExtract %int %array_struct_inner 0 0 + %423 = OpBitcast %uint %421 + %424 = OpBitcast %uint %422 + %425 = OpIAdd %uint %423 %424 + %426 = OpBitcast %int %425 + %427 = OpAccessChain %_ptr_StorageBuffer_int_0 %45 %uint_0 + OpStore %427 %426 None OpReturn OpFunctionEnd -%tint_f32_to_i32 = OpFunction %int None %319 +%tint_f32_to_i32 = OpFunction %int None %430 %value = OpFunctionParameter %float - %320 = OpLabel - %321 = OpExtInst %float %322 NClamp %value %float_n2_14748365e_09 %float_2_14748352e_09 - %325 = OpConvertFToS %int %321 - OpReturnValue %325 + %431 = OpLabel + %432 = OpExtInst %float %433 NClamp %value %float_n2_14748365e_09 %float_2_14748352e_09 + %436 = OpConvertFToS %int %432 + OpReturnValue %436 OpFunctionEnd -%tint_f16_to_i32 = OpFunction %int None %327 +%tint_f16_to_i32 = OpFunction %int None %438 %value_0 = OpFunctionParameter %half - %328 = OpLabel - %329 = OpExtInst %half %322 NClamp %value_0 %half_n0x1_ffcp_15 %half_0x1_ffcp_15 - %332 = OpConvertFToS %int %329 - OpReturnValue %332 + %439 = OpLabel + %440 = OpExtInst %half %433 NClamp %value_0 %half_n0x1_ffcp_15 %half_0x1_ffcp_15 + %443 = OpConvertFToS %int %440 + OpReturnValue %443 OpFunctionEnd -%tint_convert_explicit_layout = OpFunction %_arr_v3float_uint_2_0 None %334 +%tint_convert_explicit_layout = OpFunction %_arr_v3float_uint_2_0 None %445 %tint_source = OpFunctionParameter %_arr_v3float_uint_2 - %335 = OpLabel - %336 = OpVariable %_ptr_Function__arr_v3float_uint_2 Function - %338 = OpVariable %_ptr_Function__arr_v3float_uint_2_0 Function %340 - OpStore %336 %tint_source - OpBranch %341 - %341 = OpLabel - OpBranch %344 - %344 = OpLabel - %346 = OpPhi %uint %uint_0 %341 %347 %343 - OpLoopMerge %345 %343 None - OpBranch %342 - %342 = OpLabel - %349 = OpUGreaterThanEqual %bool %346 %uint_2 - OpSelectionMerge %351 None - OpBranchConditional %349 %352 %351 - %352 = OpLabel - OpBranch %345 - %351 = OpLabel - %353 = OpAccessChain %_ptr_Function_v3float %336 %346 - %355 = OpLoad %v3float %353 None - %356 = OpAccessChain %_ptr_Function_v3float %338 %346 - OpStore %356 %355 None - OpBranch %343 - %343 = OpLabel - %347 = OpIAdd %uint %346 %uint_1 - OpBranch %344 - %345 = OpLabel - %348 = OpLoad %_arr_v3float_uint_2_0 %338 None - OpReturnValue %348 + %446 = OpLabel + %447 = OpVariable %_ptr_Function__arr_v3float_uint_2 Function + %449 = OpVariable %_ptr_Function__arr_v3float_uint_2_0 Function %451 + OpStore %447 %tint_source + OpBranch %452 + %452 = OpLabel + OpBranch %455 + %455 = OpLabel + %457 = OpPhi %uint %uint_0 %452 %458 %454 + OpLoopMerge %456 %454 None + OpBranch %453 + %453 = OpLabel + %460 = OpUGreaterThanEqual %bool %457 %uint_2 + OpSelectionMerge %462 None + OpBranchConditional %460 %463 %462 + %463 = OpLabel + OpBranch %456 + %462 = OpLabel + %464 = OpAccessChain %_ptr_Function_v3float %447 %457 + %466 = OpLoad %v3float %464 None + %467 = OpAccessChain %_ptr_Function_v3float %449 %457 + OpStore %467 %466 None + OpBranch %454 + %454 = OpLabel + %458 = OpIAdd %uint %457 %uint_1 + OpBranch %455 + %456 = OpLabel + %459 = OpLoad %_arr_v3float_uint_2_0 %449 None + OpReturnValue %459 OpFunctionEnd -%tint_convert_explicit_layout_0 = OpFunction %_arr_mat4v2half_uint_2_0 None %358 +%tint_convert_explicit_layout_0 = OpFunction %_arr_mat4v2half_uint_2_0 None %469 %tint_source_0 = OpFunctionParameter %_arr_mat4v2half_uint_2 - %359 = OpLabel - %360 = OpVariable %_ptr_Function__arr_mat4v2half_uint_2 Function - %362 = OpVariable %_ptr_Function__arr_mat4v2half_uint_2_0 Function %364 - OpStore %360 %tint_source_0 - OpBranch %365 - %365 = OpLabel - OpBranch %368 - %368 = OpLabel - %370 = OpPhi %uint %uint_0 %365 %371 %367 - OpLoopMerge %369 %367 None - OpBranch %366 - %366 = OpLabel - %373 = OpUGreaterThanEqual %bool %370 %uint_2 - OpSelectionMerge %374 None - OpBranchConditional %373 %375 %374 - %375 = OpLabel - OpBranch %369 - %374 = OpLabel - %376 = OpAccessChain %_ptr_Function_mat4v2half %360 %370 - %378 = OpLoad %mat4v2half %376 None - %379 = OpAccessChain %_ptr_Function_mat4v2half %362 %370 - OpStore %379 %378 None - OpBranch %367 - %367 = OpLabel - %371 = OpIAdd %uint %370 %uint_1 - OpBranch %368 - %369 = OpLabel - %372 = OpLoad %_arr_mat4v2half_uint_2_0 %362 None - OpReturnValue %372 + %470 = OpLabel + %471 = OpVariable %_ptr_Function__arr_mat4v2half_uint_2 Function + %473 = OpVariable %_ptr_Function__arr_mat4v2half_uint_2_0 Function %475 + OpStore %471 %tint_source_0 + OpBranch %476 + %476 = OpLabel + OpBranch %479 + %479 = OpLabel + %481 = OpPhi %uint %uint_0 %476 %482 %478 + OpLoopMerge %480 %478 None + OpBranch %477 + %477 = OpLabel + %484 = OpUGreaterThanEqual %bool %481 %uint_2 + OpSelectionMerge %485 None + OpBranchConditional %484 %486 %485 + %486 = OpLabel + OpBranch %480 + %485 = OpLabel + %487 = OpAccessChain %_ptr_Function_mat4v2half %471 %481 + %489 = OpLoad %mat4v2half %487 None + %490 = OpAccessChain %_ptr_Function_mat4v2half %473 %481 + OpStore %490 %489 None + OpBranch %478 + %478 = OpLabel + %482 = OpIAdd %uint %481 %uint_1 + OpBranch %479 + %480 = OpLabel + %483 = OpLoad %_arr_mat4v2half_uint_2_0 %473 None + OpReturnValue %483 OpFunctionEnd -%tint_convert_explicit_layout_1 = OpFunction %_arr_Inner_uint_4_0 None %381 +%tint_convert_explicit_layout_1 = OpFunction %_arr_Inner_uint_4_0 None %492 %tint_source_1 = OpFunctionParameter %_arr_Inner_uint_4 - %382 = OpLabel - %383 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function - %385 = OpVariable %_ptr_Function__arr_Inner_uint_4_0 Function %387 - OpStore %383 %tint_source_1 - OpBranch %388 - %388 = OpLabel - OpBranch %391 - %391 = OpLabel - %393 = OpPhi %uint %uint_0 %388 %394 %390 - OpLoopMerge %392 %390 None - OpBranch %389 - %389 = OpLabel - %396 = OpUGreaterThanEqual %bool %393 %uint_4 - OpSelectionMerge %397 None - OpBranchConditional %396 %398 %397 - %398 = OpLabel - OpBranch %392 - %397 = OpLabel - %399 = OpAccessChain %_ptr_Function_Inner %383 %393 - %401 = OpLoad %Inner %399 None - %402 = OpAccessChain %_ptr_Function_Inner %385 %393 - OpStore %402 %401 None - OpBranch %390 - %390 = OpLabel - %394 = OpIAdd %uint %393 %uint_1 - OpBranch %391 - %392 = OpLabel - %395 = OpLoad %_arr_Inner_uint_4_0 %385 None - OpReturnValue %395 + %493 = OpLabel + %494 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function + %496 = OpVariable %_ptr_Function__arr_Inner_uint_4_0 Function %498 + OpStore %494 %tint_source_1 + OpBranch %499 + %499 = OpLabel + OpBranch %502 + %502 = OpLabel + %504 = OpPhi %uint %uint_0 %499 %505 %501 + OpLoopMerge %503 %501 None + OpBranch %500 + %500 = OpLabel + %507 = OpUGreaterThanEqual %bool %504 %uint_4 + OpSelectionMerge %508 None + OpBranchConditional %507 %509 %508 + %509 = OpLabel + OpBranch %503 + %508 = OpLabel + %510 = OpAccessChain %_ptr_Function_Inner %494 %504 + %512 = OpLoad %Inner %510 None + %513 = OpAccessChain %_ptr_Function_Inner %496 %504 + OpStore %513 %512 None + OpBranch %501 + %501 = OpLabel + %505 = OpIAdd %uint %504 %uint_1 + OpBranch %502 + %503 = OpLabel + %506 = OpLoad %_arr_Inner_uint_4_0 %496 None + OpReturnValue %506 OpFunctionEnd
diff --git a/test/tint/buffer/uniform/dynamic_index/read.wgsl.expected.glsl b/test/tint/buffer/uniform/dynamic_index/read.wgsl.expected.glsl index df8236d..7168493 100644 --- a/test/tint/buffer/uniform/dynamic_index/read.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/dynamic_index/read.wgsl.expected.glsl
@@ -93,24 +93,62 @@ mat4x3 mat4x3_f32 = mat4x3(v.inner.arr[min(idx, 7u)].mat4x3_f32_col0, v.inner.arr[min(idx, 7u)].mat4x3_f32_col1, v.inner.arr[min(idx, 7u)].mat4x3_f32_col2, v.inner.arr[min(idx, 7u)].mat4x3_f32_col3); mat4 mat4x4_f32 = v.inner.arr[min(idx, 7u)].mat4x4_f32; vec3 arr2_vec3_f32[2] = v.inner.arr[min(idx, 7u)].arr2_vec3_f32; - int v_2 = (tint_f32_to_i32(scalar_f32) + scalar_i32); - int v_3 = (v_2 + int(scalar_u32)); - int v_4 = ((v_3 + tint_f32_to_i32(vec2_f32.x)) + vec2_i32.x); - int v_5 = (v_4 + int(vec2_u32.x)); - int v_6 = ((v_5 + tint_f32_to_i32(vec3_f32.y)) + vec3_i32.y); - int v_7 = (v_6 + int(vec3_u32.y)); - int v_8 = ((v_7 + tint_f32_to_i32(vec4_f32.z)) + vec4_i32.z); - int v_9 = (v_8 + int(vec4_u32.z)); - int v_10 = (v_9 + tint_f32_to_i32(mat2x2_f32[0u].x)); - int v_11 = (v_10 + tint_f32_to_i32(mat2x3_f32[0u].x)); - int v_12 = (v_11 + tint_f32_to_i32(mat2x4_f32[0u].x)); - int v_13 = (v_12 + tint_f32_to_i32(mat3x2_f32[0u].x)); - int v_14 = (v_13 + tint_f32_to_i32(mat3x3_f32[0u].x)); - int v_15 = (v_14 + tint_f32_to_i32(mat3x4_f32[0u].x)); - int v_16 = (v_15 + tint_f32_to_i32(mat4x2_f32[0u].x)); - int v_17 = (v_16 + tint_f32_to_i32(mat4x3_f32[0u].x)); - int v_18 = (v_17 + tint_f32_to_i32(mat4x4_f32[0u].x)); - v_1.inner = (v_18 + tint_f32_to_i32(arr2_vec3_f32[0u].x)); + uint v_2 = uint(tint_f32_to_i32(scalar_f32)); + int v_3 = int((v_2 + uint(scalar_i32))); + int v_4 = int(scalar_u32); + uint v_5 = uint(v_3); + int v_6 = int((v_5 + uint(v_4))); + int v_7 = tint_f32_to_i32(vec2_f32.x); + uint v_8 = uint(v_6); + uint v_9 = uint(int((v_8 + uint(v_7)))); + int v_10 = int((v_9 + uint(vec2_i32.x))); + int v_11 = int(vec2_u32.x); + uint v_12 = uint(v_10); + int v_13 = int((v_12 + uint(v_11))); + int v_14 = tint_f32_to_i32(vec3_f32.y); + uint v_15 = uint(v_13); + uint v_16 = uint(int((v_15 + uint(v_14)))); + int v_17 = int((v_16 + uint(vec3_i32.y))); + int v_18 = int(vec3_u32.y); + uint v_19 = uint(v_17); + int v_20 = int((v_19 + uint(v_18))); + int v_21 = tint_f32_to_i32(vec4_f32.z); + uint v_22 = uint(v_20); + uint v_23 = uint(int((v_22 + uint(v_21)))); + int v_24 = int((v_23 + uint(vec4_i32.z))); + int v_25 = int(vec4_u32.z); + uint v_26 = uint(v_24); + int v_27 = int((v_26 + uint(v_25))); + int v_28 = tint_f32_to_i32(mat2x2_f32[0u].x); + uint v_29 = uint(v_27); + int v_30 = int((v_29 + uint(v_28))); + int v_31 = tint_f32_to_i32(mat2x3_f32[0u].x); + uint v_32 = uint(v_30); + int v_33 = int((v_32 + uint(v_31))); + int v_34 = tint_f32_to_i32(mat2x4_f32[0u].x); + uint v_35 = uint(v_33); + int v_36 = int((v_35 + uint(v_34))); + int v_37 = tint_f32_to_i32(mat3x2_f32[0u].x); + uint v_38 = uint(v_36); + int v_39 = int((v_38 + uint(v_37))); + int v_40 = tint_f32_to_i32(mat3x3_f32[0u].x); + uint v_41 = uint(v_39); + int v_42 = int((v_41 + uint(v_40))); + int v_43 = tint_f32_to_i32(mat3x4_f32[0u].x); + uint v_44 = uint(v_42); + int v_45 = int((v_44 + uint(v_43))); + int v_46 = tint_f32_to_i32(mat4x2_f32[0u].x); + uint v_47 = uint(v_45); + int v_48 = int((v_47 + uint(v_46))); + int v_49 = tint_f32_to_i32(mat4x3_f32[0u].x); + uint v_50 = uint(v_48); + int v_51 = int((v_50 + uint(v_49))); + int v_52 = tint_f32_to_i32(mat4x4_f32[0u].x); + uint v_53 = uint(v_51); + int v_54 = int((v_53 + uint(v_52))); + int v_55 = tint_f32_to_i32(arr2_vec3_f32[0u].x); + uint v_56 = uint(v_54); + v_1.inner = int((v_56 + uint(v_55))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/buffer/uniform/dynamic_index/read.wgsl.expected.spvasm b/test/tint/buffer/uniform/dynamic_index/read.wgsl.expected.spvasm index 9b9907b..552b748 100644 --- a/test/tint/buffer/uniform/dynamic_index/read.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/dynamic_index/read.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 286 +; Bound: 349 ; Schema: 0 OpCapability Shader %36 = OpExtInstImport "GLSL.std.450" @@ -220,14 +220,14 @@ %uint_33 = OpConstant %uint 33 %_arr_v3float_uint_2_0 = OpTypeArray %v3float %uint_2 %_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int - %251 = OpTypeFunction %int %float + %314 = OpTypeFunction %int %float %float_n2_14748365e_09 = OpConstant %float -2.14748365e+09 %float_2_14748352e_09 = OpConstant %float 2.14748352e+09 - %258 = OpTypeFunction %void - %263 = OpTypeFunction %_arr_v3float_uint_2_0 %_arr_v3float_uint_2 + %321 = OpTypeFunction %void + %326 = OpTypeFunction %_arr_v3float_uint_2_0 %_arr_v3float_uint_2 %_ptr_Function__arr_v3float_uint_2 = OpTypePointer Function %_arr_v3float_uint_2 %_ptr_Function__arr_v3float_uint_2_0 = OpTypePointer Function %_arr_v3float_uint_2_0 - %269 = OpConstantNull %_arr_v3float_uint_2_0 + %332 = OpConstantNull %_arr_v3float_uint_2_0 %bool = OpTypeBool %_ptr_Function_v3float = OpTypePointer Function %v3float %main_inner = OpFunction %void None %33 @@ -331,109 +331,172 @@ %185 = OpLoad %_arr_v3float_uint_2 %182 None %arr2_vec3_f32 = OpFunctionCall %_arr_v3float_uint_2_0 %tint_convert_explicit_layout %185 %189 = OpFunctionCall %int %tint_f32_to_i32 %scalar_f32 - %191 = OpIAdd %int %189 %scalar_i32 - %192 = OpBitcast %int %scalar_u32 - %193 = OpIAdd %int %191 %192 - %194 = OpCompositeExtract %float %vec2_f32 0 - %195 = OpFunctionCall %int %tint_f32_to_i32 %194 - %196 = OpIAdd %int %193 %195 - %197 = OpCompositeExtract %int %vec2_i32 0 - %198 = OpIAdd %int %196 %197 - %199 = OpCompositeExtract %uint %vec2_u32 0 - %200 = OpBitcast %int %199 - %201 = OpIAdd %int %198 %200 - %202 = OpCompositeExtract %float %vec3_f32 1 - %203 = OpFunctionCall %int %tint_f32_to_i32 %202 - %204 = OpIAdd %int %201 %203 - %205 = OpCompositeExtract %int %vec3_i32 1 - %206 = OpIAdd %int %204 %205 - %207 = OpCompositeExtract %uint %vec3_u32 1 - %208 = OpBitcast %int %207 - %209 = OpIAdd %int %206 %208 - %210 = OpCompositeExtract %float %vec4_f32 2 - %211 = OpFunctionCall %int %tint_f32_to_i32 %210 - %212 = OpIAdd %int %209 %211 - %213 = OpCompositeExtract %int %vec4_i32 2 - %214 = OpIAdd %int %212 %213 - %215 = OpCompositeExtract %uint %vec4_u32 2 + %191 = OpBitcast %uint %189 + %192 = OpBitcast %uint %scalar_i32 + %193 = OpIAdd %uint %191 %192 + %194 = OpBitcast %int %193 + %195 = OpBitcast %int %scalar_u32 + %196 = OpBitcast %uint %194 + %197 = OpBitcast %uint %195 + %198 = OpIAdd %uint %196 %197 + %199 = OpBitcast %int %198 + %200 = OpCompositeExtract %float %vec2_f32 0 + %201 = OpFunctionCall %int %tint_f32_to_i32 %200 + %202 = OpBitcast %uint %199 + %203 = OpBitcast %uint %201 + %204 = OpIAdd %uint %202 %203 + %205 = OpBitcast %int %204 + %206 = OpCompositeExtract %int %vec2_i32 0 + %207 = OpBitcast %uint %205 + %208 = OpBitcast %uint %206 + %209 = OpIAdd %uint %207 %208 + %210 = OpBitcast %int %209 + %211 = OpCompositeExtract %uint %vec2_u32 0 + %212 = OpBitcast %int %211 + %213 = OpBitcast %uint %210 + %214 = OpBitcast %uint %212 + %215 = OpIAdd %uint %213 %214 %216 = OpBitcast %int %215 - %217 = OpIAdd %int %214 %216 - %218 = OpCompositeExtract %float %mat2x2_f32 0 0 - %219 = OpFunctionCall %int %tint_f32_to_i32 %218 - %220 = OpIAdd %int %217 %219 - %221 = OpCompositeExtract %float %mat2x3_f32 0 0 - %222 = OpFunctionCall %int %tint_f32_to_i32 %221 - %223 = OpIAdd %int %220 %222 - %224 = OpCompositeExtract %float %mat2x4_f32 0 0 - %225 = OpFunctionCall %int %tint_f32_to_i32 %224 - %226 = OpIAdd %int %223 %225 - %227 = OpCompositeExtract %float %mat3x2_f32 0 0 - %228 = OpFunctionCall %int %tint_f32_to_i32 %227 - %229 = OpIAdd %int %226 %228 - %230 = OpCompositeExtract %float %mat3x3_f32 0 0 - %231 = OpFunctionCall %int %tint_f32_to_i32 %230 - %232 = OpIAdd %int %229 %231 - %233 = OpCompositeExtract %float %mat3x4_f32 0 0 - %234 = OpFunctionCall %int %tint_f32_to_i32 %233 - %235 = OpIAdd %int %232 %234 - %236 = OpCompositeExtract %float %mat4x2_f32 0 0 - %237 = OpFunctionCall %int %tint_f32_to_i32 %236 - %238 = OpIAdd %int %235 %237 - %239 = OpCompositeExtract %float %mat4x3_f32 0 0 - %240 = OpFunctionCall %int %tint_f32_to_i32 %239 - %241 = OpIAdd %int %238 %240 - %242 = OpCompositeExtract %float %mat4x4_f32 0 0 - %243 = OpFunctionCall %int %tint_f32_to_i32 %242 - %244 = OpIAdd %int %241 %243 - %245 = OpCompositeExtract %float %arr2_vec3_f32 0 0 - %246 = OpFunctionCall %int %tint_f32_to_i32 %245 - %247 = OpIAdd %int %244 %246 - %248 = OpAccessChain %_ptr_StorageBuffer_int %25 %uint_0 - OpStore %248 %247 None + %217 = OpCompositeExtract %float %vec3_f32 1 + %218 = OpFunctionCall %int %tint_f32_to_i32 %217 + %219 = OpBitcast %uint %216 + %220 = OpBitcast %uint %218 + %221 = OpIAdd %uint %219 %220 + %222 = OpBitcast %int %221 + %223 = OpCompositeExtract %int %vec3_i32 1 + %224 = OpBitcast %uint %222 + %225 = OpBitcast %uint %223 + %226 = OpIAdd %uint %224 %225 + %227 = OpBitcast %int %226 + %228 = OpCompositeExtract %uint %vec3_u32 1 + %229 = OpBitcast %int %228 + %230 = OpBitcast %uint %227 + %231 = OpBitcast %uint %229 + %232 = OpIAdd %uint %230 %231 + %233 = OpBitcast %int %232 + %234 = OpCompositeExtract %float %vec4_f32 2 + %235 = OpFunctionCall %int %tint_f32_to_i32 %234 + %236 = OpBitcast %uint %233 + %237 = OpBitcast %uint %235 + %238 = OpIAdd %uint %236 %237 + %239 = OpBitcast %int %238 + %240 = OpCompositeExtract %int %vec4_i32 2 + %241 = OpBitcast %uint %239 + %242 = OpBitcast %uint %240 + %243 = OpIAdd %uint %241 %242 + %244 = OpBitcast %int %243 + %245 = OpCompositeExtract %uint %vec4_u32 2 + %246 = OpBitcast %int %245 + %247 = OpBitcast %uint %244 + %248 = OpBitcast %uint %246 + %249 = OpIAdd %uint %247 %248 + %250 = OpBitcast %int %249 + %251 = OpCompositeExtract %float %mat2x2_f32 0 0 + %252 = OpFunctionCall %int %tint_f32_to_i32 %251 + %253 = OpBitcast %uint %250 + %254 = OpBitcast %uint %252 + %255 = OpIAdd %uint %253 %254 + %256 = OpBitcast %int %255 + %257 = OpCompositeExtract %float %mat2x3_f32 0 0 + %258 = OpFunctionCall %int %tint_f32_to_i32 %257 + %259 = OpBitcast %uint %256 + %260 = OpBitcast %uint %258 + %261 = OpIAdd %uint %259 %260 + %262 = OpBitcast %int %261 + %263 = OpCompositeExtract %float %mat2x4_f32 0 0 + %264 = OpFunctionCall %int %tint_f32_to_i32 %263 + %265 = OpBitcast %uint %262 + %266 = OpBitcast %uint %264 + %267 = OpIAdd %uint %265 %266 + %268 = OpBitcast %int %267 + %269 = OpCompositeExtract %float %mat3x2_f32 0 0 + %270 = OpFunctionCall %int %tint_f32_to_i32 %269 + %271 = OpBitcast %uint %268 + %272 = OpBitcast %uint %270 + %273 = OpIAdd %uint %271 %272 + %274 = OpBitcast %int %273 + %275 = OpCompositeExtract %float %mat3x3_f32 0 0 + %276 = OpFunctionCall %int %tint_f32_to_i32 %275 + %277 = OpBitcast %uint %274 + %278 = OpBitcast %uint %276 + %279 = OpIAdd %uint %277 %278 + %280 = OpBitcast %int %279 + %281 = OpCompositeExtract %float %mat3x4_f32 0 0 + %282 = OpFunctionCall %int %tint_f32_to_i32 %281 + %283 = OpBitcast %uint %280 + %284 = OpBitcast %uint %282 + %285 = OpIAdd %uint %283 %284 + %286 = OpBitcast %int %285 + %287 = OpCompositeExtract %float %mat4x2_f32 0 0 + %288 = OpFunctionCall %int %tint_f32_to_i32 %287 + %289 = OpBitcast %uint %286 + %290 = OpBitcast %uint %288 + %291 = OpIAdd %uint %289 %290 + %292 = OpBitcast %int %291 + %293 = OpCompositeExtract %float %mat4x3_f32 0 0 + %294 = OpFunctionCall %int %tint_f32_to_i32 %293 + %295 = OpBitcast %uint %292 + %296 = OpBitcast %uint %294 + %297 = OpIAdd %uint %295 %296 + %298 = OpBitcast %int %297 + %299 = OpCompositeExtract %float %mat4x4_f32 0 0 + %300 = OpFunctionCall %int %tint_f32_to_i32 %299 + %301 = OpBitcast %uint %298 + %302 = OpBitcast %uint %300 + %303 = OpIAdd %uint %301 %302 + %304 = OpBitcast %int %303 + %305 = OpCompositeExtract %float %arr2_vec3_f32 0 0 + %306 = OpFunctionCall %int %tint_f32_to_i32 %305 + %307 = OpBitcast %uint %304 + %308 = OpBitcast %uint %306 + %309 = OpIAdd %uint %307 %308 + %310 = OpBitcast %int %309 + %311 = OpAccessChain %_ptr_StorageBuffer_int %25 %uint_0 + OpStore %311 %310 None OpReturn OpFunctionEnd -%tint_f32_to_i32 = OpFunction %int None %251 +%tint_f32_to_i32 = OpFunction %int None %314 %value = OpFunctionParameter %float - %252 = OpLabel - %253 = OpExtInst %float %36 NClamp %value %float_n2_14748365e_09 %float_2_14748352e_09 - %256 = OpConvertFToS %int %253 - OpReturnValue %256 + %315 = OpLabel + %316 = OpExtInst %float %36 NClamp %value %float_n2_14748365e_09 %float_2_14748352e_09 + %319 = OpConvertFToS %int %316 + OpReturnValue %319 OpFunctionEnd - %main = OpFunction %void None %258 - %259 = OpLabel - %260 = OpLoad %uint %main_local_invocation_index_Input None - %261 = OpFunctionCall %void %main_inner %260 + %main = OpFunction %void None %321 + %322 = OpLabel + %323 = OpLoad %uint %main_local_invocation_index_Input None + %324 = OpFunctionCall %void %main_inner %323 OpReturn OpFunctionEnd -%tint_convert_explicit_layout = OpFunction %_arr_v3float_uint_2_0 None %263 +%tint_convert_explicit_layout = OpFunction %_arr_v3float_uint_2_0 None %326 %tint_source = OpFunctionParameter %_arr_v3float_uint_2 - %264 = OpLabel - %265 = OpVariable %_ptr_Function__arr_v3float_uint_2 Function - %267 = OpVariable %_ptr_Function__arr_v3float_uint_2_0 Function %269 - OpStore %265 %tint_source - OpBranch %270 - %270 = OpLabel - OpBranch %273 - %273 = OpLabel - %275 = OpPhi %uint %uint_0 %270 %276 %272 - OpLoopMerge %274 %272 None - OpBranch %271 - %271 = OpLabel - %278 = OpUGreaterThanEqual %bool %275 %uint_2 - OpSelectionMerge %280 None - OpBranchConditional %278 %281 %280 - %281 = OpLabel - OpBranch %274 - %280 = OpLabel - %282 = OpAccessChain %_ptr_Function_v3float %265 %275 - %284 = OpLoad %v3float %282 None - %285 = OpAccessChain %_ptr_Function_v3float %267 %275 - OpStore %285 %284 None - OpBranch %272 - %272 = OpLabel - %276 = OpIAdd %uint %275 %uint_1 - OpBranch %273 - %274 = OpLabel - %277 = OpLoad %_arr_v3float_uint_2_0 %267 None - OpReturnValue %277 + %327 = OpLabel + %328 = OpVariable %_ptr_Function__arr_v3float_uint_2 Function + %330 = OpVariable %_ptr_Function__arr_v3float_uint_2_0 Function %332 + OpStore %328 %tint_source + OpBranch %333 + %333 = OpLabel + OpBranch %336 + %336 = OpLabel + %338 = OpPhi %uint %uint_0 %333 %339 %335 + OpLoopMerge %337 %335 None + OpBranch %334 + %334 = OpLabel + %341 = OpUGreaterThanEqual %bool %338 %uint_2 + OpSelectionMerge %343 None + OpBranchConditional %341 %344 %343 + %344 = OpLabel + OpBranch %337 + %343 = OpLabel + %345 = OpAccessChain %_ptr_Function_v3float %328 %338 + %347 = OpLoad %v3float %345 None + %348 = OpAccessChain %_ptr_Function_v3float %330 %338 + OpStore %348 %347 None + OpBranch %335 + %335 = OpLabel + %339 = OpIAdd %uint %338 %uint_1 + OpBranch %336 + %337 = OpLabel + %340 = OpLoad %_arr_v3float_uint_2_0 %330 None + OpReturnValue %340 OpFunctionEnd
diff --git a/test/tint/buffer/uniform/dynamic_index/read_f16.wgsl.expected.glsl b/test/tint/buffer/uniform/dynamic_index/read_f16.wgsl.expected.glsl index 6799dc4..ef1797b 100644 --- a/test/tint/buffer/uniform/dynamic_index/read_f16.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/dynamic_index/read_f16.wgsl.expected.glsl
@@ -172,38 +172,104 @@ } } f16mat4x2 arr2_mat4x2_f16[2] = v_3; - int v_6 = (tint_f32_to_i32(scalar_f32) + scalar_i32); - int v_7 = (v_6 + int(scalar_u32)); - int v_8 = (v_7 + tint_f16_to_i32(scalar_f16)); - int v_9 = ((v_8 + tint_f32_to_i32(vec2_f32.x)) + vec2_i32.x); - int v_10 = (v_9 + int(vec2_u32.x)); - int v_11 = (v_10 + tint_f16_to_i32(vec2_f16.x)); - int v_12 = ((v_11 + tint_f32_to_i32(vec3_f32.y)) + vec3_i32.y); - int v_13 = (v_12 + int(vec3_u32.y)); - int v_14 = (v_13 + tint_f16_to_i32(vec3_f16.y)); - int v_15 = ((v_14 + tint_f32_to_i32(vec4_f32.z)) + vec4_i32.z); - int v_16 = (v_15 + int(vec4_u32.z)); - int v_17 = (v_16 + tint_f16_to_i32(vec4_f16.z)); - int v_18 = (v_17 + tint_f32_to_i32(mat2x2_f32[0u].x)); - int v_19 = (v_18 + tint_f32_to_i32(mat2x3_f32[0u].x)); - int v_20 = (v_19 + tint_f32_to_i32(mat2x4_f32[0u].x)); - int v_21 = (v_20 + tint_f32_to_i32(mat3x2_f32[0u].x)); - int v_22 = (v_21 + tint_f32_to_i32(mat3x3_f32[0u].x)); - int v_23 = (v_22 + tint_f32_to_i32(mat3x4_f32[0u].x)); - int v_24 = (v_23 + tint_f32_to_i32(mat4x2_f32[0u].x)); - int v_25 = (v_24 + tint_f32_to_i32(mat4x3_f32[0u].x)); - int v_26 = (v_25 + tint_f32_to_i32(mat4x4_f32[0u].x)); - int v_27 = (v_26 + tint_f16_to_i32(mat2x2_f16[0u].x)); - int v_28 = (v_27 + tint_f16_to_i32(mat2x3_f16[0u].x)); - int v_29 = (v_28 + tint_f16_to_i32(mat2x4_f16[0u].x)); - int v_30 = (v_29 + tint_f16_to_i32(mat3x2_f16[0u].x)); - int v_31 = (v_30 + tint_f16_to_i32(mat3x3_f16[0u].x)); - int v_32 = (v_31 + tint_f16_to_i32(mat3x4_f16[0u].x)); - int v_33 = (v_32 + tint_f16_to_i32(mat4x2_f16[0u].x)); - int v_34 = (v_33 + tint_f16_to_i32(mat4x3_f16[0u].x)); - int v_35 = (v_34 + tint_f16_to_i32(mat4x4_f16[0u].x)); - int v_36 = (v_35 + tint_f32_to_i32(arr2_vec3_f32[0u].x)); - v_1.inner = (v_36 + tint_f16_to_i32(arr2_mat4x2_f16[0u][0u].x)); + uint v_6 = uint(tint_f32_to_i32(scalar_f32)); + int v_7 = int((v_6 + uint(scalar_i32))); + int v_8 = int(scalar_u32); + uint v_9 = uint(v_7); + int v_10 = int((v_9 + uint(v_8))); + int v_11 = tint_f16_to_i32(scalar_f16); + uint v_12 = uint(v_10); + int v_13 = int((v_12 + uint(v_11))); + int v_14 = tint_f32_to_i32(vec2_f32.x); + uint v_15 = uint(v_13); + uint v_16 = uint(int((v_15 + uint(v_14)))); + int v_17 = int((v_16 + uint(vec2_i32.x))); + int v_18 = int(vec2_u32.x); + uint v_19 = uint(v_17); + int v_20 = int((v_19 + uint(v_18))); + int v_21 = tint_f16_to_i32(vec2_f16.x); + uint v_22 = uint(v_20); + int v_23 = int((v_22 + uint(v_21))); + int v_24 = tint_f32_to_i32(vec3_f32.y); + uint v_25 = uint(v_23); + uint v_26 = uint(int((v_25 + uint(v_24)))); + int v_27 = int((v_26 + uint(vec3_i32.y))); + int v_28 = int(vec3_u32.y); + uint v_29 = uint(v_27); + int v_30 = int((v_29 + uint(v_28))); + int v_31 = tint_f16_to_i32(vec3_f16.y); + uint v_32 = uint(v_30); + int v_33 = int((v_32 + uint(v_31))); + int v_34 = tint_f32_to_i32(vec4_f32.z); + uint v_35 = uint(v_33); + uint v_36 = uint(int((v_35 + uint(v_34)))); + int v_37 = int((v_36 + uint(vec4_i32.z))); + int v_38 = int(vec4_u32.z); + uint v_39 = uint(v_37); + int v_40 = int((v_39 + uint(v_38))); + int v_41 = tint_f16_to_i32(vec4_f16.z); + uint v_42 = uint(v_40); + int v_43 = int((v_42 + uint(v_41))); + int v_44 = tint_f32_to_i32(mat2x2_f32[0u].x); + uint v_45 = uint(v_43); + int v_46 = int((v_45 + uint(v_44))); + int v_47 = tint_f32_to_i32(mat2x3_f32[0u].x); + uint v_48 = uint(v_46); + int v_49 = int((v_48 + uint(v_47))); + int v_50 = tint_f32_to_i32(mat2x4_f32[0u].x); + uint v_51 = uint(v_49); + int v_52 = int((v_51 + uint(v_50))); + int v_53 = tint_f32_to_i32(mat3x2_f32[0u].x); + uint v_54 = uint(v_52); + int v_55 = int((v_54 + uint(v_53))); + int v_56 = tint_f32_to_i32(mat3x3_f32[0u].x); + uint v_57 = uint(v_55); + int v_58 = int((v_57 + uint(v_56))); + int v_59 = tint_f32_to_i32(mat3x4_f32[0u].x); + uint v_60 = uint(v_58); + int v_61 = int((v_60 + uint(v_59))); + int v_62 = tint_f32_to_i32(mat4x2_f32[0u].x); + uint v_63 = uint(v_61); + int v_64 = int((v_63 + uint(v_62))); + int v_65 = tint_f32_to_i32(mat4x3_f32[0u].x); + uint v_66 = uint(v_64); + int v_67 = int((v_66 + uint(v_65))); + int v_68 = tint_f32_to_i32(mat4x4_f32[0u].x); + uint v_69 = uint(v_67); + int v_70 = int((v_69 + uint(v_68))); + int v_71 = tint_f16_to_i32(mat2x2_f16[0u].x); + uint v_72 = uint(v_70); + int v_73 = int((v_72 + uint(v_71))); + int v_74 = tint_f16_to_i32(mat2x3_f16[0u].x); + uint v_75 = uint(v_73); + int v_76 = int((v_75 + uint(v_74))); + int v_77 = tint_f16_to_i32(mat2x4_f16[0u].x); + uint v_78 = uint(v_76); + int v_79 = int((v_78 + uint(v_77))); + int v_80 = tint_f16_to_i32(mat3x2_f16[0u].x); + uint v_81 = uint(v_79); + int v_82 = int((v_81 + uint(v_80))); + int v_83 = tint_f16_to_i32(mat3x3_f16[0u].x); + uint v_84 = uint(v_82); + int v_85 = int((v_84 + uint(v_83))); + int v_86 = tint_f16_to_i32(mat3x4_f16[0u].x); + uint v_87 = uint(v_85); + int v_88 = int((v_87 + uint(v_86))); + int v_89 = tint_f16_to_i32(mat4x2_f16[0u].x); + uint v_90 = uint(v_88); + int v_91 = int((v_90 + uint(v_89))); + int v_92 = tint_f16_to_i32(mat4x3_f16[0u].x); + uint v_93 = uint(v_91); + int v_94 = int((v_93 + uint(v_92))); + int v_95 = tint_f16_to_i32(mat4x4_f16[0u].x); + uint v_96 = uint(v_94); + int v_97 = int((v_96 + uint(v_95))); + int v_98 = tint_f32_to_i32(arr2_vec3_f32[0u].x); + uint v_99 = uint(v_97); + int v_100 = int((v_99 + uint(v_98))); + int v_101 = tint_f16_to_i32(arr2_mat4x2_f16[0u][0u].x); + uint v_102 = uint(v_100); + v_1.inner = int((v_102 + uint(v_101))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/buffer/uniform/dynamic_index/read_f16.wgsl.expected.spvasm b/test/tint/buffer/uniform/dynamic_index/read_f16.wgsl.expected.spvasm index 6312b0c..35e2f5f 100644 --- a/test/tint/buffer/uniform/dynamic_index/read_f16.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/dynamic_index/read_f16.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 525 +; Bound: 630 ; Schema: 0 OpCapability Shader OpCapability Float16 @@ -375,21 +375,21 @@ %bool = OpTypeBool %_ptr_Function_mat4v2half = OpTypePointer Function %mat4v2half %_ptr_Function_mat4x2_f16_std140 = OpTypePointer Function %mat4x2_f16_std140 - %463 = OpTypeFunction %int %float + %568 = OpTypeFunction %int %float %float_n2_14748365e_09 = OpConstant %float -2.14748365e+09 %float_2_14748352e_09 = OpConstant %float 2.14748352e+09 - %470 = OpTypeFunction %int %half + %575 = OpTypeFunction %int %half %half_n0x1_ffcp_15 = OpConstant %half -0x1.ffcp+15 %half_0x1_ffcp_15 = OpConstant %half 0x1.ffcp+15 - %477 = OpTypeFunction %void - %482 = OpTypeFunction %_arr_v3float_uint_2_0 %_arr_v3float_uint_2 + %582 = OpTypeFunction %void + %587 = OpTypeFunction %_arr_v3float_uint_2_0 %_arr_v3float_uint_2 %_ptr_Function__arr_v3float_uint_2 = OpTypePointer Function %_arr_v3float_uint_2 %_ptr_Function__arr_v3float_uint_2_0 = OpTypePointer Function %_arr_v3float_uint_2_0 - %488 = OpConstantNull %_arr_v3float_uint_2_0 + %593 = OpConstantNull %_arr_v3float_uint_2_0 %_ptr_Function_v3float = OpTypePointer Function %v3float - %505 = OpTypeFunction %_arr_mat4x2_f16_std140_uint_2_0 %_arr_mat4x2_f16_std140_uint_2 + %610 = OpTypeFunction %_arr_mat4x2_f16_std140_uint_2_0 %_arr_mat4x2_f16_std140_uint_2 %_ptr_Function__arr_mat4x2_f16_std140_uint_2 = OpTypePointer Function %_arr_mat4x2_f16_std140_uint_2 - %510 = OpConstantNull %_arr_mat4x2_f16_std140_uint_2_0 + %615 = OpConstantNull %_arr_mat4x2_f16_std140_uint_2_0 %main_inner = OpFunction %void None %39 %idx = OpFunctionParameter %uint %40 = OpLabel @@ -589,21 +589,21 @@ OpLoopMerge %341 %339 None OpBranch %338 %338 = OpLabel - %448 = OpUGreaterThanEqual %bool %342 %uint_2 - OpSelectionMerge %450 None - OpBranchConditional %448 %451 %450 - %451 = OpLabel + %553 = OpUGreaterThanEqual %bool %342 %uint_2 + OpSelectionMerge %555 None + OpBranchConditional %553 %556 %555 + %556 = OpLabel OpBranch %341 - %450 = OpLabel - %452 = OpAccessChain %_ptr_Function_mat4v2half %333 %342 - %454 = OpAccessChain %_ptr_Function_mat4x2_f16_std140 %331 %342 - %456 = OpLoad %mat4x2_f16_std140 %454 None - %457 = OpCompositeExtract %v2half %456 0 - %458 = OpCompositeExtract %v2half %456 1 - %459 = OpCompositeExtract %v2half %456 2 - %460 = OpCompositeExtract %v2half %456 3 - %461 = OpCompositeConstruct %mat4v2half %457 %458 %459 %460 - OpStore %452 %461 None + %555 = OpLabel + %557 = OpAccessChain %_ptr_Function_mat4v2half %333 %342 + %559 = OpAccessChain %_ptr_Function_mat4x2_f16_std140 %331 %342 + %561 = OpLoad %mat4x2_f16_std140 %559 None + %562 = OpCompositeExtract %v2half %561 0 + %563 = OpCompositeExtract %v2half %561 1 + %564 = OpCompositeExtract %v2half %561 2 + %565 = OpCompositeExtract %v2half %561 3 + %566 = OpCompositeConstruct %mat4v2half %562 %563 %564 %565 + OpStore %557 %566 None OpBranch %339 %339 = OpLabel %343 = OpIAdd %uint %342 %uint_1 @@ -611,189 +611,294 @@ %341 = OpLabel %arr2_mat4x2_f16 = OpLoad %_arr_mat4v2half_uint_2 %333 None %345 = OpFunctionCall %int %tint_f32_to_i32 %scalar_f32 - %347 = OpIAdd %int %345 %scalar_i32 - %348 = OpBitcast %int %scalar_u32 - %349 = OpIAdd %int %347 %348 - %350 = OpFunctionCall %int %tint_f16_to_i32 %scalar_f16 - %352 = OpIAdd %int %349 %350 - %353 = OpCompositeExtract %float %vec2_f32 0 - %354 = OpFunctionCall %int %tint_f32_to_i32 %353 - %355 = OpIAdd %int %352 %354 - %356 = OpCompositeExtract %int %vec2_i32 0 - %357 = OpIAdd %int %355 %356 - %358 = OpCompositeExtract %uint %vec2_u32 0 - %359 = OpBitcast %int %358 - %360 = OpIAdd %int %357 %359 - %361 = OpCompositeExtract %half %vec2_f16 0 - %362 = OpFunctionCall %int %tint_f16_to_i32 %361 - %363 = OpIAdd %int %360 %362 - %364 = OpCompositeExtract %float %vec3_f32 1 - %365 = OpFunctionCall %int %tint_f32_to_i32 %364 - %366 = OpIAdd %int %363 %365 - %367 = OpCompositeExtract %int %vec3_i32 1 - %368 = OpIAdd %int %366 %367 - %369 = OpCompositeExtract %uint %vec3_u32 1 - %370 = OpBitcast %int %369 - %371 = OpIAdd %int %368 %370 - %372 = OpCompositeExtract %half %vec3_f16 1 - %373 = OpFunctionCall %int %tint_f16_to_i32 %372 - %374 = OpIAdd %int %371 %373 - %375 = OpCompositeExtract %float %vec4_f32 2 - %376 = OpFunctionCall %int %tint_f32_to_i32 %375 - %377 = OpIAdd %int %374 %376 - %378 = OpCompositeExtract %int %vec4_i32 2 - %379 = OpIAdd %int %377 %378 - %380 = OpCompositeExtract %uint %vec4_u32 2 - %381 = OpBitcast %int %380 - %382 = OpIAdd %int %379 %381 - %383 = OpCompositeExtract %half %vec4_f16 2 - %384 = OpFunctionCall %int %tint_f16_to_i32 %383 - %385 = OpIAdd %int %382 %384 - %386 = OpCompositeExtract %float %mat2x2_f32 0 0 - %387 = OpFunctionCall %int %tint_f32_to_i32 %386 - %388 = OpIAdd %int %385 %387 - %389 = OpCompositeExtract %float %mat2x3_f32 0 0 - %390 = OpFunctionCall %int %tint_f32_to_i32 %389 - %391 = OpIAdd %int %388 %390 - %392 = OpCompositeExtract %float %mat2x4_f32 0 0 - %393 = OpFunctionCall %int %tint_f32_to_i32 %392 - %394 = OpIAdd %int %391 %393 - %395 = OpCompositeExtract %float %mat3x2_f32 0 0 - %396 = OpFunctionCall %int %tint_f32_to_i32 %395 - %397 = OpIAdd %int %394 %396 - %398 = OpCompositeExtract %float %mat3x3_f32 0 0 - %399 = OpFunctionCall %int %tint_f32_to_i32 %398 - %400 = OpIAdd %int %397 %399 - %401 = OpCompositeExtract %float %mat3x4_f32 0 0 - %402 = OpFunctionCall %int %tint_f32_to_i32 %401 - %403 = OpIAdd %int %400 %402 - %404 = OpCompositeExtract %float %mat4x2_f32 0 0 - %405 = OpFunctionCall %int %tint_f32_to_i32 %404 - %406 = OpIAdd %int %403 %405 - %407 = OpCompositeExtract %float %mat4x3_f32 0 0 - %408 = OpFunctionCall %int %tint_f32_to_i32 %407 - %409 = OpIAdd %int %406 %408 - %410 = OpCompositeExtract %float %mat4x4_f32 0 0 - %411 = OpFunctionCall %int %tint_f32_to_i32 %410 - %412 = OpIAdd %int %409 %411 - %413 = OpCompositeExtract %half %mat2x2_f16 0 0 - %414 = OpFunctionCall %int %tint_f16_to_i32 %413 - %415 = OpIAdd %int %412 %414 - %416 = OpCompositeExtract %half %mat2x3_f16 0 0 - %417 = OpFunctionCall %int %tint_f16_to_i32 %416 - %418 = OpIAdd %int %415 %417 - %419 = OpCompositeExtract %half %mat2x4_f16 0 0 - %420 = OpFunctionCall %int %tint_f16_to_i32 %419 - %421 = OpIAdd %int %418 %420 - %422 = OpCompositeExtract %half %mat3x2_f16 0 0 - %423 = OpFunctionCall %int %tint_f16_to_i32 %422 - %424 = OpIAdd %int %421 %423 - %425 = OpCompositeExtract %half %mat3x3_f16 0 0 + %347 = OpBitcast %uint %345 + %348 = OpBitcast %uint %scalar_i32 + %349 = OpIAdd %uint %347 %348 + %350 = OpBitcast %int %349 + %351 = OpBitcast %int %scalar_u32 + %352 = OpBitcast %uint %350 + %353 = OpBitcast %uint %351 + %354 = OpIAdd %uint %352 %353 + %355 = OpBitcast %int %354 + %356 = OpFunctionCall %int %tint_f16_to_i32 %scalar_f16 + %358 = OpBitcast %uint %355 + %359 = OpBitcast %uint %356 + %360 = OpIAdd %uint %358 %359 + %361 = OpBitcast %int %360 + %362 = OpCompositeExtract %float %vec2_f32 0 + %363 = OpFunctionCall %int %tint_f32_to_i32 %362 + %364 = OpBitcast %uint %361 + %365 = OpBitcast %uint %363 + %366 = OpIAdd %uint %364 %365 + %367 = OpBitcast %int %366 + %368 = OpCompositeExtract %int %vec2_i32 0 + %369 = OpBitcast %uint %367 + %370 = OpBitcast %uint %368 + %371 = OpIAdd %uint %369 %370 + %372 = OpBitcast %int %371 + %373 = OpCompositeExtract %uint %vec2_u32 0 + %374 = OpBitcast %int %373 + %375 = OpBitcast %uint %372 + %376 = OpBitcast %uint %374 + %377 = OpIAdd %uint %375 %376 + %378 = OpBitcast %int %377 + %379 = OpCompositeExtract %half %vec2_f16 0 + %380 = OpFunctionCall %int %tint_f16_to_i32 %379 + %381 = OpBitcast %uint %378 + %382 = OpBitcast %uint %380 + %383 = OpIAdd %uint %381 %382 + %384 = OpBitcast %int %383 + %385 = OpCompositeExtract %float %vec3_f32 1 + %386 = OpFunctionCall %int %tint_f32_to_i32 %385 + %387 = OpBitcast %uint %384 + %388 = OpBitcast %uint %386 + %389 = OpIAdd %uint %387 %388 + %390 = OpBitcast %int %389 + %391 = OpCompositeExtract %int %vec3_i32 1 + %392 = OpBitcast %uint %390 + %393 = OpBitcast %uint %391 + %394 = OpIAdd %uint %392 %393 + %395 = OpBitcast %int %394 + %396 = OpCompositeExtract %uint %vec3_u32 1 + %397 = OpBitcast %int %396 + %398 = OpBitcast %uint %395 + %399 = OpBitcast %uint %397 + %400 = OpIAdd %uint %398 %399 + %401 = OpBitcast %int %400 + %402 = OpCompositeExtract %half %vec3_f16 1 + %403 = OpFunctionCall %int %tint_f16_to_i32 %402 + %404 = OpBitcast %uint %401 + %405 = OpBitcast %uint %403 + %406 = OpIAdd %uint %404 %405 + %407 = OpBitcast %int %406 + %408 = OpCompositeExtract %float %vec4_f32 2 + %409 = OpFunctionCall %int %tint_f32_to_i32 %408 + %410 = OpBitcast %uint %407 + %411 = OpBitcast %uint %409 + %412 = OpIAdd %uint %410 %411 + %413 = OpBitcast %int %412 + %414 = OpCompositeExtract %int %vec4_i32 2 + %415 = OpBitcast %uint %413 + %416 = OpBitcast %uint %414 + %417 = OpIAdd %uint %415 %416 + %418 = OpBitcast %int %417 + %419 = OpCompositeExtract %uint %vec4_u32 2 + %420 = OpBitcast %int %419 + %421 = OpBitcast %uint %418 + %422 = OpBitcast %uint %420 + %423 = OpIAdd %uint %421 %422 + %424 = OpBitcast %int %423 + %425 = OpCompositeExtract %half %vec4_f16 2 %426 = OpFunctionCall %int %tint_f16_to_i32 %425 - %427 = OpIAdd %int %424 %426 - %428 = OpCompositeExtract %half %mat3x4_f16 0 0 - %429 = OpFunctionCall %int %tint_f16_to_i32 %428 - %430 = OpIAdd %int %427 %429 - %431 = OpCompositeExtract %half %mat4x2_f16 0 0 - %432 = OpFunctionCall %int %tint_f16_to_i32 %431 - %433 = OpIAdd %int %430 %432 - %434 = OpCompositeExtract %half %mat4x3_f16 0 0 - %435 = OpFunctionCall %int %tint_f16_to_i32 %434 - %436 = OpIAdd %int %433 %435 - %437 = OpCompositeExtract %half %mat4x4_f16 0 0 - %438 = OpFunctionCall %int %tint_f16_to_i32 %437 - %439 = OpIAdd %int %436 %438 - %440 = OpCompositeExtract %float %arr2_vec3_f32 0 0 - %441 = OpFunctionCall %int %tint_f32_to_i32 %440 - %442 = OpIAdd %int %439 %441 - %443 = OpCompositeExtract %half %arr2_mat4x2_f16 0 0 0 - %444 = OpFunctionCall %int %tint_f16_to_i32 %443 - %445 = OpIAdd %int %442 %444 - %446 = OpAccessChain %_ptr_StorageBuffer_int %31 %uint_0 - OpStore %446 %445 None + %427 = OpBitcast %uint %424 + %428 = OpBitcast %uint %426 + %429 = OpIAdd %uint %427 %428 + %430 = OpBitcast %int %429 + %431 = OpCompositeExtract %float %mat2x2_f32 0 0 + %432 = OpFunctionCall %int %tint_f32_to_i32 %431 + %433 = OpBitcast %uint %430 + %434 = OpBitcast %uint %432 + %435 = OpIAdd %uint %433 %434 + %436 = OpBitcast %int %435 + %437 = OpCompositeExtract %float %mat2x3_f32 0 0 + %438 = OpFunctionCall %int %tint_f32_to_i32 %437 + %439 = OpBitcast %uint %436 + %440 = OpBitcast %uint %438 + %441 = OpIAdd %uint %439 %440 + %442 = OpBitcast %int %441 + %443 = OpCompositeExtract %float %mat2x4_f32 0 0 + %444 = OpFunctionCall %int %tint_f32_to_i32 %443 + %445 = OpBitcast %uint %442 + %446 = OpBitcast %uint %444 + %447 = OpIAdd %uint %445 %446 + %448 = OpBitcast %int %447 + %449 = OpCompositeExtract %float %mat3x2_f32 0 0 + %450 = OpFunctionCall %int %tint_f32_to_i32 %449 + %451 = OpBitcast %uint %448 + %452 = OpBitcast %uint %450 + %453 = OpIAdd %uint %451 %452 + %454 = OpBitcast %int %453 + %455 = OpCompositeExtract %float %mat3x3_f32 0 0 + %456 = OpFunctionCall %int %tint_f32_to_i32 %455 + %457 = OpBitcast %uint %454 + %458 = OpBitcast %uint %456 + %459 = OpIAdd %uint %457 %458 + %460 = OpBitcast %int %459 + %461 = OpCompositeExtract %float %mat3x4_f32 0 0 + %462 = OpFunctionCall %int %tint_f32_to_i32 %461 + %463 = OpBitcast %uint %460 + %464 = OpBitcast %uint %462 + %465 = OpIAdd %uint %463 %464 + %466 = OpBitcast %int %465 + %467 = OpCompositeExtract %float %mat4x2_f32 0 0 + %468 = OpFunctionCall %int %tint_f32_to_i32 %467 + %469 = OpBitcast %uint %466 + %470 = OpBitcast %uint %468 + %471 = OpIAdd %uint %469 %470 + %472 = OpBitcast %int %471 + %473 = OpCompositeExtract %float %mat4x3_f32 0 0 + %474 = OpFunctionCall %int %tint_f32_to_i32 %473 + %475 = OpBitcast %uint %472 + %476 = OpBitcast %uint %474 + %477 = OpIAdd %uint %475 %476 + %478 = OpBitcast %int %477 + %479 = OpCompositeExtract %float %mat4x4_f32 0 0 + %480 = OpFunctionCall %int %tint_f32_to_i32 %479 + %481 = OpBitcast %uint %478 + %482 = OpBitcast %uint %480 + %483 = OpIAdd %uint %481 %482 + %484 = OpBitcast %int %483 + %485 = OpCompositeExtract %half %mat2x2_f16 0 0 + %486 = OpFunctionCall %int %tint_f16_to_i32 %485 + %487 = OpBitcast %uint %484 + %488 = OpBitcast %uint %486 + %489 = OpIAdd %uint %487 %488 + %490 = OpBitcast %int %489 + %491 = OpCompositeExtract %half %mat2x3_f16 0 0 + %492 = OpFunctionCall %int %tint_f16_to_i32 %491 + %493 = OpBitcast %uint %490 + %494 = OpBitcast %uint %492 + %495 = OpIAdd %uint %493 %494 + %496 = OpBitcast %int %495 + %497 = OpCompositeExtract %half %mat2x4_f16 0 0 + %498 = OpFunctionCall %int %tint_f16_to_i32 %497 + %499 = OpBitcast %uint %496 + %500 = OpBitcast %uint %498 + %501 = OpIAdd %uint %499 %500 + %502 = OpBitcast %int %501 + %503 = OpCompositeExtract %half %mat3x2_f16 0 0 + %504 = OpFunctionCall %int %tint_f16_to_i32 %503 + %505 = OpBitcast %uint %502 + %506 = OpBitcast %uint %504 + %507 = OpIAdd %uint %505 %506 + %508 = OpBitcast %int %507 + %509 = OpCompositeExtract %half %mat3x3_f16 0 0 + %510 = OpFunctionCall %int %tint_f16_to_i32 %509 + %511 = OpBitcast %uint %508 + %512 = OpBitcast %uint %510 + %513 = OpIAdd %uint %511 %512 + %514 = OpBitcast %int %513 + %515 = OpCompositeExtract %half %mat3x4_f16 0 0 + %516 = OpFunctionCall %int %tint_f16_to_i32 %515 + %517 = OpBitcast %uint %514 + %518 = OpBitcast %uint %516 + %519 = OpIAdd %uint %517 %518 + %520 = OpBitcast %int %519 + %521 = OpCompositeExtract %half %mat4x2_f16 0 0 + %522 = OpFunctionCall %int %tint_f16_to_i32 %521 + %523 = OpBitcast %uint %520 + %524 = OpBitcast %uint %522 + %525 = OpIAdd %uint %523 %524 + %526 = OpBitcast %int %525 + %527 = OpCompositeExtract %half %mat4x3_f16 0 0 + %528 = OpFunctionCall %int %tint_f16_to_i32 %527 + %529 = OpBitcast %uint %526 + %530 = OpBitcast %uint %528 + %531 = OpIAdd %uint %529 %530 + %532 = OpBitcast %int %531 + %533 = OpCompositeExtract %half %mat4x4_f16 0 0 + %534 = OpFunctionCall %int %tint_f16_to_i32 %533 + %535 = OpBitcast %uint %532 + %536 = OpBitcast %uint %534 + %537 = OpIAdd %uint %535 %536 + %538 = OpBitcast %int %537 + %539 = OpCompositeExtract %float %arr2_vec3_f32 0 0 + %540 = OpFunctionCall %int %tint_f32_to_i32 %539 + %541 = OpBitcast %uint %538 + %542 = OpBitcast %uint %540 + %543 = OpIAdd %uint %541 %542 + %544 = OpBitcast %int %543 + %545 = OpCompositeExtract %half %arr2_mat4x2_f16 0 0 0 + %546 = OpFunctionCall %int %tint_f16_to_i32 %545 + %547 = OpBitcast %uint %544 + %548 = OpBitcast %uint %546 + %549 = OpIAdd %uint %547 %548 + %550 = OpBitcast %int %549 + %551 = OpAccessChain %_ptr_StorageBuffer_int %31 %uint_0 + OpStore %551 %550 None OpReturn OpFunctionEnd -%tint_f32_to_i32 = OpFunction %int None %463 +%tint_f32_to_i32 = OpFunction %int None %568 %value = OpFunctionParameter %float - %464 = OpLabel - %465 = OpExtInst %float %42 NClamp %value %float_n2_14748365e_09 %float_2_14748352e_09 - %468 = OpConvertFToS %int %465 - OpReturnValue %468 + %569 = OpLabel + %570 = OpExtInst %float %42 NClamp %value %float_n2_14748365e_09 %float_2_14748352e_09 + %573 = OpConvertFToS %int %570 + OpReturnValue %573 OpFunctionEnd -%tint_f16_to_i32 = OpFunction %int None %470 +%tint_f16_to_i32 = OpFunction %int None %575 %value_0 = OpFunctionParameter %half - %471 = OpLabel - %472 = OpExtInst %half %42 NClamp %value_0 %half_n0x1_ffcp_15 %half_0x1_ffcp_15 - %475 = OpConvertFToS %int %472 - OpReturnValue %475 + %576 = OpLabel + %577 = OpExtInst %half %42 NClamp %value_0 %half_n0x1_ffcp_15 %half_0x1_ffcp_15 + %580 = OpConvertFToS %int %577 + OpReturnValue %580 OpFunctionEnd - %main = OpFunction %void None %477 - %478 = OpLabel - %479 = OpLoad %uint %main_local_invocation_index_Input None - %480 = OpFunctionCall %void %main_inner %479 + %main = OpFunction %void None %582 + %583 = OpLabel + %584 = OpLoad %uint %main_local_invocation_index_Input None + %585 = OpFunctionCall %void %main_inner %584 OpReturn OpFunctionEnd -%tint_convert_explicit_layout = OpFunction %_arr_v3float_uint_2_0 None %482 +%tint_convert_explicit_layout = OpFunction %_arr_v3float_uint_2_0 None %587 %tint_source = OpFunctionParameter %_arr_v3float_uint_2 - %483 = OpLabel - %484 = OpVariable %_ptr_Function__arr_v3float_uint_2 Function - %486 = OpVariable %_ptr_Function__arr_v3float_uint_2_0 Function %488 - OpStore %484 %tint_source - OpBranch %489 - %489 = OpLabel - OpBranch %492 - %492 = OpLabel - %494 = OpPhi %uint %uint_0 %489 %495 %491 - OpLoopMerge %493 %491 None - OpBranch %490 - %490 = OpLabel - %497 = OpUGreaterThanEqual %bool %494 %uint_2 - OpSelectionMerge %498 None - OpBranchConditional %497 %499 %498 - %499 = OpLabel - OpBranch %493 - %498 = OpLabel - %500 = OpAccessChain %_ptr_Function_v3float %484 %494 - %502 = OpLoad %v3float %500 None - %503 = OpAccessChain %_ptr_Function_v3float %486 %494 - OpStore %503 %502 None - OpBranch %491 - %491 = OpLabel - %495 = OpIAdd %uint %494 %uint_1 - OpBranch %492 - %493 = OpLabel - %496 = OpLoad %_arr_v3float_uint_2_0 %486 None - OpReturnValue %496 + %588 = OpLabel + %589 = OpVariable %_ptr_Function__arr_v3float_uint_2 Function + %591 = OpVariable %_ptr_Function__arr_v3float_uint_2_0 Function %593 + OpStore %589 %tint_source + OpBranch %594 + %594 = OpLabel + OpBranch %597 + %597 = OpLabel + %599 = OpPhi %uint %uint_0 %594 %600 %596 + OpLoopMerge %598 %596 None + OpBranch %595 + %595 = OpLabel + %602 = OpUGreaterThanEqual %bool %599 %uint_2 + OpSelectionMerge %603 None + OpBranchConditional %602 %604 %603 + %604 = OpLabel + OpBranch %598 + %603 = OpLabel + %605 = OpAccessChain %_ptr_Function_v3float %589 %599 + %607 = OpLoad %v3float %605 None + %608 = OpAccessChain %_ptr_Function_v3float %591 %599 + OpStore %608 %607 None + OpBranch %596 + %596 = OpLabel + %600 = OpIAdd %uint %599 %uint_1 + OpBranch %597 + %598 = OpLabel + %601 = OpLoad %_arr_v3float_uint_2_0 %591 None + OpReturnValue %601 OpFunctionEnd -%tint_convert_explicit_layout_0 = OpFunction %_arr_mat4x2_f16_std140_uint_2_0 None %505 +%tint_convert_explicit_layout_0 = OpFunction %_arr_mat4x2_f16_std140_uint_2_0 None %610 %tint_source_0 = OpFunctionParameter %_arr_mat4x2_f16_std140_uint_2 - %506 = OpLabel - %507 = OpVariable %_ptr_Function__arr_mat4x2_f16_std140_uint_2 Function - %509 = OpVariable %_ptr_Function__arr_mat4x2_f16_std140_uint_2_0 Function %510 - OpStore %507 %tint_source_0 - OpBranch %511 - %511 = OpLabel - OpBranch %514 - %514 = OpLabel - %516 = OpPhi %uint %uint_0 %511 %517 %513 - OpLoopMerge %515 %513 None - OpBranch %512 - %512 = OpLabel - %519 = OpUGreaterThanEqual %bool %516 %uint_2 - OpSelectionMerge %520 None - OpBranchConditional %519 %521 %520 - %521 = OpLabel - OpBranch %515 - %520 = OpLabel - %522 = OpAccessChain %_ptr_Function_mat4x2_f16_std140 %507 %516 - %523 = OpLoad %mat4x2_f16_std140 %522 None - %524 = OpAccessChain %_ptr_Function_mat4x2_f16_std140 %509 %516 - OpStore %524 %523 None - OpBranch %513 - %513 = OpLabel - %517 = OpIAdd %uint %516 %uint_1 - OpBranch %514 - %515 = OpLabel - %518 = OpLoad %_arr_mat4x2_f16_std140_uint_2_0 %509 None - OpReturnValue %518 + %611 = OpLabel + %612 = OpVariable %_ptr_Function__arr_mat4x2_f16_std140_uint_2 Function + %614 = OpVariable %_ptr_Function__arr_mat4x2_f16_std140_uint_2_0 Function %615 + OpStore %612 %tint_source_0 + OpBranch %616 + %616 = OpLabel + OpBranch %619 + %619 = OpLabel + %621 = OpPhi %uint %uint_0 %616 %622 %618 + OpLoopMerge %620 %618 None + OpBranch %617 + %617 = OpLabel + %624 = OpUGreaterThanEqual %bool %621 %uint_2 + OpSelectionMerge %625 None + OpBranchConditional %624 %626 %625 + %626 = OpLabel + OpBranch %620 + %625 = OpLabel + %627 = OpAccessChain %_ptr_Function_mat4x2_f16_std140 %612 %621 + %628 = OpLoad %mat4x2_f16_std140 %627 None + %629 = OpAccessChain %_ptr_Function_mat4x2_f16_std140 %614 %621 + OpStore %629 %628 None + OpBranch %618 + %618 = OpLabel + %622 = OpIAdd %uint %621 %uint_1 + OpBranch %619 + %620 = OpLabel + %623 = OpLoad %_arr_mat4x2_f16_std140_uint_2_0 %614 None + OpReturnValue %623 OpFunctionEnd
diff --git a/test/tint/buffer/uniform/static_index/read.wgsl.expected.glsl b/test/tint/buffer/uniform/static_index/read.wgsl.expected.glsl index a158c11..57ab07f 100644 --- a/test/tint/buffer/uniform/static_index/read.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/static_index/read.wgsl.expected.glsl
@@ -105,22 +105,62 @@ vec3 arr2_vec3_f32[2] = v.inner.arr2_vec3_f32; Inner struct_inner = v.inner.struct_inner; Inner array_struct_inner[4] = v.inner.array_struct_inner; - int v_2 = (tint_f32_to_i32(scalar_f32) + scalar_i32); - int v_3 = (v_2 + int(scalar_u32)); - int v_4 = ((v_3 + tint_f32_to_i32(vec2_f32.x)) + vec2_i32.x); - int v_5 = (v_4 + int(vec2_u32.x)); - int v_6 = ((v_5 + tint_f32_to_i32(vec3_f32.y)) + vec3_i32.y); - int v_7 = (v_6 + int(vec3_u32.y)); - int v_8 = ((v_7 + tint_f32_to_i32(vec4_f32.z)) + vec4_i32.z); - int v_9 = (v_8 + int(vec4_u32.z)); - int v_10 = (v_9 + tint_f32_to_i32(mat2x2_f32[0u].x)); - int v_11 = (v_10 + tint_f32_to_i32(mat2x3_f32[0u].x)); - int v_12 = (v_11 + tint_f32_to_i32(mat2x4_f32[0u].x)); - int v_13 = (v_12 + tint_f32_to_i32(mat3x2_f32[0u].x)); - int v_14 = (v_13 + tint_f32_to_i32(mat3x3_f32[0u].x)); - int v_15 = (v_14 + tint_f32_to_i32(mat3x4_f32[0u].x)); - int v_16 = (v_15 + tint_f32_to_i32(mat4x2_f32[0u].x)); - int v_17 = (v_16 + tint_f32_to_i32(mat4x3_f32[0u].x)); - int v_18 = (v_17 + tint_f32_to_i32(mat4x4_f32[0u].x)); - v_1.inner = (((v_18 + tint_f32_to_i32(arr2_vec3_f32[0u].x)) + struct_inner.scalar_i32) + array_struct_inner[0u].scalar_i32); + uint v_2 = uint(tint_f32_to_i32(scalar_f32)); + int v_3 = int((v_2 + uint(scalar_i32))); + int v_4 = int(scalar_u32); + uint v_5 = uint(v_3); + int v_6 = int((v_5 + uint(v_4))); + int v_7 = tint_f32_to_i32(vec2_f32.x); + uint v_8 = uint(v_6); + uint v_9 = uint(int((v_8 + uint(v_7)))); + int v_10 = int((v_9 + uint(vec2_i32.x))); + int v_11 = int(vec2_u32.x); + uint v_12 = uint(v_10); + int v_13 = int((v_12 + uint(v_11))); + int v_14 = tint_f32_to_i32(vec3_f32.y); + uint v_15 = uint(v_13); + uint v_16 = uint(int((v_15 + uint(v_14)))); + int v_17 = int((v_16 + uint(vec3_i32.y))); + int v_18 = int(vec3_u32.y); + uint v_19 = uint(v_17); + int v_20 = int((v_19 + uint(v_18))); + int v_21 = tint_f32_to_i32(vec4_f32.z); + uint v_22 = uint(v_20); + uint v_23 = uint(int((v_22 + uint(v_21)))); + int v_24 = int((v_23 + uint(vec4_i32.z))); + int v_25 = int(vec4_u32.z); + uint v_26 = uint(v_24); + int v_27 = int((v_26 + uint(v_25))); + int v_28 = tint_f32_to_i32(mat2x2_f32[0u].x); + uint v_29 = uint(v_27); + int v_30 = int((v_29 + uint(v_28))); + int v_31 = tint_f32_to_i32(mat2x3_f32[0u].x); + uint v_32 = uint(v_30); + int v_33 = int((v_32 + uint(v_31))); + int v_34 = tint_f32_to_i32(mat2x4_f32[0u].x); + uint v_35 = uint(v_33); + int v_36 = int((v_35 + uint(v_34))); + int v_37 = tint_f32_to_i32(mat3x2_f32[0u].x); + uint v_38 = uint(v_36); + int v_39 = int((v_38 + uint(v_37))); + int v_40 = tint_f32_to_i32(mat3x3_f32[0u].x); + uint v_41 = uint(v_39); + int v_42 = int((v_41 + uint(v_40))); + int v_43 = tint_f32_to_i32(mat3x4_f32[0u].x); + uint v_44 = uint(v_42); + int v_45 = int((v_44 + uint(v_43))); + int v_46 = tint_f32_to_i32(mat4x2_f32[0u].x); + uint v_47 = uint(v_45); + int v_48 = int((v_47 + uint(v_46))); + int v_49 = tint_f32_to_i32(mat4x3_f32[0u].x); + uint v_50 = uint(v_48); + int v_51 = int((v_50 + uint(v_49))); + int v_52 = tint_f32_to_i32(mat4x4_f32[0u].x); + uint v_53 = uint(v_51); + int v_54 = int((v_53 + uint(v_52))); + int v_55 = tint_f32_to_i32(arr2_vec3_f32[0u].x); + uint v_56 = uint(v_54); + uint v_57 = uint(int((v_56 + uint(v_55)))); + uint v_58 = uint(int((v_57 + uint(struct_inner.scalar_i32)))); + v_1.inner = int((v_58 + uint(array_struct_inner[0u].scalar_i32))); }
diff --git a/test/tint/buffer/uniform/static_index/read.wgsl.expected.spvasm b/test/tint/buffer/uniform/static_index/read.wgsl.expected.spvasm index d26c0eb..3bb46cf 100644 --- a/test/tint/buffer/uniform/static_index/read.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/static_index/read.wgsl.expected.spvasm
@@ -1,10 +1,10 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 294 +; Bound: 363 ; Schema: 0 OpCapability Shader - %243 = OpExtInstImport "GLSL.std.450" + %312 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %main "main" OpExecutionMode %main LocalSize 1 1 1 @@ -229,19 +229,19 @@ %uint_35 = OpConstant %uint 35 %_arr_Inner_uint_4_0 = OpTypeArray %Inner %uint_4 %_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int - %240 = OpTypeFunction %int %float + %309 = OpTypeFunction %int %float %float_n2_14748365e_09 = OpConstant %float -2.14748365e+09 %float_2_14748352e_09 = OpConstant %float 2.14748352e+09 - %248 = OpTypeFunction %_arr_v3float_uint_2_0 %_arr_v3float_uint_2 + %317 = OpTypeFunction %_arr_v3float_uint_2_0 %_arr_v3float_uint_2 %_ptr_Function__arr_v3float_uint_2 = OpTypePointer Function %_arr_v3float_uint_2 %_ptr_Function__arr_v3float_uint_2_0 = OpTypePointer Function %_arr_v3float_uint_2_0 - %254 = OpConstantNull %_arr_v3float_uint_2_0 + %323 = OpConstantNull %_arr_v3float_uint_2_0 %bool = OpTypeBool %_ptr_Function_v3float = OpTypePointer Function %v3float - %272 = OpTypeFunction %_arr_Inner_uint_4_0 %_arr_Inner_uint_4 + %341 = OpTypeFunction %_arr_Inner_uint_4_0 %_arr_Inner_uint_4 %_ptr_Function__arr_Inner_uint_4 = OpTypePointer Function %_arr_Inner_uint_4 %_ptr_Function__arr_Inner_uint_4_0 = OpTypePointer Function %_arr_Inner_uint_4_0 - %278 = OpConstantNull %_arr_Inner_uint_4_0 + %347 = OpConstantNull %_arr_Inner_uint_4_0 %_ptr_Function_Inner = OpTypePointer Function %Inner %main = OpFunction %void None %30 %31 = OpLabel @@ -326,139 +326,208 @@ %170 = OpLoad %_arr_Inner_uint_4 %167 None %array_struct_inner = OpFunctionCall %_arr_Inner_uint_4_0 %tint_convert_explicit_layout_0 %170 %174 = OpFunctionCall %int %tint_f32_to_i32 %scalar_f32 - %176 = OpIAdd %int %174 %scalar_i32 - %177 = OpBitcast %int %scalar_u32 - %178 = OpIAdd %int %176 %177 - %179 = OpCompositeExtract %float %vec2_f32 0 - %180 = OpFunctionCall %int %tint_f32_to_i32 %179 - %181 = OpIAdd %int %178 %180 - %182 = OpCompositeExtract %int %vec2_i32 0 - %183 = OpIAdd %int %181 %182 - %184 = OpCompositeExtract %uint %vec2_u32 0 - %185 = OpBitcast %int %184 - %186 = OpIAdd %int %183 %185 - %187 = OpCompositeExtract %float %vec3_f32 1 - %188 = OpFunctionCall %int %tint_f32_to_i32 %187 - %189 = OpIAdd %int %186 %188 - %190 = OpCompositeExtract %int %vec3_i32 1 - %191 = OpIAdd %int %189 %190 - %192 = OpCompositeExtract %uint %vec3_u32 1 - %193 = OpBitcast %int %192 - %194 = OpIAdd %int %191 %193 - %195 = OpCompositeExtract %float %vec4_f32 2 - %196 = OpFunctionCall %int %tint_f32_to_i32 %195 - %197 = OpIAdd %int %194 %196 - %198 = OpCompositeExtract %int %vec4_i32 2 - %199 = OpIAdd %int %197 %198 - %200 = OpCompositeExtract %uint %vec4_u32 2 + %176 = OpBitcast %uint %174 + %177 = OpBitcast %uint %scalar_i32 + %178 = OpIAdd %uint %176 %177 + %179 = OpBitcast %int %178 + %180 = OpBitcast %int %scalar_u32 + %181 = OpBitcast %uint %179 + %182 = OpBitcast %uint %180 + %183 = OpIAdd %uint %181 %182 + %184 = OpBitcast %int %183 + %185 = OpCompositeExtract %float %vec2_f32 0 + %186 = OpFunctionCall %int %tint_f32_to_i32 %185 + %187 = OpBitcast %uint %184 + %188 = OpBitcast %uint %186 + %189 = OpIAdd %uint %187 %188 + %190 = OpBitcast %int %189 + %191 = OpCompositeExtract %int %vec2_i32 0 + %192 = OpBitcast %uint %190 + %193 = OpBitcast %uint %191 + %194 = OpIAdd %uint %192 %193 + %195 = OpBitcast %int %194 + %196 = OpCompositeExtract %uint %vec2_u32 0 + %197 = OpBitcast %int %196 + %198 = OpBitcast %uint %195 + %199 = OpBitcast %uint %197 + %200 = OpIAdd %uint %198 %199 %201 = OpBitcast %int %200 - %202 = OpIAdd %int %199 %201 - %203 = OpCompositeExtract %float %mat2x2_f32 0 0 - %204 = OpFunctionCall %int %tint_f32_to_i32 %203 - %205 = OpIAdd %int %202 %204 - %206 = OpCompositeExtract %float %mat2x3_f32 0 0 - %207 = OpFunctionCall %int %tint_f32_to_i32 %206 - %208 = OpIAdd %int %205 %207 - %209 = OpCompositeExtract %float %mat2x4_f32 0 0 - %210 = OpFunctionCall %int %tint_f32_to_i32 %209 - %211 = OpIAdd %int %208 %210 - %212 = OpCompositeExtract %float %mat3x2_f32 0 0 - %213 = OpFunctionCall %int %tint_f32_to_i32 %212 - %214 = OpIAdd %int %211 %213 - %215 = OpCompositeExtract %float %mat3x3_f32 0 0 - %216 = OpFunctionCall %int %tint_f32_to_i32 %215 - %217 = OpIAdd %int %214 %216 - %218 = OpCompositeExtract %float %mat3x4_f32 0 0 - %219 = OpFunctionCall %int %tint_f32_to_i32 %218 - %220 = OpIAdd %int %217 %219 - %221 = OpCompositeExtract %float %mat4x2_f32 0 0 - %222 = OpFunctionCall %int %tint_f32_to_i32 %221 - %223 = OpIAdd %int %220 %222 - %224 = OpCompositeExtract %float %mat4x3_f32 0 0 - %225 = OpFunctionCall %int %tint_f32_to_i32 %224 - %226 = OpIAdd %int %223 %225 - %227 = OpCompositeExtract %float %mat4x4_f32 0 0 - %228 = OpFunctionCall %int %tint_f32_to_i32 %227 - %229 = OpIAdd %int %226 %228 - %230 = OpCompositeExtract %float %arr2_vec3_f32 0 0 - %231 = OpFunctionCall %int %tint_f32_to_i32 %230 - %232 = OpIAdd %int %229 %231 - %233 = OpCompositeExtract %int %struct_inner 0 - %234 = OpIAdd %int %232 %233 - %235 = OpCompositeExtract %int %array_struct_inner 0 0 - %236 = OpIAdd %int %234 %235 - %237 = OpAccessChain %_ptr_StorageBuffer_int %25 %uint_0 - OpStore %237 %236 None + %202 = OpCompositeExtract %float %vec3_f32 1 + %203 = OpFunctionCall %int %tint_f32_to_i32 %202 + %204 = OpBitcast %uint %201 + %205 = OpBitcast %uint %203 + %206 = OpIAdd %uint %204 %205 + %207 = OpBitcast %int %206 + %208 = OpCompositeExtract %int %vec3_i32 1 + %209 = OpBitcast %uint %207 + %210 = OpBitcast %uint %208 + %211 = OpIAdd %uint %209 %210 + %212 = OpBitcast %int %211 + %213 = OpCompositeExtract %uint %vec3_u32 1 + %214 = OpBitcast %int %213 + %215 = OpBitcast %uint %212 + %216 = OpBitcast %uint %214 + %217 = OpIAdd %uint %215 %216 + %218 = OpBitcast %int %217 + %219 = OpCompositeExtract %float %vec4_f32 2 + %220 = OpFunctionCall %int %tint_f32_to_i32 %219 + %221 = OpBitcast %uint %218 + %222 = OpBitcast %uint %220 + %223 = OpIAdd %uint %221 %222 + %224 = OpBitcast %int %223 + %225 = OpCompositeExtract %int %vec4_i32 2 + %226 = OpBitcast %uint %224 + %227 = OpBitcast %uint %225 + %228 = OpIAdd %uint %226 %227 + %229 = OpBitcast %int %228 + %230 = OpCompositeExtract %uint %vec4_u32 2 + %231 = OpBitcast %int %230 + %232 = OpBitcast %uint %229 + %233 = OpBitcast %uint %231 + %234 = OpIAdd %uint %232 %233 + %235 = OpBitcast %int %234 + %236 = OpCompositeExtract %float %mat2x2_f32 0 0 + %237 = OpFunctionCall %int %tint_f32_to_i32 %236 + %238 = OpBitcast %uint %235 + %239 = OpBitcast %uint %237 + %240 = OpIAdd %uint %238 %239 + %241 = OpBitcast %int %240 + %242 = OpCompositeExtract %float %mat2x3_f32 0 0 + %243 = OpFunctionCall %int %tint_f32_to_i32 %242 + %244 = OpBitcast %uint %241 + %245 = OpBitcast %uint %243 + %246 = OpIAdd %uint %244 %245 + %247 = OpBitcast %int %246 + %248 = OpCompositeExtract %float %mat2x4_f32 0 0 + %249 = OpFunctionCall %int %tint_f32_to_i32 %248 + %250 = OpBitcast %uint %247 + %251 = OpBitcast %uint %249 + %252 = OpIAdd %uint %250 %251 + %253 = OpBitcast %int %252 + %254 = OpCompositeExtract %float %mat3x2_f32 0 0 + %255 = OpFunctionCall %int %tint_f32_to_i32 %254 + %256 = OpBitcast %uint %253 + %257 = OpBitcast %uint %255 + %258 = OpIAdd %uint %256 %257 + %259 = OpBitcast %int %258 + %260 = OpCompositeExtract %float %mat3x3_f32 0 0 + %261 = OpFunctionCall %int %tint_f32_to_i32 %260 + %262 = OpBitcast %uint %259 + %263 = OpBitcast %uint %261 + %264 = OpIAdd %uint %262 %263 + %265 = OpBitcast %int %264 + %266 = OpCompositeExtract %float %mat3x4_f32 0 0 + %267 = OpFunctionCall %int %tint_f32_to_i32 %266 + %268 = OpBitcast %uint %265 + %269 = OpBitcast %uint %267 + %270 = OpIAdd %uint %268 %269 + %271 = OpBitcast %int %270 + %272 = OpCompositeExtract %float %mat4x2_f32 0 0 + %273 = OpFunctionCall %int %tint_f32_to_i32 %272 + %274 = OpBitcast %uint %271 + %275 = OpBitcast %uint %273 + %276 = OpIAdd %uint %274 %275 + %277 = OpBitcast %int %276 + %278 = OpCompositeExtract %float %mat4x3_f32 0 0 + %279 = OpFunctionCall %int %tint_f32_to_i32 %278 + %280 = OpBitcast %uint %277 + %281 = OpBitcast %uint %279 + %282 = OpIAdd %uint %280 %281 + %283 = OpBitcast %int %282 + %284 = OpCompositeExtract %float %mat4x4_f32 0 0 + %285 = OpFunctionCall %int %tint_f32_to_i32 %284 + %286 = OpBitcast %uint %283 + %287 = OpBitcast %uint %285 + %288 = OpIAdd %uint %286 %287 + %289 = OpBitcast %int %288 + %290 = OpCompositeExtract %float %arr2_vec3_f32 0 0 + %291 = OpFunctionCall %int %tint_f32_to_i32 %290 + %292 = OpBitcast %uint %289 + %293 = OpBitcast %uint %291 + %294 = OpIAdd %uint %292 %293 + %295 = OpBitcast %int %294 + %296 = OpCompositeExtract %int %struct_inner 0 + %297 = OpBitcast %uint %295 + %298 = OpBitcast %uint %296 + %299 = OpIAdd %uint %297 %298 + %300 = OpBitcast %int %299 + %301 = OpCompositeExtract %int %array_struct_inner 0 0 + %302 = OpBitcast %uint %300 + %303 = OpBitcast %uint %301 + %304 = OpIAdd %uint %302 %303 + %305 = OpBitcast %int %304 + %306 = OpAccessChain %_ptr_StorageBuffer_int %25 %uint_0 + OpStore %306 %305 None OpReturn OpFunctionEnd -%tint_f32_to_i32 = OpFunction %int None %240 +%tint_f32_to_i32 = OpFunction %int None %309 %value = OpFunctionParameter %float - %241 = OpLabel - %242 = OpExtInst %float %243 NClamp %value %float_n2_14748365e_09 %float_2_14748352e_09 - %246 = OpConvertFToS %int %242 - OpReturnValue %246 + %310 = OpLabel + %311 = OpExtInst %float %312 NClamp %value %float_n2_14748365e_09 %float_2_14748352e_09 + %315 = OpConvertFToS %int %311 + OpReturnValue %315 OpFunctionEnd -%tint_convert_explicit_layout = OpFunction %_arr_v3float_uint_2_0 None %248 +%tint_convert_explicit_layout = OpFunction %_arr_v3float_uint_2_0 None %317 %tint_source = OpFunctionParameter %_arr_v3float_uint_2 - %249 = OpLabel - %250 = OpVariable %_ptr_Function__arr_v3float_uint_2 Function - %252 = OpVariable %_ptr_Function__arr_v3float_uint_2_0 Function %254 - OpStore %250 %tint_source - OpBranch %255 - %255 = OpLabel - OpBranch %258 - %258 = OpLabel - %260 = OpPhi %uint %uint_0 %255 %261 %257 - OpLoopMerge %259 %257 None - OpBranch %256 - %256 = OpLabel - %263 = OpUGreaterThanEqual %bool %260 %uint_2 - OpSelectionMerge %265 None - OpBranchConditional %263 %266 %265 - %266 = OpLabel - OpBranch %259 - %265 = OpLabel - %267 = OpAccessChain %_ptr_Function_v3float %250 %260 - %269 = OpLoad %v3float %267 None - %270 = OpAccessChain %_ptr_Function_v3float %252 %260 - OpStore %270 %269 None - OpBranch %257 - %257 = OpLabel - %261 = OpIAdd %uint %260 %uint_1 - OpBranch %258 - %259 = OpLabel - %262 = OpLoad %_arr_v3float_uint_2_0 %252 None - OpReturnValue %262 + %318 = OpLabel + %319 = OpVariable %_ptr_Function__arr_v3float_uint_2 Function + %321 = OpVariable %_ptr_Function__arr_v3float_uint_2_0 Function %323 + OpStore %319 %tint_source + OpBranch %324 + %324 = OpLabel + OpBranch %327 + %327 = OpLabel + %329 = OpPhi %uint %uint_0 %324 %330 %326 + OpLoopMerge %328 %326 None + OpBranch %325 + %325 = OpLabel + %332 = OpUGreaterThanEqual %bool %329 %uint_2 + OpSelectionMerge %334 None + OpBranchConditional %332 %335 %334 + %335 = OpLabel + OpBranch %328 + %334 = OpLabel + %336 = OpAccessChain %_ptr_Function_v3float %319 %329 + %338 = OpLoad %v3float %336 None + %339 = OpAccessChain %_ptr_Function_v3float %321 %329 + OpStore %339 %338 None + OpBranch %326 + %326 = OpLabel + %330 = OpIAdd %uint %329 %uint_1 + OpBranch %327 + %328 = OpLabel + %331 = OpLoad %_arr_v3float_uint_2_0 %321 None + OpReturnValue %331 OpFunctionEnd -%tint_convert_explicit_layout_0 = OpFunction %_arr_Inner_uint_4_0 None %272 +%tint_convert_explicit_layout_0 = OpFunction %_arr_Inner_uint_4_0 None %341 %tint_source_0 = OpFunctionParameter %_arr_Inner_uint_4 - %273 = OpLabel - %274 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function - %276 = OpVariable %_ptr_Function__arr_Inner_uint_4_0 Function %278 - OpStore %274 %tint_source_0 - OpBranch %279 - %279 = OpLabel - OpBranch %282 - %282 = OpLabel - %284 = OpPhi %uint %uint_0 %279 %285 %281 - OpLoopMerge %283 %281 None - OpBranch %280 - %280 = OpLabel - %287 = OpUGreaterThanEqual %bool %284 %uint_4 - OpSelectionMerge %288 None - OpBranchConditional %287 %289 %288 - %289 = OpLabel - OpBranch %283 - %288 = OpLabel - %290 = OpAccessChain %_ptr_Function_Inner %274 %284 - %292 = OpLoad %Inner %290 None - %293 = OpAccessChain %_ptr_Function_Inner %276 %284 - OpStore %293 %292 None - OpBranch %281 - %281 = OpLabel - %285 = OpIAdd %uint %284 %uint_1 - OpBranch %282 - %283 = OpLabel - %286 = OpLoad %_arr_Inner_uint_4_0 %276 None - OpReturnValue %286 + %342 = OpLabel + %343 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function + %345 = OpVariable %_ptr_Function__arr_Inner_uint_4_0 Function %347 + OpStore %343 %tint_source_0 + OpBranch %348 + %348 = OpLabel + OpBranch %351 + %351 = OpLabel + %353 = OpPhi %uint %uint_0 %348 %354 %350 + OpLoopMerge %352 %350 None + OpBranch %349 + %349 = OpLabel + %356 = OpUGreaterThanEqual %bool %353 %uint_4 + OpSelectionMerge %357 None + OpBranchConditional %356 %358 %357 + %358 = OpLabel + OpBranch %352 + %357 = OpLabel + %359 = OpAccessChain %_ptr_Function_Inner %343 %353 + %361 = OpLoad %Inner %359 None + %362 = OpAccessChain %_ptr_Function_Inner %345 %353 + OpStore %362 %361 None + OpBranch %350 + %350 = OpLabel + %354 = OpIAdd %uint %353 %uint_1 + OpBranch %351 + %352 = OpLabel + %355 = OpLoad %_arr_Inner_uint_4_0 %345 None + OpReturnValue %355 OpFunctionEnd
diff --git a/test/tint/buffer/uniform/static_index/read_f16.wgsl.expected.glsl b/test/tint/buffer/uniform/static_index/read_f16.wgsl.expected.glsl index b794383..b6a229d 100644 --- a/test/tint/buffer/uniform/static_index/read_f16.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/static_index/read_f16.wgsl.expected.glsl
@@ -180,36 +180,104 @@ f16mat4x2 arr2_mat4x2_f16[2] = v_3; Inner struct_inner = v.inner.struct_inner; Inner array_struct_inner[4] = v.inner.array_struct_inner; - int v_6 = (tint_f32_to_i32(scalar_f32) + scalar_i32); - int v_7 = (v_6 + int(scalar_u32)); - int v_8 = (v_7 + tint_f16_to_i32(scalar_f16)); - int v_9 = ((v_8 + tint_f32_to_i32(vec2_f32.x)) + vec2_i32.x); - int v_10 = (v_9 + int(vec2_u32.x)); - int v_11 = (v_10 + tint_f16_to_i32(vec2_f16.x)); - int v_12 = ((v_11 + tint_f32_to_i32(vec3_f32.y)) + vec3_i32.y); - int v_13 = (v_12 + int(vec3_u32.y)); - int v_14 = (v_13 + tint_f16_to_i32(vec3_f16.y)); - int v_15 = ((v_14 + tint_f32_to_i32(vec4_f32.z)) + vec4_i32.z); - int v_16 = (v_15 + int(vec4_u32.z)); - int v_17 = (v_16 + tint_f16_to_i32(vec4_f16.z)); - int v_18 = (v_17 + tint_f32_to_i32(mat2x2_f32[0u].x)); - int v_19 = (v_18 + tint_f32_to_i32(mat2x3_f32[0u].x)); - int v_20 = (v_19 + tint_f32_to_i32(mat2x4_f32[0u].x)); - int v_21 = (v_20 + tint_f32_to_i32(mat3x2_f32[0u].x)); - int v_22 = (v_21 + tint_f32_to_i32(mat3x3_f32[0u].x)); - int v_23 = (v_22 + tint_f32_to_i32(mat3x4_f32[0u].x)); - int v_24 = (v_23 + tint_f32_to_i32(mat4x2_f32[0u].x)); - int v_25 = (v_24 + tint_f32_to_i32(mat4x3_f32[0u].x)); - int v_26 = (v_25 + tint_f32_to_i32(mat4x4_f32[0u].x)); - int v_27 = (v_26 + tint_f16_to_i32(mat2x2_f16[0u].x)); - int v_28 = (v_27 + tint_f16_to_i32(mat2x3_f16[0u].x)); - int v_29 = (v_28 + tint_f16_to_i32(mat2x4_f16[0u].x)); - int v_30 = (v_29 + tint_f16_to_i32(mat3x2_f16[0u].x)); - int v_31 = (v_30 + tint_f16_to_i32(mat3x3_f16[0u].x)); - int v_32 = (v_31 + tint_f16_to_i32(mat3x4_f16[0u].x)); - int v_33 = (v_32 + tint_f16_to_i32(mat4x2_f16[0u].x)); - int v_34 = (v_33 + tint_f16_to_i32(mat4x3_f16[0u].x)); - int v_35 = (v_34 + tint_f16_to_i32(mat4x4_f16[0u].x)); - int v_36 = (v_35 + tint_f32_to_i32(arr2_vec3_f32[0u].x)); - v_1.inner = (((v_36 + tint_f16_to_i32(arr2_mat4x2_f16[0u][0u].x)) + struct_inner.scalar_i32) + array_struct_inner[0u].scalar_i32); + uint v_6 = uint(tint_f32_to_i32(scalar_f32)); + int v_7 = int((v_6 + uint(scalar_i32))); + int v_8 = int(scalar_u32); + uint v_9 = uint(v_7); + int v_10 = int((v_9 + uint(v_8))); + int v_11 = tint_f16_to_i32(scalar_f16); + uint v_12 = uint(v_10); + int v_13 = int((v_12 + uint(v_11))); + int v_14 = tint_f32_to_i32(vec2_f32.x); + uint v_15 = uint(v_13); + uint v_16 = uint(int((v_15 + uint(v_14)))); + int v_17 = int((v_16 + uint(vec2_i32.x))); + int v_18 = int(vec2_u32.x); + uint v_19 = uint(v_17); + int v_20 = int((v_19 + uint(v_18))); + int v_21 = tint_f16_to_i32(vec2_f16.x); + uint v_22 = uint(v_20); + int v_23 = int((v_22 + uint(v_21))); + int v_24 = tint_f32_to_i32(vec3_f32.y); + uint v_25 = uint(v_23); + uint v_26 = uint(int((v_25 + uint(v_24)))); + int v_27 = int((v_26 + uint(vec3_i32.y))); + int v_28 = int(vec3_u32.y); + uint v_29 = uint(v_27); + int v_30 = int((v_29 + uint(v_28))); + int v_31 = tint_f16_to_i32(vec3_f16.y); + uint v_32 = uint(v_30); + int v_33 = int((v_32 + uint(v_31))); + int v_34 = tint_f32_to_i32(vec4_f32.z); + uint v_35 = uint(v_33); + uint v_36 = uint(int((v_35 + uint(v_34)))); + int v_37 = int((v_36 + uint(vec4_i32.z))); + int v_38 = int(vec4_u32.z); + uint v_39 = uint(v_37); + int v_40 = int((v_39 + uint(v_38))); + int v_41 = tint_f16_to_i32(vec4_f16.z); + uint v_42 = uint(v_40); + int v_43 = int((v_42 + uint(v_41))); + int v_44 = tint_f32_to_i32(mat2x2_f32[0u].x); + uint v_45 = uint(v_43); + int v_46 = int((v_45 + uint(v_44))); + int v_47 = tint_f32_to_i32(mat2x3_f32[0u].x); + uint v_48 = uint(v_46); + int v_49 = int((v_48 + uint(v_47))); + int v_50 = tint_f32_to_i32(mat2x4_f32[0u].x); + uint v_51 = uint(v_49); + int v_52 = int((v_51 + uint(v_50))); + int v_53 = tint_f32_to_i32(mat3x2_f32[0u].x); + uint v_54 = uint(v_52); + int v_55 = int((v_54 + uint(v_53))); + int v_56 = tint_f32_to_i32(mat3x3_f32[0u].x); + uint v_57 = uint(v_55); + int v_58 = int((v_57 + uint(v_56))); + int v_59 = tint_f32_to_i32(mat3x4_f32[0u].x); + uint v_60 = uint(v_58); + int v_61 = int((v_60 + uint(v_59))); + int v_62 = tint_f32_to_i32(mat4x2_f32[0u].x); + uint v_63 = uint(v_61); + int v_64 = int((v_63 + uint(v_62))); + int v_65 = tint_f32_to_i32(mat4x3_f32[0u].x); + uint v_66 = uint(v_64); + int v_67 = int((v_66 + uint(v_65))); + int v_68 = tint_f32_to_i32(mat4x4_f32[0u].x); + uint v_69 = uint(v_67); + int v_70 = int((v_69 + uint(v_68))); + int v_71 = tint_f16_to_i32(mat2x2_f16[0u].x); + uint v_72 = uint(v_70); + int v_73 = int((v_72 + uint(v_71))); + int v_74 = tint_f16_to_i32(mat2x3_f16[0u].x); + uint v_75 = uint(v_73); + int v_76 = int((v_75 + uint(v_74))); + int v_77 = tint_f16_to_i32(mat2x4_f16[0u].x); + uint v_78 = uint(v_76); + int v_79 = int((v_78 + uint(v_77))); + int v_80 = tint_f16_to_i32(mat3x2_f16[0u].x); + uint v_81 = uint(v_79); + int v_82 = int((v_81 + uint(v_80))); + int v_83 = tint_f16_to_i32(mat3x3_f16[0u].x); + uint v_84 = uint(v_82); + int v_85 = int((v_84 + uint(v_83))); + int v_86 = tint_f16_to_i32(mat3x4_f16[0u].x); + uint v_87 = uint(v_85); + int v_88 = int((v_87 + uint(v_86))); + int v_89 = tint_f16_to_i32(mat4x2_f16[0u].x); + uint v_90 = uint(v_88); + int v_91 = int((v_90 + uint(v_89))); + int v_92 = tint_f16_to_i32(mat4x3_f16[0u].x); + uint v_93 = uint(v_91); + int v_94 = int((v_93 + uint(v_92))); + int v_95 = tint_f16_to_i32(mat4x4_f16[0u].x); + uint v_96 = uint(v_94); + int v_97 = int((v_96 + uint(v_95))); + int v_98 = tint_f32_to_i32(arr2_vec3_f32[0u].x); + uint v_99 = uint(v_97); + int v_100 = int((v_99 + uint(v_98))); + int v_101 = tint_f16_to_i32(arr2_mat4x2_f16[0u][0u].x); + uint v_102 = uint(v_100); + uint v_103 = uint(int((v_102 + uint(v_101)))); + uint v_104 = uint(int((v_103 + uint(struct_inner.scalar_i32)))); + v_1.inner = int((v_104 + uint(array_struct_inner[0u].scalar_i32))); }
diff --git a/test/tint/buffer/uniform/static_index/read_f16.wgsl.expected.spvasm b/test/tint/buffer/uniform/static_index/read_f16.wgsl.expected.spvasm index e34513b..8ec6478 100644 --- a/test/tint/buffer/uniform/static_index/read_f16.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/static_index/read_f16.wgsl.expected.spvasm
@@ -1,13 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 519 +; Bound: 630 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess - %441 = OpExtInstImport "GLSL.std.450" + %552 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %main "main" OpExecutionMode %main LocalSize 1 1 1 @@ -386,24 +386,24 @@ %bool = OpTypeBool %_ptr_Function_mat4v2half = OpTypePointer Function %mat4v2half %_ptr_Function_mat4x2_f16_std140 = OpTypePointer Function %mat4x2_f16_std140 - %438 = OpTypeFunction %int %float + %549 = OpTypeFunction %int %float %float_n2_14748365e_09 = OpConstant %float -2.14748365e+09 %float_2_14748352e_09 = OpConstant %float 2.14748352e+09 - %446 = OpTypeFunction %int %half + %557 = OpTypeFunction %int %half %half_n0x1_ffcp_15 = OpConstant %half -0x1.ffcp+15 %half_0x1_ffcp_15 = OpConstant %half 0x1.ffcp+15 - %453 = OpTypeFunction %_arr_v3float_uint_2_0 %_arr_v3float_uint_2 + %564 = OpTypeFunction %_arr_v3float_uint_2_0 %_arr_v3float_uint_2 %_ptr_Function__arr_v3float_uint_2 = OpTypePointer Function %_arr_v3float_uint_2 %_ptr_Function__arr_v3float_uint_2_0 = OpTypePointer Function %_arr_v3float_uint_2_0 - %459 = OpConstantNull %_arr_v3float_uint_2_0 + %570 = OpConstantNull %_arr_v3float_uint_2_0 %_ptr_Function_v3float = OpTypePointer Function %v3float - %476 = OpTypeFunction %_arr_mat4x2_f16_std140_uint_2_0 %_arr_mat4x2_f16_std140_uint_2 + %587 = OpTypeFunction %_arr_mat4x2_f16_std140_uint_2_0 %_arr_mat4x2_f16_std140_uint_2 %_ptr_Function__arr_mat4x2_f16_std140_uint_2 = OpTypePointer Function %_arr_mat4x2_f16_std140_uint_2 - %481 = OpConstantNull %_arr_mat4x2_f16_std140_uint_2_0 - %497 = OpTypeFunction %_arr_Inner_uint_4_0 %_arr_Inner_uint_4 + %592 = OpConstantNull %_arr_mat4x2_f16_std140_uint_2_0 + %608 = OpTypeFunction %_arr_Inner_uint_4_0 %_arr_Inner_uint_4 %_ptr_Function__arr_Inner_uint_4 = OpTypePointer Function %_arr_Inner_uint_4 %_ptr_Function__arr_Inner_uint_4_0 = OpTypePointer Function %_arr_Inner_uint_4_0 - %503 = OpConstantNull %_arr_Inner_uint_4_0 + %614 = OpConstantNull %_arr_Inner_uint_4_0 %_ptr_Function_Inner = OpTypePointer Function %Inner %main = OpFunction %void None %36 %37 = OpLabel @@ -567,21 +567,21 @@ OpLoopMerge %301 %299 None OpBranch %298 %298 = OpLabel - %423 = OpUGreaterThanEqual %bool %302 %uint_2 - OpSelectionMerge %425 None - OpBranchConditional %423 %426 %425 - %426 = OpLabel + %534 = OpUGreaterThanEqual %bool %302 %uint_2 + OpSelectionMerge %536 None + OpBranchConditional %534 %537 %536 + %537 = OpLabel OpBranch %301 - %425 = OpLabel - %427 = OpAccessChain %_ptr_Function_mat4v2half %293 %302 - %429 = OpAccessChain %_ptr_Function_mat4x2_f16_std140 %291 %302 - %431 = OpLoad %mat4x2_f16_std140 %429 None - %432 = OpCompositeExtract %v2half %431 0 - %433 = OpCompositeExtract %v2half %431 1 - %434 = OpCompositeExtract %v2half %431 2 - %435 = OpCompositeExtract %v2half %431 3 - %436 = OpCompositeConstruct %mat4v2half %432 %433 %434 %435 - OpStore %427 %436 None + %536 = OpLabel + %538 = OpAccessChain %_ptr_Function_mat4v2half %293 %302 + %540 = OpAccessChain %_ptr_Function_mat4x2_f16_std140 %291 %302 + %542 = OpLoad %mat4x2_f16_std140 %540 None + %543 = OpCompositeExtract %v2half %542 0 + %544 = OpCompositeExtract %v2half %542 1 + %545 = OpCompositeExtract %v2half %542 2 + %546 = OpCompositeExtract %v2half %542 3 + %547 = OpCompositeConstruct %mat4v2half %543 %544 %545 %546 + OpStore %538 %547 None OpBranch %299 %299 = OpLabel %303 = OpIAdd %uint %302 %uint_1 @@ -594,219 +594,330 @@ %312 = OpLoad %_arr_Inner_uint_4 %309 None %array_struct_inner = OpFunctionCall %_arr_Inner_uint_4_0 %tint_convert_explicit_layout_1 %312 %316 = OpFunctionCall %int %tint_f32_to_i32 %scalar_f32 - %318 = OpIAdd %int %316 %scalar_i32 - %319 = OpBitcast %int %scalar_u32 - %320 = OpIAdd %int %318 %319 - %321 = OpFunctionCall %int %tint_f16_to_i32 %scalar_f16 - %323 = OpIAdd %int %320 %321 - %324 = OpCompositeExtract %float %vec2_f32 0 - %325 = OpFunctionCall %int %tint_f32_to_i32 %324 - %326 = OpIAdd %int %323 %325 - %327 = OpCompositeExtract %int %vec2_i32 0 - %328 = OpIAdd %int %326 %327 - %329 = OpCompositeExtract %uint %vec2_u32 0 - %330 = OpBitcast %int %329 - %331 = OpIAdd %int %328 %330 - %332 = OpCompositeExtract %half %vec2_f16 0 - %333 = OpFunctionCall %int %tint_f16_to_i32 %332 - %334 = OpIAdd %int %331 %333 - %335 = OpCompositeExtract %float %vec3_f32 1 - %336 = OpFunctionCall %int %tint_f32_to_i32 %335 - %337 = OpIAdd %int %334 %336 - %338 = OpCompositeExtract %int %vec3_i32 1 - %339 = OpIAdd %int %337 %338 - %340 = OpCompositeExtract %uint %vec3_u32 1 - %341 = OpBitcast %int %340 - %342 = OpIAdd %int %339 %341 - %343 = OpCompositeExtract %half %vec3_f16 1 - %344 = OpFunctionCall %int %tint_f16_to_i32 %343 - %345 = OpIAdd %int %342 %344 - %346 = OpCompositeExtract %float %vec4_f32 2 - %347 = OpFunctionCall %int %tint_f32_to_i32 %346 - %348 = OpIAdd %int %345 %347 - %349 = OpCompositeExtract %int %vec4_i32 2 - %350 = OpIAdd %int %348 %349 - %351 = OpCompositeExtract %uint %vec4_u32 2 - %352 = OpBitcast %int %351 - %353 = OpIAdd %int %350 %352 - %354 = OpCompositeExtract %half %vec4_f16 2 - %355 = OpFunctionCall %int %tint_f16_to_i32 %354 - %356 = OpIAdd %int %353 %355 - %357 = OpCompositeExtract %float %mat2x2_f32 0 0 - %358 = OpFunctionCall %int %tint_f32_to_i32 %357 - %359 = OpIAdd %int %356 %358 - %360 = OpCompositeExtract %float %mat2x3_f32 0 0 - %361 = OpFunctionCall %int %tint_f32_to_i32 %360 - %362 = OpIAdd %int %359 %361 - %363 = OpCompositeExtract %float %mat2x4_f32 0 0 - %364 = OpFunctionCall %int %tint_f32_to_i32 %363 - %365 = OpIAdd %int %362 %364 - %366 = OpCompositeExtract %float %mat3x2_f32 0 0 - %367 = OpFunctionCall %int %tint_f32_to_i32 %366 - %368 = OpIAdd %int %365 %367 - %369 = OpCompositeExtract %float %mat3x3_f32 0 0 - %370 = OpFunctionCall %int %tint_f32_to_i32 %369 - %371 = OpIAdd %int %368 %370 - %372 = OpCompositeExtract %float %mat3x4_f32 0 0 - %373 = OpFunctionCall %int %tint_f32_to_i32 %372 - %374 = OpIAdd %int %371 %373 - %375 = OpCompositeExtract %float %mat4x2_f32 0 0 - %376 = OpFunctionCall %int %tint_f32_to_i32 %375 - %377 = OpIAdd %int %374 %376 - %378 = OpCompositeExtract %float %mat4x3_f32 0 0 - %379 = OpFunctionCall %int %tint_f32_to_i32 %378 - %380 = OpIAdd %int %377 %379 - %381 = OpCompositeExtract %float %mat4x4_f32 0 0 - %382 = OpFunctionCall %int %tint_f32_to_i32 %381 - %383 = OpIAdd %int %380 %382 - %384 = OpCompositeExtract %half %mat2x2_f16 0 0 - %385 = OpFunctionCall %int %tint_f16_to_i32 %384 - %386 = OpIAdd %int %383 %385 - %387 = OpCompositeExtract %half %mat2x3_f16 0 0 - %388 = OpFunctionCall %int %tint_f16_to_i32 %387 - %389 = OpIAdd %int %386 %388 - %390 = OpCompositeExtract %half %mat2x4_f16 0 0 - %391 = OpFunctionCall %int %tint_f16_to_i32 %390 - %392 = OpIAdd %int %389 %391 - %393 = OpCompositeExtract %half %mat3x2_f16 0 0 - %394 = OpFunctionCall %int %tint_f16_to_i32 %393 - %395 = OpIAdd %int %392 %394 - %396 = OpCompositeExtract %half %mat3x3_f16 0 0 + %318 = OpBitcast %uint %316 + %319 = OpBitcast %uint %scalar_i32 + %320 = OpIAdd %uint %318 %319 + %321 = OpBitcast %int %320 + %322 = OpBitcast %int %scalar_u32 + %323 = OpBitcast %uint %321 + %324 = OpBitcast %uint %322 + %325 = OpIAdd %uint %323 %324 + %326 = OpBitcast %int %325 + %327 = OpFunctionCall %int %tint_f16_to_i32 %scalar_f16 + %329 = OpBitcast %uint %326 + %330 = OpBitcast %uint %327 + %331 = OpIAdd %uint %329 %330 + %332 = OpBitcast %int %331 + %333 = OpCompositeExtract %float %vec2_f32 0 + %334 = OpFunctionCall %int %tint_f32_to_i32 %333 + %335 = OpBitcast %uint %332 + %336 = OpBitcast %uint %334 + %337 = OpIAdd %uint %335 %336 + %338 = OpBitcast %int %337 + %339 = OpCompositeExtract %int %vec2_i32 0 + %340 = OpBitcast %uint %338 + %341 = OpBitcast %uint %339 + %342 = OpIAdd %uint %340 %341 + %343 = OpBitcast %int %342 + %344 = OpCompositeExtract %uint %vec2_u32 0 + %345 = OpBitcast %int %344 + %346 = OpBitcast %uint %343 + %347 = OpBitcast %uint %345 + %348 = OpIAdd %uint %346 %347 + %349 = OpBitcast %int %348 + %350 = OpCompositeExtract %half %vec2_f16 0 + %351 = OpFunctionCall %int %tint_f16_to_i32 %350 + %352 = OpBitcast %uint %349 + %353 = OpBitcast %uint %351 + %354 = OpIAdd %uint %352 %353 + %355 = OpBitcast %int %354 + %356 = OpCompositeExtract %float %vec3_f32 1 + %357 = OpFunctionCall %int %tint_f32_to_i32 %356 + %358 = OpBitcast %uint %355 + %359 = OpBitcast %uint %357 + %360 = OpIAdd %uint %358 %359 + %361 = OpBitcast %int %360 + %362 = OpCompositeExtract %int %vec3_i32 1 + %363 = OpBitcast %uint %361 + %364 = OpBitcast %uint %362 + %365 = OpIAdd %uint %363 %364 + %366 = OpBitcast %int %365 + %367 = OpCompositeExtract %uint %vec3_u32 1 + %368 = OpBitcast %int %367 + %369 = OpBitcast %uint %366 + %370 = OpBitcast %uint %368 + %371 = OpIAdd %uint %369 %370 + %372 = OpBitcast %int %371 + %373 = OpCompositeExtract %half %vec3_f16 1 + %374 = OpFunctionCall %int %tint_f16_to_i32 %373 + %375 = OpBitcast %uint %372 + %376 = OpBitcast %uint %374 + %377 = OpIAdd %uint %375 %376 + %378 = OpBitcast %int %377 + %379 = OpCompositeExtract %float %vec4_f32 2 + %380 = OpFunctionCall %int %tint_f32_to_i32 %379 + %381 = OpBitcast %uint %378 + %382 = OpBitcast %uint %380 + %383 = OpIAdd %uint %381 %382 + %384 = OpBitcast %int %383 + %385 = OpCompositeExtract %int %vec4_i32 2 + %386 = OpBitcast %uint %384 + %387 = OpBitcast %uint %385 + %388 = OpIAdd %uint %386 %387 + %389 = OpBitcast %int %388 + %390 = OpCompositeExtract %uint %vec4_u32 2 + %391 = OpBitcast %int %390 + %392 = OpBitcast %uint %389 + %393 = OpBitcast %uint %391 + %394 = OpIAdd %uint %392 %393 + %395 = OpBitcast %int %394 + %396 = OpCompositeExtract %half %vec4_f16 2 %397 = OpFunctionCall %int %tint_f16_to_i32 %396 - %398 = OpIAdd %int %395 %397 - %399 = OpCompositeExtract %half %mat3x4_f16 0 0 - %400 = OpFunctionCall %int %tint_f16_to_i32 %399 - %401 = OpIAdd %int %398 %400 - %402 = OpCompositeExtract %half %mat4x2_f16 0 0 - %403 = OpFunctionCall %int %tint_f16_to_i32 %402 - %404 = OpIAdd %int %401 %403 - %405 = OpCompositeExtract %half %mat4x3_f16 0 0 - %406 = OpFunctionCall %int %tint_f16_to_i32 %405 - %407 = OpIAdd %int %404 %406 - %408 = OpCompositeExtract %half %mat4x4_f16 0 0 - %409 = OpFunctionCall %int %tint_f16_to_i32 %408 - %410 = OpIAdd %int %407 %409 - %411 = OpCompositeExtract %float %arr2_vec3_f32 0 0 - %412 = OpFunctionCall %int %tint_f32_to_i32 %411 - %413 = OpIAdd %int %410 %412 - %414 = OpCompositeExtract %half %arr2_mat4x2_f16 0 0 0 - %415 = OpFunctionCall %int %tint_f16_to_i32 %414 - %416 = OpIAdd %int %413 %415 - %417 = OpCompositeExtract %int %struct_inner 0 - %418 = OpIAdd %int %416 %417 - %419 = OpCompositeExtract %int %array_struct_inner 0 0 - %420 = OpIAdd %int %418 %419 - %421 = OpAccessChain %_ptr_StorageBuffer_int %31 %uint_0 - OpStore %421 %420 None + %398 = OpBitcast %uint %395 + %399 = OpBitcast %uint %397 + %400 = OpIAdd %uint %398 %399 + %401 = OpBitcast %int %400 + %402 = OpCompositeExtract %float %mat2x2_f32 0 0 + %403 = OpFunctionCall %int %tint_f32_to_i32 %402 + %404 = OpBitcast %uint %401 + %405 = OpBitcast %uint %403 + %406 = OpIAdd %uint %404 %405 + %407 = OpBitcast %int %406 + %408 = OpCompositeExtract %float %mat2x3_f32 0 0 + %409 = OpFunctionCall %int %tint_f32_to_i32 %408 + %410 = OpBitcast %uint %407 + %411 = OpBitcast %uint %409 + %412 = OpIAdd %uint %410 %411 + %413 = OpBitcast %int %412 + %414 = OpCompositeExtract %float %mat2x4_f32 0 0 + %415 = OpFunctionCall %int %tint_f32_to_i32 %414 + %416 = OpBitcast %uint %413 + %417 = OpBitcast %uint %415 + %418 = OpIAdd %uint %416 %417 + %419 = OpBitcast %int %418 + %420 = OpCompositeExtract %float %mat3x2_f32 0 0 + %421 = OpFunctionCall %int %tint_f32_to_i32 %420 + %422 = OpBitcast %uint %419 + %423 = OpBitcast %uint %421 + %424 = OpIAdd %uint %422 %423 + %425 = OpBitcast %int %424 + %426 = OpCompositeExtract %float %mat3x3_f32 0 0 + %427 = OpFunctionCall %int %tint_f32_to_i32 %426 + %428 = OpBitcast %uint %425 + %429 = OpBitcast %uint %427 + %430 = OpIAdd %uint %428 %429 + %431 = OpBitcast %int %430 + %432 = OpCompositeExtract %float %mat3x4_f32 0 0 + %433 = OpFunctionCall %int %tint_f32_to_i32 %432 + %434 = OpBitcast %uint %431 + %435 = OpBitcast %uint %433 + %436 = OpIAdd %uint %434 %435 + %437 = OpBitcast %int %436 + %438 = OpCompositeExtract %float %mat4x2_f32 0 0 + %439 = OpFunctionCall %int %tint_f32_to_i32 %438 + %440 = OpBitcast %uint %437 + %441 = OpBitcast %uint %439 + %442 = OpIAdd %uint %440 %441 + %443 = OpBitcast %int %442 + %444 = OpCompositeExtract %float %mat4x3_f32 0 0 + %445 = OpFunctionCall %int %tint_f32_to_i32 %444 + %446 = OpBitcast %uint %443 + %447 = OpBitcast %uint %445 + %448 = OpIAdd %uint %446 %447 + %449 = OpBitcast %int %448 + %450 = OpCompositeExtract %float %mat4x4_f32 0 0 + %451 = OpFunctionCall %int %tint_f32_to_i32 %450 + %452 = OpBitcast %uint %449 + %453 = OpBitcast %uint %451 + %454 = OpIAdd %uint %452 %453 + %455 = OpBitcast %int %454 + %456 = OpCompositeExtract %half %mat2x2_f16 0 0 + %457 = OpFunctionCall %int %tint_f16_to_i32 %456 + %458 = OpBitcast %uint %455 + %459 = OpBitcast %uint %457 + %460 = OpIAdd %uint %458 %459 + %461 = OpBitcast %int %460 + %462 = OpCompositeExtract %half %mat2x3_f16 0 0 + %463 = OpFunctionCall %int %tint_f16_to_i32 %462 + %464 = OpBitcast %uint %461 + %465 = OpBitcast %uint %463 + %466 = OpIAdd %uint %464 %465 + %467 = OpBitcast %int %466 + %468 = OpCompositeExtract %half %mat2x4_f16 0 0 + %469 = OpFunctionCall %int %tint_f16_to_i32 %468 + %470 = OpBitcast %uint %467 + %471 = OpBitcast %uint %469 + %472 = OpIAdd %uint %470 %471 + %473 = OpBitcast %int %472 + %474 = OpCompositeExtract %half %mat3x2_f16 0 0 + %475 = OpFunctionCall %int %tint_f16_to_i32 %474 + %476 = OpBitcast %uint %473 + %477 = OpBitcast %uint %475 + %478 = OpIAdd %uint %476 %477 + %479 = OpBitcast %int %478 + %480 = OpCompositeExtract %half %mat3x3_f16 0 0 + %481 = OpFunctionCall %int %tint_f16_to_i32 %480 + %482 = OpBitcast %uint %479 + %483 = OpBitcast %uint %481 + %484 = OpIAdd %uint %482 %483 + %485 = OpBitcast %int %484 + %486 = OpCompositeExtract %half %mat3x4_f16 0 0 + %487 = OpFunctionCall %int %tint_f16_to_i32 %486 + %488 = OpBitcast %uint %485 + %489 = OpBitcast %uint %487 + %490 = OpIAdd %uint %488 %489 + %491 = OpBitcast %int %490 + %492 = OpCompositeExtract %half %mat4x2_f16 0 0 + %493 = OpFunctionCall %int %tint_f16_to_i32 %492 + %494 = OpBitcast %uint %491 + %495 = OpBitcast %uint %493 + %496 = OpIAdd %uint %494 %495 + %497 = OpBitcast %int %496 + %498 = OpCompositeExtract %half %mat4x3_f16 0 0 + %499 = OpFunctionCall %int %tint_f16_to_i32 %498 + %500 = OpBitcast %uint %497 + %501 = OpBitcast %uint %499 + %502 = OpIAdd %uint %500 %501 + %503 = OpBitcast %int %502 + %504 = OpCompositeExtract %half %mat4x4_f16 0 0 + %505 = OpFunctionCall %int %tint_f16_to_i32 %504 + %506 = OpBitcast %uint %503 + %507 = OpBitcast %uint %505 + %508 = OpIAdd %uint %506 %507 + %509 = OpBitcast %int %508 + %510 = OpCompositeExtract %float %arr2_vec3_f32 0 0 + %511 = OpFunctionCall %int %tint_f32_to_i32 %510 + %512 = OpBitcast %uint %509 + %513 = OpBitcast %uint %511 + %514 = OpIAdd %uint %512 %513 + %515 = OpBitcast %int %514 + %516 = OpCompositeExtract %half %arr2_mat4x2_f16 0 0 0 + %517 = OpFunctionCall %int %tint_f16_to_i32 %516 + %518 = OpBitcast %uint %515 + %519 = OpBitcast %uint %517 + %520 = OpIAdd %uint %518 %519 + %521 = OpBitcast %int %520 + %522 = OpCompositeExtract %int %struct_inner 0 + %523 = OpBitcast %uint %521 + %524 = OpBitcast %uint %522 + %525 = OpIAdd %uint %523 %524 + %526 = OpBitcast %int %525 + %527 = OpCompositeExtract %int %array_struct_inner 0 0 + %528 = OpBitcast %uint %526 + %529 = OpBitcast %uint %527 + %530 = OpIAdd %uint %528 %529 + %531 = OpBitcast %int %530 + %532 = OpAccessChain %_ptr_StorageBuffer_int %31 %uint_0 + OpStore %532 %531 None OpReturn OpFunctionEnd -%tint_f32_to_i32 = OpFunction %int None %438 +%tint_f32_to_i32 = OpFunction %int None %549 %value = OpFunctionParameter %float - %439 = OpLabel - %440 = OpExtInst %float %441 NClamp %value %float_n2_14748365e_09 %float_2_14748352e_09 - %444 = OpConvertFToS %int %440 - OpReturnValue %444 + %550 = OpLabel + %551 = OpExtInst %float %552 NClamp %value %float_n2_14748365e_09 %float_2_14748352e_09 + %555 = OpConvertFToS %int %551 + OpReturnValue %555 OpFunctionEnd -%tint_f16_to_i32 = OpFunction %int None %446 +%tint_f16_to_i32 = OpFunction %int None %557 %value_0 = OpFunctionParameter %half - %447 = OpLabel - %448 = OpExtInst %half %441 NClamp %value_0 %half_n0x1_ffcp_15 %half_0x1_ffcp_15 - %451 = OpConvertFToS %int %448 - OpReturnValue %451 + %558 = OpLabel + %559 = OpExtInst %half %552 NClamp %value_0 %half_n0x1_ffcp_15 %half_0x1_ffcp_15 + %562 = OpConvertFToS %int %559 + OpReturnValue %562 OpFunctionEnd -%tint_convert_explicit_layout = OpFunction %_arr_v3float_uint_2_0 None %453 +%tint_convert_explicit_layout = OpFunction %_arr_v3float_uint_2_0 None %564 %tint_source = OpFunctionParameter %_arr_v3float_uint_2 - %454 = OpLabel - %455 = OpVariable %_ptr_Function__arr_v3float_uint_2 Function - %457 = OpVariable %_ptr_Function__arr_v3float_uint_2_0 Function %459 - OpStore %455 %tint_source - OpBranch %460 - %460 = OpLabel - OpBranch %463 - %463 = OpLabel - %465 = OpPhi %uint %uint_0 %460 %466 %462 - OpLoopMerge %464 %462 None - OpBranch %461 - %461 = OpLabel - %468 = OpUGreaterThanEqual %bool %465 %uint_2 - OpSelectionMerge %469 None - OpBranchConditional %468 %470 %469 - %470 = OpLabel - OpBranch %464 - %469 = OpLabel - %471 = OpAccessChain %_ptr_Function_v3float %455 %465 - %473 = OpLoad %v3float %471 None - %474 = OpAccessChain %_ptr_Function_v3float %457 %465 - OpStore %474 %473 None - OpBranch %462 - %462 = OpLabel - %466 = OpIAdd %uint %465 %uint_1 - OpBranch %463 - %464 = OpLabel - %467 = OpLoad %_arr_v3float_uint_2_0 %457 None - OpReturnValue %467 + %565 = OpLabel + %566 = OpVariable %_ptr_Function__arr_v3float_uint_2 Function + %568 = OpVariable %_ptr_Function__arr_v3float_uint_2_0 Function %570 + OpStore %566 %tint_source + OpBranch %571 + %571 = OpLabel + OpBranch %574 + %574 = OpLabel + %576 = OpPhi %uint %uint_0 %571 %577 %573 + OpLoopMerge %575 %573 None + OpBranch %572 + %572 = OpLabel + %579 = OpUGreaterThanEqual %bool %576 %uint_2 + OpSelectionMerge %580 None + OpBranchConditional %579 %581 %580 + %581 = OpLabel + OpBranch %575 + %580 = OpLabel + %582 = OpAccessChain %_ptr_Function_v3float %566 %576 + %584 = OpLoad %v3float %582 None + %585 = OpAccessChain %_ptr_Function_v3float %568 %576 + OpStore %585 %584 None + OpBranch %573 + %573 = OpLabel + %577 = OpIAdd %uint %576 %uint_1 + OpBranch %574 + %575 = OpLabel + %578 = OpLoad %_arr_v3float_uint_2_0 %568 None + OpReturnValue %578 OpFunctionEnd -%tint_convert_explicit_layout_0 = OpFunction %_arr_mat4x2_f16_std140_uint_2_0 None %476 +%tint_convert_explicit_layout_0 = OpFunction %_arr_mat4x2_f16_std140_uint_2_0 None %587 %tint_source_0 = OpFunctionParameter %_arr_mat4x2_f16_std140_uint_2 - %477 = OpLabel - %478 = OpVariable %_ptr_Function__arr_mat4x2_f16_std140_uint_2 Function - %480 = OpVariable %_ptr_Function__arr_mat4x2_f16_std140_uint_2_0 Function %481 - OpStore %478 %tint_source_0 - OpBranch %482 - %482 = OpLabel - OpBranch %485 - %485 = OpLabel - %487 = OpPhi %uint %uint_0 %482 %488 %484 - OpLoopMerge %486 %484 None - OpBranch %483 - %483 = OpLabel - %490 = OpUGreaterThanEqual %bool %487 %uint_2 - OpSelectionMerge %491 None - OpBranchConditional %490 %492 %491 - %492 = OpLabel - OpBranch %486 - %491 = OpLabel - %493 = OpAccessChain %_ptr_Function_mat4x2_f16_std140 %478 %487 - %494 = OpLoad %mat4x2_f16_std140 %493 None - %495 = OpAccessChain %_ptr_Function_mat4x2_f16_std140 %480 %487 - OpStore %495 %494 None - OpBranch %484 - %484 = OpLabel - %488 = OpIAdd %uint %487 %uint_1 - OpBranch %485 - %486 = OpLabel - %489 = OpLoad %_arr_mat4x2_f16_std140_uint_2_0 %480 None - OpReturnValue %489 + %588 = OpLabel + %589 = OpVariable %_ptr_Function__arr_mat4x2_f16_std140_uint_2 Function + %591 = OpVariable %_ptr_Function__arr_mat4x2_f16_std140_uint_2_0 Function %592 + OpStore %589 %tint_source_0 + OpBranch %593 + %593 = OpLabel + OpBranch %596 + %596 = OpLabel + %598 = OpPhi %uint %uint_0 %593 %599 %595 + OpLoopMerge %597 %595 None + OpBranch %594 + %594 = OpLabel + %601 = OpUGreaterThanEqual %bool %598 %uint_2 + OpSelectionMerge %602 None + OpBranchConditional %601 %603 %602 + %603 = OpLabel + OpBranch %597 + %602 = OpLabel + %604 = OpAccessChain %_ptr_Function_mat4x2_f16_std140 %589 %598 + %605 = OpLoad %mat4x2_f16_std140 %604 None + %606 = OpAccessChain %_ptr_Function_mat4x2_f16_std140 %591 %598 + OpStore %606 %605 None + OpBranch %595 + %595 = OpLabel + %599 = OpIAdd %uint %598 %uint_1 + OpBranch %596 + %597 = OpLabel + %600 = OpLoad %_arr_mat4x2_f16_std140_uint_2_0 %591 None + OpReturnValue %600 OpFunctionEnd -%tint_convert_explicit_layout_1 = OpFunction %_arr_Inner_uint_4_0 None %497 +%tint_convert_explicit_layout_1 = OpFunction %_arr_Inner_uint_4_0 None %608 %tint_source_1 = OpFunctionParameter %_arr_Inner_uint_4 - %498 = OpLabel - %499 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function - %501 = OpVariable %_ptr_Function__arr_Inner_uint_4_0 Function %503 - OpStore %499 %tint_source_1 - OpBranch %504 - %504 = OpLabel - OpBranch %507 - %507 = OpLabel - %509 = OpPhi %uint %uint_0 %504 %510 %506 - OpLoopMerge %508 %506 None - OpBranch %505 - %505 = OpLabel - %512 = OpUGreaterThanEqual %bool %509 %uint_4 - OpSelectionMerge %513 None - OpBranchConditional %512 %514 %513 - %514 = OpLabel - OpBranch %508 - %513 = OpLabel - %515 = OpAccessChain %_ptr_Function_Inner %499 %509 - %517 = OpLoad %Inner %515 None - %518 = OpAccessChain %_ptr_Function_Inner %501 %509 - OpStore %518 %517 None - OpBranch %506 - %506 = OpLabel - %510 = OpIAdd %uint %509 %uint_1 - OpBranch %507 - %508 = OpLabel - %511 = OpLoad %_arr_Inner_uint_4_0 %501 None - OpReturnValue %511 + %609 = OpLabel + %610 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function + %612 = OpVariable %_ptr_Function__arr_Inner_uint_4_0 Function %614 + OpStore %610 %tint_source_1 + OpBranch %615 + %615 = OpLabel + OpBranch %618 + %618 = OpLabel + %620 = OpPhi %uint %uint_0 %615 %621 %617 + OpLoopMerge %619 %617 None + OpBranch %616 + %616 = OpLabel + %623 = OpUGreaterThanEqual %bool %620 %uint_4 + OpSelectionMerge %624 None + OpBranchConditional %623 %625 %624 + %625 = OpLabel + OpBranch %619 + %624 = OpLabel + %626 = OpAccessChain %_ptr_Function_Inner %610 %620 + %628 = OpLoad %Inner %626 None + %629 = OpAccessChain %_ptr_Function_Inner %612 %620 + OpStore %629 %628 None + OpBranch %617 + %617 = OpLabel + %621 = OpIAdd %uint %620 %uint_1 + OpBranch %618 + %619 = OpLabel + %622 = OpLoad %_arr_Inner_uint_4_0 %612 None + OpReturnValue %622 OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/array/mat2x2_f32/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/array/mat2x2_f32/dynamic_index_via_ptr.wgsl.expected.glsl index 36287e1..6d24b36 100644 --- a/test/tint/buffer/uniform/std140/array/mat2x2_f32/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/array/mat2x2_f32/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -16,33 +16,34 @@ } v_1; int counter = 0; int i() { - counter = (counter + 1); + uint v_2 = uint(counter); + counter = int((v_2 + uint(1))); return counter; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - uint v_2 = min(uint(i()), 3u); - mat2 v_3 = mat2(v.inner[v_2].col0, v.inner[v_2].col1); - vec2 v_4 = v_3[min(uint(i()), 1u)]; - mat2x2_f32_std140 v_5[4] = v.inner; - mat2 v_6[4] = mat2[4](mat2(vec2(0.0f), vec2(0.0f)), mat2(vec2(0.0f), vec2(0.0f)), mat2(vec2(0.0f), vec2(0.0f)), mat2(vec2(0.0f), vec2(0.0f))); + uint v_3 = min(uint(i()), 3u); + mat2 v_4 = mat2(v.inner[v_3].col0, v.inner[v_3].col1); + vec2 v_5 = v_4[min(uint(i()), 1u)]; + mat2x2_f32_std140 v_6[4] = v.inner; + mat2 v_7[4] = mat2[4](mat2(vec2(0.0f), vec2(0.0f)), mat2(vec2(0.0f), vec2(0.0f)), mat2(vec2(0.0f), vec2(0.0f)), mat2(vec2(0.0f), vec2(0.0f))); { - uint v_7 = 0u; - v_7 = 0u; + uint v_8 = 0u; + v_8 = 0u; while(true) { - uint v_8 = v_7; - if ((v_8 >= 4u)) { + uint v_9 = v_8; + if ((v_9 >= 4u)) { break; } - v_6[v_8] = mat2(v_5[v_8].col0, v_5[v_8].col1); + v_7[v_9] = mat2(v_6[v_9].col0, v_6[v_9].col1); { - v_7 = (v_8 + 1u); + v_8 = (v_9 + 1u); } continue; } } - mat2 l_a[4] = v_6; - mat2 l_a_i = v_3; - vec2 l_a_i_i = v_4; - v_1.inner = (((v_4.x + l_a[0u][0u].x) + l_a_i[0u].x) + l_a_i_i.x); + mat2 l_a[4] = v_7; + mat2 l_a_i = v_4; + vec2 l_a_i_i = v_5; + v_1.inner = (((v_5.x + l_a[0u][0u].x) + l_a_i[0u].x) + l_a_i_i.x); }
diff --git a/test/tint/buffer/uniform/std140/array/mat2x2_f32/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/array/mat2x2_f32/dynamic_index_via_ptr.wgsl.expected.spvasm index a6da27c..c76e05c 100644 --- a/test/tint/buffer/uniform/std140/array/mat2x2_f32/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/array/mat2x2_f32/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,10 +1,10 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 111 +; Bound: 114 ; Schema: 0 OpCapability Shader - %34 = OpExtInstImport "GLSL.std.450" + %37 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -55,7 +55,7 @@ %18 = OpTypeFunction %int %int_1 = OpConstant %int 1 %void = OpTypeVoid - %26 = OpTypeFunction %void + %29 = OpTypeFunction %void %_ptr_Uniform__arr_mat2x2_f32_std140_uint_4 = OpTypePointer Uniform %_arr_mat2x2_f32_std140_uint_4 %uint_0 = OpConstant %uint 0 %uint_3 = OpConstant %uint 3 @@ -68,111 +68,114 @@ %_ptr_Function__arr_mat2x2_f32_std140_uint_4_0 = OpTypePointer Function %_arr_mat2x2_f32_std140_uint_4_0 %_arr_mat2v2float_uint_4 = OpTypeArray %mat2v2float %uint_4 %_ptr_Function__arr_mat2v2float_uint_4 = OpTypePointer Function %_arr_mat2v2float_uint_4 - %61 = OpConstantNull %_arr_mat2v2float_uint_4 + %64 = OpConstantNull %_arr_mat2v2float_uint_4 %_ptr_StorageBuffer_float = OpTypePointer StorageBuffer %float %bool = OpTypeBool %_ptr_Function_mat2x2_f32_std140 = OpTypePointer Function %mat2x2_f32_std140 - %91 = OpTypeFunction %_arr_mat2x2_f32_std140_uint_4_0 %_arr_mat2x2_f32_std140_uint_4 + %94 = OpTypeFunction %_arr_mat2x2_f32_std140_uint_4_0 %_arr_mat2x2_f32_std140_uint_4 %_ptr_Function__arr_mat2x2_f32_std140_uint_4 = OpTypePointer Function %_arr_mat2x2_f32_std140_uint_4 - %96 = OpConstantNull %_arr_mat2x2_f32_std140_uint_4_0 + %99 = OpConstantNull %_arr_mat2x2_f32_std140_uint_4_0 %i = OpFunction %int None %18 %19 = OpLabel %20 = OpLoad %int %counter None - %21 = OpIAdd %int %20 %int_1 - OpStore %counter %21 None - %23 = OpLoad %int %counter None - OpReturnValue %23 + %21 = OpBitcast %uint %20 + %22 = OpBitcast %uint %int_1 + %24 = OpIAdd %uint %21 %22 + %25 = OpBitcast %int %24 + OpStore %counter %25 None + %26 = OpLoad %int %counter None + OpReturnValue %26 OpFunctionEnd - %f = OpFunction %void None %26 - %27 = OpLabel - %44 = OpVariable %_ptr_Function_mat2v2float Function - %56 = OpVariable %_ptr_Function__arr_mat2x2_f32_std140_uint_4_0 Function - %58 = OpVariable %_ptr_Function__arr_mat2v2float_uint_4 Function %61 - %28 = OpAccessChain %_ptr_Uniform__arr_mat2x2_f32_std140_uint_4 %1 %uint_0 - %31 = OpFunctionCall %int %i - %32 = OpBitcast %uint %31 - %33 = OpExtInst %uint %34 UMin %32 %uint_3 - %36 = OpAccessChain %_ptr_Uniform_v2float %28 %33 %uint_0 - %38 = OpLoad %v2float %36 None - %39 = OpAccessChain %_ptr_Uniform_v2float %28 %33 %uint_1 + %f = OpFunction %void None %29 + %30 = OpLabel + %47 = OpVariable %_ptr_Function_mat2v2float Function + %59 = OpVariable %_ptr_Function__arr_mat2x2_f32_std140_uint_4_0 Function + %61 = OpVariable %_ptr_Function__arr_mat2v2float_uint_4 Function %64 + %31 = OpAccessChain %_ptr_Uniform__arr_mat2x2_f32_std140_uint_4 %1 %uint_0 + %34 = OpFunctionCall %int %i + %35 = OpBitcast %uint %34 + %36 = OpExtInst %uint %37 UMin %35 %uint_3 + %39 = OpAccessChain %_ptr_Uniform_v2float %31 %36 %uint_0 %41 = OpLoad %v2float %39 None - %l_a_i = OpCompositeConstruct %mat2v2float %38 %41 - OpStore %44 %l_a_i - %46 = OpFunctionCall %int %i - %47 = OpBitcast %uint %46 - %48 = OpExtInst %uint %34 UMin %47 %uint_1 - %49 = OpAccessChain %_ptr_Function_v2float %44 %48 - %l_a_i_i = OpLoad %v2float %49 None - %52 = OpLoad %_arr_mat2x2_f32_std140_uint_4 %28 None - %53 = OpFunctionCall %_arr_mat2x2_f32_std140_uint_4_0 %tint_convert_explicit_layout %52 - OpStore %56 %53 - OpBranch %62 - %62 = OpLabel + %42 = OpAccessChain %_ptr_Uniform_v2float %31 %36 %uint_1 + %44 = OpLoad %v2float %42 None + %l_a_i = OpCompositeConstruct %mat2v2float %41 %44 + OpStore %47 %l_a_i + %49 = OpFunctionCall %int %i + %50 = OpBitcast %uint %49 + %51 = OpExtInst %uint %37 UMin %50 %uint_1 + %52 = OpAccessChain %_ptr_Function_v2float %47 %51 + %l_a_i_i = OpLoad %v2float %52 None + %55 = OpLoad %_arr_mat2x2_f32_std140_uint_4 %31 None + %56 = OpFunctionCall %_arr_mat2x2_f32_std140_uint_4_0 %tint_convert_explicit_layout %55 + OpStore %59 %56 OpBranch %65 %65 = OpLabel - %67 = OpPhi %uint %uint_0 %62 %68 %64 - OpLoopMerge %66 %64 None - OpBranch %63 - %63 = OpLabel - %79 = OpUGreaterThanEqual %bool %67 %uint_4 - OpSelectionMerge %81 None - OpBranchConditional %79 %82 %81 - %82 = OpLabel + OpBranch %68 + %68 = OpLabel + %70 = OpPhi %uint %uint_0 %65 %71 %67 + OpLoopMerge %69 %67 None OpBranch %66 - %81 = OpLabel - %83 = OpAccessChain %_ptr_Function_mat2v2float %58 %67 - %84 = OpAccessChain %_ptr_Function_mat2x2_f32_std140 %56 %67 - %86 = OpLoad %mat2x2_f32_std140 %84 None - %87 = OpCompositeExtract %v2float %86 0 - %88 = OpCompositeExtract %v2float %86 1 - %89 = OpCompositeConstruct %mat2v2float %87 %88 - OpStore %83 %89 None - OpBranch %64 - %64 = OpLabel - %68 = OpIAdd %uint %67 %uint_1 - OpBranch %65 %66 = OpLabel - %l_a = OpLoad %_arr_mat2v2float_uint_4 %58 None - %70 = OpCompositeExtract %float %l_a_i_i 0 - %71 = OpCompositeExtract %float %l_a 0 0 0 - %72 = OpFAdd %float %70 %71 - %73 = OpCompositeExtract %float %l_a_i 0 0 - %74 = OpFAdd %float %72 %73 - %75 = OpCompositeExtract %float %l_a_i_i 0 - %76 = OpFAdd %float %74 %75 - %77 = OpAccessChain %_ptr_StorageBuffer_float %10 %uint_0 - OpStore %77 %76 None + %82 = OpUGreaterThanEqual %bool %70 %uint_4 + OpSelectionMerge %84 None + OpBranchConditional %82 %85 %84 + %85 = OpLabel + OpBranch %69 + %84 = OpLabel + %86 = OpAccessChain %_ptr_Function_mat2v2float %61 %70 + %87 = OpAccessChain %_ptr_Function_mat2x2_f32_std140 %59 %70 + %89 = OpLoad %mat2x2_f32_std140 %87 None + %90 = OpCompositeExtract %v2float %89 0 + %91 = OpCompositeExtract %v2float %89 1 + %92 = OpCompositeConstruct %mat2v2float %90 %91 + OpStore %86 %92 None + OpBranch %67 + %67 = OpLabel + %71 = OpIAdd %uint %70 %uint_1 + OpBranch %68 + %69 = OpLabel + %l_a = OpLoad %_arr_mat2v2float_uint_4 %61 None + %73 = OpCompositeExtract %float %l_a_i_i 0 + %74 = OpCompositeExtract %float %l_a 0 0 0 + %75 = OpFAdd %float %73 %74 + %76 = OpCompositeExtract %float %l_a_i 0 0 + %77 = OpFAdd %float %75 %76 + %78 = OpCompositeExtract %float %l_a_i_i 0 + %79 = OpFAdd %float %77 %78 + %80 = OpAccessChain %_ptr_StorageBuffer_float %10 %uint_0 + OpStore %80 %79 None OpReturn OpFunctionEnd -%tint_convert_explicit_layout = OpFunction %_arr_mat2x2_f32_std140_uint_4_0 None %91 +%tint_convert_explicit_layout = OpFunction %_arr_mat2x2_f32_std140_uint_4_0 None %94 %tint_source = OpFunctionParameter %_arr_mat2x2_f32_std140_uint_4 - %92 = OpLabel - %93 = OpVariable %_ptr_Function__arr_mat2x2_f32_std140_uint_4 Function - %95 = OpVariable %_ptr_Function__arr_mat2x2_f32_std140_uint_4_0 Function %96 - OpStore %93 %tint_source - OpBranch %97 - %97 = OpLabel + %95 = OpLabel + %96 = OpVariable %_ptr_Function__arr_mat2x2_f32_std140_uint_4 Function + %98 = OpVariable %_ptr_Function__arr_mat2x2_f32_std140_uint_4_0 Function %99 + OpStore %96 %tint_source OpBranch %100 %100 = OpLabel - %102 = OpPhi %uint %uint_0 %97 %103 %99 - OpLoopMerge %101 %99 None - OpBranch %98 - %98 = OpLabel - %105 = OpUGreaterThanEqual %bool %102 %uint_4 - OpSelectionMerge %106 None - OpBranchConditional %105 %107 %106 - %107 = OpLabel + OpBranch %103 + %103 = OpLabel + %105 = OpPhi %uint %uint_0 %100 %106 %102 + OpLoopMerge %104 %102 None OpBranch %101 - %106 = OpLabel - %108 = OpAccessChain %_ptr_Function_mat2x2_f32_std140 %93 %102 - %109 = OpLoad %mat2x2_f32_std140 %108 None - %110 = OpAccessChain %_ptr_Function_mat2x2_f32_std140 %95 %102 - OpStore %110 %109 None - OpBranch %99 - %99 = OpLabel - %103 = OpIAdd %uint %102 %uint_1 - OpBranch %100 %101 = OpLabel - %104 = OpLoad %_arr_mat2x2_f32_std140_uint_4_0 %95 None - OpReturnValue %104 + %108 = OpUGreaterThanEqual %bool %105 %uint_4 + OpSelectionMerge %109 None + OpBranchConditional %108 %110 %109 + %110 = OpLabel + OpBranch %104 + %109 = OpLabel + %111 = OpAccessChain %_ptr_Function_mat2x2_f32_std140 %96 %105 + %112 = OpLoad %mat2x2_f32_std140 %111 None + %113 = OpAccessChain %_ptr_Function_mat2x2_f32_std140 %98 %105 + OpStore %113 %112 None + OpBranch %102 + %102 = OpLabel + %106 = OpIAdd %uint %105 %uint_1 + OpBranch %103 + %104 = OpLabel + %107 = OpLoad %_arr_mat2x2_f32_std140_uint_4_0 %98 None + OpReturnValue %107 OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/array/mat2x3_f16/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/array/mat2x3_f16/dynamic_index_via_ptr.wgsl.expected.glsl index f14b269..3fd6b70 100644 --- a/test/tint/buffer/uniform/std140/array/mat2x3_f16/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/array/mat2x3_f16/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -17,33 +17,34 @@ } v_1; int counter = 0; int i() { - counter = (counter + 1); + uint v_2 = uint(counter); + counter = int((v_2 + uint(1))); return counter; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - uint v_2 = min(uint(i()), 3u); - f16mat2x3 v_3 = f16mat2x3(v.inner[v_2].col0, v.inner[v_2].col1); - f16vec3 v_4 = v_3[min(uint(i()), 1u)]; - mat2x3_f16_std140 v_5[4] = v.inner; - f16mat2x3 v_6[4] = f16mat2x3[4](f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf)), f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf)), f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf)), f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))); + uint v_3 = min(uint(i()), 3u); + f16mat2x3 v_4 = f16mat2x3(v.inner[v_3].col0, v.inner[v_3].col1); + f16vec3 v_5 = v_4[min(uint(i()), 1u)]; + mat2x3_f16_std140 v_6[4] = v.inner; + f16mat2x3 v_7[4] = f16mat2x3[4](f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf)), f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf)), f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf)), f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))); { - uint v_7 = 0u; - v_7 = 0u; + uint v_8 = 0u; + v_8 = 0u; while(true) { - uint v_8 = v_7; - if ((v_8 >= 4u)) { + uint v_9 = v_8; + if ((v_9 >= 4u)) { break; } - v_6[v_8] = f16mat2x3(v_5[v_8].col0, v_5[v_8].col1); + v_7[v_9] = f16mat2x3(v_6[v_9].col0, v_6[v_9].col1); { - v_7 = (v_8 + 1u); + v_8 = (v_9 + 1u); } continue; } } - f16mat2x3 l_a[4] = v_6; - f16mat2x3 l_a_i = v_3; - f16vec3 l_a_i_i = v_4; - v_1.inner = (((v_4.x + l_a[0u][0u].x) + l_a_i[0u].x) + l_a_i_i.x); + f16mat2x3 l_a[4] = v_7; + f16mat2x3 l_a_i = v_4; + f16vec3 l_a_i_i = v_5; + v_1.inner = (((v_5.x + l_a[0u][0u].x) + l_a_i[0u].x) + l_a_i_i.x); }
diff --git a/test/tint/buffer/uniform/std140/array/mat2x3_f16/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/array/mat2x3_f16/dynamic_index_via_ptr.wgsl.expected.spvasm index 1a04df5..669c2a2 100644 --- a/test/tint/buffer/uniform/std140/array/mat2x3_f16/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/array/mat2x3_f16/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,13 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 111 +; Bound: 114 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess - %34 = OpExtInstImport "GLSL.std.450" + %37 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -58,7 +58,7 @@ %18 = OpTypeFunction %int %int_1 = OpConstant %int 1 %void = OpTypeVoid - %26 = OpTypeFunction %void + %29 = OpTypeFunction %void %_ptr_Uniform__arr_mat2x3_f16_std140_uint_4 = OpTypePointer Uniform %_arr_mat2x3_f16_std140_uint_4 %uint_0 = OpConstant %uint 0 %uint_3 = OpConstant %uint 3 @@ -71,111 +71,114 @@ %_ptr_Function__arr_mat2x3_f16_std140_uint_4_0 = OpTypePointer Function %_arr_mat2x3_f16_std140_uint_4_0 %_arr_mat2v3half_uint_4 = OpTypeArray %mat2v3half %uint_4 %_ptr_Function__arr_mat2v3half_uint_4 = OpTypePointer Function %_arr_mat2v3half_uint_4 - %61 = OpConstantNull %_arr_mat2v3half_uint_4 + %64 = OpConstantNull %_arr_mat2v3half_uint_4 %_ptr_StorageBuffer_half = OpTypePointer StorageBuffer %half %bool = OpTypeBool %_ptr_Function_mat2x3_f16_std140 = OpTypePointer Function %mat2x3_f16_std140 - %91 = OpTypeFunction %_arr_mat2x3_f16_std140_uint_4_0 %_arr_mat2x3_f16_std140_uint_4 + %94 = OpTypeFunction %_arr_mat2x3_f16_std140_uint_4_0 %_arr_mat2x3_f16_std140_uint_4 %_ptr_Function__arr_mat2x3_f16_std140_uint_4 = OpTypePointer Function %_arr_mat2x3_f16_std140_uint_4 - %96 = OpConstantNull %_arr_mat2x3_f16_std140_uint_4_0 + %99 = OpConstantNull %_arr_mat2x3_f16_std140_uint_4_0 %i = OpFunction %int None %18 %19 = OpLabel %20 = OpLoad %int %counter None - %21 = OpIAdd %int %20 %int_1 - OpStore %counter %21 None - %23 = OpLoad %int %counter None - OpReturnValue %23 + %21 = OpBitcast %uint %20 + %22 = OpBitcast %uint %int_1 + %24 = OpIAdd %uint %21 %22 + %25 = OpBitcast %int %24 + OpStore %counter %25 None + %26 = OpLoad %int %counter None + OpReturnValue %26 OpFunctionEnd - %f = OpFunction %void None %26 - %27 = OpLabel - %44 = OpVariable %_ptr_Function_mat2v3half Function - %56 = OpVariable %_ptr_Function__arr_mat2x3_f16_std140_uint_4_0 Function - %58 = OpVariable %_ptr_Function__arr_mat2v3half_uint_4 Function %61 - %28 = OpAccessChain %_ptr_Uniform__arr_mat2x3_f16_std140_uint_4 %1 %uint_0 - %31 = OpFunctionCall %int %i - %32 = OpBitcast %uint %31 - %33 = OpExtInst %uint %34 UMin %32 %uint_3 - %36 = OpAccessChain %_ptr_Uniform_v3half %28 %33 %uint_0 - %38 = OpLoad %v3half %36 None - %39 = OpAccessChain %_ptr_Uniform_v3half %28 %33 %uint_1 + %f = OpFunction %void None %29 + %30 = OpLabel + %47 = OpVariable %_ptr_Function_mat2v3half Function + %59 = OpVariable %_ptr_Function__arr_mat2x3_f16_std140_uint_4_0 Function + %61 = OpVariable %_ptr_Function__arr_mat2v3half_uint_4 Function %64 + %31 = OpAccessChain %_ptr_Uniform__arr_mat2x3_f16_std140_uint_4 %1 %uint_0 + %34 = OpFunctionCall %int %i + %35 = OpBitcast %uint %34 + %36 = OpExtInst %uint %37 UMin %35 %uint_3 + %39 = OpAccessChain %_ptr_Uniform_v3half %31 %36 %uint_0 %41 = OpLoad %v3half %39 None - %l_a_i = OpCompositeConstruct %mat2v3half %38 %41 - OpStore %44 %l_a_i - %46 = OpFunctionCall %int %i - %47 = OpBitcast %uint %46 - %48 = OpExtInst %uint %34 UMin %47 %uint_1 - %49 = OpAccessChain %_ptr_Function_v3half %44 %48 - %l_a_i_i = OpLoad %v3half %49 None - %52 = OpLoad %_arr_mat2x3_f16_std140_uint_4 %28 None - %53 = OpFunctionCall %_arr_mat2x3_f16_std140_uint_4_0 %tint_convert_explicit_layout %52 - OpStore %56 %53 - OpBranch %62 - %62 = OpLabel + %42 = OpAccessChain %_ptr_Uniform_v3half %31 %36 %uint_1 + %44 = OpLoad %v3half %42 None + %l_a_i = OpCompositeConstruct %mat2v3half %41 %44 + OpStore %47 %l_a_i + %49 = OpFunctionCall %int %i + %50 = OpBitcast %uint %49 + %51 = OpExtInst %uint %37 UMin %50 %uint_1 + %52 = OpAccessChain %_ptr_Function_v3half %47 %51 + %l_a_i_i = OpLoad %v3half %52 None + %55 = OpLoad %_arr_mat2x3_f16_std140_uint_4 %31 None + %56 = OpFunctionCall %_arr_mat2x3_f16_std140_uint_4_0 %tint_convert_explicit_layout %55 + OpStore %59 %56 OpBranch %65 %65 = OpLabel - %67 = OpPhi %uint %uint_0 %62 %68 %64 - OpLoopMerge %66 %64 None - OpBranch %63 - %63 = OpLabel - %79 = OpUGreaterThanEqual %bool %67 %uint_4 - OpSelectionMerge %81 None - OpBranchConditional %79 %82 %81 - %82 = OpLabel + OpBranch %68 + %68 = OpLabel + %70 = OpPhi %uint %uint_0 %65 %71 %67 + OpLoopMerge %69 %67 None OpBranch %66 - %81 = OpLabel - %83 = OpAccessChain %_ptr_Function_mat2v3half %58 %67 - %84 = OpAccessChain %_ptr_Function_mat2x3_f16_std140 %56 %67 - %86 = OpLoad %mat2x3_f16_std140 %84 None - %87 = OpCompositeExtract %v3half %86 0 - %88 = OpCompositeExtract %v3half %86 1 - %89 = OpCompositeConstruct %mat2v3half %87 %88 - OpStore %83 %89 None - OpBranch %64 - %64 = OpLabel - %68 = OpIAdd %uint %67 %uint_1 - OpBranch %65 %66 = OpLabel - %l_a = OpLoad %_arr_mat2v3half_uint_4 %58 None - %70 = OpCompositeExtract %half %l_a_i_i 0 - %71 = OpCompositeExtract %half %l_a 0 0 0 - %72 = OpFAdd %half %70 %71 - %73 = OpCompositeExtract %half %l_a_i 0 0 - %74 = OpFAdd %half %72 %73 - %75 = OpCompositeExtract %half %l_a_i_i 0 - %76 = OpFAdd %half %74 %75 - %77 = OpAccessChain %_ptr_StorageBuffer_half %10 %uint_0 - OpStore %77 %76 None + %82 = OpUGreaterThanEqual %bool %70 %uint_4 + OpSelectionMerge %84 None + OpBranchConditional %82 %85 %84 + %85 = OpLabel + OpBranch %69 + %84 = OpLabel + %86 = OpAccessChain %_ptr_Function_mat2v3half %61 %70 + %87 = OpAccessChain %_ptr_Function_mat2x3_f16_std140 %59 %70 + %89 = OpLoad %mat2x3_f16_std140 %87 None + %90 = OpCompositeExtract %v3half %89 0 + %91 = OpCompositeExtract %v3half %89 1 + %92 = OpCompositeConstruct %mat2v3half %90 %91 + OpStore %86 %92 None + OpBranch %67 + %67 = OpLabel + %71 = OpIAdd %uint %70 %uint_1 + OpBranch %68 + %69 = OpLabel + %l_a = OpLoad %_arr_mat2v3half_uint_4 %61 None + %73 = OpCompositeExtract %half %l_a_i_i 0 + %74 = OpCompositeExtract %half %l_a 0 0 0 + %75 = OpFAdd %half %73 %74 + %76 = OpCompositeExtract %half %l_a_i 0 0 + %77 = OpFAdd %half %75 %76 + %78 = OpCompositeExtract %half %l_a_i_i 0 + %79 = OpFAdd %half %77 %78 + %80 = OpAccessChain %_ptr_StorageBuffer_half %10 %uint_0 + OpStore %80 %79 None OpReturn OpFunctionEnd -%tint_convert_explicit_layout = OpFunction %_arr_mat2x3_f16_std140_uint_4_0 None %91 +%tint_convert_explicit_layout = OpFunction %_arr_mat2x3_f16_std140_uint_4_0 None %94 %tint_source = OpFunctionParameter %_arr_mat2x3_f16_std140_uint_4 - %92 = OpLabel - %93 = OpVariable %_ptr_Function__arr_mat2x3_f16_std140_uint_4 Function - %95 = OpVariable %_ptr_Function__arr_mat2x3_f16_std140_uint_4_0 Function %96 - OpStore %93 %tint_source - OpBranch %97 - %97 = OpLabel + %95 = OpLabel + %96 = OpVariable %_ptr_Function__arr_mat2x3_f16_std140_uint_4 Function + %98 = OpVariable %_ptr_Function__arr_mat2x3_f16_std140_uint_4_0 Function %99 + OpStore %96 %tint_source OpBranch %100 %100 = OpLabel - %102 = OpPhi %uint %uint_0 %97 %103 %99 - OpLoopMerge %101 %99 None - OpBranch %98 - %98 = OpLabel - %105 = OpUGreaterThanEqual %bool %102 %uint_4 - OpSelectionMerge %106 None - OpBranchConditional %105 %107 %106 - %107 = OpLabel + OpBranch %103 + %103 = OpLabel + %105 = OpPhi %uint %uint_0 %100 %106 %102 + OpLoopMerge %104 %102 None OpBranch %101 - %106 = OpLabel - %108 = OpAccessChain %_ptr_Function_mat2x3_f16_std140 %93 %102 - %109 = OpLoad %mat2x3_f16_std140 %108 None - %110 = OpAccessChain %_ptr_Function_mat2x3_f16_std140 %95 %102 - OpStore %110 %109 None - OpBranch %99 - %99 = OpLabel - %103 = OpIAdd %uint %102 %uint_1 - OpBranch %100 %101 = OpLabel - %104 = OpLoad %_arr_mat2x3_f16_std140_uint_4_0 %95 None - OpReturnValue %104 + %108 = OpUGreaterThanEqual %bool %105 %uint_4 + OpSelectionMerge %109 None + OpBranchConditional %108 %110 %109 + %110 = OpLabel + OpBranch %104 + %109 = OpLabel + %111 = OpAccessChain %_ptr_Function_mat2x3_f16_std140 %96 %105 + %112 = OpLoad %mat2x3_f16_std140 %111 None + %113 = OpAccessChain %_ptr_Function_mat2x3_f16_std140 %98 %105 + OpStore %113 %112 None + OpBranch %102 + %102 = OpLabel + %106 = OpIAdd %uint %105 %uint_1 + OpBranch %103 + %104 = OpLabel + %107 = OpLoad %_arr_mat2x3_f16_std140_uint_4_0 %98 None + OpReturnValue %107 OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/array/mat2x3_f32/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/array/mat2x3_f32/dynamic_index_via_ptr.wgsl.expected.glsl index e9d8e29..f3f5e57 100644 --- a/test/tint/buffer/uniform/std140/array/mat2x3_f32/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/array/mat2x3_f32/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -18,33 +18,34 @@ } v_1; int counter = 0; int i() { - counter = (counter + 1); + uint v_2 = uint(counter); + counter = int((v_2 + uint(1))); return counter; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - uint v_2 = min(uint(i()), 3u); - mat2x3 v_3 = mat2x3(v.inner[v_2].col0, v.inner[v_2].col1); - vec3 v_4 = v_3[min(uint(i()), 1u)]; - mat2x3_f32_std140 v_5[4] = v.inner; - mat2x3 v_6[4] = mat2x3[4](mat2x3(vec3(0.0f), vec3(0.0f)), mat2x3(vec3(0.0f), vec3(0.0f)), mat2x3(vec3(0.0f), vec3(0.0f)), mat2x3(vec3(0.0f), vec3(0.0f))); + uint v_3 = min(uint(i()), 3u); + mat2x3 v_4 = mat2x3(v.inner[v_3].col0, v.inner[v_3].col1); + vec3 v_5 = v_4[min(uint(i()), 1u)]; + mat2x3_f32_std140 v_6[4] = v.inner; + mat2x3 v_7[4] = mat2x3[4](mat2x3(vec3(0.0f), vec3(0.0f)), mat2x3(vec3(0.0f), vec3(0.0f)), mat2x3(vec3(0.0f), vec3(0.0f)), mat2x3(vec3(0.0f), vec3(0.0f))); { - uint v_7 = 0u; - v_7 = 0u; + uint v_8 = 0u; + v_8 = 0u; while(true) { - uint v_8 = v_7; - if ((v_8 >= 4u)) { + uint v_9 = v_8; + if ((v_9 >= 4u)) { break; } - v_6[v_8] = mat2x3(v_5[v_8].col0, v_5[v_8].col1); + v_7[v_9] = mat2x3(v_6[v_9].col0, v_6[v_9].col1); { - v_7 = (v_8 + 1u); + v_8 = (v_9 + 1u); } continue; } } - mat2x3 l_a[4] = v_6; - mat2x3 l_a_i = v_3; - vec3 l_a_i_i = v_4; - v_1.inner = (((v_4.x + l_a[0u][0u].x) + l_a_i[0u].x) + l_a_i_i.x); + mat2x3 l_a[4] = v_7; + mat2x3 l_a_i = v_4; + vec3 l_a_i_i = v_5; + v_1.inner = (((v_5.x + l_a[0u][0u].x) + l_a_i[0u].x) + l_a_i_i.x); }
diff --git a/test/tint/buffer/uniform/std140/array/mat2x3_f32/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/array/mat2x3_f32/dynamic_index_via_ptr.wgsl.expected.spvasm index 805dc2f..b08554e 100644 --- a/test/tint/buffer/uniform/std140/array/mat2x3_f32/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/array/mat2x3_f32/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,10 +1,10 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 111 +; Bound: 114 ; Schema: 0 OpCapability Shader - %34 = OpExtInstImport "GLSL.std.450" + %37 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -55,7 +55,7 @@ %18 = OpTypeFunction %int %int_1 = OpConstant %int 1 %void = OpTypeVoid - %26 = OpTypeFunction %void + %29 = OpTypeFunction %void %_ptr_Uniform__arr_mat2x3_f32_std140_uint_4 = OpTypePointer Uniform %_arr_mat2x3_f32_std140_uint_4 %uint_0 = OpConstant %uint 0 %uint_3 = OpConstant %uint 3 @@ -68,111 +68,114 @@ %_ptr_Function__arr_mat2x3_f32_std140_uint_4_0 = OpTypePointer Function %_arr_mat2x3_f32_std140_uint_4_0 %_arr_mat2v3float_uint_4 = OpTypeArray %mat2v3float %uint_4 %_ptr_Function__arr_mat2v3float_uint_4 = OpTypePointer Function %_arr_mat2v3float_uint_4 - %61 = OpConstantNull %_arr_mat2v3float_uint_4 + %64 = OpConstantNull %_arr_mat2v3float_uint_4 %_ptr_StorageBuffer_float = OpTypePointer StorageBuffer %float %bool = OpTypeBool %_ptr_Function_mat2x3_f32_std140 = OpTypePointer Function %mat2x3_f32_std140 - %91 = OpTypeFunction %_arr_mat2x3_f32_std140_uint_4_0 %_arr_mat2x3_f32_std140_uint_4 + %94 = OpTypeFunction %_arr_mat2x3_f32_std140_uint_4_0 %_arr_mat2x3_f32_std140_uint_4 %_ptr_Function__arr_mat2x3_f32_std140_uint_4 = OpTypePointer Function %_arr_mat2x3_f32_std140_uint_4 - %96 = OpConstantNull %_arr_mat2x3_f32_std140_uint_4_0 + %99 = OpConstantNull %_arr_mat2x3_f32_std140_uint_4_0 %i = OpFunction %int None %18 %19 = OpLabel %20 = OpLoad %int %counter None - %21 = OpIAdd %int %20 %int_1 - OpStore %counter %21 None - %23 = OpLoad %int %counter None - OpReturnValue %23 + %21 = OpBitcast %uint %20 + %22 = OpBitcast %uint %int_1 + %24 = OpIAdd %uint %21 %22 + %25 = OpBitcast %int %24 + OpStore %counter %25 None + %26 = OpLoad %int %counter None + OpReturnValue %26 OpFunctionEnd - %f = OpFunction %void None %26 - %27 = OpLabel - %44 = OpVariable %_ptr_Function_mat2v3float Function - %56 = OpVariable %_ptr_Function__arr_mat2x3_f32_std140_uint_4_0 Function - %58 = OpVariable %_ptr_Function__arr_mat2v3float_uint_4 Function %61 - %28 = OpAccessChain %_ptr_Uniform__arr_mat2x3_f32_std140_uint_4 %1 %uint_0 - %31 = OpFunctionCall %int %i - %32 = OpBitcast %uint %31 - %33 = OpExtInst %uint %34 UMin %32 %uint_3 - %36 = OpAccessChain %_ptr_Uniform_v3float %28 %33 %uint_0 - %38 = OpLoad %v3float %36 None - %39 = OpAccessChain %_ptr_Uniform_v3float %28 %33 %uint_1 + %f = OpFunction %void None %29 + %30 = OpLabel + %47 = OpVariable %_ptr_Function_mat2v3float Function + %59 = OpVariable %_ptr_Function__arr_mat2x3_f32_std140_uint_4_0 Function + %61 = OpVariable %_ptr_Function__arr_mat2v3float_uint_4 Function %64 + %31 = OpAccessChain %_ptr_Uniform__arr_mat2x3_f32_std140_uint_4 %1 %uint_0 + %34 = OpFunctionCall %int %i + %35 = OpBitcast %uint %34 + %36 = OpExtInst %uint %37 UMin %35 %uint_3 + %39 = OpAccessChain %_ptr_Uniform_v3float %31 %36 %uint_0 %41 = OpLoad %v3float %39 None - %l_a_i = OpCompositeConstruct %mat2v3float %38 %41 - OpStore %44 %l_a_i - %46 = OpFunctionCall %int %i - %47 = OpBitcast %uint %46 - %48 = OpExtInst %uint %34 UMin %47 %uint_1 - %49 = OpAccessChain %_ptr_Function_v3float %44 %48 - %l_a_i_i = OpLoad %v3float %49 None - %52 = OpLoad %_arr_mat2x3_f32_std140_uint_4 %28 None - %53 = OpFunctionCall %_arr_mat2x3_f32_std140_uint_4_0 %tint_convert_explicit_layout %52 - OpStore %56 %53 - OpBranch %62 - %62 = OpLabel + %42 = OpAccessChain %_ptr_Uniform_v3float %31 %36 %uint_1 + %44 = OpLoad %v3float %42 None + %l_a_i = OpCompositeConstruct %mat2v3float %41 %44 + OpStore %47 %l_a_i + %49 = OpFunctionCall %int %i + %50 = OpBitcast %uint %49 + %51 = OpExtInst %uint %37 UMin %50 %uint_1 + %52 = OpAccessChain %_ptr_Function_v3float %47 %51 + %l_a_i_i = OpLoad %v3float %52 None + %55 = OpLoad %_arr_mat2x3_f32_std140_uint_4 %31 None + %56 = OpFunctionCall %_arr_mat2x3_f32_std140_uint_4_0 %tint_convert_explicit_layout %55 + OpStore %59 %56 OpBranch %65 %65 = OpLabel - %67 = OpPhi %uint %uint_0 %62 %68 %64 - OpLoopMerge %66 %64 None - OpBranch %63 - %63 = OpLabel - %79 = OpUGreaterThanEqual %bool %67 %uint_4 - OpSelectionMerge %81 None - OpBranchConditional %79 %82 %81 - %82 = OpLabel + OpBranch %68 + %68 = OpLabel + %70 = OpPhi %uint %uint_0 %65 %71 %67 + OpLoopMerge %69 %67 None OpBranch %66 - %81 = OpLabel - %83 = OpAccessChain %_ptr_Function_mat2v3float %58 %67 - %84 = OpAccessChain %_ptr_Function_mat2x3_f32_std140 %56 %67 - %86 = OpLoad %mat2x3_f32_std140 %84 None - %87 = OpCompositeExtract %v3float %86 0 - %88 = OpCompositeExtract %v3float %86 1 - %89 = OpCompositeConstruct %mat2v3float %87 %88 - OpStore %83 %89 None - OpBranch %64 - %64 = OpLabel - %68 = OpIAdd %uint %67 %uint_1 - OpBranch %65 %66 = OpLabel - %l_a = OpLoad %_arr_mat2v3float_uint_4 %58 None - %70 = OpCompositeExtract %float %l_a_i_i 0 - %71 = OpCompositeExtract %float %l_a 0 0 0 - %72 = OpFAdd %float %70 %71 - %73 = OpCompositeExtract %float %l_a_i 0 0 - %74 = OpFAdd %float %72 %73 - %75 = OpCompositeExtract %float %l_a_i_i 0 - %76 = OpFAdd %float %74 %75 - %77 = OpAccessChain %_ptr_StorageBuffer_float %10 %uint_0 - OpStore %77 %76 None + %82 = OpUGreaterThanEqual %bool %70 %uint_4 + OpSelectionMerge %84 None + OpBranchConditional %82 %85 %84 + %85 = OpLabel + OpBranch %69 + %84 = OpLabel + %86 = OpAccessChain %_ptr_Function_mat2v3float %61 %70 + %87 = OpAccessChain %_ptr_Function_mat2x3_f32_std140 %59 %70 + %89 = OpLoad %mat2x3_f32_std140 %87 None + %90 = OpCompositeExtract %v3float %89 0 + %91 = OpCompositeExtract %v3float %89 1 + %92 = OpCompositeConstruct %mat2v3float %90 %91 + OpStore %86 %92 None + OpBranch %67 + %67 = OpLabel + %71 = OpIAdd %uint %70 %uint_1 + OpBranch %68 + %69 = OpLabel + %l_a = OpLoad %_arr_mat2v3float_uint_4 %61 None + %73 = OpCompositeExtract %float %l_a_i_i 0 + %74 = OpCompositeExtract %float %l_a 0 0 0 + %75 = OpFAdd %float %73 %74 + %76 = OpCompositeExtract %float %l_a_i 0 0 + %77 = OpFAdd %float %75 %76 + %78 = OpCompositeExtract %float %l_a_i_i 0 + %79 = OpFAdd %float %77 %78 + %80 = OpAccessChain %_ptr_StorageBuffer_float %10 %uint_0 + OpStore %80 %79 None OpReturn OpFunctionEnd -%tint_convert_explicit_layout = OpFunction %_arr_mat2x3_f32_std140_uint_4_0 None %91 +%tint_convert_explicit_layout = OpFunction %_arr_mat2x3_f32_std140_uint_4_0 None %94 %tint_source = OpFunctionParameter %_arr_mat2x3_f32_std140_uint_4 - %92 = OpLabel - %93 = OpVariable %_ptr_Function__arr_mat2x3_f32_std140_uint_4 Function - %95 = OpVariable %_ptr_Function__arr_mat2x3_f32_std140_uint_4_0 Function %96 - OpStore %93 %tint_source - OpBranch %97 - %97 = OpLabel + %95 = OpLabel + %96 = OpVariable %_ptr_Function__arr_mat2x3_f32_std140_uint_4 Function + %98 = OpVariable %_ptr_Function__arr_mat2x3_f32_std140_uint_4_0 Function %99 + OpStore %96 %tint_source OpBranch %100 %100 = OpLabel - %102 = OpPhi %uint %uint_0 %97 %103 %99 - OpLoopMerge %101 %99 None - OpBranch %98 - %98 = OpLabel - %105 = OpUGreaterThanEqual %bool %102 %uint_4 - OpSelectionMerge %106 None - OpBranchConditional %105 %107 %106 - %107 = OpLabel + OpBranch %103 + %103 = OpLabel + %105 = OpPhi %uint %uint_0 %100 %106 %102 + OpLoopMerge %104 %102 None OpBranch %101 - %106 = OpLabel - %108 = OpAccessChain %_ptr_Function_mat2x3_f32_std140 %93 %102 - %109 = OpLoad %mat2x3_f32_std140 %108 None - %110 = OpAccessChain %_ptr_Function_mat2x3_f32_std140 %95 %102 - OpStore %110 %109 None - OpBranch %99 - %99 = OpLabel - %103 = OpIAdd %uint %102 %uint_1 - OpBranch %100 %101 = OpLabel - %104 = OpLoad %_arr_mat2x3_f32_std140_uint_4_0 %95 None - OpReturnValue %104 + %108 = OpUGreaterThanEqual %bool %105 %uint_4 + OpSelectionMerge %109 None + OpBranchConditional %108 %110 %109 + %110 = OpLabel + OpBranch %104 + %109 = OpLabel + %111 = OpAccessChain %_ptr_Function_mat2x3_f32_std140 %96 %105 + %112 = OpLoad %mat2x3_f32_std140 %111 None + %113 = OpAccessChain %_ptr_Function_mat2x3_f32_std140 %98 %105 + OpStore %113 %112 None + OpBranch %102 + %102 = OpLabel + %106 = OpIAdd %uint %105 %uint_1 + OpBranch %103 + %104 = OpLabel + %107 = OpLoad %_arr_mat2x3_f32_std140_uint_4_0 %98 None + OpReturnValue %107 OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/array/mat2x4_f16/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/array/mat2x4_f16/dynamic_index_via_ptr.wgsl.expected.glsl index f1aaa4e..7f8cd057 100644 --- a/test/tint/buffer/uniform/std140/array/mat2x4_f16/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/array/mat2x4_f16/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -17,33 +17,34 @@ } v_1; int counter = 0; int i() { - counter = (counter + 1); + uint v_2 = uint(counter); + counter = int((v_2 + uint(1))); return counter; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - uint v_2 = min(uint(i()), 3u); - f16mat2x4 v_3 = f16mat2x4(v.inner[v_2].col0, v.inner[v_2].col1); - f16vec4 v_4 = v_3[min(uint(i()), 1u)]; - mat2x4_f16_std140 v_5[4] = v.inner; - f16mat2x4 v_6[4] = f16mat2x4[4](f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf)), f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf)), f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf)), f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))); + uint v_3 = min(uint(i()), 3u); + f16mat2x4 v_4 = f16mat2x4(v.inner[v_3].col0, v.inner[v_3].col1); + f16vec4 v_5 = v_4[min(uint(i()), 1u)]; + mat2x4_f16_std140 v_6[4] = v.inner; + f16mat2x4 v_7[4] = f16mat2x4[4](f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf)), f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf)), f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf)), f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))); { - uint v_7 = 0u; - v_7 = 0u; + uint v_8 = 0u; + v_8 = 0u; while(true) { - uint v_8 = v_7; - if ((v_8 >= 4u)) { + uint v_9 = v_8; + if ((v_9 >= 4u)) { break; } - v_6[v_8] = f16mat2x4(v_5[v_8].col0, v_5[v_8].col1); + v_7[v_9] = f16mat2x4(v_6[v_9].col0, v_6[v_9].col1); { - v_7 = (v_8 + 1u); + v_8 = (v_9 + 1u); } continue; } } - f16mat2x4 l_a[4] = v_6; - f16mat2x4 l_a_i = v_3; - f16vec4 l_a_i_i = v_4; - v_1.inner = (((v_4.x + l_a[0u][0u].x) + l_a_i[0u].x) + l_a_i_i.x); + f16mat2x4 l_a[4] = v_7; + f16mat2x4 l_a_i = v_4; + f16vec4 l_a_i_i = v_5; + v_1.inner = (((v_5.x + l_a[0u][0u].x) + l_a_i[0u].x) + l_a_i_i.x); }
diff --git a/test/tint/buffer/uniform/std140/array/mat2x4_f16/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/array/mat2x4_f16/dynamic_index_via_ptr.wgsl.expected.spvasm index c0d9b1c..8dc778a 100644 --- a/test/tint/buffer/uniform/std140/array/mat2x4_f16/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/array/mat2x4_f16/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,13 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 111 +; Bound: 114 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess - %34 = OpExtInstImport "GLSL.std.450" + %37 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -58,7 +58,7 @@ %18 = OpTypeFunction %int %int_1 = OpConstant %int 1 %void = OpTypeVoid - %26 = OpTypeFunction %void + %29 = OpTypeFunction %void %_ptr_Uniform__arr_mat2x4_f16_std140_uint_4 = OpTypePointer Uniform %_arr_mat2x4_f16_std140_uint_4 %uint_0 = OpConstant %uint 0 %uint_3 = OpConstant %uint 3 @@ -71,111 +71,114 @@ %_ptr_Function__arr_mat2x4_f16_std140_uint_4_0 = OpTypePointer Function %_arr_mat2x4_f16_std140_uint_4_0 %_arr_mat2v4half_uint_4 = OpTypeArray %mat2v4half %uint_4 %_ptr_Function__arr_mat2v4half_uint_4 = OpTypePointer Function %_arr_mat2v4half_uint_4 - %61 = OpConstantNull %_arr_mat2v4half_uint_4 + %64 = OpConstantNull %_arr_mat2v4half_uint_4 %_ptr_StorageBuffer_half = OpTypePointer StorageBuffer %half %bool = OpTypeBool %_ptr_Function_mat2x4_f16_std140 = OpTypePointer Function %mat2x4_f16_std140 - %91 = OpTypeFunction %_arr_mat2x4_f16_std140_uint_4_0 %_arr_mat2x4_f16_std140_uint_4 + %94 = OpTypeFunction %_arr_mat2x4_f16_std140_uint_4_0 %_arr_mat2x4_f16_std140_uint_4 %_ptr_Function__arr_mat2x4_f16_std140_uint_4 = OpTypePointer Function %_arr_mat2x4_f16_std140_uint_4 - %96 = OpConstantNull %_arr_mat2x4_f16_std140_uint_4_0 + %99 = OpConstantNull %_arr_mat2x4_f16_std140_uint_4_0 %i = OpFunction %int None %18 %19 = OpLabel %20 = OpLoad %int %counter None - %21 = OpIAdd %int %20 %int_1 - OpStore %counter %21 None - %23 = OpLoad %int %counter None - OpReturnValue %23 + %21 = OpBitcast %uint %20 + %22 = OpBitcast %uint %int_1 + %24 = OpIAdd %uint %21 %22 + %25 = OpBitcast %int %24 + OpStore %counter %25 None + %26 = OpLoad %int %counter None + OpReturnValue %26 OpFunctionEnd - %f = OpFunction %void None %26 - %27 = OpLabel - %44 = OpVariable %_ptr_Function_mat2v4half Function - %56 = OpVariable %_ptr_Function__arr_mat2x4_f16_std140_uint_4_0 Function - %58 = OpVariable %_ptr_Function__arr_mat2v4half_uint_4 Function %61 - %28 = OpAccessChain %_ptr_Uniform__arr_mat2x4_f16_std140_uint_4 %1 %uint_0 - %31 = OpFunctionCall %int %i - %32 = OpBitcast %uint %31 - %33 = OpExtInst %uint %34 UMin %32 %uint_3 - %36 = OpAccessChain %_ptr_Uniform_v4half %28 %33 %uint_0 - %38 = OpLoad %v4half %36 None - %39 = OpAccessChain %_ptr_Uniform_v4half %28 %33 %uint_1 + %f = OpFunction %void None %29 + %30 = OpLabel + %47 = OpVariable %_ptr_Function_mat2v4half Function + %59 = OpVariable %_ptr_Function__arr_mat2x4_f16_std140_uint_4_0 Function + %61 = OpVariable %_ptr_Function__arr_mat2v4half_uint_4 Function %64 + %31 = OpAccessChain %_ptr_Uniform__arr_mat2x4_f16_std140_uint_4 %1 %uint_0 + %34 = OpFunctionCall %int %i + %35 = OpBitcast %uint %34 + %36 = OpExtInst %uint %37 UMin %35 %uint_3 + %39 = OpAccessChain %_ptr_Uniform_v4half %31 %36 %uint_0 %41 = OpLoad %v4half %39 None - %l_a_i = OpCompositeConstruct %mat2v4half %38 %41 - OpStore %44 %l_a_i - %46 = OpFunctionCall %int %i - %47 = OpBitcast %uint %46 - %48 = OpExtInst %uint %34 UMin %47 %uint_1 - %49 = OpAccessChain %_ptr_Function_v4half %44 %48 - %l_a_i_i = OpLoad %v4half %49 None - %52 = OpLoad %_arr_mat2x4_f16_std140_uint_4 %28 None - %53 = OpFunctionCall %_arr_mat2x4_f16_std140_uint_4_0 %tint_convert_explicit_layout %52 - OpStore %56 %53 - OpBranch %62 - %62 = OpLabel + %42 = OpAccessChain %_ptr_Uniform_v4half %31 %36 %uint_1 + %44 = OpLoad %v4half %42 None + %l_a_i = OpCompositeConstruct %mat2v4half %41 %44 + OpStore %47 %l_a_i + %49 = OpFunctionCall %int %i + %50 = OpBitcast %uint %49 + %51 = OpExtInst %uint %37 UMin %50 %uint_1 + %52 = OpAccessChain %_ptr_Function_v4half %47 %51 + %l_a_i_i = OpLoad %v4half %52 None + %55 = OpLoad %_arr_mat2x4_f16_std140_uint_4 %31 None + %56 = OpFunctionCall %_arr_mat2x4_f16_std140_uint_4_0 %tint_convert_explicit_layout %55 + OpStore %59 %56 OpBranch %65 %65 = OpLabel - %67 = OpPhi %uint %uint_0 %62 %68 %64 - OpLoopMerge %66 %64 None - OpBranch %63 - %63 = OpLabel - %79 = OpUGreaterThanEqual %bool %67 %uint_4 - OpSelectionMerge %81 None - OpBranchConditional %79 %82 %81 - %82 = OpLabel + OpBranch %68 + %68 = OpLabel + %70 = OpPhi %uint %uint_0 %65 %71 %67 + OpLoopMerge %69 %67 None OpBranch %66 - %81 = OpLabel - %83 = OpAccessChain %_ptr_Function_mat2v4half %58 %67 - %84 = OpAccessChain %_ptr_Function_mat2x4_f16_std140 %56 %67 - %86 = OpLoad %mat2x4_f16_std140 %84 None - %87 = OpCompositeExtract %v4half %86 0 - %88 = OpCompositeExtract %v4half %86 1 - %89 = OpCompositeConstruct %mat2v4half %87 %88 - OpStore %83 %89 None - OpBranch %64 - %64 = OpLabel - %68 = OpIAdd %uint %67 %uint_1 - OpBranch %65 %66 = OpLabel - %l_a = OpLoad %_arr_mat2v4half_uint_4 %58 None - %70 = OpCompositeExtract %half %l_a_i_i 0 - %71 = OpCompositeExtract %half %l_a 0 0 0 - %72 = OpFAdd %half %70 %71 - %73 = OpCompositeExtract %half %l_a_i 0 0 - %74 = OpFAdd %half %72 %73 - %75 = OpCompositeExtract %half %l_a_i_i 0 - %76 = OpFAdd %half %74 %75 - %77 = OpAccessChain %_ptr_StorageBuffer_half %10 %uint_0 - OpStore %77 %76 None + %82 = OpUGreaterThanEqual %bool %70 %uint_4 + OpSelectionMerge %84 None + OpBranchConditional %82 %85 %84 + %85 = OpLabel + OpBranch %69 + %84 = OpLabel + %86 = OpAccessChain %_ptr_Function_mat2v4half %61 %70 + %87 = OpAccessChain %_ptr_Function_mat2x4_f16_std140 %59 %70 + %89 = OpLoad %mat2x4_f16_std140 %87 None + %90 = OpCompositeExtract %v4half %89 0 + %91 = OpCompositeExtract %v4half %89 1 + %92 = OpCompositeConstruct %mat2v4half %90 %91 + OpStore %86 %92 None + OpBranch %67 + %67 = OpLabel + %71 = OpIAdd %uint %70 %uint_1 + OpBranch %68 + %69 = OpLabel + %l_a = OpLoad %_arr_mat2v4half_uint_4 %61 None + %73 = OpCompositeExtract %half %l_a_i_i 0 + %74 = OpCompositeExtract %half %l_a 0 0 0 + %75 = OpFAdd %half %73 %74 + %76 = OpCompositeExtract %half %l_a_i 0 0 + %77 = OpFAdd %half %75 %76 + %78 = OpCompositeExtract %half %l_a_i_i 0 + %79 = OpFAdd %half %77 %78 + %80 = OpAccessChain %_ptr_StorageBuffer_half %10 %uint_0 + OpStore %80 %79 None OpReturn OpFunctionEnd -%tint_convert_explicit_layout = OpFunction %_arr_mat2x4_f16_std140_uint_4_0 None %91 +%tint_convert_explicit_layout = OpFunction %_arr_mat2x4_f16_std140_uint_4_0 None %94 %tint_source = OpFunctionParameter %_arr_mat2x4_f16_std140_uint_4 - %92 = OpLabel - %93 = OpVariable %_ptr_Function__arr_mat2x4_f16_std140_uint_4 Function - %95 = OpVariable %_ptr_Function__arr_mat2x4_f16_std140_uint_4_0 Function %96 - OpStore %93 %tint_source - OpBranch %97 - %97 = OpLabel + %95 = OpLabel + %96 = OpVariable %_ptr_Function__arr_mat2x4_f16_std140_uint_4 Function + %98 = OpVariable %_ptr_Function__arr_mat2x4_f16_std140_uint_4_0 Function %99 + OpStore %96 %tint_source OpBranch %100 %100 = OpLabel - %102 = OpPhi %uint %uint_0 %97 %103 %99 - OpLoopMerge %101 %99 None - OpBranch %98 - %98 = OpLabel - %105 = OpUGreaterThanEqual %bool %102 %uint_4 - OpSelectionMerge %106 None - OpBranchConditional %105 %107 %106 - %107 = OpLabel + OpBranch %103 + %103 = OpLabel + %105 = OpPhi %uint %uint_0 %100 %106 %102 + OpLoopMerge %104 %102 None OpBranch %101 - %106 = OpLabel - %108 = OpAccessChain %_ptr_Function_mat2x4_f16_std140 %93 %102 - %109 = OpLoad %mat2x4_f16_std140 %108 None - %110 = OpAccessChain %_ptr_Function_mat2x4_f16_std140 %95 %102 - OpStore %110 %109 None - OpBranch %99 - %99 = OpLabel - %103 = OpIAdd %uint %102 %uint_1 - OpBranch %100 %101 = OpLabel - %104 = OpLoad %_arr_mat2x4_f16_std140_uint_4_0 %95 None - OpReturnValue %104 + %108 = OpUGreaterThanEqual %bool %105 %uint_4 + OpSelectionMerge %109 None + OpBranchConditional %108 %110 %109 + %110 = OpLabel + OpBranch %104 + %109 = OpLabel + %111 = OpAccessChain %_ptr_Function_mat2x4_f16_std140 %96 %105 + %112 = OpLoad %mat2x4_f16_std140 %111 None + %113 = OpAccessChain %_ptr_Function_mat2x4_f16_std140 %98 %105 + OpStore %113 %112 None + OpBranch %102 + %102 = OpLabel + %106 = OpIAdd %uint %105 %uint_1 + OpBranch %103 + %104 = OpLabel + %107 = OpLoad %_arr_mat2x4_f16_std140_uint_4_0 %98 None + OpReturnValue %107 OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/array/mat2x4_f32/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/array/mat2x4_f32/dynamic_index_via_ptr.wgsl.expected.glsl index 766a0a9..fae4d36 100644 --- a/test/tint/buffer/uniform/std140/array/mat2x4_f32/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/array/mat2x4_f32/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -10,15 +10,16 @@ } v_1; int counter = 0; int i() { - counter = (counter + 1); + uint v_2 = uint(counter); + counter = int((v_2 + uint(1))); return counter; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - uint v_2 = min(uint(i()), 3u); - uint v_3 = min(uint(i()), 1u); + uint v_3 = min(uint(i()), 3u); + uint v_4 = min(uint(i()), 1u); mat2x4 l_a[4] = v.inner; - mat2x4 l_a_i = v.inner[v_2]; - vec4 l_a_i_i = v.inner[v_2][v_3]; - v_1.inner = (((v.inner[v_2][v_3].x + l_a[0u][0u].x) + l_a_i[0u].x) + l_a_i_i.x); + mat2x4 l_a_i = v.inner[v_3]; + vec4 l_a_i_i = v.inner[v_3][v_4]; + v_1.inner = (((v.inner[v_3][v_4].x + l_a[0u][0u].x) + l_a_i[0u].x) + l_a_i_i.x); }
diff --git a/test/tint/buffer/uniform/std140/array/mat2x4_f32/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/array/mat2x4_f32/dynamic_index_via_ptr.wgsl.expected.spvasm index f4bf821..f43bf49 100644 --- a/test/tint/buffer/uniform/std140/array/mat2x4_f32/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/array/mat2x4_f32/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,10 +1,10 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 85 +; Bound: 88 ; Schema: 0 OpCapability Shader - %34 = OpExtInstImport "GLSL.std.450" + %37 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -55,7 +55,7 @@ %18 = OpTypeFunction %int %int_1 = OpConstant %int 1 %void = OpTypeVoid - %26 = OpTypeFunction %void + %29 = OpTypeFunction %void %_ptr_Uniform__arr_mat2v4float_uint_4 = OpTypePointer Uniform %_arr_mat2v4float_uint_4 %uint_0 = OpConstant %uint 0 %uint_3 = OpConstant %uint 3 @@ -65,76 +65,79 @@ %_arr_mat2v4float_uint_4_0 = OpTypeArray %mat2v4float %uint_4 %_ptr_Uniform_float = OpTypePointer Uniform %float %_ptr_StorageBuffer_float = OpTypePointer StorageBuffer %float - %62 = OpTypeFunction %_arr_mat2v4float_uint_4_0 %_arr_mat2v4float_uint_4 + %65 = OpTypeFunction %_arr_mat2v4float_uint_4_0 %_arr_mat2v4float_uint_4 %_ptr_Function__arr_mat2v4float_uint_4 = OpTypePointer Function %_arr_mat2v4float_uint_4 %_ptr_Function__arr_mat2v4float_uint_4_0 = OpTypePointer Function %_arr_mat2v4float_uint_4_0 - %68 = OpConstantNull %_arr_mat2v4float_uint_4_0 + %71 = OpConstantNull %_arr_mat2v4float_uint_4_0 %bool = OpTypeBool %_ptr_Function_mat2v4float = OpTypePointer Function %mat2v4float %i = OpFunction %int None %18 %19 = OpLabel %20 = OpLoad %int %counter None - %21 = OpIAdd %int %20 %int_1 - OpStore %counter %21 None - %23 = OpLoad %int %counter None - OpReturnValue %23 + %21 = OpBitcast %uint %20 + %22 = OpBitcast %uint %int_1 + %24 = OpIAdd %uint %21 %22 + %25 = OpBitcast %int %24 + OpStore %counter %25 None + %26 = OpLoad %int %counter None + OpReturnValue %26 OpFunctionEnd - %f = OpFunction %void None %26 - %27 = OpLabel + %f = OpFunction %void None %29 + %30 = OpLabel %p_a = OpAccessChain %_ptr_Uniform__arr_mat2v4float_uint_4 %1 %uint_0 - %31 = OpFunctionCall %int %i - %32 = OpBitcast %uint %31 - %33 = OpExtInst %uint %34 UMin %32 %uint_3 - %p_a_i = OpAccessChain %_ptr_Uniform_mat2v4float %p_a %33 - %38 = OpFunctionCall %int %i - %39 = OpBitcast %uint %38 - %40 = OpExtInst %uint %34 UMin %39 %uint_1 - %p_a_i_i = OpAccessChain %_ptr_Uniform_v4float %p_a_i %40 - %44 = OpLoad %_arr_mat2v4float_uint_4 %p_a None - %l_a = OpFunctionCall %_arr_mat2v4float_uint_4_0 %tint_convert_explicit_layout %44 + %34 = OpFunctionCall %int %i + %35 = OpBitcast %uint %34 + %36 = OpExtInst %uint %37 UMin %35 %uint_3 + %p_a_i = OpAccessChain %_ptr_Uniform_mat2v4float %p_a %36 + %41 = OpFunctionCall %int %i + %42 = OpBitcast %uint %41 + %43 = OpExtInst %uint %37 UMin %42 %uint_1 + %p_a_i_i = OpAccessChain %_ptr_Uniform_v4float %p_a_i %43 + %47 = OpLoad %_arr_mat2v4float_uint_4 %p_a None + %l_a = OpFunctionCall %_arr_mat2v4float_uint_4_0 %tint_convert_explicit_layout %47 %l_a_i = OpLoad %mat2v4float %p_a_i None %l_a_i_i = OpLoad %v4float %p_a_i_i None - %50 = OpAccessChain %_ptr_Uniform_float %p_a_i_i %uint_0 - %52 = OpLoad %float %50 None - %53 = OpCompositeExtract %float %l_a 0 0 0 - %54 = OpFAdd %float %52 %53 - %55 = OpCompositeExtract %float %l_a_i 0 0 - %56 = OpFAdd %float %54 %55 - %57 = OpCompositeExtract %float %l_a_i_i 0 - %58 = OpFAdd %float %56 %57 - %59 = OpAccessChain %_ptr_StorageBuffer_float %10 %uint_0 - OpStore %59 %58 None + %53 = OpAccessChain %_ptr_Uniform_float %p_a_i_i %uint_0 + %55 = OpLoad %float %53 None + %56 = OpCompositeExtract %float %l_a 0 0 0 + %57 = OpFAdd %float %55 %56 + %58 = OpCompositeExtract %float %l_a_i 0 0 + %59 = OpFAdd %float %57 %58 + %60 = OpCompositeExtract %float %l_a_i_i 0 + %61 = OpFAdd %float %59 %60 + %62 = OpAccessChain %_ptr_StorageBuffer_float %10 %uint_0 + OpStore %62 %61 None OpReturn OpFunctionEnd -%tint_convert_explicit_layout = OpFunction %_arr_mat2v4float_uint_4_0 None %62 +%tint_convert_explicit_layout = OpFunction %_arr_mat2v4float_uint_4_0 None %65 %tint_source = OpFunctionParameter %_arr_mat2v4float_uint_4 - %63 = OpLabel - %64 = OpVariable %_ptr_Function__arr_mat2v4float_uint_4 Function - %66 = OpVariable %_ptr_Function__arr_mat2v4float_uint_4_0 Function %68 - OpStore %64 %tint_source - OpBranch %69 - %69 = OpLabel + %66 = OpLabel + %67 = OpVariable %_ptr_Function__arr_mat2v4float_uint_4 Function + %69 = OpVariable %_ptr_Function__arr_mat2v4float_uint_4_0 Function %71 + OpStore %67 %tint_source OpBranch %72 %72 = OpLabel - %74 = OpPhi %uint %uint_0 %69 %75 %71 - OpLoopMerge %73 %71 None - OpBranch %70 - %70 = OpLabel - %77 = OpUGreaterThanEqual %bool %74 %uint_4 - OpSelectionMerge %79 None - OpBranchConditional %77 %80 %79 - %80 = OpLabel + OpBranch %75 + %75 = OpLabel + %77 = OpPhi %uint %uint_0 %72 %78 %74 + OpLoopMerge %76 %74 None OpBranch %73 - %79 = OpLabel - %81 = OpAccessChain %_ptr_Function_mat2v4float %64 %74 - %83 = OpLoad %mat2v4float %81 None - %84 = OpAccessChain %_ptr_Function_mat2v4float %66 %74 - OpStore %84 %83 None - OpBranch %71 - %71 = OpLabel - %75 = OpIAdd %uint %74 %uint_1 - OpBranch %72 %73 = OpLabel - %76 = OpLoad %_arr_mat2v4float_uint_4_0 %66 None - OpReturnValue %76 + %80 = OpUGreaterThanEqual %bool %77 %uint_4 + OpSelectionMerge %82 None + OpBranchConditional %80 %83 %82 + %83 = OpLabel + OpBranch %76 + %82 = OpLabel + %84 = OpAccessChain %_ptr_Function_mat2v4float %67 %77 + %86 = OpLoad %mat2v4float %84 None + %87 = OpAccessChain %_ptr_Function_mat2v4float %69 %77 + OpStore %87 %86 None + OpBranch %74 + %74 = OpLabel + %78 = OpIAdd %uint %77 %uint_1 + OpBranch %75 + %76 = OpLabel + %79 = OpLoad %_arr_mat2v4float_uint_4_0 %69 None + OpReturnValue %79 OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/array/mat3x3_f32/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/array/mat3x3_f32/dynamic_index_via_ptr.wgsl.expected.glsl index 9160a6c..a795335 100644 --- a/test/tint/buffer/uniform/std140/array/mat3x3_f32/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/array/mat3x3_f32/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -20,33 +20,34 @@ } v_1; int counter = 0; int i() { - counter = (counter + 1); + uint v_2 = uint(counter); + counter = int((v_2 + uint(1))); return counter; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - uint v_2 = min(uint(i()), 3u); - mat3 v_3 = mat3(v.inner[v_2].col0, v.inner[v_2].col1, v.inner[v_2].col2); - vec3 v_4 = v_3[min(uint(i()), 2u)]; - mat3x3_f32_std140 v_5[4] = v.inner; - mat3 v_6[4] = mat3[4](mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f)), mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f)), mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f)), mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))); + uint v_3 = min(uint(i()), 3u); + mat3 v_4 = mat3(v.inner[v_3].col0, v.inner[v_3].col1, v.inner[v_3].col2); + vec3 v_5 = v_4[min(uint(i()), 2u)]; + mat3x3_f32_std140 v_6[4] = v.inner; + mat3 v_7[4] = mat3[4](mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f)), mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f)), mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f)), mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))); { - uint v_7 = 0u; - v_7 = 0u; + uint v_8 = 0u; + v_8 = 0u; while(true) { - uint v_8 = v_7; - if ((v_8 >= 4u)) { + uint v_9 = v_8; + if ((v_9 >= 4u)) { break; } - v_6[v_8] = mat3(v_5[v_8].col0, v_5[v_8].col1, v_5[v_8].col2); + v_7[v_9] = mat3(v_6[v_9].col0, v_6[v_9].col1, v_6[v_9].col2); { - v_7 = (v_8 + 1u); + v_8 = (v_9 + 1u); } continue; } } - mat3 l_a[4] = v_6; - mat3 l_a_i = v_3; - vec3 l_a_i_i = v_4; - v_1.inner = (((v_4.x + l_a[0u][0u].x) + l_a_i[0u].x) + l_a_i_i.x); + mat3 l_a[4] = v_7; + mat3 l_a_i = v_4; + vec3 l_a_i_i = v_5; + v_1.inner = (((v_5.x + l_a[0u][0u].x) + l_a_i[0u].x) + l_a_i_i.x); }
diff --git a/test/tint/buffer/uniform/std140/array/mat3x3_f32/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/array/mat3x3_f32/dynamic_index_via_ptr.wgsl.expected.spvasm index 81a5773..3833506 100644 --- a/test/tint/buffer/uniform/std140/array/mat3x3_f32/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/array/mat3x3_f32/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,10 +1,10 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 115 +; Bound: 118 ; Schema: 0 OpCapability Shader - %34 = OpExtInstImport "GLSL.std.450" + %37 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -57,7 +57,7 @@ %18 = OpTypeFunction %int %int_1 = OpConstant %int 1 %void = OpTypeVoid - %26 = OpTypeFunction %void + %29 = OpTypeFunction %void %_ptr_Uniform__arr_mat3x3_f32_std140_uint_4 = OpTypePointer Uniform %_arr_mat3x3_f32_std140_uint_4 %uint_0 = OpConstant %uint 0 %uint_3 = OpConstant %uint 3 @@ -71,114 +71,117 @@ %_ptr_Function__arr_mat3x3_f32_std140_uint_4_0 = OpTypePointer Function %_arr_mat3x3_f32_std140_uint_4_0 %_arr_mat3v3float_uint_4 = OpTypeArray %mat3v3float %uint_4 %_ptr_Function__arr_mat3v3float_uint_4 = OpTypePointer Function %_arr_mat3v3float_uint_4 - %64 = OpConstantNull %_arr_mat3v3float_uint_4 + %67 = OpConstantNull %_arr_mat3v3float_uint_4 %_ptr_StorageBuffer_float = OpTypePointer StorageBuffer %float %bool = OpTypeBool %_ptr_Function_mat3x3_f32_std140 = OpTypePointer Function %mat3x3_f32_std140 - %95 = OpTypeFunction %_arr_mat3x3_f32_std140_uint_4_0 %_arr_mat3x3_f32_std140_uint_4 + %98 = OpTypeFunction %_arr_mat3x3_f32_std140_uint_4_0 %_arr_mat3x3_f32_std140_uint_4 %_ptr_Function__arr_mat3x3_f32_std140_uint_4 = OpTypePointer Function %_arr_mat3x3_f32_std140_uint_4 - %100 = OpConstantNull %_arr_mat3x3_f32_std140_uint_4_0 + %103 = OpConstantNull %_arr_mat3x3_f32_std140_uint_4_0 %i = OpFunction %int None %18 %19 = OpLabel %20 = OpLoad %int %counter None - %21 = OpIAdd %int %20 %int_1 - OpStore %counter %21 None - %23 = OpLoad %int %counter None - OpReturnValue %23 + %21 = OpBitcast %uint %20 + %22 = OpBitcast %uint %int_1 + %24 = OpIAdd %uint %21 %22 + %25 = OpBitcast %int %24 + OpStore %counter %25 None + %26 = OpLoad %int %counter None + OpReturnValue %26 OpFunctionEnd - %f = OpFunction %void None %26 - %27 = OpLabel - %47 = OpVariable %_ptr_Function_mat3v3float Function - %59 = OpVariable %_ptr_Function__arr_mat3x3_f32_std140_uint_4_0 Function - %61 = OpVariable %_ptr_Function__arr_mat3v3float_uint_4 Function %64 - %28 = OpAccessChain %_ptr_Uniform__arr_mat3x3_f32_std140_uint_4 %1 %uint_0 - %31 = OpFunctionCall %int %i - %32 = OpBitcast %uint %31 - %33 = OpExtInst %uint %34 UMin %32 %uint_3 - %36 = OpAccessChain %_ptr_Uniform_v3float %28 %33 %uint_0 - %38 = OpLoad %v3float %36 None - %39 = OpAccessChain %_ptr_Uniform_v3float %28 %33 %uint_1 + %f = OpFunction %void None %29 + %30 = OpLabel + %50 = OpVariable %_ptr_Function_mat3v3float Function + %62 = OpVariable %_ptr_Function__arr_mat3x3_f32_std140_uint_4_0 Function + %64 = OpVariable %_ptr_Function__arr_mat3v3float_uint_4 Function %67 + %31 = OpAccessChain %_ptr_Uniform__arr_mat3x3_f32_std140_uint_4 %1 %uint_0 + %34 = OpFunctionCall %int %i + %35 = OpBitcast %uint %34 + %36 = OpExtInst %uint %37 UMin %35 %uint_3 + %39 = OpAccessChain %_ptr_Uniform_v3float %31 %36 %uint_0 %41 = OpLoad %v3float %39 None - %42 = OpAccessChain %_ptr_Uniform_v3float %28 %33 %uint_2 + %42 = OpAccessChain %_ptr_Uniform_v3float %31 %36 %uint_1 %44 = OpLoad %v3float %42 None - %l_a_i = OpCompositeConstruct %mat3v3float %38 %41 %44 - OpStore %47 %l_a_i - %49 = OpFunctionCall %int %i - %50 = OpBitcast %uint %49 - %51 = OpExtInst %uint %34 UMin %50 %uint_2 - %52 = OpAccessChain %_ptr_Function_v3float %47 %51 - %l_a_i_i = OpLoad %v3float %52 None - %55 = OpLoad %_arr_mat3x3_f32_std140_uint_4 %28 None - %56 = OpFunctionCall %_arr_mat3x3_f32_std140_uint_4_0 %tint_convert_explicit_layout %55 - OpStore %59 %56 - OpBranch %65 - %65 = OpLabel + %45 = OpAccessChain %_ptr_Uniform_v3float %31 %36 %uint_2 + %47 = OpLoad %v3float %45 None + %l_a_i = OpCompositeConstruct %mat3v3float %41 %44 %47 + OpStore %50 %l_a_i + %52 = OpFunctionCall %int %i + %53 = OpBitcast %uint %52 + %54 = OpExtInst %uint %37 UMin %53 %uint_2 + %55 = OpAccessChain %_ptr_Function_v3float %50 %54 + %l_a_i_i = OpLoad %v3float %55 None + %58 = OpLoad %_arr_mat3x3_f32_std140_uint_4 %31 None + %59 = OpFunctionCall %_arr_mat3x3_f32_std140_uint_4_0 %tint_convert_explicit_layout %58 + OpStore %62 %59 OpBranch %68 %68 = OpLabel - %70 = OpPhi %uint %uint_0 %65 %71 %67 - OpLoopMerge %69 %67 None - OpBranch %66 - %66 = OpLabel - %82 = OpUGreaterThanEqual %bool %70 %uint_4 - OpSelectionMerge %84 None - OpBranchConditional %82 %85 %84 - %85 = OpLabel + OpBranch %71 + %71 = OpLabel + %73 = OpPhi %uint %uint_0 %68 %74 %70 + OpLoopMerge %72 %70 None OpBranch %69 - %84 = OpLabel - %86 = OpAccessChain %_ptr_Function_mat3v3float %61 %70 - %87 = OpAccessChain %_ptr_Function_mat3x3_f32_std140 %59 %70 - %89 = OpLoad %mat3x3_f32_std140 %87 None - %90 = OpCompositeExtract %v3float %89 0 - %91 = OpCompositeExtract %v3float %89 1 - %92 = OpCompositeExtract %v3float %89 2 - %93 = OpCompositeConstruct %mat3v3float %90 %91 %92 - OpStore %86 %93 None - OpBranch %67 - %67 = OpLabel - %71 = OpIAdd %uint %70 %uint_1 - OpBranch %68 %69 = OpLabel - %l_a = OpLoad %_arr_mat3v3float_uint_4 %61 None - %73 = OpCompositeExtract %float %l_a_i_i 0 - %74 = OpCompositeExtract %float %l_a 0 0 0 - %75 = OpFAdd %float %73 %74 - %76 = OpCompositeExtract %float %l_a_i 0 0 - %77 = OpFAdd %float %75 %76 - %78 = OpCompositeExtract %float %l_a_i_i 0 - %79 = OpFAdd %float %77 %78 - %80 = OpAccessChain %_ptr_StorageBuffer_float %10 %uint_0 - OpStore %80 %79 None + %85 = OpUGreaterThanEqual %bool %73 %uint_4 + OpSelectionMerge %87 None + OpBranchConditional %85 %88 %87 + %88 = OpLabel + OpBranch %72 + %87 = OpLabel + %89 = OpAccessChain %_ptr_Function_mat3v3float %64 %73 + %90 = OpAccessChain %_ptr_Function_mat3x3_f32_std140 %62 %73 + %92 = OpLoad %mat3x3_f32_std140 %90 None + %93 = OpCompositeExtract %v3float %92 0 + %94 = OpCompositeExtract %v3float %92 1 + %95 = OpCompositeExtract %v3float %92 2 + %96 = OpCompositeConstruct %mat3v3float %93 %94 %95 + OpStore %89 %96 None + OpBranch %70 + %70 = OpLabel + %74 = OpIAdd %uint %73 %uint_1 + OpBranch %71 + %72 = OpLabel + %l_a = OpLoad %_arr_mat3v3float_uint_4 %64 None + %76 = OpCompositeExtract %float %l_a_i_i 0 + %77 = OpCompositeExtract %float %l_a 0 0 0 + %78 = OpFAdd %float %76 %77 + %79 = OpCompositeExtract %float %l_a_i 0 0 + %80 = OpFAdd %float %78 %79 + %81 = OpCompositeExtract %float %l_a_i_i 0 + %82 = OpFAdd %float %80 %81 + %83 = OpAccessChain %_ptr_StorageBuffer_float %10 %uint_0 + OpStore %83 %82 None OpReturn OpFunctionEnd -%tint_convert_explicit_layout = OpFunction %_arr_mat3x3_f32_std140_uint_4_0 None %95 +%tint_convert_explicit_layout = OpFunction %_arr_mat3x3_f32_std140_uint_4_0 None %98 %tint_source = OpFunctionParameter %_arr_mat3x3_f32_std140_uint_4 - %96 = OpLabel - %97 = OpVariable %_ptr_Function__arr_mat3x3_f32_std140_uint_4 Function - %99 = OpVariable %_ptr_Function__arr_mat3x3_f32_std140_uint_4_0 Function %100 - OpStore %97 %tint_source - OpBranch %101 - %101 = OpLabel + %99 = OpLabel + %100 = OpVariable %_ptr_Function__arr_mat3x3_f32_std140_uint_4 Function + %102 = OpVariable %_ptr_Function__arr_mat3x3_f32_std140_uint_4_0 Function %103 + OpStore %100 %tint_source OpBranch %104 %104 = OpLabel - %106 = OpPhi %uint %uint_0 %101 %107 %103 - OpLoopMerge %105 %103 None - OpBranch %102 - %102 = OpLabel - %109 = OpUGreaterThanEqual %bool %106 %uint_4 - OpSelectionMerge %110 None - OpBranchConditional %109 %111 %110 - %111 = OpLabel + OpBranch %107 + %107 = OpLabel + %109 = OpPhi %uint %uint_0 %104 %110 %106 + OpLoopMerge %108 %106 None OpBranch %105 - %110 = OpLabel - %112 = OpAccessChain %_ptr_Function_mat3x3_f32_std140 %97 %106 - %113 = OpLoad %mat3x3_f32_std140 %112 None - %114 = OpAccessChain %_ptr_Function_mat3x3_f32_std140 %99 %106 - OpStore %114 %113 None - OpBranch %103 - %103 = OpLabel - %107 = OpIAdd %uint %106 %uint_1 - OpBranch %104 %105 = OpLabel - %108 = OpLoad %_arr_mat3x3_f32_std140_uint_4_0 %99 None - OpReturnValue %108 + %112 = OpUGreaterThanEqual %bool %109 %uint_4 + OpSelectionMerge %113 None + OpBranchConditional %112 %114 %113 + %114 = OpLabel + OpBranch %108 + %113 = OpLabel + %115 = OpAccessChain %_ptr_Function_mat3x3_f32_std140 %100 %109 + %116 = OpLoad %mat3x3_f32_std140 %115 None + %117 = OpAccessChain %_ptr_Function_mat3x3_f32_std140 %102 %109 + OpStore %117 %116 None + OpBranch %106 + %106 = OpLabel + %110 = OpIAdd %uint %109 %uint_1 + OpBranch %107 + %108 = OpLabel + %111 = OpLoad %_arr_mat3x3_f32_std140_uint_4_0 %102 None + OpReturnValue %111 OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/array/mat3x4_f32/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/array/mat3x4_f32/dynamic_index_via_ptr.wgsl.expected.glsl index 0e02c7d..3dec4d6 100644 --- a/test/tint/buffer/uniform/std140/array/mat3x4_f32/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/array/mat3x4_f32/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -10,15 +10,16 @@ } v_1; int counter = 0; int i() { - counter = (counter + 1); + uint v_2 = uint(counter); + counter = int((v_2 + uint(1))); return counter; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - uint v_2 = min(uint(i()), 3u); - uint v_3 = min(uint(i()), 2u); + uint v_3 = min(uint(i()), 3u); + uint v_4 = min(uint(i()), 2u); mat3x4 l_a[4] = v.inner; - mat3x4 l_a_i = v.inner[v_2]; - vec4 l_a_i_i = v.inner[v_2][v_3]; - v_1.inner = (((v.inner[v_2][v_3].x + l_a[0u][0u].x) + l_a_i[0u].x) + l_a_i_i.x); + mat3x4 l_a_i = v.inner[v_3]; + vec4 l_a_i_i = v.inner[v_3][v_4]; + v_1.inner = (((v.inner[v_3][v_4].x + l_a[0u][0u].x) + l_a_i[0u].x) + l_a_i_i.x); }
diff --git a/test/tint/buffer/uniform/std140/array/mat3x4_f32/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/array/mat3x4_f32/dynamic_index_via_ptr.wgsl.expected.spvasm index 2ac6f4f..32e7e93 100644 --- a/test/tint/buffer/uniform/std140/array/mat3x4_f32/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/array/mat3x4_f32/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,10 +1,10 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 86 +; Bound: 89 ; Schema: 0 OpCapability Shader - %34 = OpExtInstImport "GLSL.std.450" + %37 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -55,7 +55,7 @@ %18 = OpTypeFunction %int %int_1 = OpConstant %int 1 %void = OpTypeVoid - %26 = OpTypeFunction %void + %29 = OpTypeFunction %void %_ptr_Uniform__arr_mat3v4float_uint_4 = OpTypePointer Uniform %_arr_mat3v4float_uint_4 %uint_0 = OpConstant %uint 0 %uint_3 = OpConstant %uint 3 @@ -65,77 +65,80 @@ %_arr_mat3v4float_uint_4_0 = OpTypeArray %mat3v4float %uint_4 %_ptr_Uniform_float = OpTypePointer Uniform %float %_ptr_StorageBuffer_float = OpTypePointer StorageBuffer %float - %62 = OpTypeFunction %_arr_mat3v4float_uint_4_0 %_arr_mat3v4float_uint_4 + %65 = OpTypeFunction %_arr_mat3v4float_uint_4_0 %_arr_mat3v4float_uint_4 %_ptr_Function__arr_mat3v4float_uint_4 = OpTypePointer Function %_arr_mat3v4float_uint_4 %_ptr_Function__arr_mat3v4float_uint_4_0 = OpTypePointer Function %_arr_mat3v4float_uint_4_0 - %68 = OpConstantNull %_arr_mat3v4float_uint_4_0 + %71 = OpConstantNull %_arr_mat3v4float_uint_4_0 %bool = OpTypeBool %_ptr_Function_mat3v4float = OpTypePointer Function %mat3v4float %uint_1 = OpConstant %uint 1 %i = OpFunction %int None %18 %19 = OpLabel %20 = OpLoad %int %counter None - %21 = OpIAdd %int %20 %int_1 - OpStore %counter %21 None - %23 = OpLoad %int %counter None - OpReturnValue %23 + %21 = OpBitcast %uint %20 + %22 = OpBitcast %uint %int_1 + %24 = OpIAdd %uint %21 %22 + %25 = OpBitcast %int %24 + OpStore %counter %25 None + %26 = OpLoad %int %counter None + OpReturnValue %26 OpFunctionEnd - %f = OpFunction %void None %26 - %27 = OpLabel + %f = OpFunction %void None %29 + %30 = OpLabel %p_a = OpAccessChain %_ptr_Uniform__arr_mat3v4float_uint_4 %1 %uint_0 - %31 = OpFunctionCall %int %i - %32 = OpBitcast %uint %31 - %33 = OpExtInst %uint %34 UMin %32 %uint_3 - %p_a_i = OpAccessChain %_ptr_Uniform_mat3v4float %p_a %33 - %38 = OpFunctionCall %int %i - %39 = OpBitcast %uint %38 - %40 = OpExtInst %uint %34 UMin %39 %uint_2 - %p_a_i_i = OpAccessChain %_ptr_Uniform_v4float %p_a_i %40 - %44 = OpLoad %_arr_mat3v4float_uint_4 %p_a None - %l_a = OpFunctionCall %_arr_mat3v4float_uint_4_0 %tint_convert_explicit_layout %44 + %34 = OpFunctionCall %int %i + %35 = OpBitcast %uint %34 + %36 = OpExtInst %uint %37 UMin %35 %uint_3 + %p_a_i = OpAccessChain %_ptr_Uniform_mat3v4float %p_a %36 + %41 = OpFunctionCall %int %i + %42 = OpBitcast %uint %41 + %43 = OpExtInst %uint %37 UMin %42 %uint_2 + %p_a_i_i = OpAccessChain %_ptr_Uniform_v4float %p_a_i %43 + %47 = OpLoad %_arr_mat3v4float_uint_4 %p_a None + %l_a = OpFunctionCall %_arr_mat3v4float_uint_4_0 %tint_convert_explicit_layout %47 %l_a_i = OpLoad %mat3v4float %p_a_i None %l_a_i_i = OpLoad %v4float %p_a_i_i None - %50 = OpAccessChain %_ptr_Uniform_float %p_a_i_i %uint_0 - %52 = OpLoad %float %50 None - %53 = OpCompositeExtract %float %l_a 0 0 0 - %54 = OpFAdd %float %52 %53 - %55 = OpCompositeExtract %float %l_a_i 0 0 - %56 = OpFAdd %float %54 %55 - %57 = OpCompositeExtract %float %l_a_i_i 0 - %58 = OpFAdd %float %56 %57 - %59 = OpAccessChain %_ptr_StorageBuffer_float %10 %uint_0 - OpStore %59 %58 None + %53 = OpAccessChain %_ptr_Uniform_float %p_a_i_i %uint_0 + %55 = OpLoad %float %53 None + %56 = OpCompositeExtract %float %l_a 0 0 0 + %57 = OpFAdd %float %55 %56 + %58 = OpCompositeExtract %float %l_a_i 0 0 + %59 = OpFAdd %float %57 %58 + %60 = OpCompositeExtract %float %l_a_i_i 0 + %61 = OpFAdd %float %59 %60 + %62 = OpAccessChain %_ptr_StorageBuffer_float %10 %uint_0 + OpStore %62 %61 None OpReturn OpFunctionEnd -%tint_convert_explicit_layout = OpFunction %_arr_mat3v4float_uint_4_0 None %62 +%tint_convert_explicit_layout = OpFunction %_arr_mat3v4float_uint_4_0 None %65 %tint_source = OpFunctionParameter %_arr_mat3v4float_uint_4 - %63 = OpLabel - %64 = OpVariable %_ptr_Function__arr_mat3v4float_uint_4 Function - %66 = OpVariable %_ptr_Function__arr_mat3v4float_uint_4_0 Function %68 - OpStore %64 %tint_source - OpBranch %69 - %69 = OpLabel + %66 = OpLabel + %67 = OpVariable %_ptr_Function__arr_mat3v4float_uint_4 Function + %69 = OpVariable %_ptr_Function__arr_mat3v4float_uint_4_0 Function %71 + OpStore %67 %tint_source OpBranch %72 %72 = OpLabel - %74 = OpPhi %uint %uint_0 %69 %75 %71 - OpLoopMerge %73 %71 None - OpBranch %70 - %70 = OpLabel - %77 = OpUGreaterThanEqual %bool %74 %uint_4 - OpSelectionMerge %79 None - OpBranchConditional %77 %80 %79 - %80 = OpLabel + OpBranch %75 + %75 = OpLabel + %77 = OpPhi %uint %uint_0 %72 %78 %74 + OpLoopMerge %76 %74 None OpBranch %73 - %79 = OpLabel - %81 = OpAccessChain %_ptr_Function_mat3v4float %64 %74 - %83 = OpLoad %mat3v4float %81 None - %84 = OpAccessChain %_ptr_Function_mat3v4float %66 %74 - OpStore %84 %83 None - OpBranch %71 - %71 = OpLabel - %75 = OpIAdd %uint %74 %uint_1 - OpBranch %72 %73 = OpLabel - %76 = OpLoad %_arr_mat3v4float_uint_4_0 %66 None - OpReturnValue %76 + %80 = OpUGreaterThanEqual %bool %77 %uint_4 + OpSelectionMerge %82 None + OpBranchConditional %80 %83 %82 + %83 = OpLabel + OpBranch %76 + %82 = OpLabel + %84 = OpAccessChain %_ptr_Function_mat3v4float %67 %77 + %86 = OpLoad %mat3v4float %84 None + %87 = OpAccessChain %_ptr_Function_mat3v4float %69 %77 + OpStore %87 %86 None + OpBranch %74 + %74 = OpLabel + %78 = OpIAdd %uint %77 %uint_1 + OpBranch %75 + %76 = OpLabel + %79 = OpLoad %_arr_mat3v4float_uint_4_0 %69 None + OpReturnValue %79 OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/array/mat4x2_f16/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/array/mat4x2_f16/dynamic_index_via_ptr.wgsl.expected.glsl index 2282894..928ecfc 100644 --- a/test/tint/buffer/uniform/std140/array/mat4x2_f16/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/array/mat4x2_f16/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -19,33 +19,34 @@ } v_1; int counter = 0; int i() { - counter = (counter + 1); + uint v_2 = uint(counter); + counter = int((v_2 + uint(1))); return counter; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - uint v_2 = min(uint(i()), 3u); - f16mat4x2 v_3 = f16mat4x2(v.inner[v_2].col0, v.inner[v_2].col1, v.inner[v_2].col2, v.inner[v_2].col3); - f16vec2 v_4 = v_3[min(uint(i()), 3u)]; - mat4x2_f16_std140 v_5[4] = v.inner; - f16mat4x2 v_6[4] = f16mat4x2[4](f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf)), f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf)), f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf)), f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))); + uint v_3 = min(uint(i()), 3u); + f16mat4x2 v_4 = f16mat4x2(v.inner[v_3].col0, v.inner[v_3].col1, v.inner[v_3].col2, v.inner[v_3].col3); + f16vec2 v_5 = v_4[min(uint(i()), 3u)]; + mat4x2_f16_std140 v_6[4] = v.inner; + f16mat4x2 v_7[4] = f16mat4x2[4](f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf)), f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf)), f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf)), f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))); { - uint v_7 = 0u; - v_7 = 0u; + uint v_8 = 0u; + v_8 = 0u; while(true) { - uint v_8 = v_7; - if ((v_8 >= 4u)) { + uint v_9 = v_8; + if ((v_9 >= 4u)) { break; } - v_6[v_8] = f16mat4x2(v_5[v_8].col0, v_5[v_8].col1, v_5[v_8].col2, v_5[v_8].col3); + v_7[v_9] = f16mat4x2(v_6[v_9].col0, v_6[v_9].col1, v_6[v_9].col2, v_6[v_9].col3); { - v_7 = (v_8 + 1u); + v_8 = (v_9 + 1u); } continue; } } - f16mat4x2 l_a[4] = v_6; - f16mat4x2 l_a_i = v_3; - f16vec2 l_a_i_i = v_4; - v_1.inner = (((v_4.x + l_a[0u][0u].x) + l_a_i[0u].x) + l_a_i_i.x); + f16mat4x2 l_a[4] = v_7; + f16mat4x2 l_a_i = v_4; + f16vec2 l_a_i_i = v_5; + v_1.inner = (((v_5.x + l_a[0u][0u].x) + l_a_i[0u].x) + l_a_i_i.x); }
diff --git a/test/tint/buffer/uniform/std140/array/mat4x2_f16/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/array/mat4x2_f16/dynamic_index_via_ptr.wgsl.expected.spvasm index 167cfdc..681edc1 100644 --- a/test/tint/buffer/uniform/std140/array/mat4x2_f16/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/array/mat4x2_f16/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,13 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 118 +; Bound: 121 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess - %34 = OpExtInstImport "GLSL.std.450" + %37 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -62,7 +62,7 @@ %18 = OpTypeFunction %int %int_1 = OpConstant %int 1 %void = OpTypeVoid - %26 = OpTypeFunction %void + %29 = OpTypeFunction %void %_ptr_Uniform__arr_mat4x2_f16_std140_uint_4 = OpTypePointer Uniform %_arr_mat4x2_f16_std140_uint_4 %uint_0 = OpConstant %uint 0 %uint_3 = OpConstant %uint 3 @@ -76,117 +76,120 @@ %_ptr_Function__arr_mat4x2_f16_std140_uint_4_0 = OpTypePointer Function %_arr_mat4x2_f16_std140_uint_4_0 %_arr_mat4v2half_uint_4 = OpTypeArray %mat4v2half %uint_4 %_ptr_Function__arr_mat4v2half_uint_4 = OpTypePointer Function %_arr_mat4v2half_uint_4 - %66 = OpConstantNull %_arr_mat4v2half_uint_4 + %69 = OpConstantNull %_arr_mat4v2half_uint_4 %_ptr_StorageBuffer_half = OpTypePointer StorageBuffer %half %bool = OpTypeBool %_ptr_Function_mat4x2_f16_std140 = OpTypePointer Function %mat4x2_f16_std140 - %98 = OpTypeFunction %_arr_mat4x2_f16_std140_uint_4_0 %_arr_mat4x2_f16_std140_uint_4 + %101 = OpTypeFunction %_arr_mat4x2_f16_std140_uint_4_0 %_arr_mat4x2_f16_std140_uint_4 %_ptr_Function__arr_mat4x2_f16_std140_uint_4 = OpTypePointer Function %_arr_mat4x2_f16_std140_uint_4 - %103 = OpConstantNull %_arr_mat4x2_f16_std140_uint_4_0 + %106 = OpConstantNull %_arr_mat4x2_f16_std140_uint_4_0 %i = OpFunction %int None %18 %19 = OpLabel %20 = OpLoad %int %counter None - %21 = OpIAdd %int %20 %int_1 - OpStore %counter %21 None - %23 = OpLoad %int %counter None - OpReturnValue %23 + %21 = OpBitcast %uint %20 + %22 = OpBitcast %uint %int_1 + %24 = OpIAdd %uint %21 %22 + %25 = OpBitcast %int %24 + OpStore %counter %25 None + %26 = OpLoad %int %counter None + OpReturnValue %26 OpFunctionEnd - %f = OpFunction %void None %26 - %27 = OpLabel - %49 = OpVariable %_ptr_Function_mat4v2half Function - %61 = OpVariable %_ptr_Function__arr_mat4x2_f16_std140_uint_4_0 Function - %63 = OpVariable %_ptr_Function__arr_mat4v2half_uint_4 Function %66 - %28 = OpAccessChain %_ptr_Uniform__arr_mat4x2_f16_std140_uint_4 %1 %uint_0 - %31 = OpFunctionCall %int %i - %32 = OpBitcast %uint %31 - %33 = OpExtInst %uint %34 UMin %32 %uint_3 - %36 = OpAccessChain %_ptr_Uniform_v2half %28 %33 %uint_0 - %38 = OpLoad %v2half %36 None - %39 = OpAccessChain %_ptr_Uniform_v2half %28 %33 %uint_1 + %f = OpFunction %void None %29 + %30 = OpLabel + %52 = OpVariable %_ptr_Function_mat4v2half Function + %64 = OpVariable %_ptr_Function__arr_mat4x2_f16_std140_uint_4_0 Function + %66 = OpVariable %_ptr_Function__arr_mat4v2half_uint_4 Function %69 + %31 = OpAccessChain %_ptr_Uniform__arr_mat4x2_f16_std140_uint_4 %1 %uint_0 + %34 = OpFunctionCall %int %i + %35 = OpBitcast %uint %34 + %36 = OpExtInst %uint %37 UMin %35 %uint_3 + %39 = OpAccessChain %_ptr_Uniform_v2half %31 %36 %uint_0 %41 = OpLoad %v2half %39 None - %42 = OpAccessChain %_ptr_Uniform_v2half %28 %33 %uint_2 + %42 = OpAccessChain %_ptr_Uniform_v2half %31 %36 %uint_1 %44 = OpLoad %v2half %42 None - %45 = OpAccessChain %_ptr_Uniform_v2half %28 %33 %uint_3 - %46 = OpLoad %v2half %45 None - %l_a_i = OpCompositeConstruct %mat4v2half %38 %41 %44 %46 - OpStore %49 %l_a_i - %51 = OpFunctionCall %int %i - %52 = OpBitcast %uint %51 - %53 = OpExtInst %uint %34 UMin %52 %uint_3 - %54 = OpAccessChain %_ptr_Function_v2half %49 %53 - %l_a_i_i = OpLoad %v2half %54 None - %57 = OpLoad %_arr_mat4x2_f16_std140_uint_4 %28 None - %58 = OpFunctionCall %_arr_mat4x2_f16_std140_uint_4_0 %tint_convert_explicit_layout %57 - OpStore %61 %58 - OpBranch %67 - %67 = OpLabel + %45 = OpAccessChain %_ptr_Uniform_v2half %31 %36 %uint_2 + %47 = OpLoad %v2half %45 None + %48 = OpAccessChain %_ptr_Uniform_v2half %31 %36 %uint_3 + %49 = OpLoad %v2half %48 None + %l_a_i = OpCompositeConstruct %mat4v2half %41 %44 %47 %49 + OpStore %52 %l_a_i + %54 = OpFunctionCall %int %i + %55 = OpBitcast %uint %54 + %56 = OpExtInst %uint %37 UMin %55 %uint_3 + %57 = OpAccessChain %_ptr_Function_v2half %52 %56 + %l_a_i_i = OpLoad %v2half %57 None + %60 = OpLoad %_arr_mat4x2_f16_std140_uint_4 %31 None + %61 = OpFunctionCall %_arr_mat4x2_f16_std140_uint_4_0 %tint_convert_explicit_layout %60 + OpStore %64 %61 OpBranch %70 %70 = OpLabel - %72 = OpPhi %uint %uint_0 %67 %73 %69 - OpLoopMerge %71 %69 None - OpBranch %68 - %68 = OpLabel - %84 = OpUGreaterThanEqual %bool %72 %uint_4 - OpSelectionMerge %86 None - OpBranchConditional %84 %87 %86 - %87 = OpLabel + OpBranch %73 + %73 = OpLabel + %75 = OpPhi %uint %uint_0 %70 %76 %72 + OpLoopMerge %74 %72 None OpBranch %71 - %86 = OpLabel - %88 = OpAccessChain %_ptr_Function_mat4v2half %63 %72 - %89 = OpAccessChain %_ptr_Function_mat4x2_f16_std140 %61 %72 - %91 = OpLoad %mat4x2_f16_std140 %89 None - %92 = OpCompositeExtract %v2half %91 0 - %93 = OpCompositeExtract %v2half %91 1 - %94 = OpCompositeExtract %v2half %91 2 - %95 = OpCompositeExtract %v2half %91 3 - %96 = OpCompositeConstruct %mat4v2half %92 %93 %94 %95 - OpStore %88 %96 None - OpBranch %69 - %69 = OpLabel - %73 = OpIAdd %uint %72 %uint_1 - OpBranch %70 %71 = OpLabel - %l_a = OpLoad %_arr_mat4v2half_uint_4 %63 None - %75 = OpCompositeExtract %half %l_a_i_i 0 - %76 = OpCompositeExtract %half %l_a 0 0 0 - %77 = OpFAdd %half %75 %76 - %78 = OpCompositeExtract %half %l_a_i 0 0 - %79 = OpFAdd %half %77 %78 - %80 = OpCompositeExtract %half %l_a_i_i 0 - %81 = OpFAdd %half %79 %80 - %82 = OpAccessChain %_ptr_StorageBuffer_half %10 %uint_0 - OpStore %82 %81 None + %87 = OpUGreaterThanEqual %bool %75 %uint_4 + OpSelectionMerge %89 None + OpBranchConditional %87 %90 %89 + %90 = OpLabel + OpBranch %74 + %89 = OpLabel + %91 = OpAccessChain %_ptr_Function_mat4v2half %66 %75 + %92 = OpAccessChain %_ptr_Function_mat4x2_f16_std140 %64 %75 + %94 = OpLoad %mat4x2_f16_std140 %92 None + %95 = OpCompositeExtract %v2half %94 0 + %96 = OpCompositeExtract %v2half %94 1 + %97 = OpCompositeExtract %v2half %94 2 + %98 = OpCompositeExtract %v2half %94 3 + %99 = OpCompositeConstruct %mat4v2half %95 %96 %97 %98 + OpStore %91 %99 None + OpBranch %72 + %72 = OpLabel + %76 = OpIAdd %uint %75 %uint_1 + OpBranch %73 + %74 = OpLabel + %l_a = OpLoad %_arr_mat4v2half_uint_4 %66 None + %78 = OpCompositeExtract %half %l_a_i_i 0 + %79 = OpCompositeExtract %half %l_a 0 0 0 + %80 = OpFAdd %half %78 %79 + %81 = OpCompositeExtract %half %l_a_i 0 0 + %82 = OpFAdd %half %80 %81 + %83 = OpCompositeExtract %half %l_a_i_i 0 + %84 = OpFAdd %half %82 %83 + %85 = OpAccessChain %_ptr_StorageBuffer_half %10 %uint_0 + OpStore %85 %84 None OpReturn OpFunctionEnd -%tint_convert_explicit_layout = OpFunction %_arr_mat4x2_f16_std140_uint_4_0 None %98 +%tint_convert_explicit_layout = OpFunction %_arr_mat4x2_f16_std140_uint_4_0 None %101 %tint_source = OpFunctionParameter %_arr_mat4x2_f16_std140_uint_4 - %99 = OpLabel - %100 = OpVariable %_ptr_Function__arr_mat4x2_f16_std140_uint_4 Function - %102 = OpVariable %_ptr_Function__arr_mat4x2_f16_std140_uint_4_0 Function %103 - OpStore %100 %tint_source - OpBranch %104 - %104 = OpLabel + %102 = OpLabel + %103 = OpVariable %_ptr_Function__arr_mat4x2_f16_std140_uint_4 Function + %105 = OpVariable %_ptr_Function__arr_mat4x2_f16_std140_uint_4_0 Function %106 + OpStore %103 %tint_source OpBranch %107 %107 = OpLabel - %109 = OpPhi %uint %uint_0 %104 %110 %106 - OpLoopMerge %108 %106 None - OpBranch %105 - %105 = OpLabel - %112 = OpUGreaterThanEqual %bool %109 %uint_4 - OpSelectionMerge %113 None - OpBranchConditional %112 %114 %113 - %114 = OpLabel + OpBranch %110 + %110 = OpLabel + %112 = OpPhi %uint %uint_0 %107 %113 %109 + OpLoopMerge %111 %109 None OpBranch %108 - %113 = OpLabel - %115 = OpAccessChain %_ptr_Function_mat4x2_f16_std140 %100 %109 - %116 = OpLoad %mat4x2_f16_std140 %115 None - %117 = OpAccessChain %_ptr_Function_mat4x2_f16_std140 %102 %109 - OpStore %117 %116 None - OpBranch %106 - %106 = OpLabel - %110 = OpIAdd %uint %109 %uint_1 - OpBranch %107 %108 = OpLabel - %111 = OpLoad %_arr_mat4x2_f16_std140_uint_4_0 %102 None - OpReturnValue %111 + %115 = OpUGreaterThanEqual %bool %112 %uint_4 + OpSelectionMerge %116 None + OpBranchConditional %115 %117 %116 + %117 = OpLabel + OpBranch %111 + %116 = OpLabel + %118 = OpAccessChain %_ptr_Function_mat4x2_f16_std140 %103 %112 + %119 = OpLoad %mat4x2_f16_std140 %118 None + %120 = OpAccessChain %_ptr_Function_mat4x2_f16_std140 %105 %112 + OpStore %120 %119 None + OpBranch %109 + %109 = OpLabel + %113 = OpIAdd %uint %112 %uint_1 + OpBranch %110 + %111 = OpLabel + %114 = OpLoad %_arr_mat4x2_f16_std140_uint_4_0 %105 None + OpReturnValue %114 OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/array/mat4x2_f32/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/array/mat4x2_f32/dynamic_index_via_ptr.wgsl.expected.glsl index 09bd5a1..b3f67ae 100644 --- a/test/tint/buffer/uniform/std140/array/mat4x2_f32/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/array/mat4x2_f32/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -18,33 +18,34 @@ } v_1; int counter = 0; int i() { - counter = (counter + 1); + uint v_2 = uint(counter); + counter = int((v_2 + uint(1))); return counter; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - uint v_2 = min(uint(i()), 3u); - mat4x2 v_3 = mat4x2(v.inner[v_2].col0, v.inner[v_2].col1, v.inner[v_2].col2, v.inner[v_2].col3); - vec2 v_4 = v_3[min(uint(i()), 3u)]; - mat4x2_f32_std140 v_5[4] = v.inner; - mat4x2 v_6[4] = mat4x2[4](mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f)), mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f)), mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f)), mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))); + uint v_3 = min(uint(i()), 3u); + mat4x2 v_4 = mat4x2(v.inner[v_3].col0, v.inner[v_3].col1, v.inner[v_3].col2, v.inner[v_3].col3); + vec2 v_5 = v_4[min(uint(i()), 3u)]; + mat4x2_f32_std140 v_6[4] = v.inner; + mat4x2 v_7[4] = mat4x2[4](mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f)), mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f)), mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f)), mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))); { - uint v_7 = 0u; - v_7 = 0u; + uint v_8 = 0u; + v_8 = 0u; while(true) { - uint v_8 = v_7; - if ((v_8 >= 4u)) { + uint v_9 = v_8; + if ((v_9 >= 4u)) { break; } - v_6[v_8] = mat4x2(v_5[v_8].col0, v_5[v_8].col1, v_5[v_8].col2, v_5[v_8].col3); + v_7[v_9] = mat4x2(v_6[v_9].col0, v_6[v_9].col1, v_6[v_9].col2, v_6[v_9].col3); { - v_7 = (v_8 + 1u); + v_8 = (v_9 + 1u); } continue; } } - mat4x2 l_a[4] = v_6; - mat4x2 l_a_i = v_3; - vec2 l_a_i_i = v_4; - v_1.inner = (((v_4.x + l_a[0u][0u].x) + l_a_i[0u].x) + l_a_i_i.x); + mat4x2 l_a[4] = v_7; + mat4x2 l_a_i = v_4; + vec2 l_a_i_i = v_5; + v_1.inner = (((v_5.x + l_a[0u][0u].x) + l_a_i[0u].x) + l_a_i_i.x); }
diff --git a/test/tint/buffer/uniform/std140/array/mat4x2_f32/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/array/mat4x2_f32/dynamic_index_via_ptr.wgsl.expected.spvasm index e397eba..c7cec0f 100644 --- a/test/tint/buffer/uniform/std140/array/mat4x2_f32/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/array/mat4x2_f32/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,10 +1,10 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 118 +; Bound: 121 ; Schema: 0 OpCapability Shader - %34 = OpExtInstImport "GLSL.std.450" + %37 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -59,7 +59,7 @@ %18 = OpTypeFunction %int %int_1 = OpConstant %int 1 %void = OpTypeVoid - %26 = OpTypeFunction %void + %29 = OpTypeFunction %void %_ptr_Uniform__arr_mat4x2_f32_std140_uint_4 = OpTypePointer Uniform %_arr_mat4x2_f32_std140_uint_4 %uint_0 = OpConstant %uint 0 %uint_3 = OpConstant %uint 3 @@ -73,117 +73,120 @@ %_ptr_Function__arr_mat4x2_f32_std140_uint_4_0 = OpTypePointer Function %_arr_mat4x2_f32_std140_uint_4_0 %_arr_mat4v2float_uint_4 = OpTypeArray %mat4v2float %uint_4 %_ptr_Function__arr_mat4v2float_uint_4 = OpTypePointer Function %_arr_mat4v2float_uint_4 - %66 = OpConstantNull %_arr_mat4v2float_uint_4 + %69 = OpConstantNull %_arr_mat4v2float_uint_4 %_ptr_StorageBuffer_float = OpTypePointer StorageBuffer %float %bool = OpTypeBool %_ptr_Function_mat4x2_f32_std140 = OpTypePointer Function %mat4x2_f32_std140 - %98 = OpTypeFunction %_arr_mat4x2_f32_std140_uint_4_0 %_arr_mat4x2_f32_std140_uint_4 + %101 = OpTypeFunction %_arr_mat4x2_f32_std140_uint_4_0 %_arr_mat4x2_f32_std140_uint_4 %_ptr_Function__arr_mat4x2_f32_std140_uint_4 = OpTypePointer Function %_arr_mat4x2_f32_std140_uint_4 - %103 = OpConstantNull %_arr_mat4x2_f32_std140_uint_4_0 + %106 = OpConstantNull %_arr_mat4x2_f32_std140_uint_4_0 %i = OpFunction %int None %18 %19 = OpLabel %20 = OpLoad %int %counter None - %21 = OpIAdd %int %20 %int_1 - OpStore %counter %21 None - %23 = OpLoad %int %counter None - OpReturnValue %23 + %21 = OpBitcast %uint %20 + %22 = OpBitcast %uint %int_1 + %24 = OpIAdd %uint %21 %22 + %25 = OpBitcast %int %24 + OpStore %counter %25 None + %26 = OpLoad %int %counter None + OpReturnValue %26 OpFunctionEnd - %f = OpFunction %void None %26 - %27 = OpLabel - %49 = OpVariable %_ptr_Function_mat4v2float Function - %61 = OpVariable %_ptr_Function__arr_mat4x2_f32_std140_uint_4_0 Function - %63 = OpVariable %_ptr_Function__arr_mat4v2float_uint_4 Function %66 - %28 = OpAccessChain %_ptr_Uniform__arr_mat4x2_f32_std140_uint_4 %1 %uint_0 - %31 = OpFunctionCall %int %i - %32 = OpBitcast %uint %31 - %33 = OpExtInst %uint %34 UMin %32 %uint_3 - %36 = OpAccessChain %_ptr_Uniform_v2float %28 %33 %uint_0 - %38 = OpLoad %v2float %36 None - %39 = OpAccessChain %_ptr_Uniform_v2float %28 %33 %uint_1 + %f = OpFunction %void None %29 + %30 = OpLabel + %52 = OpVariable %_ptr_Function_mat4v2float Function + %64 = OpVariable %_ptr_Function__arr_mat4x2_f32_std140_uint_4_0 Function + %66 = OpVariable %_ptr_Function__arr_mat4v2float_uint_4 Function %69 + %31 = OpAccessChain %_ptr_Uniform__arr_mat4x2_f32_std140_uint_4 %1 %uint_0 + %34 = OpFunctionCall %int %i + %35 = OpBitcast %uint %34 + %36 = OpExtInst %uint %37 UMin %35 %uint_3 + %39 = OpAccessChain %_ptr_Uniform_v2float %31 %36 %uint_0 %41 = OpLoad %v2float %39 None - %42 = OpAccessChain %_ptr_Uniform_v2float %28 %33 %uint_2 + %42 = OpAccessChain %_ptr_Uniform_v2float %31 %36 %uint_1 %44 = OpLoad %v2float %42 None - %45 = OpAccessChain %_ptr_Uniform_v2float %28 %33 %uint_3 - %46 = OpLoad %v2float %45 None - %l_a_i = OpCompositeConstruct %mat4v2float %38 %41 %44 %46 - OpStore %49 %l_a_i - %51 = OpFunctionCall %int %i - %52 = OpBitcast %uint %51 - %53 = OpExtInst %uint %34 UMin %52 %uint_3 - %54 = OpAccessChain %_ptr_Function_v2float %49 %53 - %l_a_i_i = OpLoad %v2float %54 None - %57 = OpLoad %_arr_mat4x2_f32_std140_uint_4 %28 None - %58 = OpFunctionCall %_arr_mat4x2_f32_std140_uint_4_0 %tint_convert_explicit_layout %57 - OpStore %61 %58 - OpBranch %67 - %67 = OpLabel + %45 = OpAccessChain %_ptr_Uniform_v2float %31 %36 %uint_2 + %47 = OpLoad %v2float %45 None + %48 = OpAccessChain %_ptr_Uniform_v2float %31 %36 %uint_3 + %49 = OpLoad %v2float %48 None + %l_a_i = OpCompositeConstruct %mat4v2float %41 %44 %47 %49 + OpStore %52 %l_a_i + %54 = OpFunctionCall %int %i + %55 = OpBitcast %uint %54 + %56 = OpExtInst %uint %37 UMin %55 %uint_3 + %57 = OpAccessChain %_ptr_Function_v2float %52 %56 + %l_a_i_i = OpLoad %v2float %57 None + %60 = OpLoad %_arr_mat4x2_f32_std140_uint_4 %31 None + %61 = OpFunctionCall %_arr_mat4x2_f32_std140_uint_4_0 %tint_convert_explicit_layout %60 + OpStore %64 %61 OpBranch %70 %70 = OpLabel - %72 = OpPhi %uint %uint_0 %67 %73 %69 - OpLoopMerge %71 %69 None - OpBranch %68 - %68 = OpLabel - %84 = OpUGreaterThanEqual %bool %72 %uint_4 - OpSelectionMerge %86 None - OpBranchConditional %84 %87 %86 - %87 = OpLabel + OpBranch %73 + %73 = OpLabel + %75 = OpPhi %uint %uint_0 %70 %76 %72 + OpLoopMerge %74 %72 None OpBranch %71 - %86 = OpLabel - %88 = OpAccessChain %_ptr_Function_mat4v2float %63 %72 - %89 = OpAccessChain %_ptr_Function_mat4x2_f32_std140 %61 %72 - %91 = OpLoad %mat4x2_f32_std140 %89 None - %92 = OpCompositeExtract %v2float %91 0 - %93 = OpCompositeExtract %v2float %91 1 - %94 = OpCompositeExtract %v2float %91 2 - %95 = OpCompositeExtract %v2float %91 3 - %96 = OpCompositeConstruct %mat4v2float %92 %93 %94 %95 - OpStore %88 %96 None - OpBranch %69 - %69 = OpLabel - %73 = OpIAdd %uint %72 %uint_1 - OpBranch %70 %71 = OpLabel - %l_a = OpLoad %_arr_mat4v2float_uint_4 %63 None - %75 = OpCompositeExtract %float %l_a_i_i 0 - %76 = OpCompositeExtract %float %l_a 0 0 0 - %77 = OpFAdd %float %75 %76 - %78 = OpCompositeExtract %float %l_a_i 0 0 - %79 = OpFAdd %float %77 %78 - %80 = OpCompositeExtract %float %l_a_i_i 0 - %81 = OpFAdd %float %79 %80 - %82 = OpAccessChain %_ptr_StorageBuffer_float %10 %uint_0 - OpStore %82 %81 None + %87 = OpUGreaterThanEqual %bool %75 %uint_4 + OpSelectionMerge %89 None + OpBranchConditional %87 %90 %89 + %90 = OpLabel + OpBranch %74 + %89 = OpLabel + %91 = OpAccessChain %_ptr_Function_mat4v2float %66 %75 + %92 = OpAccessChain %_ptr_Function_mat4x2_f32_std140 %64 %75 + %94 = OpLoad %mat4x2_f32_std140 %92 None + %95 = OpCompositeExtract %v2float %94 0 + %96 = OpCompositeExtract %v2float %94 1 + %97 = OpCompositeExtract %v2float %94 2 + %98 = OpCompositeExtract %v2float %94 3 + %99 = OpCompositeConstruct %mat4v2float %95 %96 %97 %98 + OpStore %91 %99 None + OpBranch %72 + %72 = OpLabel + %76 = OpIAdd %uint %75 %uint_1 + OpBranch %73 + %74 = OpLabel + %l_a = OpLoad %_arr_mat4v2float_uint_4 %66 None + %78 = OpCompositeExtract %float %l_a_i_i 0 + %79 = OpCompositeExtract %float %l_a 0 0 0 + %80 = OpFAdd %float %78 %79 + %81 = OpCompositeExtract %float %l_a_i 0 0 + %82 = OpFAdd %float %80 %81 + %83 = OpCompositeExtract %float %l_a_i_i 0 + %84 = OpFAdd %float %82 %83 + %85 = OpAccessChain %_ptr_StorageBuffer_float %10 %uint_0 + OpStore %85 %84 None OpReturn OpFunctionEnd -%tint_convert_explicit_layout = OpFunction %_arr_mat4x2_f32_std140_uint_4_0 None %98 +%tint_convert_explicit_layout = OpFunction %_arr_mat4x2_f32_std140_uint_4_0 None %101 %tint_source = OpFunctionParameter %_arr_mat4x2_f32_std140_uint_4 - %99 = OpLabel - %100 = OpVariable %_ptr_Function__arr_mat4x2_f32_std140_uint_4 Function - %102 = OpVariable %_ptr_Function__arr_mat4x2_f32_std140_uint_4_0 Function %103 - OpStore %100 %tint_source - OpBranch %104 - %104 = OpLabel + %102 = OpLabel + %103 = OpVariable %_ptr_Function__arr_mat4x2_f32_std140_uint_4 Function + %105 = OpVariable %_ptr_Function__arr_mat4x2_f32_std140_uint_4_0 Function %106 + OpStore %103 %tint_source OpBranch %107 %107 = OpLabel - %109 = OpPhi %uint %uint_0 %104 %110 %106 - OpLoopMerge %108 %106 None - OpBranch %105 - %105 = OpLabel - %112 = OpUGreaterThanEqual %bool %109 %uint_4 - OpSelectionMerge %113 None - OpBranchConditional %112 %114 %113 - %114 = OpLabel + OpBranch %110 + %110 = OpLabel + %112 = OpPhi %uint %uint_0 %107 %113 %109 + OpLoopMerge %111 %109 None OpBranch %108 - %113 = OpLabel - %115 = OpAccessChain %_ptr_Function_mat4x2_f32_std140 %100 %109 - %116 = OpLoad %mat4x2_f32_std140 %115 None - %117 = OpAccessChain %_ptr_Function_mat4x2_f32_std140 %102 %109 - OpStore %117 %116 None - OpBranch %106 - %106 = OpLabel - %110 = OpIAdd %uint %109 %uint_1 - OpBranch %107 %108 = OpLabel - %111 = OpLoad %_arr_mat4x2_f32_std140_uint_4_0 %102 None - OpReturnValue %111 + %115 = OpUGreaterThanEqual %bool %112 %uint_4 + OpSelectionMerge %116 None + OpBranchConditional %115 %117 %116 + %117 = OpLabel + OpBranch %111 + %116 = OpLabel + %118 = OpAccessChain %_ptr_Function_mat4x2_f32_std140 %103 %112 + %119 = OpLoad %mat4x2_f32_std140 %118 None + %120 = OpAccessChain %_ptr_Function_mat4x2_f32_std140 %105 %112 + OpStore %120 %119 None + OpBranch %109 + %109 = OpLabel + %113 = OpIAdd %uint %112 %uint_1 + OpBranch %110 + %111 = OpLabel + %114 = OpLoad %_arr_mat4x2_f32_std140_uint_4_0 %105 None + OpReturnValue %114 OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/array/mat4x3_f16/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/array/mat4x3_f16/dynamic_index_via_ptr.wgsl.expected.glsl index a7beaaa..cfe27b8 100644 --- a/test/tint/buffer/uniform/std140/array/mat4x3_f16/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/array/mat4x3_f16/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -19,33 +19,34 @@ } v_1; int counter = 0; int i() { - counter = (counter + 1); + uint v_2 = uint(counter); + counter = int((v_2 + uint(1))); return counter; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - uint v_2 = min(uint(i()), 3u); - f16mat4x3 v_3 = f16mat4x3(v.inner[v_2].col0, v.inner[v_2].col1, v.inner[v_2].col2, v.inner[v_2].col3); - f16vec3 v_4 = v_3[min(uint(i()), 3u)]; - mat4x3_f16_std140 v_5[4] = v.inner; - f16mat4x3 v_6[4] = f16mat4x3[4](f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf)), f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf)), f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf)), f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))); + uint v_3 = min(uint(i()), 3u); + f16mat4x3 v_4 = f16mat4x3(v.inner[v_3].col0, v.inner[v_3].col1, v.inner[v_3].col2, v.inner[v_3].col3); + f16vec3 v_5 = v_4[min(uint(i()), 3u)]; + mat4x3_f16_std140 v_6[4] = v.inner; + f16mat4x3 v_7[4] = f16mat4x3[4](f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf)), f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf)), f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf)), f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))); { - uint v_7 = 0u; - v_7 = 0u; + uint v_8 = 0u; + v_8 = 0u; while(true) { - uint v_8 = v_7; - if ((v_8 >= 4u)) { + uint v_9 = v_8; + if ((v_9 >= 4u)) { break; } - v_6[v_8] = f16mat4x3(v_5[v_8].col0, v_5[v_8].col1, v_5[v_8].col2, v_5[v_8].col3); + v_7[v_9] = f16mat4x3(v_6[v_9].col0, v_6[v_9].col1, v_6[v_9].col2, v_6[v_9].col3); { - v_7 = (v_8 + 1u); + v_8 = (v_9 + 1u); } continue; } } - f16mat4x3 l_a[4] = v_6; - f16mat4x3 l_a_i = v_3; - f16vec3 l_a_i_i = v_4; - v_1.inner = (((v_4.x + l_a[0u][0u].x) + l_a_i[0u].x) + l_a_i_i.x); + f16mat4x3 l_a[4] = v_7; + f16mat4x3 l_a_i = v_4; + f16vec3 l_a_i_i = v_5; + v_1.inner = (((v_5.x + l_a[0u][0u].x) + l_a_i[0u].x) + l_a_i_i.x); }
diff --git a/test/tint/buffer/uniform/std140/array/mat4x3_f16/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/array/mat4x3_f16/dynamic_index_via_ptr.wgsl.expected.spvasm index efa2753..338b387 100644 --- a/test/tint/buffer/uniform/std140/array/mat4x3_f16/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/array/mat4x3_f16/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,13 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 118 +; Bound: 121 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess - %34 = OpExtInstImport "GLSL.std.450" + %37 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -62,7 +62,7 @@ %18 = OpTypeFunction %int %int_1 = OpConstant %int 1 %void = OpTypeVoid - %26 = OpTypeFunction %void + %29 = OpTypeFunction %void %_ptr_Uniform__arr_mat4x3_f16_std140_uint_4 = OpTypePointer Uniform %_arr_mat4x3_f16_std140_uint_4 %uint_0 = OpConstant %uint 0 %uint_3 = OpConstant %uint 3 @@ -76,117 +76,120 @@ %_ptr_Function__arr_mat4x3_f16_std140_uint_4_0 = OpTypePointer Function %_arr_mat4x3_f16_std140_uint_4_0 %_arr_mat4v3half_uint_4 = OpTypeArray %mat4v3half %uint_4 %_ptr_Function__arr_mat4v3half_uint_4 = OpTypePointer Function %_arr_mat4v3half_uint_4 - %66 = OpConstantNull %_arr_mat4v3half_uint_4 + %69 = OpConstantNull %_arr_mat4v3half_uint_4 %_ptr_StorageBuffer_half = OpTypePointer StorageBuffer %half %bool = OpTypeBool %_ptr_Function_mat4x3_f16_std140 = OpTypePointer Function %mat4x3_f16_std140 - %98 = OpTypeFunction %_arr_mat4x3_f16_std140_uint_4_0 %_arr_mat4x3_f16_std140_uint_4 + %101 = OpTypeFunction %_arr_mat4x3_f16_std140_uint_4_0 %_arr_mat4x3_f16_std140_uint_4 %_ptr_Function__arr_mat4x3_f16_std140_uint_4 = OpTypePointer Function %_arr_mat4x3_f16_std140_uint_4 - %103 = OpConstantNull %_arr_mat4x3_f16_std140_uint_4_0 + %106 = OpConstantNull %_arr_mat4x3_f16_std140_uint_4_0 %i = OpFunction %int None %18 %19 = OpLabel %20 = OpLoad %int %counter None - %21 = OpIAdd %int %20 %int_1 - OpStore %counter %21 None - %23 = OpLoad %int %counter None - OpReturnValue %23 + %21 = OpBitcast %uint %20 + %22 = OpBitcast %uint %int_1 + %24 = OpIAdd %uint %21 %22 + %25 = OpBitcast %int %24 + OpStore %counter %25 None + %26 = OpLoad %int %counter None + OpReturnValue %26 OpFunctionEnd - %f = OpFunction %void None %26 - %27 = OpLabel - %49 = OpVariable %_ptr_Function_mat4v3half Function - %61 = OpVariable %_ptr_Function__arr_mat4x3_f16_std140_uint_4_0 Function - %63 = OpVariable %_ptr_Function__arr_mat4v3half_uint_4 Function %66 - %28 = OpAccessChain %_ptr_Uniform__arr_mat4x3_f16_std140_uint_4 %1 %uint_0 - %31 = OpFunctionCall %int %i - %32 = OpBitcast %uint %31 - %33 = OpExtInst %uint %34 UMin %32 %uint_3 - %36 = OpAccessChain %_ptr_Uniform_v3half %28 %33 %uint_0 - %38 = OpLoad %v3half %36 None - %39 = OpAccessChain %_ptr_Uniform_v3half %28 %33 %uint_1 + %f = OpFunction %void None %29 + %30 = OpLabel + %52 = OpVariable %_ptr_Function_mat4v3half Function + %64 = OpVariable %_ptr_Function__arr_mat4x3_f16_std140_uint_4_0 Function + %66 = OpVariable %_ptr_Function__arr_mat4v3half_uint_4 Function %69 + %31 = OpAccessChain %_ptr_Uniform__arr_mat4x3_f16_std140_uint_4 %1 %uint_0 + %34 = OpFunctionCall %int %i + %35 = OpBitcast %uint %34 + %36 = OpExtInst %uint %37 UMin %35 %uint_3 + %39 = OpAccessChain %_ptr_Uniform_v3half %31 %36 %uint_0 %41 = OpLoad %v3half %39 None - %42 = OpAccessChain %_ptr_Uniform_v3half %28 %33 %uint_2 + %42 = OpAccessChain %_ptr_Uniform_v3half %31 %36 %uint_1 %44 = OpLoad %v3half %42 None - %45 = OpAccessChain %_ptr_Uniform_v3half %28 %33 %uint_3 - %46 = OpLoad %v3half %45 None - %l_a_i = OpCompositeConstruct %mat4v3half %38 %41 %44 %46 - OpStore %49 %l_a_i - %51 = OpFunctionCall %int %i - %52 = OpBitcast %uint %51 - %53 = OpExtInst %uint %34 UMin %52 %uint_3 - %54 = OpAccessChain %_ptr_Function_v3half %49 %53 - %l_a_i_i = OpLoad %v3half %54 None - %57 = OpLoad %_arr_mat4x3_f16_std140_uint_4 %28 None - %58 = OpFunctionCall %_arr_mat4x3_f16_std140_uint_4_0 %tint_convert_explicit_layout %57 - OpStore %61 %58 - OpBranch %67 - %67 = OpLabel + %45 = OpAccessChain %_ptr_Uniform_v3half %31 %36 %uint_2 + %47 = OpLoad %v3half %45 None + %48 = OpAccessChain %_ptr_Uniform_v3half %31 %36 %uint_3 + %49 = OpLoad %v3half %48 None + %l_a_i = OpCompositeConstruct %mat4v3half %41 %44 %47 %49 + OpStore %52 %l_a_i + %54 = OpFunctionCall %int %i + %55 = OpBitcast %uint %54 + %56 = OpExtInst %uint %37 UMin %55 %uint_3 + %57 = OpAccessChain %_ptr_Function_v3half %52 %56 + %l_a_i_i = OpLoad %v3half %57 None + %60 = OpLoad %_arr_mat4x3_f16_std140_uint_4 %31 None + %61 = OpFunctionCall %_arr_mat4x3_f16_std140_uint_4_0 %tint_convert_explicit_layout %60 + OpStore %64 %61 OpBranch %70 %70 = OpLabel - %72 = OpPhi %uint %uint_0 %67 %73 %69 - OpLoopMerge %71 %69 None - OpBranch %68 - %68 = OpLabel - %84 = OpUGreaterThanEqual %bool %72 %uint_4 - OpSelectionMerge %86 None - OpBranchConditional %84 %87 %86 - %87 = OpLabel + OpBranch %73 + %73 = OpLabel + %75 = OpPhi %uint %uint_0 %70 %76 %72 + OpLoopMerge %74 %72 None OpBranch %71 - %86 = OpLabel - %88 = OpAccessChain %_ptr_Function_mat4v3half %63 %72 - %89 = OpAccessChain %_ptr_Function_mat4x3_f16_std140 %61 %72 - %91 = OpLoad %mat4x3_f16_std140 %89 None - %92 = OpCompositeExtract %v3half %91 0 - %93 = OpCompositeExtract %v3half %91 1 - %94 = OpCompositeExtract %v3half %91 2 - %95 = OpCompositeExtract %v3half %91 3 - %96 = OpCompositeConstruct %mat4v3half %92 %93 %94 %95 - OpStore %88 %96 None - OpBranch %69 - %69 = OpLabel - %73 = OpIAdd %uint %72 %uint_1 - OpBranch %70 %71 = OpLabel - %l_a = OpLoad %_arr_mat4v3half_uint_4 %63 None - %75 = OpCompositeExtract %half %l_a_i_i 0 - %76 = OpCompositeExtract %half %l_a 0 0 0 - %77 = OpFAdd %half %75 %76 - %78 = OpCompositeExtract %half %l_a_i 0 0 - %79 = OpFAdd %half %77 %78 - %80 = OpCompositeExtract %half %l_a_i_i 0 - %81 = OpFAdd %half %79 %80 - %82 = OpAccessChain %_ptr_StorageBuffer_half %10 %uint_0 - OpStore %82 %81 None + %87 = OpUGreaterThanEqual %bool %75 %uint_4 + OpSelectionMerge %89 None + OpBranchConditional %87 %90 %89 + %90 = OpLabel + OpBranch %74 + %89 = OpLabel + %91 = OpAccessChain %_ptr_Function_mat4v3half %66 %75 + %92 = OpAccessChain %_ptr_Function_mat4x3_f16_std140 %64 %75 + %94 = OpLoad %mat4x3_f16_std140 %92 None + %95 = OpCompositeExtract %v3half %94 0 + %96 = OpCompositeExtract %v3half %94 1 + %97 = OpCompositeExtract %v3half %94 2 + %98 = OpCompositeExtract %v3half %94 3 + %99 = OpCompositeConstruct %mat4v3half %95 %96 %97 %98 + OpStore %91 %99 None + OpBranch %72 + %72 = OpLabel + %76 = OpIAdd %uint %75 %uint_1 + OpBranch %73 + %74 = OpLabel + %l_a = OpLoad %_arr_mat4v3half_uint_4 %66 None + %78 = OpCompositeExtract %half %l_a_i_i 0 + %79 = OpCompositeExtract %half %l_a 0 0 0 + %80 = OpFAdd %half %78 %79 + %81 = OpCompositeExtract %half %l_a_i 0 0 + %82 = OpFAdd %half %80 %81 + %83 = OpCompositeExtract %half %l_a_i_i 0 + %84 = OpFAdd %half %82 %83 + %85 = OpAccessChain %_ptr_StorageBuffer_half %10 %uint_0 + OpStore %85 %84 None OpReturn OpFunctionEnd -%tint_convert_explicit_layout = OpFunction %_arr_mat4x3_f16_std140_uint_4_0 None %98 +%tint_convert_explicit_layout = OpFunction %_arr_mat4x3_f16_std140_uint_4_0 None %101 %tint_source = OpFunctionParameter %_arr_mat4x3_f16_std140_uint_4 - %99 = OpLabel - %100 = OpVariable %_ptr_Function__arr_mat4x3_f16_std140_uint_4 Function - %102 = OpVariable %_ptr_Function__arr_mat4x3_f16_std140_uint_4_0 Function %103 - OpStore %100 %tint_source - OpBranch %104 - %104 = OpLabel + %102 = OpLabel + %103 = OpVariable %_ptr_Function__arr_mat4x3_f16_std140_uint_4 Function + %105 = OpVariable %_ptr_Function__arr_mat4x3_f16_std140_uint_4_0 Function %106 + OpStore %103 %tint_source OpBranch %107 %107 = OpLabel - %109 = OpPhi %uint %uint_0 %104 %110 %106 - OpLoopMerge %108 %106 None - OpBranch %105 - %105 = OpLabel - %112 = OpUGreaterThanEqual %bool %109 %uint_4 - OpSelectionMerge %113 None - OpBranchConditional %112 %114 %113 - %114 = OpLabel + OpBranch %110 + %110 = OpLabel + %112 = OpPhi %uint %uint_0 %107 %113 %109 + OpLoopMerge %111 %109 None OpBranch %108 - %113 = OpLabel - %115 = OpAccessChain %_ptr_Function_mat4x3_f16_std140 %100 %109 - %116 = OpLoad %mat4x3_f16_std140 %115 None - %117 = OpAccessChain %_ptr_Function_mat4x3_f16_std140 %102 %109 - OpStore %117 %116 None - OpBranch %106 - %106 = OpLabel - %110 = OpIAdd %uint %109 %uint_1 - OpBranch %107 %108 = OpLabel - %111 = OpLoad %_arr_mat4x3_f16_std140_uint_4_0 %102 None - OpReturnValue %111 + %115 = OpUGreaterThanEqual %bool %112 %uint_4 + OpSelectionMerge %116 None + OpBranchConditional %115 %117 %116 + %117 = OpLabel + OpBranch %111 + %116 = OpLabel + %118 = OpAccessChain %_ptr_Function_mat4x3_f16_std140 %103 %112 + %119 = OpLoad %mat4x3_f16_std140 %118 None + %120 = OpAccessChain %_ptr_Function_mat4x3_f16_std140 %105 %112 + OpStore %120 %119 None + OpBranch %109 + %109 = OpLabel + %113 = OpIAdd %uint %112 %uint_1 + OpBranch %110 + %111 = OpLabel + %114 = OpLoad %_arr_mat4x3_f16_std140_uint_4_0 %105 None + OpReturnValue %114 OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/array/mat4x3_f32/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/array/mat4x3_f32/dynamic_index_via_ptr.wgsl.expected.glsl index 96c174b..c8c3030 100644 --- a/test/tint/buffer/uniform/std140/array/mat4x3_f32/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/array/mat4x3_f32/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -22,33 +22,34 @@ } v_1; int counter = 0; int i() { - counter = (counter + 1); + uint v_2 = uint(counter); + counter = int((v_2 + uint(1))); return counter; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - uint v_2 = min(uint(i()), 3u); - mat4x3 v_3 = mat4x3(v.inner[v_2].col0, v.inner[v_2].col1, v.inner[v_2].col2, v.inner[v_2].col3); - vec3 v_4 = v_3[min(uint(i()), 3u)]; - mat4x3_f32_std140 v_5[4] = v.inner; - mat4x3 v_6[4] = mat4x3[4](mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f)), mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f)), mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f)), mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))); + uint v_3 = min(uint(i()), 3u); + mat4x3 v_4 = mat4x3(v.inner[v_3].col0, v.inner[v_3].col1, v.inner[v_3].col2, v.inner[v_3].col3); + vec3 v_5 = v_4[min(uint(i()), 3u)]; + mat4x3_f32_std140 v_6[4] = v.inner; + mat4x3 v_7[4] = mat4x3[4](mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f)), mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f)), mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f)), mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))); { - uint v_7 = 0u; - v_7 = 0u; + uint v_8 = 0u; + v_8 = 0u; while(true) { - uint v_8 = v_7; - if ((v_8 >= 4u)) { + uint v_9 = v_8; + if ((v_9 >= 4u)) { break; } - v_6[v_8] = mat4x3(v_5[v_8].col0, v_5[v_8].col1, v_5[v_8].col2, v_5[v_8].col3); + v_7[v_9] = mat4x3(v_6[v_9].col0, v_6[v_9].col1, v_6[v_9].col2, v_6[v_9].col3); { - v_7 = (v_8 + 1u); + v_8 = (v_9 + 1u); } continue; } } - mat4x3 l_a[4] = v_6; - mat4x3 l_a_i = v_3; - vec3 l_a_i_i = v_4; - v_1.inner = (((v_4.x + l_a[0u][0u].x) + l_a_i[0u].x) + l_a_i_i.x); + mat4x3 l_a[4] = v_7; + mat4x3 l_a_i = v_4; + vec3 l_a_i_i = v_5; + v_1.inner = (((v_5.x + l_a[0u][0u].x) + l_a_i[0u].x) + l_a_i_i.x); }
diff --git a/test/tint/buffer/uniform/std140/array/mat4x3_f32/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/array/mat4x3_f32/dynamic_index_via_ptr.wgsl.expected.spvasm index d664283..532c497 100644 --- a/test/tint/buffer/uniform/std140/array/mat4x3_f32/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/array/mat4x3_f32/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,10 +1,10 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 118 +; Bound: 121 ; Schema: 0 OpCapability Shader - %34 = OpExtInstImport "GLSL.std.450" + %37 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -59,7 +59,7 @@ %18 = OpTypeFunction %int %int_1 = OpConstant %int 1 %void = OpTypeVoid - %26 = OpTypeFunction %void + %29 = OpTypeFunction %void %_ptr_Uniform__arr_mat4x3_f32_std140_uint_4 = OpTypePointer Uniform %_arr_mat4x3_f32_std140_uint_4 %uint_0 = OpConstant %uint 0 %uint_3 = OpConstant %uint 3 @@ -73,117 +73,120 @@ %_ptr_Function__arr_mat4x3_f32_std140_uint_4_0 = OpTypePointer Function %_arr_mat4x3_f32_std140_uint_4_0 %_arr_mat4v3float_uint_4 = OpTypeArray %mat4v3float %uint_4 %_ptr_Function__arr_mat4v3float_uint_4 = OpTypePointer Function %_arr_mat4v3float_uint_4 - %66 = OpConstantNull %_arr_mat4v3float_uint_4 + %69 = OpConstantNull %_arr_mat4v3float_uint_4 %_ptr_StorageBuffer_float = OpTypePointer StorageBuffer %float %bool = OpTypeBool %_ptr_Function_mat4x3_f32_std140 = OpTypePointer Function %mat4x3_f32_std140 - %98 = OpTypeFunction %_arr_mat4x3_f32_std140_uint_4_0 %_arr_mat4x3_f32_std140_uint_4 + %101 = OpTypeFunction %_arr_mat4x3_f32_std140_uint_4_0 %_arr_mat4x3_f32_std140_uint_4 %_ptr_Function__arr_mat4x3_f32_std140_uint_4 = OpTypePointer Function %_arr_mat4x3_f32_std140_uint_4 - %103 = OpConstantNull %_arr_mat4x3_f32_std140_uint_4_0 + %106 = OpConstantNull %_arr_mat4x3_f32_std140_uint_4_0 %i = OpFunction %int None %18 %19 = OpLabel %20 = OpLoad %int %counter None - %21 = OpIAdd %int %20 %int_1 - OpStore %counter %21 None - %23 = OpLoad %int %counter None - OpReturnValue %23 + %21 = OpBitcast %uint %20 + %22 = OpBitcast %uint %int_1 + %24 = OpIAdd %uint %21 %22 + %25 = OpBitcast %int %24 + OpStore %counter %25 None + %26 = OpLoad %int %counter None + OpReturnValue %26 OpFunctionEnd - %f = OpFunction %void None %26 - %27 = OpLabel - %49 = OpVariable %_ptr_Function_mat4v3float Function - %61 = OpVariable %_ptr_Function__arr_mat4x3_f32_std140_uint_4_0 Function - %63 = OpVariable %_ptr_Function__arr_mat4v3float_uint_4 Function %66 - %28 = OpAccessChain %_ptr_Uniform__arr_mat4x3_f32_std140_uint_4 %1 %uint_0 - %31 = OpFunctionCall %int %i - %32 = OpBitcast %uint %31 - %33 = OpExtInst %uint %34 UMin %32 %uint_3 - %36 = OpAccessChain %_ptr_Uniform_v3float %28 %33 %uint_0 - %38 = OpLoad %v3float %36 None - %39 = OpAccessChain %_ptr_Uniform_v3float %28 %33 %uint_1 + %f = OpFunction %void None %29 + %30 = OpLabel + %52 = OpVariable %_ptr_Function_mat4v3float Function + %64 = OpVariable %_ptr_Function__arr_mat4x3_f32_std140_uint_4_0 Function + %66 = OpVariable %_ptr_Function__arr_mat4v3float_uint_4 Function %69 + %31 = OpAccessChain %_ptr_Uniform__arr_mat4x3_f32_std140_uint_4 %1 %uint_0 + %34 = OpFunctionCall %int %i + %35 = OpBitcast %uint %34 + %36 = OpExtInst %uint %37 UMin %35 %uint_3 + %39 = OpAccessChain %_ptr_Uniform_v3float %31 %36 %uint_0 %41 = OpLoad %v3float %39 None - %42 = OpAccessChain %_ptr_Uniform_v3float %28 %33 %uint_2 + %42 = OpAccessChain %_ptr_Uniform_v3float %31 %36 %uint_1 %44 = OpLoad %v3float %42 None - %45 = OpAccessChain %_ptr_Uniform_v3float %28 %33 %uint_3 - %46 = OpLoad %v3float %45 None - %l_a_i = OpCompositeConstruct %mat4v3float %38 %41 %44 %46 - OpStore %49 %l_a_i - %51 = OpFunctionCall %int %i - %52 = OpBitcast %uint %51 - %53 = OpExtInst %uint %34 UMin %52 %uint_3 - %54 = OpAccessChain %_ptr_Function_v3float %49 %53 - %l_a_i_i = OpLoad %v3float %54 None - %57 = OpLoad %_arr_mat4x3_f32_std140_uint_4 %28 None - %58 = OpFunctionCall %_arr_mat4x3_f32_std140_uint_4_0 %tint_convert_explicit_layout %57 - OpStore %61 %58 - OpBranch %67 - %67 = OpLabel + %45 = OpAccessChain %_ptr_Uniform_v3float %31 %36 %uint_2 + %47 = OpLoad %v3float %45 None + %48 = OpAccessChain %_ptr_Uniform_v3float %31 %36 %uint_3 + %49 = OpLoad %v3float %48 None + %l_a_i = OpCompositeConstruct %mat4v3float %41 %44 %47 %49 + OpStore %52 %l_a_i + %54 = OpFunctionCall %int %i + %55 = OpBitcast %uint %54 + %56 = OpExtInst %uint %37 UMin %55 %uint_3 + %57 = OpAccessChain %_ptr_Function_v3float %52 %56 + %l_a_i_i = OpLoad %v3float %57 None + %60 = OpLoad %_arr_mat4x3_f32_std140_uint_4 %31 None + %61 = OpFunctionCall %_arr_mat4x3_f32_std140_uint_4_0 %tint_convert_explicit_layout %60 + OpStore %64 %61 OpBranch %70 %70 = OpLabel - %72 = OpPhi %uint %uint_0 %67 %73 %69 - OpLoopMerge %71 %69 None - OpBranch %68 - %68 = OpLabel - %84 = OpUGreaterThanEqual %bool %72 %uint_4 - OpSelectionMerge %86 None - OpBranchConditional %84 %87 %86 - %87 = OpLabel + OpBranch %73 + %73 = OpLabel + %75 = OpPhi %uint %uint_0 %70 %76 %72 + OpLoopMerge %74 %72 None OpBranch %71 - %86 = OpLabel - %88 = OpAccessChain %_ptr_Function_mat4v3float %63 %72 - %89 = OpAccessChain %_ptr_Function_mat4x3_f32_std140 %61 %72 - %91 = OpLoad %mat4x3_f32_std140 %89 None - %92 = OpCompositeExtract %v3float %91 0 - %93 = OpCompositeExtract %v3float %91 1 - %94 = OpCompositeExtract %v3float %91 2 - %95 = OpCompositeExtract %v3float %91 3 - %96 = OpCompositeConstruct %mat4v3float %92 %93 %94 %95 - OpStore %88 %96 None - OpBranch %69 - %69 = OpLabel - %73 = OpIAdd %uint %72 %uint_1 - OpBranch %70 %71 = OpLabel - %l_a = OpLoad %_arr_mat4v3float_uint_4 %63 None - %75 = OpCompositeExtract %float %l_a_i_i 0 - %76 = OpCompositeExtract %float %l_a 0 0 0 - %77 = OpFAdd %float %75 %76 - %78 = OpCompositeExtract %float %l_a_i 0 0 - %79 = OpFAdd %float %77 %78 - %80 = OpCompositeExtract %float %l_a_i_i 0 - %81 = OpFAdd %float %79 %80 - %82 = OpAccessChain %_ptr_StorageBuffer_float %10 %uint_0 - OpStore %82 %81 None + %87 = OpUGreaterThanEqual %bool %75 %uint_4 + OpSelectionMerge %89 None + OpBranchConditional %87 %90 %89 + %90 = OpLabel + OpBranch %74 + %89 = OpLabel + %91 = OpAccessChain %_ptr_Function_mat4v3float %66 %75 + %92 = OpAccessChain %_ptr_Function_mat4x3_f32_std140 %64 %75 + %94 = OpLoad %mat4x3_f32_std140 %92 None + %95 = OpCompositeExtract %v3float %94 0 + %96 = OpCompositeExtract %v3float %94 1 + %97 = OpCompositeExtract %v3float %94 2 + %98 = OpCompositeExtract %v3float %94 3 + %99 = OpCompositeConstruct %mat4v3float %95 %96 %97 %98 + OpStore %91 %99 None + OpBranch %72 + %72 = OpLabel + %76 = OpIAdd %uint %75 %uint_1 + OpBranch %73 + %74 = OpLabel + %l_a = OpLoad %_arr_mat4v3float_uint_4 %66 None + %78 = OpCompositeExtract %float %l_a_i_i 0 + %79 = OpCompositeExtract %float %l_a 0 0 0 + %80 = OpFAdd %float %78 %79 + %81 = OpCompositeExtract %float %l_a_i 0 0 + %82 = OpFAdd %float %80 %81 + %83 = OpCompositeExtract %float %l_a_i_i 0 + %84 = OpFAdd %float %82 %83 + %85 = OpAccessChain %_ptr_StorageBuffer_float %10 %uint_0 + OpStore %85 %84 None OpReturn OpFunctionEnd -%tint_convert_explicit_layout = OpFunction %_arr_mat4x3_f32_std140_uint_4_0 None %98 +%tint_convert_explicit_layout = OpFunction %_arr_mat4x3_f32_std140_uint_4_0 None %101 %tint_source = OpFunctionParameter %_arr_mat4x3_f32_std140_uint_4 - %99 = OpLabel - %100 = OpVariable %_ptr_Function__arr_mat4x3_f32_std140_uint_4 Function - %102 = OpVariable %_ptr_Function__arr_mat4x3_f32_std140_uint_4_0 Function %103 - OpStore %100 %tint_source - OpBranch %104 - %104 = OpLabel + %102 = OpLabel + %103 = OpVariable %_ptr_Function__arr_mat4x3_f32_std140_uint_4 Function + %105 = OpVariable %_ptr_Function__arr_mat4x3_f32_std140_uint_4_0 Function %106 + OpStore %103 %tint_source OpBranch %107 %107 = OpLabel - %109 = OpPhi %uint %uint_0 %104 %110 %106 - OpLoopMerge %108 %106 None - OpBranch %105 - %105 = OpLabel - %112 = OpUGreaterThanEqual %bool %109 %uint_4 - OpSelectionMerge %113 None - OpBranchConditional %112 %114 %113 - %114 = OpLabel + OpBranch %110 + %110 = OpLabel + %112 = OpPhi %uint %uint_0 %107 %113 %109 + OpLoopMerge %111 %109 None OpBranch %108 - %113 = OpLabel - %115 = OpAccessChain %_ptr_Function_mat4x3_f32_std140 %100 %109 - %116 = OpLoad %mat4x3_f32_std140 %115 None - %117 = OpAccessChain %_ptr_Function_mat4x3_f32_std140 %102 %109 - OpStore %117 %116 None - OpBranch %106 - %106 = OpLabel - %110 = OpIAdd %uint %109 %uint_1 - OpBranch %107 %108 = OpLabel - %111 = OpLoad %_arr_mat4x3_f32_std140_uint_4_0 %102 None - OpReturnValue %111 + %115 = OpUGreaterThanEqual %bool %112 %uint_4 + OpSelectionMerge %116 None + OpBranchConditional %115 %117 %116 + %117 = OpLabel + OpBranch %111 + %116 = OpLabel + %118 = OpAccessChain %_ptr_Function_mat4x3_f32_std140 %103 %112 + %119 = OpLoad %mat4x3_f32_std140 %118 None + %120 = OpAccessChain %_ptr_Function_mat4x3_f32_std140 %105 %112 + OpStore %120 %119 None + OpBranch %109 + %109 = OpLabel + %113 = OpIAdd %uint %112 %uint_1 + OpBranch %110 + %111 = OpLabel + %114 = OpLoad %_arr_mat4x3_f32_std140_uint_4_0 %105 None + OpReturnValue %114 OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/array/mat4x4_f16/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/array/mat4x4_f16/dynamic_index_via_ptr.wgsl.expected.glsl index 3b4d863..81b6530 100644 --- a/test/tint/buffer/uniform/std140/array/mat4x4_f16/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/array/mat4x4_f16/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -19,33 +19,34 @@ } v_1; int counter = 0; int i() { - counter = (counter + 1); + uint v_2 = uint(counter); + counter = int((v_2 + uint(1))); return counter; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - uint v_2 = min(uint(i()), 3u); - f16mat4 v_3 = f16mat4(v.inner[v_2].col0, v.inner[v_2].col1, v.inner[v_2].col2, v.inner[v_2].col3); - f16vec4 v_4 = v_3[min(uint(i()), 3u)]; - mat4x4_f16_std140 v_5[4] = v.inner; - f16mat4 v_6[4] = f16mat4[4](f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf)), f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf)), f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf)), f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))); + uint v_3 = min(uint(i()), 3u); + f16mat4 v_4 = f16mat4(v.inner[v_3].col0, v.inner[v_3].col1, v.inner[v_3].col2, v.inner[v_3].col3); + f16vec4 v_5 = v_4[min(uint(i()), 3u)]; + mat4x4_f16_std140 v_6[4] = v.inner; + f16mat4 v_7[4] = f16mat4[4](f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf)), f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf)), f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf)), f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))); { - uint v_7 = 0u; - v_7 = 0u; + uint v_8 = 0u; + v_8 = 0u; while(true) { - uint v_8 = v_7; - if ((v_8 >= 4u)) { + uint v_9 = v_8; + if ((v_9 >= 4u)) { break; } - v_6[v_8] = f16mat4(v_5[v_8].col0, v_5[v_8].col1, v_5[v_8].col2, v_5[v_8].col3); + v_7[v_9] = f16mat4(v_6[v_9].col0, v_6[v_9].col1, v_6[v_9].col2, v_6[v_9].col3); { - v_7 = (v_8 + 1u); + v_8 = (v_9 + 1u); } continue; } } - f16mat4 l_a[4] = v_6; - f16mat4 l_a_i = v_3; - f16vec4 l_a_i_i = v_4; - v_1.inner = (((v_4.x + l_a[0u][0u].x) + l_a_i[0u].x) + l_a_i_i.x); + f16mat4 l_a[4] = v_7; + f16mat4 l_a_i = v_4; + f16vec4 l_a_i_i = v_5; + v_1.inner = (((v_5.x + l_a[0u][0u].x) + l_a_i[0u].x) + l_a_i_i.x); }
diff --git a/test/tint/buffer/uniform/std140/array/mat4x4_f16/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/array/mat4x4_f16/dynamic_index_via_ptr.wgsl.expected.spvasm index 0eec30d..a4b2311 100644 --- a/test/tint/buffer/uniform/std140/array/mat4x4_f16/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/array/mat4x4_f16/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,13 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 118 +; Bound: 121 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess - %34 = OpExtInstImport "GLSL.std.450" + %37 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -62,7 +62,7 @@ %18 = OpTypeFunction %int %int_1 = OpConstant %int 1 %void = OpTypeVoid - %26 = OpTypeFunction %void + %29 = OpTypeFunction %void %_ptr_Uniform__arr_mat4x4_f16_std140_uint_4 = OpTypePointer Uniform %_arr_mat4x4_f16_std140_uint_4 %uint_0 = OpConstant %uint 0 %uint_3 = OpConstant %uint 3 @@ -76,117 +76,120 @@ %_ptr_Function__arr_mat4x4_f16_std140_uint_4_0 = OpTypePointer Function %_arr_mat4x4_f16_std140_uint_4_0 %_arr_mat4v4half_uint_4 = OpTypeArray %mat4v4half %uint_4 %_ptr_Function__arr_mat4v4half_uint_4 = OpTypePointer Function %_arr_mat4v4half_uint_4 - %66 = OpConstantNull %_arr_mat4v4half_uint_4 + %69 = OpConstantNull %_arr_mat4v4half_uint_4 %_ptr_StorageBuffer_half = OpTypePointer StorageBuffer %half %bool = OpTypeBool %_ptr_Function_mat4x4_f16_std140 = OpTypePointer Function %mat4x4_f16_std140 - %98 = OpTypeFunction %_arr_mat4x4_f16_std140_uint_4_0 %_arr_mat4x4_f16_std140_uint_4 + %101 = OpTypeFunction %_arr_mat4x4_f16_std140_uint_4_0 %_arr_mat4x4_f16_std140_uint_4 %_ptr_Function__arr_mat4x4_f16_std140_uint_4 = OpTypePointer Function %_arr_mat4x4_f16_std140_uint_4 - %103 = OpConstantNull %_arr_mat4x4_f16_std140_uint_4_0 + %106 = OpConstantNull %_arr_mat4x4_f16_std140_uint_4_0 %i = OpFunction %int None %18 %19 = OpLabel %20 = OpLoad %int %counter None - %21 = OpIAdd %int %20 %int_1 - OpStore %counter %21 None - %23 = OpLoad %int %counter None - OpReturnValue %23 + %21 = OpBitcast %uint %20 + %22 = OpBitcast %uint %int_1 + %24 = OpIAdd %uint %21 %22 + %25 = OpBitcast %int %24 + OpStore %counter %25 None + %26 = OpLoad %int %counter None + OpReturnValue %26 OpFunctionEnd - %f = OpFunction %void None %26 - %27 = OpLabel - %49 = OpVariable %_ptr_Function_mat4v4half Function - %61 = OpVariable %_ptr_Function__arr_mat4x4_f16_std140_uint_4_0 Function - %63 = OpVariable %_ptr_Function__arr_mat4v4half_uint_4 Function %66 - %28 = OpAccessChain %_ptr_Uniform__arr_mat4x4_f16_std140_uint_4 %1 %uint_0 - %31 = OpFunctionCall %int %i - %32 = OpBitcast %uint %31 - %33 = OpExtInst %uint %34 UMin %32 %uint_3 - %36 = OpAccessChain %_ptr_Uniform_v4half %28 %33 %uint_0 - %38 = OpLoad %v4half %36 None - %39 = OpAccessChain %_ptr_Uniform_v4half %28 %33 %uint_1 + %f = OpFunction %void None %29 + %30 = OpLabel + %52 = OpVariable %_ptr_Function_mat4v4half Function + %64 = OpVariable %_ptr_Function__arr_mat4x4_f16_std140_uint_4_0 Function + %66 = OpVariable %_ptr_Function__arr_mat4v4half_uint_4 Function %69 + %31 = OpAccessChain %_ptr_Uniform__arr_mat4x4_f16_std140_uint_4 %1 %uint_0 + %34 = OpFunctionCall %int %i + %35 = OpBitcast %uint %34 + %36 = OpExtInst %uint %37 UMin %35 %uint_3 + %39 = OpAccessChain %_ptr_Uniform_v4half %31 %36 %uint_0 %41 = OpLoad %v4half %39 None - %42 = OpAccessChain %_ptr_Uniform_v4half %28 %33 %uint_2 + %42 = OpAccessChain %_ptr_Uniform_v4half %31 %36 %uint_1 %44 = OpLoad %v4half %42 None - %45 = OpAccessChain %_ptr_Uniform_v4half %28 %33 %uint_3 - %46 = OpLoad %v4half %45 None - %l_a_i = OpCompositeConstruct %mat4v4half %38 %41 %44 %46 - OpStore %49 %l_a_i - %51 = OpFunctionCall %int %i - %52 = OpBitcast %uint %51 - %53 = OpExtInst %uint %34 UMin %52 %uint_3 - %54 = OpAccessChain %_ptr_Function_v4half %49 %53 - %l_a_i_i = OpLoad %v4half %54 None - %57 = OpLoad %_arr_mat4x4_f16_std140_uint_4 %28 None - %58 = OpFunctionCall %_arr_mat4x4_f16_std140_uint_4_0 %tint_convert_explicit_layout %57 - OpStore %61 %58 - OpBranch %67 - %67 = OpLabel + %45 = OpAccessChain %_ptr_Uniform_v4half %31 %36 %uint_2 + %47 = OpLoad %v4half %45 None + %48 = OpAccessChain %_ptr_Uniform_v4half %31 %36 %uint_3 + %49 = OpLoad %v4half %48 None + %l_a_i = OpCompositeConstruct %mat4v4half %41 %44 %47 %49 + OpStore %52 %l_a_i + %54 = OpFunctionCall %int %i + %55 = OpBitcast %uint %54 + %56 = OpExtInst %uint %37 UMin %55 %uint_3 + %57 = OpAccessChain %_ptr_Function_v4half %52 %56 + %l_a_i_i = OpLoad %v4half %57 None + %60 = OpLoad %_arr_mat4x4_f16_std140_uint_4 %31 None + %61 = OpFunctionCall %_arr_mat4x4_f16_std140_uint_4_0 %tint_convert_explicit_layout %60 + OpStore %64 %61 OpBranch %70 %70 = OpLabel - %72 = OpPhi %uint %uint_0 %67 %73 %69 - OpLoopMerge %71 %69 None - OpBranch %68 - %68 = OpLabel - %84 = OpUGreaterThanEqual %bool %72 %uint_4 - OpSelectionMerge %86 None - OpBranchConditional %84 %87 %86 - %87 = OpLabel + OpBranch %73 + %73 = OpLabel + %75 = OpPhi %uint %uint_0 %70 %76 %72 + OpLoopMerge %74 %72 None OpBranch %71 - %86 = OpLabel - %88 = OpAccessChain %_ptr_Function_mat4v4half %63 %72 - %89 = OpAccessChain %_ptr_Function_mat4x4_f16_std140 %61 %72 - %91 = OpLoad %mat4x4_f16_std140 %89 None - %92 = OpCompositeExtract %v4half %91 0 - %93 = OpCompositeExtract %v4half %91 1 - %94 = OpCompositeExtract %v4half %91 2 - %95 = OpCompositeExtract %v4half %91 3 - %96 = OpCompositeConstruct %mat4v4half %92 %93 %94 %95 - OpStore %88 %96 None - OpBranch %69 - %69 = OpLabel - %73 = OpIAdd %uint %72 %uint_1 - OpBranch %70 %71 = OpLabel - %l_a = OpLoad %_arr_mat4v4half_uint_4 %63 None - %75 = OpCompositeExtract %half %l_a_i_i 0 - %76 = OpCompositeExtract %half %l_a 0 0 0 - %77 = OpFAdd %half %75 %76 - %78 = OpCompositeExtract %half %l_a_i 0 0 - %79 = OpFAdd %half %77 %78 - %80 = OpCompositeExtract %half %l_a_i_i 0 - %81 = OpFAdd %half %79 %80 - %82 = OpAccessChain %_ptr_StorageBuffer_half %10 %uint_0 - OpStore %82 %81 None + %87 = OpUGreaterThanEqual %bool %75 %uint_4 + OpSelectionMerge %89 None + OpBranchConditional %87 %90 %89 + %90 = OpLabel + OpBranch %74 + %89 = OpLabel + %91 = OpAccessChain %_ptr_Function_mat4v4half %66 %75 + %92 = OpAccessChain %_ptr_Function_mat4x4_f16_std140 %64 %75 + %94 = OpLoad %mat4x4_f16_std140 %92 None + %95 = OpCompositeExtract %v4half %94 0 + %96 = OpCompositeExtract %v4half %94 1 + %97 = OpCompositeExtract %v4half %94 2 + %98 = OpCompositeExtract %v4half %94 3 + %99 = OpCompositeConstruct %mat4v4half %95 %96 %97 %98 + OpStore %91 %99 None + OpBranch %72 + %72 = OpLabel + %76 = OpIAdd %uint %75 %uint_1 + OpBranch %73 + %74 = OpLabel + %l_a = OpLoad %_arr_mat4v4half_uint_4 %66 None + %78 = OpCompositeExtract %half %l_a_i_i 0 + %79 = OpCompositeExtract %half %l_a 0 0 0 + %80 = OpFAdd %half %78 %79 + %81 = OpCompositeExtract %half %l_a_i 0 0 + %82 = OpFAdd %half %80 %81 + %83 = OpCompositeExtract %half %l_a_i_i 0 + %84 = OpFAdd %half %82 %83 + %85 = OpAccessChain %_ptr_StorageBuffer_half %10 %uint_0 + OpStore %85 %84 None OpReturn OpFunctionEnd -%tint_convert_explicit_layout = OpFunction %_arr_mat4x4_f16_std140_uint_4_0 None %98 +%tint_convert_explicit_layout = OpFunction %_arr_mat4x4_f16_std140_uint_4_0 None %101 %tint_source = OpFunctionParameter %_arr_mat4x4_f16_std140_uint_4 - %99 = OpLabel - %100 = OpVariable %_ptr_Function__arr_mat4x4_f16_std140_uint_4 Function - %102 = OpVariable %_ptr_Function__arr_mat4x4_f16_std140_uint_4_0 Function %103 - OpStore %100 %tint_source - OpBranch %104 - %104 = OpLabel + %102 = OpLabel + %103 = OpVariable %_ptr_Function__arr_mat4x4_f16_std140_uint_4 Function + %105 = OpVariable %_ptr_Function__arr_mat4x4_f16_std140_uint_4_0 Function %106 + OpStore %103 %tint_source OpBranch %107 %107 = OpLabel - %109 = OpPhi %uint %uint_0 %104 %110 %106 - OpLoopMerge %108 %106 None - OpBranch %105 - %105 = OpLabel - %112 = OpUGreaterThanEqual %bool %109 %uint_4 - OpSelectionMerge %113 None - OpBranchConditional %112 %114 %113 - %114 = OpLabel + OpBranch %110 + %110 = OpLabel + %112 = OpPhi %uint %uint_0 %107 %113 %109 + OpLoopMerge %111 %109 None OpBranch %108 - %113 = OpLabel - %115 = OpAccessChain %_ptr_Function_mat4x4_f16_std140 %100 %109 - %116 = OpLoad %mat4x4_f16_std140 %115 None - %117 = OpAccessChain %_ptr_Function_mat4x4_f16_std140 %102 %109 - OpStore %117 %116 None - OpBranch %106 - %106 = OpLabel - %110 = OpIAdd %uint %109 %uint_1 - OpBranch %107 %108 = OpLabel - %111 = OpLoad %_arr_mat4x4_f16_std140_uint_4_0 %102 None - OpReturnValue %111 + %115 = OpUGreaterThanEqual %bool %112 %uint_4 + OpSelectionMerge %116 None + OpBranchConditional %115 %117 %116 + %117 = OpLabel + OpBranch %111 + %116 = OpLabel + %118 = OpAccessChain %_ptr_Function_mat4x4_f16_std140 %103 %112 + %119 = OpLoad %mat4x4_f16_std140 %118 None + %120 = OpAccessChain %_ptr_Function_mat4x4_f16_std140 %105 %112 + OpStore %120 %119 None + OpBranch %109 + %109 = OpLabel + %113 = OpIAdd %uint %112 %uint_1 + OpBranch %110 + %111 = OpLabel + %114 = OpLoad %_arr_mat4x4_f16_std140_uint_4_0 %105 None + OpReturnValue %114 OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/array/mat4x4_f32/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/array/mat4x4_f32/dynamic_index_via_ptr.wgsl.expected.glsl index 2bc80cf..2755577 100644 --- a/test/tint/buffer/uniform/std140/array/mat4x4_f32/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/array/mat4x4_f32/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -10,15 +10,16 @@ } v_1; int counter = 0; int i() { - counter = (counter + 1); + uint v_2 = uint(counter); + counter = int((v_2 + uint(1))); return counter; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - uint v_2 = min(uint(i()), 3u); uint v_3 = min(uint(i()), 3u); + uint v_4 = min(uint(i()), 3u); mat4 l_a[4] = v.inner; - mat4 l_a_i = v.inner[v_2]; - vec4 l_a_i_i = v.inner[v_2][v_3]; - v_1.inner = (((v.inner[v_2][v_3].x + l_a[0u][0u].x) + l_a_i[0u].x) + l_a_i_i.x); + mat4 l_a_i = v.inner[v_3]; + vec4 l_a_i_i = v.inner[v_3][v_4]; + v_1.inner = (((v.inner[v_3][v_4].x + l_a[0u][0u].x) + l_a_i[0u].x) + l_a_i_i.x); }
diff --git a/test/tint/buffer/uniform/std140/array/mat4x4_f32/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/array/mat4x4_f32/dynamic_index_via_ptr.wgsl.expected.spvasm index ce91537..3c3b565 100644 --- a/test/tint/buffer/uniform/std140/array/mat4x4_f32/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/array/mat4x4_f32/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,10 +1,10 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 85 +; Bound: 88 ; Schema: 0 OpCapability Shader - %34 = OpExtInstImport "GLSL.std.450" + %37 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -55,7 +55,7 @@ %18 = OpTypeFunction %int %int_1 = OpConstant %int 1 %void = OpTypeVoid - %26 = OpTypeFunction %void + %29 = OpTypeFunction %void %_ptr_Uniform__arr_mat4v4float_uint_4 = OpTypePointer Uniform %_arr_mat4v4float_uint_4 %uint_0 = OpConstant %uint 0 %uint_3 = OpConstant %uint 3 @@ -64,77 +64,80 @@ %_arr_mat4v4float_uint_4_0 = OpTypeArray %mat4v4float %uint_4 %_ptr_Uniform_float = OpTypePointer Uniform %float %_ptr_StorageBuffer_float = OpTypePointer StorageBuffer %float - %61 = OpTypeFunction %_arr_mat4v4float_uint_4_0 %_arr_mat4v4float_uint_4 + %64 = OpTypeFunction %_arr_mat4v4float_uint_4_0 %_arr_mat4v4float_uint_4 %_ptr_Function__arr_mat4v4float_uint_4 = OpTypePointer Function %_arr_mat4v4float_uint_4 %_ptr_Function__arr_mat4v4float_uint_4_0 = OpTypePointer Function %_arr_mat4v4float_uint_4_0 - %67 = OpConstantNull %_arr_mat4v4float_uint_4_0 + %70 = OpConstantNull %_arr_mat4v4float_uint_4_0 %bool = OpTypeBool %_ptr_Function_mat4v4float = OpTypePointer Function %mat4v4float %uint_1 = OpConstant %uint 1 %i = OpFunction %int None %18 %19 = OpLabel %20 = OpLoad %int %counter None - %21 = OpIAdd %int %20 %int_1 - OpStore %counter %21 None - %23 = OpLoad %int %counter None - OpReturnValue %23 + %21 = OpBitcast %uint %20 + %22 = OpBitcast %uint %int_1 + %24 = OpIAdd %uint %21 %22 + %25 = OpBitcast %int %24 + OpStore %counter %25 None + %26 = OpLoad %int %counter None + OpReturnValue %26 OpFunctionEnd - %f = OpFunction %void None %26 - %27 = OpLabel + %f = OpFunction %void None %29 + %30 = OpLabel %p_a = OpAccessChain %_ptr_Uniform__arr_mat4v4float_uint_4 %1 %uint_0 - %31 = OpFunctionCall %int %i - %32 = OpBitcast %uint %31 - %33 = OpExtInst %uint %34 UMin %32 %uint_3 - %p_a_i = OpAccessChain %_ptr_Uniform_mat4v4float %p_a %33 - %38 = OpFunctionCall %int %i - %39 = OpBitcast %uint %38 - %40 = OpExtInst %uint %34 UMin %39 %uint_3 - %p_a_i_i = OpAccessChain %_ptr_Uniform_v4float %p_a_i %40 - %43 = OpLoad %_arr_mat4v4float_uint_4 %p_a None - %l_a = OpFunctionCall %_arr_mat4v4float_uint_4_0 %tint_convert_explicit_layout %43 + %34 = OpFunctionCall %int %i + %35 = OpBitcast %uint %34 + %36 = OpExtInst %uint %37 UMin %35 %uint_3 + %p_a_i = OpAccessChain %_ptr_Uniform_mat4v4float %p_a %36 + %41 = OpFunctionCall %int %i + %42 = OpBitcast %uint %41 + %43 = OpExtInst %uint %37 UMin %42 %uint_3 + %p_a_i_i = OpAccessChain %_ptr_Uniform_v4float %p_a_i %43 + %46 = OpLoad %_arr_mat4v4float_uint_4 %p_a None + %l_a = OpFunctionCall %_arr_mat4v4float_uint_4_0 %tint_convert_explicit_layout %46 %l_a_i = OpLoad %mat4v4float %p_a_i None %l_a_i_i = OpLoad %v4float %p_a_i_i None - %49 = OpAccessChain %_ptr_Uniform_float %p_a_i_i %uint_0 - %51 = OpLoad %float %49 None - %52 = OpCompositeExtract %float %l_a 0 0 0 - %53 = OpFAdd %float %51 %52 - %54 = OpCompositeExtract %float %l_a_i 0 0 - %55 = OpFAdd %float %53 %54 - %56 = OpCompositeExtract %float %l_a_i_i 0 - %57 = OpFAdd %float %55 %56 - %58 = OpAccessChain %_ptr_StorageBuffer_float %10 %uint_0 - OpStore %58 %57 None + %52 = OpAccessChain %_ptr_Uniform_float %p_a_i_i %uint_0 + %54 = OpLoad %float %52 None + %55 = OpCompositeExtract %float %l_a 0 0 0 + %56 = OpFAdd %float %54 %55 + %57 = OpCompositeExtract %float %l_a_i 0 0 + %58 = OpFAdd %float %56 %57 + %59 = OpCompositeExtract %float %l_a_i_i 0 + %60 = OpFAdd %float %58 %59 + %61 = OpAccessChain %_ptr_StorageBuffer_float %10 %uint_0 + OpStore %61 %60 None OpReturn OpFunctionEnd -%tint_convert_explicit_layout = OpFunction %_arr_mat4v4float_uint_4_0 None %61 +%tint_convert_explicit_layout = OpFunction %_arr_mat4v4float_uint_4_0 None %64 %tint_source = OpFunctionParameter %_arr_mat4v4float_uint_4 - %62 = OpLabel - %63 = OpVariable %_ptr_Function__arr_mat4v4float_uint_4 Function - %65 = OpVariable %_ptr_Function__arr_mat4v4float_uint_4_0 Function %67 - OpStore %63 %tint_source - OpBranch %68 - %68 = OpLabel + %65 = OpLabel + %66 = OpVariable %_ptr_Function__arr_mat4v4float_uint_4 Function + %68 = OpVariable %_ptr_Function__arr_mat4v4float_uint_4_0 Function %70 + OpStore %66 %tint_source OpBranch %71 %71 = OpLabel - %73 = OpPhi %uint %uint_0 %68 %74 %70 - OpLoopMerge %72 %70 None - OpBranch %69 - %69 = OpLabel - %76 = OpUGreaterThanEqual %bool %73 %uint_4 - OpSelectionMerge %78 None - OpBranchConditional %76 %79 %78 - %79 = OpLabel + OpBranch %74 + %74 = OpLabel + %76 = OpPhi %uint %uint_0 %71 %77 %73 + OpLoopMerge %75 %73 None OpBranch %72 - %78 = OpLabel - %80 = OpAccessChain %_ptr_Function_mat4v4float %63 %73 - %82 = OpLoad %mat4v4float %80 None - %83 = OpAccessChain %_ptr_Function_mat4v4float %65 %73 - OpStore %83 %82 None - OpBranch %70 - %70 = OpLabel - %74 = OpIAdd %uint %73 %uint_1 - OpBranch %71 %72 = OpLabel - %75 = OpLoad %_arr_mat4v4float_uint_4_0 %65 None - OpReturnValue %75 + %79 = OpUGreaterThanEqual %bool %76 %uint_4 + OpSelectionMerge %81 None + OpBranchConditional %79 %82 %81 + %82 = OpLabel + OpBranch %75 + %81 = OpLabel + %83 = OpAccessChain %_ptr_Function_mat4v4float %66 %76 + %85 = OpLoad %mat4v4float %83 None + %86 = OpAccessChain %_ptr_Function_mat4v4float %68 %76 + OpStore %86 %85 None + OpBranch %73 + %73 = OpLabel + %77 = OpIAdd %uint %76 %uint_1 + OpBranch %74 + %75 = OpLabel + %78 = OpLoad %_arr_mat4v4float_uint_4_0 %68 None + OpReturnValue %78 OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/struct/mat2x2_f16/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/struct/mat2x2_f16/dynamic_index_via_ptr.wgsl.expected.glsl index ccab01e..02e4c81 100644 --- a/test/tint/buffer/uniform/std140/struct/mat2x2_f16/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/struct/mat2x2_f16/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -39,76 +39,77 @@ } v; int counter = 0; int i() { - counter = (counter + 1); + uint v_1 = uint(counter); + counter = int((v_1 + uint(1))); return counter; } Inner tint_convert_Inner(Inner_std140 tint_input) { return Inner(f16mat2(tint_input.m_col0, tint_input.m_col1)); } Outer tint_convert_Outer(Outer_std140 tint_input) { - Inner v_1[4] = Inner[4](Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf)))); + Inner v_2[4] = Inner[4](Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf)))); { - uint v_2 = 0u; - v_2 = 0u; + uint v_3 = 0u; + v_3 = 0u; while(true) { - uint v_3 = v_2; - if ((v_3 >= 4u)) { + uint v_4 = v_3; + if ((v_4 >= 4u)) { break; } - v_1[v_3] = tint_convert_Inner(tint_input.a[v_3]); + v_2[v_4] = tint_convert_Inner(tint_input.a[v_4]); { - v_2 = (v_3 + 1u); + v_3 = (v_4 + 1u); } continue; } } - return Outer(v_1); + return Outer(v_2); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - uint v_4 = min(uint(i()), 3u); uint v_5 = min(uint(i()), 3u); - f16mat2 v_6 = f16mat2(v.inner[v_4].a[v_5].m_col0, v.inner[v_4].a[v_5].m_col1); - f16vec2 v_7 = v_6[min(uint(i()), 1u)]; - Outer_std140 v_8[4] = v.inner; - Outer v_9[4] = Outer[4](Outer(Inner[4](Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))))), Outer(Inner[4](Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))))), Outer(Inner[4](Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))))), Outer(Inner[4](Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf)))))); + uint v_6 = min(uint(i()), 3u); + f16mat2 v_7 = f16mat2(v.inner[v_5].a[v_6].m_col0, v.inner[v_5].a[v_6].m_col1); + f16vec2 v_8 = v_7[min(uint(i()), 1u)]; + Outer_std140 v_9[4] = v.inner; + Outer v_10[4] = Outer[4](Outer(Inner[4](Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))))), Outer(Inner[4](Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))))), Outer(Inner[4](Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))))), Outer(Inner[4](Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf)))))); { - uint v_10 = 0u; - v_10 = 0u; + uint v_11 = 0u; + v_11 = 0u; while(true) { - uint v_11 = v_10; - if ((v_11 >= 4u)) { + uint v_12 = v_11; + if ((v_12 >= 4u)) { break; } - v_9[v_11] = tint_convert_Outer(v_8[v_11]); + v_10[v_12] = tint_convert_Outer(v_9[v_12]); { - v_10 = (v_11 + 1u); + v_11 = (v_12 + 1u); } continue; } } - Outer l_a[4] = v_9; - Outer l_a_i = tint_convert_Outer(v.inner[v_4]); - Inner_std140 v_12[4] = v.inner[v_4].a; - Inner v_13[4] = Inner[4](Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf)))); + Outer l_a[4] = v_10; + Outer l_a_i = tint_convert_Outer(v.inner[v_5]); + Inner_std140 v_13[4] = v.inner[v_5].a; + Inner v_14[4] = Inner[4](Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat2(f16vec2(0.0hf), f16vec2(0.0hf)))); { - uint v_14 = 0u; - v_14 = 0u; + uint v_15 = 0u; + v_15 = 0u; while(true) { - uint v_15 = v_14; - if ((v_15 >= 4u)) { + uint v_16 = v_15; + if ((v_16 >= 4u)) { break; } - v_13[v_15] = tint_convert_Inner(v_12[v_15]); + v_14[v_16] = tint_convert_Inner(v_13[v_16]); { - v_14 = (v_15 + 1u); + v_15 = (v_16 + 1u); } continue; } } - Inner l_a_i_a[4] = v_13; - Inner l_a_i_a_i = tint_convert_Inner(v.inner[v_4].a[v_5]); - f16mat2 l_a_i_a_i_m = v_6; - f16vec2 l_a_i_a_i_m_i = v_7; - float16_t l_a_i_a_i_m_i_i = v_7[min(uint(i()), 1u)]; + Inner l_a_i_a[4] = v_14; + Inner l_a_i_a_i = tint_convert_Inner(v.inner[v_5].a[v_6]); + f16mat2 l_a_i_a_i_m = v_7; + f16vec2 l_a_i_a_i_m_i = v_8; + float16_t l_a_i_a_i_m_i_i = v_8[min(uint(i()), 1u)]; }
diff --git a/test/tint/buffer/uniform/std140/struct/mat2x2_f16/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/struct/mat2x2_f16/dynamic_index_via_ptr.wgsl.expected.spvasm index 30d14d1..e548a8e 100644 --- a/test/tint/buffer/uniform/std140/struct/mat2x2_f16/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/struct/mat2x2_f16/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,13 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 209 +; Bound: 212 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess - %33 = OpExtInstImport "GLSL.std.450" + %36 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -72,7 +72,7 @@ %17 = OpTypeFunction %int %int_1 = OpConstant %int 1 %void = OpTypeVoid - %25 = OpTypeFunction %void + %28 = OpTypeFunction %void %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 = OpTypePointer Uniform %_arr_Outer_std140_tint_explicit_layout_uint_4 %uint_0 = OpConstant %uint 0 %uint_3 = OpConstant %uint 3 @@ -93,242 +93,245 @@ %Outer = OpTypeStruct %_arr_Inner_uint_4 %_arr_Outer_uint_4 = OpTypeArray %Outer %uint_4 %_ptr_Function__arr_Outer_uint_4 = OpTypePointer Function %_arr_Outer_uint_4 - %74 = OpConstantNull %_arr_Outer_uint_4 + %77 = OpConstantNull %_arr_Outer_uint_4 %_ptr_Function__arr_Inner_std140_uint_4_0 = OpTypePointer Function %_arr_Inner_std140_uint_4_0 %_ptr_Function__arr_Inner_uint_4 = OpTypePointer Function %_arr_Inner_uint_4 - %95 = OpConstantNull %_arr_Inner_uint_4 + %98 = OpConstantNull %_arr_Inner_uint_4 %bool = OpTypeBool %_ptr_Function_Outer = OpTypePointer Function %Outer %_ptr_Function_Outer_std140 = OpTypePointer Function %Outer_std140 %_ptr_Function_Inner = OpTypePointer Function %Inner %_ptr_Function_Inner_std140 = OpTypePointer Function %Inner_std140 - %131 = OpTypeFunction %Inner %Inner_std140 - %138 = OpTypeFunction %Outer %Outer_std140 - %160 = OpTypeFunction %_arr_Inner_std140_uint_4_0 %_arr_Inner_std140_uint_4 + %134 = OpTypeFunction %Inner %Inner_std140 + %141 = OpTypeFunction %Outer %Outer_std140 + %163 = OpTypeFunction %_arr_Inner_std140_uint_4_0 %_arr_Inner_std140_uint_4 %_ptr_Function__arr_Inner_std140_uint_4 = OpTypePointer Function %_arr_Inner_std140_uint_4 - %165 = OpConstantNull %_arr_Inner_std140_uint_4_0 - %181 = OpTypeFunction %Outer_std140 %Outer_std140_tint_explicit_layout - %187 = OpTypeFunction %_arr_Outer_std140_uint_4 %_arr_Outer_std140_tint_explicit_layout_uint_4 + %168 = OpConstantNull %_arr_Inner_std140_uint_4_0 + %184 = OpTypeFunction %Outer_std140 %Outer_std140_tint_explicit_layout + %190 = OpTypeFunction %_arr_Outer_std140_uint_4 %_arr_Outer_std140_tint_explicit_layout_uint_4 %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 = OpTypePointer Function %_arr_Outer_std140_tint_explicit_layout_uint_4 - %192 = OpConstantNull %_arr_Outer_std140_uint_4 + %195 = OpConstantNull %_arr_Outer_std140_uint_4 %_ptr_Function_Outer_std140_tint_explicit_layout = OpTypePointer Function %Outer_std140_tint_explicit_layout %i = OpFunction %int None %17 %18 = OpLabel %19 = OpLoad %int %counter None - %20 = OpIAdd %int %19 %int_1 - OpStore %counter %20 None - %22 = OpLoad %int %counter None - OpReturnValue %22 + %20 = OpBitcast %uint %19 + %21 = OpBitcast %uint %int_1 + %23 = OpIAdd %uint %20 %21 + %24 = OpBitcast %int %23 + OpStore %counter %24 None + %25 = OpLoad %int %counter None + OpReturnValue %25 OpFunctionEnd - %f = OpFunction %void None %25 - %26 = OpLabel - %52 = OpVariable %_ptr_Function_mat2v2half Function - %66 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function - %68 = OpVariable %_ptr_Function__arr_Outer_uint_4 Function %74 - %91 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function - %93 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %95 - %27 = OpAccessChain %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 %1 %uint_0 - %30 = OpFunctionCall %int %i - %31 = OpBitcast %uint %30 - %32 = OpExtInst %uint %33 UMin %31 %uint_3 - %35 = OpAccessChain %_ptr_Uniform_Outer_std140_tint_explicit_layout %27 %32 - %37 = OpAccessChain %_ptr_Uniform__arr_Inner_std140_uint_4 %35 %uint_0 - %39 = OpFunctionCall %int %i - %40 = OpBitcast %uint %39 - %41 = OpExtInst %uint %33 UMin %40 %uint_3 - %42 = OpAccessChain %_ptr_Uniform_Inner_std140 %37 %41 - %44 = OpAccessChain %_ptr_Uniform_v2half %42 %uint_0 - %46 = OpLoad %v2half %44 None - %47 = OpAccessChain %_ptr_Uniform_v2half %42 %uint_1 + %f = OpFunction %void None %28 + %29 = OpLabel + %55 = OpVariable %_ptr_Function_mat2v2half Function + %69 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function + %71 = OpVariable %_ptr_Function__arr_Outer_uint_4 Function %77 + %94 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function + %96 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %98 + %30 = OpAccessChain %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 %1 %uint_0 + %33 = OpFunctionCall %int %i + %34 = OpBitcast %uint %33 + %35 = OpExtInst %uint %36 UMin %34 %uint_3 + %38 = OpAccessChain %_ptr_Uniform_Outer_std140_tint_explicit_layout %30 %35 + %40 = OpAccessChain %_ptr_Uniform__arr_Inner_std140_uint_4 %38 %uint_0 + %42 = OpFunctionCall %int %i + %43 = OpBitcast %uint %42 + %44 = OpExtInst %uint %36 UMin %43 %uint_3 + %45 = OpAccessChain %_ptr_Uniform_Inner_std140 %40 %44 + %47 = OpAccessChain %_ptr_Uniform_v2half %45 %uint_0 %49 = OpLoad %v2half %47 None -%l_a_i_a_i_m = OpCompositeConstruct %mat2v2half %46 %49 - OpStore %52 %l_a_i_a_i_m - %54 = OpFunctionCall %int %i - %55 = OpBitcast %uint %54 - %56 = OpExtInst %uint %33 UMin %55 %uint_1 - %57 = OpAccessChain %_ptr_Function_v2half %52 %56 -%l_a_i_a_i_m_i = OpLoad %v2half %57 None - %60 = OpLoad %_arr_Outer_std140_tint_explicit_layout_uint_4 %27 None - %61 = OpFunctionCall %_arr_Outer_std140_uint_4 %tint_convert_explicit_layout_1 %60 - OpStore %66 %61 - OpBranch %75 - %75 = OpLabel + %50 = OpAccessChain %_ptr_Uniform_v2half %45 %uint_1 + %52 = OpLoad %v2half %50 None +%l_a_i_a_i_m = OpCompositeConstruct %mat2v2half %49 %52 + OpStore %55 %l_a_i_a_i_m + %57 = OpFunctionCall %int %i + %58 = OpBitcast %uint %57 + %59 = OpExtInst %uint %36 UMin %58 %uint_1 + %60 = OpAccessChain %_ptr_Function_v2half %55 %59 +%l_a_i_a_i_m_i = OpLoad %v2half %60 None + %63 = OpLoad %_arr_Outer_std140_tint_explicit_layout_uint_4 %30 None + %64 = OpFunctionCall %_arr_Outer_std140_uint_4 %tint_convert_explicit_layout_1 %63 + OpStore %69 %64 OpBranch %78 %78 = OpLabel - %80 = OpPhi %uint %uint_0 %75 %81 %77 - OpLoopMerge %79 %77 None - OpBranch %76 - %76 = OpLabel - %111 = OpUGreaterThanEqual %bool %80 %uint_4 - OpSelectionMerge %113 None - OpBranchConditional %111 %114 %113 - %114 = OpLabel + OpBranch %81 + %81 = OpLabel + %83 = OpPhi %uint %uint_0 %78 %84 %80 + OpLoopMerge %82 %80 None OpBranch %79 - %113 = OpLabel - %115 = OpAccessChain %_ptr_Function_Outer %68 %80 - %117 = OpAccessChain %_ptr_Function_Outer_std140 %66 %80 - %119 = OpLoad %Outer_std140 %117 None - %120 = OpFunctionCall %Outer %tint_convert_Outer %119 - OpStore %115 %120 None - OpBranch %77 - %77 = OpLabel - %81 = OpIAdd %uint %80 %uint_1 - OpBranch %78 %79 = OpLabel - %l_a = OpLoad %_arr_Outer_uint_4 %68 None - %83 = OpLoad %Outer_std140_tint_explicit_layout %35 None - %84 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %83 - %l_a_i = OpFunctionCall %Outer %tint_convert_Outer %84 - %88 = OpLoad %_arr_Inner_std140_uint_4 %37 None - %89 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %88 - OpStore %91 %89 - OpBranch %96 - %96 = OpLabel + %114 = OpUGreaterThanEqual %bool %83 %uint_4 + OpSelectionMerge %116 None + OpBranchConditional %114 %117 %116 + %117 = OpLabel + OpBranch %82 + %116 = OpLabel + %118 = OpAccessChain %_ptr_Function_Outer %71 %83 + %120 = OpAccessChain %_ptr_Function_Outer_std140 %69 %83 + %122 = OpLoad %Outer_std140 %120 None + %123 = OpFunctionCall %Outer %tint_convert_Outer %122 + OpStore %118 %123 None + OpBranch %80 + %80 = OpLabel + %84 = OpIAdd %uint %83 %uint_1 + OpBranch %81 + %82 = OpLabel + %l_a = OpLoad %_arr_Outer_uint_4 %71 None + %86 = OpLoad %Outer_std140_tint_explicit_layout %38 None + %87 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %86 + %l_a_i = OpFunctionCall %Outer %tint_convert_Outer %87 + %91 = OpLoad %_arr_Inner_std140_uint_4 %40 None + %92 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %91 + OpStore %94 %92 OpBranch %99 %99 = OpLabel - %101 = OpPhi %uint %uint_0 %96 %102 %98 - OpLoopMerge %100 %98 None - OpBranch %97 - %97 = OpLabel - %121 = OpUGreaterThanEqual %bool %101 %uint_4 - OpSelectionMerge %122 None - OpBranchConditional %121 %123 %122 - %123 = OpLabel + OpBranch %102 + %102 = OpLabel + %104 = OpPhi %uint %uint_0 %99 %105 %101 + OpLoopMerge %103 %101 None OpBranch %100 - %122 = OpLabel - %124 = OpAccessChain %_ptr_Function_Inner %93 %101 - %126 = OpAccessChain %_ptr_Function_Inner_std140 %91 %101 - %128 = OpLoad %Inner_std140 %126 None - %129 = OpFunctionCall %Inner %tint_convert_Inner %128 - OpStore %124 %129 None - OpBranch %98 - %98 = OpLabel - %102 = OpIAdd %uint %101 %uint_1 - OpBranch %99 %100 = OpLabel - %l_a_i_a = OpLoad %_arr_Inner_uint_4 %93 None - %104 = OpLoad %Inner_std140 %42 None - %l_a_i_a_i = OpFunctionCall %Inner %tint_convert_Inner %104 - %107 = OpFunctionCall %int %i - %108 = OpBitcast %uint %107 - %109 = OpExtInst %uint %33 UMin %108 %uint_1 -%l_a_i_a_i_m_i_i = OpVectorExtractDynamic %half %l_a_i_a_i_m_i %109 + %124 = OpUGreaterThanEqual %bool %104 %uint_4 + OpSelectionMerge %125 None + OpBranchConditional %124 %126 %125 + %126 = OpLabel + OpBranch %103 + %125 = OpLabel + %127 = OpAccessChain %_ptr_Function_Inner %96 %104 + %129 = OpAccessChain %_ptr_Function_Inner_std140 %94 %104 + %131 = OpLoad %Inner_std140 %129 None + %132 = OpFunctionCall %Inner %tint_convert_Inner %131 + OpStore %127 %132 None + OpBranch %101 + %101 = OpLabel + %105 = OpIAdd %uint %104 %uint_1 + OpBranch %102 + %103 = OpLabel + %l_a_i_a = OpLoad %_arr_Inner_uint_4 %96 None + %107 = OpLoad %Inner_std140 %45 None + %l_a_i_a_i = OpFunctionCall %Inner %tint_convert_Inner %107 + %110 = OpFunctionCall %int %i + %111 = OpBitcast %uint %110 + %112 = OpExtInst %uint %36 UMin %111 %uint_1 +%l_a_i_a_i_m_i_i = OpVectorExtractDynamic %half %l_a_i_a_i_m_i %112 OpReturn OpFunctionEnd -%tint_convert_Inner = OpFunction %Inner None %131 +%tint_convert_Inner = OpFunction %Inner None %134 %tint_input = OpFunctionParameter %Inner_std140 - %132 = OpLabel - %133 = OpCompositeExtract %v2half %tint_input 0 - %134 = OpCompositeExtract %v2half %tint_input 1 - %135 = OpCompositeConstruct %mat2v2half %133 %134 - %136 = OpCompositeConstruct %Inner %135 - OpReturnValue %136 + %135 = OpLabel + %136 = OpCompositeExtract %v2half %tint_input 0 + %137 = OpCompositeExtract %v2half %tint_input 1 + %138 = OpCompositeConstruct %mat2v2half %136 %137 + %139 = OpCompositeConstruct %Inner %138 + OpReturnValue %139 OpFunctionEnd -%tint_convert_Outer = OpFunction %Outer None %138 +%tint_convert_Outer = OpFunction %Outer None %141 %tint_input_0 = OpFunctionParameter %Outer_std140 - %139 = OpLabel - %141 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function - %142 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %95 - %140 = OpCompositeExtract %_arr_Inner_std140_uint_4_0 %tint_input_0 0 - OpStore %141 %140 - OpBranch %143 - %143 = OpLabel + %142 = OpLabel + %144 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function + %145 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %98 + %143 = OpCompositeExtract %_arr_Inner_std140_uint_4_0 %tint_input_0 0 + OpStore %144 %143 OpBranch %146 %146 = OpLabel - %148 = OpPhi %uint %uint_0 %143 %149 %145 - OpLoopMerge %147 %145 None - OpBranch %144 - %144 = OpLabel - %152 = OpUGreaterThanEqual %bool %148 %uint_4 - OpSelectionMerge %153 None - OpBranchConditional %152 %154 %153 - %154 = OpLabel + OpBranch %149 + %149 = OpLabel + %151 = OpPhi %uint %uint_0 %146 %152 %148 + OpLoopMerge %150 %148 None OpBranch %147 - %153 = OpLabel - %155 = OpAccessChain %_ptr_Function_Inner %142 %148 - %156 = OpAccessChain %_ptr_Function_Inner_std140 %141 %148 - %157 = OpLoad %Inner_std140 %156 None - %158 = OpFunctionCall %Inner %tint_convert_Inner %157 - OpStore %155 %158 None - OpBranch %145 - %145 = OpLabel - %149 = OpIAdd %uint %148 %uint_1 - OpBranch %146 %147 = OpLabel - %150 = OpLoad %_arr_Inner_uint_4 %142 None - %151 = OpCompositeConstruct %Outer %150 - OpReturnValue %151 + %155 = OpUGreaterThanEqual %bool %151 %uint_4 + OpSelectionMerge %156 None + OpBranchConditional %155 %157 %156 + %157 = OpLabel + OpBranch %150 + %156 = OpLabel + %158 = OpAccessChain %_ptr_Function_Inner %145 %151 + %159 = OpAccessChain %_ptr_Function_Inner_std140 %144 %151 + %160 = OpLoad %Inner_std140 %159 None + %161 = OpFunctionCall %Inner %tint_convert_Inner %160 + OpStore %158 %161 None + OpBranch %148 + %148 = OpLabel + %152 = OpIAdd %uint %151 %uint_1 + OpBranch %149 + %150 = OpLabel + %153 = OpLoad %_arr_Inner_uint_4 %145 None + %154 = OpCompositeConstruct %Outer %153 + OpReturnValue %154 OpFunctionEnd -%tint_convert_explicit_layout = OpFunction %_arr_Inner_std140_uint_4_0 None %160 +%tint_convert_explicit_layout = OpFunction %_arr_Inner_std140_uint_4_0 None %163 %tint_source = OpFunctionParameter %_arr_Inner_std140_uint_4 - %161 = OpLabel - %162 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4 Function - %164 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function %165 - OpStore %162 %tint_source - OpBranch %166 - %166 = OpLabel + %164 = OpLabel + %165 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4 Function + %167 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function %168 + OpStore %165 %tint_source OpBranch %169 %169 = OpLabel - %171 = OpPhi %uint %uint_0 %166 %172 %168 - OpLoopMerge %170 %168 None - OpBranch %167 - %167 = OpLabel - %174 = OpUGreaterThanEqual %bool %171 %uint_4 - OpSelectionMerge %175 None - OpBranchConditional %174 %176 %175 - %176 = OpLabel + OpBranch %172 + %172 = OpLabel + %174 = OpPhi %uint %uint_0 %169 %175 %171 + OpLoopMerge %173 %171 None OpBranch %170 - %175 = OpLabel - %177 = OpAccessChain %_ptr_Function_Inner_std140 %162 %171 - %178 = OpLoad %Inner_std140 %177 None - %179 = OpAccessChain %_ptr_Function_Inner_std140 %164 %171 - OpStore %179 %178 None - OpBranch %168 - %168 = OpLabel - %172 = OpIAdd %uint %171 %uint_1 - OpBranch %169 %170 = OpLabel - %173 = OpLoad %_arr_Inner_std140_uint_4_0 %164 None - OpReturnValue %173 + %177 = OpUGreaterThanEqual %bool %174 %uint_4 + OpSelectionMerge %178 None + OpBranchConditional %177 %179 %178 + %179 = OpLabel + OpBranch %173 + %178 = OpLabel + %180 = OpAccessChain %_ptr_Function_Inner_std140 %165 %174 + %181 = OpLoad %Inner_std140 %180 None + %182 = OpAccessChain %_ptr_Function_Inner_std140 %167 %174 + OpStore %182 %181 None + OpBranch %171 + %171 = OpLabel + %175 = OpIAdd %uint %174 %uint_1 + OpBranch %172 + %173 = OpLabel + %176 = OpLoad %_arr_Inner_std140_uint_4_0 %167 None + OpReturnValue %176 OpFunctionEnd -%tint_convert_explicit_layout_0 = OpFunction %Outer_std140 None %181 +%tint_convert_explicit_layout_0 = OpFunction %Outer_std140 None %184 %tint_source_0 = OpFunctionParameter %Outer_std140_tint_explicit_layout - %182 = OpLabel - %183 = OpCompositeExtract %_arr_Inner_std140_uint_4 %tint_source_0 0 - %184 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %183 - %185 = OpCompositeConstruct %Outer_std140 %184 - OpReturnValue %185 + %185 = OpLabel + %186 = OpCompositeExtract %_arr_Inner_std140_uint_4 %tint_source_0 0 + %187 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %186 + %188 = OpCompositeConstruct %Outer_std140 %187 + OpReturnValue %188 OpFunctionEnd -%tint_convert_explicit_layout_1 = OpFunction %_arr_Outer_std140_uint_4 None %187 +%tint_convert_explicit_layout_1 = OpFunction %_arr_Outer_std140_uint_4 None %190 %tint_source_1 = OpFunctionParameter %_arr_Outer_std140_tint_explicit_layout_uint_4 - %188 = OpLabel - %189 = OpVariable %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 Function - %191 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function %192 - OpStore %189 %tint_source_1 - OpBranch %193 - %193 = OpLabel + %191 = OpLabel + %192 = OpVariable %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 Function + %194 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function %195 + OpStore %192 %tint_source_1 OpBranch %196 %196 = OpLabel - %198 = OpPhi %uint %uint_0 %193 %199 %195 - OpLoopMerge %197 %195 None - OpBranch %194 - %194 = OpLabel - %201 = OpUGreaterThanEqual %bool %198 %uint_4 - OpSelectionMerge %202 None - OpBranchConditional %201 %203 %202 - %203 = OpLabel + OpBranch %199 + %199 = OpLabel + %201 = OpPhi %uint %uint_0 %196 %202 %198 + OpLoopMerge %200 %198 None OpBranch %197 - %202 = OpLabel - %204 = OpAccessChain %_ptr_Function_Outer_std140_tint_explicit_layout %189 %198 - %206 = OpLoad %Outer_std140_tint_explicit_layout %204 None - %207 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %206 - %208 = OpAccessChain %_ptr_Function_Outer_std140 %191 %198 - OpStore %208 %207 None - OpBranch %195 - %195 = OpLabel - %199 = OpIAdd %uint %198 %uint_1 - OpBranch %196 %197 = OpLabel - %200 = OpLoad %_arr_Outer_std140_uint_4 %191 None - OpReturnValue %200 + %204 = OpUGreaterThanEqual %bool %201 %uint_4 + OpSelectionMerge %205 None + OpBranchConditional %204 %206 %205 + %206 = OpLabel + OpBranch %200 + %205 = OpLabel + %207 = OpAccessChain %_ptr_Function_Outer_std140_tint_explicit_layout %192 %201 + %209 = OpLoad %Outer_std140_tint_explicit_layout %207 None + %210 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %209 + %211 = OpAccessChain %_ptr_Function_Outer_std140 %194 %201 + OpStore %211 %210 None + OpBranch %198 + %198 = OpLabel + %202 = OpIAdd %uint %201 %uint_1 + OpBranch %199 + %200 = OpLabel + %203 = OpLoad %_arr_Outer_std140_uint_4 %194 None + OpReturnValue %203 OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/struct/mat2x2_f32/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/struct/mat2x2_f32/dynamic_index_via_ptr.wgsl.expected.glsl index 9fec8d2..0d86ec7 100644 --- a/test/tint/buffer/uniform/std140/struct/mat2x2_f32/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/struct/mat2x2_f32/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -36,76 +36,77 @@ } v; int counter = 0; int i() { - counter = (counter + 1); + uint v_1 = uint(counter); + counter = int((v_1 + uint(1))); return counter; } Inner tint_convert_Inner(Inner_std140 tint_input) { return Inner(mat2(tint_input.m_col0, tint_input.m_col1)); } Outer tint_convert_Outer(Outer_std140 tint_input) { - Inner v_1[4] = Inner[4](Inner(mat2(vec2(0.0f), vec2(0.0f))), Inner(mat2(vec2(0.0f), vec2(0.0f))), Inner(mat2(vec2(0.0f), vec2(0.0f))), Inner(mat2(vec2(0.0f), vec2(0.0f)))); + Inner v_2[4] = Inner[4](Inner(mat2(vec2(0.0f), vec2(0.0f))), Inner(mat2(vec2(0.0f), vec2(0.0f))), Inner(mat2(vec2(0.0f), vec2(0.0f))), Inner(mat2(vec2(0.0f), vec2(0.0f)))); { - uint v_2 = 0u; - v_2 = 0u; + uint v_3 = 0u; + v_3 = 0u; while(true) { - uint v_3 = v_2; - if ((v_3 >= 4u)) { + uint v_4 = v_3; + if ((v_4 >= 4u)) { break; } - v_1[v_3] = tint_convert_Inner(tint_input.a[v_3]); + v_2[v_4] = tint_convert_Inner(tint_input.a[v_4]); { - v_2 = (v_3 + 1u); + v_3 = (v_4 + 1u); } continue; } } - return Outer(v_1); + return Outer(v_2); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - uint v_4 = min(uint(i()), 3u); uint v_5 = min(uint(i()), 3u); - mat2 v_6 = mat2(v.inner[v_4].a[v_5].m_col0, v.inner[v_4].a[v_5].m_col1); - vec2 v_7 = v_6[min(uint(i()), 1u)]; - Outer_std140 v_8[4] = v.inner; - Outer v_9[4] = Outer[4](Outer(Inner[4](Inner(mat2(vec2(0.0f), vec2(0.0f))), Inner(mat2(vec2(0.0f), vec2(0.0f))), Inner(mat2(vec2(0.0f), vec2(0.0f))), Inner(mat2(vec2(0.0f), vec2(0.0f))))), Outer(Inner[4](Inner(mat2(vec2(0.0f), vec2(0.0f))), Inner(mat2(vec2(0.0f), vec2(0.0f))), Inner(mat2(vec2(0.0f), vec2(0.0f))), Inner(mat2(vec2(0.0f), vec2(0.0f))))), Outer(Inner[4](Inner(mat2(vec2(0.0f), vec2(0.0f))), Inner(mat2(vec2(0.0f), vec2(0.0f))), Inner(mat2(vec2(0.0f), vec2(0.0f))), Inner(mat2(vec2(0.0f), vec2(0.0f))))), Outer(Inner[4](Inner(mat2(vec2(0.0f), vec2(0.0f))), Inner(mat2(vec2(0.0f), vec2(0.0f))), Inner(mat2(vec2(0.0f), vec2(0.0f))), Inner(mat2(vec2(0.0f), vec2(0.0f)))))); + uint v_6 = min(uint(i()), 3u); + mat2 v_7 = mat2(v.inner[v_5].a[v_6].m_col0, v.inner[v_5].a[v_6].m_col1); + vec2 v_8 = v_7[min(uint(i()), 1u)]; + Outer_std140 v_9[4] = v.inner; + Outer v_10[4] = Outer[4](Outer(Inner[4](Inner(mat2(vec2(0.0f), vec2(0.0f))), Inner(mat2(vec2(0.0f), vec2(0.0f))), Inner(mat2(vec2(0.0f), vec2(0.0f))), Inner(mat2(vec2(0.0f), vec2(0.0f))))), Outer(Inner[4](Inner(mat2(vec2(0.0f), vec2(0.0f))), Inner(mat2(vec2(0.0f), vec2(0.0f))), Inner(mat2(vec2(0.0f), vec2(0.0f))), Inner(mat2(vec2(0.0f), vec2(0.0f))))), Outer(Inner[4](Inner(mat2(vec2(0.0f), vec2(0.0f))), Inner(mat2(vec2(0.0f), vec2(0.0f))), Inner(mat2(vec2(0.0f), vec2(0.0f))), Inner(mat2(vec2(0.0f), vec2(0.0f))))), Outer(Inner[4](Inner(mat2(vec2(0.0f), vec2(0.0f))), Inner(mat2(vec2(0.0f), vec2(0.0f))), Inner(mat2(vec2(0.0f), vec2(0.0f))), Inner(mat2(vec2(0.0f), vec2(0.0f)))))); { - uint v_10 = 0u; - v_10 = 0u; + uint v_11 = 0u; + v_11 = 0u; while(true) { - uint v_11 = v_10; - if ((v_11 >= 4u)) { + uint v_12 = v_11; + if ((v_12 >= 4u)) { break; } - v_9[v_11] = tint_convert_Outer(v_8[v_11]); + v_10[v_12] = tint_convert_Outer(v_9[v_12]); { - v_10 = (v_11 + 1u); + v_11 = (v_12 + 1u); } continue; } } - Outer l_a[4] = v_9; - Outer l_a_i = tint_convert_Outer(v.inner[v_4]); - Inner_std140 v_12[4] = v.inner[v_4].a; - Inner v_13[4] = Inner[4](Inner(mat2(vec2(0.0f), vec2(0.0f))), Inner(mat2(vec2(0.0f), vec2(0.0f))), Inner(mat2(vec2(0.0f), vec2(0.0f))), Inner(mat2(vec2(0.0f), vec2(0.0f)))); + Outer l_a[4] = v_10; + Outer l_a_i = tint_convert_Outer(v.inner[v_5]); + Inner_std140 v_13[4] = v.inner[v_5].a; + Inner v_14[4] = Inner[4](Inner(mat2(vec2(0.0f), vec2(0.0f))), Inner(mat2(vec2(0.0f), vec2(0.0f))), Inner(mat2(vec2(0.0f), vec2(0.0f))), Inner(mat2(vec2(0.0f), vec2(0.0f)))); { - uint v_14 = 0u; - v_14 = 0u; + uint v_15 = 0u; + v_15 = 0u; while(true) { - uint v_15 = v_14; - if ((v_15 >= 4u)) { + uint v_16 = v_15; + if ((v_16 >= 4u)) { break; } - v_13[v_15] = tint_convert_Inner(v_12[v_15]); + v_14[v_16] = tint_convert_Inner(v_13[v_16]); { - v_14 = (v_15 + 1u); + v_15 = (v_16 + 1u); } continue; } } - Inner l_a_i_a[4] = v_13; - Inner l_a_i_a_i = tint_convert_Inner(v.inner[v_4].a[v_5]); - mat2 l_a_i_a_i_m = v_6; - vec2 l_a_i_a_i_m_i = v_7; - float l_a_i_a_i_m_i_i = v_7[min(uint(i()), 1u)]; + Inner l_a_i_a[4] = v_14; + Inner l_a_i_a_i = tint_convert_Inner(v.inner[v_5].a[v_6]); + mat2 l_a_i_a_i_m = v_7; + vec2 l_a_i_a_i_m_i = v_8; + float l_a_i_a_i_m_i_i = v_8[min(uint(i()), 1u)]; }
diff --git a/test/tint/buffer/uniform/std140/struct/mat2x2_f32/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/struct/mat2x2_f32/dynamic_index_via_ptr.wgsl.expected.spvasm index 0306c28..82ab8a0 100644 --- a/test/tint/buffer/uniform/std140/struct/mat2x2_f32/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/struct/mat2x2_f32/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,10 +1,10 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 209 +; Bound: 212 ; Schema: 0 OpCapability Shader - %33 = OpExtInstImport "GLSL.std.450" + %36 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -69,7 +69,7 @@ %17 = OpTypeFunction %int %int_1 = OpConstant %int 1 %void = OpTypeVoid - %25 = OpTypeFunction %void + %28 = OpTypeFunction %void %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 = OpTypePointer Uniform %_arr_Outer_std140_tint_explicit_layout_uint_4 %uint_0 = OpConstant %uint 0 %uint_3 = OpConstant %uint 3 @@ -90,242 +90,245 @@ %Outer = OpTypeStruct %_arr_Inner_uint_4 %_arr_Outer_uint_4 = OpTypeArray %Outer %uint_4 %_ptr_Function__arr_Outer_uint_4 = OpTypePointer Function %_arr_Outer_uint_4 - %74 = OpConstantNull %_arr_Outer_uint_4 + %77 = OpConstantNull %_arr_Outer_uint_4 %_ptr_Function__arr_Inner_std140_uint_4_0 = OpTypePointer Function %_arr_Inner_std140_uint_4_0 %_ptr_Function__arr_Inner_uint_4 = OpTypePointer Function %_arr_Inner_uint_4 - %95 = OpConstantNull %_arr_Inner_uint_4 + %98 = OpConstantNull %_arr_Inner_uint_4 %bool = OpTypeBool %_ptr_Function_Outer = OpTypePointer Function %Outer %_ptr_Function_Outer_std140 = OpTypePointer Function %Outer_std140 %_ptr_Function_Inner = OpTypePointer Function %Inner %_ptr_Function_Inner_std140 = OpTypePointer Function %Inner_std140 - %131 = OpTypeFunction %Inner %Inner_std140 - %138 = OpTypeFunction %Outer %Outer_std140 - %160 = OpTypeFunction %_arr_Inner_std140_uint_4_0 %_arr_Inner_std140_uint_4 + %134 = OpTypeFunction %Inner %Inner_std140 + %141 = OpTypeFunction %Outer %Outer_std140 + %163 = OpTypeFunction %_arr_Inner_std140_uint_4_0 %_arr_Inner_std140_uint_4 %_ptr_Function__arr_Inner_std140_uint_4 = OpTypePointer Function %_arr_Inner_std140_uint_4 - %165 = OpConstantNull %_arr_Inner_std140_uint_4_0 - %181 = OpTypeFunction %Outer_std140 %Outer_std140_tint_explicit_layout - %187 = OpTypeFunction %_arr_Outer_std140_uint_4 %_arr_Outer_std140_tint_explicit_layout_uint_4 + %168 = OpConstantNull %_arr_Inner_std140_uint_4_0 + %184 = OpTypeFunction %Outer_std140 %Outer_std140_tint_explicit_layout + %190 = OpTypeFunction %_arr_Outer_std140_uint_4 %_arr_Outer_std140_tint_explicit_layout_uint_4 %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 = OpTypePointer Function %_arr_Outer_std140_tint_explicit_layout_uint_4 - %192 = OpConstantNull %_arr_Outer_std140_uint_4 + %195 = OpConstantNull %_arr_Outer_std140_uint_4 %_ptr_Function_Outer_std140_tint_explicit_layout = OpTypePointer Function %Outer_std140_tint_explicit_layout %i = OpFunction %int None %17 %18 = OpLabel %19 = OpLoad %int %counter None - %20 = OpIAdd %int %19 %int_1 - OpStore %counter %20 None - %22 = OpLoad %int %counter None - OpReturnValue %22 + %20 = OpBitcast %uint %19 + %21 = OpBitcast %uint %int_1 + %23 = OpIAdd %uint %20 %21 + %24 = OpBitcast %int %23 + OpStore %counter %24 None + %25 = OpLoad %int %counter None + OpReturnValue %25 OpFunctionEnd - %f = OpFunction %void None %25 - %26 = OpLabel - %52 = OpVariable %_ptr_Function_mat2v2float Function - %66 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function - %68 = OpVariable %_ptr_Function__arr_Outer_uint_4 Function %74 - %91 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function - %93 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %95 - %27 = OpAccessChain %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 %1 %uint_0 - %30 = OpFunctionCall %int %i - %31 = OpBitcast %uint %30 - %32 = OpExtInst %uint %33 UMin %31 %uint_3 - %35 = OpAccessChain %_ptr_Uniform_Outer_std140_tint_explicit_layout %27 %32 - %37 = OpAccessChain %_ptr_Uniform__arr_Inner_std140_uint_4 %35 %uint_0 - %39 = OpFunctionCall %int %i - %40 = OpBitcast %uint %39 - %41 = OpExtInst %uint %33 UMin %40 %uint_3 - %42 = OpAccessChain %_ptr_Uniform_Inner_std140 %37 %41 - %44 = OpAccessChain %_ptr_Uniform_v2float %42 %uint_0 - %46 = OpLoad %v2float %44 None - %47 = OpAccessChain %_ptr_Uniform_v2float %42 %uint_1 + %f = OpFunction %void None %28 + %29 = OpLabel + %55 = OpVariable %_ptr_Function_mat2v2float Function + %69 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function + %71 = OpVariable %_ptr_Function__arr_Outer_uint_4 Function %77 + %94 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function + %96 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %98 + %30 = OpAccessChain %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 %1 %uint_0 + %33 = OpFunctionCall %int %i + %34 = OpBitcast %uint %33 + %35 = OpExtInst %uint %36 UMin %34 %uint_3 + %38 = OpAccessChain %_ptr_Uniform_Outer_std140_tint_explicit_layout %30 %35 + %40 = OpAccessChain %_ptr_Uniform__arr_Inner_std140_uint_4 %38 %uint_0 + %42 = OpFunctionCall %int %i + %43 = OpBitcast %uint %42 + %44 = OpExtInst %uint %36 UMin %43 %uint_3 + %45 = OpAccessChain %_ptr_Uniform_Inner_std140 %40 %44 + %47 = OpAccessChain %_ptr_Uniform_v2float %45 %uint_0 %49 = OpLoad %v2float %47 None -%l_a_i_a_i_m = OpCompositeConstruct %mat2v2float %46 %49 - OpStore %52 %l_a_i_a_i_m - %54 = OpFunctionCall %int %i - %55 = OpBitcast %uint %54 - %56 = OpExtInst %uint %33 UMin %55 %uint_1 - %57 = OpAccessChain %_ptr_Function_v2float %52 %56 -%l_a_i_a_i_m_i = OpLoad %v2float %57 None - %60 = OpLoad %_arr_Outer_std140_tint_explicit_layout_uint_4 %27 None - %61 = OpFunctionCall %_arr_Outer_std140_uint_4 %tint_convert_explicit_layout_1 %60 - OpStore %66 %61 - OpBranch %75 - %75 = OpLabel + %50 = OpAccessChain %_ptr_Uniform_v2float %45 %uint_1 + %52 = OpLoad %v2float %50 None +%l_a_i_a_i_m = OpCompositeConstruct %mat2v2float %49 %52 + OpStore %55 %l_a_i_a_i_m + %57 = OpFunctionCall %int %i + %58 = OpBitcast %uint %57 + %59 = OpExtInst %uint %36 UMin %58 %uint_1 + %60 = OpAccessChain %_ptr_Function_v2float %55 %59 +%l_a_i_a_i_m_i = OpLoad %v2float %60 None + %63 = OpLoad %_arr_Outer_std140_tint_explicit_layout_uint_4 %30 None + %64 = OpFunctionCall %_arr_Outer_std140_uint_4 %tint_convert_explicit_layout_1 %63 + OpStore %69 %64 OpBranch %78 %78 = OpLabel - %80 = OpPhi %uint %uint_0 %75 %81 %77 - OpLoopMerge %79 %77 None - OpBranch %76 - %76 = OpLabel - %111 = OpUGreaterThanEqual %bool %80 %uint_4 - OpSelectionMerge %113 None - OpBranchConditional %111 %114 %113 - %114 = OpLabel + OpBranch %81 + %81 = OpLabel + %83 = OpPhi %uint %uint_0 %78 %84 %80 + OpLoopMerge %82 %80 None OpBranch %79 - %113 = OpLabel - %115 = OpAccessChain %_ptr_Function_Outer %68 %80 - %117 = OpAccessChain %_ptr_Function_Outer_std140 %66 %80 - %119 = OpLoad %Outer_std140 %117 None - %120 = OpFunctionCall %Outer %tint_convert_Outer %119 - OpStore %115 %120 None - OpBranch %77 - %77 = OpLabel - %81 = OpIAdd %uint %80 %uint_1 - OpBranch %78 %79 = OpLabel - %l_a = OpLoad %_arr_Outer_uint_4 %68 None - %83 = OpLoad %Outer_std140_tint_explicit_layout %35 None - %84 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %83 - %l_a_i = OpFunctionCall %Outer %tint_convert_Outer %84 - %88 = OpLoad %_arr_Inner_std140_uint_4 %37 None - %89 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %88 - OpStore %91 %89 - OpBranch %96 - %96 = OpLabel + %114 = OpUGreaterThanEqual %bool %83 %uint_4 + OpSelectionMerge %116 None + OpBranchConditional %114 %117 %116 + %117 = OpLabel + OpBranch %82 + %116 = OpLabel + %118 = OpAccessChain %_ptr_Function_Outer %71 %83 + %120 = OpAccessChain %_ptr_Function_Outer_std140 %69 %83 + %122 = OpLoad %Outer_std140 %120 None + %123 = OpFunctionCall %Outer %tint_convert_Outer %122 + OpStore %118 %123 None + OpBranch %80 + %80 = OpLabel + %84 = OpIAdd %uint %83 %uint_1 + OpBranch %81 + %82 = OpLabel + %l_a = OpLoad %_arr_Outer_uint_4 %71 None + %86 = OpLoad %Outer_std140_tint_explicit_layout %38 None + %87 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %86 + %l_a_i = OpFunctionCall %Outer %tint_convert_Outer %87 + %91 = OpLoad %_arr_Inner_std140_uint_4 %40 None + %92 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %91 + OpStore %94 %92 OpBranch %99 %99 = OpLabel - %101 = OpPhi %uint %uint_0 %96 %102 %98 - OpLoopMerge %100 %98 None - OpBranch %97 - %97 = OpLabel - %121 = OpUGreaterThanEqual %bool %101 %uint_4 - OpSelectionMerge %122 None - OpBranchConditional %121 %123 %122 - %123 = OpLabel + OpBranch %102 + %102 = OpLabel + %104 = OpPhi %uint %uint_0 %99 %105 %101 + OpLoopMerge %103 %101 None OpBranch %100 - %122 = OpLabel - %124 = OpAccessChain %_ptr_Function_Inner %93 %101 - %126 = OpAccessChain %_ptr_Function_Inner_std140 %91 %101 - %128 = OpLoad %Inner_std140 %126 None - %129 = OpFunctionCall %Inner %tint_convert_Inner %128 - OpStore %124 %129 None - OpBranch %98 - %98 = OpLabel - %102 = OpIAdd %uint %101 %uint_1 - OpBranch %99 %100 = OpLabel - %l_a_i_a = OpLoad %_arr_Inner_uint_4 %93 None - %104 = OpLoad %Inner_std140 %42 None - %l_a_i_a_i = OpFunctionCall %Inner %tint_convert_Inner %104 - %107 = OpFunctionCall %int %i - %108 = OpBitcast %uint %107 - %109 = OpExtInst %uint %33 UMin %108 %uint_1 -%l_a_i_a_i_m_i_i = OpVectorExtractDynamic %float %l_a_i_a_i_m_i %109 + %124 = OpUGreaterThanEqual %bool %104 %uint_4 + OpSelectionMerge %125 None + OpBranchConditional %124 %126 %125 + %126 = OpLabel + OpBranch %103 + %125 = OpLabel + %127 = OpAccessChain %_ptr_Function_Inner %96 %104 + %129 = OpAccessChain %_ptr_Function_Inner_std140 %94 %104 + %131 = OpLoad %Inner_std140 %129 None + %132 = OpFunctionCall %Inner %tint_convert_Inner %131 + OpStore %127 %132 None + OpBranch %101 + %101 = OpLabel + %105 = OpIAdd %uint %104 %uint_1 + OpBranch %102 + %103 = OpLabel + %l_a_i_a = OpLoad %_arr_Inner_uint_4 %96 None + %107 = OpLoad %Inner_std140 %45 None + %l_a_i_a_i = OpFunctionCall %Inner %tint_convert_Inner %107 + %110 = OpFunctionCall %int %i + %111 = OpBitcast %uint %110 + %112 = OpExtInst %uint %36 UMin %111 %uint_1 +%l_a_i_a_i_m_i_i = OpVectorExtractDynamic %float %l_a_i_a_i_m_i %112 OpReturn OpFunctionEnd -%tint_convert_Inner = OpFunction %Inner None %131 +%tint_convert_Inner = OpFunction %Inner None %134 %tint_input = OpFunctionParameter %Inner_std140 - %132 = OpLabel - %133 = OpCompositeExtract %v2float %tint_input 0 - %134 = OpCompositeExtract %v2float %tint_input 1 - %135 = OpCompositeConstruct %mat2v2float %133 %134 - %136 = OpCompositeConstruct %Inner %135 - OpReturnValue %136 + %135 = OpLabel + %136 = OpCompositeExtract %v2float %tint_input 0 + %137 = OpCompositeExtract %v2float %tint_input 1 + %138 = OpCompositeConstruct %mat2v2float %136 %137 + %139 = OpCompositeConstruct %Inner %138 + OpReturnValue %139 OpFunctionEnd -%tint_convert_Outer = OpFunction %Outer None %138 +%tint_convert_Outer = OpFunction %Outer None %141 %tint_input_0 = OpFunctionParameter %Outer_std140 - %139 = OpLabel - %141 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function - %142 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %95 - %140 = OpCompositeExtract %_arr_Inner_std140_uint_4_0 %tint_input_0 0 - OpStore %141 %140 - OpBranch %143 - %143 = OpLabel + %142 = OpLabel + %144 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function + %145 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %98 + %143 = OpCompositeExtract %_arr_Inner_std140_uint_4_0 %tint_input_0 0 + OpStore %144 %143 OpBranch %146 %146 = OpLabel - %148 = OpPhi %uint %uint_0 %143 %149 %145 - OpLoopMerge %147 %145 None - OpBranch %144 - %144 = OpLabel - %152 = OpUGreaterThanEqual %bool %148 %uint_4 - OpSelectionMerge %153 None - OpBranchConditional %152 %154 %153 - %154 = OpLabel + OpBranch %149 + %149 = OpLabel + %151 = OpPhi %uint %uint_0 %146 %152 %148 + OpLoopMerge %150 %148 None OpBranch %147 - %153 = OpLabel - %155 = OpAccessChain %_ptr_Function_Inner %142 %148 - %156 = OpAccessChain %_ptr_Function_Inner_std140 %141 %148 - %157 = OpLoad %Inner_std140 %156 None - %158 = OpFunctionCall %Inner %tint_convert_Inner %157 - OpStore %155 %158 None - OpBranch %145 - %145 = OpLabel - %149 = OpIAdd %uint %148 %uint_1 - OpBranch %146 %147 = OpLabel - %150 = OpLoad %_arr_Inner_uint_4 %142 None - %151 = OpCompositeConstruct %Outer %150 - OpReturnValue %151 + %155 = OpUGreaterThanEqual %bool %151 %uint_4 + OpSelectionMerge %156 None + OpBranchConditional %155 %157 %156 + %157 = OpLabel + OpBranch %150 + %156 = OpLabel + %158 = OpAccessChain %_ptr_Function_Inner %145 %151 + %159 = OpAccessChain %_ptr_Function_Inner_std140 %144 %151 + %160 = OpLoad %Inner_std140 %159 None + %161 = OpFunctionCall %Inner %tint_convert_Inner %160 + OpStore %158 %161 None + OpBranch %148 + %148 = OpLabel + %152 = OpIAdd %uint %151 %uint_1 + OpBranch %149 + %150 = OpLabel + %153 = OpLoad %_arr_Inner_uint_4 %145 None + %154 = OpCompositeConstruct %Outer %153 + OpReturnValue %154 OpFunctionEnd -%tint_convert_explicit_layout = OpFunction %_arr_Inner_std140_uint_4_0 None %160 +%tint_convert_explicit_layout = OpFunction %_arr_Inner_std140_uint_4_0 None %163 %tint_source = OpFunctionParameter %_arr_Inner_std140_uint_4 - %161 = OpLabel - %162 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4 Function - %164 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function %165 - OpStore %162 %tint_source - OpBranch %166 - %166 = OpLabel + %164 = OpLabel + %165 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4 Function + %167 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function %168 + OpStore %165 %tint_source OpBranch %169 %169 = OpLabel - %171 = OpPhi %uint %uint_0 %166 %172 %168 - OpLoopMerge %170 %168 None - OpBranch %167 - %167 = OpLabel - %174 = OpUGreaterThanEqual %bool %171 %uint_4 - OpSelectionMerge %175 None - OpBranchConditional %174 %176 %175 - %176 = OpLabel + OpBranch %172 + %172 = OpLabel + %174 = OpPhi %uint %uint_0 %169 %175 %171 + OpLoopMerge %173 %171 None OpBranch %170 - %175 = OpLabel - %177 = OpAccessChain %_ptr_Function_Inner_std140 %162 %171 - %178 = OpLoad %Inner_std140 %177 None - %179 = OpAccessChain %_ptr_Function_Inner_std140 %164 %171 - OpStore %179 %178 None - OpBranch %168 - %168 = OpLabel - %172 = OpIAdd %uint %171 %uint_1 - OpBranch %169 %170 = OpLabel - %173 = OpLoad %_arr_Inner_std140_uint_4_0 %164 None - OpReturnValue %173 + %177 = OpUGreaterThanEqual %bool %174 %uint_4 + OpSelectionMerge %178 None + OpBranchConditional %177 %179 %178 + %179 = OpLabel + OpBranch %173 + %178 = OpLabel + %180 = OpAccessChain %_ptr_Function_Inner_std140 %165 %174 + %181 = OpLoad %Inner_std140 %180 None + %182 = OpAccessChain %_ptr_Function_Inner_std140 %167 %174 + OpStore %182 %181 None + OpBranch %171 + %171 = OpLabel + %175 = OpIAdd %uint %174 %uint_1 + OpBranch %172 + %173 = OpLabel + %176 = OpLoad %_arr_Inner_std140_uint_4_0 %167 None + OpReturnValue %176 OpFunctionEnd -%tint_convert_explicit_layout_0 = OpFunction %Outer_std140 None %181 +%tint_convert_explicit_layout_0 = OpFunction %Outer_std140 None %184 %tint_source_0 = OpFunctionParameter %Outer_std140_tint_explicit_layout - %182 = OpLabel - %183 = OpCompositeExtract %_arr_Inner_std140_uint_4 %tint_source_0 0 - %184 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %183 - %185 = OpCompositeConstruct %Outer_std140 %184 - OpReturnValue %185 + %185 = OpLabel + %186 = OpCompositeExtract %_arr_Inner_std140_uint_4 %tint_source_0 0 + %187 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %186 + %188 = OpCompositeConstruct %Outer_std140 %187 + OpReturnValue %188 OpFunctionEnd -%tint_convert_explicit_layout_1 = OpFunction %_arr_Outer_std140_uint_4 None %187 +%tint_convert_explicit_layout_1 = OpFunction %_arr_Outer_std140_uint_4 None %190 %tint_source_1 = OpFunctionParameter %_arr_Outer_std140_tint_explicit_layout_uint_4 - %188 = OpLabel - %189 = OpVariable %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 Function - %191 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function %192 - OpStore %189 %tint_source_1 - OpBranch %193 - %193 = OpLabel + %191 = OpLabel + %192 = OpVariable %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 Function + %194 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function %195 + OpStore %192 %tint_source_1 OpBranch %196 %196 = OpLabel - %198 = OpPhi %uint %uint_0 %193 %199 %195 - OpLoopMerge %197 %195 None - OpBranch %194 - %194 = OpLabel - %201 = OpUGreaterThanEqual %bool %198 %uint_4 - OpSelectionMerge %202 None - OpBranchConditional %201 %203 %202 - %203 = OpLabel + OpBranch %199 + %199 = OpLabel + %201 = OpPhi %uint %uint_0 %196 %202 %198 + OpLoopMerge %200 %198 None OpBranch %197 - %202 = OpLabel - %204 = OpAccessChain %_ptr_Function_Outer_std140_tint_explicit_layout %189 %198 - %206 = OpLoad %Outer_std140_tint_explicit_layout %204 None - %207 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %206 - %208 = OpAccessChain %_ptr_Function_Outer_std140 %191 %198 - OpStore %208 %207 None - OpBranch %195 - %195 = OpLabel - %199 = OpIAdd %uint %198 %uint_1 - OpBranch %196 %197 = OpLabel - %200 = OpLoad %_arr_Outer_std140_uint_4 %191 None - OpReturnValue %200 + %204 = OpUGreaterThanEqual %bool %201 %uint_4 + OpSelectionMerge %205 None + OpBranchConditional %204 %206 %205 + %206 = OpLabel + OpBranch %200 + %205 = OpLabel + %207 = OpAccessChain %_ptr_Function_Outer_std140_tint_explicit_layout %192 %201 + %209 = OpLoad %Outer_std140_tint_explicit_layout %207 None + %210 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %209 + %211 = OpAccessChain %_ptr_Function_Outer_std140 %194 %201 + OpStore %211 %210 None + OpBranch %198 + %198 = OpLabel + %202 = OpIAdd %uint %201 %uint_1 + OpBranch %199 + %200 = OpLabel + %203 = OpLoad %_arr_Outer_std140_uint_4 %194 None + OpReturnValue %203 OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/struct/mat2x3_f16/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/struct/mat2x3_f16/dynamic_index_via_ptr.wgsl.expected.glsl index 02d1955..de776fb 100644 --- a/test/tint/buffer/uniform/std140/struct/mat2x3_f16/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/struct/mat2x3_f16/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -37,76 +37,77 @@ } v; int counter = 0; int i() { - counter = (counter + 1); + uint v_1 = uint(counter); + counter = int((v_1 + uint(1))); return counter; } Inner tint_convert_Inner(Inner_std140 tint_input) { return Inner(f16mat2x3(tint_input.m_col0, tint_input.m_col1)); } Outer tint_convert_Outer(Outer_std140 tint_input) { - Inner v_1[4] = Inner[4](Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf)))); + Inner v_2[4] = Inner[4](Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf)))); { - uint v_2 = 0u; - v_2 = 0u; + uint v_3 = 0u; + v_3 = 0u; while(true) { - uint v_3 = v_2; - if ((v_3 >= 4u)) { + uint v_4 = v_3; + if ((v_4 >= 4u)) { break; } - v_1[v_3] = tint_convert_Inner(tint_input.a[v_3]); + v_2[v_4] = tint_convert_Inner(tint_input.a[v_4]); { - v_2 = (v_3 + 1u); + v_3 = (v_4 + 1u); } continue; } } - return Outer(v_1); + return Outer(v_2); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - uint v_4 = min(uint(i()), 3u); uint v_5 = min(uint(i()), 3u); - f16mat2x3 v_6 = f16mat2x3(v.inner[v_4].a[v_5].m_col0, v.inner[v_4].a[v_5].m_col1); - f16vec3 v_7 = v_6[min(uint(i()), 1u)]; - Outer_std140 v_8[4] = v.inner; - Outer v_9[4] = Outer[4](Outer(Inner[4](Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))))), Outer(Inner[4](Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))))), Outer(Inner[4](Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))))), Outer(Inner[4](Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf)))))); + uint v_6 = min(uint(i()), 3u); + f16mat2x3 v_7 = f16mat2x3(v.inner[v_5].a[v_6].m_col0, v.inner[v_5].a[v_6].m_col1); + f16vec3 v_8 = v_7[min(uint(i()), 1u)]; + Outer_std140 v_9[4] = v.inner; + Outer v_10[4] = Outer[4](Outer(Inner[4](Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))))), Outer(Inner[4](Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))))), Outer(Inner[4](Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))))), Outer(Inner[4](Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf)))))); { - uint v_10 = 0u; - v_10 = 0u; + uint v_11 = 0u; + v_11 = 0u; while(true) { - uint v_11 = v_10; - if ((v_11 >= 4u)) { + uint v_12 = v_11; + if ((v_12 >= 4u)) { break; } - v_9[v_11] = tint_convert_Outer(v_8[v_11]); + v_10[v_12] = tint_convert_Outer(v_9[v_12]); { - v_10 = (v_11 + 1u); + v_11 = (v_12 + 1u); } continue; } } - Outer l_a[4] = v_9; - Outer l_a_i = tint_convert_Outer(v.inner[v_4]); - Inner_std140 v_12[4] = v.inner[v_4].a; - Inner v_13[4] = Inner[4](Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf)))); + Outer l_a[4] = v_10; + Outer l_a_i = tint_convert_Outer(v.inner[v_5]); + Inner_std140 v_13[4] = v.inner[v_5].a; + Inner v_14[4] = Inner[4](Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf)))); { - uint v_14 = 0u; - v_14 = 0u; + uint v_15 = 0u; + v_15 = 0u; while(true) { - uint v_15 = v_14; - if ((v_15 >= 4u)) { + uint v_16 = v_15; + if ((v_16 >= 4u)) { break; } - v_13[v_15] = tint_convert_Inner(v_12[v_15]); + v_14[v_16] = tint_convert_Inner(v_13[v_16]); { - v_14 = (v_15 + 1u); + v_15 = (v_16 + 1u); } continue; } } - Inner l_a_i_a[4] = v_13; - Inner l_a_i_a_i = tint_convert_Inner(v.inner[v_4].a[v_5]); - f16mat2x3 l_a_i_a_i_m = v_6; - f16vec3 l_a_i_a_i_m_i = v_7; - float16_t l_a_i_a_i_m_i_i = v_7[min(uint(i()), 2u)]; + Inner l_a_i_a[4] = v_14; + Inner l_a_i_a_i = tint_convert_Inner(v.inner[v_5].a[v_6]); + f16mat2x3 l_a_i_a_i_m = v_7; + f16vec3 l_a_i_a_i_m_i = v_8; + float16_t l_a_i_a_i_m_i_i = v_8[min(uint(i()), 2u)]; }
diff --git a/test/tint/buffer/uniform/std140/struct/mat2x3_f16/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/struct/mat2x3_f16/dynamic_index_via_ptr.wgsl.expected.spvasm index c104b7a..c711321 100644 --- a/test/tint/buffer/uniform/std140/struct/mat2x3_f16/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/struct/mat2x3_f16/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,13 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 210 +; Bound: 213 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess - %33 = OpExtInstImport "GLSL.std.450" + %36 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -72,7 +72,7 @@ %17 = OpTypeFunction %int %int_1 = OpConstant %int 1 %void = OpTypeVoid - %25 = OpTypeFunction %void + %28 = OpTypeFunction %void %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 = OpTypePointer Uniform %_arr_Outer_std140_tint_explicit_layout_uint_4 %uint_0 = OpConstant %uint 0 %uint_3 = OpConstant %uint 3 @@ -93,243 +93,246 @@ %Outer = OpTypeStruct %_arr_Inner_uint_4 %_arr_Outer_uint_4 = OpTypeArray %Outer %uint_4 %_ptr_Function__arr_Outer_uint_4 = OpTypePointer Function %_arr_Outer_uint_4 - %74 = OpConstantNull %_arr_Outer_uint_4 + %77 = OpConstantNull %_arr_Outer_uint_4 %_ptr_Function__arr_Inner_std140_uint_4_0 = OpTypePointer Function %_arr_Inner_std140_uint_4_0 %_ptr_Function__arr_Inner_uint_4 = OpTypePointer Function %_arr_Inner_uint_4 - %95 = OpConstantNull %_arr_Inner_uint_4 + %98 = OpConstantNull %_arr_Inner_uint_4 %uint_2 = OpConstant %uint 2 %bool = OpTypeBool %_ptr_Function_Outer = OpTypePointer Function %Outer %_ptr_Function_Outer_std140 = OpTypePointer Function %Outer_std140 %_ptr_Function_Inner = OpTypePointer Function %Inner %_ptr_Function_Inner_std140 = OpTypePointer Function %Inner_std140 - %132 = OpTypeFunction %Inner %Inner_std140 - %139 = OpTypeFunction %Outer %Outer_std140 - %161 = OpTypeFunction %_arr_Inner_std140_uint_4_0 %_arr_Inner_std140_uint_4 + %135 = OpTypeFunction %Inner %Inner_std140 + %142 = OpTypeFunction %Outer %Outer_std140 + %164 = OpTypeFunction %_arr_Inner_std140_uint_4_0 %_arr_Inner_std140_uint_4 %_ptr_Function__arr_Inner_std140_uint_4 = OpTypePointer Function %_arr_Inner_std140_uint_4 - %166 = OpConstantNull %_arr_Inner_std140_uint_4_0 - %182 = OpTypeFunction %Outer_std140 %Outer_std140_tint_explicit_layout - %188 = OpTypeFunction %_arr_Outer_std140_uint_4 %_arr_Outer_std140_tint_explicit_layout_uint_4 + %169 = OpConstantNull %_arr_Inner_std140_uint_4_0 + %185 = OpTypeFunction %Outer_std140 %Outer_std140_tint_explicit_layout + %191 = OpTypeFunction %_arr_Outer_std140_uint_4 %_arr_Outer_std140_tint_explicit_layout_uint_4 %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 = OpTypePointer Function %_arr_Outer_std140_tint_explicit_layout_uint_4 - %193 = OpConstantNull %_arr_Outer_std140_uint_4 + %196 = OpConstantNull %_arr_Outer_std140_uint_4 %_ptr_Function_Outer_std140_tint_explicit_layout = OpTypePointer Function %Outer_std140_tint_explicit_layout %i = OpFunction %int None %17 %18 = OpLabel %19 = OpLoad %int %counter None - %20 = OpIAdd %int %19 %int_1 - OpStore %counter %20 None - %22 = OpLoad %int %counter None - OpReturnValue %22 + %20 = OpBitcast %uint %19 + %21 = OpBitcast %uint %int_1 + %23 = OpIAdd %uint %20 %21 + %24 = OpBitcast %int %23 + OpStore %counter %24 None + %25 = OpLoad %int %counter None + OpReturnValue %25 OpFunctionEnd - %f = OpFunction %void None %25 - %26 = OpLabel - %52 = OpVariable %_ptr_Function_mat2v3half Function - %66 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function - %68 = OpVariable %_ptr_Function__arr_Outer_uint_4 Function %74 - %91 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function - %93 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %95 - %27 = OpAccessChain %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 %1 %uint_0 - %30 = OpFunctionCall %int %i - %31 = OpBitcast %uint %30 - %32 = OpExtInst %uint %33 UMin %31 %uint_3 - %35 = OpAccessChain %_ptr_Uniform_Outer_std140_tint_explicit_layout %27 %32 - %37 = OpAccessChain %_ptr_Uniform__arr_Inner_std140_uint_4 %35 %uint_0 - %39 = OpFunctionCall %int %i - %40 = OpBitcast %uint %39 - %41 = OpExtInst %uint %33 UMin %40 %uint_3 - %42 = OpAccessChain %_ptr_Uniform_Inner_std140 %37 %41 - %44 = OpAccessChain %_ptr_Uniform_v3half %42 %uint_0 - %46 = OpLoad %v3half %44 None - %47 = OpAccessChain %_ptr_Uniform_v3half %42 %uint_1 + %f = OpFunction %void None %28 + %29 = OpLabel + %55 = OpVariable %_ptr_Function_mat2v3half Function + %69 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function + %71 = OpVariable %_ptr_Function__arr_Outer_uint_4 Function %77 + %94 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function + %96 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %98 + %30 = OpAccessChain %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 %1 %uint_0 + %33 = OpFunctionCall %int %i + %34 = OpBitcast %uint %33 + %35 = OpExtInst %uint %36 UMin %34 %uint_3 + %38 = OpAccessChain %_ptr_Uniform_Outer_std140_tint_explicit_layout %30 %35 + %40 = OpAccessChain %_ptr_Uniform__arr_Inner_std140_uint_4 %38 %uint_0 + %42 = OpFunctionCall %int %i + %43 = OpBitcast %uint %42 + %44 = OpExtInst %uint %36 UMin %43 %uint_3 + %45 = OpAccessChain %_ptr_Uniform_Inner_std140 %40 %44 + %47 = OpAccessChain %_ptr_Uniform_v3half %45 %uint_0 %49 = OpLoad %v3half %47 None -%l_a_i_a_i_m = OpCompositeConstruct %mat2v3half %46 %49 - OpStore %52 %l_a_i_a_i_m - %54 = OpFunctionCall %int %i - %55 = OpBitcast %uint %54 - %56 = OpExtInst %uint %33 UMin %55 %uint_1 - %57 = OpAccessChain %_ptr_Function_v3half %52 %56 -%l_a_i_a_i_m_i = OpLoad %v3half %57 None - %60 = OpLoad %_arr_Outer_std140_tint_explicit_layout_uint_4 %27 None - %61 = OpFunctionCall %_arr_Outer_std140_uint_4 %tint_convert_explicit_layout_1 %60 - OpStore %66 %61 - OpBranch %75 - %75 = OpLabel + %50 = OpAccessChain %_ptr_Uniform_v3half %45 %uint_1 + %52 = OpLoad %v3half %50 None +%l_a_i_a_i_m = OpCompositeConstruct %mat2v3half %49 %52 + OpStore %55 %l_a_i_a_i_m + %57 = OpFunctionCall %int %i + %58 = OpBitcast %uint %57 + %59 = OpExtInst %uint %36 UMin %58 %uint_1 + %60 = OpAccessChain %_ptr_Function_v3half %55 %59 +%l_a_i_a_i_m_i = OpLoad %v3half %60 None + %63 = OpLoad %_arr_Outer_std140_tint_explicit_layout_uint_4 %30 None + %64 = OpFunctionCall %_arr_Outer_std140_uint_4 %tint_convert_explicit_layout_1 %63 + OpStore %69 %64 OpBranch %78 %78 = OpLabel - %80 = OpPhi %uint %uint_0 %75 %81 %77 - OpLoopMerge %79 %77 None - OpBranch %76 - %76 = OpLabel - %112 = OpUGreaterThanEqual %bool %80 %uint_4 - OpSelectionMerge %114 None - OpBranchConditional %112 %115 %114 - %115 = OpLabel + OpBranch %81 + %81 = OpLabel + %83 = OpPhi %uint %uint_0 %78 %84 %80 + OpLoopMerge %82 %80 None OpBranch %79 - %114 = OpLabel - %116 = OpAccessChain %_ptr_Function_Outer %68 %80 - %118 = OpAccessChain %_ptr_Function_Outer_std140 %66 %80 - %120 = OpLoad %Outer_std140 %118 None - %121 = OpFunctionCall %Outer %tint_convert_Outer %120 - OpStore %116 %121 None - OpBranch %77 - %77 = OpLabel - %81 = OpIAdd %uint %80 %uint_1 - OpBranch %78 %79 = OpLabel - %l_a = OpLoad %_arr_Outer_uint_4 %68 None - %83 = OpLoad %Outer_std140_tint_explicit_layout %35 None - %84 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %83 - %l_a_i = OpFunctionCall %Outer %tint_convert_Outer %84 - %88 = OpLoad %_arr_Inner_std140_uint_4 %37 None - %89 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %88 - OpStore %91 %89 - OpBranch %96 - %96 = OpLabel + %115 = OpUGreaterThanEqual %bool %83 %uint_4 + OpSelectionMerge %117 None + OpBranchConditional %115 %118 %117 + %118 = OpLabel + OpBranch %82 + %117 = OpLabel + %119 = OpAccessChain %_ptr_Function_Outer %71 %83 + %121 = OpAccessChain %_ptr_Function_Outer_std140 %69 %83 + %123 = OpLoad %Outer_std140 %121 None + %124 = OpFunctionCall %Outer %tint_convert_Outer %123 + OpStore %119 %124 None + OpBranch %80 + %80 = OpLabel + %84 = OpIAdd %uint %83 %uint_1 + OpBranch %81 + %82 = OpLabel + %l_a = OpLoad %_arr_Outer_uint_4 %71 None + %86 = OpLoad %Outer_std140_tint_explicit_layout %38 None + %87 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %86 + %l_a_i = OpFunctionCall %Outer %tint_convert_Outer %87 + %91 = OpLoad %_arr_Inner_std140_uint_4 %40 None + %92 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %91 + OpStore %94 %92 OpBranch %99 %99 = OpLabel - %101 = OpPhi %uint %uint_0 %96 %102 %98 - OpLoopMerge %100 %98 None - OpBranch %97 - %97 = OpLabel - %122 = OpUGreaterThanEqual %bool %101 %uint_4 - OpSelectionMerge %123 None - OpBranchConditional %122 %124 %123 - %124 = OpLabel + OpBranch %102 + %102 = OpLabel + %104 = OpPhi %uint %uint_0 %99 %105 %101 + OpLoopMerge %103 %101 None OpBranch %100 - %123 = OpLabel - %125 = OpAccessChain %_ptr_Function_Inner %93 %101 - %127 = OpAccessChain %_ptr_Function_Inner_std140 %91 %101 - %129 = OpLoad %Inner_std140 %127 None - %130 = OpFunctionCall %Inner %tint_convert_Inner %129 - OpStore %125 %130 None - OpBranch %98 - %98 = OpLabel - %102 = OpIAdd %uint %101 %uint_1 - OpBranch %99 %100 = OpLabel - %l_a_i_a = OpLoad %_arr_Inner_uint_4 %93 None - %104 = OpLoad %Inner_std140 %42 None - %l_a_i_a_i = OpFunctionCall %Inner %tint_convert_Inner %104 - %107 = OpFunctionCall %int %i - %108 = OpBitcast %uint %107 - %109 = OpExtInst %uint %33 UMin %108 %uint_2 -%l_a_i_a_i_m_i_i = OpVectorExtractDynamic %half %l_a_i_a_i_m_i %109 + %125 = OpUGreaterThanEqual %bool %104 %uint_4 + OpSelectionMerge %126 None + OpBranchConditional %125 %127 %126 + %127 = OpLabel + OpBranch %103 + %126 = OpLabel + %128 = OpAccessChain %_ptr_Function_Inner %96 %104 + %130 = OpAccessChain %_ptr_Function_Inner_std140 %94 %104 + %132 = OpLoad %Inner_std140 %130 None + %133 = OpFunctionCall %Inner %tint_convert_Inner %132 + OpStore %128 %133 None + OpBranch %101 + %101 = OpLabel + %105 = OpIAdd %uint %104 %uint_1 + OpBranch %102 + %103 = OpLabel + %l_a_i_a = OpLoad %_arr_Inner_uint_4 %96 None + %107 = OpLoad %Inner_std140 %45 None + %l_a_i_a_i = OpFunctionCall %Inner %tint_convert_Inner %107 + %110 = OpFunctionCall %int %i + %111 = OpBitcast %uint %110 + %112 = OpExtInst %uint %36 UMin %111 %uint_2 +%l_a_i_a_i_m_i_i = OpVectorExtractDynamic %half %l_a_i_a_i_m_i %112 OpReturn OpFunctionEnd -%tint_convert_Inner = OpFunction %Inner None %132 +%tint_convert_Inner = OpFunction %Inner None %135 %tint_input = OpFunctionParameter %Inner_std140 - %133 = OpLabel - %134 = OpCompositeExtract %v3half %tint_input 0 - %135 = OpCompositeExtract %v3half %tint_input 1 - %136 = OpCompositeConstruct %mat2v3half %134 %135 - %137 = OpCompositeConstruct %Inner %136 - OpReturnValue %137 + %136 = OpLabel + %137 = OpCompositeExtract %v3half %tint_input 0 + %138 = OpCompositeExtract %v3half %tint_input 1 + %139 = OpCompositeConstruct %mat2v3half %137 %138 + %140 = OpCompositeConstruct %Inner %139 + OpReturnValue %140 OpFunctionEnd -%tint_convert_Outer = OpFunction %Outer None %139 +%tint_convert_Outer = OpFunction %Outer None %142 %tint_input_0 = OpFunctionParameter %Outer_std140 - %140 = OpLabel - %142 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function - %143 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %95 - %141 = OpCompositeExtract %_arr_Inner_std140_uint_4_0 %tint_input_0 0 - OpStore %142 %141 - OpBranch %144 - %144 = OpLabel + %143 = OpLabel + %145 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function + %146 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %98 + %144 = OpCompositeExtract %_arr_Inner_std140_uint_4_0 %tint_input_0 0 + OpStore %145 %144 OpBranch %147 %147 = OpLabel - %149 = OpPhi %uint %uint_0 %144 %150 %146 - OpLoopMerge %148 %146 None - OpBranch %145 - %145 = OpLabel - %153 = OpUGreaterThanEqual %bool %149 %uint_4 - OpSelectionMerge %154 None - OpBranchConditional %153 %155 %154 - %155 = OpLabel + OpBranch %150 + %150 = OpLabel + %152 = OpPhi %uint %uint_0 %147 %153 %149 + OpLoopMerge %151 %149 None OpBranch %148 - %154 = OpLabel - %156 = OpAccessChain %_ptr_Function_Inner %143 %149 - %157 = OpAccessChain %_ptr_Function_Inner_std140 %142 %149 - %158 = OpLoad %Inner_std140 %157 None - %159 = OpFunctionCall %Inner %tint_convert_Inner %158 - OpStore %156 %159 None - OpBranch %146 - %146 = OpLabel - %150 = OpIAdd %uint %149 %uint_1 - OpBranch %147 %148 = OpLabel - %151 = OpLoad %_arr_Inner_uint_4 %143 None - %152 = OpCompositeConstruct %Outer %151 - OpReturnValue %152 + %156 = OpUGreaterThanEqual %bool %152 %uint_4 + OpSelectionMerge %157 None + OpBranchConditional %156 %158 %157 + %158 = OpLabel + OpBranch %151 + %157 = OpLabel + %159 = OpAccessChain %_ptr_Function_Inner %146 %152 + %160 = OpAccessChain %_ptr_Function_Inner_std140 %145 %152 + %161 = OpLoad %Inner_std140 %160 None + %162 = OpFunctionCall %Inner %tint_convert_Inner %161 + OpStore %159 %162 None + OpBranch %149 + %149 = OpLabel + %153 = OpIAdd %uint %152 %uint_1 + OpBranch %150 + %151 = OpLabel + %154 = OpLoad %_arr_Inner_uint_4 %146 None + %155 = OpCompositeConstruct %Outer %154 + OpReturnValue %155 OpFunctionEnd -%tint_convert_explicit_layout = OpFunction %_arr_Inner_std140_uint_4_0 None %161 +%tint_convert_explicit_layout = OpFunction %_arr_Inner_std140_uint_4_0 None %164 %tint_source = OpFunctionParameter %_arr_Inner_std140_uint_4 - %162 = OpLabel - %163 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4 Function - %165 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function %166 - OpStore %163 %tint_source - OpBranch %167 - %167 = OpLabel + %165 = OpLabel + %166 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4 Function + %168 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function %169 + OpStore %166 %tint_source OpBranch %170 %170 = OpLabel - %172 = OpPhi %uint %uint_0 %167 %173 %169 - OpLoopMerge %171 %169 None - OpBranch %168 - %168 = OpLabel - %175 = OpUGreaterThanEqual %bool %172 %uint_4 - OpSelectionMerge %176 None - OpBranchConditional %175 %177 %176 - %177 = OpLabel + OpBranch %173 + %173 = OpLabel + %175 = OpPhi %uint %uint_0 %170 %176 %172 + OpLoopMerge %174 %172 None OpBranch %171 - %176 = OpLabel - %178 = OpAccessChain %_ptr_Function_Inner_std140 %163 %172 - %179 = OpLoad %Inner_std140 %178 None - %180 = OpAccessChain %_ptr_Function_Inner_std140 %165 %172 - OpStore %180 %179 None - OpBranch %169 - %169 = OpLabel - %173 = OpIAdd %uint %172 %uint_1 - OpBranch %170 %171 = OpLabel - %174 = OpLoad %_arr_Inner_std140_uint_4_0 %165 None - OpReturnValue %174 + %178 = OpUGreaterThanEqual %bool %175 %uint_4 + OpSelectionMerge %179 None + OpBranchConditional %178 %180 %179 + %180 = OpLabel + OpBranch %174 + %179 = OpLabel + %181 = OpAccessChain %_ptr_Function_Inner_std140 %166 %175 + %182 = OpLoad %Inner_std140 %181 None + %183 = OpAccessChain %_ptr_Function_Inner_std140 %168 %175 + OpStore %183 %182 None + OpBranch %172 + %172 = OpLabel + %176 = OpIAdd %uint %175 %uint_1 + OpBranch %173 + %174 = OpLabel + %177 = OpLoad %_arr_Inner_std140_uint_4_0 %168 None + OpReturnValue %177 OpFunctionEnd -%tint_convert_explicit_layout_0 = OpFunction %Outer_std140 None %182 +%tint_convert_explicit_layout_0 = OpFunction %Outer_std140 None %185 %tint_source_0 = OpFunctionParameter %Outer_std140_tint_explicit_layout - %183 = OpLabel - %184 = OpCompositeExtract %_arr_Inner_std140_uint_4 %tint_source_0 0 - %185 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %184 - %186 = OpCompositeConstruct %Outer_std140 %185 - OpReturnValue %186 + %186 = OpLabel + %187 = OpCompositeExtract %_arr_Inner_std140_uint_4 %tint_source_0 0 + %188 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %187 + %189 = OpCompositeConstruct %Outer_std140 %188 + OpReturnValue %189 OpFunctionEnd -%tint_convert_explicit_layout_1 = OpFunction %_arr_Outer_std140_uint_4 None %188 +%tint_convert_explicit_layout_1 = OpFunction %_arr_Outer_std140_uint_4 None %191 %tint_source_1 = OpFunctionParameter %_arr_Outer_std140_tint_explicit_layout_uint_4 - %189 = OpLabel - %190 = OpVariable %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 Function - %192 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function %193 - OpStore %190 %tint_source_1 - OpBranch %194 - %194 = OpLabel + %192 = OpLabel + %193 = OpVariable %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 Function + %195 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function %196 + OpStore %193 %tint_source_1 OpBranch %197 %197 = OpLabel - %199 = OpPhi %uint %uint_0 %194 %200 %196 - OpLoopMerge %198 %196 None - OpBranch %195 - %195 = OpLabel - %202 = OpUGreaterThanEqual %bool %199 %uint_4 - OpSelectionMerge %203 None - OpBranchConditional %202 %204 %203 - %204 = OpLabel + OpBranch %200 + %200 = OpLabel + %202 = OpPhi %uint %uint_0 %197 %203 %199 + OpLoopMerge %201 %199 None OpBranch %198 - %203 = OpLabel - %205 = OpAccessChain %_ptr_Function_Outer_std140_tint_explicit_layout %190 %199 - %207 = OpLoad %Outer_std140_tint_explicit_layout %205 None - %208 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %207 - %209 = OpAccessChain %_ptr_Function_Outer_std140 %192 %199 - OpStore %209 %208 None - OpBranch %196 - %196 = OpLabel - %200 = OpIAdd %uint %199 %uint_1 - OpBranch %197 %198 = OpLabel - %201 = OpLoad %_arr_Outer_std140_uint_4 %192 None - OpReturnValue %201 + %205 = OpUGreaterThanEqual %bool %202 %uint_4 + OpSelectionMerge %206 None + OpBranchConditional %205 %207 %206 + %207 = OpLabel + OpBranch %201 + %206 = OpLabel + %208 = OpAccessChain %_ptr_Function_Outer_std140_tint_explicit_layout %193 %202 + %210 = OpLoad %Outer_std140_tint_explicit_layout %208 None + %211 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %210 + %212 = OpAccessChain %_ptr_Function_Outer_std140 %195 %202 + OpStore %212 %211 None + OpBranch %199 + %199 = OpLabel + %203 = OpIAdd %uint %202 %uint_1 + OpBranch %200 + %201 = OpLabel + %204 = OpLoad %_arr_Outer_std140_uint_4 %195 None + OpReturnValue %204 OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/struct/mat2x3_f32/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/struct/mat2x3_f32/dynamic_index_via_ptr.wgsl.expected.glsl index 6ea76b1..e7db5b2 100644 --- a/test/tint/buffer/uniform/std140/struct/mat2x3_f32/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/struct/mat2x3_f32/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -34,76 +34,77 @@ } v; int counter = 0; int i() { - counter = (counter + 1); + uint v_1 = uint(counter); + counter = int((v_1 + uint(1))); return counter; } Inner tint_convert_Inner(Inner_std140 tint_input) { return Inner(mat2x3(tint_input.m_col0, tint_input.m_col1)); } Outer tint_convert_Outer(Outer_std140 tint_input) { - Inner v_1[4] = Inner[4](Inner(mat2x3(vec3(0.0f), vec3(0.0f))), Inner(mat2x3(vec3(0.0f), vec3(0.0f))), Inner(mat2x3(vec3(0.0f), vec3(0.0f))), Inner(mat2x3(vec3(0.0f), vec3(0.0f)))); + Inner v_2[4] = Inner[4](Inner(mat2x3(vec3(0.0f), vec3(0.0f))), Inner(mat2x3(vec3(0.0f), vec3(0.0f))), Inner(mat2x3(vec3(0.0f), vec3(0.0f))), Inner(mat2x3(vec3(0.0f), vec3(0.0f)))); { - uint v_2 = 0u; - v_2 = 0u; + uint v_3 = 0u; + v_3 = 0u; while(true) { - uint v_3 = v_2; - if ((v_3 >= 4u)) { + uint v_4 = v_3; + if ((v_4 >= 4u)) { break; } - v_1[v_3] = tint_convert_Inner(tint_input.a[v_3]); + v_2[v_4] = tint_convert_Inner(tint_input.a[v_4]); { - v_2 = (v_3 + 1u); + v_3 = (v_4 + 1u); } continue; } } - return Outer(v_1); + return Outer(v_2); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - uint v_4 = min(uint(i()), 3u); uint v_5 = min(uint(i()), 3u); - mat2x3 v_6 = mat2x3(v.inner[v_4].a[v_5].m_col0, v.inner[v_4].a[v_5].m_col1); - vec3 v_7 = v_6[min(uint(i()), 1u)]; - Outer_std140 v_8[4] = v.inner; - Outer v_9[4] = Outer[4](Outer(Inner[4](Inner(mat2x3(vec3(0.0f), vec3(0.0f))), Inner(mat2x3(vec3(0.0f), vec3(0.0f))), Inner(mat2x3(vec3(0.0f), vec3(0.0f))), Inner(mat2x3(vec3(0.0f), vec3(0.0f))))), Outer(Inner[4](Inner(mat2x3(vec3(0.0f), vec3(0.0f))), Inner(mat2x3(vec3(0.0f), vec3(0.0f))), Inner(mat2x3(vec3(0.0f), vec3(0.0f))), Inner(mat2x3(vec3(0.0f), vec3(0.0f))))), Outer(Inner[4](Inner(mat2x3(vec3(0.0f), vec3(0.0f))), Inner(mat2x3(vec3(0.0f), vec3(0.0f))), Inner(mat2x3(vec3(0.0f), vec3(0.0f))), Inner(mat2x3(vec3(0.0f), vec3(0.0f))))), Outer(Inner[4](Inner(mat2x3(vec3(0.0f), vec3(0.0f))), Inner(mat2x3(vec3(0.0f), vec3(0.0f))), Inner(mat2x3(vec3(0.0f), vec3(0.0f))), Inner(mat2x3(vec3(0.0f), vec3(0.0f)))))); + uint v_6 = min(uint(i()), 3u); + mat2x3 v_7 = mat2x3(v.inner[v_5].a[v_6].m_col0, v.inner[v_5].a[v_6].m_col1); + vec3 v_8 = v_7[min(uint(i()), 1u)]; + Outer_std140 v_9[4] = v.inner; + Outer v_10[4] = Outer[4](Outer(Inner[4](Inner(mat2x3(vec3(0.0f), vec3(0.0f))), Inner(mat2x3(vec3(0.0f), vec3(0.0f))), Inner(mat2x3(vec3(0.0f), vec3(0.0f))), Inner(mat2x3(vec3(0.0f), vec3(0.0f))))), Outer(Inner[4](Inner(mat2x3(vec3(0.0f), vec3(0.0f))), Inner(mat2x3(vec3(0.0f), vec3(0.0f))), Inner(mat2x3(vec3(0.0f), vec3(0.0f))), Inner(mat2x3(vec3(0.0f), vec3(0.0f))))), Outer(Inner[4](Inner(mat2x3(vec3(0.0f), vec3(0.0f))), Inner(mat2x3(vec3(0.0f), vec3(0.0f))), Inner(mat2x3(vec3(0.0f), vec3(0.0f))), Inner(mat2x3(vec3(0.0f), vec3(0.0f))))), Outer(Inner[4](Inner(mat2x3(vec3(0.0f), vec3(0.0f))), Inner(mat2x3(vec3(0.0f), vec3(0.0f))), Inner(mat2x3(vec3(0.0f), vec3(0.0f))), Inner(mat2x3(vec3(0.0f), vec3(0.0f)))))); { - uint v_10 = 0u; - v_10 = 0u; + uint v_11 = 0u; + v_11 = 0u; while(true) { - uint v_11 = v_10; - if ((v_11 >= 4u)) { + uint v_12 = v_11; + if ((v_12 >= 4u)) { break; } - v_9[v_11] = tint_convert_Outer(v_8[v_11]); + v_10[v_12] = tint_convert_Outer(v_9[v_12]); { - v_10 = (v_11 + 1u); + v_11 = (v_12 + 1u); } continue; } } - Outer l_a[4] = v_9; - Outer l_a_i = tint_convert_Outer(v.inner[v_4]); - Inner_std140 v_12[4] = v.inner[v_4].a; - Inner v_13[4] = Inner[4](Inner(mat2x3(vec3(0.0f), vec3(0.0f))), Inner(mat2x3(vec3(0.0f), vec3(0.0f))), Inner(mat2x3(vec3(0.0f), vec3(0.0f))), Inner(mat2x3(vec3(0.0f), vec3(0.0f)))); + Outer l_a[4] = v_10; + Outer l_a_i = tint_convert_Outer(v.inner[v_5]); + Inner_std140 v_13[4] = v.inner[v_5].a; + Inner v_14[4] = Inner[4](Inner(mat2x3(vec3(0.0f), vec3(0.0f))), Inner(mat2x3(vec3(0.0f), vec3(0.0f))), Inner(mat2x3(vec3(0.0f), vec3(0.0f))), Inner(mat2x3(vec3(0.0f), vec3(0.0f)))); { - uint v_14 = 0u; - v_14 = 0u; + uint v_15 = 0u; + v_15 = 0u; while(true) { - uint v_15 = v_14; - if ((v_15 >= 4u)) { + uint v_16 = v_15; + if ((v_16 >= 4u)) { break; } - v_13[v_15] = tint_convert_Inner(v_12[v_15]); + v_14[v_16] = tint_convert_Inner(v_13[v_16]); { - v_14 = (v_15 + 1u); + v_15 = (v_16 + 1u); } continue; } } - Inner l_a_i_a[4] = v_13; - Inner l_a_i_a_i = tint_convert_Inner(v.inner[v_4].a[v_5]); - mat2x3 l_a_i_a_i_m = v_6; - vec3 l_a_i_a_i_m_i = v_7; - float l_a_i_a_i_m_i_i = v_7[min(uint(i()), 2u)]; + Inner l_a_i_a[4] = v_14; + Inner l_a_i_a_i = tint_convert_Inner(v.inner[v_5].a[v_6]); + mat2x3 l_a_i_a_i_m = v_7; + vec3 l_a_i_a_i_m_i = v_8; + float l_a_i_a_i_m_i_i = v_8[min(uint(i()), 2u)]; }
diff --git a/test/tint/buffer/uniform/std140/struct/mat2x3_f32/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/struct/mat2x3_f32/dynamic_index_via_ptr.wgsl.expected.spvasm index aa98529..8912a80 100644 --- a/test/tint/buffer/uniform/std140/struct/mat2x3_f32/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/struct/mat2x3_f32/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,10 +1,10 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 210 +; Bound: 213 ; Schema: 0 OpCapability Shader - %33 = OpExtInstImport "GLSL.std.450" + %36 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -69,7 +69,7 @@ %17 = OpTypeFunction %int %int_1 = OpConstant %int 1 %void = OpTypeVoid - %25 = OpTypeFunction %void + %28 = OpTypeFunction %void %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 = OpTypePointer Uniform %_arr_Outer_std140_tint_explicit_layout_uint_4 %uint_0 = OpConstant %uint 0 %uint_3 = OpConstant %uint 3 @@ -90,243 +90,246 @@ %Outer = OpTypeStruct %_arr_Inner_uint_4 %_arr_Outer_uint_4 = OpTypeArray %Outer %uint_4 %_ptr_Function__arr_Outer_uint_4 = OpTypePointer Function %_arr_Outer_uint_4 - %74 = OpConstantNull %_arr_Outer_uint_4 + %77 = OpConstantNull %_arr_Outer_uint_4 %_ptr_Function__arr_Inner_std140_uint_4_0 = OpTypePointer Function %_arr_Inner_std140_uint_4_0 %_ptr_Function__arr_Inner_uint_4 = OpTypePointer Function %_arr_Inner_uint_4 - %95 = OpConstantNull %_arr_Inner_uint_4 + %98 = OpConstantNull %_arr_Inner_uint_4 %uint_2 = OpConstant %uint 2 %bool = OpTypeBool %_ptr_Function_Outer = OpTypePointer Function %Outer %_ptr_Function_Outer_std140 = OpTypePointer Function %Outer_std140 %_ptr_Function_Inner = OpTypePointer Function %Inner %_ptr_Function_Inner_std140 = OpTypePointer Function %Inner_std140 - %132 = OpTypeFunction %Inner %Inner_std140 - %139 = OpTypeFunction %Outer %Outer_std140 - %161 = OpTypeFunction %_arr_Inner_std140_uint_4_0 %_arr_Inner_std140_uint_4 + %135 = OpTypeFunction %Inner %Inner_std140 + %142 = OpTypeFunction %Outer %Outer_std140 + %164 = OpTypeFunction %_arr_Inner_std140_uint_4_0 %_arr_Inner_std140_uint_4 %_ptr_Function__arr_Inner_std140_uint_4 = OpTypePointer Function %_arr_Inner_std140_uint_4 - %166 = OpConstantNull %_arr_Inner_std140_uint_4_0 - %182 = OpTypeFunction %Outer_std140 %Outer_std140_tint_explicit_layout - %188 = OpTypeFunction %_arr_Outer_std140_uint_4 %_arr_Outer_std140_tint_explicit_layout_uint_4 + %169 = OpConstantNull %_arr_Inner_std140_uint_4_0 + %185 = OpTypeFunction %Outer_std140 %Outer_std140_tint_explicit_layout + %191 = OpTypeFunction %_arr_Outer_std140_uint_4 %_arr_Outer_std140_tint_explicit_layout_uint_4 %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 = OpTypePointer Function %_arr_Outer_std140_tint_explicit_layout_uint_4 - %193 = OpConstantNull %_arr_Outer_std140_uint_4 + %196 = OpConstantNull %_arr_Outer_std140_uint_4 %_ptr_Function_Outer_std140_tint_explicit_layout = OpTypePointer Function %Outer_std140_tint_explicit_layout %i = OpFunction %int None %17 %18 = OpLabel %19 = OpLoad %int %counter None - %20 = OpIAdd %int %19 %int_1 - OpStore %counter %20 None - %22 = OpLoad %int %counter None - OpReturnValue %22 + %20 = OpBitcast %uint %19 + %21 = OpBitcast %uint %int_1 + %23 = OpIAdd %uint %20 %21 + %24 = OpBitcast %int %23 + OpStore %counter %24 None + %25 = OpLoad %int %counter None + OpReturnValue %25 OpFunctionEnd - %f = OpFunction %void None %25 - %26 = OpLabel - %52 = OpVariable %_ptr_Function_mat2v3float Function - %66 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function - %68 = OpVariable %_ptr_Function__arr_Outer_uint_4 Function %74 - %91 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function - %93 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %95 - %27 = OpAccessChain %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 %1 %uint_0 - %30 = OpFunctionCall %int %i - %31 = OpBitcast %uint %30 - %32 = OpExtInst %uint %33 UMin %31 %uint_3 - %35 = OpAccessChain %_ptr_Uniform_Outer_std140_tint_explicit_layout %27 %32 - %37 = OpAccessChain %_ptr_Uniform__arr_Inner_std140_uint_4 %35 %uint_0 - %39 = OpFunctionCall %int %i - %40 = OpBitcast %uint %39 - %41 = OpExtInst %uint %33 UMin %40 %uint_3 - %42 = OpAccessChain %_ptr_Uniform_Inner_std140 %37 %41 - %44 = OpAccessChain %_ptr_Uniform_v3float %42 %uint_0 - %46 = OpLoad %v3float %44 None - %47 = OpAccessChain %_ptr_Uniform_v3float %42 %uint_1 + %f = OpFunction %void None %28 + %29 = OpLabel + %55 = OpVariable %_ptr_Function_mat2v3float Function + %69 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function + %71 = OpVariable %_ptr_Function__arr_Outer_uint_4 Function %77 + %94 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function + %96 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %98 + %30 = OpAccessChain %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 %1 %uint_0 + %33 = OpFunctionCall %int %i + %34 = OpBitcast %uint %33 + %35 = OpExtInst %uint %36 UMin %34 %uint_3 + %38 = OpAccessChain %_ptr_Uniform_Outer_std140_tint_explicit_layout %30 %35 + %40 = OpAccessChain %_ptr_Uniform__arr_Inner_std140_uint_4 %38 %uint_0 + %42 = OpFunctionCall %int %i + %43 = OpBitcast %uint %42 + %44 = OpExtInst %uint %36 UMin %43 %uint_3 + %45 = OpAccessChain %_ptr_Uniform_Inner_std140 %40 %44 + %47 = OpAccessChain %_ptr_Uniform_v3float %45 %uint_0 %49 = OpLoad %v3float %47 None -%l_a_i_a_i_m = OpCompositeConstruct %mat2v3float %46 %49 - OpStore %52 %l_a_i_a_i_m - %54 = OpFunctionCall %int %i - %55 = OpBitcast %uint %54 - %56 = OpExtInst %uint %33 UMin %55 %uint_1 - %57 = OpAccessChain %_ptr_Function_v3float %52 %56 -%l_a_i_a_i_m_i = OpLoad %v3float %57 None - %60 = OpLoad %_arr_Outer_std140_tint_explicit_layout_uint_4 %27 None - %61 = OpFunctionCall %_arr_Outer_std140_uint_4 %tint_convert_explicit_layout_1 %60 - OpStore %66 %61 - OpBranch %75 - %75 = OpLabel + %50 = OpAccessChain %_ptr_Uniform_v3float %45 %uint_1 + %52 = OpLoad %v3float %50 None +%l_a_i_a_i_m = OpCompositeConstruct %mat2v3float %49 %52 + OpStore %55 %l_a_i_a_i_m + %57 = OpFunctionCall %int %i + %58 = OpBitcast %uint %57 + %59 = OpExtInst %uint %36 UMin %58 %uint_1 + %60 = OpAccessChain %_ptr_Function_v3float %55 %59 +%l_a_i_a_i_m_i = OpLoad %v3float %60 None + %63 = OpLoad %_arr_Outer_std140_tint_explicit_layout_uint_4 %30 None + %64 = OpFunctionCall %_arr_Outer_std140_uint_4 %tint_convert_explicit_layout_1 %63 + OpStore %69 %64 OpBranch %78 %78 = OpLabel - %80 = OpPhi %uint %uint_0 %75 %81 %77 - OpLoopMerge %79 %77 None - OpBranch %76 - %76 = OpLabel - %112 = OpUGreaterThanEqual %bool %80 %uint_4 - OpSelectionMerge %114 None - OpBranchConditional %112 %115 %114 - %115 = OpLabel + OpBranch %81 + %81 = OpLabel + %83 = OpPhi %uint %uint_0 %78 %84 %80 + OpLoopMerge %82 %80 None OpBranch %79 - %114 = OpLabel - %116 = OpAccessChain %_ptr_Function_Outer %68 %80 - %118 = OpAccessChain %_ptr_Function_Outer_std140 %66 %80 - %120 = OpLoad %Outer_std140 %118 None - %121 = OpFunctionCall %Outer %tint_convert_Outer %120 - OpStore %116 %121 None - OpBranch %77 - %77 = OpLabel - %81 = OpIAdd %uint %80 %uint_1 - OpBranch %78 %79 = OpLabel - %l_a = OpLoad %_arr_Outer_uint_4 %68 None - %83 = OpLoad %Outer_std140_tint_explicit_layout %35 None - %84 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %83 - %l_a_i = OpFunctionCall %Outer %tint_convert_Outer %84 - %88 = OpLoad %_arr_Inner_std140_uint_4 %37 None - %89 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %88 - OpStore %91 %89 - OpBranch %96 - %96 = OpLabel + %115 = OpUGreaterThanEqual %bool %83 %uint_4 + OpSelectionMerge %117 None + OpBranchConditional %115 %118 %117 + %118 = OpLabel + OpBranch %82 + %117 = OpLabel + %119 = OpAccessChain %_ptr_Function_Outer %71 %83 + %121 = OpAccessChain %_ptr_Function_Outer_std140 %69 %83 + %123 = OpLoad %Outer_std140 %121 None + %124 = OpFunctionCall %Outer %tint_convert_Outer %123 + OpStore %119 %124 None + OpBranch %80 + %80 = OpLabel + %84 = OpIAdd %uint %83 %uint_1 + OpBranch %81 + %82 = OpLabel + %l_a = OpLoad %_arr_Outer_uint_4 %71 None + %86 = OpLoad %Outer_std140_tint_explicit_layout %38 None + %87 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %86 + %l_a_i = OpFunctionCall %Outer %tint_convert_Outer %87 + %91 = OpLoad %_arr_Inner_std140_uint_4 %40 None + %92 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %91 + OpStore %94 %92 OpBranch %99 %99 = OpLabel - %101 = OpPhi %uint %uint_0 %96 %102 %98 - OpLoopMerge %100 %98 None - OpBranch %97 - %97 = OpLabel - %122 = OpUGreaterThanEqual %bool %101 %uint_4 - OpSelectionMerge %123 None - OpBranchConditional %122 %124 %123 - %124 = OpLabel + OpBranch %102 + %102 = OpLabel + %104 = OpPhi %uint %uint_0 %99 %105 %101 + OpLoopMerge %103 %101 None OpBranch %100 - %123 = OpLabel - %125 = OpAccessChain %_ptr_Function_Inner %93 %101 - %127 = OpAccessChain %_ptr_Function_Inner_std140 %91 %101 - %129 = OpLoad %Inner_std140 %127 None - %130 = OpFunctionCall %Inner %tint_convert_Inner %129 - OpStore %125 %130 None - OpBranch %98 - %98 = OpLabel - %102 = OpIAdd %uint %101 %uint_1 - OpBranch %99 %100 = OpLabel - %l_a_i_a = OpLoad %_arr_Inner_uint_4 %93 None - %104 = OpLoad %Inner_std140 %42 None - %l_a_i_a_i = OpFunctionCall %Inner %tint_convert_Inner %104 - %107 = OpFunctionCall %int %i - %108 = OpBitcast %uint %107 - %109 = OpExtInst %uint %33 UMin %108 %uint_2 -%l_a_i_a_i_m_i_i = OpVectorExtractDynamic %float %l_a_i_a_i_m_i %109 + %125 = OpUGreaterThanEqual %bool %104 %uint_4 + OpSelectionMerge %126 None + OpBranchConditional %125 %127 %126 + %127 = OpLabel + OpBranch %103 + %126 = OpLabel + %128 = OpAccessChain %_ptr_Function_Inner %96 %104 + %130 = OpAccessChain %_ptr_Function_Inner_std140 %94 %104 + %132 = OpLoad %Inner_std140 %130 None + %133 = OpFunctionCall %Inner %tint_convert_Inner %132 + OpStore %128 %133 None + OpBranch %101 + %101 = OpLabel + %105 = OpIAdd %uint %104 %uint_1 + OpBranch %102 + %103 = OpLabel + %l_a_i_a = OpLoad %_arr_Inner_uint_4 %96 None + %107 = OpLoad %Inner_std140 %45 None + %l_a_i_a_i = OpFunctionCall %Inner %tint_convert_Inner %107 + %110 = OpFunctionCall %int %i + %111 = OpBitcast %uint %110 + %112 = OpExtInst %uint %36 UMin %111 %uint_2 +%l_a_i_a_i_m_i_i = OpVectorExtractDynamic %float %l_a_i_a_i_m_i %112 OpReturn OpFunctionEnd -%tint_convert_Inner = OpFunction %Inner None %132 +%tint_convert_Inner = OpFunction %Inner None %135 %tint_input = OpFunctionParameter %Inner_std140 - %133 = OpLabel - %134 = OpCompositeExtract %v3float %tint_input 0 - %135 = OpCompositeExtract %v3float %tint_input 1 - %136 = OpCompositeConstruct %mat2v3float %134 %135 - %137 = OpCompositeConstruct %Inner %136 - OpReturnValue %137 + %136 = OpLabel + %137 = OpCompositeExtract %v3float %tint_input 0 + %138 = OpCompositeExtract %v3float %tint_input 1 + %139 = OpCompositeConstruct %mat2v3float %137 %138 + %140 = OpCompositeConstruct %Inner %139 + OpReturnValue %140 OpFunctionEnd -%tint_convert_Outer = OpFunction %Outer None %139 +%tint_convert_Outer = OpFunction %Outer None %142 %tint_input_0 = OpFunctionParameter %Outer_std140 - %140 = OpLabel - %142 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function - %143 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %95 - %141 = OpCompositeExtract %_arr_Inner_std140_uint_4_0 %tint_input_0 0 - OpStore %142 %141 - OpBranch %144 - %144 = OpLabel + %143 = OpLabel + %145 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function + %146 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %98 + %144 = OpCompositeExtract %_arr_Inner_std140_uint_4_0 %tint_input_0 0 + OpStore %145 %144 OpBranch %147 %147 = OpLabel - %149 = OpPhi %uint %uint_0 %144 %150 %146 - OpLoopMerge %148 %146 None - OpBranch %145 - %145 = OpLabel - %153 = OpUGreaterThanEqual %bool %149 %uint_4 - OpSelectionMerge %154 None - OpBranchConditional %153 %155 %154 - %155 = OpLabel + OpBranch %150 + %150 = OpLabel + %152 = OpPhi %uint %uint_0 %147 %153 %149 + OpLoopMerge %151 %149 None OpBranch %148 - %154 = OpLabel - %156 = OpAccessChain %_ptr_Function_Inner %143 %149 - %157 = OpAccessChain %_ptr_Function_Inner_std140 %142 %149 - %158 = OpLoad %Inner_std140 %157 None - %159 = OpFunctionCall %Inner %tint_convert_Inner %158 - OpStore %156 %159 None - OpBranch %146 - %146 = OpLabel - %150 = OpIAdd %uint %149 %uint_1 - OpBranch %147 %148 = OpLabel - %151 = OpLoad %_arr_Inner_uint_4 %143 None - %152 = OpCompositeConstruct %Outer %151 - OpReturnValue %152 + %156 = OpUGreaterThanEqual %bool %152 %uint_4 + OpSelectionMerge %157 None + OpBranchConditional %156 %158 %157 + %158 = OpLabel + OpBranch %151 + %157 = OpLabel + %159 = OpAccessChain %_ptr_Function_Inner %146 %152 + %160 = OpAccessChain %_ptr_Function_Inner_std140 %145 %152 + %161 = OpLoad %Inner_std140 %160 None + %162 = OpFunctionCall %Inner %tint_convert_Inner %161 + OpStore %159 %162 None + OpBranch %149 + %149 = OpLabel + %153 = OpIAdd %uint %152 %uint_1 + OpBranch %150 + %151 = OpLabel + %154 = OpLoad %_arr_Inner_uint_4 %146 None + %155 = OpCompositeConstruct %Outer %154 + OpReturnValue %155 OpFunctionEnd -%tint_convert_explicit_layout = OpFunction %_arr_Inner_std140_uint_4_0 None %161 +%tint_convert_explicit_layout = OpFunction %_arr_Inner_std140_uint_4_0 None %164 %tint_source = OpFunctionParameter %_arr_Inner_std140_uint_4 - %162 = OpLabel - %163 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4 Function - %165 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function %166 - OpStore %163 %tint_source - OpBranch %167 - %167 = OpLabel + %165 = OpLabel + %166 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4 Function + %168 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function %169 + OpStore %166 %tint_source OpBranch %170 %170 = OpLabel - %172 = OpPhi %uint %uint_0 %167 %173 %169 - OpLoopMerge %171 %169 None - OpBranch %168 - %168 = OpLabel - %175 = OpUGreaterThanEqual %bool %172 %uint_4 - OpSelectionMerge %176 None - OpBranchConditional %175 %177 %176 - %177 = OpLabel + OpBranch %173 + %173 = OpLabel + %175 = OpPhi %uint %uint_0 %170 %176 %172 + OpLoopMerge %174 %172 None OpBranch %171 - %176 = OpLabel - %178 = OpAccessChain %_ptr_Function_Inner_std140 %163 %172 - %179 = OpLoad %Inner_std140 %178 None - %180 = OpAccessChain %_ptr_Function_Inner_std140 %165 %172 - OpStore %180 %179 None - OpBranch %169 - %169 = OpLabel - %173 = OpIAdd %uint %172 %uint_1 - OpBranch %170 %171 = OpLabel - %174 = OpLoad %_arr_Inner_std140_uint_4_0 %165 None - OpReturnValue %174 + %178 = OpUGreaterThanEqual %bool %175 %uint_4 + OpSelectionMerge %179 None + OpBranchConditional %178 %180 %179 + %180 = OpLabel + OpBranch %174 + %179 = OpLabel + %181 = OpAccessChain %_ptr_Function_Inner_std140 %166 %175 + %182 = OpLoad %Inner_std140 %181 None + %183 = OpAccessChain %_ptr_Function_Inner_std140 %168 %175 + OpStore %183 %182 None + OpBranch %172 + %172 = OpLabel + %176 = OpIAdd %uint %175 %uint_1 + OpBranch %173 + %174 = OpLabel + %177 = OpLoad %_arr_Inner_std140_uint_4_0 %168 None + OpReturnValue %177 OpFunctionEnd -%tint_convert_explicit_layout_0 = OpFunction %Outer_std140 None %182 +%tint_convert_explicit_layout_0 = OpFunction %Outer_std140 None %185 %tint_source_0 = OpFunctionParameter %Outer_std140_tint_explicit_layout - %183 = OpLabel - %184 = OpCompositeExtract %_arr_Inner_std140_uint_4 %tint_source_0 0 - %185 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %184 - %186 = OpCompositeConstruct %Outer_std140 %185 - OpReturnValue %186 + %186 = OpLabel + %187 = OpCompositeExtract %_arr_Inner_std140_uint_4 %tint_source_0 0 + %188 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %187 + %189 = OpCompositeConstruct %Outer_std140 %188 + OpReturnValue %189 OpFunctionEnd -%tint_convert_explicit_layout_1 = OpFunction %_arr_Outer_std140_uint_4 None %188 +%tint_convert_explicit_layout_1 = OpFunction %_arr_Outer_std140_uint_4 None %191 %tint_source_1 = OpFunctionParameter %_arr_Outer_std140_tint_explicit_layout_uint_4 - %189 = OpLabel - %190 = OpVariable %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 Function - %192 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function %193 - OpStore %190 %tint_source_1 - OpBranch %194 - %194 = OpLabel + %192 = OpLabel + %193 = OpVariable %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 Function + %195 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function %196 + OpStore %193 %tint_source_1 OpBranch %197 %197 = OpLabel - %199 = OpPhi %uint %uint_0 %194 %200 %196 - OpLoopMerge %198 %196 None - OpBranch %195 - %195 = OpLabel - %202 = OpUGreaterThanEqual %bool %199 %uint_4 - OpSelectionMerge %203 None - OpBranchConditional %202 %204 %203 - %204 = OpLabel + OpBranch %200 + %200 = OpLabel + %202 = OpPhi %uint %uint_0 %197 %203 %199 + OpLoopMerge %201 %199 None OpBranch %198 - %203 = OpLabel - %205 = OpAccessChain %_ptr_Function_Outer_std140_tint_explicit_layout %190 %199 - %207 = OpLoad %Outer_std140_tint_explicit_layout %205 None - %208 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %207 - %209 = OpAccessChain %_ptr_Function_Outer_std140 %192 %199 - OpStore %209 %208 None - OpBranch %196 - %196 = OpLabel - %200 = OpIAdd %uint %199 %uint_1 - OpBranch %197 %198 = OpLabel - %201 = OpLoad %_arr_Outer_std140_uint_4 %192 None - OpReturnValue %201 + %205 = OpUGreaterThanEqual %bool %202 %uint_4 + OpSelectionMerge %206 None + OpBranchConditional %205 %207 %206 + %207 = OpLabel + OpBranch %201 + %206 = OpLabel + %208 = OpAccessChain %_ptr_Function_Outer_std140_tint_explicit_layout %193 %202 + %210 = OpLoad %Outer_std140_tint_explicit_layout %208 None + %211 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %210 + %212 = OpAccessChain %_ptr_Function_Outer_std140 %195 %202 + OpStore %212 %211 None + OpBranch %199 + %199 = OpLabel + %203 = OpIAdd %uint %202 %uint_1 + OpBranch %200 + %201 = OpLabel + %204 = OpLoad %_arr_Outer_std140_uint_4 %195 None + OpReturnValue %204 OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/struct/mat2x4_f16/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/struct/mat2x4_f16/dynamic_index_via_ptr.wgsl.expected.glsl index b2d15aa..304b40a 100644 --- a/test/tint/buffer/uniform/std140/struct/mat2x4_f16/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/struct/mat2x4_f16/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -37,76 +37,77 @@ } v; int counter = 0; int i() { - counter = (counter + 1); + uint v_1 = uint(counter); + counter = int((v_1 + uint(1))); return counter; } Inner tint_convert_Inner(Inner_std140 tint_input) { return Inner(f16mat2x4(tint_input.m_col0, tint_input.m_col1)); } Outer tint_convert_Outer(Outer_std140 tint_input) { - Inner v_1[4] = Inner[4](Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf)))); + Inner v_2[4] = Inner[4](Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf)))); { - uint v_2 = 0u; - v_2 = 0u; + uint v_3 = 0u; + v_3 = 0u; while(true) { - uint v_3 = v_2; - if ((v_3 >= 4u)) { + uint v_4 = v_3; + if ((v_4 >= 4u)) { break; } - v_1[v_3] = tint_convert_Inner(tint_input.a[v_3]); + v_2[v_4] = tint_convert_Inner(tint_input.a[v_4]); { - v_2 = (v_3 + 1u); + v_3 = (v_4 + 1u); } continue; } } - return Outer(v_1); + return Outer(v_2); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - uint v_4 = min(uint(i()), 3u); uint v_5 = min(uint(i()), 3u); - f16mat2x4 v_6 = f16mat2x4(v.inner[v_4].a[v_5].m_col0, v.inner[v_4].a[v_5].m_col1); - f16vec4 v_7 = v_6[min(uint(i()), 1u)]; - Outer_std140 v_8[4] = v.inner; - Outer v_9[4] = Outer[4](Outer(Inner[4](Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))))), Outer(Inner[4](Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))))), Outer(Inner[4](Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))))), Outer(Inner[4](Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf)))))); + uint v_6 = min(uint(i()), 3u); + f16mat2x4 v_7 = f16mat2x4(v.inner[v_5].a[v_6].m_col0, v.inner[v_5].a[v_6].m_col1); + f16vec4 v_8 = v_7[min(uint(i()), 1u)]; + Outer_std140 v_9[4] = v.inner; + Outer v_10[4] = Outer[4](Outer(Inner[4](Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))))), Outer(Inner[4](Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))))), Outer(Inner[4](Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))))), Outer(Inner[4](Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf)))))); { - uint v_10 = 0u; - v_10 = 0u; + uint v_11 = 0u; + v_11 = 0u; while(true) { - uint v_11 = v_10; - if ((v_11 >= 4u)) { + uint v_12 = v_11; + if ((v_12 >= 4u)) { break; } - v_9[v_11] = tint_convert_Outer(v_8[v_11]); + v_10[v_12] = tint_convert_Outer(v_9[v_12]); { - v_10 = (v_11 + 1u); + v_11 = (v_12 + 1u); } continue; } } - Outer l_a[4] = v_9; - Outer l_a_i = tint_convert_Outer(v.inner[v_4]); - Inner_std140 v_12[4] = v.inner[v_4].a; - Inner v_13[4] = Inner[4](Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf)))); + Outer l_a[4] = v_10; + Outer l_a_i = tint_convert_Outer(v.inner[v_5]); + Inner_std140 v_13[4] = v.inner[v_5].a; + Inner v_14[4] = Inner[4](Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat2x4(f16vec4(0.0hf), f16vec4(0.0hf)))); { - uint v_14 = 0u; - v_14 = 0u; + uint v_15 = 0u; + v_15 = 0u; while(true) { - uint v_15 = v_14; - if ((v_15 >= 4u)) { + uint v_16 = v_15; + if ((v_16 >= 4u)) { break; } - v_13[v_15] = tint_convert_Inner(v_12[v_15]); + v_14[v_16] = tint_convert_Inner(v_13[v_16]); { - v_14 = (v_15 + 1u); + v_15 = (v_16 + 1u); } continue; } } - Inner l_a_i_a[4] = v_13; - Inner l_a_i_a_i = tint_convert_Inner(v.inner[v_4].a[v_5]); - f16mat2x4 l_a_i_a_i_m = v_6; - f16vec4 l_a_i_a_i_m_i = v_7; - float16_t l_a_i_a_i_m_i_i = v_7[min(uint(i()), 3u)]; + Inner l_a_i_a[4] = v_14; + Inner l_a_i_a_i = tint_convert_Inner(v.inner[v_5].a[v_6]); + f16mat2x4 l_a_i_a_i_m = v_7; + f16vec4 l_a_i_a_i_m_i = v_8; + float16_t l_a_i_a_i_m_i_i = v_8[min(uint(i()), 3u)]; }
diff --git a/test/tint/buffer/uniform/std140/struct/mat2x4_f16/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/struct/mat2x4_f16/dynamic_index_via_ptr.wgsl.expected.spvasm index 560ffa4..f5ab81c 100644 --- a/test/tint/buffer/uniform/std140/struct/mat2x4_f16/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/struct/mat2x4_f16/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,13 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 209 +; Bound: 212 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess - %33 = OpExtInstImport "GLSL.std.450" + %36 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -72,7 +72,7 @@ %17 = OpTypeFunction %int %int_1 = OpConstant %int 1 %void = OpTypeVoid - %25 = OpTypeFunction %void + %28 = OpTypeFunction %void %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 = OpTypePointer Uniform %_arr_Outer_std140_tint_explicit_layout_uint_4 %uint_0 = OpConstant %uint 0 %uint_3 = OpConstant %uint 3 @@ -93,242 +93,245 @@ %Outer = OpTypeStruct %_arr_Inner_uint_4 %_arr_Outer_uint_4 = OpTypeArray %Outer %uint_4 %_ptr_Function__arr_Outer_uint_4 = OpTypePointer Function %_arr_Outer_uint_4 - %74 = OpConstantNull %_arr_Outer_uint_4 + %77 = OpConstantNull %_arr_Outer_uint_4 %_ptr_Function__arr_Inner_std140_uint_4_0 = OpTypePointer Function %_arr_Inner_std140_uint_4_0 %_ptr_Function__arr_Inner_uint_4 = OpTypePointer Function %_arr_Inner_uint_4 - %95 = OpConstantNull %_arr_Inner_uint_4 + %98 = OpConstantNull %_arr_Inner_uint_4 %bool = OpTypeBool %_ptr_Function_Outer = OpTypePointer Function %Outer %_ptr_Function_Outer_std140 = OpTypePointer Function %Outer_std140 %_ptr_Function_Inner = OpTypePointer Function %Inner %_ptr_Function_Inner_std140 = OpTypePointer Function %Inner_std140 - %131 = OpTypeFunction %Inner %Inner_std140 - %138 = OpTypeFunction %Outer %Outer_std140 - %160 = OpTypeFunction %_arr_Inner_std140_uint_4_0 %_arr_Inner_std140_uint_4 + %134 = OpTypeFunction %Inner %Inner_std140 + %141 = OpTypeFunction %Outer %Outer_std140 + %163 = OpTypeFunction %_arr_Inner_std140_uint_4_0 %_arr_Inner_std140_uint_4 %_ptr_Function__arr_Inner_std140_uint_4 = OpTypePointer Function %_arr_Inner_std140_uint_4 - %165 = OpConstantNull %_arr_Inner_std140_uint_4_0 - %181 = OpTypeFunction %Outer_std140 %Outer_std140_tint_explicit_layout - %187 = OpTypeFunction %_arr_Outer_std140_uint_4 %_arr_Outer_std140_tint_explicit_layout_uint_4 + %168 = OpConstantNull %_arr_Inner_std140_uint_4_0 + %184 = OpTypeFunction %Outer_std140 %Outer_std140_tint_explicit_layout + %190 = OpTypeFunction %_arr_Outer_std140_uint_4 %_arr_Outer_std140_tint_explicit_layout_uint_4 %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 = OpTypePointer Function %_arr_Outer_std140_tint_explicit_layout_uint_4 - %192 = OpConstantNull %_arr_Outer_std140_uint_4 + %195 = OpConstantNull %_arr_Outer_std140_uint_4 %_ptr_Function_Outer_std140_tint_explicit_layout = OpTypePointer Function %Outer_std140_tint_explicit_layout %i = OpFunction %int None %17 %18 = OpLabel %19 = OpLoad %int %counter None - %20 = OpIAdd %int %19 %int_1 - OpStore %counter %20 None - %22 = OpLoad %int %counter None - OpReturnValue %22 + %20 = OpBitcast %uint %19 + %21 = OpBitcast %uint %int_1 + %23 = OpIAdd %uint %20 %21 + %24 = OpBitcast %int %23 + OpStore %counter %24 None + %25 = OpLoad %int %counter None + OpReturnValue %25 OpFunctionEnd - %f = OpFunction %void None %25 - %26 = OpLabel - %52 = OpVariable %_ptr_Function_mat2v4half Function - %66 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function - %68 = OpVariable %_ptr_Function__arr_Outer_uint_4 Function %74 - %91 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function - %93 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %95 - %27 = OpAccessChain %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 %1 %uint_0 - %30 = OpFunctionCall %int %i - %31 = OpBitcast %uint %30 - %32 = OpExtInst %uint %33 UMin %31 %uint_3 - %35 = OpAccessChain %_ptr_Uniform_Outer_std140_tint_explicit_layout %27 %32 - %37 = OpAccessChain %_ptr_Uniform__arr_Inner_std140_uint_4 %35 %uint_0 - %39 = OpFunctionCall %int %i - %40 = OpBitcast %uint %39 - %41 = OpExtInst %uint %33 UMin %40 %uint_3 - %42 = OpAccessChain %_ptr_Uniform_Inner_std140 %37 %41 - %44 = OpAccessChain %_ptr_Uniform_v4half %42 %uint_0 - %46 = OpLoad %v4half %44 None - %47 = OpAccessChain %_ptr_Uniform_v4half %42 %uint_1 + %f = OpFunction %void None %28 + %29 = OpLabel + %55 = OpVariable %_ptr_Function_mat2v4half Function + %69 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function + %71 = OpVariable %_ptr_Function__arr_Outer_uint_4 Function %77 + %94 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function + %96 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %98 + %30 = OpAccessChain %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 %1 %uint_0 + %33 = OpFunctionCall %int %i + %34 = OpBitcast %uint %33 + %35 = OpExtInst %uint %36 UMin %34 %uint_3 + %38 = OpAccessChain %_ptr_Uniform_Outer_std140_tint_explicit_layout %30 %35 + %40 = OpAccessChain %_ptr_Uniform__arr_Inner_std140_uint_4 %38 %uint_0 + %42 = OpFunctionCall %int %i + %43 = OpBitcast %uint %42 + %44 = OpExtInst %uint %36 UMin %43 %uint_3 + %45 = OpAccessChain %_ptr_Uniform_Inner_std140 %40 %44 + %47 = OpAccessChain %_ptr_Uniform_v4half %45 %uint_0 %49 = OpLoad %v4half %47 None -%l_a_i_a_i_m = OpCompositeConstruct %mat2v4half %46 %49 - OpStore %52 %l_a_i_a_i_m - %54 = OpFunctionCall %int %i - %55 = OpBitcast %uint %54 - %56 = OpExtInst %uint %33 UMin %55 %uint_1 - %57 = OpAccessChain %_ptr_Function_v4half %52 %56 -%l_a_i_a_i_m_i = OpLoad %v4half %57 None - %60 = OpLoad %_arr_Outer_std140_tint_explicit_layout_uint_4 %27 None - %61 = OpFunctionCall %_arr_Outer_std140_uint_4 %tint_convert_explicit_layout_1 %60 - OpStore %66 %61 - OpBranch %75 - %75 = OpLabel + %50 = OpAccessChain %_ptr_Uniform_v4half %45 %uint_1 + %52 = OpLoad %v4half %50 None +%l_a_i_a_i_m = OpCompositeConstruct %mat2v4half %49 %52 + OpStore %55 %l_a_i_a_i_m + %57 = OpFunctionCall %int %i + %58 = OpBitcast %uint %57 + %59 = OpExtInst %uint %36 UMin %58 %uint_1 + %60 = OpAccessChain %_ptr_Function_v4half %55 %59 +%l_a_i_a_i_m_i = OpLoad %v4half %60 None + %63 = OpLoad %_arr_Outer_std140_tint_explicit_layout_uint_4 %30 None + %64 = OpFunctionCall %_arr_Outer_std140_uint_4 %tint_convert_explicit_layout_1 %63 + OpStore %69 %64 OpBranch %78 %78 = OpLabel - %80 = OpPhi %uint %uint_0 %75 %81 %77 - OpLoopMerge %79 %77 None - OpBranch %76 - %76 = OpLabel - %111 = OpUGreaterThanEqual %bool %80 %uint_4 - OpSelectionMerge %113 None - OpBranchConditional %111 %114 %113 - %114 = OpLabel + OpBranch %81 + %81 = OpLabel + %83 = OpPhi %uint %uint_0 %78 %84 %80 + OpLoopMerge %82 %80 None OpBranch %79 - %113 = OpLabel - %115 = OpAccessChain %_ptr_Function_Outer %68 %80 - %117 = OpAccessChain %_ptr_Function_Outer_std140 %66 %80 - %119 = OpLoad %Outer_std140 %117 None - %120 = OpFunctionCall %Outer %tint_convert_Outer %119 - OpStore %115 %120 None - OpBranch %77 - %77 = OpLabel - %81 = OpIAdd %uint %80 %uint_1 - OpBranch %78 %79 = OpLabel - %l_a = OpLoad %_arr_Outer_uint_4 %68 None - %83 = OpLoad %Outer_std140_tint_explicit_layout %35 None - %84 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %83 - %l_a_i = OpFunctionCall %Outer %tint_convert_Outer %84 - %88 = OpLoad %_arr_Inner_std140_uint_4 %37 None - %89 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %88 - OpStore %91 %89 - OpBranch %96 - %96 = OpLabel + %114 = OpUGreaterThanEqual %bool %83 %uint_4 + OpSelectionMerge %116 None + OpBranchConditional %114 %117 %116 + %117 = OpLabel + OpBranch %82 + %116 = OpLabel + %118 = OpAccessChain %_ptr_Function_Outer %71 %83 + %120 = OpAccessChain %_ptr_Function_Outer_std140 %69 %83 + %122 = OpLoad %Outer_std140 %120 None + %123 = OpFunctionCall %Outer %tint_convert_Outer %122 + OpStore %118 %123 None + OpBranch %80 + %80 = OpLabel + %84 = OpIAdd %uint %83 %uint_1 + OpBranch %81 + %82 = OpLabel + %l_a = OpLoad %_arr_Outer_uint_4 %71 None + %86 = OpLoad %Outer_std140_tint_explicit_layout %38 None + %87 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %86 + %l_a_i = OpFunctionCall %Outer %tint_convert_Outer %87 + %91 = OpLoad %_arr_Inner_std140_uint_4 %40 None + %92 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %91 + OpStore %94 %92 OpBranch %99 %99 = OpLabel - %101 = OpPhi %uint %uint_0 %96 %102 %98 - OpLoopMerge %100 %98 None - OpBranch %97 - %97 = OpLabel - %121 = OpUGreaterThanEqual %bool %101 %uint_4 - OpSelectionMerge %122 None - OpBranchConditional %121 %123 %122 - %123 = OpLabel + OpBranch %102 + %102 = OpLabel + %104 = OpPhi %uint %uint_0 %99 %105 %101 + OpLoopMerge %103 %101 None OpBranch %100 - %122 = OpLabel - %124 = OpAccessChain %_ptr_Function_Inner %93 %101 - %126 = OpAccessChain %_ptr_Function_Inner_std140 %91 %101 - %128 = OpLoad %Inner_std140 %126 None - %129 = OpFunctionCall %Inner %tint_convert_Inner %128 - OpStore %124 %129 None - OpBranch %98 - %98 = OpLabel - %102 = OpIAdd %uint %101 %uint_1 - OpBranch %99 %100 = OpLabel - %l_a_i_a = OpLoad %_arr_Inner_uint_4 %93 None - %104 = OpLoad %Inner_std140 %42 None - %l_a_i_a_i = OpFunctionCall %Inner %tint_convert_Inner %104 - %107 = OpFunctionCall %int %i - %108 = OpBitcast %uint %107 - %109 = OpExtInst %uint %33 UMin %108 %uint_3 -%l_a_i_a_i_m_i_i = OpVectorExtractDynamic %half %l_a_i_a_i_m_i %109 + %124 = OpUGreaterThanEqual %bool %104 %uint_4 + OpSelectionMerge %125 None + OpBranchConditional %124 %126 %125 + %126 = OpLabel + OpBranch %103 + %125 = OpLabel + %127 = OpAccessChain %_ptr_Function_Inner %96 %104 + %129 = OpAccessChain %_ptr_Function_Inner_std140 %94 %104 + %131 = OpLoad %Inner_std140 %129 None + %132 = OpFunctionCall %Inner %tint_convert_Inner %131 + OpStore %127 %132 None + OpBranch %101 + %101 = OpLabel + %105 = OpIAdd %uint %104 %uint_1 + OpBranch %102 + %103 = OpLabel + %l_a_i_a = OpLoad %_arr_Inner_uint_4 %96 None + %107 = OpLoad %Inner_std140 %45 None + %l_a_i_a_i = OpFunctionCall %Inner %tint_convert_Inner %107 + %110 = OpFunctionCall %int %i + %111 = OpBitcast %uint %110 + %112 = OpExtInst %uint %36 UMin %111 %uint_3 +%l_a_i_a_i_m_i_i = OpVectorExtractDynamic %half %l_a_i_a_i_m_i %112 OpReturn OpFunctionEnd -%tint_convert_Inner = OpFunction %Inner None %131 +%tint_convert_Inner = OpFunction %Inner None %134 %tint_input = OpFunctionParameter %Inner_std140 - %132 = OpLabel - %133 = OpCompositeExtract %v4half %tint_input 0 - %134 = OpCompositeExtract %v4half %tint_input 1 - %135 = OpCompositeConstruct %mat2v4half %133 %134 - %136 = OpCompositeConstruct %Inner %135 - OpReturnValue %136 + %135 = OpLabel + %136 = OpCompositeExtract %v4half %tint_input 0 + %137 = OpCompositeExtract %v4half %tint_input 1 + %138 = OpCompositeConstruct %mat2v4half %136 %137 + %139 = OpCompositeConstruct %Inner %138 + OpReturnValue %139 OpFunctionEnd -%tint_convert_Outer = OpFunction %Outer None %138 +%tint_convert_Outer = OpFunction %Outer None %141 %tint_input_0 = OpFunctionParameter %Outer_std140 - %139 = OpLabel - %141 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function - %142 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %95 - %140 = OpCompositeExtract %_arr_Inner_std140_uint_4_0 %tint_input_0 0 - OpStore %141 %140 - OpBranch %143 - %143 = OpLabel + %142 = OpLabel + %144 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function + %145 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %98 + %143 = OpCompositeExtract %_arr_Inner_std140_uint_4_0 %tint_input_0 0 + OpStore %144 %143 OpBranch %146 %146 = OpLabel - %148 = OpPhi %uint %uint_0 %143 %149 %145 - OpLoopMerge %147 %145 None - OpBranch %144 - %144 = OpLabel - %152 = OpUGreaterThanEqual %bool %148 %uint_4 - OpSelectionMerge %153 None - OpBranchConditional %152 %154 %153 - %154 = OpLabel + OpBranch %149 + %149 = OpLabel + %151 = OpPhi %uint %uint_0 %146 %152 %148 + OpLoopMerge %150 %148 None OpBranch %147 - %153 = OpLabel - %155 = OpAccessChain %_ptr_Function_Inner %142 %148 - %156 = OpAccessChain %_ptr_Function_Inner_std140 %141 %148 - %157 = OpLoad %Inner_std140 %156 None - %158 = OpFunctionCall %Inner %tint_convert_Inner %157 - OpStore %155 %158 None - OpBranch %145 - %145 = OpLabel - %149 = OpIAdd %uint %148 %uint_1 - OpBranch %146 %147 = OpLabel - %150 = OpLoad %_arr_Inner_uint_4 %142 None - %151 = OpCompositeConstruct %Outer %150 - OpReturnValue %151 + %155 = OpUGreaterThanEqual %bool %151 %uint_4 + OpSelectionMerge %156 None + OpBranchConditional %155 %157 %156 + %157 = OpLabel + OpBranch %150 + %156 = OpLabel + %158 = OpAccessChain %_ptr_Function_Inner %145 %151 + %159 = OpAccessChain %_ptr_Function_Inner_std140 %144 %151 + %160 = OpLoad %Inner_std140 %159 None + %161 = OpFunctionCall %Inner %tint_convert_Inner %160 + OpStore %158 %161 None + OpBranch %148 + %148 = OpLabel + %152 = OpIAdd %uint %151 %uint_1 + OpBranch %149 + %150 = OpLabel + %153 = OpLoad %_arr_Inner_uint_4 %145 None + %154 = OpCompositeConstruct %Outer %153 + OpReturnValue %154 OpFunctionEnd -%tint_convert_explicit_layout = OpFunction %_arr_Inner_std140_uint_4_0 None %160 +%tint_convert_explicit_layout = OpFunction %_arr_Inner_std140_uint_4_0 None %163 %tint_source = OpFunctionParameter %_arr_Inner_std140_uint_4 - %161 = OpLabel - %162 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4 Function - %164 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function %165 - OpStore %162 %tint_source - OpBranch %166 - %166 = OpLabel + %164 = OpLabel + %165 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4 Function + %167 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function %168 + OpStore %165 %tint_source OpBranch %169 %169 = OpLabel - %171 = OpPhi %uint %uint_0 %166 %172 %168 - OpLoopMerge %170 %168 None - OpBranch %167 - %167 = OpLabel - %174 = OpUGreaterThanEqual %bool %171 %uint_4 - OpSelectionMerge %175 None - OpBranchConditional %174 %176 %175 - %176 = OpLabel + OpBranch %172 + %172 = OpLabel + %174 = OpPhi %uint %uint_0 %169 %175 %171 + OpLoopMerge %173 %171 None OpBranch %170 - %175 = OpLabel - %177 = OpAccessChain %_ptr_Function_Inner_std140 %162 %171 - %178 = OpLoad %Inner_std140 %177 None - %179 = OpAccessChain %_ptr_Function_Inner_std140 %164 %171 - OpStore %179 %178 None - OpBranch %168 - %168 = OpLabel - %172 = OpIAdd %uint %171 %uint_1 - OpBranch %169 %170 = OpLabel - %173 = OpLoad %_arr_Inner_std140_uint_4_0 %164 None - OpReturnValue %173 + %177 = OpUGreaterThanEqual %bool %174 %uint_4 + OpSelectionMerge %178 None + OpBranchConditional %177 %179 %178 + %179 = OpLabel + OpBranch %173 + %178 = OpLabel + %180 = OpAccessChain %_ptr_Function_Inner_std140 %165 %174 + %181 = OpLoad %Inner_std140 %180 None + %182 = OpAccessChain %_ptr_Function_Inner_std140 %167 %174 + OpStore %182 %181 None + OpBranch %171 + %171 = OpLabel + %175 = OpIAdd %uint %174 %uint_1 + OpBranch %172 + %173 = OpLabel + %176 = OpLoad %_arr_Inner_std140_uint_4_0 %167 None + OpReturnValue %176 OpFunctionEnd -%tint_convert_explicit_layout_0 = OpFunction %Outer_std140 None %181 +%tint_convert_explicit_layout_0 = OpFunction %Outer_std140 None %184 %tint_source_0 = OpFunctionParameter %Outer_std140_tint_explicit_layout - %182 = OpLabel - %183 = OpCompositeExtract %_arr_Inner_std140_uint_4 %tint_source_0 0 - %184 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %183 - %185 = OpCompositeConstruct %Outer_std140 %184 - OpReturnValue %185 + %185 = OpLabel + %186 = OpCompositeExtract %_arr_Inner_std140_uint_4 %tint_source_0 0 + %187 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %186 + %188 = OpCompositeConstruct %Outer_std140 %187 + OpReturnValue %188 OpFunctionEnd -%tint_convert_explicit_layout_1 = OpFunction %_arr_Outer_std140_uint_4 None %187 +%tint_convert_explicit_layout_1 = OpFunction %_arr_Outer_std140_uint_4 None %190 %tint_source_1 = OpFunctionParameter %_arr_Outer_std140_tint_explicit_layout_uint_4 - %188 = OpLabel - %189 = OpVariable %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 Function - %191 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function %192 - OpStore %189 %tint_source_1 - OpBranch %193 - %193 = OpLabel + %191 = OpLabel + %192 = OpVariable %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 Function + %194 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function %195 + OpStore %192 %tint_source_1 OpBranch %196 %196 = OpLabel - %198 = OpPhi %uint %uint_0 %193 %199 %195 - OpLoopMerge %197 %195 None - OpBranch %194 - %194 = OpLabel - %201 = OpUGreaterThanEqual %bool %198 %uint_4 - OpSelectionMerge %202 None - OpBranchConditional %201 %203 %202 - %203 = OpLabel + OpBranch %199 + %199 = OpLabel + %201 = OpPhi %uint %uint_0 %196 %202 %198 + OpLoopMerge %200 %198 None OpBranch %197 - %202 = OpLabel - %204 = OpAccessChain %_ptr_Function_Outer_std140_tint_explicit_layout %189 %198 - %206 = OpLoad %Outer_std140_tint_explicit_layout %204 None - %207 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %206 - %208 = OpAccessChain %_ptr_Function_Outer_std140 %191 %198 - OpStore %208 %207 None - OpBranch %195 - %195 = OpLabel - %199 = OpIAdd %uint %198 %uint_1 - OpBranch %196 %197 = OpLabel - %200 = OpLoad %_arr_Outer_std140_uint_4 %191 None - OpReturnValue %200 + %204 = OpUGreaterThanEqual %bool %201 %uint_4 + OpSelectionMerge %205 None + OpBranchConditional %204 %206 %205 + %206 = OpLabel + OpBranch %200 + %205 = OpLabel + %207 = OpAccessChain %_ptr_Function_Outer_std140_tint_explicit_layout %192 %201 + %209 = OpLoad %Outer_std140_tint_explicit_layout %207 None + %210 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %209 + %211 = OpAccessChain %_ptr_Function_Outer_std140 %194 %201 + OpStore %211 %210 None + OpBranch %198 + %198 = OpLabel + %202 = OpIAdd %uint %201 %uint_1 + OpBranch %199 + %200 = OpLabel + %203 = OpLoad %_arr_Outer_std140_uint_4 %194 None + OpReturnValue %203 OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/struct/mat2x4_f32/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/struct/mat2x4_f32/dynamic_index_via_ptr.wgsl.expected.glsl index 8d38e28..22bc747 100644 --- a/test/tint/buffer/uniform/std140/struct/mat2x4_f32/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/struct/mat2x4_f32/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -23,19 +23,20 @@ } v; int counter = 0; int i() { - counter = (counter + 1); + uint v_1 = uint(counter); + counter = int((v_1 + uint(1))); return counter; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - uint v_1 = min(uint(i()), 3u); uint v_2 = min(uint(i()), 3u); - uint v_3 = min(uint(i()), 1u); + uint v_3 = min(uint(i()), 3u); + uint v_4 = min(uint(i()), 1u); Outer l_a[4] = v.inner; - Outer l_a_i = v.inner[v_1]; - Inner l_a_i_a[4] = v.inner[v_1].a; - Inner l_a_i_a_i = v.inner[v_1].a[v_2]; - mat2x4 l_a_i_a_i_m = v.inner[v_1].a[v_2].m; - vec4 l_a_i_a_i_m_i = v.inner[v_1].a[v_2].m[v_3]; - float l_a_i_a_i_m_i_i = v.inner[v_1].a[v_2].m[v_3][min(uint(i()), 3u)]; + Outer l_a_i = v.inner[v_2]; + Inner l_a_i_a[4] = v.inner[v_2].a; + Inner l_a_i_a_i = v.inner[v_2].a[v_3]; + mat2x4 l_a_i_a_i_m = v.inner[v_2].a[v_3].m; + vec4 l_a_i_a_i_m_i = v.inner[v_2].a[v_3].m[v_4]; + float l_a_i_a_i_m_i_i = v.inner[v_2].a[v_3].m[v_4][min(uint(i()), 3u)]; }
diff --git a/test/tint/buffer/uniform/std140/struct/mat2x4_f32/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/struct/mat2x4_f32/dynamic_index_via_ptr.wgsl.expected.spvasm index 9c21d4f..c961dd4 100644 --- a/test/tint/buffer/uniform/std140/struct/mat2x4_f32/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/struct/mat2x4_f32/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,10 +1,10 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 129 +; Bound: 132 ; Schema: 0 OpCapability Shader - %34 = OpExtInstImport "GLSL.std.450" + %37 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -68,7 +68,7 @@ %18 = OpTypeFunction %int %int_1 = OpConstant %int 1 %void = OpTypeVoid - %26 = OpTypeFunction %void + %29 = OpTypeFunction %void %_ptr_Uniform__arr_Outer_tint_explicit_layout_uint_4 = OpTypePointer Uniform %_arr_Outer_tint_explicit_layout_uint_4 %uint_0 = OpConstant %uint 0 %uint_3 = OpConstant %uint 3 @@ -82,130 +82,133 @@ %Outer = OpTypeStruct %_arr_Inner_uint_4_0 %_arr_Outer_uint_4 = OpTypeArray %Outer %uint_4 %_ptr_Uniform_float = OpTypePointer Uniform %float - %75 = OpTypeFunction %_arr_Inner_uint_4_0 %_arr_Inner_uint_4 + %78 = OpTypeFunction %_arr_Inner_uint_4_0 %_arr_Inner_uint_4 %_ptr_Function__arr_Inner_uint_4 = OpTypePointer Function %_arr_Inner_uint_4 %_ptr_Function__arr_Inner_uint_4_0 = OpTypePointer Function %_arr_Inner_uint_4_0 - %81 = OpConstantNull %_arr_Inner_uint_4_0 + %84 = OpConstantNull %_arr_Inner_uint_4_0 %bool = OpTypeBool %_ptr_Function_Inner = OpTypePointer Function %Inner - %99 = OpTypeFunction %Outer %Outer_tint_explicit_layout - %105 = OpTypeFunction %_arr_Outer_uint_4 %_arr_Outer_tint_explicit_layout_uint_4 + %102 = OpTypeFunction %Outer %Outer_tint_explicit_layout + %108 = OpTypeFunction %_arr_Outer_uint_4 %_arr_Outer_tint_explicit_layout_uint_4 %_ptr_Function__arr_Outer_tint_explicit_layout_uint_4 = OpTypePointer Function %_arr_Outer_tint_explicit_layout_uint_4 %_ptr_Function__arr_Outer_uint_4 = OpTypePointer Function %_arr_Outer_uint_4 - %111 = OpConstantNull %_arr_Outer_uint_4 + %114 = OpConstantNull %_arr_Outer_uint_4 %_ptr_Function_Outer_tint_explicit_layout = OpTypePointer Function %Outer_tint_explicit_layout %_ptr_Function_Outer = OpTypePointer Function %Outer %i = OpFunction %int None %18 %19 = OpLabel %20 = OpLoad %int %counter None - %21 = OpIAdd %int %20 %int_1 - OpStore %counter %21 None - %23 = OpLoad %int %counter None - OpReturnValue %23 + %21 = OpBitcast %uint %20 + %22 = OpBitcast %uint %int_1 + %24 = OpIAdd %uint %21 %22 + %25 = OpBitcast %int %24 + OpStore %counter %25 None + %26 = OpLoad %int %counter None + OpReturnValue %26 OpFunctionEnd - %f = OpFunction %void None %26 - %27 = OpLabel + %f = OpFunction %void None %29 + %30 = OpLabel %p_a = OpAccessChain %_ptr_Uniform__arr_Outer_tint_explicit_layout_uint_4 %1 %uint_0 - %31 = OpFunctionCall %int %i - %32 = OpBitcast %uint %31 - %33 = OpExtInst %uint %34 UMin %32 %uint_3 - %p_a_i = OpAccessChain %_ptr_Uniform_Outer_tint_explicit_layout %p_a %33 + %34 = OpFunctionCall %int %i + %35 = OpBitcast %uint %34 + %36 = OpExtInst %uint %37 UMin %35 %uint_3 + %p_a_i = OpAccessChain %_ptr_Uniform_Outer_tint_explicit_layout %p_a %36 %p_a_i_a = OpAccessChain %_ptr_Uniform__arr_Inner_uint_4 %p_a_i %uint_0 - %40 = OpFunctionCall %int %i - %41 = OpBitcast %uint %40 - %42 = OpExtInst %uint %34 UMin %41 %uint_3 - %p_a_i_a_i = OpAccessChain %_ptr_Uniform_Inner %p_a_i_a %42 + %43 = OpFunctionCall %int %i + %44 = OpBitcast %uint %43 + %45 = OpExtInst %uint %37 UMin %44 %uint_3 + %p_a_i_a_i = OpAccessChain %_ptr_Uniform_Inner %p_a_i_a %45 %p_a_i_a_i_m = OpAccessChain %_ptr_Uniform_mat2v4float %p_a_i_a_i %uint_0 - %47 = OpFunctionCall %int %i - %48 = OpBitcast %uint %47 - %49 = OpExtInst %uint %34 UMin %48 %uint_1 -%p_a_i_a_i_m_i = OpAccessChain %_ptr_Uniform_v4float %p_a_i_a_i_m %49 - %53 = OpLoad %_arr_Outer_tint_explicit_layout_uint_4 %p_a None - %l_a = OpFunctionCall %_arr_Outer_uint_4 %tint_convert_explicit_layout_1 %53 - %59 = OpLoad %Outer_tint_explicit_layout %p_a_i None - %l_a_i = OpFunctionCall %Outer %tint_convert_explicit_layout_0 %59 - %62 = OpLoad %_arr_Inner_uint_4 %p_a_i_a None - %l_a_i_a = OpFunctionCall %_arr_Inner_uint_4_0 %tint_convert_explicit_layout %62 + %50 = OpFunctionCall %int %i + %51 = OpBitcast %uint %50 + %52 = OpExtInst %uint %37 UMin %51 %uint_1 +%p_a_i_a_i_m_i = OpAccessChain %_ptr_Uniform_v4float %p_a_i_a_i_m %52 + %56 = OpLoad %_arr_Outer_tint_explicit_layout_uint_4 %p_a None + %l_a = OpFunctionCall %_arr_Outer_uint_4 %tint_convert_explicit_layout_1 %56 + %62 = OpLoad %Outer_tint_explicit_layout %p_a_i None + %l_a_i = OpFunctionCall %Outer %tint_convert_explicit_layout_0 %62 + %65 = OpLoad %_arr_Inner_uint_4 %p_a_i_a None + %l_a_i_a = OpFunctionCall %_arr_Inner_uint_4_0 %tint_convert_explicit_layout %65 %l_a_i_a_i = OpLoad %Inner %p_a_i_a_i None %l_a_i_a_i_m = OpLoad %mat2v4float %p_a_i_a_i_m None %l_a_i_a_i_m_i = OpLoad %v4float %p_a_i_a_i_m_i None - %68 = OpFunctionCall %int %i - %69 = OpBitcast %uint %68 - %70 = OpExtInst %uint %34 UMin %69 %uint_3 - %71 = OpAccessChain %_ptr_Uniform_float %p_a_i_a_i_m_i %70 -%l_a_i_a_i_m_i_i = OpLoad %float %71 None + %71 = OpFunctionCall %int %i + %72 = OpBitcast %uint %71 + %73 = OpExtInst %uint %37 UMin %72 %uint_3 + %74 = OpAccessChain %_ptr_Uniform_float %p_a_i_a_i_m_i %73 +%l_a_i_a_i_m_i_i = OpLoad %float %74 None OpReturn OpFunctionEnd -%tint_convert_explicit_layout = OpFunction %_arr_Inner_uint_4_0 None %75 +%tint_convert_explicit_layout = OpFunction %_arr_Inner_uint_4_0 None %78 %tint_source = OpFunctionParameter %_arr_Inner_uint_4 - %76 = OpLabel - %77 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function - %79 = OpVariable %_ptr_Function__arr_Inner_uint_4_0 Function %81 - OpStore %77 %tint_source - OpBranch %82 - %82 = OpLabel + %79 = OpLabel + %80 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function + %82 = OpVariable %_ptr_Function__arr_Inner_uint_4_0 Function %84 + OpStore %80 %tint_source OpBranch %85 %85 = OpLabel - %87 = OpPhi %uint %uint_0 %82 %88 %84 - OpLoopMerge %86 %84 None - OpBranch %83 - %83 = OpLabel - %90 = OpUGreaterThanEqual %bool %87 %uint_4 - OpSelectionMerge %92 None - OpBranchConditional %90 %93 %92 - %93 = OpLabel + OpBranch %88 + %88 = OpLabel + %90 = OpPhi %uint %uint_0 %85 %91 %87 + OpLoopMerge %89 %87 None OpBranch %86 - %92 = OpLabel - %94 = OpAccessChain %_ptr_Function_Inner %77 %87 - %96 = OpLoad %Inner %94 None - %97 = OpAccessChain %_ptr_Function_Inner %79 %87 - OpStore %97 %96 None - OpBranch %84 - %84 = OpLabel - %88 = OpIAdd %uint %87 %uint_1 - OpBranch %85 %86 = OpLabel - %89 = OpLoad %_arr_Inner_uint_4_0 %79 None - OpReturnValue %89 + %93 = OpUGreaterThanEqual %bool %90 %uint_4 + OpSelectionMerge %95 None + OpBranchConditional %93 %96 %95 + %96 = OpLabel + OpBranch %89 + %95 = OpLabel + %97 = OpAccessChain %_ptr_Function_Inner %80 %90 + %99 = OpLoad %Inner %97 None + %100 = OpAccessChain %_ptr_Function_Inner %82 %90 + OpStore %100 %99 None + OpBranch %87 + %87 = OpLabel + %91 = OpIAdd %uint %90 %uint_1 + OpBranch %88 + %89 = OpLabel + %92 = OpLoad %_arr_Inner_uint_4_0 %82 None + OpReturnValue %92 OpFunctionEnd -%tint_convert_explicit_layout_0 = OpFunction %Outer None %99 +%tint_convert_explicit_layout_0 = OpFunction %Outer None %102 %tint_source_0 = OpFunctionParameter %Outer_tint_explicit_layout - %100 = OpLabel - %101 = OpCompositeExtract %_arr_Inner_uint_4 %tint_source_0 0 - %102 = OpFunctionCall %_arr_Inner_uint_4_0 %tint_convert_explicit_layout %101 - %103 = OpCompositeConstruct %Outer %102 - OpReturnValue %103 + %103 = OpLabel + %104 = OpCompositeExtract %_arr_Inner_uint_4 %tint_source_0 0 + %105 = OpFunctionCall %_arr_Inner_uint_4_0 %tint_convert_explicit_layout %104 + %106 = OpCompositeConstruct %Outer %105 + OpReturnValue %106 OpFunctionEnd -%tint_convert_explicit_layout_1 = OpFunction %_arr_Outer_uint_4 None %105 +%tint_convert_explicit_layout_1 = OpFunction %_arr_Outer_uint_4 None %108 %tint_source_1 = OpFunctionParameter %_arr_Outer_tint_explicit_layout_uint_4 - %106 = OpLabel - %107 = OpVariable %_ptr_Function__arr_Outer_tint_explicit_layout_uint_4 Function - %109 = OpVariable %_ptr_Function__arr_Outer_uint_4 Function %111 - OpStore %107 %tint_source_1 - OpBranch %112 - %112 = OpLabel + %109 = OpLabel + %110 = OpVariable %_ptr_Function__arr_Outer_tint_explicit_layout_uint_4 Function + %112 = OpVariable %_ptr_Function__arr_Outer_uint_4 Function %114 + OpStore %110 %tint_source_1 OpBranch %115 %115 = OpLabel - %117 = OpPhi %uint %uint_0 %112 %118 %114 - OpLoopMerge %116 %114 None - OpBranch %113 - %113 = OpLabel - %120 = OpUGreaterThanEqual %bool %117 %uint_4 - OpSelectionMerge %121 None - OpBranchConditional %120 %122 %121 - %122 = OpLabel + OpBranch %118 + %118 = OpLabel + %120 = OpPhi %uint %uint_0 %115 %121 %117 + OpLoopMerge %119 %117 None OpBranch %116 - %121 = OpLabel - %123 = OpAccessChain %_ptr_Function_Outer_tint_explicit_layout %107 %117 - %125 = OpLoad %Outer_tint_explicit_layout %123 None - %126 = OpFunctionCall %Outer %tint_convert_explicit_layout_0 %125 - %127 = OpAccessChain %_ptr_Function_Outer %109 %117 - OpStore %127 %126 None - OpBranch %114 - %114 = OpLabel - %118 = OpIAdd %uint %117 %uint_1 - OpBranch %115 %116 = OpLabel - %119 = OpLoad %_arr_Outer_uint_4 %109 None - OpReturnValue %119 + %123 = OpUGreaterThanEqual %bool %120 %uint_4 + OpSelectionMerge %124 None + OpBranchConditional %123 %125 %124 + %125 = OpLabel + OpBranch %119 + %124 = OpLabel + %126 = OpAccessChain %_ptr_Function_Outer_tint_explicit_layout %110 %120 + %128 = OpLoad %Outer_tint_explicit_layout %126 None + %129 = OpFunctionCall %Outer %tint_convert_explicit_layout_0 %128 + %130 = OpAccessChain %_ptr_Function_Outer %112 %120 + OpStore %130 %129 None + OpBranch %117 + %117 = OpLabel + %121 = OpIAdd %uint %120 %uint_1 + OpBranch %118 + %119 = OpLabel + %122 = OpLoad %_arr_Outer_uint_4 %112 None + OpReturnValue %122 OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/struct/mat3x2_f16/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/struct/mat3x2_f16/dynamic_index_via_ptr.wgsl.expected.glsl index 6d0584e..d7c4807 100644 --- a/test/tint/buffer/uniform/std140/struct/mat3x2_f16/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/struct/mat3x2_f16/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -39,76 +39,77 @@ } v; int counter = 0; int i() { - counter = (counter + 1); + uint v_1 = uint(counter); + counter = int((v_1 + uint(1))); return counter; } Inner tint_convert_Inner(Inner_std140 tint_input) { return Inner(f16mat3x2(tint_input.m_col0, tint_input.m_col1, tint_input.m_col2)); } Outer tint_convert_Outer(Outer_std140 tint_input) { - Inner v_1[4] = Inner[4](Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf)))); + Inner v_2[4] = Inner[4](Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf)))); { - uint v_2 = 0u; - v_2 = 0u; + uint v_3 = 0u; + v_3 = 0u; while(true) { - uint v_3 = v_2; - if ((v_3 >= 4u)) { + uint v_4 = v_3; + if ((v_4 >= 4u)) { break; } - v_1[v_3] = tint_convert_Inner(tint_input.a[v_3]); + v_2[v_4] = tint_convert_Inner(tint_input.a[v_4]); { - v_2 = (v_3 + 1u); + v_3 = (v_4 + 1u); } continue; } } - return Outer(v_1); + return Outer(v_2); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - uint v_4 = min(uint(i()), 3u); uint v_5 = min(uint(i()), 3u); - f16mat3x2 v_6 = f16mat3x2(v.inner[v_4].a[v_5].m_col0, v.inner[v_4].a[v_5].m_col1, v.inner[v_4].a[v_5].m_col2); - f16vec2 v_7 = v_6[min(uint(i()), 2u)]; - Outer_std140 v_8[4] = v.inner; - Outer v_9[4] = Outer[4](Outer(Inner[4](Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))))), Outer(Inner[4](Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))))), Outer(Inner[4](Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))))), Outer(Inner[4](Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf)))))); + uint v_6 = min(uint(i()), 3u); + f16mat3x2 v_7 = f16mat3x2(v.inner[v_5].a[v_6].m_col0, v.inner[v_5].a[v_6].m_col1, v.inner[v_5].a[v_6].m_col2); + f16vec2 v_8 = v_7[min(uint(i()), 2u)]; + Outer_std140 v_9[4] = v.inner; + Outer v_10[4] = Outer[4](Outer(Inner[4](Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))))), Outer(Inner[4](Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))))), Outer(Inner[4](Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))))), Outer(Inner[4](Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf)))))); { - uint v_10 = 0u; - v_10 = 0u; + uint v_11 = 0u; + v_11 = 0u; while(true) { - uint v_11 = v_10; - if ((v_11 >= 4u)) { + uint v_12 = v_11; + if ((v_12 >= 4u)) { break; } - v_9[v_11] = tint_convert_Outer(v_8[v_11]); + v_10[v_12] = tint_convert_Outer(v_9[v_12]); { - v_10 = (v_11 + 1u); + v_11 = (v_12 + 1u); } continue; } } - Outer l_a[4] = v_9; - Outer l_a_i = tint_convert_Outer(v.inner[v_4]); - Inner_std140 v_12[4] = v.inner[v_4].a; - Inner v_13[4] = Inner[4](Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf)))); + Outer l_a[4] = v_10; + Outer l_a_i = tint_convert_Outer(v.inner[v_5]); + Inner_std140 v_13[4] = v.inner[v_5].a; + Inner v_14[4] = Inner[4](Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat3x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf)))); { - uint v_14 = 0u; - v_14 = 0u; + uint v_15 = 0u; + v_15 = 0u; while(true) { - uint v_15 = v_14; - if ((v_15 >= 4u)) { + uint v_16 = v_15; + if ((v_16 >= 4u)) { break; } - v_13[v_15] = tint_convert_Inner(v_12[v_15]); + v_14[v_16] = tint_convert_Inner(v_13[v_16]); { - v_14 = (v_15 + 1u); + v_15 = (v_16 + 1u); } continue; } } - Inner l_a_i_a[4] = v_13; - Inner l_a_i_a_i = tint_convert_Inner(v.inner[v_4].a[v_5]); - f16mat3x2 l_a_i_a_i_m = v_6; - f16vec2 l_a_i_a_i_m_i = v_7; - float16_t l_a_i_a_i_m_i_i = v_7[min(uint(i()), 1u)]; + Inner l_a_i_a[4] = v_14; + Inner l_a_i_a_i = tint_convert_Inner(v.inner[v_5].a[v_6]); + f16mat3x2 l_a_i_a_i_m = v_7; + f16vec2 l_a_i_a_i_m_i = v_8; + float16_t l_a_i_a_i_m_i_i = v_8[min(uint(i()), 1u)]; }
diff --git a/test/tint/buffer/uniform/std140/struct/mat3x2_f16/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/struct/mat3x2_f16/dynamic_index_via_ptr.wgsl.expected.spvasm index dad729a..e638f26 100644 --- a/test/tint/buffer/uniform/std140/struct/mat3x2_f16/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/struct/mat3x2_f16/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,13 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 213 +; Bound: 216 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess - %33 = OpExtInstImport "GLSL.std.450" + %36 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -74,7 +74,7 @@ %17 = OpTypeFunction %int %int_1 = OpConstant %int 1 %void = OpTypeVoid - %25 = OpTypeFunction %void + %28 = OpTypeFunction %void %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 = OpTypePointer Uniform %_arr_Outer_std140_tint_explicit_layout_uint_4 %uint_0 = OpConstant %uint 0 %uint_3 = OpConstant %uint 3 @@ -96,245 +96,248 @@ %Outer = OpTypeStruct %_arr_Inner_uint_4 %_arr_Outer_uint_4 = OpTypeArray %Outer %uint_4 %_ptr_Function__arr_Outer_uint_4 = OpTypePointer Function %_arr_Outer_uint_4 - %77 = OpConstantNull %_arr_Outer_uint_4 + %80 = OpConstantNull %_arr_Outer_uint_4 %_ptr_Function__arr_Inner_std140_uint_4_0 = OpTypePointer Function %_arr_Inner_std140_uint_4_0 %_ptr_Function__arr_Inner_uint_4 = OpTypePointer Function %_arr_Inner_uint_4 - %98 = OpConstantNull %_arr_Inner_uint_4 + %101 = OpConstantNull %_arr_Inner_uint_4 %bool = OpTypeBool %_ptr_Function_Outer = OpTypePointer Function %Outer %_ptr_Function_Outer_std140 = OpTypePointer Function %Outer_std140 %_ptr_Function_Inner = OpTypePointer Function %Inner %_ptr_Function_Inner_std140 = OpTypePointer Function %Inner_std140 - %134 = OpTypeFunction %Inner %Inner_std140 - %142 = OpTypeFunction %Outer %Outer_std140 - %164 = OpTypeFunction %_arr_Inner_std140_uint_4_0 %_arr_Inner_std140_uint_4 + %137 = OpTypeFunction %Inner %Inner_std140 + %145 = OpTypeFunction %Outer %Outer_std140 + %167 = OpTypeFunction %_arr_Inner_std140_uint_4_0 %_arr_Inner_std140_uint_4 %_ptr_Function__arr_Inner_std140_uint_4 = OpTypePointer Function %_arr_Inner_std140_uint_4 - %169 = OpConstantNull %_arr_Inner_std140_uint_4_0 - %185 = OpTypeFunction %Outer_std140 %Outer_std140_tint_explicit_layout - %191 = OpTypeFunction %_arr_Outer_std140_uint_4 %_arr_Outer_std140_tint_explicit_layout_uint_4 + %172 = OpConstantNull %_arr_Inner_std140_uint_4_0 + %188 = OpTypeFunction %Outer_std140 %Outer_std140_tint_explicit_layout + %194 = OpTypeFunction %_arr_Outer_std140_uint_4 %_arr_Outer_std140_tint_explicit_layout_uint_4 %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 = OpTypePointer Function %_arr_Outer_std140_tint_explicit_layout_uint_4 - %196 = OpConstantNull %_arr_Outer_std140_uint_4 + %199 = OpConstantNull %_arr_Outer_std140_uint_4 %_ptr_Function_Outer_std140_tint_explicit_layout = OpTypePointer Function %Outer_std140_tint_explicit_layout %i = OpFunction %int None %17 %18 = OpLabel %19 = OpLoad %int %counter None - %20 = OpIAdd %int %19 %int_1 - OpStore %counter %20 None - %22 = OpLoad %int %counter None - OpReturnValue %22 + %20 = OpBitcast %uint %19 + %21 = OpBitcast %uint %int_1 + %23 = OpIAdd %uint %20 %21 + %24 = OpBitcast %int %23 + OpStore %counter %24 None + %25 = OpLoad %int %counter None + OpReturnValue %25 OpFunctionEnd - %f = OpFunction %void None %25 - %26 = OpLabel - %55 = OpVariable %_ptr_Function_mat3v2half Function - %69 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function - %71 = OpVariable %_ptr_Function__arr_Outer_uint_4 Function %77 - %94 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function - %96 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %98 - %27 = OpAccessChain %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 %1 %uint_0 - %30 = OpFunctionCall %int %i - %31 = OpBitcast %uint %30 - %32 = OpExtInst %uint %33 UMin %31 %uint_3 - %35 = OpAccessChain %_ptr_Uniform_Outer_std140_tint_explicit_layout %27 %32 - %37 = OpAccessChain %_ptr_Uniform__arr_Inner_std140_uint_4 %35 %uint_0 - %39 = OpFunctionCall %int %i - %40 = OpBitcast %uint %39 - %41 = OpExtInst %uint %33 UMin %40 %uint_3 - %42 = OpAccessChain %_ptr_Uniform_Inner_std140 %37 %41 - %44 = OpAccessChain %_ptr_Uniform_v2half %42 %uint_0 - %46 = OpLoad %v2half %44 None - %47 = OpAccessChain %_ptr_Uniform_v2half %42 %uint_1 + %f = OpFunction %void None %28 + %29 = OpLabel + %58 = OpVariable %_ptr_Function_mat3v2half Function + %72 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function + %74 = OpVariable %_ptr_Function__arr_Outer_uint_4 Function %80 + %97 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function + %99 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %101 + %30 = OpAccessChain %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 %1 %uint_0 + %33 = OpFunctionCall %int %i + %34 = OpBitcast %uint %33 + %35 = OpExtInst %uint %36 UMin %34 %uint_3 + %38 = OpAccessChain %_ptr_Uniform_Outer_std140_tint_explicit_layout %30 %35 + %40 = OpAccessChain %_ptr_Uniform__arr_Inner_std140_uint_4 %38 %uint_0 + %42 = OpFunctionCall %int %i + %43 = OpBitcast %uint %42 + %44 = OpExtInst %uint %36 UMin %43 %uint_3 + %45 = OpAccessChain %_ptr_Uniform_Inner_std140 %40 %44 + %47 = OpAccessChain %_ptr_Uniform_v2half %45 %uint_0 %49 = OpLoad %v2half %47 None - %50 = OpAccessChain %_ptr_Uniform_v2half %42 %uint_2 + %50 = OpAccessChain %_ptr_Uniform_v2half %45 %uint_1 %52 = OpLoad %v2half %50 None -%l_a_i_a_i_m = OpCompositeConstruct %mat3v2half %46 %49 %52 - OpStore %55 %l_a_i_a_i_m - %57 = OpFunctionCall %int %i - %58 = OpBitcast %uint %57 - %59 = OpExtInst %uint %33 UMin %58 %uint_2 - %60 = OpAccessChain %_ptr_Function_v2half %55 %59 -%l_a_i_a_i_m_i = OpLoad %v2half %60 None - %63 = OpLoad %_arr_Outer_std140_tint_explicit_layout_uint_4 %27 None - %64 = OpFunctionCall %_arr_Outer_std140_uint_4 %tint_convert_explicit_layout_1 %63 - OpStore %69 %64 - OpBranch %78 - %78 = OpLabel + %53 = OpAccessChain %_ptr_Uniform_v2half %45 %uint_2 + %55 = OpLoad %v2half %53 None +%l_a_i_a_i_m = OpCompositeConstruct %mat3v2half %49 %52 %55 + OpStore %58 %l_a_i_a_i_m + %60 = OpFunctionCall %int %i + %61 = OpBitcast %uint %60 + %62 = OpExtInst %uint %36 UMin %61 %uint_2 + %63 = OpAccessChain %_ptr_Function_v2half %58 %62 +%l_a_i_a_i_m_i = OpLoad %v2half %63 None + %66 = OpLoad %_arr_Outer_std140_tint_explicit_layout_uint_4 %30 None + %67 = OpFunctionCall %_arr_Outer_std140_uint_4 %tint_convert_explicit_layout_1 %66 + OpStore %72 %67 OpBranch %81 %81 = OpLabel - %83 = OpPhi %uint %uint_0 %78 %84 %80 - OpLoopMerge %82 %80 None - OpBranch %79 - %79 = OpLabel - %114 = OpUGreaterThanEqual %bool %83 %uint_4 - OpSelectionMerge %116 None - OpBranchConditional %114 %117 %116 - %117 = OpLabel + OpBranch %84 + %84 = OpLabel + %86 = OpPhi %uint %uint_0 %81 %87 %83 + OpLoopMerge %85 %83 None OpBranch %82 - %116 = OpLabel - %118 = OpAccessChain %_ptr_Function_Outer %71 %83 - %120 = OpAccessChain %_ptr_Function_Outer_std140 %69 %83 - %122 = OpLoad %Outer_std140 %120 None - %123 = OpFunctionCall %Outer %tint_convert_Outer %122 - OpStore %118 %123 None - OpBranch %80 - %80 = OpLabel - %84 = OpIAdd %uint %83 %uint_1 - OpBranch %81 %82 = OpLabel - %l_a = OpLoad %_arr_Outer_uint_4 %71 None - %86 = OpLoad %Outer_std140_tint_explicit_layout %35 None - %87 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %86 - %l_a_i = OpFunctionCall %Outer %tint_convert_Outer %87 - %91 = OpLoad %_arr_Inner_std140_uint_4 %37 None - %92 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %91 - OpStore %94 %92 - OpBranch %99 - %99 = OpLabel + %117 = OpUGreaterThanEqual %bool %86 %uint_4 + OpSelectionMerge %119 None + OpBranchConditional %117 %120 %119 + %120 = OpLabel + OpBranch %85 + %119 = OpLabel + %121 = OpAccessChain %_ptr_Function_Outer %74 %86 + %123 = OpAccessChain %_ptr_Function_Outer_std140 %72 %86 + %125 = OpLoad %Outer_std140 %123 None + %126 = OpFunctionCall %Outer %tint_convert_Outer %125 + OpStore %121 %126 None + OpBranch %83 + %83 = OpLabel + %87 = OpIAdd %uint %86 %uint_1 + OpBranch %84 + %85 = OpLabel + %l_a = OpLoad %_arr_Outer_uint_4 %74 None + %89 = OpLoad %Outer_std140_tint_explicit_layout %38 None + %90 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %89 + %l_a_i = OpFunctionCall %Outer %tint_convert_Outer %90 + %94 = OpLoad %_arr_Inner_std140_uint_4 %40 None + %95 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %94 + OpStore %97 %95 OpBranch %102 %102 = OpLabel - %104 = OpPhi %uint %uint_0 %99 %105 %101 - OpLoopMerge %103 %101 None - OpBranch %100 - %100 = OpLabel - %124 = OpUGreaterThanEqual %bool %104 %uint_4 - OpSelectionMerge %125 None - OpBranchConditional %124 %126 %125 - %126 = OpLabel + OpBranch %105 + %105 = OpLabel + %107 = OpPhi %uint %uint_0 %102 %108 %104 + OpLoopMerge %106 %104 None OpBranch %103 - %125 = OpLabel - %127 = OpAccessChain %_ptr_Function_Inner %96 %104 - %129 = OpAccessChain %_ptr_Function_Inner_std140 %94 %104 - %131 = OpLoad %Inner_std140 %129 None - %132 = OpFunctionCall %Inner %tint_convert_Inner %131 - OpStore %127 %132 None - OpBranch %101 - %101 = OpLabel - %105 = OpIAdd %uint %104 %uint_1 - OpBranch %102 %103 = OpLabel - %l_a_i_a = OpLoad %_arr_Inner_uint_4 %96 None - %107 = OpLoad %Inner_std140 %42 None - %l_a_i_a_i = OpFunctionCall %Inner %tint_convert_Inner %107 - %110 = OpFunctionCall %int %i - %111 = OpBitcast %uint %110 - %112 = OpExtInst %uint %33 UMin %111 %uint_1 -%l_a_i_a_i_m_i_i = OpVectorExtractDynamic %half %l_a_i_a_i_m_i %112 + %127 = OpUGreaterThanEqual %bool %107 %uint_4 + OpSelectionMerge %128 None + OpBranchConditional %127 %129 %128 + %129 = OpLabel + OpBranch %106 + %128 = OpLabel + %130 = OpAccessChain %_ptr_Function_Inner %99 %107 + %132 = OpAccessChain %_ptr_Function_Inner_std140 %97 %107 + %134 = OpLoad %Inner_std140 %132 None + %135 = OpFunctionCall %Inner %tint_convert_Inner %134 + OpStore %130 %135 None + OpBranch %104 + %104 = OpLabel + %108 = OpIAdd %uint %107 %uint_1 + OpBranch %105 + %106 = OpLabel + %l_a_i_a = OpLoad %_arr_Inner_uint_4 %99 None + %110 = OpLoad %Inner_std140 %45 None + %l_a_i_a_i = OpFunctionCall %Inner %tint_convert_Inner %110 + %113 = OpFunctionCall %int %i + %114 = OpBitcast %uint %113 + %115 = OpExtInst %uint %36 UMin %114 %uint_1 +%l_a_i_a_i_m_i_i = OpVectorExtractDynamic %half %l_a_i_a_i_m_i %115 OpReturn OpFunctionEnd -%tint_convert_Inner = OpFunction %Inner None %134 +%tint_convert_Inner = OpFunction %Inner None %137 %tint_input = OpFunctionParameter %Inner_std140 - %135 = OpLabel - %136 = OpCompositeExtract %v2half %tint_input 0 - %137 = OpCompositeExtract %v2half %tint_input 1 - %138 = OpCompositeExtract %v2half %tint_input 2 - %139 = OpCompositeConstruct %mat3v2half %136 %137 %138 - %140 = OpCompositeConstruct %Inner %139 - OpReturnValue %140 + %138 = OpLabel + %139 = OpCompositeExtract %v2half %tint_input 0 + %140 = OpCompositeExtract %v2half %tint_input 1 + %141 = OpCompositeExtract %v2half %tint_input 2 + %142 = OpCompositeConstruct %mat3v2half %139 %140 %141 + %143 = OpCompositeConstruct %Inner %142 + OpReturnValue %143 OpFunctionEnd -%tint_convert_Outer = OpFunction %Outer None %142 +%tint_convert_Outer = OpFunction %Outer None %145 %tint_input_0 = OpFunctionParameter %Outer_std140 - %143 = OpLabel - %145 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function - %146 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %98 - %144 = OpCompositeExtract %_arr_Inner_std140_uint_4_0 %tint_input_0 0 - OpStore %145 %144 - OpBranch %147 - %147 = OpLabel + %146 = OpLabel + %148 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function + %149 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %101 + %147 = OpCompositeExtract %_arr_Inner_std140_uint_4_0 %tint_input_0 0 + OpStore %148 %147 OpBranch %150 %150 = OpLabel - %152 = OpPhi %uint %uint_0 %147 %153 %149 - OpLoopMerge %151 %149 None - OpBranch %148 - %148 = OpLabel - %156 = OpUGreaterThanEqual %bool %152 %uint_4 - OpSelectionMerge %157 None - OpBranchConditional %156 %158 %157 - %158 = OpLabel + OpBranch %153 + %153 = OpLabel + %155 = OpPhi %uint %uint_0 %150 %156 %152 + OpLoopMerge %154 %152 None OpBranch %151 - %157 = OpLabel - %159 = OpAccessChain %_ptr_Function_Inner %146 %152 - %160 = OpAccessChain %_ptr_Function_Inner_std140 %145 %152 - %161 = OpLoad %Inner_std140 %160 None - %162 = OpFunctionCall %Inner %tint_convert_Inner %161 - OpStore %159 %162 None - OpBranch %149 - %149 = OpLabel - %153 = OpIAdd %uint %152 %uint_1 - OpBranch %150 %151 = OpLabel - %154 = OpLoad %_arr_Inner_uint_4 %146 None - %155 = OpCompositeConstruct %Outer %154 - OpReturnValue %155 + %159 = OpUGreaterThanEqual %bool %155 %uint_4 + OpSelectionMerge %160 None + OpBranchConditional %159 %161 %160 + %161 = OpLabel + OpBranch %154 + %160 = OpLabel + %162 = OpAccessChain %_ptr_Function_Inner %149 %155 + %163 = OpAccessChain %_ptr_Function_Inner_std140 %148 %155 + %164 = OpLoad %Inner_std140 %163 None + %165 = OpFunctionCall %Inner %tint_convert_Inner %164 + OpStore %162 %165 None + OpBranch %152 + %152 = OpLabel + %156 = OpIAdd %uint %155 %uint_1 + OpBranch %153 + %154 = OpLabel + %157 = OpLoad %_arr_Inner_uint_4 %149 None + %158 = OpCompositeConstruct %Outer %157 + OpReturnValue %158 OpFunctionEnd -%tint_convert_explicit_layout = OpFunction %_arr_Inner_std140_uint_4_0 None %164 +%tint_convert_explicit_layout = OpFunction %_arr_Inner_std140_uint_4_0 None %167 %tint_source = OpFunctionParameter %_arr_Inner_std140_uint_4 - %165 = OpLabel - %166 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4 Function - %168 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function %169 - OpStore %166 %tint_source - OpBranch %170 - %170 = OpLabel + %168 = OpLabel + %169 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4 Function + %171 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function %172 + OpStore %169 %tint_source OpBranch %173 %173 = OpLabel - %175 = OpPhi %uint %uint_0 %170 %176 %172 - OpLoopMerge %174 %172 None - OpBranch %171 - %171 = OpLabel - %178 = OpUGreaterThanEqual %bool %175 %uint_4 - OpSelectionMerge %179 None - OpBranchConditional %178 %180 %179 - %180 = OpLabel + OpBranch %176 + %176 = OpLabel + %178 = OpPhi %uint %uint_0 %173 %179 %175 + OpLoopMerge %177 %175 None OpBranch %174 - %179 = OpLabel - %181 = OpAccessChain %_ptr_Function_Inner_std140 %166 %175 - %182 = OpLoad %Inner_std140 %181 None - %183 = OpAccessChain %_ptr_Function_Inner_std140 %168 %175 - OpStore %183 %182 None - OpBranch %172 - %172 = OpLabel - %176 = OpIAdd %uint %175 %uint_1 - OpBranch %173 %174 = OpLabel - %177 = OpLoad %_arr_Inner_std140_uint_4_0 %168 None - OpReturnValue %177 + %181 = OpUGreaterThanEqual %bool %178 %uint_4 + OpSelectionMerge %182 None + OpBranchConditional %181 %183 %182 + %183 = OpLabel + OpBranch %177 + %182 = OpLabel + %184 = OpAccessChain %_ptr_Function_Inner_std140 %169 %178 + %185 = OpLoad %Inner_std140 %184 None + %186 = OpAccessChain %_ptr_Function_Inner_std140 %171 %178 + OpStore %186 %185 None + OpBranch %175 + %175 = OpLabel + %179 = OpIAdd %uint %178 %uint_1 + OpBranch %176 + %177 = OpLabel + %180 = OpLoad %_arr_Inner_std140_uint_4_0 %171 None + OpReturnValue %180 OpFunctionEnd -%tint_convert_explicit_layout_0 = OpFunction %Outer_std140 None %185 +%tint_convert_explicit_layout_0 = OpFunction %Outer_std140 None %188 %tint_source_0 = OpFunctionParameter %Outer_std140_tint_explicit_layout - %186 = OpLabel - %187 = OpCompositeExtract %_arr_Inner_std140_uint_4 %tint_source_0 0 - %188 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %187 - %189 = OpCompositeConstruct %Outer_std140 %188 - OpReturnValue %189 + %189 = OpLabel + %190 = OpCompositeExtract %_arr_Inner_std140_uint_4 %tint_source_0 0 + %191 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %190 + %192 = OpCompositeConstruct %Outer_std140 %191 + OpReturnValue %192 OpFunctionEnd -%tint_convert_explicit_layout_1 = OpFunction %_arr_Outer_std140_uint_4 None %191 +%tint_convert_explicit_layout_1 = OpFunction %_arr_Outer_std140_uint_4 None %194 %tint_source_1 = OpFunctionParameter %_arr_Outer_std140_tint_explicit_layout_uint_4 - %192 = OpLabel - %193 = OpVariable %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 Function - %195 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function %196 - OpStore %193 %tint_source_1 - OpBranch %197 - %197 = OpLabel + %195 = OpLabel + %196 = OpVariable %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 Function + %198 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function %199 + OpStore %196 %tint_source_1 OpBranch %200 %200 = OpLabel - %202 = OpPhi %uint %uint_0 %197 %203 %199 - OpLoopMerge %201 %199 None - OpBranch %198 - %198 = OpLabel - %205 = OpUGreaterThanEqual %bool %202 %uint_4 - OpSelectionMerge %206 None - OpBranchConditional %205 %207 %206 - %207 = OpLabel + OpBranch %203 + %203 = OpLabel + %205 = OpPhi %uint %uint_0 %200 %206 %202 + OpLoopMerge %204 %202 None OpBranch %201 - %206 = OpLabel - %208 = OpAccessChain %_ptr_Function_Outer_std140_tint_explicit_layout %193 %202 - %210 = OpLoad %Outer_std140_tint_explicit_layout %208 None - %211 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %210 - %212 = OpAccessChain %_ptr_Function_Outer_std140 %195 %202 - OpStore %212 %211 None - OpBranch %199 - %199 = OpLabel - %203 = OpIAdd %uint %202 %uint_1 - OpBranch %200 %201 = OpLabel - %204 = OpLoad %_arr_Outer_std140_uint_4 %195 None - OpReturnValue %204 + %208 = OpUGreaterThanEqual %bool %205 %uint_4 + OpSelectionMerge %209 None + OpBranchConditional %208 %210 %209 + %210 = OpLabel + OpBranch %204 + %209 = OpLabel + %211 = OpAccessChain %_ptr_Function_Outer_std140_tint_explicit_layout %196 %205 + %213 = OpLoad %Outer_std140_tint_explicit_layout %211 None + %214 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %213 + %215 = OpAccessChain %_ptr_Function_Outer_std140 %198 %205 + OpStore %215 %214 None + OpBranch %202 + %202 = OpLabel + %206 = OpIAdd %uint %205 %uint_1 + OpBranch %203 + %204 = OpLabel + %207 = OpLoad %_arr_Outer_std140_uint_4 %198 None + OpReturnValue %207 OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/struct/mat3x2_f32/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/struct/mat3x2_f32/dynamic_index_via_ptr.wgsl.expected.glsl index c8e2253..2f4b525 100644 --- a/test/tint/buffer/uniform/std140/struct/mat3x2_f32/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/struct/mat3x2_f32/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -35,76 +35,77 @@ } v; int counter = 0; int i() { - counter = (counter + 1); + uint v_1 = uint(counter); + counter = int((v_1 + uint(1))); return counter; } Inner tint_convert_Inner(Inner_std140 tint_input) { return Inner(mat3x2(tint_input.m_col0, tint_input.m_col1, tint_input.m_col2)); } Outer tint_convert_Outer(Outer_std140 tint_input) { - Inner v_1[4] = Inner[4](Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f)))); + Inner v_2[4] = Inner[4](Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f)))); { - uint v_2 = 0u; - v_2 = 0u; + uint v_3 = 0u; + v_3 = 0u; while(true) { - uint v_3 = v_2; - if ((v_3 >= 4u)) { + uint v_4 = v_3; + if ((v_4 >= 4u)) { break; } - v_1[v_3] = tint_convert_Inner(tint_input.a[v_3]); + v_2[v_4] = tint_convert_Inner(tint_input.a[v_4]); { - v_2 = (v_3 + 1u); + v_3 = (v_4 + 1u); } continue; } } - return Outer(v_1); + return Outer(v_2); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - uint v_4 = min(uint(i()), 3u); uint v_5 = min(uint(i()), 3u); - mat3x2 v_6 = mat3x2(v.inner[v_4].a[v_5].m_col0, v.inner[v_4].a[v_5].m_col1, v.inner[v_4].a[v_5].m_col2); - vec2 v_7 = v_6[min(uint(i()), 2u)]; - Outer_std140 v_8[4] = v.inner; - Outer v_9[4] = Outer[4](Outer(Inner[4](Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))))), Outer(Inner[4](Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))))), Outer(Inner[4](Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))))), Outer(Inner[4](Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f)))))); + uint v_6 = min(uint(i()), 3u); + mat3x2 v_7 = mat3x2(v.inner[v_5].a[v_6].m_col0, v.inner[v_5].a[v_6].m_col1, v.inner[v_5].a[v_6].m_col2); + vec2 v_8 = v_7[min(uint(i()), 2u)]; + Outer_std140 v_9[4] = v.inner; + Outer v_10[4] = Outer[4](Outer(Inner[4](Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))))), Outer(Inner[4](Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))))), Outer(Inner[4](Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))))), Outer(Inner[4](Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f)))))); { - uint v_10 = 0u; - v_10 = 0u; + uint v_11 = 0u; + v_11 = 0u; while(true) { - uint v_11 = v_10; - if ((v_11 >= 4u)) { + uint v_12 = v_11; + if ((v_12 >= 4u)) { break; } - v_9[v_11] = tint_convert_Outer(v_8[v_11]); + v_10[v_12] = tint_convert_Outer(v_9[v_12]); { - v_10 = (v_11 + 1u); + v_11 = (v_12 + 1u); } continue; } } - Outer l_a[4] = v_9; - Outer l_a_i = tint_convert_Outer(v.inner[v_4]); - Inner_std140 v_12[4] = v.inner[v_4].a; - Inner v_13[4] = Inner[4](Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f)))); + Outer l_a[4] = v_10; + Outer l_a_i = tint_convert_Outer(v.inner[v_5]); + Inner_std140 v_13[4] = v.inner[v_5].a; + Inner v_14[4] = Inner[4](Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat3x2(vec2(0.0f), vec2(0.0f), vec2(0.0f)))); { - uint v_14 = 0u; - v_14 = 0u; + uint v_15 = 0u; + v_15 = 0u; while(true) { - uint v_15 = v_14; - if ((v_15 >= 4u)) { + uint v_16 = v_15; + if ((v_16 >= 4u)) { break; } - v_13[v_15] = tint_convert_Inner(v_12[v_15]); + v_14[v_16] = tint_convert_Inner(v_13[v_16]); { - v_14 = (v_15 + 1u); + v_15 = (v_16 + 1u); } continue; } } - Inner l_a_i_a[4] = v_13; - Inner l_a_i_a_i = tint_convert_Inner(v.inner[v_4].a[v_5]); - mat3x2 l_a_i_a_i_m = v_6; - vec2 l_a_i_a_i_m_i = v_7; - float l_a_i_a_i_m_i_i = v_7[min(uint(i()), 1u)]; + Inner l_a_i_a[4] = v_14; + Inner l_a_i_a_i = tint_convert_Inner(v.inner[v_5].a[v_6]); + mat3x2 l_a_i_a_i_m = v_7; + vec2 l_a_i_a_i_m_i = v_8; + float l_a_i_a_i_m_i_i = v_8[min(uint(i()), 1u)]; }
diff --git a/test/tint/buffer/uniform/std140/struct/mat3x2_f32/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/struct/mat3x2_f32/dynamic_index_via_ptr.wgsl.expected.spvasm index 495be83..6cfce4b 100644 --- a/test/tint/buffer/uniform/std140/struct/mat3x2_f32/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/struct/mat3x2_f32/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,10 +1,10 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 213 +; Bound: 216 ; Schema: 0 OpCapability Shader - %33 = OpExtInstImport "GLSL.std.450" + %36 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -71,7 +71,7 @@ %17 = OpTypeFunction %int %int_1 = OpConstant %int 1 %void = OpTypeVoid - %25 = OpTypeFunction %void + %28 = OpTypeFunction %void %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 = OpTypePointer Uniform %_arr_Outer_std140_tint_explicit_layout_uint_4 %uint_0 = OpConstant %uint 0 %uint_3 = OpConstant %uint 3 @@ -93,245 +93,248 @@ %Outer = OpTypeStruct %_arr_Inner_uint_4 %_arr_Outer_uint_4 = OpTypeArray %Outer %uint_4 %_ptr_Function__arr_Outer_uint_4 = OpTypePointer Function %_arr_Outer_uint_4 - %77 = OpConstantNull %_arr_Outer_uint_4 + %80 = OpConstantNull %_arr_Outer_uint_4 %_ptr_Function__arr_Inner_std140_uint_4_0 = OpTypePointer Function %_arr_Inner_std140_uint_4_0 %_ptr_Function__arr_Inner_uint_4 = OpTypePointer Function %_arr_Inner_uint_4 - %98 = OpConstantNull %_arr_Inner_uint_4 + %101 = OpConstantNull %_arr_Inner_uint_4 %bool = OpTypeBool %_ptr_Function_Outer = OpTypePointer Function %Outer %_ptr_Function_Outer_std140 = OpTypePointer Function %Outer_std140 %_ptr_Function_Inner = OpTypePointer Function %Inner %_ptr_Function_Inner_std140 = OpTypePointer Function %Inner_std140 - %134 = OpTypeFunction %Inner %Inner_std140 - %142 = OpTypeFunction %Outer %Outer_std140 - %164 = OpTypeFunction %_arr_Inner_std140_uint_4_0 %_arr_Inner_std140_uint_4 + %137 = OpTypeFunction %Inner %Inner_std140 + %145 = OpTypeFunction %Outer %Outer_std140 + %167 = OpTypeFunction %_arr_Inner_std140_uint_4_0 %_arr_Inner_std140_uint_4 %_ptr_Function__arr_Inner_std140_uint_4 = OpTypePointer Function %_arr_Inner_std140_uint_4 - %169 = OpConstantNull %_arr_Inner_std140_uint_4_0 - %185 = OpTypeFunction %Outer_std140 %Outer_std140_tint_explicit_layout - %191 = OpTypeFunction %_arr_Outer_std140_uint_4 %_arr_Outer_std140_tint_explicit_layout_uint_4 + %172 = OpConstantNull %_arr_Inner_std140_uint_4_0 + %188 = OpTypeFunction %Outer_std140 %Outer_std140_tint_explicit_layout + %194 = OpTypeFunction %_arr_Outer_std140_uint_4 %_arr_Outer_std140_tint_explicit_layout_uint_4 %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 = OpTypePointer Function %_arr_Outer_std140_tint_explicit_layout_uint_4 - %196 = OpConstantNull %_arr_Outer_std140_uint_4 + %199 = OpConstantNull %_arr_Outer_std140_uint_4 %_ptr_Function_Outer_std140_tint_explicit_layout = OpTypePointer Function %Outer_std140_tint_explicit_layout %i = OpFunction %int None %17 %18 = OpLabel %19 = OpLoad %int %counter None - %20 = OpIAdd %int %19 %int_1 - OpStore %counter %20 None - %22 = OpLoad %int %counter None - OpReturnValue %22 + %20 = OpBitcast %uint %19 + %21 = OpBitcast %uint %int_1 + %23 = OpIAdd %uint %20 %21 + %24 = OpBitcast %int %23 + OpStore %counter %24 None + %25 = OpLoad %int %counter None + OpReturnValue %25 OpFunctionEnd - %f = OpFunction %void None %25 - %26 = OpLabel - %55 = OpVariable %_ptr_Function_mat3v2float Function - %69 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function - %71 = OpVariable %_ptr_Function__arr_Outer_uint_4 Function %77 - %94 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function - %96 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %98 - %27 = OpAccessChain %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 %1 %uint_0 - %30 = OpFunctionCall %int %i - %31 = OpBitcast %uint %30 - %32 = OpExtInst %uint %33 UMin %31 %uint_3 - %35 = OpAccessChain %_ptr_Uniform_Outer_std140_tint_explicit_layout %27 %32 - %37 = OpAccessChain %_ptr_Uniform__arr_Inner_std140_uint_4 %35 %uint_0 - %39 = OpFunctionCall %int %i - %40 = OpBitcast %uint %39 - %41 = OpExtInst %uint %33 UMin %40 %uint_3 - %42 = OpAccessChain %_ptr_Uniform_Inner_std140 %37 %41 - %44 = OpAccessChain %_ptr_Uniform_v2float %42 %uint_0 - %46 = OpLoad %v2float %44 None - %47 = OpAccessChain %_ptr_Uniform_v2float %42 %uint_1 + %f = OpFunction %void None %28 + %29 = OpLabel + %58 = OpVariable %_ptr_Function_mat3v2float Function + %72 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function + %74 = OpVariable %_ptr_Function__arr_Outer_uint_4 Function %80 + %97 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function + %99 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %101 + %30 = OpAccessChain %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 %1 %uint_0 + %33 = OpFunctionCall %int %i + %34 = OpBitcast %uint %33 + %35 = OpExtInst %uint %36 UMin %34 %uint_3 + %38 = OpAccessChain %_ptr_Uniform_Outer_std140_tint_explicit_layout %30 %35 + %40 = OpAccessChain %_ptr_Uniform__arr_Inner_std140_uint_4 %38 %uint_0 + %42 = OpFunctionCall %int %i + %43 = OpBitcast %uint %42 + %44 = OpExtInst %uint %36 UMin %43 %uint_3 + %45 = OpAccessChain %_ptr_Uniform_Inner_std140 %40 %44 + %47 = OpAccessChain %_ptr_Uniform_v2float %45 %uint_0 %49 = OpLoad %v2float %47 None - %50 = OpAccessChain %_ptr_Uniform_v2float %42 %uint_2 + %50 = OpAccessChain %_ptr_Uniform_v2float %45 %uint_1 %52 = OpLoad %v2float %50 None -%l_a_i_a_i_m = OpCompositeConstruct %mat3v2float %46 %49 %52 - OpStore %55 %l_a_i_a_i_m - %57 = OpFunctionCall %int %i - %58 = OpBitcast %uint %57 - %59 = OpExtInst %uint %33 UMin %58 %uint_2 - %60 = OpAccessChain %_ptr_Function_v2float %55 %59 -%l_a_i_a_i_m_i = OpLoad %v2float %60 None - %63 = OpLoad %_arr_Outer_std140_tint_explicit_layout_uint_4 %27 None - %64 = OpFunctionCall %_arr_Outer_std140_uint_4 %tint_convert_explicit_layout_1 %63 - OpStore %69 %64 - OpBranch %78 - %78 = OpLabel + %53 = OpAccessChain %_ptr_Uniform_v2float %45 %uint_2 + %55 = OpLoad %v2float %53 None +%l_a_i_a_i_m = OpCompositeConstruct %mat3v2float %49 %52 %55 + OpStore %58 %l_a_i_a_i_m + %60 = OpFunctionCall %int %i + %61 = OpBitcast %uint %60 + %62 = OpExtInst %uint %36 UMin %61 %uint_2 + %63 = OpAccessChain %_ptr_Function_v2float %58 %62 +%l_a_i_a_i_m_i = OpLoad %v2float %63 None + %66 = OpLoad %_arr_Outer_std140_tint_explicit_layout_uint_4 %30 None + %67 = OpFunctionCall %_arr_Outer_std140_uint_4 %tint_convert_explicit_layout_1 %66 + OpStore %72 %67 OpBranch %81 %81 = OpLabel - %83 = OpPhi %uint %uint_0 %78 %84 %80 - OpLoopMerge %82 %80 None - OpBranch %79 - %79 = OpLabel - %114 = OpUGreaterThanEqual %bool %83 %uint_4 - OpSelectionMerge %116 None - OpBranchConditional %114 %117 %116 - %117 = OpLabel + OpBranch %84 + %84 = OpLabel + %86 = OpPhi %uint %uint_0 %81 %87 %83 + OpLoopMerge %85 %83 None OpBranch %82 - %116 = OpLabel - %118 = OpAccessChain %_ptr_Function_Outer %71 %83 - %120 = OpAccessChain %_ptr_Function_Outer_std140 %69 %83 - %122 = OpLoad %Outer_std140 %120 None - %123 = OpFunctionCall %Outer %tint_convert_Outer %122 - OpStore %118 %123 None - OpBranch %80 - %80 = OpLabel - %84 = OpIAdd %uint %83 %uint_1 - OpBranch %81 %82 = OpLabel - %l_a = OpLoad %_arr_Outer_uint_4 %71 None - %86 = OpLoad %Outer_std140_tint_explicit_layout %35 None - %87 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %86 - %l_a_i = OpFunctionCall %Outer %tint_convert_Outer %87 - %91 = OpLoad %_arr_Inner_std140_uint_4 %37 None - %92 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %91 - OpStore %94 %92 - OpBranch %99 - %99 = OpLabel + %117 = OpUGreaterThanEqual %bool %86 %uint_4 + OpSelectionMerge %119 None + OpBranchConditional %117 %120 %119 + %120 = OpLabel + OpBranch %85 + %119 = OpLabel + %121 = OpAccessChain %_ptr_Function_Outer %74 %86 + %123 = OpAccessChain %_ptr_Function_Outer_std140 %72 %86 + %125 = OpLoad %Outer_std140 %123 None + %126 = OpFunctionCall %Outer %tint_convert_Outer %125 + OpStore %121 %126 None + OpBranch %83 + %83 = OpLabel + %87 = OpIAdd %uint %86 %uint_1 + OpBranch %84 + %85 = OpLabel + %l_a = OpLoad %_arr_Outer_uint_4 %74 None + %89 = OpLoad %Outer_std140_tint_explicit_layout %38 None + %90 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %89 + %l_a_i = OpFunctionCall %Outer %tint_convert_Outer %90 + %94 = OpLoad %_arr_Inner_std140_uint_4 %40 None + %95 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %94 + OpStore %97 %95 OpBranch %102 %102 = OpLabel - %104 = OpPhi %uint %uint_0 %99 %105 %101 - OpLoopMerge %103 %101 None - OpBranch %100 - %100 = OpLabel - %124 = OpUGreaterThanEqual %bool %104 %uint_4 - OpSelectionMerge %125 None - OpBranchConditional %124 %126 %125 - %126 = OpLabel + OpBranch %105 + %105 = OpLabel + %107 = OpPhi %uint %uint_0 %102 %108 %104 + OpLoopMerge %106 %104 None OpBranch %103 - %125 = OpLabel - %127 = OpAccessChain %_ptr_Function_Inner %96 %104 - %129 = OpAccessChain %_ptr_Function_Inner_std140 %94 %104 - %131 = OpLoad %Inner_std140 %129 None - %132 = OpFunctionCall %Inner %tint_convert_Inner %131 - OpStore %127 %132 None - OpBranch %101 - %101 = OpLabel - %105 = OpIAdd %uint %104 %uint_1 - OpBranch %102 %103 = OpLabel - %l_a_i_a = OpLoad %_arr_Inner_uint_4 %96 None - %107 = OpLoad %Inner_std140 %42 None - %l_a_i_a_i = OpFunctionCall %Inner %tint_convert_Inner %107 - %110 = OpFunctionCall %int %i - %111 = OpBitcast %uint %110 - %112 = OpExtInst %uint %33 UMin %111 %uint_1 -%l_a_i_a_i_m_i_i = OpVectorExtractDynamic %float %l_a_i_a_i_m_i %112 + %127 = OpUGreaterThanEqual %bool %107 %uint_4 + OpSelectionMerge %128 None + OpBranchConditional %127 %129 %128 + %129 = OpLabel + OpBranch %106 + %128 = OpLabel + %130 = OpAccessChain %_ptr_Function_Inner %99 %107 + %132 = OpAccessChain %_ptr_Function_Inner_std140 %97 %107 + %134 = OpLoad %Inner_std140 %132 None + %135 = OpFunctionCall %Inner %tint_convert_Inner %134 + OpStore %130 %135 None + OpBranch %104 + %104 = OpLabel + %108 = OpIAdd %uint %107 %uint_1 + OpBranch %105 + %106 = OpLabel + %l_a_i_a = OpLoad %_arr_Inner_uint_4 %99 None + %110 = OpLoad %Inner_std140 %45 None + %l_a_i_a_i = OpFunctionCall %Inner %tint_convert_Inner %110 + %113 = OpFunctionCall %int %i + %114 = OpBitcast %uint %113 + %115 = OpExtInst %uint %36 UMin %114 %uint_1 +%l_a_i_a_i_m_i_i = OpVectorExtractDynamic %float %l_a_i_a_i_m_i %115 OpReturn OpFunctionEnd -%tint_convert_Inner = OpFunction %Inner None %134 +%tint_convert_Inner = OpFunction %Inner None %137 %tint_input = OpFunctionParameter %Inner_std140 - %135 = OpLabel - %136 = OpCompositeExtract %v2float %tint_input 0 - %137 = OpCompositeExtract %v2float %tint_input 1 - %138 = OpCompositeExtract %v2float %tint_input 2 - %139 = OpCompositeConstruct %mat3v2float %136 %137 %138 - %140 = OpCompositeConstruct %Inner %139 - OpReturnValue %140 + %138 = OpLabel + %139 = OpCompositeExtract %v2float %tint_input 0 + %140 = OpCompositeExtract %v2float %tint_input 1 + %141 = OpCompositeExtract %v2float %tint_input 2 + %142 = OpCompositeConstruct %mat3v2float %139 %140 %141 + %143 = OpCompositeConstruct %Inner %142 + OpReturnValue %143 OpFunctionEnd -%tint_convert_Outer = OpFunction %Outer None %142 +%tint_convert_Outer = OpFunction %Outer None %145 %tint_input_0 = OpFunctionParameter %Outer_std140 - %143 = OpLabel - %145 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function - %146 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %98 - %144 = OpCompositeExtract %_arr_Inner_std140_uint_4_0 %tint_input_0 0 - OpStore %145 %144 - OpBranch %147 - %147 = OpLabel + %146 = OpLabel + %148 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function + %149 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %101 + %147 = OpCompositeExtract %_arr_Inner_std140_uint_4_0 %tint_input_0 0 + OpStore %148 %147 OpBranch %150 %150 = OpLabel - %152 = OpPhi %uint %uint_0 %147 %153 %149 - OpLoopMerge %151 %149 None - OpBranch %148 - %148 = OpLabel - %156 = OpUGreaterThanEqual %bool %152 %uint_4 - OpSelectionMerge %157 None - OpBranchConditional %156 %158 %157 - %158 = OpLabel + OpBranch %153 + %153 = OpLabel + %155 = OpPhi %uint %uint_0 %150 %156 %152 + OpLoopMerge %154 %152 None OpBranch %151 - %157 = OpLabel - %159 = OpAccessChain %_ptr_Function_Inner %146 %152 - %160 = OpAccessChain %_ptr_Function_Inner_std140 %145 %152 - %161 = OpLoad %Inner_std140 %160 None - %162 = OpFunctionCall %Inner %tint_convert_Inner %161 - OpStore %159 %162 None - OpBranch %149 - %149 = OpLabel - %153 = OpIAdd %uint %152 %uint_1 - OpBranch %150 %151 = OpLabel - %154 = OpLoad %_arr_Inner_uint_4 %146 None - %155 = OpCompositeConstruct %Outer %154 - OpReturnValue %155 + %159 = OpUGreaterThanEqual %bool %155 %uint_4 + OpSelectionMerge %160 None + OpBranchConditional %159 %161 %160 + %161 = OpLabel + OpBranch %154 + %160 = OpLabel + %162 = OpAccessChain %_ptr_Function_Inner %149 %155 + %163 = OpAccessChain %_ptr_Function_Inner_std140 %148 %155 + %164 = OpLoad %Inner_std140 %163 None + %165 = OpFunctionCall %Inner %tint_convert_Inner %164 + OpStore %162 %165 None + OpBranch %152 + %152 = OpLabel + %156 = OpIAdd %uint %155 %uint_1 + OpBranch %153 + %154 = OpLabel + %157 = OpLoad %_arr_Inner_uint_4 %149 None + %158 = OpCompositeConstruct %Outer %157 + OpReturnValue %158 OpFunctionEnd -%tint_convert_explicit_layout = OpFunction %_arr_Inner_std140_uint_4_0 None %164 +%tint_convert_explicit_layout = OpFunction %_arr_Inner_std140_uint_4_0 None %167 %tint_source = OpFunctionParameter %_arr_Inner_std140_uint_4 - %165 = OpLabel - %166 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4 Function - %168 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function %169 - OpStore %166 %tint_source - OpBranch %170 - %170 = OpLabel + %168 = OpLabel + %169 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4 Function + %171 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function %172 + OpStore %169 %tint_source OpBranch %173 %173 = OpLabel - %175 = OpPhi %uint %uint_0 %170 %176 %172 - OpLoopMerge %174 %172 None - OpBranch %171 - %171 = OpLabel - %178 = OpUGreaterThanEqual %bool %175 %uint_4 - OpSelectionMerge %179 None - OpBranchConditional %178 %180 %179 - %180 = OpLabel + OpBranch %176 + %176 = OpLabel + %178 = OpPhi %uint %uint_0 %173 %179 %175 + OpLoopMerge %177 %175 None OpBranch %174 - %179 = OpLabel - %181 = OpAccessChain %_ptr_Function_Inner_std140 %166 %175 - %182 = OpLoad %Inner_std140 %181 None - %183 = OpAccessChain %_ptr_Function_Inner_std140 %168 %175 - OpStore %183 %182 None - OpBranch %172 - %172 = OpLabel - %176 = OpIAdd %uint %175 %uint_1 - OpBranch %173 %174 = OpLabel - %177 = OpLoad %_arr_Inner_std140_uint_4_0 %168 None - OpReturnValue %177 + %181 = OpUGreaterThanEqual %bool %178 %uint_4 + OpSelectionMerge %182 None + OpBranchConditional %181 %183 %182 + %183 = OpLabel + OpBranch %177 + %182 = OpLabel + %184 = OpAccessChain %_ptr_Function_Inner_std140 %169 %178 + %185 = OpLoad %Inner_std140 %184 None + %186 = OpAccessChain %_ptr_Function_Inner_std140 %171 %178 + OpStore %186 %185 None + OpBranch %175 + %175 = OpLabel + %179 = OpIAdd %uint %178 %uint_1 + OpBranch %176 + %177 = OpLabel + %180 = OpLoad %_arr_Inner_std140_uint_4_0 %171 None + OpReturnValue %180 OpFunctionEnd -%tint_convert_explicit_layout_0 = OpFunction %Outer_std140 None %185 +%tint_convert_explicit_layout_0 = OpFunction %Outer_std140 None %188 %tint_source_0 = OpFunctionParameter %Outer_std140_tint_explicit_layout - %186 = OpLabel - %187 = OpCompositeExtract %_arr_Inner_std140_uint_4 %tint_source_0 0 - %188 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %187 - %189 = OpCompositeConstruct %Outer_std140 %188 - OpReturnValue %189 + %189 = OpLabel + %190 = OpCompositeExtract %_arr_Inner_std140_uint_4 %tint_source_0 0 + %191 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %190 + %192 = OpCompositeConstruct %Outer_std140 %191 + OpReturnValue %192 OpFunctionEnd -%tint_convert_explicit_layout_1 = OpFunction %_arr_Outer_std140_uint_4 None %191 +%tint_convert_explicit_layout_1 = OpFunction %_arr_Outer_std140_uint_4 None %194 %tint_source_1 = OpFunctionParameter %_arr_Outer_std140_tint_explicit_layout_uint_4 - %192 = OpLabel - %193 = OpVariable %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 Function - %195 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function %196 - OpStore %193 %tint_source_1 - OpBranch %197 - %197 = OpLabel + %195 = OpLabel + %196 = OpVariable %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 Function + %198 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function %199 + OpStore %196 %tint_source_1 OpBranch %200 %200 = OpLabel - %202 = OpPhi %uint %uint_0 %197 %203 %199 - OpLoopMerge %201 %199 None - OpBranch %198 - %198 = OpLabel - %205 = OpUGreaterThanEqual %bool %202 %uint_4 - OpSelectionMerge %206 None - OpBranchConditional %205 %207 %206 - %207 = OpLabel + OpBranch %203 + %203 = OpLabel + %205 = OpPhi %uint %uint_0 %200 %206 %202 + OpLoopMerge %204 %202 None OpBranch %201 - %206 = OpLabel - %208 = OpAccessChain %_ptr_Function_Outer_std140_tint_explicit_layout %193 %202 - %210 = OpLoad %Outer_std140_tint_explicit_layout %208 None - %211 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %210 - %212 = OpAccessChain %_ptr_Function_Outer_std140 %195 %202 - OpStore %212 %211 None - OpBranch %199 - %199 = OpLabel - %203 = OpIAdd %uint %202 %uint_1 - OpBranch %200 %201 = OpLabel - %204 = OpLoad %_arr_Outer_std140_uint_4 %195 None - OpReturnValue %204 + %208 = OpUGreaterThanEqual %bool %205 %uint_4 + OpSelectionMerge %209 None + OpBranchConditional %208 %210 %209 + %210 = OpLabel + OpBranch %204 + %209 = OpLabel + %211 = OpAccessChain %_ptr_Function_Outer_std140_tint_explicit_layout %196 %205 + %213 = OpLoad %Outer_std140_tint_explicit_layout %211 None + %214 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %213 + %215 = OpAccessChain %_ptr_Function_Outer_std140 %198 %205 + OpStore %215 %214 None + OpBranch %202 + %202 = OpLabel + %206 = OpIAdd %uint %205 %uint_1 + OpBranch %203 + %204 = OpLabel + %207 = OpLoad %_arr_Outer_std140_uint_4 %198 None + OpReturnValue %207 OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/struct/mat3x3_f16/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/struct/mat3x3_f16/dynamic_index_via_ptr.wgsl.expected.glsl index c0f2547..9b85615 100644 --- a/test/tint/buffer/uniform/std140/struct/mat3x3_f16/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/struct/mat3x3_f16/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -36,76 +36,77 @@ } v; int counter = 0; int i() { - counter = (counter + 1); + uint v_1 = uint(counter); + counter = int((v_1 + uint(1))); return counter; } Inner tint_convert_Inner(Inner_std140 tint_input) { return Inner(f16mat3(tint_input.m_col0, tint_input.m_col1, tint_input.m_col2)); } Outer tint_convert_Outer(Outer_std140 tint_input) { - Inner v_1[4] = Inner[4](Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf)))); + Inner v_2[4] = Inner[4](Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf)))); { - uint v_2 = 0u; - v_2 = 0u; + uint v_3 = 0u; + v_3 = 0u; while(true) { - uint v_3 = v_2; - if ((v_3 >= 4u)) { + uint v_4 = v_3; + if ((v_4 >= 4u)) { break; } - v_1[v_3] = tint_convert_Inner(tint_input.a[v_3]); + v_2[v_4] = tint_convert_Inner(tint_input.a[v_4]); { - v_2 = (v_3 + 1u); + v_3 = (v_4 + 1u); } continue; } } - return Outer(v_1); + return Outer(v_2); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - uint v_4 = min(uint(i()), 3u); uint v_5 = min(uint(i()), 3u); - f16mat3 v_6 = f16mat3(v.inner[v_4].a[v_5].m_col0, v.inner[v_4].a[v_5].m_col1, v.inner[v_4].a[v_5].m_col2); - f16vec3 v_7 = v_6[min(uint(i()), 2u)]; - Outer_std140 v_8[4] = v.inner; - Outer v_9[4] = Outer[4](Outer(Inner[4](Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))))), Outer(Inner[4](Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))))), Outer(Inner[4](Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))))), Outer(Inner[4](Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf)))))); + uint v_6 = min(uint(i()), 3u); + f16mat3 v_7 = f16mat3(v.inner[v_5].a[v_6].m_col0, v.inner[v_5].a[v_6].m_col1, v.inner[v_5].a[v_6].m_col2); + f16vec3 v_8 = v_7[min(uint(i()), 2u)]; + Outer_std140 v_9[4] = v.inner; + Outer v_10[4] = Outer[4](Outer(Inner[4](Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))))), Outer(Inner[4](Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))))), Outer(Inner[4](Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))))), Outer(Inner[4](Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf)))))); { - uint v_10 = 0u; - v_10 = 0u; + uint v_11 = 0u; + v_11 = 0u; while(true) { - uint v_11 = v_10; - if ((v_11 >= 4u)) { + uint v_12 = v_11; + if ((v_12 >= 4u)) { break; } - v_9[v_11] = tint_convert_Outer(v_8[v_11]); + v_10[v_12] = tint_convert_Outer(v_9[v_12]); { - v_10 = (v_11 + 1u); + v_11 = (v_12 + 1u); } continue; } } - Outer l_a[4] = v_9; - Outer l_a_i = tint_convert_Outer(v.inner[v_4]); - Inner_std140 v_12[4] = v.inner[v_4].a; - Inner v_13[4] = Inner[4](Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf)))); + Outer l_a[4] = v_10; + Outer l_a_i = tint_convert_Outer(v.inner[v_5]); + Inner_std140 v_13[4] = v.inner[v_5].a; + Inner v_14[4] = Inner[4](Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf)))); { - uint v_14 = 0u; - v_14 = 0u; + uint v_15 = 0u; + v_15 = 0u; while(true) { - uint v_15 = v_14; - if ((v_15 >= 4u)) { + uint v_16 = v_15; + if ((v_16 >= 4u)) { break; } - v_13[v_15] = tint_convert_Inner(v_12[v_15]); + v_14[v_16] = tint_convert_Inner(v_13[v_16]); { - v_14 = (v_15 + 1u); + v_15 = (v_16 + 1u); } continue; } } - Inner l_a_i_a[4] = v_13; - Inner l_a_i_a_i = tint_convert_Inner(v.inner[v_4].a[v_5]); - f16mat3 l_a_i_a_i_m = v_6; - f16vec3 l_a_i_a_i_m_i = v_7; - float16_t l_a_i_a_i_m_i_i = v_7[min(uint(i()), 2u)]; + Inner l_a_i_a[4] = v_14; + Inner l_a_i_a_i = tint_convert_Inner(v.inner[v_5].a[v_6]); + f16mat3 l_a_i_a_i_m = v_7; + f16vec3 l_a_i_a_i_m_i = v_8; + float16_t l_a_i_a_i_m_i_i = v_8[min(uint(i()), 2u)]; }
diff --git a/test/tint/buffer/uniform/std140/struct/mat3x3_f16/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/struct/mat3x3_f16/dynamic_index_via_ptr.wgsl.expected.spvasm index 62b33b3..c504352 100644 --- a/test/tint/buffer/uniform/std140/struct/mat3x3_f16/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/struct/mat3x3_f16/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,13 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 213 +; Bound: 216 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess - %33 = OpExtInstImport "GLSL.std.450" + %36 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -74,7 +74,7 @@ %17 = OpTypeFunction %int %int_1 = OpConstant %int 1 %void = OpTypeVoid - %25 = OpTypeFunction %void + %28 = OpTypeFunction %void %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 = OpTypePointer Uniform %_arr_Outer_std140_tint_explicit_layout_uint_4 %uint_0 = OpConstant %uint 0 %uint_3 = OpConstant %uint 3 @@ -96,245 +96,248 @@ %Outer = OpTypeStruct %_arr_Inner_uint_4 %_arr_Outer_uint_4 = OpTypeArray %Outer %uint_4 %_ptr_Function__arr_Outer_uint_4 = OpTypePointer Function %_arr_Outer_uint_4 - %77 = OpConstantNull %_arr_Outer_uint_4 + %80 = OpConstantNull %_arr_Outer_uint_4 %_ptr_Function__arr_Inner_std140_uint_4_0 = OpTypePointer Function %_arr_Inner_std140_uint_4_0 %_ptr_Function__arr_Inner_uint_4 = OpTypePointer Function %_arr_Inner_uint_4 - %98 = OpConstantNull %_arr_Inner_uint_4 + %101 = OpConstantNull %_arr_Inner_uint_4 %bool = OpTypeBool %_ptr_Function_Outer = OpTypePointer Function %Outer %_ptr_Function_Outer_std140 = OpTypePointer Function %Outer_std140 %_ptr_Function_Inner = OpTypePointer Function %Inner %_ptr_Function_Inner_std140 = OpTypePointer Function %Inner_std140 - %134 = OpTypeFunction %Inner %Inner_std140 - %142 = OpTypeFunction %Outer %Outer_std140 - %164 = OpTypeFunction %_arr_Inner_std140_uint_4_0 %_arr_Inner_std140_uint_4 + %137 = OpTypeFunction %Inner %Inner_std140 + %145 = OpTypeFunction %Outer %Outer_std140 + %167 = OpTypeFunction %_arr_Inner_std140_uint_4_0 %_arr_Inner_std140_uint_4 %_ptr_Function__arr_Inner_std140_uint_4 = OpTypePointer Function %_arr_Inner_std140_uint_4 - %169 = OpConstantNull %_arr_Inner_std140_uint_4_0 - %185 = OpTypeFunction %Outer_std140 %Outer_std140_tint_explicit_layout - %191 = OpTypeFunction %_arr_Outer_std140_uint_4 %_arr_Outer_std140_tint_explicit_layout_uint_4 + %172 = OpConstantNull %_arr_Inner_std140_uint_4_0 + %188 = OpTypeFunction %Outer_std140 %Outer_std140_tint_explicit_layout + %194 = OpTypeFunction %_arr_Outer_std140_uint_4 %_arr_Outer_std140_tint_explicit_layout_uint_4 %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 = OpTypePointer Function %_arr_Outer_std140_tint_explicit_layout_uint_4 - %196 = OpConstantNull %_arr_Outer_std140_uint_4 + %199 = OpConstantNull %_arr_Outer_std140_uint_4 %_ptr_Function_Outer_std140_tint_explicit_layout = OpTypePointer Function %Outer_std140_tint_explicit_layout %i = OpFunction %int None %17 %18 = OpLabel %19 = OpLoad %int %counter None - %20 = OpIAdd %int %19 %int_1 - OpStore %counter %20 None - %22 = OpLoad %int %counter None - OpReturnValue %22 + %20 = OpBitcast %uint %19 + %21 = OpBitcast %uint %int_1 + %23 = OpIAdd %uint %20 %21 + %24 = OpBitcast %int %23 + OpStore %counter %24 None + %25 = OpLoad %int %counter None + OpReturnValue %25 OpFunctionEnd - %f = OpFunction %void None %25 - %26 = OpLabel - %55 = OpVariable %_ptr_Function_mat3v3half Function - %69 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function - %71 = OpVariable %_ptr_Function__arr_Outer_uint_4 Function %77 - %94 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function - %96 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %98 - %27 = OpAccessChain %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 %1 %uint_0 - %30 = OpFunctionCall %int %i - %31 = OpBitcast %uint %30 - %32 = OpExtInst %uint %33 UMin %31 %uint_3 - %35 = OpAccessChain %_ptr_Uniform_Outer_std140_tint_explicit_layout %27 %32 - %37 = OpAccessChain %_ptr_Uniform__arr_Inner_std140_uint_4 %35 %uint_0 - %39 = OpFunctionCall %int %i - %40 = OpBitcast %uint %39 - %41 = OpExtInst %uint %33 UMin %40 %uint_3 - %42 = OpAccessChain %_ptr_Uniform_Inner_std140 %37 %41 - %44 = OpAccessChain %_ptr_Uniform_v3half %42 %uint_0 - %46 = OpLoad %v3half %44 None - %47 = OpAccessChain %_ptr_Uniform_v3half %42 %uint_1 + %f = OpFunction %void None %28 + %29 = OpLabel + %58 = OpVariable %_ptr_Function_mat3v3half Function + %72 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function + %74 = OpVariable %_ptr_Function__arr_Outer_uint_4 Function %80 + %97 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function + %99 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %101 + %30 = OpAccessChain %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 %1 %uint_0 + %33 = OpFunctionCall %int %i + %34 = OpBitcast %uint %33 + %35 = OpExtInst %uint %36 UMin %34 %uint_3 + %38 = OpAccessChain %_ptr_Uniform_Outer_std140_tint_explicit_layout %30 %35 + %40 = OpAccessChain %_ptr_Uniform__arr_Inner_std140_uint_4 %38 %uint_0 + %42 = OpFunctionCall %int %i + %43 = OpBitcast %uint %42 + %44 = OpExtInst %uint %36 UMin %43 %uint_3 + %45 = OpAccessChain %_ptr_Uniform_Inner_std140 %40 %44 + %47 = OpAccessChain %_ptr_Uniform_v3half %45 %uint_0 %49 = OpLoad %v3half %47 None - %50 = OpAccessChain %_ptr_Uniform_v3half %42 %uint_2 + %50 = OpAccessChain %_ptr_Uniform_v3half %45 %uint_1 %52 = OpLoad %v3half %50 None -%l_a_i_a_i_m = OpCompositeConstruct %mat3v3half %46 %49 %52 - OpStore %55 %l_a_i_a_i_m - %57 = OpFunctionCall %int %i - %58 = OpBitcast %uint %57 - %59 = OpExtInst %uint %33 UMin %58 %uint_2 - %60 = OpAccessChain %_ptr_Function_v3half %55 %59 -%l_a_i_a_i_m_i = OpLoad %v3half %60 None - %63 = OpLoad %_arr_Outer_std140_tint_explicit_layout_uint_4 %27 None - %64 = OpFunctionCall %_arr_Outer_std140_uint_4 %tint_convert_explicit_layout_1 %63 - OpStore %69 %64 - OpBranch %78 - %78 = OpLabel + %53 = OpAccessChain %_ptr_Uniform_v3half %45 %uint_2 + %55 = OpLoad %v3half %53 None +%l_a_i_a_i_m = OpCompositeConstruct %mat3v3half %49 %52 %55 + OpStore %58 %l_a_i_a_i_m + %60 = OpFunctionCall %int %i + %61 = OpBitcast %uint %60 + %62 = OpExtInst %uint %36 UMin %61 %uint_2 + %63 = OpAccessChain %_ptr_Function_v3half %58 %62 +%l_a_i_a_i_m_i = OpLoad %v3half %63 None + %66 = OpLoad %_arr_Outer_std140_tint_explicit_layout_uint_4 %30 None + %67 = OpFunctionCall %_arr_Outer_std140_uint_4 %tint_convert_explicit_layout_1 %66 + OpStore %72 %67 OpBranch %81 %81 = OpLabel - %83 = OpPhi %uint %uint_0 %78 %84 %80 - OpLoopMerge %82 %80 None - OpBranch %79 - %79 = OpLabel - %114 = OpUGreaterThanEqual %bool %83 %uint_4 - OpSelectionMerge %116 None - OpBranchConditional %114 %117 %116 - %117 = OpLabel + OpBranch %84 + %84 = OpLabel + %86 = OpPhi %uint %uint_0 %81 %87 %83 + OpLoopMerge %85 %83 None OpBranch %82 - %116 = OpLabel - %118 = OpAccessChain %_ptr_Function_Outer %71 %83 - %120 = OpAccessChain %_ptr_Function_Outer_std140 %69 %83 - %122 = OpLoad %Outer_std140 %120 None - %123 = OpFunctionCall %Outer %tint_convert_Outer %122 - OpStore %118 %123 None - OpBranch %80 - %80 = OpLabel - %84 = OpIAdd %uint %83 %uint_1 - OpBranch %81 %82 = OpLabel - %l_a = OpLoad %_arr_Outer_uint_4 %71 None - %86 = OpLoad %Outer_std140_tint_explicit_layout %35 None - %87 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %86 - %l_a_i = OpFunctionCall %Outer %tint_convert_Outer %87 - %91 = OpLoad %_arr_Inner_std140_uint_4 %37 None - %92 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %91 - OpStore %94 %92 - OpBranch %99 - %99 = OpLabel + %117 = OpUGreaterThanEqual %bool %86 %uint_4 + OpSelectionMerge %119 None + OpBranchConditional %117 %120 %119 + %120 = OpLabel + OpBranch %85 + %119 = OpLabel + %121 = OpAccessChain %_ptr_Function_Outer %74 %86 + %123 = OpAccessChain %_ptr_Function_Outer_std140 %72 %86 + %125 = OpLoad %Outer_std140 %123 None + %126 = OpFunctionCall %Outer %tint_convert_Outer %125 + OpStore %121 %126 None + OpBranch %83 + %83 = OpLabel + %87 = OpIAdd %uint %86 %uint_1 + OpBranch %84 + %85 = OpLabel + %l_a = OpLoad %_arr_Outer_uint_4 %74 None + %89 = OpLoad %Outer_std140_tint_explicit_layout %38 None + %90 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %89 + %l_a_i = OpFunctionCall %Outer %tint_convert_Outer %90 + %94 = OpLoad %_arr_Inner_std140_uint_4 %40 None + %95 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %94 + OpStore %97 %95 OpBranch %102 %102 = OpLabel - %104 = OpPhi %uint %uint_0 %99 %105 %101 - OpLoopMerge %103 %101 None - OpBranch %100 - %100 = OpLabel - %124 = OpUGreaterThanEqual %bool %104 %uint_4 - OpSelectionMerge %125 None - OpBranchConditional %124 %126 %125 - %126 = OpLabel + OpBranch %105 + %105 = OpLabel + %107 = OpPhi %uint %uint_0 %102 %108 %104 + OpLoopMerge %106 %104 None OpBranch %103 - %125 = OpLabel - %127 = OpAccessChain %_ptr_Function_Inner %96 %104 - %129 = OpAccessChain %_ptr_Function_Inner_std140 %94 %104 - %131 = OpLoad %Inner_std140 %129 None - %132 = OpFunctionCall %Inner %tint_convert_Inner %131 - OpStore %127 %132 None - OpBranch %101 - %101 = OpLabel - %105 = OpIAdd %uint %104 %uint_1 - OpBranch %102 %103 = OpLabel - %l_a_i_a = OpLoad %_arr_Inner_uint_4 %96 None - %107 = OpLoad %Inner_std140 %42 None - %l_a_i_a_i = OpFunctionCall %Inner %tint_convert_Inner %107 - %110 = OpFunctionCall %int %i - %111 = OpBitcast %uint %110 - %112 = OpExtInst %uint %33 UMin %111 %uint_2 -%l_a_i_a_i_m_i_i = OpVectorExtractDynamic %half %l_a_i_a_i_m_i %112 + %127 = OpUGreaterThanEqual %bool %107 %uint_4 + OpSelectionMerge %128 None + OpBranchConditional %127 %129 %128 + %129 = OpLabel + OpBranch %106 + %128 = OpLabel + %130 = OpAccessChain %_ptr_Function_Inner %99 %107 + %132 = OpAccessChain %_ptr_Function_Inner_std140 %97 %107 + %134 = OpLoad %Inner_std140 %132 None + %135 = OpFunctionCall %Inner %tint_convert_Inner %134 + OpStore %130 %135 None + OpBranch %104 + %104 = OpLabel + %108 = OpIAdd %uint %107 %uint_1 + OpBranch %105 + %106 = OpLabel + %l_a_i_a = OpLoad %_arr_Inner_uint_4 %99 None + %110 = OpLoad %Inner_std140 %45 None + %l_a_i_a_i = OpFunctionCall %Inner %tint_convert_Inner %110 + %113 = OpFunctionCall %int %i + %114 = OpBitcast %uint %113 + %115 = OpExtInst %uint %36 UMin %114 %uint_2 +%l_a_i_a_i_m_i_i = OpVectorExtractDynamic %half %l_a_i_a_i_m_i %115 OpReturn OpFunctionEnd -%tint_convert_Inner = OpFunction %Inner None %134 +%tint_convert_Inner = OpFunction %Inner None %137 %tint_input = OpFunctionParameter %Inner_std140 - %135 = OpLabel - %136 = OpCompositeExtract %v3half %tint_input 0 - %137 = OpCompositeExtract %v3half %tint_input 1 - %138 = OpCompositeExtract %v3half %tint_input 2 - %139 = OpCompositeConstruct %mat3v3half %136 %137 %138 - %140 = OpCompositeConstruct %Inner %139 - OpReturnValue %140 + %138 = OpLabel + %139 = OpCompositeExtract %v3half %tint_input 0 + %140 = OpCompositeExtract %v3half %tint_input 1 + %141 = OpCompositeExtract %v3half %tint_input 2 + %142 = OpCompositeConstruct %mat3v3half %139 %140 %141 + %143 = OpCompositeConstruct %Inner %142 + OpReturnValue %143 OpFunctionEnd -%tint_convert_Outer = OpFunction %Outer None %142 +%tint_convert_Outer = OpFunction %Outer None %145 %tint_input_0 = OpFunctionParameter %Outer_std140 - %143 = OpLabel - %145 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function - %146 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %98 - %144 = OpCompositeExtract %_arr_Inner_std140_uint_4_0 %tint_input_0 0 - OpStore %145 %144 - OpBranch %147 - %147 = OpLabel + %146 = OpLabel + %148 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function + %149 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %101 + %147 = OpCompositeExtract %_arr_Inner_std140_uint_4_0 %tint_input_0 0 + OpStore %148 %147 OpBranch %150 %150 = OpLabel - %152 = OpPhi %uint %uint_0 %147 %153 %149 - OpLoopMerge %151 %149 None - OpBranch %148 - %148 = OpLabel - %156 = OpUGreaterThanEqual %bool %152 %uint_4 - OpSelectionMerge %157 None - OpBranchConditional %156 %158 %157 - %158 = OpLabel + OpBranch %153 + %153 = OpLabel + %155 = OpPhi %uint %uint_0 %150 %156 %152 + OpLoopMerge %154 %152 None OpBranch %151 - %157 = OpLabel - %159 = OpAccessChain %_ptr_Function_Inner %146 %152 - %160 = OpAccessChain %_ptr_Function_Inner_std140 %145 %152 - %161 = OpLoad %Inner_std140 %160 None - %162 = OpFunctionCall %Inner %tint_convert_Inner %161 - OpStore %159 %162 None - OpBranch %149 - %149 = OpLabel - %153 = OpIAdd %uint %152 %uint_1 - OpBranch %150 %151 = OpLabel - %154 = OpLoad %_arr_Inner_uint_4 %146 None - %155 = OpCompositeConstruct %Outer %154 - OpReturnValue %155 + %159 = OpUGreaterThanEqual %bool %155 %uint_4 + OpSelectionMerge %160 None + OpBranchConditional %159 %161 %160 + %161 = OpLabel + OpBranch %154 + %160 = OpLabel + %162 = OpAccessChain %_ptr_Function_Inner %149 %155 + %163 = OpAccessChain %_ptr_Function_Inner_std140 %148 %155 + %164 = OpLoad %Inner_std140 %163 None + %165 = OpFunctionCall %Inner %tint_convert_Inner %164 + OpStore %162 %165 None + OpBranch %152 + %152 = OpLabel + %156 = OpIAdd %uint %155 %uint_1 + OpBranch %153 + %154 = OpLabel + %157 = OpLoad %_arr_Inner_uint_4 %149 None + %158 = OpCompositeConstruct %Outer %157 + OpReturnValue %158 OpFunctionEnd -%tint_convert_explicit_layout = OpFunction %_arr_Inner_std140_uint_4_0 None %164 +%tint_convert_explicit_layout = OpFunction %_arr_Inner_std140_uint_4_0 None %167 %tint_source = OpFunctionParameter %_arr_Inner_std140_uint_4 - %165 = OpLabel - %166 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4 Function - %168 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function %169 - OpStore %166 %tint_source - OpBranch %170 - %170 = OpLabel + %168 = OpLabel + %169 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4 Function + %171 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function %172 + OpStore %169 %tint_source OpBranch %173 %173 = OpLabel - %175 = OpPhi %uint %uint_0 %170 %176 %172 - OpLoopMerge %174 %172 None - OpBranch %171 - %171 = OpLabel - %178 = OpUGreaterThanEqual %bool %175 %uint_4 - OpSelectionMerge %179 None - OpBranchConditional %178 %180 %179 - %180 = OpLabel + OpBranch %176 + %176 = OpLabel + %178 = OpPhi %uint %uint_0 %173 %179 %175 + OpLoopMerge %177 %175 None OpBranch %174 - %179 = OpLabel - %181 = OpAccessChain %_ptr_Function_Inner_std140 %166 %175 - %182 = OpLoad %Inner_std140 %181 None - %183 = OpAccessChain %_ptr_Function_Inner_std140 %168 %175 - OpStore %183 %182 None - OpBranch %172 - %172 = OpLabel - %176 = OpIAdd %uint %175 %uint_1 - OpBranch %173 %174 = OpLabel - %177 = OpLoad %_arr_Inner_std140_uint_4_0 %168 None - OpReturnValue %177 + %181 = OpUGreaterThanEqual %bool %178 %uint_4 + OpSelectionMerge %182 None + OpBranchConditional %181 %183 %182 + %183 = OpLabel + OpBranch %177 + %182 = OpLabel + %184 = OpAccessChain %_ptr_Function_Inner_std140 %169 %178 + %185 = OpLoad %Inner_std140 %184 None + %186 = OpAccessChain %_ptr_Function_Inner_std140 %171 %178 + OpStore %186 %185 None + OpBranch %175 + %175 = OpLabel + %179 = OpIAdd %uint %178 %uint_1 + OpBranch %176 + %177 = OpLabel + %180 = OpLoad %_arr_Inner_std140_uint_4_0 %171 None + OpReturnValue %180 OpFunctionEnd -%tint_convert_explicit_layout_0 = OpFunction %Outer_std140 None %185 +%tint_convert_explicit_layout_0 = OpFunction %Outer_std140 None %188 %tint_source_0 = OpFunctionParameter %Outer_std140_tint_explicit_layout - %186 = OpLabel - %187 = OpCompositeExtract %_arr_Inner_std140_uint_4 %tint_source_0 0 - %188 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %187 - %189 = OpCompositeConstruct %Outer_std140 %188 - OpReturnValue %189 + %189 = OpLabel + %190 = OpCompositeExtract %_arr_Inner_std140_uint_4 %tint_source_0 0 + %191 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %190 + %192 = OpCompositeConstruct %Outer_std140 %191 + OpReturnValue %192 OpFunctionEnd -%tint_convert_explicit_layout_1 = OpFunction %_arr_Outer_std140_uint_4 None %191 +%tint_convert_explicit_layout_1 = OpFunction %_arr_Outer_std140_uint_4 None %194 %tint_source_1 = OpFunctionParameter %_arr_Outer_std140_tint_explicit_layout_uint_4 - %192 = OpLabel - %193 = OpVariable %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 Function - %195 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function %196 - OpStore %193 %tint_source_1 - OpBranch %197 - %197 = OpLabel + %195 = OpLabel + %196 = OpVariable %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 Function + %198 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function %199 + OpStore %196 %tint_source_1 OpBranch %200 %200 = OpLabel - %202 = OpPhi %uint %uint_0 %197 %203 %199 - OpLoopMerge %201 %199 None - OpBranch %198 - %198 = OpLabel - %205 = OpUGreaterThanEqual %bool %202 %uint_4 - OpSelectionMerge %206 None - OpBranchConditional %205 %207 %206 - %207 = OpLabel + OpBranch %203 + %203 = OpLabel + %205 = OpPhi %uint %uint_0 %200 %206 %202 + OpLoopMerge %204 %202 None OpBranch %201 - %206 = OpLabel - %208 = OpAccessChain %_ptr_Function_Outer_std140_tint_explicit_layout %193 %202 - %210 = OpLoad %Outer_std140_tint_explicit_layout %208 None - %211 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %210 - %212 = OpAccessChain %_ptr_Function_Outer_std140 %195 %202 - OpStore %212 %211 None - OpBranch %199 - %199 = OpLabel - %203 = OpIAdd %uint %202 %uint_1 - OpBranch %200 %201 = OpLabel - %204 = OpLoad %_arr_Outer_std140_uint_4 %195 None - OpReturnValue %204 + %208 = OpUGreaterThanEqual %bool %205 %uint_4 + OpSelectionMerge %209 None + OpBranchConditional %208 %210 %209 + %210 = OpLabel + OpBranch %204 + %209 = OpLabel + %211 = OpAccessChain %_ptr_Function_Outer_std140_tint_explicit_layout %196 %205 + %213 = OpLoad %Outer_std140_tint_explicit_layout %211 None + %214 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %213 + %215 = OpAccessChain %_ptr_Function_Outer_std140 %198 %205 + OpStore %215 %214 None + OpBranch %202 + %202 = OpLabel + %206 = OpIAdd %uint %205 %uint_1 + OpBranch %203 + %204 = OpLabel + %207 = OpLoad %_arr_Outer_std140_uint_4 %198 None + OpReturnValue %207 OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/struct/mat3x3_f32/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/struct/mat3x3_f32/dynamic_index_via_ptr.wgsl.expected.glsl index 5f74eac..badd378 100644 --- a/test/tint/buffer/uniform/std140/struct/mat3x3_f32/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/struct/mat3x3_f32/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -32,76 +32,77 @@ } v; int counter = 0; int i() { - counter = (counter + 1); + uint v_1 = uint(counter); + counter = int((v_1 + uint(1))); return counter; } Inner tint_convert_Inner(Inner_std140 tint_input) { return Inner(mat3(tint_input.m_col0, tint_input.m_col1, tint_input.m_col2)); } Outer tint_convert_Outer(Outer_std140 tint_input) { - Inner v_1[4] = Inner[4](Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f)))); + Inner v_2[4] = Inner[4](Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f)))); { - uint v_2 = 0u; - v_2 = 0u; + uint v_3 = 0u; + v_3 = 0u; while(true) { - uint v_3 = v_2; - if ((v_3 >= 4u)) { + uint v_4 = v_3; + if ((v_4 >= 4u)) { break; } - v_1[v_3] = tint_convert_Inner(tint_input.a[v_3]); + v_2[v_4] = tint_convert_Inner(tint_input.a[v_4]); { - v_2 = (v_3 + 1u); + v_3 = (v_4 + 1u); } continue; } } - return Outer(v_1); + return Outer(v_2); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - uint v_4 = min(uint(i()), 3u); uint v_5 = min(uint(i()), 3u); - mat3 v_6 = mat3(v.inner[v_4].a[v_5].m_col0, v.inner[v_4].a[v_5].m_col1, v.inner[v_4].a[v_5].m_col2); - vec3 v_7 = v_6[min(uint(i()), 2u)]; - Outer_std140 v_8[4] = v.inner; - Outer v_9[4] = Outer[4](Outer(Inner[4](Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))))), Outer(Inner[4](Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))))), Outer(Inner[4](Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))))), Outer(Inner[4](Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f)))))); + uint v_6 = min(uint(i()), 3u); + mat3 v_7 = mat3(v.inner[v_5].a[v_6].m_col0, v.inner[v_5].a[v_6].m_col1, v.inner[v_5].a[v_6].m_col2); + vec3 v_8 = v_7[min(uint(i()), 2u)]; + Outer_std140 v_9[4] = v.inner; + Outer v_10[4] = Outer[4](Outer(Inner[4](Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))))), Outer(Inner[4](Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))))), Outer(Inner[4](Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))))), Outer(Inner[4](Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f)))))); { - uint v_10 = 0u; - v_10 = 0u; + uint v_11 = 0u; + v_11 = 0u; while(true) { - uint v_11 = v_10; - if ((v_11 >= 4u)) { + uint v_12 = v_11; + if ((v_12 >= 4u)) { break; } - v_9[v_11] = tint_convert_Outer(v_8[v_11]); + v_10[v_12] = tint_convert_Outer(v_9[v_12]); { - v_10 = (v_11 + 1u); + v_11 = (v_12 + 1u); } continue; } } - Outer l_a[4] = v_9; - Outer l_a_i = tint_convert_Outer(v.inner[v_4]); - Inner_std140 v_12[4] = v.inner[v_4].a; - Inner v_13[4] = Inner[4](Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f)))); + Outer l_a[4] = v_10; + Outer l_a_i = tint_convert_Outer(v.inner[v_5]); + Inner_std140 v_13[4] = v.inner[v_5].a; + Inner v_14[4] = Inner[4](Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat3(vec3(0.0f), vec3(0.0f), vec3(0.0f)))); { - uint v_14 = 0u; - v_14 = 0u; + uint v_15 = 0u; + v_15 = 0u; while(true) { - uint v_15 = v_14; - if ((v_15 >= 4u)) { + uint v_16 = v_15; + if ((v_16 >= 4u)) { break; } - v_13[v_15] = tint_convert_Inner(v_12[v_15]); + v_14[v_16] = tint_convert_Inner(v_13[v_16]); { - v_14 = (v_15 + 1u); + v_15 = (v_16 + 1u); } continue; } } - Inner l_a_i_a[4] = v_13; - Inner l_a_i_a_i = tint_convert_Inner(v.inner[v_4].a[v_5]); - mat3 l_a_i_a_i_m = v_6; - vec3 l_a_i_a_i_m_i = v_7; - float l_a_i_a_i_m_i_i = v_7[min(uint(i()), 2u)]; + Inner l_a_i_a[4] = v_14; + Inner l_a_i_a_i = tint_convert_Inner(v.inner[v_5].a[v_6]); + mat3 l_a_i_a_i_m = v_7; + vec3 l_a_i_a_i_m_i = v_8; + float l_a_i_a_i_m_i_i = v_8[min(uint(i()), 2u)]; }
diff --git a/test/tint/buffer/uniform/std140/struct/mat3x3_f32/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/struct/mat3x3_f32/dynamic_index_via_ptr.wgsl.expected.spvasm index d0b6737..c1fd798 100644 --- a/test/tint/buffer/uniform/std140/struct/mat3x3_f32/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/struct/mat3x3_f32/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,10 +1,10 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 213 +; Bound: 216 ; Schema: 0 OpCapability Shader - %33 = OpExtInstImport "GLSL.std.450" + %36 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -71,7 +71,7 @@ %17 = OpTypeFunction %int %int_1 = OpConstant %int 1 %void = OpTypeVoid - %25 = OpTypeFunction %void + %28 = OpTypeFunction %void %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 = OpTypePointer Uniform %_arr_Outer_std140_tint_explicit_layout_uint_4 %uint_0 = OpConstant %uint 0 %uint_3 = OpConstant %uint 3 @@ -93,245 +93,248 @@ %Outer = OpTypeStruct %_arr_Inner_uint_4 %_arr_Outer_uint_4 = OpTypeArray %Outer %uint_4 %_ptr_Function__arr_Outer_uint_4 = OpTypePointer Function %_arr_Outer_uint_4 - %77 = OpConstantNull %_arr_Outer_uint_4 + %80 = OpConstantNull %_arr_Outer_uint_4 %_ptr_Function__arr_Inner_std140_uint_4_0 = OpTypePointer Function %_arr_Inner_std140_uint_4_0 %_ptr_Function__arr_Inner_uint_4 = OpTypePointer Function %_arr_Inner_uint_4 - %98 = OpConstantNull %_arr_Inner_uint_4 + %101 = OpConstantNull %_arr_Inner_uint_4 %bool = OpTypeBool %_ptr_Function_Outer = OpTypePointer Function %Outer %_ptr_Function_Outer_std140 = OpTypePointer Function %Outer_std140 %_ptr_Function_Inner = OpTypePointer Function %Inner %_ptr_Function_Inner_std140 = OpTypePointer Function %Inner_std140 - %134 = OpTypeFunction %Inner %Inner_std140 - %142 = OpTypeFunction %Outer %Outer_std140 - %164 = OpTypeFunction %_arr_Inner_std140_uint_4_0 %_arr_Inner_std140_uint_4 + %137 = OpTypeFunction %Inner %Inner_std140 + %145 = OpTypeFunction %Outer %Outer_std140 + %167 = OpTypeFunction %_arr_Inner_std140_uint_4_0 %_arr_Inner_std140_uint_4 %_ptr_Function__arr_Inner_std140_uint_4 = OpTypePointer Function %_arr_Inner_std140_uint_4 - %169 = OpConstantNull %_arr_Inner_std140_uint_4_0 - %185 = OpTypeFunction %Outer_std140 %Outer_std140_tint_explicit_layout - %191 = OpTypeFunction %_arr_Outer_std140_uint_4 %_arr_Outer_std140_tint_explicit_layout_uint_4 + %172 = OpConstantNull %_arr_Inner_std140_uint_4_0 + %188 = OpTypeFunction %Outer_std140 %Outer_std140_tint_explicit_layout + %194 = OpTypeFunction %_arr_Outer_std140_uint_4 %_arr_Outer_std140_tint_explicit_layout_uint_4 %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 = OpTypePointer Function %_arr_Outer_std140_tint_explicit_layout_uint_4 - %196 = OpConstantNull %_arr_Outer_std140_uint_4 + %199 = OpConstantNull %_arr_Outer_std140_uint_4 %_ptr_Function_Outer_std140_tint_explicit_layout = OpTypePointer Function %Outer_std140_tint_explicit_layout %i = OpFunction %int None %17 %18 = OpLabel %19 = OpLoad %int %counter None - %20 = OpIAdd %int %19 %int_1 - OpStore %counter %20 None - %22 = OpLoad %int %counter None - OpReturnValue %22 + %20 = OpBitcast %uint %19 + %21 = OpBitcast %uint %int_1 + %23 = OpIAdd %uint %20 %21 + %24 = OpBitcast %int %23 + OpStore %counter %24 None + %25 = OpLoad %int %counter None + OpReturnValue %25 OpFunctionEnd - %f = OpFunction %void None %25 - %26 = OpLabel - %55 = OpVariable %_ptr_Function_mat3v3float Function - %69 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function - %71 = OpVariable %_ptr_Function__arr_Outer_uint_4 Function %77 - %94 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function - %96 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %98 - %27 = OpAccessChain %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 %1 %uint_0 - %30 = OpFunctionCall %int %i - %31 = OpBitcast %uint %30 - %32 = OpExtInst %uint %33 UMin %31 %uint_3 - %35 = OpAccessChain %_ptr_Uniform_Outer_std140_tint_explicit_layout %27 %32 - %37 = OpAccessChain %_ptr_Uniform__arr_Inner_std140_uint_4 %35 %uint_0 - %39 = OpFunctionCall %int %i - %40 = OpBitcast %uint %39 - %41 = OpExtInst %uint %33 UMin %40 %uint_3 - %42 = OpAccessChain %_ptr_Uniform_Inner_std140 %37 %41 - %44 = OpAccessChain %_ptr_Uniform_v3float %42 %uint_0 - %46 = OpLoad %v3float %44 None - %47 = OpAccessChain %_ptr_Uniform_v3float %42 %uint_1 + %f = OpFunction %void None %28 + %29 = OpLabel + %58 = OpVariable %_ptr_Function_mat3v3float Function + %72 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function + %74 = OpVariable %_ptr_Function__arr_Outer_uint_4 Function %80 + %97 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function + %99 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %101 + %30 = OpAccessChain %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 %1 %uint_0 + %33 = OpFunctionCall %int %i + %34 = OpBitcast %uint %33 + %35 = OpExtInst %uint %36 UMin %34 %uint_3 + %38 = OpAccessChain %_ptr_Uniform_Outer_std140_tint_explicit_layout %30 %35 + %40 = OpAccessChain %_ptr_Uniform__arr_Inner_std140_uint_4 %38 %uint_0 + %42 = OpFunctionCall %int %i + %43 = OpBitcast %uint %42 + %44 = OpExtInst %uint %36 UMin %43 %uint_3 + %45 = OpAccessChain %_ptr_Uniform_Inner_std140 %40 %44 + %47 = OpAccessChain %_ptr_Uniform_v3float %45 %uint_0 %49 = OpLoad %v3float %47 None - %50 = OpAccessChain %_ptr_Uniform_v3float %42 %uint_2 + %50 = OpAccessChain %_ptr_Uniform_v3float %45 %uint_1 %52 = OpLoad %v3float %50 None -%l_a_i_a_i_m = OpCompositeConstruct %mat3v3float %46 %49 %52 - OpStore %55 %l_a_i_a_i_m - %57 = OpFunctionCall %int %i - %58 = OpBitcast %uint %57 - %59 = OpExtInst %uint %33 UMin %58 %uint_2 - %60 = OpAccessChain %_ptr_Function_v3float %55 %59 -%l_a_i_a_i_m_i = OpLoad %v3float %60 None - %63 = OpLoad %_arr_Outer_std140_tint_explicit_layout_uint_4 %27 None - %64 = OpFunctionCall %_arr_Outer_std140_uint_4 %tint_convert_explicit_layout_1 %63 - OpStore %69 %64 - OpBranch %78 - %78 = OpLabel + %53 = OpAccessChain %_ptr_Uniform_v3float %45 %uint_2 + %55 = OpLoad %v3float %53 None +%l_a_i_a_i_m = OpCompositeConstruct %mat3v3float %49 %52 %55 + OpStore %58 %l_a_i_a_i_m + %60 = OpFunctionCall %int %i + %61 = OpBitcast %uint %60 + %62 = OpExtInst %uint %36 UMin %61 %uint_2 + %63 = OpAccessChain %_ptr_Function_v3float %58 %62 +%l_a_i_a_i_m_i = OpLoad %v3float %63 None + %66 = OpLoad %_arr_Outer_std140_tint_explicit_layout_uint_4 %30 None + %67 = OpFunctionCall %_arr_Outer_std140_uint_4 %tint_convert_explicit_layout_1 %66 + OpStore %72 %67 OpBranch %81 %81 = OpLabel - %83 = OpPhi %uint %uint_0 %78 %84 %80 - OpLoopMerge %82 %80 None - OpBranch %79 - %79 = OpLabel - %114 = OpUGreaterThanEqual %bool %83 %uint_4 - OpSelectionMerge %116 None - OpBranchConditional %114 %117 %116 - %117 = OpLabel + OpBranch %84 + %84 = OpLabel + %86 = OpPhi %uint %uint_0 %81 %87 %83 + OpLoopMerge %85 %83 None OpBranch %82 - %116 = OpLabel - %118 = OpAccessChain %_ptr_Function_Outer %71 %83 - %120 = OpAccessChain %_ptr_Function_Outer_std140 %69 %83 - %122 = OpLoad %Outer_std140 %120 None - %123 = OpFunctionCall %Outer %tint_convert_Outer %122 - OpStore %118 %123 None - OpBranch %80 - %80 = OpLabel - %84 = OpIAdd %uint %83 %uint_1 - OpBranch %81 %82 = OpLabel - %l_a = OpLoad %_arr_Outer_uint_4 %71 None - %86 = OpLoad %Outer_std140_tint_explicit_layout %35 None - %87 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %86 - %l_a_i = OpFunctionCall %Outer %tint_convert_Outer %87 - %91 = OpLoad %_arr_Inner_std140_uint_4 %37 None - %92 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %91 - OpStore %94 %92 - OpBranch %99 - %99 = OpLabel + %117 = OpUGreaterThanEqual %bool %86 %uint_4 + OpSelectionMerge %119 None + OpBranchConditional %117 %120 %119 + %120 = OpLabel + OpBranch %85 + %119 = OpLabel + %121 = OpAccessChain %_ptr_Function_Outer %74 %86 + %123 = OpAccessChain %_ptr_Function_Outer_std140 %72 %86 + %125 = OpLoad %Outer_std140 %123 None + %126 = OpFunctionCall %Outer %tint_convert_Outer %125 + OpStore %121 %126 None + OpBranch %83 + %83 = OpLabel + %87 = OpIAdd %uint %86 %uint_1 + OpBranch %84 + %85 = OpLabel + %l_a = OpLoad %_arr_Outer_uint_4 %74 None + %89 = OpLoad %Outer_std140_tint_explicit_layout %38 None + %90 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %89 + %l_a_i = OpFunctionCall %Outer %tint_convert_Outer %90 + %94 = OpLoad %_arr_Inner_std140_uint_4 %40 None + %95 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %94 + OpStore %97 %95 OpBranch %102 %102 = OpLabel - %104 = OpPhi %uint %uint_0 %99 %105 %101 - OpLoopMerge %103 %101 None - OpBranch %100 - %100 = OpLabel - %124 = OpUGreaterThanEqual %bool %104 %uint_4 - OpSelectionMerge %125 None - OpBranchConditional %124 %126 %125 - %126 = OpLabel + OpBranch %105 + %105 = OpLabel + %107 = OpPhi %uint %uint_0 %102 %108 %104 + OpLoopMerge %106 %104 None OpBranch %103 - %125 = OpLabel - %127 = OpAccessChain %_ptr_Function_Inner %96 %104 - %129 = OpAccessChain %_ptr_Function_Inner_std140 %94 %104 - %131 = OpLoad %Inner_std140 %129 None - %132 = OpFunctionCall %Inner %tint_convert_Inner %131 - OpStore %127 %132 None - OpBranch %101 - %101 = OpLabel - %105 = OpIAdd %uint %104 %uint_1 - OpBranch %102 %103 = OpLabel - %l_a_i_a = OpLoad %_arr_Inner_uint_4 %96 None - %107 = OpLoad %Inner_std140 %42 None - %l_a_i_a_i = OpFunctionCall %Inner %tint_convert_Inner %107 - %110 = OpFunctionCall %int %i - %111 = OpBitcast %uint %110 - %112 = OpExtInst %uint %33 UMin %111 %uint_2 -%l_a_i_a_i_m_i_i = OpVectorExtractDynamic %float %l_a_i_a_i_m_i %112 + %127 = OpUGreaterThanEqual %bool %107 %uint_4 + OpSelectionMerge %128 None + OpBranchConditional %127 %129 %128 + %129 = OpLabel + OpBranch %106 + %128 = OpLabel + %130 = OpAccessChain %_ptr_Function_Inner %99 %107 + %132 = OpAccessChain %_ptr_Function_Inner_std140 %97 %107 + %134 = OpLoad %Inner_std140 %132 None + %135 = OpFunctionCall %Inner %tint_convert_Inner %134 + OpStore %130 %135 None + OpBranch %104 + %104 = OpLabel + %108 = OpIAdd %uint %107 %uint_1 + OpBranch %105 + %106 = OpLabel + %l_a_i_a = OpLoad %_arr_Inner_uint_4 %99 None + %110 = OpLoad %Inner_std140 %45 None + %l_a_i_a_i = OpFunctionCall %Inner %tint_convert_Inner %110 + %113 = OpFunctionCall %int %i + %114 = OpBitcast %uint %113 + %115 = OpExtInst %uint %36 UMin %114 %uint_2 +%l_a_i_a_i_m_i_i = OpVectorExtractDynamic %float %l_a_i_a_i_m_i %115 OpReturn OpFunctionEnd -%tint_convert_Inner = OpFunction %Inner None %134 +%tint_convert_Inner = OpFunction %Inner None %137 %tint_input = OpFunctionParameter %Inner_std140 - %135 = OpLabel - %136 = OpCompositeExtract %v3float %tint_input 0 - %137 = OpCompositeExtract %v3float %tint_input 1 - %138 = OpCompositeExtract %v3float %tint_input 2 - %139 = OpCompositeConstruct %mat3v3float %136 %137 %138 - %140 = OpCompositeConstruct %Inner %139 - OpReturnValue %140 + %138 = OpLabel + %139 = OpCompositeExtract %v3float %tint_input 0 + %140 = OpCompositeExtract %v3float %tint_input 1 + %141 = OpCompositeExtract %v3float %tint_input 2 + %142 = OpCompositeConstruct %mat3v3float %139 %140 %141 + %143 = OpCompositeConstruct %Inner %142 + OpReturnValue %143 OpFunctionEnd -%tint_convert_Outer = OpFunction %Outer None %142 +%tint_convert_Outer = OpFunction %Outer None %145 %tint_input_0 = OpFunctionParameter %Outer_std140 - %143 = OpLabel - %145 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function - %146 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %98 - %144 = OpCompositeExtract %_arr_Inner_std140_uint_4_0 %tint_input_0 0 - OpStore %145 %144 - OpBranch %147 - %147 = OpLabel + %146 = OpLabel + %148 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function + %149 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %101 + %147 = OpCompositeExtract %_arr_Inner_std140_uint_4_0 %tint_input_0 0 + OpStore %148 %147 OpBranch %150 %150 = OpLabel - %152 = OpPhi %uint %uint_0 %147 %153 %149 - OpLoopMerge %151 %149 None - OpBranch %148 - %148 = OpLabel - %156 = OpUGreaterThanEqual %bool %152 %uint_4 - OpSelectionMerge %157 None - OpBranchConditional %156 %158 %157 - %158 = OpLabel + OpBranch %153 + %153 = OpLabel + %155 = OpPhi %uint %uint_0 %150 %156 %152 + OpLoopMerge %154 %152 None OpBranch %151 - %157 = OpLabel - %159 = OpAccessChain %_ptr_Function_Inner %146 %152 - %160 = OpAccessChain %_ptr_Function_Inner_std140 %145 %152 - %161 = OpLoad %Inner_std140 %160 None - %162 = OpFunctionCall %Inner %tint_convert_Inner %161 - OpStore %159 %162 None - OpBranch %149 - %149 = OpLabel - %153 = OpIAdd %uint %152 %uint_1 - OpBranch %150 %151 = OpLabel - %154 = OpLoad %_arr_Inner_uint_4 %146 None - %155 = OpCompositeConstruct %Outer %154 - OpReturnValue %155 + %159 = OpUGreaterThanEqual %bool %155 %uint_4 + OpSelectionMerge %160 None + OpBranchConditional %159 %161 %160 + %161 = OpLabel + OpBranch %154 + %160 = OpLabel + %162 = OpAccessChain %_ptr_Function_Inner %149 %155 + %163 = OpAccessChain %_ptr_Function_Inner_std140 %148 %155 + %164 = OpLoad %Inner_std140 %163 None + %165 = OpFunctionCall %Inner %tint_convert_Inner %164 + OpStore %162 %165 None + OpBranch %152 + %152 = OpLabel + %156 = OpIAdd %uint %155 %uint_1 + OpBranch %153 + %154 = OpLabel + %157 = OpLoad %_arr_Inner_uint_4 %149 None + %158 = OpCompositeConstruct %Outer %157 + OpReturnValue %158 OpFunctionEnd -%tint_convert_explicit_layout = OpFunction %_arr_Inner_std140_uint_4_0 None %164 +%tint_convert_explicit_layout = OpFunction %_arr_Inner_std140_uint_4_0 None %167 %tint_source = OpFunctionParameter %_arr_Inner_std140_uint_4 - %165 = OpLabel - %166 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4 Function - %168 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function %169 - OpStore %166 %tint_source - OpBranch %170 - %170 = OpLabel + %168 = OpLabel + %169 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4 Function + %171 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function %172 + OpStore %169 %tint_source OpBranch %173 %173 = OpLabel - %175 = OpPhi %uint %uint_0 %170 %176 %172 - OpLoopMerge %174 %172 None - OpBranch %171 - %171 = OpLabel - %178 = OpUGreaterThanEqual %bool %175 %uint_4 - OpSelectionMerge %179 None - OpBranchConditional %178 %180 %179 - %180 = OpLabel + OpBranch %176 + %176 = OpLabel + %178 = OpPhi %uint %uint_0 %173 %179 %175 + OpLoopMerge %177 %175 None OpBranch %174 - %179 = OpLabel - %181 = OpAccessChain %_ptr_Function_Inner_std140 %166 %175 - %182 = OpLoad %Inner_std140 %181 None - %183 = OpAccessChain %_ptr_Function_Inner_std140 %168 %175 - OpStore %183 %182 None - OpBranch %172 - %172 = OpLabel - %176 = OpIAdd %uint %175 %uint_1 - OpBranch %173 %174 = OpLabel - %177 = OpLoad %_arr_Inner_std140_uint_4_0 %168 None - OpReturnValue %177 + %181 = OpUGreaterThanEqual %bool %178 %uint_4 + OpSelectionMerge %182 None + OpBranchConditional %181 %183 %182 + %183 = OpLabel + OpBranch %177 + %182 = OpLabel + %184 = OpAccessChain %_ptr_Function_Inner_std140 %169 %178 + %185 = OpLoad %Inner_std140 %184 None + %186 = OpAccessChain %_ptr_Function_Inner_std140 %171 %178 + OpStore %186 %185 None + OpBranch %175 + %175 = OpLabel + %179 = OpIAdd %uint %178 %uint_1 + OpBranch %176 + %177 = OpLabel + %180 = OpLoad %_arr_Inner_std140_uint_4_0 %171 None + OpReturnValue %180 OpFunctionEnd -%tint_convert_explicit_layout_0 = OpFunction %Outer_std140 None %185 +%tint_convert_explicit_layout_0 = OpFunction %Outer_std140 None %188 %tint_source_0 = OpFunctionParameter %Outer_std140_tint_explicit_layout - %186 = OpLabel - %187 = OpCompositeExtract %_arr_Inner_std140_uint_4 %tint_source_0 0 - %188 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %187 - %189 = OpCompositeConstruct %Outer_std140 %188 - OpReturnValue %189 + %189 = OpLabel + %190 = OpCompositeExtract %_arr_Inner_std140_uint_4 %tint_source_0 0 + %191 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %190 + %192 = OpCompositeConstruct %Outer_std140 %191 + OpReturnValue %192 OpFunctionEnd -%tint_convert_explicit_layout_1 = OpFunction %_arr_Outer_std140_uint_4 None %191 +%tint_convert_explicit_layout_1 = OpFunction %_arr_Outer_std140_uint_4 None %194 %tint_source_1 = OpFunctionParameter %_arr_Outer_std140_tint_explicit_layout_uint_4 - %192 = OpLabel - %193 = OpVariable %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 Function - %195 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function %196 - OpStore %193 %tint_source_1 - OpBranch %197 - %197 = OpLabel + %195 = OpLabel + %196 = OpVariable %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 Function + %198 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function %199 + OpStore %196 %tint_source_1 OpBranch %200 %200 = OpLabel - %202 = OpPhi %uint %uint_0 %197 %203 %199 - OpLoopMerge %201 %199 None - OpBranch %198 - %198 = OpLabel - %205 = OpUGreaterThanEqual %bool %202 %uint_4 - OpSelectionMerge %206 None - OpBranchConditional %205 %207 %206 - %207 = OpLabel + OpBranch %203 + %203 = OpLabel + %205 = OpPhi %uint %uint_0 %200 %206 %202 + OpLoopMerge %204 %202 None OpBranch %201 - %206 = OpLabel - %208 = OpAccessChain %_ptr_Function_Outer_std140_tint_explicit_layout %193 %202 - %210 = OpLoad %Outer_std140_tint_explicit_layout %208 None - %211 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %210 - %212 = OpAccessChain %_ptr_Function_Outer_std140 %195 %202 - OpStore %212 %211 None - OpBranch %199 - %199 = OpLabel - %203 = OpIAdd %uint %202 %uint_1 - OpBranch %200 %201 = OpLabel - %204 = OpLoad %_arr_Outer_std140_uint_4 %195 None - OpReturnValue %204 + %208 = OpUGreaterThanEqual %bool %205 %uint_4 + OpSelectionMerge %209 None + OpBranchConditional %208 %210 %209 + %210 = OpLabel + OpBranch %204 + %209 = OpLabel + %211 = OpAccessChain %_ptr_Function_Outer_std140_tint_explicit_layout %196 %205 + %213 = OpLoad %Outer_std140_tint_explicit_layout %211 None + %214 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %213 + %215 = OpAccessChain %_ptr_Function_Outer_std140 %198 %205 + OpStore %215 %214 None + OpBranch %202 + %202 = OpLabel + %206 = OpIAdd %uint %205 %uint_1 + OpBranch %203 + %204 = OpLabel + %207 = OpLoad %_arr_Outer_std140_uint_4 %198 None + OpReturnValue %207 OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/struct/mat3x4_f16/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/struct/mat3x4_f16/dynamic_index_via_ptr.wgsl.expected.glsl index 3f19ba0..f2f01c4 100644 --- a/test/tint/buffer/uniform/std140/struct/mat3x4_f16/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/struct/mat3x4_f16/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -36,76 +36,77 @@ } v; int counter = 0; int i() { - counter = (counter + 1); + uint v_1 = uint(counter); + counter = int((v_1 + uint(1))); return counter; } Inner tint_convert_Inner(Inner_std140 tint_input) { return Inner(f16mat3x4(tint_input.m_col0, tint_input.m_col1, tint_input.m_col2)); } Outer tint_convert_Outer(Outer_std140 tint_input) { - Inner v_1[4] = Inner[4](Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf)))); + Inner v_2[4] = Inner[4](Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf)))); { - uint v_2 = 0u; - v_2 = 0u; + uint v_3 = 0u; + v_3 = 0u; while(true) { - uint v_3 = v_2; - if ((v_3 >= 4u)) { + uint v_4 = v_3; + if ((v_4 >= 4u)) { break; } - v_1[v_3] = tint_convert_Inner(tint_input.a[v_3]); + v_2[v_4] = tint_convert_Inner(tint_input.a[v_4]); { - v_2 = (v_3 + 1u); + v_3 = (v_4 + 1u); } continue; } } - return Outer(v_1); + return Outer(v_2); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - uint v_4 = min(uint(i()), 3u); uint v_5 = min(uint(i()), 3u); - f16mat3x4 v_6 = f16mat3x4(v.inner[v_4].a[v_5].m_col0, v.inner[v_4].a[v_5].m_col1, v.inner[v_4].a[v_5].m_col2); - f16vec4 v_7 = v_6[min(uint(i()), 2u)]; - Outer_std140 v_8[4] = v.inner; - Outer v_9[4] = Outer[4](Outer(Inner[4](Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))))), Outer(Inner[4](Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))))), Outer(Inner[4](Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))))), Outer(Inner[4](Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf)))))); + uint v_6 = min(uint(i()), 3u); + f16mat3x4 v_7 = f16mat3x4(v.inner[v_5].a[v_6].m_col0, v.inner[v_5].a[v_6].m_col1, v.inner[v_5].a[v_6].m_col2); + f16vec4 v_8 = v_7[min(uint(i()), 2u)]; + Outer_std140 v_9[4] = v.inner; + Outer v_10[4] = Outer[4](Outer(Inner[4](Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))))), Outer(Inner[4](Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))))), Outer(Inner[4](Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))))), Outer(Inner[4](Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf)))))); { - uint v_10 = 0u; - v_10 = 0u; + uint v_11 = 0u; + v_11 = 0u; while(true) { - uint v_11 = v_10; - if ((v_11 >= 4u)) { + uint v_12 = v_11; + if ((v_12 >= 4u)) { break; } - v_9[v_11] = tint_convert_Outer(v_8[v_11]); + v_10[v_12] = tint_convert_Outer(v_9[v_12]); { - v_10 = (v_11 + 1u); + v_11 = (v_12 + 1u); } continue; } } - Outer l_a[4] = v_9; - Outer l_a_i = tint_convert_Outer(v.inner[v_4]); - Inner_std140 v_12[4] = v.inner[v_4].a; - Inner v_13[4] = Inner[4](Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf)))); + Outer l_a[4] = v_10; + Outer l_a_i = tint_convert_Outer(v.inner[v_5]); + Inner_std140 v_13[4] = v.inner[v_5].a; + Inner v_14[4] = Inner[4](Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat3x4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf)))); { - uint v_14 = 0u; - v_14 = 0u; + uint v_15 = 0u; + v_15 = 0u; while(true) { - uint v_15 = v_14; - if ((v_15 >= 4u)) { + uint v_16 = v_15; + if ((v_16 >= 4u)) { break; } - v_13[v_15] = tint_convert_Inner(v_12[v_15]); + v_14[v_16] = tint_convert_Inner(v_13[v_16]); { - v_14 = (v_15 + 1u); + v_15 = (v_16 + 1u); } continue; } } - Inner l_a_i_a[4] = v_13; - Inner l_a_i_a_i = tint_convert_Inner(v.inner[v_4].a[v_5]); - f16mat3x4 l_a_i_a_i_m = v_6; - f16vec4 l_a_i_a_i_m_i = v_7; - float16_t l_a_i_a_i_m_i_i = v_7[min(uint(i()), 3u)]; + Inner l_a_i_a[4] = v_14; + Inner l_a_i_a_i = tint_convert_Inner(v.inner[v_5].a[v_6]); + f16mat3x4 l_a_i_a_i_m = v_7; + f16vec4 l_a_i_a_i_m_i = v_8; + float16_t l_a_i_a_i_m_i_i = v_8[min(uint(i()), 3u)]; }
diff --git a/test/tint/buffer/uniform/std140/struct/mat3x4_f16/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/struct/mat3x4_f16/dynamic_index_via_ptr.wgsl.expected.spvasm index 7692d21..d15757a 100644 --- a/test/tint/buffer/uniform/std140/struct/mat3x4_f16/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/struct/mat3x4_f16/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,13 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 213 +; Bound: 216 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess - %33 = OpExtInstImport "GLSL.std.450" + %36 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -74,7 +74,7 @@ %17 = OpTypeFunction %int %int_1 = OpConstant %int 1 %void = OpTypeVoid - %25 = OpTypeFunction %void + %28 = OpTypeFunction %void %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 = OpTypePointer Uniform %_arr_Outer_std140_tint_explicit_layout_uint_4 %uint_0 = OpConstant %uint 0 %uint_3 = OpConstant %uint 3 @@ -96,245 +96,248 @@ %Outer = OpTypeStruct %_arr_Inner_uint_4 %_arr_Outer_uint_4 = OpTypeArray %Outer %uint_4 %_ptr_Function__arr_Outer_uint_4 = OpTypePointer Function %_arr_Outer_uint_4 - %77 = OpConstantNull %_arr_Outer_uint_4 + %80 = OpConstantNull %_arr_Outer_uint_4 %_ptr_Function__arr_Inner_std140_uint_4_0 = OpTypePointer Function %_arr_Inner_std140_uint_4_0 %_ptr_Function__arr_Inner_uint_4 = OpTypePointer Function %_arr_Inner_uint_4 - %98 = OpConstantNull %_arr_Inner_uint_4 + %101 = OpConstantNull %_arr_Inner_uint_4 %bool = OpTypeBool %_ptr_Function_Outer = OpTypePointer Function %Outer %_ptr_Function_Outer_std140 = OpTypePointer Function %Outer_std140 %_ptr_Function_Inner = OpTypePointer Function %Inner %_ptr_Function_Inner_std140 = OpTypePointer Function %Inner_std140 - %134 = OpTypeFunction %Inner %Inner_std140 - %142 = OpTypeFunction %Outer %Outer_std140 - %164 = OpTypeFunction %_arr_Inner_std140_uint_4_0 %_arr_Inner_std140_uint_4 + %137 = OpTypeFunction %Inner %Inner_std140 + %145 = OpTypeFunction %Outer %Outer_std140 + %167 = OpTypeFunction %_arr_Inner_std140_uint_4_0 %_arr_Inner_std140_uint_4 %_ptr_Function__arr_Inner_std140_uint_4 = OpTypePointer Function %_arr_Inner_std140_uint_4 - %169 = OpConstantNull %_arr_Inner_std140_uint_4_0 - %185 = OpTypeFunction %Outer_std140 %Outer_std140_tint_explicit_layout - %191 = OpTypeFunction %_arr_Outer_std140_uint_4 %_arr_Outer_std140_tint_explicit_layout_uint_4 + %172 = OpConstantNull %_arr_Inner_std140_uint_4_0 + %188 = OpTypeFunction %Outer_std140 %Outer_std140_tint_explicit_layout + %194 = OpTypeFunction %_arr_Outer_std140_uint_4 %_arr_Outer_std140_tint_explicit_layout_uint_4 %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 = OpTypePointer Function %_arr_Outer_std140_tint_explicit_layout_uint_4 - %196 = OpConstantNull %_arr_Outer_std140_uint_4 + %199 = OpConstantNull %_arr_Outer_std140_uint_4 %_ptr_Function_Outer_std140_tint_explicit_layout = OpTypePointer Function %Outer_std140_tint_explicit_layout %i = OpFunction %int None %17 %18 = OpLabel %19 = OpLoad %int %counter None - %20 = OpIAdd %int %19 %int_1 - OpStore %counter %20 None - %22 = OpLoad %int %counter None - OpReturnValue %22 + %20 = OpBitcast %uint %19 + %21 = OpBitcast %uint %int_1 + %23 = OpIAdd %uint %20 %21 + %24 = OpBitcast %int %23 + OpStore %counter %24 None + %25 = OpLoad %int %counter None + OpReturnValue %25 OpFunctionEnd - %f = OpFunction %void None %25 - %26 = OpLabel - %55 = OpVariable %_ptr_Function_mat3v4half Function - %69 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function - %71 = OpVariable %_ptr_Function__arr_Outer_uint_4 Function %77 - %94 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function - %96 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %98 - %27 = OpAccessChain %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 %1 %uint_0 - %30 = OpFunctionCall %int %i - %31 = OpBitcast %uint %30 - %32 = OpExtInst %uint %33 UMin %31 %uint_3 - %35 = OpAccessChain %_ptr_Uniform_Outer_std140_tint_explicit_layout %27 %32 - %37 = OpAccessChain %_ptr_Uniform__arr_Inner_std140_uint_4 %35 %uint_0 - %39 = OpFunctionCall %int %i - %40 = OpBitcast %uint %39 - %41 = OpExtInst %uint %33 UMin %40 %uint_3 - %42 = OpAccessChain %_ptr_Uniform_Inner_std140 %37 %41 - %44 = OpAccessChain %_ptr_Uniform_v4half %42 %uint_0 - %46 = OpLoad %v4half %44 None - %47 = OpAccessChain %_ptr_Uniform_v4half %42 %uint_1 + %f = OpFunction %void None %28 + %29 = OpLabel + %58 = OpVariable %_ptr_Function_mat3v4half Function + %72 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function + %74 = OpVariable %_ptr_Function__arr_Outer_uint_4 Function %80 + %97 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function + %99 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %101 + %30 = OpAccessChain %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 %1 %uint_0 + %33 = OpFunctionCall %int %i + %34 = OpBitcast %uint %33 + %35 = OpExtInst %uint %36 UMin %34 %uint_3 + %38 = OpAccessChain %_ptr_Uniform_Outer_std140_tint_explicit_layout %30 %35 + %40 = OpAccessChain %_ptr_Uniform__arr_Inner_std140_uint_4 %38 %uint_0 + %42 = OpFunctionCall %int %i + %43 = OpBitcast %uint %42 + %44 = OpExtInst %uint %36 UMin %43 %uint_3 + %45 = OpAccessChain %_ptr_Uniform_Inner_std140 %40 %44 + %47 = OpAccessChain %_ptr_Uniform_v4half %45 %uint_0 %49 = OpLoad %v4half %47 None - %50 = OpAccessChain %_ptr_Uniform_v4half %42 %uint_2 + %50 = OpAccessChain %_ptr_Uniform_v4half %45 %uint_1 %52 = OpLoad %v4half %50 None -%l_a_i_a_i_m = OpCompositeConstruct %mat3v4half %46 %49 %52 - OpStore %55 %l_a_i_a_i_m - %57 = OpFunctionCall %int %i - %58 = OpBitcast %uint %57 - %59 = OpExtInst %uint %33 UMin %58 %uint_2 - %60 = OpAccessChain %_ptr_Function_v4half %55 %59 -%l_a_i_a_i_m_i = OpLoad %v4half %60 None - %63 = OpLoad %_arr_Outer_std140_tint_explicit_layout_uint_4 %27 None - %64 = OpFunctionCall %_arr_Outer_std140_uint_4 %tint_convert_explicit_layout_1 %63 - OpStore %69 %64 - OpBranch %78 - %78 = OpLabel + %53 = OpAccessChain %_ptr_Uniform_v4half %45 %uint_2 + %55 = OpLoad %v4half %53 None +%l_a_i_a_i_m = OpCompositeConstruct %mat3v4half %49 %52 %55 + OpStore %58 %l_a_i_a_i_m + %60 = OpFunctionCall %int %i + %61 = OpBitcast %uint %60 + %62 = OpExtInst %uint %36 UMin %61 %uint_2 + %63 = OpAccessChain %_ptr_Function_v4half %58 %62 +%l_a_i_a_i_m_i = OpLoad %v4half %63 None + %66 = OpLoad %_arr_Outer_std140_tint_explicit_layout_uint_4 %30 None + %67 = OpFunctionCall %_arr_Outer_std140_uint_4 %tint_convert_explicit_layout_1 %66 + OpStore %72 %67 OpBranch %81 %81 = OpLabel - %83 = OpPhi %uint %uint_0 %78 %84 %80 - OpLoopMerge %82 %80 None - OpBranch %79 - %79 = OpLabel - %114 = OpUGreaterThanEqual %bool %83 %uint_4 - OpSelectionMerge %116 None - OpBranchConditional %114 %117 %116 - %117 = OpLabel + OpBranch %84 + %84 = OpLabel + %86 = OpPhi %uint %uint_0 %81 %87 %83 + OpLoopMerge %85 %83 None OpBranch %82 - %116 = OpLabel - %118 = OpAccessChain %_ptr_Function_Outer %71 %83 - %120 = OpAccessChain %_ptr_Function_Outer_std140 %69 %83 - %122 = OpLoad %Outer_std140 %120 None - %123 = OpFunctionCall %Outer %tint_convert_Outer %122 - OpStore %118 %123 None - OpBranch %80 - %80 = OpLabel - %84 = OpIAdd %uint %83 %uint_1 - OpBranch %81 %82 = OpLabel - %l_a = OpLoad %_arr_Outer_uint_4 %71 None - %86 = OpLoad %Outer_std140_tint_explicit_layout %35 None - %87 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %86 - %l_a_i = OpFunctionCall %Outer %tint_convert_Outer %87 - %91 = OpLoad %_arr_Inner_std140_uint_4 %37 None - %92 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %91 - OpStore %94 %92 - OpBranch %99 - %99 = OpLabel + %117 = OpUGreaterThanEqual %bool %86 %uint_4 + OpSelectionMerge %119 None + OpBranchConditional %117 %120 %119 + %120 = OpLabel + OpBranch %85 + %119 = OpLabel + %121 = OpAccessChain %_ptr_Function_Outer %74 %86 + %123 = OpAccessChain %_ptr_Function_Outer_std140 %72 %86 + %125 = OpLoad %Outer_std140 %123 None + %126 = OpFunctionCall %Outer %tint_convert_Outer %125 + OpStore %121 %126 None + OpBranch %83 + %83 = OpLabel + %87 = OpIAdd %uint %86 %uint_1 + OpBranch %84 + %85 = OpLabel + %l_a = OpLoad %_arr_Outer_uint_4 %74 None + %89 = OpLoad %Outer_std140_tint_explicit_layout %38 None + %90 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %89 + %l_a_i = OpFunctionCall %Outer %tint_convert_Outer %90 + %94 = OpLoad %_arr_Inner_std140_uint_4 %40 None + %95 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %94 + OpStore %97 %95 OpBranch %102 %102 = OpLabel - %104 = OpPhi %uint %uint_0 %99 %105 %101 - OpLoopMerge %103 %101 None - OpBranch %100 - %100 = OpLabel - %124 = OpUGreaterThanEqual %bool %104 %uint_4 - OpSelectionMerge %125 None - OpBranchConditional %124 %126 %125 - %126 = OpLabel + OpBranch %105 + %105 = OpLabel + %107 = OpPhi %uint %uint_0 %102 %108 %104 + OpLoopMerge %106 %104 None OpBranch %103 - %125 = OpLabel - %127 = OpAccessChain %_ptr_Function_Inner %96 %104 - %129 = OpAccessChain %_ptr_Function_Inner_std140 %94 %104 - %131 = OpLoad %Inner_std140 %129 None - %132 = OpFunctionCall %Inner %tint_convert_Inner %131 - OpStore %127 %132 None - OpBranch %101 - %101 = OpLabel - %105 = OpIAdd %uint %104 %uint_1 - OpBranch %102 %103 = OpLabel - %l_a_i_a = OpLoad %_arr_Inner_uint_4 %96 None - %107 = OpLoad %Inner_std140 %42 None - %l_a_i_a_i = OpFunctionCall %Inner %tint_convert_Inner %107 - %110 = OpFunctionCall %int %i - %111 = OpBitcast %uint %110 - %112 = OpExtInst %uint %33 UMin %111 %uint_3 -%l_a_i_a_i_m_i_i = OpVectorExtractDynamic %half %l_a_i_a_i_m_i %112 + %127 = OpUGreaterThanEqual %bool %107 %uint_4 + OpSelectionMerge %128 None + OpBranchConditional %127 %129 %128 + %129 = OpLabel + OpBranch %106 + %128 = OpLabel + %130 = OpAccessChain %_ptr_Function_Inner %99 %107 + %132 = OpAccessChain %_ptr_Function_Inner_std140 %97 %107 + %134 = OpLoad %Inner_std140 %132 None + %135 = OpFunctionCall %Inner %tint_convert_Inner %134 + OpStore %130 %135 None + OpBranch %104 + %104 = OpLabel + %108 = OpIAdd %uint %107 %uint_1 + OpBranch %105 + %106 = OpLabel + %l_a_i_a = OpLoad %_arr_Inner_uint_4 %99 None + %110 = OpLoad %Inner_std140 %45 None + %l_a_i_a_i = OpFunctionCall %Inner %tint_convert_Inner %110 + %113 = OpFunctionCall %int %i + %114 = OpBitcast %uint %113 + %115 = OpExtInst %uint %36 UMin %114 %uint_3 +%l_a_i_a_i_m_i_i = OpVectorExtractDynamic %half %l_a_i_a_i_m_i %115 OpReturn OpFunctionEnd -%tint_convert_Inner = OpFunction %Inner None %134 +%tint_convert_Inner = OpFunction %Inner None %137 %tint_input = OpFunctionParameter %Inner_std140 - %135 = OpLabel - %136 = OpCompositeExtract %v4half %tint_input 0 - %137 = OpCompositeExtract %v4half %tint_input 1 - %138 = OpCompositeExtract %v4half %tint_input 2 - %139 = OpCompositeConstruct %mat3v4half %136 %137 %138 - %140 = OpCompositeConstruct %Inner %139 - OpReturnValue %140 + %138 = OpLabel + %139 = OpCompositeExtract %v4half %tint_input 0 + %140 = OpCompositeExtract %v4half %tint_input 1 + %141 = OpCompositeExtract %v4half %tint_input 2 + %142 = OpCompositeConstruct %mat3v4half %139 %140 %141 + %143 = OpCompositeConstruct %Inner %142 + OpReturnValue %143 OpFunctionEnd -%tint_convert_Outer = OpFunction %Outer None %142 +%tint_convert_Outer = OpFunction %Outer None %145 %tint_input_0 = OpFunctionParameter %Outer_std140 - %143 = OpLabel - %145 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function - %146 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %98 - %144 = OpCompositeExtract %_arr_Inner_std140_uint_4_0 %tint_input_0 0 - OpStore %145 %144 - OpBranch %147 - %147 = OpLabel + %146 = OpLabel + %148 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function + %149 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %101 + %147 = OpCompositeExtract %_arr_Inner_std140_uint_4_0 %tint_input_0 0 + OpStore %148 %147 OpBranch %150 %150 = OpLabel - %152 = OpPhi %uint %uint_0 %147 %153 %149 - OpLoopMerge %151 %149 None - OpBranch %148 - %148 = OpLabel - %156 = OpUGreaterThanEqual %bool %152 %uint_4 - OpSelectionMerge %157 None - OpBranchConditional %156 %158 %157 - %158 = OpLabel + OpBranch %153 + %153 = OpLabel + %155 = OpPhi %uint %uint_0 %150 %156 %152 + OpLoopMerge %154 %152 None OpBranch %151 - %157 = OpLabel - %159 = OpAccessChain %_ptr_Function_Inner %146 %152 - %160 = OpAccessChain %_ptr_Function_Inner_std140 %145 %152 - %161 = OpLoad %Inner_std140 %160 None - %162 = OpFunctionCall %Inner %tint_convert_Inner %161 - OpStore %159 %162 None - OpBranch %149 - %149 = OpLabel - %153 = OpIAdd %uint %152 %uint_1 - OpBranch %150 %151 = OpLabel - %154 = OpLoad %_arr_Inner_uint_4 %146 None - %155 = OpCompositeConstruct %Outer %154 - OpReturnValue %155 + %159 = OpUGreaterThanEqual %bool %155 %uint_4 + OpSelectionMerge %160 None + OpBranchConditional %159 %161 %160 + %161 = OpLabel + OpBranch %154 + %160 = OpLabel + %162 = OpAccessChain %_ptr_Function_Inner %149 %155 + %163 = OpAccessChain %_ptr_Function_Inner_std140 %148 %155 + %164 = OpLoad %Inner_std140 %163 None + %165 = OpFunctionCall %Inner %tint_convert_Inner %164 + OpStore %162 %165 None + OpBranch %152 + %152 = OpLabel + %156 = OpIAdd %uint %155 %uint_1 + OpBranch %153 + %154 = OpLabel + %157 = OpLoad %_arr_Inner_uint_4 %149 None + %158 = OpCompositeConstruct %Outer %157 + OpReturnValue %158 OpFunctionEnd -%tint_convert_explicit_layout = OpFunction %_arr_Inner_std140_uint_4_0 None %164 +%tint_convert_explicit_layout = OpFunction %_arr_Inner_std140_uint_4_0 None %167 %tint_source = OpFunctionParameter %_arr_Inner_std140_uint_4 - %165 = OpLabel - %166 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4 Function - %168 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function %169 - OpStore %166 %tint_source - OpBranch %170 - %170 = OpLabel + %168 = OpLabel + %169 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4 Function + %171 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function %172 + OpStore %169 %tint_source OpBranch %173 %173 = OpLabel - %175 = OpPhi %uint %uint_0 %170 %176 %172 - OpLoopMerge %174 %172 None - OpBranch %171 - %171 = OpLabel - %178 = OpUGreaterThanEqual %bool %175 %uint_4 - OpSelectionMerge %179 None - OpBranchConditional %178 %180 %179 - %180 = OpLabel + OpBranch %176 + %176 = OpLabel + %178 = OpPhi %uint %uint_0 %173 %179 %175 + OpLoopMerge %177 %175 None OpBranch %174 - %179 = OpLabel - %181 = OpAccessChain %_ptr_Function_Inner_std140 %166 %175 - %182 = OpLoad %Inner_std140 %181 None - %183 = OpAccessChain %_ptr_Function_Inner_std140 %168 %175 - OpStore %183 %182 None - OpBranch %172 - %172 = OpLabel - %176 = OpIAdd %uint %175 %uint_1 - OpBranch %173 %174 = OpLabel - %177 = OpLoad %_arr_Inner_std140_uint_4_0 %168 None - OpReturnValue %177 + %181 = OpUGreaterThanEqual %bool %178 %uint_4 + OpSelectionMerge %182 None + OpBranchConditional %181 %183 %182 + %183 = OpLabel + OpBranch %177 + %182 = OpLabel + %184 = OpAccessChain %_ptr_Function_Inner_std140 %169 %178 + %185 = OpLoad %Inner_std140 %184 None + %186 = OpAccessChain %_ptr_Function_Inner_std140 %171 %178 + OpStore %186 %185 None + OpBranch %175 + %175 = OpLabel + %179 = OpIAdd %uint %178 %uint_1 + OpBranch %176 + %177 = OpLabel + %180 = OpLoad %_arr_Inner_std140_uint_4_0 %171 None + OpReturnValue %180 OpFunctionEnd -%tint_convert_explicit_layout_0 = OpFunction %Outer_std140 None %185 +%tint_convert_explicit_layout_0 = OpFunction %Outer_std140 None %188 %tint_source_0 = OpFunctionParameter %Outer_std140_tint_explicit_layout - %186 = OpLabel - %187 = OpCompositeExtract %_arr_Inner_std140_uint_4 %tint_source_0 0 - %188 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %187 - %189 = OpCompositeConstruct %Outer_std140 %188 - OpReturnValue %189 + %189 = OpLabel + %190 = OpCompositeExtract %_arr_Inner_std140_uint_4 %tint_source_0 0 + %191 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %190 + %192 = OpCompositeConstruct %Outer_std140 %191 + OpReturnValue %192 OpFunctionEnd -%tint_convert_explicit_layout_1 = OpFunction %_arr_Outer_std140_uint_4 None %191 +%tint_convert_explicit_layout_1 = OpFunction %_arr_Outer_std140_uint_4 None %194 %tint_source_1 = OpFunctionParameter %_arr_Outer_std140_tint_explicit_layout_uint_4 - %192 = OpLabel - %193 = OpVariable %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 Function - %195 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function %196 - OpStore %193 %tint_source_1 - OpBranch %197 - %197 = OpLabel + %195 = OpLabel + %196 = OpVariable %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 Function + %198 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function %199 + OpStore %196 %tint_source_1 OpBranch %200 %200 = OpLabel - %202 = OpPhi %uint %uint_0 %197 %203 %199 - OpLoopMerge %201 %199 None - OpBranch %198 - %198 = OpLabel - %205 = OpUGreaterThanEqual %bool %202 %uint_4 - OpSelectionMerge %206 None - OpBranchConditional %205 %207 %206 - %207 = OpLabel + OpBranch %203 + %203 = OpLabel + %205 = OpPhi %uint %uint_0 %200 %206 %202 + OpLoopMerge %204 %202 None OpBranch %201 - %206 = OpLabel - %208 = OpAccessChain %_ptr_Function_Outer_std140_tint_explicit_layout %193 %202 - %210 = OpLoad %Outer_std140_tint_explicit_layout %208 None - %211 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %210 - %212 = OpAccessChain %_ptr_Function_Outer_std140 %195 %202 - OpStore %212 %211 None - OpBranch %199 - %199 = OpLabel - %203 = OpIAdd %uint %202 %uint_1 - OpBranch %200 %201 = OpLabel - %204 = OpLoad %_arr_Outer_std140_uint_4 %195 None - OpReturnValue %204 + %208 = OpUGreaterThanEqual %bool %205 %uint_4 + OpSelectionMerge %209 None + OpBranchConditional %208 %210 %209 + %210 = OpLabel + OpBranch %204 + %209 = OpLabel + %211 = OpAccessChain %_ptr_Function_Outer_std140_tint_explicit_layout %196 %205 + %213 = OpLoad %Outer_std140_tint_explicit_layout %211 None + %214 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %213 + %215 = OpAccessChain %_ptr_Function_Outer_std140 %198 %205 + OpStore %215 %214 None + OpBranch %202 + %202 = OpLabel + %206 = OpIAdd %uint %205 %uint_1 + OpBranch %203 + %204 = OpLabel + %207 = OpLoad %_arr_Outer_std140_uint_4 %198 None + OpReturnValue %207 OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/struct/mat3x4_f32/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/struct/mat3x4_f32/dynamic_index_via_ptr.wgsl.expected.glsl index 982ca97..a9deb66 100644 --- a/test/tint/buffer/uniform/std140/struct/mat3x4_f32/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/struct/mat3x4_f32/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -19,19 +19,20 @@ } v; int counter = 0; int i() { - counter = (counter + 1); + uint v_1 = uint(counter); + counter = int((v_1 + uint(1))); return counter; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - uint v_1 = min(uint(i()), 3u); uint v_2 = min(uint(i()), 3u); - uint v_3 = min(uint(i()), 2u); + uint v_3 = min(uint(i()), 3u); + uint v_4 = min(uint(i()), 2u); Outer l_a[4] = v.inner; - Outer l_a_i = v.inner[v_1]; - Inner l_a_i_a[4] = v.inner[v_1].a; - Inner l_a_i_a_i = v.inner[v_1].a[v_2]; - mat3x4 l_a_i_a_i_m = v.inner[v_1].a[v_2].m; - vec4 l_a_i_a_i_m_i = v.inner[v_1].a[v_2].m[v_3]; - float l_a_i_a_i_m_i_i = v.inner[v_1].a[v_2].m[v_3][min(uint(i()), 3u)]; + Outer l_a_i = v.inner[v_2]; + Inner l_a_i_a[4] = v.inner[v_2].a; + Inner l_a_i_a_i = v.inner[v_2].a[v_3]; + mat3x4 l_a_i_a_i_m = v.inner[v_2].a[v_3].m; + vec4 l_a_i_a_i_m_i = v.inner[v_2].a[v_3].m[v_4]; + float l_a_i_a_i_m_i_i = v.inner[v_2].a[v_3].m[v_4][min(uint(i()), 3u)]; }
diff --git a/test/tint/buffer/uniform/std140/struct/mat3x4_f32/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/struct/mat3x4_f32/dynamic_index_via_ptr.wgsl.expected.spvasm index 3c8b056..bd6660a 100644 --- a/test/tint/buffer/uniform/std140/struct/mat3x4_f32/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/struct/mat3x4_f32/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,10 +1,10 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 130 +; Bound: 133 ; Schema: 0 OpCapability Shader - %34 = OpExtInstImport "GLSL.std.450" + %37 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -68,7 +68,7 @@ %18 = OpTypeFunction %int %int_1 = OpConstant %int 1 %void = OpTypeVoid - %26 = OpTypeFunction %void + %29 = OpTypeFunction %void %_ptr_Uniform__arr_Outer_tint_explicit_layout_uint_4 = OpTypePointer Uniform %_arr_Outer_tint_explicit_layout_uint_4 %uint_0 = OpConstant %uint 0 %uint_3 = OpConstant %uint 3 @@ -82,131 +82,134 @@ %Outer = OpTypeStruct %_arr_Inner_uint_4_0 %_arr_Outer_uint_4 = OpTypeArray %Outer %uint_4 %_ptr_Uniform_float = OpTypePointer Uniform %float - %75 = OpTypeFunction %_arr_Inner_uint_4_0 %_arr_Inner_uint_4 + %78 = OpTypeFunction %_arr_Inner_uint_4_0 %_arr_Inner_uint_4 %_ptr_Function__arr_Inner_uint_4 = OpTypePointer Function %_arr_Inner_uint_4 %_ptr_Function__arr_Inner_uint_4_0 = OpTypePointer Function %_arr_Inner_uint_4_0 - %81 = OpConstantNull %_arr_Inner_uint_4_0 + %84 = OpConstantNull %_arr_Inner_uint_4_0 %bool = OpTypeBool %_ptr_Function_Inner = OpTypePointer Function %Inner %uint_1 = OpConstant %uint 1 - %100 = OpTypeFunction %Outer %Outer_tint_explicit_layout - %106 = OpTypeFunction %_arr_Outer_uint_4 %_arr_Outer_tint_explicit_layout_uint_4 + %103 = OpTypeFunction %Outer %Outer_tint_explicit_layout + %109 = OpTypeFunction %_arr_Outer_uint_4 %_arr_Outer_tint_explicit_layout_uint_4 %_ptr_Function__arr_Outer_tint_explicit_layout_uint_4 = OpTypePointer Function %_arr_Outer_tint_explicit_layout_uint_4 %_ptr_Function__arr_Outer_uint_4 = OpTypePointer Function %_arr_Outer_uint_4 - %112 = OpConstantNull %_arr_Outer_uint_4 + %115 = OpConstantNull %_arr_Outer_uint_4 %_ptr_Function_Outer_tint_explicit_layout = OpTypePointer Function %Outer_tint_explicit_layout %_ptr_Function_Outer = OpTypePointer Function %Outer %i = OpFunction %int None %18 %19 = OpLabel %20 = OpLoad %int %counter None - %21 = OpIAdd %int %20 %int_1 - OpStore %counter %21 None - %23 = OpLoad %int %counter None - OpReturnValue %23 + %21 = OpBitcast %uint %20 + %22 = OpBitcast %uint %int_1 + %24 = OpIAdd %uint %21 %22 + %25 = OpBitcast %int %24 + OpStore %counter %25 None + %26 = OpLoad %int %counter None + OpReturnValue %26 OpFunctionEnd - %f = OpFunction %void None %26 - %27 = OpLabel + %f = OpFunction %void None %29 + %30 = OpLabel %p_a = OpAccessChain %_ptr_Uniform__arr_Outer_tint_explicit_layout_uint_4 %1 %uint_0 - %31 = OpFunctionCall %int %i - %32 = OpBitcast %uint %31 - %33 = OpExtInst %uint %34 UMin %32 %uint_3 - %p_a_i = OpAccessChain %_ptr_Uniform_Outer_tint_explicit_layout %p_a %33 + %34 = OpFunctionCall %int %i + %35 = OpBitcast %uint %34 + %36 = OpExtInst %uint %37 UMin %35 %uint_3 + %p_a_i = OpAccessChain %_ptr_Uniform_Outer_tint_explicit_layout %p_a %36 %p_a_i_a = OpAccessChain %_ptr_Uniform__arr_Inner_uint_4 %p_a_i %uint_0 - %40 = OpFunctionCall %int %i - %41 = OpBitcast %uint %40 - %42 = OpExtInst %uint %34 UMin %41 %uint_3 - %p_a_i_a_i = OpAccessChain %_ptr_Uniform_Inner %p_a_i_a %42 + %43 = OpFunctionCall %int %i + %44 = OpBitcast %uint %43 + %45 = OpExtInst %uint %37 UMin %44 %uint_3 + %p_a_i_a_i = OpAccessChain %_ptr_Uniform_Inner %p_a_i_a %45 %p_a_i_a_i_m = OpAccessChain %_ptr_Uniform_mat3v4float %p_a_i_a_i %uint_0 - %47 = OpFunctionCall %int %i - %48 = OpBitcast %uint %47 - %49 = OpExtInst %uint %34 UMin %48 %uint_2 -%p_a_i_a_i_m_i = OpAccessChain %_ptr_Uniform_v4float %p_a_i_a_i_m %49 - %53 = OpLoad %_arr_Outer_tint_explicit_layout_uint_4 %p_a None - %l_a = OpFunctionCall %_arr_Outer_uint_4 %tint_convert_explicit_layout_1 %53 - %59 = OpLoad %Outer_tint_explicit_layout %p_a_i None - %l_a_i = OpFunctionCall %Outer %tint_convert_explicit_layout_0 %59 - %62 = OpLoad %_arr_Inner_uint_4 %p_a_i_a None - %l_a_i_a = OpFunctionCall %_arr_Inner_uint_4_0 %tint_convert_explicit_layout %62 + %50 = OpFunctionCall %int %i + %51 = OpBitcast %uint %50 + %52 = OpExtInst %uint %37 UMin %51 %uint_2 +%p_a_i_a_i_m_i = OpAccessChain %_ptr_Uniform_v4float %p_a_i_a_i_m %52 + %56 = OpLoad %_arr_Outer_tint_explicit_layout_uint_4 %p_a None + %l_a = OpFunctionCall %_arr_Outer_uint_4 %tint_convert_explicit_layout_1 %56 + %62 = OpLoad %Outer_tint_explicit_layout %p_a_i None + %l_a_i = OpFunctionCall %Outer %tint_convert_explicit_layout_0 %62 + %65 = OpLoad %_arr_Inner_uint_4 %p_a_i_a None + %l_a_i_a = OpFunctionCall %_arr_Inner_uint_4_0 %tint_convert_explicit_layout %65 %l_a_i_a_i = OpLoad %Inner %p_a_i_a_i None %l_a_i_a_i_m = OpLoad %mat3v4float %p_a_i_a_i_m None %l_a_i_a_i_m_i = OpLoad %v4float %p_a_i_a_i_m_i None - %68 = OpFunctionCall %int %i - %69 = OpBitcast %uint %68 - %70 = OpExtInst %uint %34 UMin %69 %uint_3 - %71 = OpAccessChain %_ptr_Uniform_float %p_a_i_a_i_m_i %70 -%l_a_i_a_i_m_i_i = OpLoad %float %71 None + %71 = OpFunctionCall %int %i + %72 = OpBitcast %uint %71 + %73 = OpExtInst %uint %37 UMin %72 %uint_3 + %74 = OpAccessChain %_ptr_Uniform_float %p_a_i_a_i_m_i %73 +%l_a_i_a_i_m_i_i = OpLoad %float %74 None OpReturn OpFunctionEnd -%tint_convert_explicit_layout = OpFunction %_arr_Inner_uint_4_0 None %75 +%tint_convert_explicit_layout = OpFunction %_arr_Inner_uint_4_0 None %78 %tint_source = OpFunctionParameter %_arr_Inner_uint_4 - %76 = OpLabel - %77 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function - %79 = OpVariable %_ptr_Function__arr_Inner_uint_4_0 Function %81 - OpStore %77 %tint_source - OpBranch %82 - %82 = OpLabel + %79 = OpLabel + %80 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function + %82 = OpVariable %_ptr_Function__arr_Inner_uint_4_0 Function %84 + OpStore %80 %tint_source OpBranch %85 %85 = OpLabel - %87 = OpPhi %uint %uint_0 %82 %88 %84 - OpLoopMerge %86 %84 None - OpBranch %83 - %83 = OpLabel - %90 = OpUGreaterThanEqual %bool %87 %uint_4 - OpSelectionMerge %92 None - OpBranchConditional %90 %93 %92 - %93 = OpLabel + OpBranch %88 + %88 = OpLabel + %90 = OpPhi %uint %uint_0 %85 %91 %87 + OpLoopMerge %89 %87 None OpBranch %86 - %92 = OpLabel - %94 = OpAccessChain %_ptr_Function_Inner %77 %87 - %96 = OpLoad %Inner %94 None - %97 = OpAccessChain %_ptr_Function_Inner %79 %87 - OpStore %97 %96 None - OpBranch %84 - %84 = OpLabel - %88 = OpIAdd %uint %87 %uint_1 - OpBranch %85 %86 = OpLabel - %89 = OpLoad %_arr_Inner_uint_4_0 %79 None - OpReturnValue %89 + %93 = OpUGreaterThanEqual %bool %90 %uint_4 + OpSelectionMerge %95 None + OpBranchConditional %93 %96 %95 + %96 = OpLabel + OpBranch %89 + %95 = OpLabel + %97 = OpAccessChain %_ptr_Function_Inner %80 %90 + %99 = OpLoad %Inner %97 None + %100 = OpAccessChain %_ptr_Function_Inner %82 %90 + OpStore %100 %99 None + OpBranch %87 + %87 = OpLabel + %91 = OpIAdd %uint %90 %uint_1 + OpBranch %88 + %89 = OpLabel + %92 = OpLoad %_arr_Inner_uint_4_0 %82 None + OpReturnValue %92 OpFunctionEnd -%tint_convert_explicit_layout_0 = OpFunction %Outer None %100 +%tint_convert_explicit_layout_0 = OpFunction %Outer None %103 %tint_source_0 = OpFunctionParameter %Outer_tint_explicit_layout - %101 = OpLabel - %102 = OpCompositeExtract %_arr_Inner_uint_4 %tint_source_0 0 - %103 = OpFunctionCall %_arr_Inner_uint_4_0 %tint_convert_explicit_layout %102 - %104 = OpCompositeConstruct %Outer %103 - OpReturnValue %104 + %104 = OpLabel + %105 = OpCompositeExtract %_arr_Inner_uint_4 %tint_source_0 0 + %106 = OpFunctionCall %_arr_Inner_uint_4_0 %tint_convert_explicit_layout %105 + %107 = OpCompositeConstruct %Outer %106 + OpReturnValue %107 OpFunctionEnd -%tint_convert_explicit_layout_1 = OpFunction %_arr_Outer_uint_4 None %106 +%tint_convert_explicit_layout_1 = OpFunction %_arr_Outer_uint_4 None %109 %tint_source_1 = OpFunctionParameter %_arr_Outer_tint_explicit_layout_uint_4 - %107 = OpLabel - %108 = OpVariable %_ptr_Function__arr_Outer_tint_explicit_layout_uint_4 Function - %110 = OpVariable %_ptr_Function__arr_Outer_uint_4 Function %112 - OpStore %108 %tint_source_1 - OpBranch %113 - %113 = OpLabel + %110 = OpLabel + %111 = OpVariable %_ptr_Function__arr_Outer_tint_explicit_layout_uint_4 Function + %113 = OpVariable %_ptr_Function__arr_Outer_uint_4 Function %115 + OpStore %111 %tint_source_1 OpBranch %116 %116 = OpLabel - %118 = OpPhi %uint %uint_0 %113 %119 %115 - OpLoopMerge %117 %115 None - OpBranch %114 - %114 = OpLabel - %121 = OpUGreaterThanEqual %bool %118 %uint_4 - OpSelectionMerge %122 None - OpBranchConditional %121 %123 %122 - %123 = OpLabel + OpBranch %119 + %119 = OpLabel + %121 = OpPhi %uint %uint_0 %116 %122 %118 + OpLoopMerge %120 %118 None OpBranch %117 - %122 = OpLabel - %124 = OpAccessChain %_ptr_Function_Outer_tint_explicit_layout %108 %118 - %126 = OpLoad %Outer_tint_explicit_layout %124 None - %127 = OpFunctionCall %Outer %tint_convert_explicit_layout_0 %126 - %128 = OpAccessChain %_ptr_Function_Outer %110 %118 - OpStore %128 %127 None - OpBranch %115 - %115 = OpLabel - %119 = OpIAdd %uint %118 %uint_1 - OpBranch %116 %117 = OpLabel - %120 = OpLoad %_arr_Outer_uint_4 %110 None - OpReturnValue %120 + %124 = OpUGreaterThanEqual %bool %121 %uint_4 + OpSelectionMerge %125 None + OpBranchConditional %124 %126 %125 + %126 = OpLabel + OpBranch %120 + %125 = OpLabel + %127 = OpAccessChain %_ptr_Function_Outer_tint_explicit_layout %111 %121 + %129 = OpLoad %Outer_tint_explicit_layout %127 None + %130 = OpFunctionCall %Outer %tint_convert_explicit_layout_0 %129 + %131 = OpAccessChain %_ptr_Function_Outer %113 %121 + OpStore %131 %130 None + OpBranch %118 + %118 = OpLabel + %122 = OpIAdd %uint %121 %uint_1 + OpBranch %119 + %120 = OpLabel + %123 = OpLoad %_arr_Outer_uint_4 %113 None + OpReturnValue %123 OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/struct/mat4x2_f16/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/struct/mat4x2_f16/dynamic_index_via_ptr.wgsl.expected.glsl index cb35fb4..cacc54a 100644 --- a/test/tint/buffer/uniform/std140/struct/mat4x2_f16/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/struct/mat4x2_f16/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -39,76 +39,77 @@ } v; int counter = 0; int i() { - counter = (counter + 1); + uint v_1 = uint(counter); + counter = int((v_1 + uint(1))); return counter; } Inner tint_convert_Inner(Inner_std140 tint_input) { return Inner(f16mat4x2(tint_input.m_col0, tint_input.m_col1, tint_input.m_col2, tint_input.m_col3)); } Outer tint_convert_Outer(Outer_std140 tint_input) { - Inner v_1[4] = Inner[4](Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf)))); + Inner v_2[4] = Inner[4](Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf)))); { - uint v_2 = 0u; - v_2 = 0u; + uint v_3 = 0u; + v_3 = 0u; while(true) { - uint v_3 = v_2; - if ((v_3 >= 4u)) { + uint v_4 = v_3; + if ((v_4 >= 4u)) { break; } - v_1[v_3] = tint_convert_Inner(tint_input.a[v_3]); + v_2[v_4] = tint_convert_Inner(tint_input.a[v_4]); { - v_2 = (v_3 + 1u); + v_3 = (v_4 + 1u); } continue; } } - return Outer(v_1); + return Outer(v_2); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - uint v_4 = min(uint(i()), 3u); uint v_5 = min(uint(i()), 3u); - f16mat4x2 v_6 = f16mat4x2(v.inner[v_4].a[v_5].m_col0, v.inner[v_4].a[v_5].m_col1, v.inner[v_4].a[v_5].m_col2, v.inner[v_4].a[v_5].m_col3); - f16vec2 v_7 = v_6[min(uint(i()), 3u)]; - Outer_std140 v_8[4] = v.inner; - Outer v_9[4] = Outer[4](Outer(Inner[4](Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))))), Outer(Inner[4](Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))))), Outer(Inner[4](Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))))), Outer(Inner[4](Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf)))))); + uint v_6 = min(uint(i()), 3u); + f16mat4x2 v_7 = f16mat4x2(v.inner[v_5].a[v_6].m_col0, v.inner[v_5].a[v_6].m_col1, v.inner[v_5].a[v_6].m_col2, v.inner[v_5].a[v_6].m_col3); + f16vec2 v_8 = v_7[min(uint(i()), 3u)]; + Outer_std140 v_9[4] = v.inner; + Outer v_10[4] = Outer[4](Outer(Inner[4](Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))))), Outer(Inner[4](Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))))), Outer(Inner[4](Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))))), Outer(Inner[4](Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf)))))); { - uint v_10 = 0u; - v_10 = 0u; + uint v_11 = 0u; + v_11 = 0u; while(true) { - uint v_11 = v_10; - if ((v_11 >= 4u)) { + uint v_12 = v_11; + if ((v_12 >= 4u)) { break; } - v_9[v_11] = tint_convert_Outer(v_8[v_11]); + v_10[v_12] = tint_convert_Outer(v_9[v_12]); { - v_10 = (v_11 + 1u); + v_11 = (v_12 + 1u); } continue; } } - Outer l_a[4] = v_9; - Outer l_a_i = tint_convert_Outer(v.inner[v_4]); - Inner_std140 v_12[4] = v.inner[v_4].a; - Inner v_13[4] = Inner[4](Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf)))); + Outer l_a[4] = v_10; + Outer l_a_i = tint_convert_Outer(v.inner[v_5]); + Inner_std140 v_13[4] = v.inner[v_5].a; + Inner v_14[4] = Inner[4](Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf))), Inner(f16mat4x2(f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf), f16vec2(0.0hf)))); { - uint v_14 = 0u; - v_14 = 0u; + uint v_15 = 0u; + v_15 = 0u; while(true) { - uint v_15 = v_14; - if ((v_15 >= 4u)) { + uint v_16 = v_15; + if ((v_16 >= 4u)) { break; } - v_13[v_15] = tint_convert_Inner(v_12[v_15]); + v_14[v_16] = tint_convert_Inner(v_13[v_16]); { - v_14 = (v_15 + 1u); + v_15 = (v_16 + 1u); } continue; } } - Inner l_a_i_a[4] = v_13; - Inner l_a_i_a_i = tint_convert_Inner(v.inner[v_4].a[v_5]); - f16mat4x2 l_a_i_a_i_m = v_6; - f16vec2 l_a_i_a_i_m_i = v_7; - float16_t l_a_i_a_i_m_i_i = v_7[min(uint(i()), 1u)]; + Inner l_a_i_a[4] = v_14; + Inner l_a_i_a_i = tint_convert_Inner(v.inner[v_5].a[v_6]); + f16mat4x2 l_a_i_a_i_m = v_7; + f16vec2 l_a_i_a_i_m_i = v_8; + float16_t l_a_i_a_i_m_i_i = v_8[min(uint(i()), 1u)]; }
diff --git a/test/tint/buffer/uniform/std140/struct/mat4x2_f16/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/struct/mat4x2_f16/dynamic_index_via_ptr.wgsl.expected.spvasm index ccc4c2d..3e52edf 100644 --- a/test/tint/buffer/uniform/std140/struct/mat4x2_f16/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/struct/mat4x2_f16/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,13 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 216 +; Bound: 219 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess - %33 = OpExtInstImport "GLSL.std.450" + %36 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -76,7 +76,7 @@ %17 = OpTypeFunction %int %int_1 = OpConstant %int 1 %void = OpTypeVoid - %25 = OpTypeFunction %void + %28 = OpTypeFunction %void %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 = OpTypePointer Uniform %_arr_Outer_std140_tint_explicit_layout_uint_4 %uint_0 = OpConstant %uint 0 %uint_3 = OpConstant %uint 3 @@ -98,248 +98,251 @@ %Outer = OpTypeStruct %_arr_Inner_uint_4 %_arr_Outer_uint_4 = OpTypeArray %Outer %uint_4 %_ptr_Function__arr_Outer_uint_4 = OpTypePointer Function %_arr_Outer_uint_4 - %79 = OpConstantNull %_arr_Outer_uint_4 + %82 = OpConstantNull %_arr_Outer_uint_4 %_ptr_Function__arr_Inner_std140_uint_4_0 = OpTypePointer Function %_arr_Inner_std140_uint_4_0 %_ptr_Function__arr_Inner_uint_4 = OpTypePointer Function %_arr_Inner_uint_4 - %100 = OpConstantNull %_arr_Inner_uint_4 + %103 = OpConstantNull %_arr_Inner_uint_4 %bool = OpTypeBool %_ptr_Function_Outer = OpTypePointer Function %Outer %_ptr_Function_Outer_std140 = OpTypePointer Function %Outer_std140 %_ptr_Function_Inner = OpTypePointer Function %Inner %_ptr_Function_Inner_std140 = OpTypePointer Function %Inner_std140 - %136 = OpTypeFunction %Inner %Inner_std140 - %145 = OpTypeFunction %Outer %Outer_std140 - %167 = OpTypeFunction %_arr_Inner_std140_uint_4_0 %_arr_Inner_std140_uint_4 + %139 = OpTypeFunction %Inner %Inner_std140 + %148 = OpTypeFunction %Outer %Outer_std140 + %170 = OpTypeFunction %_arr_Inner_std140_uint_4_0 %_arr_Inner_std140_uint_4 %_ptr_Function__arr_Inner_std140_uint_4 = OpTypePointer Function %_arr_Inner_std140_uint_4 - %172 = OpConstantNull %_arr_Inner_std140_uint_4_0 - %188 = OpTypeFunction %Outer_std140 %Outer_std140_tint_explicit_layout - %194 = OpTypeFunction %_arr_Outer_std140_uint_4 %_arr_Outer_std140_tint_explicit_layout_uint_4 + %175 = OpConstantNull %_arr_Inner_std140_uint_4_0 + %191 = OpTypeFunction %Outer_std140 %Outer_std140_tint_explicit_layout + %197 = OpTypeFunction %_arr_Outer_std140_uint_4 %_arr_Outer_std140_tint_explicit_layout_uint_4 %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 = OpTypePointer Function %_arr_Outer_std140_tint_explicit_layout_uint_4 - %199 = OpConstantNull %_arr_Outer_std140_uint_4 + %202 = OpConstantNull %_arr_Outer_std140_uint_4 %_ptr_Function_Outer_std140_tint_explicit_layout = OpTypePointer Function %Outer_std140_tint_explicit_layout %i = OpFunction %int None %17 %18 = OpLabel %19 = OpLoad %int %counter None - %20 = OpIAdd %int %19 %int_1 - OpStore %counter %20 None - %22 = OpLoad %int %counter None - OpReturnValue %22 + %20 = OpBitcast %uint %19 + %21 = OpBitcast %uint %int_1 + %23 = OpIAdd %uint %20 %21 + %24 = OpBitcast %int %23 + OpStore %counter %24 None + %25 = OpLoad %int %counter None + OpReturnValue %25 OpFunctionEnd - %f = OpFunction %void None %25 - %26 = OpLabel - %57 = OpVariable %_ptr_Function_mat4v2half Function - %71 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function - %73 = OpVariable %_ptr_Function__arr_Outer_uint_4 Function %79 - %96 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function - %98 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %100 - %27 = OpAccessChain %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 %1 %uint_0 - %30 = OpFunctionCall %int %i - %31 = OpBitcast %uint %30 - %32 = OpExtInst %uint %33 UMin %31 %uint_3 - %35 = OpAccessChain %_ptr_Uniform_Outer_std140_tint_explicit_layout %27 %32 - %37 = OpAccessChain %_ptr_Uniform__arr_Inner_std140_uint_4 %35 %uint_0 - %39 = OpFunctionCall %int %i - %40 = OpBitcast %uint %39 - %41 = OpExtInst %uint %33 UMin %40 %uint_3 - %42 = OpAccessChain %_ptr_Uniform_Inner_std140 %37 %41 - %44 = OpAccessChain %_ptr_Uniform_v2half %42 %uint_0 - %46 = OpLoad %v2half %44 None - %47 = OpAccessChain %_ptr_Uniform_v2half %42 %uint_1 + %f = OpFunction %void None %28 + %29 = OpLabel + %60 = OpVariable %_ptr_Function_mat4v2half Function + %74 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function + %76 = OpVariable %_ptr_Function__arr_Outer_uint_4 Function %82 + %99 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function + %101 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %103 + %30 = OpAccessChain %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 %1 %uint_0 + %33 = OpFunctionCall %int %i + %34 = OpBitcast %uint %33 + %35 = OpExtInst %uint %36 UMin %34 %uint_3 + %38 = OpAccessChain %_ptr_Uniform_Outer_std140_tint_explicit_layout %30 %35 + %40 = OpAccessChain %_ptr_Uniform__arr_Inner_std140_uint_4 %38 %uint_0 + %42 = OpFunctionCall %int %i + %43 = OpBitcast %uint %42 + %44 = OpExtInst %uint %36 UMin %43 %uint_3 + %45 = OpAccessChain %_ptr_Uniform_Inner_std140 %40 %44 + %47 = OpAccessChain %_ptr_Uniform_v2half %45 %uint_0 %49 = OpLoad %v2half %47 None - %50 = OpAccessChain %_ptr_Uniform_v2half %42 %uint_2 + %50 = OpAccessChain %_ptr_Uniform_v2half %45 %uint_1 %52 = OpLoad %v2half %50 None - %53 = OpAccessChain %_ptr_Uniform_v2half %42 %uint_3 - %54 = OpLoad %v2half %53 None -%l_a_i_a_i_m = OpCompositeConstruct %mat4v2half %46 %49 %52 %54 - OpStore %57 %l_a_i_a_i_m - %59 = OpFunctionCall %int %i - %60 = OpBitcast %uint %59 - %61 = OpExtInst %uint %33 UMin %60 %uint_3 - %62 = OpAccessChain %_ptr_Function_v2half %57 %61 -%l_a_i_a_i_m_i = OpLoad %v2half %62 None - %65 = OpLoad %_arr_Outer_std140_tint_explicit_layout_uint_4 %27 None - %66 = OpFunctionCall %_arr_Outer_std140_uint_4 %tint_convert_explicit_layout_1 %65 - OpStore %71 %66 - OpBranch %80 - %80 = OpLabel + %53 = OpAccessChain %_ptr_Uniform_v2half %45 %uint_2 + %55 = OpLoad %v2half %53 None + %56 = OpAccessChain %_ptr_Uniform_v2half %45 %uint_3 + %57 = OpLoad %v2half %56 None +%l_a_i_a_i_m = OpCompositeConstruct %mat4v2half %49 %52 %55 %57 + OpStore %60 %l_a_i_a_i_m + %62 = OpFunctionCall %int %i + %63 = OpBitcast %uint %62 + %64 = OpExtInst %uint %36 UMin %63 %uint_3 + %65 = OpAccessChain %_ptr_Function_v2half %60 %64 +%l_a_i_a_i_m_i = OpLoad %v2half %65 None + %68 = OpLoad %_arr_Outer_std140_tint_explicit_layout_uint_4 %30 None + %69 = OpFunctionCall %_arr_Outer_std140_uint_4 %tint_convert_explicit_layout_1 %68 + OpStore %74 %69 OpBranch %83 %83 = OpLabel - %85 = OpPhi %uint %uint_0 %80 %86 %82 - OpLoopMerge %84 %82 None - OpBranch %81 - %81 = OpLabel - %116 = OpUGreaterThanEqual %bool %85 %uint_4 - OpSelectionMerge %118 None - OpBranchConditional %116 %119 %118 - %119 = OpLabel + OpBranch %86 + %86 = OpLabel + %88 = OpPhi %uint %uint_0 %83 %89 %85 + OpLoopMerge %87 %85 None OpBranch %84 - %118 = OpLabel - %120 = OpAccessChain %_ptr_Function_Outer %73 %85 - %122 = OpAccessChain %_ptr_Function_Outer_std140 %71 %85 - %124 = OpLoad %Outer_std140 %122 None - %125 = OpFunctionCall %Outer %tint_convert_Outer %124 - OpStore %120 %125 None - OpBranch %82 - %82 = OpLabel - %86 = OpIAdd %uint %85 %uint_1 - OpBranch %83 %84 = OpLabel - %l_a = OpLoad %_arr_Outer_uint_4 %73 None - %88 = OpLoad %Outer_std140_tint_explicit_layout %35 None - %89 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %88 - %l_a_i = OpFunctionCall %Outer %tint_convert_Outer %89 - %93 = OpLoad %_arr_Inner_std140_uint_4 %37 None - %94 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %93 - OpStore %96 %94 - OpBranch %101 - %101 = OpLabel + %119 = OpUGreaterThanEqual %bool %88 %uint_4 + OpSelectionMerge %121 None + OpBranchConditional %119 %122 %121 + %122 = OpLabel + OpBranch %87 + %121 = OpLabel + %123 = OpAccessChain %_ptr_Function_Outer %76 %88 + %125 = OpAccessChain %_ptr_Function_Outer_std140 %74 %88 + %127 = OpLoad %Outer_std140 %125 None + %128 = OpFunctionCall %Outer %tint_convert_Outer %127 + OpStore %123 %128 None + OpBranch %85 + %85 = OpLabel + %89 = OpIAdd %uint %88 %uint_1 + OpBranch %86 + %87 = OpLabel + %l_a = OpLoad %_arr_Outer_uint_4 %76 None + %91 = OpLoad %Outer_std140_tint_explicit_layout %38 None + %92 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %91 + %l_a_i = OpFunctionCall %Outer %tint_convert_Outer %92 + %96 = OpLoad %_arr_Inner_std140_uint_4 %40 None + %97 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %96 + OpStore %99 %97 OpBranch %104 %104 = OpLabel - %106 = OpPhi %uint %uint_0 %101 %107 %103 - OpLoopMerge %105 %103 None - OpBranch %102 - %102 = OpLabel - %126 = OpUGreaterThanEqual %bool %106 %uint_4 - OpSelectionMerge %127 None - OpBranchConditional %126 %128 %127 - %128 = OpLabel + OpBranch %107 + %107 = OpLabel + %109 = OpPhi %uint %uint_0 %104 %110 %106 + OpLoopMerge %108 %106 None OpBranch %105 - %127 = OpLabel - %129 = OpAccessChain %_ptr_Function_Inner %98 %106 - %131 = OpAccessChain %_ptr_Function_Inner_std140 %96 %106 - %133 = OpLoad %Inner_std140 %131 None - %134 = OpFunctionCall %Inner %tint_convert_Inner %133 - OpStore %129 %134 None - OpBranch %103 - %103 = OpLabel - %107 = OpIAdd %uint %106 %uint_1 - OpBranch %104 %105 = OpLabel - %l_a_i_a = OpLoad %_arr_Inner_uint_4 %98 None - %109 = OpLoad %Inner_std140 %42 None - %l_a_i_a_i = OpFunctionCall %Inner %tint_convert_Inner %109 - %112 = OpFunctionCall %int %i - %113 = OpBitcast %uint %112 - %114 = OpExtInst %uint %33 UMin %113 %uint_1 -%l_a_i_a_i_m_i_i = OpVectorExtractDynamic %half %l_a_i_a_i_m_i %114 + %129 = OpUGreaterThanEqual %bool %109 %uint_4 + OpSelectionMerge %130 None + OpBranchConditional %129 %131 %130 + %131 = OpLabel + OpBranch %108 + %130 = OpLabel + %132 = OpAccessChain %_ptr_Function_Inner %101 %109 + %134 = OpAccessChain %_ptr_Function_Inner_std140 %99 %109 + %136 = OpLoad %Inner_std140 %134 None + %137 = OpFunctionCall %Inner %tint_convert_Inner %136 + OpStore %132 %137 None + OpBranch %106 + %106 = OpLabel + %110 = OpIAdd %uint %109 %uint_1 + OpBranch %107 + %108 = OpLabel + %l_a_i_a = OpLoad %_arr_Inner_uint_4 %101 None + %112 = OpLoad %Inner_std140 %45 None + %l_a_i_a_i = OpFunctionCall %Inner %tint_convert_Inner %112 + %115 = OpFunctionCall %int %i + %116 = OpBitcast %uint %115 + %117 = OpExtInst %uint %36 UMin %116 %uint_1 +%l_a_i_a_i_m_i_i = OpVectorExtractDynamic %half %l_a_i_a_i_m_i %117 OpReturn OpFunctionEnd -%tint_convert_Inner = OpFunction %Inner None %136 +%tint_convert_Inner = OpFunction %Inner None %139 %tint_input = OpFunctionParameter %Inner_std140 - %137 = OpLabel - %138 = OpCompositeExtract %v2half %tint_input 0 - %139 = OpCompositeExtract %v2half %tint_input 1 - %140 = OpCompositeExtract %v2half %tint_input 2 - %141 = OpCompositeExtract %v2half %tint_input 3 - %142 = OpCompositeConstruct %mat4v2half %138 %139 %140 %141 - %143 = OpCompositeConstruct %Inner %142 - OpReturnValue %143 + %140 = OpLabel + %141 = OpCompositeExtract %v2half %tint_input 0 + %142 = OpCompositeExtract %v2half %tint_input 1 + %143 = OpCompositeExtract %v2half %tint_input 2 + %144 = OpCompositeExtract %v2half %tint_input 3 + %145 = OpCompositeConstruct %mat4v2half %141 %142 %143 %144 + %146 = OpCompositeConstruct %Inner %145 + OpReturnValue %146 OpFunctionEnd -%tint_convert_Outer = OpFunction %Outer None %145 +%tint_convert_Outer = OpFunction %Outer None %148 %tint_input_0 = OpFunctionParameter %Outer_std140 - %146 = OpLabel - %148 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function - %149 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %100 - %147 = OpCompositeExtract %_arr_Inner_std140_uint_4_0 %tint_input_0 0 - OpStore %148 %147 - OpBranch %150 - %150 = OpLabel + %149 = OpLabel + %151 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function + %152 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %103 + %150 = OpCompositeExtract %_arr_Inner_std140_uint_4_0 %tint_input_0 0 + OpStore %151 %150 OpBranch %153 %153 = OpLabel - %155 = OpPhi %uint %uint_0 %150 %156 %152 - OpLoopMerge %154 %152 None - OpBranch %151 - %151 = OpLabel - %159 = OpUGreaterThanEqual %bool %155 %uint_4 - OpSelectionMerge %160 None - OpBranchConditional %159 %161 %160 - %161 = OpLabel + OpBranch %156 + %156 = OpLabel + %158 = OpPhi %uint %uint_0 %153 %159 %155 + OpLoopMerge %157 %155 None OpBranch %154 - %160 = OpLabel - %162 = OpAccessChain %_ptr_Function_Inner %149 %155 - %163 = OpAccessChain %_ptr_Function_Inner_std140 %148 %155 - %164 = OpLoad %Inner_std140 %163 None - %165 = OpFunctionCall %Inner %tint_convert_Inner %164 - OpStore %162 %165 None - OpBranch %152 - %152 = OpLabel - %156 = OpIAdd %uint %155 %uint_1 - OpBranch %153 %154 = OpLabel - %157 = OpLoad %_arr_Inner_uint_4 %149 None - %158 = OpCompositeConstruct %Outer %157 - OpReturnValue %158 + %162 = OpUGreaterThanEqual %bool %158 %uint_4 + OpSelectionMerge %163 None + OpBranchConditional %162 %164 %163 + %164 = OpLabel + OpBranch %157 + %163 = OpLabel + %165 = OpAccessChain %_ptr_Function_Inner %152 %158 + %166 = OpAccessChain %_ptr_Function_Inner_std140 %151 %158 + %167 = OpLoad %Inner_std140 %166 None + %168 = OpFunctionCall %Inner %tint_convert_Inner %167 + OpStore %165 %168 None + OpBranch %155 + %155 = OpLabel + %159 = OpIAdd %uint %158 %uint_1 + OpBranch %156 + %157 = OpLabel + %160 = OpLoad %_arr_Inner_uint_4 %152 None + %161 = OpCompositeConstruct %Outer %160 + OpReturnValue %161 OpFunctionEnd -%tint_convert_explicit_layout = OpFunction %_arr_Inner_std140_uint_4_0 None %167 +%tint_convert_explicit_layout = OpFunction %_arr_Inner_std140_uint_4_0 None %170 %tint_source = OpFunctionParameter %_arr_Inner_std140_uint_4 - %168 = OpLabel - %169 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4 Function - %171 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function %172 - OpStore %169 %tint_source - OpBranch %173 - %173 = OpLabel + %171 = OpLabel + %172 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4 Function + %174 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function %175 + OpStore %172 %tint_source OpBranch %176 %176 = OpLabel - %178 = OpPhi %uint %uint_0 %173 %179 %175 - OpLoopMerge %177 %175 None - OpBranch %174 - %174 = OpLabel - %181 = OpUGreaterThanEqual %bool %178 %uint_4 - OpSelectionMerge %182 None - OpBranchConditional %181 %183 %182 - %183 = OpLabel + OpBranch %179 + %179 = OpLabel + %181 = OpPhi %uint %uint_0 %176 %182 %178 + OpLoopMerge %180 %178 None OpBranch %177 - %182 = OpLabel - %184 = OpAccessChain %_ptr_Function_Inner_std140 %169 %178 - %185 = OpLoad %Inner_std140 %184 None - %186 = OpAccessChain %_ptr_Function_Inner_std140 %171 %178 - OpStore %186 %185 None - OpBranch %175 - %175 = OpLabel - %179 = OpIAdd %uint %178 %uint_1 - OpBranch %176 %177 = OpLabel - %180 = OpLoad %_arr_Inner_std140_uint_4_0 %171 None - OpReturnValue %180 + %184 = OpUGreaterThanEqual %bool %181 %uint_4 + OpSelectionMerge %185 None + OpBranchConditional %184 %186 %185 + %186 = OpLabel + OpBranch %180 + %185 = OpLabel + %187 = OpAccessChain %_ptr_Function_Inner_std140 %172 %181 + %188 = OpLoad %Inner_std140 %187 None + %189 = OpAccessChain %_ptr_Function_Inner_std140 %174 %181 + OpStore %189 %188 None + OpBranch %178 + %178 = OpLabel + %182 = OpIAdd %uint %181 %uint_1 + OpBranch %179 + %180 = OpLabel + %183 = OpLoad %_arr_Inner_std140_uint_4_0 %174 None + OpReturnValue %183 OpFunctionEnd -%tint_convert_explicit_layout_0 = OpFunction %Outer_std140 None %188 +%tint_convert_explicit_layout_0 = OpFunction %Outer_std140 None %191 %tint_source_0 = OpFunctionParameter %Outer_std140_tint_explicit_layout - %189 = OpLabel - %190 = OpCompositeExtract %_arr_Inner_std140_uint_4 %tint_source_0 0 - %191 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %190 - %192 = OpCompositeConstruct %Outer_std140 %191 - OpReturnValue %192 + %192 = OpLabel + %193 = OpCompositeExtract %_arr_Inner_std140_uint_4 %tint_source_0 0 + %194 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %193 + %195 = OpCompositeConstruct %Outer_std140 %194 + OpReturnValue %195 OpFunctionEnd -%tint_convert_explicit_layout_1 = OpFunction %_arr_Outer_std140_uint_4 None %194 +%tint_convert_explicit_layout_1 = OpFunction %_arr_Outer_std140_uint_4 None %197 %tint_source_1 = OpFunctionParameter %_arr_Outer_std140_tint_explicit_layout_uint_4 - %195 = OpLabel - %196 = OpVariable %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 Function - %198 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function %199 - OpStore %196 %tint_source_1 - OpBranch %200 - %200 = OpLabel + %198 = OpLabel + %199 = OpVariable %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 Function + %201 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function %202 + OpStore %199 %tint_source_1 OpBranch %203 %203 = OpLabel - %205 = OpPhi %uint %uint_0 %200 %206 %202 - OpLoopMerge %204 %202 None - OpBranch %201 - %201 = OpLabel - %208 = OpUGreaterThanEqual %bool %205 %uint_4 - OpSelectionMerge %209 None - OpBranchConditional %208 %210 %209 - %210 = OpLabel + OpBranch %206 + %206 = OpLabel + %208 = OpPhi %uint %uint_0 %203 %209 %205 + OpLoopMerge %207 %205 None OpBranch %204 - %209 = OpLabel - %211 = OpAccessChain %_ptr_Function_Outer_std140_tint_explicit_layout %196 %205 - %213 = OpLoad %Outer_std140_tint_explicit_layout %211 None - %214 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %213 - %215 = OpAccessChain %_ptr_Function_Outer_std140 %198 %205 - OpStore %215 %214 None - OpBranch %202 - %202 = OpLabel - %206 = OpIAdd %uint %205 %uint_1 - OpBranch %203 %204 = OpLabel - %207 = OpLoad %_arr_Outer_std140_uint_4 %198 None - OpReturnValue %207 + %211 = OpUGreaterThanEqual %bool %208 %uint_4 + OpSelectionMerge %212 None + OpBranchConditional %211 %213 %212 + %213 = OpLabel + OpBranch %207 + %212 = OpLabel + %214 = OpAccessChain %_ptr_Function_Outer_std140_tint_explicit_layout %199 %208 + %216 = OpLoad %Outer_std140_tint_explicit_layout %214 None + %217 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %216 + %218 = OpAccessChain %_ptr_Function_Outer_std140 %201 %208 + OpStore %218 %217 None + OpBranch %205 + %205 = OpLabel + %209 = OpIAdd %uint %208 %uint_1 + OpBranch %206 + %207 = OpLabel + %210 = OpLoad %_arr_Outer_std140_uint_4 %201 None + OpReturnValue %210 OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/struct/mat4x2_f32/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/struct/mat4x2_f32/dynamic_index_via_ptr.wgsl.expected.glsl index b59e62e..b026d87 100644 --- a/test/tint/buffer/uniform/std140/struct/mat4x2_f32/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/struct/mat4x2_f32/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -34,76 +34,77 @@ } v; int counter = 0; int i() { - counter = (counter + 1); + uint v_1 = uint(counter); + counter = int((v_1 + uint(1))); return counter; } Inner tint_convert_Inner(Inner_std140 tint_input) { return Inner(mat4x2(tint_input.m_col0, tint_input.m_col1, tint_input.m_col2, tint_input.m_col3)); } Outer tint_convert_Outer(Outer_std140 tint_input) { - Inner v_1[4] = Inner[4](Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f)))); + Inner v_2[4] = Inner[4](Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f)))); { - uint v_2 = 0u; - v_2 = 0u; + uint v_3 = 0u; + v_3 = 0u; while(true) { - uint v_3 = v_2; - if ((v_3 >= 4u)) { + uint v_4 = v_3; + if ((v_4 >= 4u)) { break; } - v_1[v_3] = tint_convert_Inner(tint_input.a[v_3]); + v_2[v_4] = tint_convert_Inner(tint_input.a[v_4]); { - v_2 = (v_3 + 1u); + v_3 = (v_4 + 1u); } continue; } } - return Outer(v_1); + return Outer(v_2); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - uint v_4 = min(uint(i()), 3u); uint v_5 = min(uint(i()), 3u); - mat4x2 v_6 = mat4x2(v.inner[v_4].a[v_5].m_col0, v.inner[v_4].a[v_5].m_col1, v.inner[v_4].a[v_5].m_col2, v.inner[v_4].a[v_5].m_col3); - vec2 v_7 = v_6[min(uint(i()), 3u)]; - Outer_std140 v_8[4] = v.inner; - Outer v_9[4] = Outer[4](Outer(Inner[4](Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))))), Outer(Inner[4](Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))))), Outer(Inner[4](Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))))), Outer(Inner[4](Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f)))))); + uint v_6 = min(uint(i()), 3u); + mat4x2 v_7 = mat4x2(v.inner[v_5].a[v_6].m_col0, v.inner[v_5].a[v_6].m_col1, v.inner[v_5].a[v_6].m_col2, v.inner[v_5].a[v_6].m_col3); + vec2 v_8 = v_7[min(uint(i()), 3u)]; + Outer_std140 v_9[4] = v.inner; + Outer v_10[4] = Outer[4](Outer(Inner[4](Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))))), Outer(Inner[4](Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))))), Outer(Inner[4](Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))))), Outer(Inner[4](Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f)))))); { - uint v_10 = 0u; - v_10 = 0u; + uint v_11 = 0u; + v_11 = 0u; while(true) { - uint v_11 = v_10; - if ((v_11 >= 4u)) { + uint v_12 = v_11; + if ((v_12 >= 4u)) { break; } - v_9[v_11] = tint_convert_Outer(v_8[v_11]); + v_10[v_12] = tint_convert_Outer(v_9[v_12]); { - v_10 = (v_11 + 1u); + v_11 = (v_12 + 1u); } continue; } } - Outer l_a[4] = v_9; - Outer l_a_i = tint_convert_Outer(v.inner[v_4]); - Inner_std140 v_12[4] = v.inner[v_4].a; - Inner v_13[4] = Inner[4](Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f)))); + Outer l_a[4] = v_10; + Outer l_a_i = tint_convert_Outer(v.inner[v_5]); + Inner_std140 v_13[4] = v.inner[v_5].a; + Inner v_14[4] = Inner[4](Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f))), Inner(mat4x2(vec2(0.0f), vec2(0.0f), vec2(0.0f), vec2(0.0f)))); { - uint v_14 = 0u; - v_14 = 0u; + uint v_15 = 0u; + v_15 = 0u; while(true) { - uint v_15 = v_14; - if ((v_15 >= 4u)) { + uint v_16 = v_15; + if ((v_16 >= 4u)) { break; } - v_13[v_15] = tint_convert_Inner(v_12[v_15]); + v_14[v_16] = tint_convert_Inner(v_13[v_16]); { - v_14 = (v_15 + 1u); + v_15 = (v_16 + 1u); } continue; } } - Inner l_a_i_a[4] = v_13; - Inner l_a_i_a_i = tint_convert_Inner(v.inner[v_4].a[v_5]); - mat4x2 l_a_i_a_i_m = v_6; - vec2 l_a_i_a_i_m_i = v_7; - float l_a_i_a_i_m_i_i = v_7[min(uint(i()), 1u)]; + Inner l_a_i_a[4] = v_14; + Inner l_a_i_a_i = tint_convert_Inner(v.inner[v_5].a[v_6]); + mat4x2 l_a_i_a_i_m = v_7; + vec2 l_a_i_a_i_m_i = v_8; + float l_a_i_a_i_m_i_i = v_8[min(uint(i()), 1u)]; }
diff --git a/test/tint/buffer/uniform/std140/struct/mat4x2_f32/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/struct/mat4x2_f32/dynamic_index_via_ptr.wgsl.expected.spvasm index f7b2786..3106e72 100644 --- a/test/tint/buffer/uniform/std140/struct/mat4x2_f32/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/struct/mat4x2_f32/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,10 +1,10 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 216 +; Bound: 219 ; Schema: 0 OpCapability Shader - %33 = OpExtInstImport "GLSL.std.450" + %36 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -73,7 +73,7 @@ %17 = OpTypeFunction %int %int_1 = OpConstant %int 1 %void = OpTypeVoid - %25 = OpTypeFunction %void + %28 = OpTypeFunction %void %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 = OpTypePointer Uniform %_arr_Outer_std140_tint_explicit_layout_uint_4 %uint_0 = OpConstant %uint 0 %uint_3 = OpConstant %uint 3 @@ -95,248 +95,251 @@ %Outer = OpTypeStruct %_arr_Inner_uint_4 %_arr_Outer_uint_4 = OpTypeArray %Outer %uint_4 %_ptr_Function__arr_Outer_uint_4 = OpTypePointer Function %_arr_Outer_uint_4 - %79 = OpConstantNull %_arr_Outer_uint_4 + %82 = OpConstantNull %_arr_Outer_uint_4 %_ptr_Function__arr_Inner_std140_uint_4_0 = OpTypePointer Function %_arr_Inner_std140_uint_4_0 %_ptr_Function__arr_Inner_uint_4 = OpTypePointer Function %_arr_Inner_uint_4 - %100 = OpConstantNull %_arr_Inner_uint_4 + %103 = OpConstantNull %_arr_Inner_uint_4 %bool = OpTypeBool %_ptr_Function_Outer = OpTypePointer Function %Outer %_ptr_Function_Outer_std140 = OpTypePointer Function %Outer_std140 %_ptr_Function_Inner = OpTypePointer Function %Inner %_ptr_Function_Inner_std140 = OpTypePointer Function %Inner_std140 - %136 = OpTypeFunction %Inner %Inner_std140 - %145 = OpTypeFunction %Outer %Outer_std140 - %167 = OpTypeFunction %_arr_Inner_std140_uint_4_0 %_arr_Inner_std140_uint_4 + %139 = OpTypeFunction %Inner %Inner_std140 + %148 = OpTypeFunction %Outer %Outer_std140 + %170 = OpTypeFunction %_arr_Inner_std140_uint_4_0 %_arr_Inner_std140_uint_4 %_ptr_Function__arr_Inner_std140_uint_4 = OpTypePointer Function %_arr_Inner_std140_uint_4 - %172 = OpConstantNull %_arr_Inner_std140_uint_4_0 - %188 = OpTypeFunction %Outer_std140 %Outer_std140_tint_explicit_layout - %194 = OpTypeFunction %_arr_Outer_std140_uint_4 %_arr_Outer_std140_tint_explicit_layout_uint_4 + %175 = OpConstantNull %_arr_Inner_std140_uint_4_0 + %191 = OpTypeFunction %Outer_std140 %Outer_std140_tint_explicit_layout + %197 = OpTypeFunction %_arr_Outer_std140_uint_4 %_arr_Outer_std140_tint_explicit_layout_uint_4 %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 = OpTypePointer Function %_arr_Outer_std140_tint_explicit_layout_uint_4 - %199 = OpConstantNull %_arr_Outer_std140_uint_4 + %202 = OpConstantNull %_arr_Outer_std140_uint_4 %_ptr_Function_Outer_std140_tint_explicit_layout = OpTypePointer Function %Outer_std140_tint_explicit_layout %i = OpFunction %int None %17 %18 = OpLabel %19 = OpLoad %int %counter None - %20 = OpIAdd %int %19 %int_1 - OpStore %counter %20 None - %22 = OpLoad %int %counter None - OpReturnValue %22 + %20 = OpBitcast %uint %19 + %21 = OpBitcast %uint %int_1 + %23 = OpIAdd %uint %20 %21 + %24 = OpBitcast %int %23 + OpStore %counter %24 None + %25 = OpLoad %int %counter None + OpReturnValue %25 OpFunctionEnd - %f = OpFunction %void None %25 - %26 = OpLabel - %57 = OpVariable %_ptr_Function_mat4v2float Function - %71 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function - %73 = OpVariable %_ptr_Function__arr_Outer_uint_4 Function %79 - %96 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function - %98 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %100 - %27 = OpAccessChain %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 %1 %uint_0 - %30 = OpFunctionCall %int %i - %31 = OpBitcast %uint %30 - %32 = OpExtInst %uint %33 UMin %31 %uint_3 - %35 = OpAccessChain %_ptr_Uniform_Outer_std140_tint_explicit_layout %27 %32 - %37 = OpAccessChain %_ptr_Uniform__arr_Inner_std140_uint_4 %35 %uint_0 - %39 = OpFunctionCall %int %i - %40 = OpBitcast %uint %39 - %41 = OpExtInst %uint %33 UMin %40 %uint_3 - %42 = OpAccessChain %_ptr_Uniform_Inner_std140 %37 %41 - %44 = OpAccessChain %_ptr_Uniform_v2float %42 %uint_0 - %46 = OpLoad %v2float %44 None - %47 = OpAccessChain %_ptr_Uniform_v2float %42 %uint_1 + %f = OpFunction %void None %28 + %29 = OpLabel + %60 = OpVariable %_ptr_Function_mat4v2float Function + %74 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function + %76 = OpVariable %_ptr_Function__arr_Outer_uint_4 Function %82 + %99 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function + %101 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %103 + %30 = OpAccessChain %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 %1 %uint_0 + %33 = OpFunctionCall %int %i + %34 = OpBitcast %uint %33 + %35 = OpExtInst %uint %36 UMin %34 %uint_3 + %38 = OpAccessChain %_ptr_Uniform_Outer_std140_tint_explicit_layout %30 %35 + %40 = OpAccessChain %_ptr_Uniform__arr_Inner_std140_uint_4 %38 %uint_0 + %42 = OpFunctionCall %int %i + %43 = OpBitcast %uint %42 + %44 = OpExtInst %uint %36 UMin %43 %uint_3 + %45 = OpAccessChain %_ptr_Uniform_Inner_std140 %40 %44 + %47 = OpAccessChain %_ptr_Uniform_v2float %45 %uint_0 %49 = OpLoad %v2float %47 None - %50 = OpAccessChain %_ptr_Uniform_v2float %42 %uint_2 + %50 = OpAccessChain %_ptr_Uniform_v2float %45 %uint_1 %52 = OpLoad %v2float %50 None - %53 = OpAccessChain %_ptr_Uniform_v2float %42 %uint_3 - %54 = OpLoad %v2float %53 None -%l_a_i_a_i_m = OpCompositeConstruct %mat4v2float %46 %49 %52 %54 - OpStore %57 %l_a_i_a_i_m - %59 = OpFunctionCall %int %i - %60 = OpBitcast %uint %59 - %61 = OpExtInst %uint %33 UMin %60 %uint_3 - %62 = OpAccessChain %_ptr_Function_v2float %57 %61 -%l_a_i_a_i_m_i = OpLoad %v2float %62 None - %65 = OpLoad %_arr_Outer_std140_tint_explicit_layout_uint_4 %27 None - %66 = OpFunctionCall %_arr_Outer_std140_uint_4 %tint_convert_explicit_layout_1 %65 - OpStore %71 %66 - OpBranch %80 - %80 = OpLabel + %53 = OpAccessChain %_ptr_Uniform_v2float %45 %uint_2 + %55 = OpLoad %v2float %53 None + %56 = OpAccessChain %_ptr_Uniform_v2float %45 %uint_3 + %57 = OpLoad %v2float %56 None +%l_a_i_a_i_m = OpCompositeConstruct %mat4v2float %49 %52 %55 %57 + OpStore %60 %l_a_i_a_i_m + %62 = OpFunctionCall %int %i + %63 = OpBitcast %uint %62 + %64 = OpExtInst %uint %36 UMin %63 %uint_3 + %65 = OpAccessChain %_ptr_Function_v2float %60 %64 +%l_a_i_a_i_m_i = OpLoad %v2float %65 None + %68 = OpLoad %_arr_Outer_std140_tint_explicit_layout_uint_4 %30 None + %69 = OpFunctionCall %_arr_Outer_std140_uint_4 %tint_convert_explicit_layout_1 %68 + OpStore %74 %69 OpBranch %83 %83 = OpLabel - %85 = OpPhi %uint %uint_0 %80 %86 %82 - OpLoopMerge %84 %82 None - OpBranch %81 - %81 = OpLabel - %116 = OpUGreaterThanEqual %bool %85 %uint_4 - OpSelectionMerge %118 None - OpBranchConditional %116 %119 %118 - %119 = OpLabel + OpBranch %86 + %86 = OpLabel + %88 = OpPhi %uint %uint_0 %83 %89 %85 + OpLoopMerge %87 %85 None OpBranch %84 - %118 = OpLabel - %120 = OpAccessChain %_ptr_Function_Outer %73 %85 - %122 = OpAccessChain %_ptr_Function_Outer_std140 %71 %85 - %124 = OpLoad %Outer_std140 %122 None - %125 = OpFunctionCall %Outer %tint_convert_Outer %124 - OpStore %120 %125 None - OpBranch %82 - %82 = OpLabel - %86 = OpIAdd %uint %85 %uint_1 - OpBranch %83 %84 = OpLabel - %l_a = OpLoad %_arr_Outer_uint_4 %73 None - %88 = OpLoad %Outer_std140_tint_explicit_layout %35 None - %89 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %88 - %l_a_i = OpFunctionCall %Outer %tint_convert_Outer %89 - %93 = OpLoad %_arr_Inner_std140_uint_4 %37 None - %94 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %93 - OpStore %96 %94 - OpBranch %101 - %101 = OpLabel + %119 = OpUGreaterThanEqual %bool %88 %uint_4 + OpSelectionMerge %121 None + OpBranchConditional %119 %122 %121 + %122 = OpLabel + OpBranch %87 + %121 = OpLabel + %123 = OpAccessChain %_ptr_Function_Outer %76 %88 + %125 = OpAccessChain %_ptr_Function_Outer_std140 %74 %88 + %127 = OpLoad %Outer_std140 %125 None + %128 = OpFunctionCall %Outer %tint_convert_Outer %127 + OpStore %123 %128 None + OpBranch %85 + %85 = OpLabel + %89 = OpIAdd %uint %88 %uint_1 + OpBranch %86 + %87 = OpLabel + %l_a = OpLoad %_arr_Outer_uint_4 %76 None + %91 = OpLoad %Outer_std140_tint_explicit_layout %38 None + %92 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %91 + %l_a_i = OpFunctionCall %Outer %tint_convert_Outer %92 + %96 = OpLoad %_arr_Inner_std140_uint_4 %40 None + %97 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %96 + OpStore %99 %97 OpBranch %104 %104 = OpLabel - %106 = OpPhi %uint %uint_0 %101 %107 %103 - OpLoopMerge %105 %103 None - OpBranch %102 - %102 = OpLabel - %126 = OpUGreaterThanEqual %bool %106 %uint_4 - OpSelectionMerge %127 None - OpBranchConditional %126 %128 %127 - %128 = OpLabel + OpBranch %107 + %107 = OpLabel + %109 = OpPhi %uint %uint_0 %104 %110 %106 + OpLoopMerge %108 %106 None OpBranch %105 - %127 = OpLabel - %129 = OpAccessChain %_ptr_Function_Inner %98 %106 - %131 = OpAccessChain %_ptr_Function_Inner_std140 %96 %106 - %133 = OpLoad %Inner_std140 %131 None - %134 = OpFunctionCall %Inner %tint_convert_Inner %133 - OpStore %129 %134 None - OpBranch %103 - %103 = OpLabel - %107 = OpIAdd %uint %106 %uint_1 - OpBranch %104 %105 = OpLabel - %l_a_i_a = OpLoad %_arr_Inner_uint_4 %98 None - %109 = OpLoad %Inner_std140 %42 None - %l_a_i_a_i = OpFunctionCall %Inner %tint_convert_Inner %109 - %112 = OpFunctionCall %int %i - %113 = OpBitcast %uint %112 - %114 = OpExtInst %uint %33 UMin %113 %uint_1 -%l_a_i_a_i_m_i_i = OpVectorExtractDynamic %float %l_a_i_a_i_m_i %114 + %129 = OpUGreaterThanEqual %bool %109 %uint_4 + OpSelectionMerge %130 None + OpBranchConditional %129 %131 %130 + %131 = OpLabel + OpBranch %108 + %130 = OpLabel + %132 = OpAccessChain %_ptr_Function_Inner %101 %109 + %134 = OpAccessChain %_ptr_Function_Inner_std140 %99 %109 + %136 = OpLoad %Inner_std140 %134 None + %137 = OpFunctionCall %Inner %tint_convert_Inner %136 + OpStore %132 %137 None + OpBranch %106 + %106 = OpLabel + %110 = OpIAdd %uint %109 %uint_1 + OpBranch %107 + %108 = OpLabel + %l_a_i_a = OpLoad %_arr_Inner_uint_4 %101 None + %112 = OpLoad %Inner_std140 %45 None + %l_a_i_a_i = OpFunctionCall %Inner %tint_convert_Inner %112 + %115 = OpFunctionCall %int %i + %116 = OpBitcast %uint %115 + %117 = OpExtInst %uint %36 UMin %116 %uint_1 +%l_a_i_a_i_m_i_i = OpVectorExtractDynamic %float %l_a_i_a_i_m_i %117 OpReturn OpFunctionEnd -%tint_convert_Inner = OpFunction %Inner None %136 +%tint_convert_Inner = OpFunction %Inner None %139 %tint_input = OpFunctionParameter %Inner_std140 - %137 = OpLabel - %138 = OpCompositeExtract %v2float %tint_input 0 - %139 = OpCompositeExtract %v2float %tint_input 1 - %140 = OpCompositeExtract %v2float %tint_input 2 - %141 = OpCompositeExtract %v2float %tint_input 3 - %142 = OpCompositeConstruct %mat4v2float %138 %139 %140 %141 - %143 = OpCompositeConstruct %Inner %142 - OpReturnValue %143 + %140 = OpLabel + %141 = OpCompositeExtract %v2float %tint_input 0 + %142 = OpCompositeExtract %v2float %tint_input 1 + %143 = OpCompositeExtract %v2float %tint_input 2 + %144 = OpCompositeExtract %v2float %tint_input 3 + %145 = OpCompositeConstruct %mat4v2float %141 %142 %143 %144 + %146 = OpCompositeConstruct %Inner %145 + OpReturnValue %146 OpFunctionEnd -%tint_convert_Outer = OpFunction %Outer None %145 +%tint_convert_Outer = OpFunction %Outer None %148 %tint_input_0 = OpFunctionParameter %Outer_std140 - %146 = OpLabel - %148 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function - %149 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %100 - %147 = OpCompositeExtract %_arr_Inner_std140_uint_4_0 %tint_input_0 0 - OpStore %148 %147 - OpBranch %150 - %150 = OpLabel + %149 = OpLabel + %151 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function + %152 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %103 + %150 = OpCompositeExtract %_arr_Inner_std140_uint_4_0 %tint_input_0 0 + OpStore %151 %150 OpBranch %153 %153 = OpLabel - %155 = OpPhi %uint %uint_0 %150 %156 %152 - OpLoopMerge %154 %152 None - OpBranch %151 - %151 = OpLabel - %159 = OpUGreaterThanEqual %bool %155 %uint_4 - OpSelectionMerge %160 None - OpBranchConditional %159 %161 %160 - %161 = OpLabel + OpBranch %156 + %156 = OpLabel + %158 = OpPhi %uint %uint_0 %153 %159 %155 + OpLoopMerge %157 %155 None OpBranch %154 - %160 = OpLabel - %162 = OpAccessChain %_ptr_Function_Inner %149 %155 - %163 = OpAccessChain %_ptr_Function_Inner_std140 %148 %155 - %164 = OpLoad %Inner_std140 %163 None - %165 = OpFunctionCall %Inner %tint_convert_Inner %164 - OpStore %162 %165 None - OpBranch %152 - %152 = OpLabel - %156 = OpIAdd %uint %155 %uint_1 - OpBranch %153 %154 = OpLabel - %157 = OpLoad %_arr_Inner_uint_4 %149 None - %158 = OpCompositeConstruct %Outer %157 - OpReturnValue %158 + %162 = OpUGreaterThanEqual %bool %158 %uint_4 + OpSelectionMerge %163 None + OpBranchConditional %162 %164 %163 + %164 = OpLabel + OpBranch %157 + %163 = OpLabel + %165 = OpAccessChain %_ptr_Function_Inner %152 %158 + %166 = OpAccessChain %_ptr_Function_Inner_std140 %151 %158 + %167 = OpLoad %Inner_std140 %166 None + %168 = OpFunctionCall %Inner %tint_convert_Inner %167 + OpStore %165 %168 None + OpBranch %155 + %155 = OpLabel + %159 = OpIAdd %uint %158 %uint_1 + OpBranch %156 + %157 = OpLabel + %160 = OpLoad %_arr_Inner_uint_4 %152 None + %161 = OpCompositeConstruct %Outer %160 + OpReturnValue %161 OpFunctionEnd -%tint_convert_explicit_layout = OpFunction %_arr_Inner_std140_uint_4_0 None %167 +%tint_convert_explicit_layout = OpFunction %_arr_Inner_std140_uint_4_0 None %170 %tint_source = OpFunctionParameter %_arr_Inner_std140_uint_4 - %168 = OpLabel - %169 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4 Function - %171 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function %172 - OpStore %169 %tint_source - OpBranch %173 - %173 = OpLabel + %171 = OpLabel + %172 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4 Function + %174 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function %175 + OpStore %172 %tint_source OpBranch %176 %176 = OpLabel - %178 = OpPhi %uint %uint_0 %173 %179 %175 - OpLoopMerge %177 %175 None - OpBranch %174 - %174 = OpLabel - %181 = OpUGreaterThanEqual %bool %178 %uint_4 - OpSelectionMerge %182 None - OpBranchConditional %181 %183 %182 - %183 = OpLabel + OpBranch %179 + %179 = OpLabel + %181 = OpPhi %uint %uint_0 %176 %182 %178 + OpLoopMerge %180 %178 None OpBranch %177 - %182 = OpLabel - %184 = OpAccessChain %_ptr_Function_Inner_std140 %169 %178 - %185 = OpLoad %Inner_std140 %184 None - %186 = OpAccessChain %_ptr_Function_Inner_std140 %171 %178 - OpStore %186 %185 None - OpBranch %175 - %175 = OpLabel - %179 = OpIAdd %uint %178 %uint_1 - OpBranch %176 %177 = OpLabel - %180 = OpLoad %_arr_Inner_std140_uint_4_0 %171 None - OpReturnValue %180 + %184 = OpUGreaterThanEqual %bool %181 %uint_4 + OpSelectionMerge %185 None + OpBranchConditional %184 %186 %185 + %186 = OpLabel + OpBranch %180 + %185 = OpLabel + %187 = OpAccessChain %_ptr_Function_Inner_std140 %172 %181 + %188 = OpLoad %Inner_std140 %187 None + %189 = OpAccessChain %_ptr_Function_Inner_std140 %174 %181 + OpStore %189 %188 None + OpBranch %178 + %178 = OpLabel + %182 = OpIAdd %uint %181 %uint_1 + OpBranch %179 + %180 = OpLabel + %183 = OpLoad %_arr_Inner_std140_uint_4_0 %174 None + OpReturnValue %183 OpFunctionEnd -%tint_convert_explicit_layout_0 = OpFunction %Outer_std140 None %188 +%tint_convert_explicit_layout_0 = OpFunction %Outer_std140 None %191 %tint_source_0 = OpFunctionParameter %Outer_std140_tint_explicit_layout - %189 = OpLabel - %190 = OpCompositeExtract %_arr_Inner_std140_uint_4 %tint_source_0 0 - %191 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %190 - %192 = OpCompositeConstruct %Outer_std140 %191 - OpReturnValue %192 + %192 = OpLabel + %193 = OpCompositeExtract %_arr_Inner_std140_uint_4 %tint_source_0 0 + %194 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %193 + %195 = OpCompositeConstruct %Outer_std140 %194 + OpReturnValue %195 OpFunctionEnd -%tint_convert_explicit_layout_1 = OpFunction %_arr_Outer_std140_uint_4 None %194 +%tint_convert_explicit_layout_1 = OpFunction %_arr_Outer_std140_uint_4 None %197 %tint_source_1 = OpFunctionParameter %_arr_Outer_std140_tint_explicit_layout_uint_4 - %195 = OpLabel - %196 = OpVariable %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 Function - %198 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function %199 - OpStore %196 %tint_source_1 - OpBranch %200 - %200 = OpLabel + %198 = OpLabel + %199 = OpVariable %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 Function + %201 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function %202 + OpStore %199 %tint_source_1 OpBranch %203 %203 = OpLabel - %205 = OpPhi %uint %uint_0 %200 %206 %202 - OpLoopMerge %204 %202 None - OpBranch %201 - %201 = OpLabel - %208 = OpUGreaterThanEqual %bool %205 %uint_4 - OpSelectionMerge %209 None - OpBranchConditional %208 %210 %209 - %210 = OpLabel + OpBranch %206 + %206 = OpLabel + %208 = OpPhi %uint %uint_0 %203 %209 %205 + OpLoopMerge %207 %205 None OpBranch %204 - %209 = OpLabel - %211 = OpAccessChain %_ptr_Function_Outer_std140_tint_explicit_layout %196 %205 - %213 = OpLoad %Outer_std140_tint_explicit_layout %211 None - %214 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %213 - %215 = OpAccessChain %_ptr_Function_Outer_std140 %198 %205 - OpStore %215 %214 None - OpBranch %202 - %202 = OpLabel - %206 = OpIAdd %uint %205 %uint_1 - OpBranch %203 %204 = OpLabel - %207 = OpLoad %_arr_Outer_std140_uint_4 %198 None - OpReturnValue %207 + %211 = OpUGreaterThanEqual %bool %208 %uint_4 + OpSelectionMerge %212 None + OpBranchConditional %211 %213 %212 + %213 = OpLabel + OpBranch %207 + %212 = OpLabel + %214 = OpAccessChain %_ptr_Function_Outer_std140_tint_explicit_layout %199 %208 + %216 = OpLoad %Outer_std140_tint_explicit_layout %214 None + %217 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %216 + %218 = OpAccessChain %_ptr_Function_Outer_std140 %201 %208 + OpStore %218 %217 None + OpBranch %205 + %205 = OpLabel + %209 = OpIAdd %uint %208 %uint_1 + OpBranch %206 + %207 = OpLabel + %210 = OpLoad %_arr_Outer_std140_uint_4 %201 None + OpReturnValue %210 OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/struct/mat4x3_f16/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/struct/mat4x3_f16/dynamic_index_via_ptr.wgsl.expected.glsl index b700b3a..b539ee0 100644 --- a/test/tint/buffer/uniform/std140/struct/mat4x3_f16/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/struct/mat4x3_f16/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -35,76 +35,77 @@ } v; int counter = 0; int i() { - counter = (counter + 1); + uint v_1 = uint(counter); + counter = int((v_1 + uint(1))); return counter; } Inner tint_convert_Inner(Inner_std140 tint_input) { return Inner(f16mat4x3(tint_input.m_col0, tint_input.m_col1, tint_input.m_col2, tint_input.m_col3)); } Outer tint_convert_Outer(Outer_std140 tint_input) { - Inner v_1[4] = Inner[4](Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf)))); + Inner v_2[4] = Inner[4](Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf)))); { - uint v_2 = 0u; - v_2 = 0u; + uint v_3 = 0u; + v_3 = 0u; while(true) { - uint v_3 = v_2; - if ((v_3 >= 4u)) { + uint v_4 = v_3; + if ((v_4 >= 4u)) { break; } - v_1[v_3] = tint_convert_Inner(tint_input.a[v_3]); + v_2[v_4] = tint_convert_Inner(tint_input.a[v_4]); { - v_2 = (v_3 + 1u); + v_3 = (v_4 + 1u); } continue; } } - return Outer(v_1); + return Outer(v_2); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - uint v_4 = min(uint(i()), 3u); uint v_5 = min(uint(i()), 3u); - f16mat4x3 v_6 = f16mat4x3(v.inner[v_4].a[v_5].m_col0, v.inner[v_4].a[v_5].m_col1, v.inner[v_4].a[v_5].m_col2, v.inner[v_4].a[v_5].m_col3); - f16vec3 v_7 = v_6[min(uint(i()), 3u)]; - Outer_std140 v_8[4] = v.inner; - Outer v_9[4] = Outer[4](Outer(Inner[4](Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))))), Outer(Inner[4](Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))))), Outer(Inner[4](Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))))), Outer(Inner[4](Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf)))))); + uint v_6 = min(uint(i()), 3u); + f16mat4x3 v_7 = f16mat4x3(v.inner[v_5].a[v_6].m_col0, v.inner[v_5].a[v_6].m_col1, v.inner[v_5].a[v_6].m_col2, v.inner[v_5].a[v_6].m_col3); + f16vec3 v_8 = v_7[min(uint(i()), 3u)]; + Outer_std140 v_9[4] = v.inner; + Outer v_10[4] = Outer[4](Outer(Inner[4](Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))))), Outer(Inner[4](Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))))), Outer(Inner[4](Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))))), Outer(Inner[4](Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf)))))); { - uint v_10 = 0u; - v_10 = 0u; + uint v_11 = 0u; + v_11 = 0u; while(true) { - uint v_11 = v_10; - if ((v_11 >= 4u)) { + uint v_12 = v_11; + if ((v_12 >= 4u)) { break; } - v_9[v_11] = tint_convert_Outer(v_8[v_11]); + v_10[v_12] = tint_convert_Outer(v_9[v_12]); { - v_10 = (v_11 + 1u); + v_11 = (v_12 + 1u); } continue; } } - Outer l_a[4] = v_9; - Outer l_a_i = tint_convert_Outer(v.inner[v_4]); - Inner_std140 v_12[4] = v.inner[v_4].a; - Inner v_13[4] = Inner[4](Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf)))); + Outer l_a[4] = v_10; + Outer l_a_i = tint_convert_Outer(v.inner[v_5]); + Inner_std140 v_13[4] = v.inner[v_5].a; + Inner v_14[4] = Inner[4](Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf))), Inner(f16mat4x3(f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf), f16vec3(0.0hf)))); { - uint v_14 = 0u; - v_14 = 0u; + uint v_15 = 0u; + v_15 = 0u; while(true) { - uint v_15 = v_14; - if ((v_15 >= 4u)) { + uint v_16 = v_15; + if ((v_16 >= 4u)) { break; } - v_13[v_15] = tint_convert_Inner(v_12[v_15]); + v_14[v_16] = tint_convert_Inner(v_13[v_16]); { - v_14 = (v_15 + 1u); + v_15 = (v_16 + 1u); } continue; } } - Inner l_a_i_a[4] = v_13; - Inner l_a_i_a_i = tint_convert_Inner(v.inner[v_4].a[v_5]); - f16mat4x3 l_a_i_a_i_m = v_6; - f16vec3 l_a_i_a_i_m_i = v_7; - float16_t l_a_i_a_i_m_i_i = v_7[min(uint(i()), 2u)]; + Inner l_a_i_a[4] = v_14; + Inner l_a_i_a_i = tint_convert_Inner(v.inner[v_5].a[v_6]); + f16mat4x3 l_a_i_a_i_m = v_7; + f16vec3 l_a_i_a_i_m_i = v_8; + float16_t l_a_i_a_i_m_i_i = v_8[min(uint(i()), 2u)]; }
diff --git a/test/tint/buffer/uniform/std140/struct/mat4x3_f16/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/struct/mat4x3_f16/dynamic_index_via_ptr.wgsl.expected.spvasm index 22d5622..05fe017 100644 --- a/test/tint/buffer/uniform/std140/struct/mat4x3_f16/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/struct/mat4x3_f16/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,13 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 216 +; Bound: 219 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess - %33 = OpExtInstImport "GLSL.std.450" + %36 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -76,7 +76,7 @@ %17 = OpTypeFunction %int %int_1 = OpConstant %int 1 %void = OpTypeVoid - %25 = OpTypeFunction %void + %28 = OpTypeFunction %void %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 = OpTypePointer Uniform %_arr_Outer_std140_tint_explicit_layout_uint_4 %uint_0 = OpConstant %uint 0 %uint_3 = OpConstant %uint 3 @@ -98,248 +98,251 @@ %Outer = OpTypeStruct %_arr_Inner_uint_4 %_arr_Outer_uint_4 = OpTypeArray %Outer %uint_4 %_ptr_Function__arr_Outer_uint_4 = OpTypePointer Function %_arr_Outer_uint_4 - %79 = OpConstantNull %_arr_Outer_uint_4 + %82 = OpConstantNull %_arr_Outer_uint_4 %_ptr_Function__arr_Inner_std140_uint_4_0 = OpTypePointer Function %_arr_Inner_std140_uint_4_0 %_ptr_Function__arr_Inner_uint_4 = OpTypePointer Function %_arr_Inner_uint_4 - %100 = OpConstantNull %_arr_Inner_uint_4 + %103 = OpConstantNull %_arr_Inner_uint_4 %bool = OpTypeBool %_ptr_Function_Outer = OpTypePointer Function %Outer %_ptr_Function_Outer_std140 = OpTypePointer Function %Outer_std140 %_ptr_Function_Inner = OpTypePointer Function %Inner %_ptr_Function_Inner_std140 = OpTypePointer Function %Inner_std140 - %136 = OpTypeFunction %Inner %Inner_std140 - %145 = OpTypeFunction %Outer %Outer_std140 - %167 = OpTypeFunction %_arr_Inner_std140_uint_4_0 %_arr_Inner_std140_uint_4 + %139 = OpTypeFunction %Inner %Inner_std140 + %148 = OpTypeFunction %Outer %Outer_std140 + %170 = OpTypeFunction %_arr_Inner_std140_uint_4_0 %_arr_Inner_std140_uint_4 %_ptr_Function__arr_Inner_std140_uint_4 = OpTypePointer Function %_arr_Inner_std140_uint_4 - %172 = OpConstantNull %_arr_Inner_std140_uint_4_0 - %188 = OpTypeFunction %Outer_std140 %Outer_std140_tint_explicit_layout - %194 = OpTypeFunction %_arr_Outer_std140_uint_4 %_arr_Outer_std140_tint_explicit_layout_uint_4 + %175 = OpConstantNull %_arr_Inner_std140_uint_4_0 + %191 = OpTypeFunction %Outer_std140 %Outer_std140_tint_explicit_layout + %197 = OpTypeFunction %_arr_Outer_std140_uint_4 %_arr_Outer_std140_tint_explicit_layout_uint_4 %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 = OpTypePointer Function %_arr_Outer_std140_tint_explicit_layout_uint_4 - %199 = OpConstantNull %_arr_Outer_std140_uint_4 + %202 = OpConstantNull %_arr_Outer_std140_uint_4 %_ptr_Function_Outer_std140_tint_explicit_layout = OpTypePointer Function %Outer_std140_tint_explicit_layout %i = OpFunction %int None %17 %18 = OpLabel %19 = OpLoad %int %counter None - %20 = OpIAdd %int %19 %int_1 - OpStore %counter %20 None - %22 = OpLoad %int %counter None - OpReturnValue %22 + %20 = OpBitcast %uint %19 + %21 = OpBitcast %uint %int_1 + %23 = OpIAdd %uint %20 %21 + %24 = OpBitcast %int %23 + OpStore %counter %24 None + %25 = OpLoad %int %counter None + OpReturnValue %25 OpFunctionEnd - %f = OpFunction %void None %25 - %26 = OpLabel - %57 = OpVariable %_ptr_Function_mat4v3half Function - %71 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function - %73 = OpVariable %_ptr_Function__arr_Outer_uint_4 Function %79 - %96 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function - %98 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %100 - %27 = OpAccessChain %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 %1 %uint_0 - %30 = OpFunctionCall %int %i - %31 = OpBitcast %uint %30 - %32 = OpExtInst %uint %33 UMin %31 %uint_3 - %35 = OpAccessChain %_ptr_Uniform_Outer_std140_tint_explicit_layout %27 %32 - %37 = OpAccessChain %_ptr_Uniform__arr_Inner_std140_uint_4 %35 %uint_0 - %39 = OpFunctionCall %int %i - %40 = OpBitcast %uint %39 - %41 = OpExtInst %uint %33 UMin %40 %uint_3 - %42 = OpAccessChain %_ptr_Uniform_Inner_std140 %37 %41 - %44 = OpAccessChain %_ptr_Uniform_v3half %42 %uint_0 - %46 = OpLoad %v3half %44 None - %47 = OpAccessChain %_ptr_Uniform_v3half %42 %uint_1 + %f = OpFunction %void None %28 + %29 = OpLabel + %60 = OpVariable %_ptr_Function_mat4v3half Function + %74 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function + %76 = OpVariable %_ptr_Function__arr_Outer_uint_4 Function %82 + %99 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function + %101 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %103 + %30 = OpAccessChain %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 %1 %uint_0 + %33 = OpFunctionCall %int %i + %34 = OpBitcast %uint %33 + %35 = OpExtInst %uint %36 UMin %34 %uint_3 + %38 = OpAccessChain %_ptr_Uniform_Outer_std140_tint_explicit_layout %30 %35 + %40 = OpAccessChain %_ptr_Uniform__arr_Inner_std140_uint_4 %38 %uint_0 + %42 = OpFunctionCall %int %i + %43 = OpBitcast %uint %42 + %44 = OpExtInst %uint %36 UMin %43 %uint_3 + %45 = OpAccessChain %_ptr_Uniform_Inner_std140 %40 %44 + %47 = OpAccessChain %_ptr_Uniform_v3half %45 %uint_0 %49 = OpLoad %v3half %47 None - %50 = OpAccessChain %_ptr_Uniform_v3half %42 %uint_2 + %50 = OpAccessChain %_ptr_Uniform_v3half %45 %uint_1 %52 = OpLoad %v3half %50 None - %53 = OpAccessChain %_ptr_Uniform_v3half %42 %uint_3 - %54 = OpLoad %v3half %53 None -%l_a_i_a_i_m = OpCompositeConstruct %mat4v3half %46 %49 %52 %54 - OpStore %57 %l_a_i_a_i_m - %59 = OpFunctionCall %int %i - %60 = OpBitcast %uint %59 - %61 = OpExtInst %uint %33 UMin %60 %uint_3 - %62 = OpAccessChain %_ptr_Function_v3half %57 %61 -%l_a_i_a_i_m_i = OpLoad %v3half %62 None - %65 = OpLoad %_arr_Outer_std140_tint_explicit_layout_uint_4 %27 None - %66 = OpFunctionCall %_arr_Outer_std140_uint_4 %tint_convert_explicit_layout_1 %65 - OpStore %71 %66 - OpBranch %80 - %80 = OpLabel + %53 = OpAccessChain %_ptr_Uniform_v3half %45 %uint_2 + %55 = OpLoad %v3half %53 None + %56 = OpAccessChain %_ptr_Uniform_v3half %45 %uint_3 + %57 = OpLoad %v3half %56 None +%l_a_i_a_i_m = OpCompositeConstruct %mat4v3half %49 %52 %55 %57 + OpStore %60 %l_a_i_a_i_m + %62 = OpFunctionCall %int %i + %63 = OpBitcast %uint %62 + %64 = OpExtInst %uint %36 UMin %63 %uint_3 + %65 = OpAccessChain %_ptr_Function_v3half %60 %64 +%l_a_i_a_i_m_i = OpLoad %v3half %65 None + %68 = OpLoad %_arr_Outer_std140_tint_explicit_layout_uint_4 %30 None + %69 = OpFunctionCall %_arr_Outer_std140_uint_4 %tint_convert_explicit_layout_1 %68 + OpStore %74 %69 OpBranch %83 %83 = OpLabel - %85 = OpPhi %uint %uint_0 %80 %86 %82 - OpLoopMerge %84 %82 None - OpBranch %81 - %81 = OpLabel - %116 = OpUGreaterThanEqual %bool %85 %uint_4 - OpSelectionMerge %118 None - OpBranchConditional %116 %119 %118 - %119 = OpLabel + OpBranch %86 + %86 = OpLabel + %88 = OpPhi %uint %uint_0 %83 %89 %85 + OpLoopMerge %87 %85 None OpBranch %84 - %118 = OpLabel - %120 = OpAccessChain %_ptr_Function_Outer %73 %85 - %122 = OpAccessChain %_ptr_Function_Outer_std140 %71 %85 - %124 = OpLoad %Outer_std140 %122 None - %125 = OpFunctionCall %Outer %tint_convert_Outer %124 - OpStore %120 %125 None - OpBranch %82 - %82 = OpLabel - %86 = OpIAdd %uint %85 %uint_1 - OpBranch %83 %84 = OpLabel - %l_a = OpLoad %_arr_Outer_uint_4 %73 None - %88 = OpLoad %Outer_std140_tint_explicit_layout %35 None - %89 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %88 - %l_a_i = OpFunctionCall %Outer %tint_convert_Outer %89 - %93 = OpLoad %_arr_Inner_std140_uint_4 %37 None - %94 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %93 - OpStore %96 %94 - OpBranch %101 - %101 = OpLabel + %119 = OpUGreaterThanEqual %bool %88 %uint_4 + OpSelectionMerge %121 None + OpBranchConditional %119 %122 %121 + %122 = OpLabel + OpBranch %87 + %121 = OpLabel + %123 = OpAccessChain %_ptr_Function_Outer %76 %88 + %125 = OpAccessChain %_ptr_Function_Outer_std140 %74 %88 + %127 = OpLoad %Outer_std140 %125 None + %128 = OpFunctionCall %Outer %tint_convert_Outer %127 + OpStore %123 %128 None + OpBranch %85 + %85 = OpLabel + %89 = OpIAdd %uint %88 %uint_1 + OpBranch %86 + %87 = OpLabel + %l_a = OpLoad %_arr_Outer_uint_4 %76 None + %91 = OpLoad %Outer_std140_tint_explicit_layout %38 None + %92 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %91 + %l_a_i = OpFunctionCall %Outer %tint_convert_Outer %92 + %96 = OpLoad %_arr_Inner_std140_uint_4 %40 None + %97 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %96 + OpStore %99 %97 OpBranch %104 %104 = OpLabel - %106 = OpPhi %uint %uint_0 %101 %107 %103 - OpLoopMerge %105 %103 None - OpBranch %102 - %102 = OpLabel - %126 = OpUGreaterThanEqual %bool %106 %uint_4 - OpSelectionMerge %127 None - OpBranchConditional %126 %128 %127 - %128 = OpLabel + OpBranch %107 + %107 = OpLabel + %109 = OpPhi %uint %uint_0 %104 %110 %106 + OpLoopMerge %108 %106 None OpBranch %105 - %127 = OpLabel - %129 = OpAccessChain %_ptr_Function_Inner %98 %106 - %131 = OpAccessChain %_ptr_Function_Inner_std140 %96 %106 - %133 = OpLoad %Inner_std140 %131 None - %134 = OpFunctionCall %Inner %tint_convert_Inner %133 - OpStore %129 %134 None - OpBranch %103 - %103 = OpLabel - %107 = OpIAdd %uint %106 %uint_1 - OpBranch %104 %105 = OpLabel - %l_a_i_a = OpLoad %_arr_Inner_uint_4 %98 None - %109 = OpLoad %Inner_std140 %42 None - %l_a_i_a_i = OpFunctionCall %Inner %tint_convert_Inner %109 - %112 = OpFunctionCall %int %i - %113 = OpBitcast %uint %112 - %114 = OpExtInst %uint %33 UMin %113 %uint_2 -%l_a_i_a_i_m_i_i = OpVectorExtractDynamic %half %l_a_i_a_i_m_i %114 + %129 = OpUGreaterThanEqual %bool %109 %uint_4 + OpSelectionMerge %130 None + OpBranchConditional %129 %131 %130 + %131 = OpLabel + OpBranch %108 + %130 = OpLabel + %132 = OpAccessChain %_ptr_Function_Inner %101 %109 + %134 = OpAccessChain %_ptr_Function_Inner_std140 %99 %109 + %136 = OpLoad %Inner_std140 %134 None + %137 = OpFunctionCall %Inner %tint_convert_Inner %136 + OpStore %132 %137 None + OpBranch %106 + %106 = OpLabel + %110 = OpIAdd %uint %109 %uint_1 + OpBranch %107 + %108 = OpLabel + %l_a_i_a = OpLoad %_arr_Inner_uint_4 %101 None + %112 = OpLoad %Inner_std140 %45 None + %l_a_i_a_i = OpFunctionCall %Inner %tint_convert_Inner %112 + %115 = OpFunctionCall %int %i + %116 = OpBitcast %uint %115 + %117 = OpExtInst %uint %36 UMin %116 %uint_2 +%l_a_i_a_i_m_i_i = OpVectorExtractDynamic %half %l_a_i_a_i_m_i %117 OpReturn OpFunctionEnd -%tint_convert_Inner = OpFunction %Inner None %136 +%tint_convert_Inner = OpFunction %Inner None %139 %tint_input = OpFunctionParameter %Inner_std140 - %137 = OpLabel - %138 = OpCompositeExtract %v3half %tint_input 0 - %139 = OpCompositeExtract %v3half %tint_input 1 - %140 = OpCompositeExtract %v3half %tint_input 2 - %141 = OpCompositeExtract %v3half %tint_input 3 - %142 = OpCompositeConstruct %mat4v3half %138 %139 %140 %141 - %143 = OpCompositeConstruct %Inner %142 - OpReturnValue %143 + %140 = OpLabel + %141 = OpCompositeExtract %v3half %tint_input 0 + %142 = OpCompositeExtract %v3half %tint_input 1 + %143 = OpCompositeExtract %v3half %tint_input 2 + %144 = OpCompositeExtract %v3half %tint_input 3 + %145 = OpCompositeConstruct %mat4v3half %141 %142 %143 %144 + %146 = OpCompositeConstruct %Inner %145 + OpReturnValue %146 OpFunctionEnd -%tint_convert_Outer = OpFunction %Outer None %145 +%tint_convert_Outer = OpFunction %Outer None %148 %tint_input_0 = OpFunctionParameter %Outer_std140 - %146 = OpLabel - %148 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function - %149 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %100 - %147 = OpCompositeExtract %_arr_Inner_std140_uint_4_0 %tint_input_0 0 - OpStore %148 %147 - OpBranch %150 - %150 = OpLabel + %149 = OpLabel + %151 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function + %152 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %103 + %150 = OpCompositeExtract %_arr_Inner_std140_uint_4_0 %tint_input_0 0 + OpStore %151 %150 OpBranch %153 %153 = OpLabel - %155 = OpPhi %uint %uint_0 %150 %156 %152 - OpLoopMerge %154 %152 None - OpBranch %151 - %151 = OpLabel - %159 = OpUGreaterThanEqual %bool %155 %uint_4 - OpSelectionMerge %160 None - OpBranchConditional %159 %161 %160 - %161 = OpLabel + OpBranch %156 + %156 = OpLabel + %158 = OpPhi %uint %uint_0 %153 %159 %155 + OpLoopMerge %157 %155 None OpBranch %154 - %160 = OpLabel - %162 = OpAccessChain %_ptr_Function_Inner %149 %155 - %163 = OpAccessChain %_ptr_Function_Inner_std140 %148 %155 - %164 = OpLoad %Inner_std140 %163 None - %165 = OpFunctionCall %Inner %tint_convert_Inner %164 - OpStore %162 %165 None - OpBranch %152 - %152 = OpLabel - %156 = OpIAdd %uint %155 %uint_1 - OpBranch %153 %154 = OpLabel - %157 = OpLoad %_arr_Inner_uint_4 %149 None - %158 = OpCompositeConstruct %Outer %157 - OpReturnValue %158 + %162 = OpUGreaterThanEqual %bool %158 %uint_4 + OpSelectionMerge %163 None + OpBranchConditional %162 %164 %163 + %164 = OpLabel + OpBranch %157 + %163 = OpLabel + %165 = OpAccessChain %_ptr_Function_Inner %152 %158 + %166 = OpAccessChain %_ptr_Function_Inner_std140 %151 %158 + %167 = OpLoad %Inner_std140 %166 None + %168 = OpFunctionCall %Inner %tint_convert_Inner %167 + OpStore %165 %168 None + OpBranch %155 + %155 = OpLabel + %159 = OpIAdd %uint %158 %uint_1 + OpBranch %156 + %157 = OpLabel + %160 = OpLoad %_arr_Inner_uint_4 %152 None + %161 = OpCompositeConstruct %Outer %160 + OpReturnValue %161 OpFunctionEnd -%tint_convert_explicit_layout = OpFunction %_arr_Inner_std140_uint_4_0 None %167 +%tint_convert_explicit_layout = OpFunction %_arr_Inner_std140_uint_4_0 None %170 %tint_source = OpFunctionParameter %_arr_Inner_std140_uint_4 - %168 = OpLabel - %169 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4 Function - %171 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function %172 - OpStore %169 %tint_source - OpBranch %173 - %173 = OpLabel + %171 = OpLabel + %172 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4 Function + %174 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function %175 + OpStore %172 %tint_source OpBranch %176 %176 = OpLabel - %178 = OpPhi %uint %uint_0 %173 %179 %175 - OpLoopMerge %177 %175 None - OpBranch %174 - %174 = OpLabel - %181 = OpUGreaterThanEqual %bool %178 %uint_4 - OpSelectionMerge %182 None - OpBranchConditional %181 %183 %182 - %183 = OpLabel + OpBranch %179 + %179 = OpLabel + %181 = OpPhi %uint %uint_0 %176 %182 %178 + OpLoopMerge %180 %178 None OpBranch %177 - %182 = OpLabel - %184 = OpAccessChain %_ptr_Function_Inner_std140 %169 %178 - %185 = OpLoad %Inner_std140 %184 None - %186 = OpAccessChain %_ptr_Function_Inner_std140 %171 %178 - OpStore %186 %185 None - OpBranch %175 - %175 = OpLabel - %179 = OpIAdd %uint %178 %uint_1 - OpBranch %176 %177 = OpLabel - %180 = OpLoad %_arr_Inner_std140_uint_4_0 %171 None - OpReturnValue %180 + %184 = OpUGreaterThanEqual %bool %181 %uint_4 + OpSelectionMerge %185 None + OpBranchConditional %184 %186 %185 + %186 = OpLabel + OpBranch %180 + %185 = OpLabel + %187 = OpAccessChain %_ptr_Function_Inner_std140 %172 %181 + %188 = OpLoad %Inner_std140 %187 None + %189 = OpAccessChain %_ptr_Function_Inner_std140 %174 %181 + OpStore %189 %188 None + OpBranch %178 + %178 = OpLabel + %182 = OpIAdd %uint %181 %uint_1 + OpBranch %179 + %180 = OpLabel + %183 = OpLoad %_arr_Inner_std140_uint_4_0 %174 None + OpReturnValue %183 OpFunctionEnd -%tint_convert_explicit_layout_0 = OpFunction %Outer_std140 None %188 +%tint_convert_explicit_layout_0 = OpFunction %Outer_std140 None %191 %tint_source_0 = OpFunctionParameter %Outer_std140_tint_explicit_layout - %189 = OpLabel - %190 = OpCompositeExtract %_arr_Inner_std140_uint_4 %tint_source_0 0 - %191 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %190 - %192 = OpCompositeConstruct %Outer_std140 %191 - OpReturnValue %192 + %192 = OpLabel + %193 = OpCompositeExtract %_arr_Inner_std140_uint_4 %tint_source_0 0 + %194 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %193 + %195 = OpCompositeConstruct %Outer_std140 %194 + OpReturnValue %195 OpFunctionEnd -%tint_convert_explicit_layout_1 = OpFunction %_arr_Outer_std140_uint_4 None %194 +%tint_convert_explicit_layout_1 = OpFunction %_arr_Outer_std140_uint_4 None %197 %tint_source_1 = OpFunctionParameter %_arr_Outer_std140_tint_explicit_layout_uint_4 - %195 = OpLabel - %196 = OpVariable %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 Function - %198 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function %199 - OpStore %196 %tint_source_1 - OpBranch %200 - %200 = OpLabel + %198 = OpLabel + %199 = OpVariable %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 Function + %201 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function %202 + OpStore %199 %tint_source_1 OpBranch %203 %203 = OpLabel - %205 = OpPhi %uint %uint_0 %200 %206 %202 - OpLoopMerge %204 %202 None - OpBranch %201 - %201 = OpLabel - %208 = OpUGreaterThanEqual %bool %205 %uint_4 - OpSelectionMerge %209 None - OpBranchConditional %208 %210 %209 - %210 = OpLabel + OpBranch %206 + %206 = OpLabel + %208 = OpPhi %uint %uint_0 %203 %209 %205 + OpLoopMerge %207 %205 None OpBranch %204 - %209 = OpLabel - %211 = OpAccessChain %_ptr_Function_Outer_std140_tint_explicit_layout %196 %205 - %213 = OpLoad %Outer_std140_tint_explicit_layout %211 None - %214 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %213 - %215 = OpAccessChain %_ptr_Function_Outer_std140 %198 %205 - OpStore %215 %214 None - OpBranch %202 - %202 = OpLabel - %206 = OpIAdd %uint %205 %uint_1 - OpBranch %203 %204 = OpLabel - %207 = OpLoad %_arr_Outer_std140_uint_4 %198 None - OpReturnValue %207 + %211 = OpUGreaterThanEqual %bool %208 %uint_4 + OpSelectionMerge %212 None + OpBranchConditional %211 %213 %212 + %213 = OpLabel + OpBranch %207 + %212 = OpLabel + %214 = OpAccessChain %_ptr_Function_Outer_std140_tint_explicit_layout %199 %208 + %216 = OpLoad %Outer_std140_tint_explicit_layout %214 None + %217 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %216 + %218 = OpAccessChain %_ptr_Function_Outer_std140 %201 %208 + OpStore %218 %217 None + OpBranch %205 + %205 = OpLabel + %209 = OpIAdd %uint %208 %uint_1 + OpBranch %206 + %207 = OpLabel + %210 = OpLoad %_arr_Outer_std140_uint_4 %201 None + OpReturnValue %210 OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/struct/mat4x3_f32/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/struct/mat4x3_f32/dynamic_index_via_ptr.wgsl.expected.glsl index dba0ad4..259a98b 100644 --- a/test/tint/buffer/uniform/std140/struct/mat4x3_f32/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/struct/mat4x3_f32/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -30,76 +30,77 @@ } v; int counter = 0; int i() { - counter = (counter + 1); + uint v_1 = uint(counter); + counter = int((v_1 + uint(1))); return counter; } Inner tint_convert_Inner(Inner_std140 tint_input) { return Inner(mat4x3(tint_input.m_col0, tint_input.m_col1, tint_input.m_col2, tint_input.m_col3)); } Outer tint_convert_Outer(Outer_std140 tint_input) { - Inner v_1[4] = Inner[4](Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f)))); + Inner v_2[4] = Inner[4](Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f)))); { - uint v_2 = 0u; - v_2 = 0u; + uint v_3 = 0u; + v_3 = 0u; while(true) { - uint v_3 = v_2; - if ((v_3 >= 4u)) { + uint v_4 = v_3; + if ((v_4 >= 4u)) { break; } - v_1[v_3] = tint_convert_Inner(tint_input.a[v_3]); + v_2[v_4] = tint_convert_Inner(tint_input.a[v_4]); { - v_2 = (v_3 + 1u); + v_3 = (v_4 + 1u); } continue; } } - return Outer(v_1); + return Outer(v_2); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - uint v_4 = min(uint(i()), 3u); uint v_5 = min(uint(i()), 3u); - mat4x3 v_6 = mat4x3(v.inner[v_4].a[v_5].m_col0, v.inner[v_4].a[v_5].m_col1, v.inner[v_4].a[v_5].m_col2, v.inner[v_4].a[v_5].m_col3); - vec3 v_7 = v_6[min(uint(i()), 3u)]; - Outer_std140 v_8[4] = v.inner; - Outer v_9[4] = Outer[4](Outer(Inner[4](Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))))), Outer(Inner[4](Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))))), Outer(Inner[4](Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))))), Outer(Inner[4](Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f)))))); + uint v_6 = min(uint(i()), 3u); + mat4x3 v_7 = mat4x3(v.inner[v_5].a[v_6].m_col0, v.inner[v_5].a[v_6].m_col1, v.inner[v_5].a[v_6].m_col2, v.inner[v_5].a[v_6].m_col3); + vec3 v_8 = v_7[min(uint(i()), 3u)]; + Outer_std140 v_9[4] = v.inner; + Outer v_10[4] = Outer[4](Outer(Inner[4](Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))))), Outer(Inner[4](Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))))), Outer(Inner[4](Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))))), Outer(Inner[4](Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f)))))); { - uint v_10 = 0u; - v_10 = 0u; + uint v_11 = 0u; + v_11 = 0u; while(true) { - uint v_11 = v_10; - if ((v_11 >= 4u)) { + uint v_12 = v_11; + if ((v_12 >= 4u)) { break; } - v_9[v_11] = tint_convert_Outer(v_8[v_11]); + v_10[v_12] = tint_convert_Outer(v_9[v_12]); { - v_10 = (v_11 + 1u); + v_11 = (v_12 + 1u); } continue; } } - Outer l_a[4] = v_9; - Outer l_a_i = tint_convert_Outer(v.inner[v_4]); - Inner_std140 v_12[4] = v.inner[v_4].a; - Inner v_13[4] = Inner[4](Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f)))); + Outer l_a[4] = v_10; + Outer l_a_i = tint_convert_Outer(v.inner[v_5]); + Inner_std140 v_13[4] = v.inner[v_5].a; + Inner v_14[4] = Inner[4](Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f))), Inner(mat4x3(vec3(0.0f), vec3(0.0f), vec3(0.0f), vec3(0.0f)))); { - uint v_14 = 0u; - v_14 = 0u; + uint v_15 = 0u; + v_15 = 0u; while(true) { - uint v_15 = v_14; - if ((v_15 >= 4u)) { + uint v_16 = v_15; + if ((v_16 >= 4u)) { break; } - v_13[v_15] = tint_convert_Inner(v_12[v_15]); + v_14[v_16] = tint_convert_Inner(v_13[v_16]); { - v_14 = (v_15 + 1u); + v_15 = (v_16 + 1u); } continue; } } - Inner l_a_i_a[4] = v_13; - Inner l_a_i_a_i = tint_convert_Inner(v.inner[v_4].a[v_5]); - mat4x3 l_a_i_a_i_m = v_6; - vec3 l_a_i_a_i_m_i = v_7; - float l_a_i_a_i_m_i_i = v_7[min(uint(i()), 2u)]; + Inner l_a_i_a[4] = v_14; + Inner l_a_i_a_i = tint_convert_Inner(v.inner[v_5].a[v_6]); + mat4x3 l_a_i_a_i_m = v_7; + vec3 l_a_i_a_i_m_i = v_8; + float l_a_i_a_i_m_i_i = v_8[min(uint(i()), 2u)]; }
diff --git a/test/tint/buffer/uniform/std140/struct/mat4x3_f32/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/struct/mat4x3_f32/dynamic_index_via_ptr.wgsl.expected.spvasm index b9f8b6a..612222a 100644 --- a/test/tint/buffer/uniform/std140/struct/mat4x3_f32/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/struct/mat4x3_f32/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,10 +1,10 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 216 +; Bound: 219 ; Schema: 0 OpCapability Shader - %33 = OpExtInstImport "GLSL.std.450" + %36 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -73,7 +73,7 @@ %17 = OpTypeFunction %int %int_1 = OpConstant %int 1 %void = OpTypeVoid - %25 = OpTypeFunction %void + %28 = OpTypeFunction %void %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 = OpTypePointer Uniform %_arr_Outer_std140_tint_explicit_layout_uint_4 %uint_0 = OpConstant %uint 0 %uint_3 = OpConstant %uint 3 @@ -95,248 +95,251 @@ %Outer = OpTypeStruct %_arr_Inner_uint_4 %_arr_Outer_uint_4 = OpTypeArray %Outer %uint_4 %_ptr_Function__arr_Outer_uint_4 = OpTypePointer Function %_arr_Outer_uint_4 - %79 = OpConstantNull %_arr_Outer_uint_4 + %82 = OpConstantNull %_arr_Outer_uint_4 %_ptr_Function__arr_Inner_std140_uint_4_0 = OpTypePointer Function %_arr_Inner_std140_uint_4_0 %_ptr_Function__arr_Inner_uint_4 = OpTypePointer Function %_arr_Inner_uint_4 - %100 = OpConstantNull %_arr_Inner_uint_4 + %103 = OpConstantNull %_arr_Inner_uint_4 %bool = OpTypeBool %_ptr_Function_Outer = OpTypePointer Function %Outer %_ptr_Function_Outer_std140 = OpTypePointer Function %Outer_std140 %_ptr_Function_Inner = OpTypePointer Function %Inner %_ptr_Function_Inner_std140 = OpTypePointer Function %Inner_std140 - %136 = OpTypeFunction %Inner %Inner_std140 - %145 = OpTypeFunction %Outer %Outer_std140 - %167 = OpTypeFunction %_arr_Inner_std140_uint_4_0 %_arr_Inner_std140_uint_4 + %139 = OpTypeFunction %Inner %Inner_std140 + %148 = OpTypeFunction %Outer %Outer_std140 + %170 = OpTypeFunction %_arr_Inner_std140_uint_4_0 %_arr_Inner_std140_uint_4 %_ptr_Function__arr_Inner_std140_uint_4 = OpTypePointer Function %_arr_Inner_std140_uint_4 - %172 = OpConstantNull %_arr_Inner_std140_uint_4_0 - %188 = OpTypeFunction %Outer_std140 %Outer_std140_tint_explicit_layout - %194 = OpTypeFunction %_arr_Outer_std140_uint_4 %_arr_Outer_std140_tint_explicit_layout_uint_4 + %175 = OpConstantNull %_arr_Inner_std140_uint_4_0 + %191 = OpTypeFunction %Outer_std140 %Outer_std140_tint_explicit_layout + %197 = OpTypeFunction %_arr_Outer_std140_uint_4 %_arr_Outer_std140_tint_explicit_layout_uint_4 %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 = OpTypePointer Function %_arr_Outer_std140_tint_explicit_layout_uint_4 - %199 = OpConstantNull %_arr_Outer_std140_uint_4 + %202 = OpConstantNull %_arr_Outer_std140_uint_4 %_ptr_Function_Outer_std140_tint_explicit_layout = OpTypePointer Function %Outer_std140_tint_explicit_layout %i = OpFunction %int None %17 %18 = OpLabel %19 = OpLoad %int %counter None - %20 = OpIAdd %int %19 %int_1 - OpStore %counter %20 None - %22 = OpLoad %int %counter None - OpReturnValue %22 + %20 = OpBitcast %uint %19 + %21 = OpBitcast %uint %int_1 + %23 = OpIAdd %uint %20 %21 + %24 = OpBitcast %int %23 + OpStore %counter %24 None + %25 = OpLoad %int %counter None + OpReturnValue %25 OpFunctionEnd - %f = OpFunction %void None %25 - %26 = OpLabel - %57 = OpVariable %_ptr_Function_mat4v3float Function - %71 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function - %73 = OpVariable %_ptr_Function__arr_Outer_uint_4 Function %79 - %96 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function - %98 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %100 - %27 = OpAccessChain %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 %1 %uint_0 - %30 = OpFunctionCall %int %i - %31 = OpBitcast %uint %30 - %32 = OpExtInst %uint %33 UMin %31 %uint_3 - %35 = OpAccessChain %_ptr_Uniform_Outer_std140_tint_explicit_layout %27 %32 - %37 = OpAccessChain %_ptr_Uniform__arr_Inner_std140_uint_4 %35 %uint_0 - %39 = OpFunctionCall %int %i - %40 = OpBitcast %uint %39 - %41 = OpExtInst %uint %33 UMin %40 %uint_3 - %42 = OpAccessChain %_ptr_Uniform_Inner_std140 %37 %41 - %44 = OpAccessChain %_ptr_Uniform_v3float %42 %uint_0 - %46 = OpLoad %v3float %44 None - %47 = OpAccessChain %_ptr_Uniform_v3float %42 %uint_1 + %f = OpFunction %void None %28 + %29 = OpLabel + %60 = OpVariable %_ptr_Function_mat4v3float Function + %74 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function + %76 = OpVariable %_ptr_Function__arr_Outer_uint_4 Function %82 + %99 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function + %101 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %103 + %30 = OpAccessChain %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 %1 %uint_0 + %33 = OpFunctionCall %int %i + %34 = OpBitcast %uint %33 + %35 = OpExtInst %uint %36 UMin %34 %uint_3 + %38 = OpAccessChain %_ptr_Uniform_Outer_std140_tint_explicit_layout %30 %35 + %40 = OpAccessChain %_ptr_Uniform__arr_Inner_std140_uint_4 %38 %uint_0 + %42 = OpFunctionCall %int %i + %43 = OpBitcast %uint %42 + %44 = OpExtInst %uint %36 UMin %43 %uint_3 + %45 = OpAccessChain %_ptr_Uniform_Inner_std140 %40 %44 + %47 = OpAccessChain %_ptr_Uniform_v3float %45 %uint_0 %49 = OpLoad %v3float %47 None - %50 = OpAccessChain %_ptr_Uniform_v3float %42 %uint_2 + %50 = OpAccessChain %_ptr_Uniform_v3float %45 %uint_1 %52 = OpLoad %v3float %50 None - %53 = OpAccessChain %_ptr_Uniform_v3float %42 %uint_3 - %54 = OpLoad %v3float %53 None -%l_a_i_a_i_m = OpCompositeConstruct %mat4v3float %46 %49 %52 %54 - OpStore %57 %l_a_i_a_i_m - %59 = OpFunctionCall %int %i - %60 = OpBitcast %uint %59 - %61 = OpExtInst %uint %33 UMin %60 %uint_3 - %62 = OpAccessChain %_ptr_Function_v3float %57 %61 -%l_a_i_a_i_m_i = OpLoad %v3float %62 None - %65 = OpLoad %_arr_Outer_std140_tint_explicit_layout_uint_4 %27 None - %66 = OpFunctionCall %_arr_Outer_std140_uint_4 %tint_convert_explicit_layout_1 %65 - OpStore %71 %66 - OpBranch %80 - %80 = OpLabel + %53 = OpAccessChain %_ptr_Uniform_v3float %45 %uint_2 + %55 = OpLoad %v3float %53 None + %56 = OpAccessChain %_ptr_Uniform_v3float %45 %uint_3 + %57 = OpLoad %v3float %56 None +%l_a_i_a_i_m = OpCompositeConstruct %mat4v3float %49 %52 %55 %57 + OpStore %60 %l_a_i_a_i_m + %62 = OpFunctionCall %int %i + %63 = OpBitcast %uint %62 + %64 = OpExtInst %uint %36 UMin %63 %uint_3 + %65 = OpAccessChain %_ptr_Function_v3float %60 %64 +%l_a_i_a_i_m_i = OpLoad %v3float %65 None + %68 = OpLoad %_arr_Outer_std140_tint_explicit_layout_uint_4 %30 None + %69 = OpFunctionCall %_arr_Outer_std140_uint_4 %tint_convert_explicit_layout_1 %68 + OpStore %74 %69 OpBranch %83 %83 = OpLabel - %85 = OpPhi %uint %uint_0 %80 %86 %82 - OpLoopMerge %84 %82 None - OpBranch %81 - %81 = OpLabel - %116 = OpUGreaterThanEqual %bool %85 %uint_4 - OpSelectionMerge %118 None - OpBranchConditional %116 %119 %118 - %119 = OpLabel + OpBranch %86 + %86 = OpLabel + %88 = OpPhi %uint %uint_0 %83 %89 %85 + OpLoopMerge %87 %85 None OpBranch %84 - %118 = OpLabel - %120 = OpAccessChain %_ptr_Function_Outer %73 %85 - %122 = OpAccessChain %_ptr_Function_Outer_std140 %71 %85 - %124 = OpLoad %Outer_std140 %122 None - %125 = OpFunctionCall %Outer %tint_convert_Outer %124 - OpStore %120 %125 None - OpBranch %82 - %82 = OpLabel - %86 = OpIAdd %uint %85 %uint_1 - OpBranch %83 %84 = OpLabel - %l_a = OpLoad %_arr_Outer_uint_4 %73 None - %88 = OpLoad %Outer_std140_tint_explicit_layout %35 None - %89 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %88 - %l_a_i = OpFunctionCall %Outer %tint_convert_Outer %89 - %93 = OpLoad %_arr_Inner_std140_uint_4 %37 None - %94 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %93 - OpStore %96 %94 - OpBranch %101 - %101 = OpLabel + %119 = OpUGreaterThanEqual %bool %88 %uint_4 + OpSelectionMerge %121 None + OpBranchConditional %119 %122 %121 + %122 = OpLabel + OpBranch %87 + %121 = OpLabel + %123 = OpAccessChain %_ptr_Function_Outer %76 %88 + %125 = OpAccessChain %_ptr_Function_Outer_std140 %74 %88 + %127 = OpLoad %Outer_std140 %125 None + %128 = OpFunctionCall %Outer %tint_convert_Outer %127 + OpStore %123 %128 None + OpBranch %85 + %85 = OpLabel + %89 = OpIAdd %uint %88 %uint_1 + OpBranch %86 + %87 = OpLabel + %l_a = OpLoad %_arr_Outer_uint_4 %76 None + %91 = OpLoad %Outer_std140_tint_explicit_layout %38 None + %92 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %91 + %l_a_i = OpFunctionCall %Outer %tint_convert_Outer %92 + %96 = OpLoad %_arr_Inner_std140_uint_4 %40 None + %97 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %96 + OpStore %99 %97 OpBranch %104 %104 = OpLabel - %106 = OpPhi %uint %uint_0 %101 %107 %103 - OpLoopMerge %105 %103 None - OpBranch %102 - %102 = OpLabel - %126 = OpUGreaterThanEqual %bool %106 %uint_4 - OpSelectionMerge %127 None - OpBranchConditional %126 %128 %127 - %128 = OpLabel + OpBranch %107 + %107 = OpLabel + %109 = OpPhi %uint %uint_0 %104 %110 %106 + OpLoopMerge %108 %106 None OpBranch %105 - %127 = OpLabel - %129 = OpAccessChain %_ptr_Function_Inner %98 %106 - %131 = OpAccessChain %_ptr_Function_Inner_std140 %96 %106 - %133 = OpLoad %Inner_std140 %131 None - %134 = OpFunctionCall %Inner %tint_convert_Inner %133 - OpStore %129 %134 None - OpBranch %103 - %103 = OpLabel - %107 = OpIAdd %uint %106 %uint_1 - OpBranch %104 %105 = OpLabel - %l_a_i_a = OpLoad %_arr_Inner_uint_4 %98 None - %109 = OpLoad %Inner_std140 %42 None - %l_a_i_a_i = OpFunctionCall %Inner %tint_convert_Inner %109 - %112 = OpFunctionCall %int %i - %113 = OpBitcast %uint %112 - %114 = OpExtInst %uint %33 UMin %113 %uint_2 -%l_a_i_a_i_m_i_i = OpVectorExtractDynamic %float %l_a_i_a_i_m_i %114 + %129 = OpUGreaterThanEqual %bool %109 %uint_4 + OpSelectionMerge %130 None + OpBranchConditional %129 %131 %130 + %131 = OpLabel + OpBranch %108 + %130 = OpLabel + %132 = OpAccessChain %_ptr_Function_Inner %101 %109 + %134 = OpAccessChain %_ptr_Function_Inner_std140 %99 %109 + %136 = OpLoad %Inner_std140 %134 None + %137 = OpFunctionCall %Inner %tint_convert_Inner %136 + OpStore %132 %137 None + OpBranch %106 + %106 = OpLabel + %110 = OpIAdd %uint %109 %uint_1 + OpBranch %107 + %108 = OpLabel + %l_a_i_a = OpLoad %_arr_Inner_uint_4 %101 None + %112 = OpLoad %Inner_std140 %45 None + %l_a_i_a_i = OpFunctionCall %Inner %tint_convert_Inner %112 + %115 = OpFunctionCall %int %i + %116 = OpBitcast %uint %115 + %117 = OpExtInst %uint %36 UMin %116 %uint_2 +%l_a_i_a_i_m_i_i = OpVectorExtractDynamic %float %l_a_i_a_i_m_i %117 OpReturn OpFunctionEnd -%tint_convert_Inner = OpFunction %Inner None %136 +%tint_convert_Inner = OpFunction %Inner None %139 %tint_input = OpFunctionParameter %Inner_std140 - %137 = OpLabel - %138 = OpCompositeExtract %v3float %tint_input 0 - %139 = OpCompositeExtract %v3float %tint_input 1 - %140 = OpCompositeExtract %v3float %tint_input 2 - %141 = OpCompositeExtract %v3float %tint_input 3 - %142 = OpCompositeConstruct %mat4v3float %138 %139 %140 %141 - %143 = OpCompositeConstruct %Inner %142 - OpReturnValue %143 + %140 = OpLabel + %141 = OpCompositeExtract %v3float %tint_input 0 + %142 = OpCompositeExtract %v3float %tint_input 1 + %143 = OpCompositeExtract %v3float %tint_input 2 + %144 = OpCompositeExtract %v3float %tint_input 3 + %145 = OpCompositeConstruct %mat4v3float %141 %142 %143 %144 + %146 = OpCompositeConstruct %Inner %145 + OpReturnValue %146 OpFunctionEnd -%tint_convert_Outer = OpFunction %Outer None %145 +%tint_convert_Outer = OpFunction %Outer None %148 %tint_input_0 = OpFunctionParameter %Outer_std140 - %146 = OpLabel - %148 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function - %149 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %100 - %147 = OpCompositeExtract %_arr_Inner_std140_uint_4_0 %tint_input_0 0 - OpStore %148 %147 - OpBranch %150 - %150 = OpLabel + %149 = OpLabel + %151 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function + %152 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %103 + %150 = OpCompositeExtract %_arr_Inner_std140_uint_4_0 %tint_input_0 0 + OpStore %151 %150 OpBranch %153 %153 = OpLabel - %155 = OpPhi %uint %uint_0 %150 %156 %152 - OpLoopMerge %154 %152 None - OpBranch %151 - %151 = OpLabel - %159 = OpUGreaterThanEqual %bool %155 %uint_4 - OpSelectionMerge %160 None - OpBranchConditional %159 %161 %160 - %161 = OpLabel + OpBranch %156 + %156 = OpLabel + %158 = OpPhi %uint %uint_0 %153 %159 %155 + OpLoopMerge %157 %155 None OpBranch %154 - %160 = OpLabel - %162 = OpAccessChain %_ptr_Function_Inner %149 %155 - %163 = OpAccessChain %_ptr_Function_Inner_std140 %148 %155 - %164 = OpLoad %Inner_std140 %163 None - %165 = OpFunctionCall %Inner %tint_convert_Inner %164 - OpStore %162 %165 None - OpBranch %152 - %152 = OpLabel - %156 = OpIAdd %uint %155 %uint_1 - OpBranch %153 %154 = OpLabel - %157 = OpLoad %_arr_Inner_uint_4 %149 None - %158 = OpCompositeConstruct %Outer %157 - OpReturnValue %158 + %162 = OpUGreaterThanEqual %bool %158 %uint_4 + OpSelectionMerge %163 None + OpBranchConditional %162 %164 %163 + %164 = OpLabel + OpBranch %157 + %163 = OpLabel + %165 = OpAccessChain %_ptr_Function_Inner %152 %158 + %166 = OpAccessChain %_ptr_Function_Inner_std140 %151 %158 + %167 = OpLoad %Inner_std140 %166 None + %168 = OpFunctionCall %Inner %tint_convert_Inner %167 + OpStore %165 %168 None + OpBranch %155 + %155 = OpLabel + %159 = OpIAdd %uint %158 %uint_1 + OpBranch %156 + %157 = OpLabel + %160 = OpLoad %_arr_Inner_uint_4 %152 None + %161 = OpCompositeConstruct %Outer %160 + OpReturnValue %161 OpFunctionEnd -%tint_convert_explicit_layout = OpFunction %_arr_Inner_std140_uint_4_0 None %167 +%tint_convert_explicit_layout = OpFunction %_arr_Inner_std140_uint_4_0 None %170 %tint_source = OpFunctionParameter %_arr_Inner_std140_uint_4 - %168 = OpLabel - %169 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4 Function - %171 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function %172 - OpStore %169 %tint_source - OpBranch %173 - %173 = OpLabel + %171 = OpLabel + %172 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4 Function + %174 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function %175 + OpStore %172 %tint_source OpBranch %176 %176 = OpLabel - %178 = OpPhi %uint %uint_0 %173 %179 %175 - OpLoopMerge %177 %175 None - OpBranch %174 - %174 = OpLabel - %181 = OpUGreaterThanEqual %bool %178 %uint_4 - OpSelectionMerge %182 None - OpBranchConditional %181 %183 %182 - %183 = OpLabel + OpBranch %179 + %179 = OpLabel + %181 = OpPhi %uint %uint_0 %176 %182 %178 + OpLoopMerge %180 %178 None OpBranch %177 - %182 = OpLabel - %184 = OpAccessChain %_ptr_Function_Inner_std140 %169 %178 - %185 = OpLoad %Inner_std140 %184 None - %186 = OpAccessChain %_ptr_Function_Inner_std140 %171 %178 - OpStore %186 %185 None - OpBranch %175 - %175 = OpLabel - %179 = OpIAdd %uint %178 %uint_1 - OpBranch %176 %177 = OpLabel - %180 = OpLoad %_arr_Inner_std140_uint_4_0 %171 None - OpReturnValue %180 + %184 = OpUGreaterThanEqual %bool %181 %uint_4 + OpSelectionMerge %185 None + OpBranchConditional %184 %186 %185 + %186 = OpLabel + OpBranch %180 + %185 = OpLabel + %187 = OpAccessChain %_ptr_Function_Inner_std140 %172 %181 + %188 = OpLoad %Inner_std140 %187 None + %189 = OpAccessChain %_ptr_Function_Inner_std140 %174 %181 + OpStore %189 %188 None + OpBranch %178 + %178 = OpLabel + %182 = OpIAdd %uint %181 %uint_1 + OpBranch %179 + %180 = OpLabel + %183 = OpLoad %_arr_Inner_std140_uint_4_0 %174 None + OpReturnValue %183 OpFunctionEnd -%tint_convert_explicit_layout_0 = OpFunction %Outer_std140 None %188 +%tint_convert_explicit_layout_0 = OpFunction %Outer_std140 None %191 %tint_source_0 = OpFunctionParameter %Outer_std140_tint_explicit_layout - %189 = OpLabel - %190 = OpCompositeExtract %_arr_Inner_std140_uint_4 %tint_source_0 0 - %191 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %190 - %192 = OpCompositeConstruct %Outer_std140 %191 - OpReturnValue %192 + %192 = OpLabel + %193 = OpCompositeExtract %_arr_Inner_std140_uint_4 %tint_source_0 0 + %194 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %193 + %195 = OpCompositeConstruct %Outer_std140 %194 + OpReturnValue %195 OpFunctionEnd -%tint_convert_explicit_layout_1 = OpFunction %_arr_Outer_std140_uint_4 None %194 +%tint_convert_explicit_layout_1 = OpFunction %_arr_Outer_std140_uint_4 None %197 %tint_source_1 = OpFunctionParameter %_arr_Outer_std140_tint_explicit_layout_uint_4 - %195 = OpLabel - %196 = OpVariable %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 Function - %198 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function %199 - OpStore %196 %tint_source_1 - OpBranch %200 - %200 = OpLabel + %198 = OpLabel + %199 = OpVariable %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 Function + %201 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function %202 + OpStore %199 %tint_source_1 OpBranch %203 %203 = OpLabel - %205 = OpPhi %uint %uint_0 %200 %206 %202 - OpLoopMerge %204 %202 None - OpBranch %201 - %201 = OpLabel - %208 = OpUGreaterThanEqual %bool %205 %uint_4 - OpSelectionMerge %209 None - OpBranchConditional %208 %210 %209 - %210 = OpLabel + OpBranch %206 + %206 = OpLabel + %208 = OpPhi %uint %uint_0 %203 %209 %205 + OpLoopMerge %207 %205 None OpBranch %204 - %209 = OpLabel - %211 = OpAccessChain %_ptr_Function_Outer_std140_tint_explicit_layout %196 %205 - %213 = OpLoad %Outer_std140_tint_explicit_layout %211 None - %214 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %213 - %215 = OpAccessChain %_ptr_Function_Outer_std140 %198 %205 - OpStore %215 %214 None - OpBranch %202 - %202 = OpLabel - %206 = OpIAdd %uint %205 %uint_1 - OpBranch %203 %204 = OpLabel - %207 = OpLoad %_arr_Outer_std140_uint_4 %198 None - OpReturnValue %207 + %211 = OpUGreaterThanEqual %bool %208 %uint_4 + OpSelectionMerge %212 None + OpBranchConditional %211 %213 %212 + %213 = OpLabel + OpBranch %207 + %212 = OpLabel + %214 = OpAccessChain %_ptr_Function_Outer_std140_tint_explicit_layout %199 %208 + %216 = OpLoad %Outer_std140_tint_explicit_layout %214 None + %217 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %216 + %218 = OpAccessChain %_ptr_Function_Outer_std140 %201 %208 + OpStore %218 %217 None + OpBranch %205 + %205 = OpLabel + %209 = OpIAdd %uint %208 %uint_1 + OpBranch %206 + %207 = OpLabel + %210 = OpLoad %_arr_Outer_std140_uint_4 %201 None + OpReturnValue %210 OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/struct/mat4x4_f16/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/struct/mat4x4_f16/dynamic_index_via_ptr.wgsl.expected.glsl index 01358a2..d8d7368 100644 --- a/test/tint/buffer/uniform/std140/struct/mat4x4_f16/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/struct/mat4x4_f16/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -35,76 +35,77 @@ } v; int counter = 0; int i() { - counter = (counter + 1); + uint v_1 = uint(counter); + counter = int((v_1 + uint(1))); return counter; } Inner tint_convert_Inner(Inner_std140 tint_input) { return Inner(f16mat4(tint_input.m_col0, tint_input.m_col1, tint_input.m_col2, tint_input.m_col3)); } Outer tint_convert_Outer(Outer_std140 tint_input) { - Inner v_1[4] = Inner[4](Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf)))); + Inner v_2[4] = Inner[4](Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf)))); { - uint v_2 = 0u; - v_2 = 0u; + uint v_3 = 0u; + v_3 = 0u; while(true) { - uint v_3 = v_2; - if ((v_3 >= 4u)) { + uint v_4 = v_3; + if ((v_4 >= 4u)) { break; } - v_1[v_3] = tint_convert_Inner(tint_input.a[v_3]); + v_2[v_4] = tint_convert_Inner(tint_input.a[v_4]); { - v_2 = (v_3 + 1u); + v_3 = (v_4 + 1u); } continue; } } - return Outer(v_1); + return Outer(v_2); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - uint v_4 = min(uint(i()), 3u); uint v_5 = min(uint(i()), 3u); - f16mat4 v_6 = f16mat4(v.inner[v_4].a[v_5].m_col0, v.inner[v_4].a[v_5].m_col1, v.inner[v_4].a[v_5].m_col2, v.inner[v_4].a[v_5].m_col3); - f16vec4 v_7 = v_6[min(uint(i()), 3u)]; - Outer_std140 v_8[4] = v.inner; - Outer v_9[4] = Outer[4](Outer(Inner[4](Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))))), Outer(Inner[4](Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))))), Outer(Inner[4](Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))))), Outer(Inner[4](Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf)))))); + uint v_6 = min(uint(i()), 3u); + f16mat4 v_7 = f16mat4(v.inner[v_5].a[v_6].m_col0, v.inner[v_5].a[v_6].m_col1, v.inner[v_5].a[v_6].m_col2, v.inner[v_5].a[v_6].m_col3); + f16vec4 v_8 = v_7[min(uint(i()), 3u)]; + Outer_std140 v_9[4] = v.inner; + Outer v_10[4] = Outer[4](Outer(Inner[4](Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))))), Outer(Inner[4](Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))))), Outer(Inner[4](Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))))), Outer(Inner[4](Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf)))))); { - uint v_10 = 0u; - v_10 = 0u; + uint v_11 = 0u; + v_11 = 0u; while(true) { - uint v_11 = v_10; - if ((v_11 >= 4u)) { + uint v_12 = v_11; + if ((v_12 >= 4u)) { break; } - v_9[v_11] = tint_convert_Outer(v_8[v_11]); + v_10[v_12] = tint_convert_Outer(v_9[v_12]); { - v_10 = (v_11 + 1u); + v_11 = (v_12 + 1u); } continue; } } - Outer l_a[4] = v_9; - Outer l_a_i = tint_convert_Outer(v.inner[v_4]); - Inner_std140 v_12[4] = v.inner[v_4].a; - Inner v_13[4] = Inner[4](Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf)))); + Outer l_a[4] = v_10; + Outer l_a_i = tint_convert_Outer(v.inner[v_5]); + Inner_std140 v_13[4] = v.inner[v_5].a; + Inner v_14[4] = Inner[4](Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf))), Inner(f16mat4(f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf), f16vec4(0.0hf)))); { - uint v_14 = 0u; - v_14 = 0u; + uint v_15 = 0u; + v_15 = 0u; while(true) { - uint v_15 = v_14; - if ((v_15 >= 4u)) { + uint v_16 = v_15; + if ((v_16 >= 4u)) { break; } - v_13[v_15] = tint_convert_Inner(v_12[v_15]); + v_14[v_16] = tint_convert_Inner(v_13[v_16]); { - v_14 = (v_15 + 1u); + v_15 = (v_16 + 1u); } continue; } } - Inner l_a_i_a[4] = v_13; - Inner l_a_i_a_i = tint_convert_Inner(v.inner[v_4].a[v_5]); - f16mat4 l_a_i_a_i_m = v_6; - f16vec4 l_a_i_a_i_m_i = v_7; - float16_t l_a_i_a_i_m_i_i = v_7[min(uint(i()), 3u)]; + Inner l_a_i_a[4] = v_14; + Inner l_a_i_a_i = tint_convert_Inner(v.inner[v_5].a[v_6]); + f16mat4 l_a_i_a_i_m = v_7; + f16vec4 l_a_i_a_i_m_i = v_8; + float16_t l_a_i_a_i_m_i_i = v_8[min(uint(i()), 3u)]; }
diff --git a/test/tint/buffer/uniform/std140/struct/mat4x4_f16/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/struct/mat4x4_f16/dynamic_index_via_ptr.wgsl.expected.spvasm index 1d2b4ec..e8aae4e 100644 --- a/test/tint/buffer/uniform/std140/struct/mat4x4_f16/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/struct/mat4x4_f16/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,13 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 216 +; Bound: 219 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess - %33 = OpExtInstImport "GLSL.std.450" + %36 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -76,7 +76,7 @@ %17 = OpTypeFunction %int %int_1 = OpConstant %int 1 %void = OpTypeVoid - %25 = OpTypeFunction %void + %28 = OpTypeFunction %void %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 = OpTypePointer Uniform %_arr_Outer_std140_tint_explicit_layout_uint_4 %uint_0 = OpConstant %uint 0 %uint_3 = OpConstant %uint 3 @@ -98,248 +98,251 @@ %Outer = OpTypeStruct %_arr_Inner_uint_4 %_arr_Outer_uint_4 = OpTypeArray %Outer %uint_4 %_ptr_Function__arr_Outer_uint_4 = OpTypePointer Function %_arr_Outer_uint_4 - %79 = OpConstantNull %_arr_Outer_uint_4 + %82 = OpConstantNull %_arr_Outer_uint_4 %_ptr_Function__arr_Inner_std140_uint_4_0 = OpTypePointer Function %_arr_Inner_std140_uint_4_0 %_ptr_Function__arr_Inner_uint_4 = OpTypePointer Function %_arr_Inner_uint_4 - %100 = OpConstantNull %_arr_Inner_uint_4 + %103 = OpConstantNull %_arr_Inner_uint_4 %bool = OpTypeBool %_ptr_Function_Outer = OpTypePointer Function %Outer %_ptr_Function_Outer_std140 = OpTypePointer Function %Outer_std140 %_ptr_Function_Inner = OpTypePointer Function %Inner %_ptr_Function_Inner_std140 = OpTypePointer Function %Inner_std140 - %136 = OpTypeFunction %Inner %Inner_std140 - %145 = OpTypeFunction %Outer %Outer_std140 - %167 = OpTypeFunction %_arr_Inner_std140_uint_4_0 %_arr_Inner_std140_uint_4 + %139 = OpTypeFunction %Inner %Inner_std140 + %148 = OpTypeFunction %Outer %Outer_std140 + %170 = OpTypeFunction %_arr_Inner_std140_uint_4_0 %_arr_Inner_std140_uint_4 %_ptr_Function__arr_Inner_std140_uint_4 = OpTypePointer Function %_arr_Inner_std140_uint_4 - %172 = OpConstantNull %_arr_Inner_std140_uint_4_0 - %188 = OpTypeFunction %Outer_std140 %Outer_std140_tint_explicit_layout - %194 = OpTypeFunction %_arr_Outer_std140_uint_4 %_arr_Outer_std140_tint_explicit_layout_uint_4 + %175 = OpConstantNull %_arr_Inner_std140_uint_4_0 + %191 = OpTypeFunction %Outer_std140 %Outer_std140_tint_explicit_layout + %197 = OpTypeFunction %_arr_Outer_std140_uint_4 %_arr_Outer_std140_tint_explicit_layout_uint_4 %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 = OpTypePointer Function %_arr_Outer_std140_tint_explicit_layout_uint_4 - %199 = OpConstantNull %_arr_Outer_std140_uint_4 + %202 = OpConstantNull %_arr_Outer_std140_uint_4 %_ptr_Function_Outer_std140_tint_explicit_layout = OpTypePointer Function %Outer_std140_tint_explicit_layout %i = OpFunction %int None %17 %18 = OpLabel %19 = OpLoad %int %counter None - %20 = OpIAdd %int %19 %int_1 - OpStore %counter %20 None - %22 = OpLoad %int %counter None - OpReturnValue %22 + %20 = OpBitcast %uint %19 + %21 = OpBitcast %uint %int_1 + %23 = OpIAdd %uint %20 %21 + %24 = OpBitcast %int %23 + OpStore %counter %24 None + %25 = OpLoad %int %counter None + OpReturnValue %25 OpFunctionEnd - %f = OpFunction %void None %25 - %26 = OpLabel - %57 = OpVariable %_ptr_Function_mat4v4half Function - %71 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function - %73 = OpVariable %_ptr_Function__arr_Outer_uint_4 Function %79 - %96 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function - %98 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %100 - %27 = OpAccessChain %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 %1 %uint_0 - %30 = OpFunctionCall %int %i - %31 = OpBitcast %uint %30 - %32 = OpExtInst %uint %33 UMin %31 %uint_3 - %35 = OpAccessChain %_ptr_Uniform_Outer_std140_tint_explicit_layout %27 %32 - %37 = OpAccessChain %_ptr_Uniform__arr_Inner_std140_uint_4 %35 %uint_0 - %39 = OpFunctionCall %int %i - %40 = OpBitcast %uint %39 - %41 = OpExtInst %uint %33 UMin %40 %uint_3 - %42 = OpAccessChain %_ptr_Uniform_Inner_std140 %37 %41 - %44 = OpAccessChain %_ptr_Uniform_v4half %42 %uint_0 - %46 = OpLoad %v4half %44 None - %47 = OpAccessChain %_ptr_Uniform_v4half %42 %uint_1 + %f = OpFunction %void None %28 + %29 = OpLabel + %60 = OpVariable %_ptr_Function_mat4v4half Function + %74 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function + %76 = OpVariable %_ptr_Function__arr_Outer_uint_4 Function %82 + %99 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function + %101 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %103 + %30 = OpAccessChain %_ptr_Uniform__arr_Outer_std140_tint_explicit_layout_uint_4 %1 %uint_0 + %33 = OpFunctionCall %int %i + %34 = OpBitcast %uint %33 + %35 = OpExtInst %uint %36 UMin %34 %uint_3 + %38 = OpAccessChain %_ptr_Uniform_Outer_std140_tint_explicit_layout %30 %35 + %40 = OpAccessChain %_ptr_Uniform__arr_Inner_std140_uint_4 %38 %uint_0 + %42 = OpFunctionCall %int %i + %43 = OpBitcast %uint %42 + %44 = OpExtInst %uint %36 UMin %43 %uint_3 + %45 = OpAccessChain %_ptr_Uniform_Inner_std140 %40 %44 + %47 = OpAccessChain %_ptr_Uniform_v4half %45 %uint_0 %49 = OpLoad %v4half %47 None - %50 = OpAccessChain %_ptr_Uniform_v4half %42 %uint_2 + %50 = OpAccessChain %_ptr_Uniform_v4half %45 %uint_1 %52 = OpLoad %v4half %50 None - %53 = OpAccessChain %_ptr_Uniform_v4half %42 %uint_3 - %54 = OpLoad %v4half %53 None -%l_a_i_a_i_m = OpCompositeConstruct %mat4v4half %46 %49 %52 %54 - OpStore %57 %l_a_i_a_i_m - %59 = OpFunctionCall %int %i - %60 = OpBitcast %uint %59 - %61 = OpExtInst %uint %33 UMin %60 %uint_3 - %62 = OpAccessChain %_ptr_Function_v4half %57 %61 -%l_a_i_a_i_m_i = OpLoad %v4half %62 None - %65 = OpLoad %_arr_Outer_std140_tint_explicit_layout_uint_4 %27 None - %66 = OpFunctionCall %_arr_Outer_std140_uint_4 %tint_convert_explicit_layout_1 %65 - OpStore %71 %66 - OpBranch %80 - %80 = OpLabel + %53 = OpAccessChain %_ptr_Uniform_v4half %45 %uint_2 + %55 = OpLoad %v4half %53 None + %56 = OpAccessChain %_ptr_Uniform_v4half %45 %uint_3 + %57 = OpLoad %v4half %56 None +%l_a_i_a_i_m = OpCompositeConstruct %mat4v4half %49 %52 %55 %57 + OpStore %60 %l_a_i_a_i_m + %62 = OpFunctionCall %int %i + %63 = OpBitcast %uint %62 + %64 = OpExtInst %uint %36 UMin %63 %uint_3 + %65 = OpAccessChain %_ptr_Function_v4half %60 %64 +%l_a_i_a_i_m_i = OpLoad %v4half %65 None + %68 = OpLoad %_arr_Outer_std140_tint_explicit_layout_uint_4 %30 None + %69 = OpFunctionCall %_arr_Outer_std140_uint_4 %tint_convert_explicit_layout_1 %68 + OpStore %74 %69 OpBranch %83 %83 = OpLabel - %85 = OpPhi %uint %uint_0 %80 %86 %82 - OpLoopMerge %84 %82 None - OpBranch %81 - %81 = OpLabel - %116 = OpUGreaterThanEqual %bool %85 %uint_4 - OpSelectionMerge %118 None - OpBranchConditional %116 %119 %118 - %119 = OpLabel + OpBranch %86 + %86 = OpLabel + %88 = OpPhi %uint %uint_0 %83 %89 %85 + OpLoopMerge %87 %85 None OpBranch %84 - %118 = OpLabel - %120 = OpAccessChain %_ptr_Function_Outer %73 %85 - %122 = OpAccessChain %_ptr_Function_Outer_std140 %71 %85 - %124 = OpLoad %Outer_std140 %122 None - %125 = OpFunctionCall %Outer %tint_convert_Outer %124 - OpStore %120 %125 None - OpBranch %82 - %82 = OpLabel - %86 = OpIAdd %uint %85 %uint_1 - OpBranch %83 %84 = OpLabel - %l_a = OpLoad %_arr_Outer_uint_4 %73 None - %88 = OpLoad %Outer_std140_tint_explicit_layout %35 None - %89 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %88 - %l_a_i = OpFunctionCall %Outer %tint_convert_Outer %89 - %93 = OpLoad %_arr_Inner_std140_uint_4 %37 None - %94 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %93 - OpStore %96 %94 - OpBranch %101 - %101 = OpLabel + %119 = OpUGreaterThanEqual %bool %88 %uint_4 + OpSelectionMerge %121 None + OpBranchConditional %119 %122 %121 + %122 = OpLabel + OpBranch %87 + %121 = OpLabel + %123 = OpAccessChain %_ptr_Function_Outer %76 %88 + %125 = OpAccessChain %_ptr_Function_Outer_std140 %74 %88 + %127 = OpLoad %Outer_std140 %125 None + %128 = OpFunctionCall %Outer %tint_convert_Outer %127 + OpStore %123 %128 None + OpBranch %85 + %85 = OpLabel + %89 = OpIAdd %uint %88 %uint_1 + OpBranch %86 + %87 = OpLabel + %l_a = OpLoad %_arr_Outer_uint_4 %76 None + %91 = OpLoad %Outer_std140_tint_explicit_layout %38 None + %92 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %91 + %l_a_i = OpFunctionCall %Outer %tint_convert_Outer %92 + %96 = OpLoad %_arr_Inner_std140_uint_4 %40 None + %97 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %96 + OpStore %99 %97 OpBranch %104 %104 = OpLabel - %106 = OpPhi %uint %uint_0 %101 %107 %103 - OpLoopMerge %105 %103 None - OpBranch %102 - %102 = OpLabel - %126 = OpUGreaterThanEqual %bool %106 %uint_4 - OpSelectionMerge %127 None - OpBranchConditional %126 %128 %127 - %128 = OpLabel + OpBranch %107 + %107 = OpLabel + %109 = OpPhi %uint %uint_0 %104 %110 %106 + OpLoopMerge %108 %106 None OpBranch %105 - %127 = OpLabel - %129 = OpAccessChain %_ptr_Function_Inner %98 %106 - %131 = OpAccessChain %_ptr_Function_Inner_std140 %96 %106 - %133 = OpLoad %Inner_std140 %131 None - %134 = OpFunctionCall %Inner %tint_convert_Inner %133 - OpStore %129 %134 None - OpBranch %103 - %103 = OpLabel - %107 = OpIAdd %uint %106 %uint_1 - OpBranch %104 %105 = OpLabel - %l_a_i_a = OpLoad %_arr_Inner_uint_4 %98 None - %109 = OpLoad %Inner_std140 %42 None - %l_a_i_a_i = OpFunctionCall %Inner %tint_convert_Inner %109 - %112 = OpFunctionCall %int %i - %113 = OpBitcast %uint %112 - %114 = OpExtInst %uint %33 UMin %113 %uint_3 -%l_a_i_a_i_m_i_i = OpVectorExtractDynamic %half %l_a_i_a_i_m_i %114 + %129 = OpUGreaterThanEqual %bool %109 %uint_4 + OpSelectionMerge %130 None + OpBranchConditional %129 %131 %130 + %131 = OpLabel + OpBranch %108 + %130 = OpLabel + %132 = OpAccessChain %_ptr_Function_Inner %101 %109 + %134 = OpAccessChain %_ptr_Function_Inner_std140 %99 %109 + %136 = OpLoad %Inner_std140 %134 None + %137 = OpFunctionCall %Inner %tint_convert_Inner %136 + OpStore %132 %137 None + OpBranch %106 + %106 = OpLabel + %110 = OpIAdd %uint %109 %uint_1 + OpBranch %107 + %108 = OpLabel + %l_a_i_a = OpLoad %_arr_Inner_uint_4 %101 None + %112 = OpLoad %Inner_std140 %45 None + %l_a_i_a_i = OpFunctionCall %Inner %tint_convert_Inner %112 + %115 = OpFunctionCall %int %i + %116 = OpBitcast %uint %115 + %117 = OpExtInst %uint %36 UMin %116 %uint_3 +%l_a_i_a_i_m_i_i = OpVectorExtractDynamic %half %l_a_i_a_i_m_i %117 OpReturn OpFunctionEnd -%tint_convert_Inner = OpFunction %Inner None %136 +%tint_convert_Inner = OpFunction %Inner None %139 %tint_input = OpFunctionParameter %Inner_std140 - %137 = OpLabel - %138 = OpCompositeExtract %v4half %tint_input 0 - %139 = OpCompositeExtract %v4half %tint_input 1 - %140 = OpCompositeExtract %v4half %tint_input 2 - %141 = OpCompositeExtract %v4half %tint_input 3 - %142 = OpCompositeConstruct %mat4v4half %138 %139 %140 %141 - %143 = OpCompositeConstruct %Inner %142 - OpReturnValue %143 + %140 = OpLabel + %141 = OpCompositeExtract %v4half %tint_input 0 + %142 = OpCompositeExtract %v4half %tint_input 1 + %143 = OpCompositeExtract %v4half %tint_input 2 + %144 = OpCompositeExtract %v4half %tint_input 3 + %145 = OpCompositeConstruct %mat4v4half %141 %142 %143 %144 + %146 = OpCompositeConstruct %Inner %145 + OpReturnValue %146 OpFunctionEnd -%tint_convert_Outer = OpFunction %Outer None %145 +%tint_convert_Outer = OpFunction %Outer None %148 %tint_input_0 = OpFunctionParameter %Outer_std140 - %146 = OpLabel - %148 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function - %149 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %100 - %147 = OpCompositeExtract %_arr_Inner_std140_uint_4_0 %tint_input_0 0 - OpStore %148 %147 - OpBranch %150 - %150 = OpLabel + %149 = OpLabel + %151 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function + %152 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function %103 + %150 = OpCompositeExtract %_arr_Inner_std140_uint_4_0 %tint_input_0 0 + OpStore %151 %150 OpBranch %153 %153 = OpLabel - %155 = OpPhi %uint %uint_0 %150 %156 %152 - OpLoopMerge %154 %152 None - OpBranch %151 - %151 = OpLabel - %159 = OpUGreaterThanEqual %bool %155 %uint_4 - OpSelectionMerge %160 None - OpBranchConditional %159 %161 %160 - %161 = OpLabel + OpBranch %156 + %156 = OpLabel + %158 = OpPhi %uint %uint_0 %153 %159 %155 + OpLoopMerge %157 %155 None OpBranch %154 - %160 = OpLabel - %162 = OpAccessChain %_ptr_Function_Inner %149 %155 - %163 = OpAccessChain %_ptr_Function_Inner_std140 %148 %155 - %164 = OpLoad %Inner_std140 %163 None - %165 = OpFunctionCall %Inner %tint_convert_Inner %164 - OpStore %162 %165 None - OpBranch %152 - %152 = OpLabel - %156 = OpIAdd %uint %155 %uint_1 - OpBranch %153 %154 = OpLabel - %157 = OpLoad %_arr_Inner_uint_4 %149 None - %158 = OpCompositeConstruct %Outer %157 - OpReturnValue %158 + %162 = OpUGreaterThanEqual %bool %158 %uint_4 + OpSelectionMerge %163 None + OpBranchConditional %162 %164 %163 + %164 = OpLabel + OpBranch %157 + %163 = OpLabel + %165 = OpAccessChain %_ptr_Function_Inner %152 %158 + %166 = OpAccessChain %_ptr_Function_Inner_std140 %151 %158 + %167 = OpLoad %Inner_std140 %166 None + %168 = OpFunctionCall %Inner %tint_convert_Inner %167 + OpStore %165 %168 None + OpBranch %155 + %155 = OpLabel + %159 = OpIAdd %uint %158 %uint_1 + OpBranch %156 + %157 = OpLabel + %160 = OpLoad %_arr_Inner_uint_4 %152 None + %161 = OpCompositeConstruct %Outer %160 + OpReturnValue %161 OpFunctionEnd -%tint_convert_explicit_layout = OpFunction %_arr_Inner_std140_uint_4_0 None %167 +%tint_convert_explicit_layout = OpFunction %_arr_Inner_std140_uint_4_0 None %170 %tint_source = OpFunctionParameter %_arr_Inner_std140_uint_4 - %168 = OpLabel - %169 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4 Function - %171 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function %172 - OpStore %169 %tint_source - OpBranch %173 - %173 = OpLabel + %171 = OpLabel + %172 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4 Function + %174 = OpVariable %_ptr_Function__arr_Inner_std140_uint_4_0 Function %175 + OpStore %172 %tint_source OpBranch %176 %176 = OpLabel - %178 = OpPhi %uint %uint_0 %173 %179 %175 - OpLoopMerge %177 %175 None - OpBranch %174 - %174 = OpLabel - %181 = OpUGreaterThanEqual %bool %178 %uint_4 - OpSelectionMerge %182 None - OpBranchConditional %181 %183 %182 - %183 = OpLabel + OpBranch %179 + %179 = OpLabel + %181 = OpPhi %uint %uint_0 %176 %182 %178 + OpLoopMerge %180 %178 None OpBranch %177 - %182 = OpLabel - %184 = OpAccessChain %_ptr_Function_Inner_std140 %169 %178 - %185 = OpLoad %Inner_std140 %184 None - %186 = OpAccessChain %_ptr_Function_Inner_std140 %171 %178 - OpStore %186 %185 None - OpBranch %175 - %175 = OpLabel - %179 = OpIAdd %uint %178 %uint_1 - OpBranch %176 %177 = OpLabel - %180 = OpLoad %_arr_Inner_std140_uint_4_0 %171 None - OpReturnValue %180 + %184 = OpUGreaterThanEqual %bool %181 %uint_4 + OpSelectionMerge %185 None + OpBranchConditional %184 %186 %185 + %186 = OpLabel + OpBranch %180 + %185 = OpLabel + %187 = OpAccessChain %_ptr_Function_Inner_std140 %172 %181 + %188 = OpLoad %Inner_std140 %187 None + %189 = OpAccessChain %_ptr_Function_Inner_std140 %174 %181 + OpStore %189 %188 None + OpBranch %178 + %178 = OpLabel + %182 = OpIAdd %uint %181 %uint_1 + OpBranch %179 + %180 = OpLabel + %183 = OpLoad %_arr_Inner_std140_uint_4_0 %174 None + OpReturnValue %183 OpFunctionEnd -%tint_convert_explicit_layout_0 = OpFunction %Outer_std140 None %188 +%tint_convert_explicit_layout_0 = OpFunction %Outer_std140 None %191 %tint_source_0 = OpFunctionParameter %Outer_std140_tint_explicit_layout - %189 = OpLabel - %190 = OpCompositeExtract %_arr_Inner_std140_uint_4 %tint_source_0 0 - %191 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %190 - %192 = OpCompositeConstruct %Outer_std140 %191 - OpReturnValue %192 + %192 = OpLabel + %193 = OpCompositeExtract %_arr_Inner_std140_uint_4 %tint_source_0 0 + %194 = OpFunctionCall %_arr_Inner_std140_uint_4_0 %tint_convert_explicit_layout %193 + %195 = OpCompositeConstruct %Outer_std140 %194 + OpReturnValue %195 OpFunctionEnd -%tint_convert_explicit_layout_1 = OpFunction %_arr_Outer_std140_uint_4 None %194 +%tint_convert_explicit_layout_1 = OpFunction %_arr_Outer_std140_uint_4 None %197 %tint_source_1 = OpFunctionParameter %_arr_Outer_std140_tint_explicit_layout_uint_4 - %195 = OpLabel - %196 = OpVariable %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 Function - %198 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function %199 - OpStore %196 %tint_source_1 - OpBranch %200 - %200 = OpLabel + %198 = OpLabel + %199 = OpVariable %_ptr_Function__arr_Outer_std140_tint_explicit_layout_uint_4 Function + %201 = OpVariable %_ptr_Function__arr_Outer_std140_uint_4 Function %202 + OpStore %199 %tint_source_1 OpBranch %203 %203 = OpLabel - %205 = OpPhi %uint %uint_0 %200 %206 %202 - OpLoopMerge %204 %202 None - OpBranch %201 - %201 = OpLabel - %208 = OpUGreaterThanEqual %bool %205 %uint_4 - OpSelectionMerge %209 None - OpBranchConditional %208 %210 %209 - %210 = OpLabel + OpBranch %206 + %206 = OpLabel + %208 = OpPhi %uint %uint_0 %203 %209 %205 + OpLoopMerge %207 %205 None OpBranch %204 - %209 = OpLabel - %211 = OpAccessChain %_ptr_Function_Outer_std140_tint_explicit_layout %196 %205 - %213 = OpLoad %Outer_std140_tint_explicit_layout %211 None - %214 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %213 - %215 = OpAccessChain %_ptr_Function_Outer_std140 %198 %205 - OpStore %215 %214 None - OpBranch %202 - %202 = OpLabel - %206 = OpIAdd %uint %205 %uint_1 - OpBranch %203 %204 = OpLabel - %207 = OpLoad %_arr_Outer_std140_uint_4 %198 None - OpReturnValue %207 + %211 = OpUGreaterThanEqual %bool %208 %uint_4 + OpSelectionMerge %212 None + OpBranchConditional %211 %213 %212 + %213 = OpLabel + OpBranch %207 + %212 = OpLabel + %214 = OpAccessChain %_ptr_Function_Outer_std140_tint_explicit_layout %199 %208 + %216 = OpLoad %Outer_std140_tint_explicit_layout %214 None + %217 = OpFunctionCall %Outer_std140 %tint_convert_explicit_layout_0 %216 + %218 = OpAccessChain %_ptr_Function_Outer_std140 %201 %208 + OpStore %218 %217 None + OpBranch %205 + %205 = OpLabel + %209 = OpIAdd %uint %208 %uint_1 + OpBranch %206 + %207 = OpLabel + %210 = OpLoad %_arr_Outer_std140_uint_4 %201 None + OpReturnValue %210 OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/struct/mat4x4_f32/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/struct/mat4x4_f32/dynamic_index_via_ptr.wgsl.expected.glsl index 56303fa..8b0b80c 100644 --- a/test/tint/buffer/uniform/std140/struct/mat4x4_f32/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/struct/mat4x4_f32/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -15,19 +15,20 @@ } v; int counter = 0; int i() { - counter = (counter + 1); + uint v_1 = uint(counter); + counter = int((v_1 + uint(1))); return counter; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - uint v_1 = min(uint(i()), 3u); uint v_2 = min(uint(i()), 3u); uint v_3 = min(uint(i()), 3u); + uint v_4 = min(uint(i()), 3u); Outer l_a[4] = v.inner; - Outer l_a_i = v.inner[v_1]; - Inner l_a_i_a[4] = v.inner[v_1].a; - Inner l_a_i_a_i = v.inner[v_1].a[v_2]; - mat4 l_a_i_a_i_m = v.inner[v_1].a[v_2].m; - vec4 l_a_i_a_i_m_i = v.inner[v_1].a[v_2].m[v_3]; - float l_a_i_a_i_m_i_i = v.inner[v_1].a[v_2].m[v_3][min(uint(i()), 3u)]; + Outer l_a_i = v.inner[v_2]; + Inner l_a_i_a[4] = v.inner[v_2].a; + Inner l_a_i_a_i = v.inner[v_2].a[v_3]; + mat4 l_a_i_a_i_m = v.inner[v_2].a[v_3].m; + vec4 l_a_i_a_i_m_i = v.inner[v_2].a[v_3].m[v_4]; + float l_a_i_a_i_m_i_i = v.inner[v_2].a[v_3].m[v_4][min(uint(i()), 3u)]; }
diff --git a/test/tint/buffer/uniform/std140/struct/mat4x4_f32/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/struct/mat4x4_f32/dynamic_index_via_ptr.wgsl.expected.spvasm index a2759c5..9894f56 100644 --- a/test/tint/buffer/uniform/std140/struct/mat4x4_f32/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/struct/mat4x4_f32/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,10 +1,10 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 129 +; Bound: 132 ; Schema: 0 OpCapability Shader - %34 = OpExtInstImport "GLSL.std.450" + %37 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -68,7 +68,7 @@ %18 = OpTypeFunction %int %int_1 = OpConstant %int 1 %void = OpTypeVoid - %26 = OpTypeFunction %void + %29 = OpTypeFunction %void %_ptr_Uniform__arr_Outer_tint_explicit_layout_uint_4 = OpTypePointer Uniform %_arr_Outer_tint_explicit_layout_uint_4 %uint_0 = OpConstant %uint 0 %uint_3 = OpConstant %uint 3 @@ -81,131 +81,134 @@ %Outer = OpTypeStruct %_arr_Inner_uint_4_0 %_arr_Outer_uint_4 = OpTypeArray %Outer %uint_4 %_ptr_Uniform_float = OpTypePointer Uniform %float - %74 = OpTypeFunction %_arr_Inner_uint_4_0 %_arr_Inner_uint_4 + %77 = OpTypeFunction %_arr_Inner_uint_4_0 %_arr_Inner_uint_4 %_ptr_Function__arr_Inner_uint_4 = OpTypePointer Function %_arr_Inner_uint_4 %_ptr_Function__arr_Inner_uint_4_0 = OpTypePointer Function %_arr_Inner_uint_4_0 - %80 = OpConstantNull %_arr_Inner_uint_4_0 + %83 = OpConstantNull %_arr_Inner_uint_4_0 %bool = OpTypeBool %_ptr_Function_Inner = OpTypePointer Function %Inner %uint_1 = OpConstant %uint 1 - %99 = OpTypeFunction %Outer %Outer_tint_explicit_layout - %105 = OpTypeFunction %_arr_Outer_uint_4 %_arr_Outer_tint_explicit_layout_uint_4 + %102 = OpTypeFunction %Outer %Outer_tint_explicit_layout + %108 = OpTypeFunction %_arr_Outer_uint_4 %_arr_Outer_tint_explicit_layout_uint_4 %_ptr_Function__arr_Outer_tint_explicit_layout_uint_4 = OpTypePointer Function %_arr_Outer_tint_explicit_layout_uint_4 %_ptr_Function__arr_Outer_uint_4 = OpTypePointer Function %_arr_Outer_uint_4 - %111 = OpConstantNull %_arr_Outer_uint_4 + %114 = OpConstantNull %_arr_Outer_uint_4 %_ptr_Function_Outer_tint_explicit_layout = OpTypePointer Function %Outer_tint_explicit_layout %_ptr_Function_Outer = OpTypePointer Function %Outer %i = OpFunction %int None %18 %19 = OpLabel %20 = OpLoad %int %counter None - %21 = OpIAdd %int %20 %int_1 - OpStore %counter %21 None - %23 = OpLoad %int %counter None - OpReturnValue %23 + %21 = OpBitcast %uint %20 + %22 = OpBitcast %uint %int_1 + %24 = OpIAdd %uint %21 %22 + %25 = OpBitcast %int %24 + OpStore %counter %25 None + %26 = OpLoad %int %counter None + OpReturnValue %26 OpFunctionEnd - %f = OpFunction %void None %26 - %27 = OpLabel + %f = OpFunction %void None %29 + %30 = OpLabel %p_a = OpAccessChain %_ptr_Uniform__arr_Outer_tint_explicit_layout_uint_4 %1 %uint_0 - %31 = OpFunctionCall %int %i - %32 = OpBitcast %uint %31 - %33 = OpExtInst %uint %34 UMin %32 %uint_3 - %p_a_i = OpAccessChain %_ptr_Uniform_Outer_tint_explicit_layout %p_a %33 + %34 = OpFunctionCall %int %i + %35 = OpBitcast %uint %34 + %36 = OpExtInst %uint %37 UMin %35 %uint_3 + %p_a_i = OpAccessChain %_ptr_Uniform_Outer_tint_explicit_layout %p_a %36 %p_a_i_a = OpAccessChain %_ptr_Uniform__arr_Inner_uint_4 %p_a_i %uint_0 - %40 = OpFunctionCall %int %i - %41 = OpBitcast %uint %40 - %42 = OpExtInst %uint %34 UMin %41 %uint_3 - %p_a_i_a_i = OpAccessChain %_ptr_Uniform_Inner %p_a_i_a %42 + %43 = OpFunctionCall %int %i + %44 = OpBitcast %uint %43 + %45 = OpExtInst %uint %37 UMin %44 %uint_3 + %p_a_i_a_i = OpAccessChain %_ptr_Uniform_Inner %p_a_i_a %45 %p_a_i_a_i_m = OpAccessChain %_ptr_Uniform_mat4v4float %p_a_i_a_i %uint_0 - %47 = OpFunctionCall %int %i - %48 = OpBitcast %uint %47 - %49 = OpExtInst %uint %34 UMin %48 %uint_3 -%p_a_i_a_i_m_i = OpAccessChain %_ptr_Uniform_v4float %p_a_i_a_i_m %49 - %52 = OpLoad %_arr_Outer_tint_explicit_layout_uint_4 %p_a None - %l_a = OpFunctionCall %_arr_Outer_uint_4 %tint_convert_explicit_layout_1 %52 - %58 = OpLoad %Outer_tint_explicit_layout %p_a_i None - %l_a_i = OpFunctionCall %Outer %tint_convert_explicit_layout_0 %58 - %61 = OpLoad %_arr_Inner_uint_4 %p_a_i_a None - %l_a_i_a = OpFunctionCall %_arr_Inner_uint_4_0 %tint_convert_explicit_layout %61 + %50 = OpFunctionCall %int %i + %51 = OpBitcast %uint %50 + %52 = OpExtInst %uint %37 UMin %51 %uint_3 +%p_a_i_a_i_m_i = OpAccessChain %_ptr_Uniform_v4float %p_a_i_a_i_m %52 + %55 = OpLoad %_arr_Outer_tint_explicit_layout_uint_4 %p_a None + %l_a = OpFunctionCall %_arr_Outer_uint_4 %tint_convert_explicit_layout_1 %55 + %61 = OpLoad %Outer_tint_explicit_layout %p_a_i None + %l_a_i = OpFunctionCall %Outer %tint_convert_explicit_layout_0 %61 + %64 = OpLoad %_arr_Inner_uint_4 %p_a_i_a None + %l_a_i_a = OpFunctionCall %_arr_Inner_uint_4_0 %tint_convert_explicit_layout %64 %l_a_i_a_i = OpLoad %Inner %p_a_i_a_i None %l_a_i_a_i_m = OpLoad %mat4v4float %p_a_i_a_i_m None %l_a_i_a_i_m_i = OpLoad %v4float %p_a_i_a_i_m_i None - %67 = OpFunctionCall %int %i - %68 = OpBitcast %uint %67 - %69 = OpExtInst %uint %34 UMin %68 %uint_3 - %70 = OpAccessChain %_ptr_Uniform_float %p_a_i_a_i_m_i %69 -%l_a_i_a_i_m_i_i = OpLoad %float %70 None + %70 = OpFunctionCall %int %i + %71 = OpBitcast %uint %70 + %72 = OpExtInst %uint %37 UMin %71 %uint_3 + %73 = OpAccessChain %_ptr_Uniform_float %p_a_i_a_i_m_i %72 +%l_a_i_a_i_m_i_i = OpLoad %float %73 None OpReturn OpFunctionEnd -%tint_convert_explicit_layout = OpFunction %_arr_Inner_uint_4_0 None %74 +%tint_convert_explicit_layout = OpFunction %_arr_Inner_uint_4_0 None %77 %tint_source = OpFunctionParameter %_arr_Inner_uint_4 - %75 = OpLabel - %76 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function - %78 = OpVariable %_ptr_Function__arr_Inner_uint_4_0 Function %80 - OpStore %76 %tint_source - OpBranch %81 - %81 = OpLabel + %78 = OpLabel + %79 = OpVariable %_ptr_Function__arr_Inner_uint_4 Function + %81 = OpVariable %_ptr_Function__arr_Inner_uint_4_0 Function %83 + OpStore %79 %tint_source OpBranch %84 %84 = OpLabel - %86 = OpPhi %uint %uint_0 %81 %87 %83 - OpLoopMerge %85 %83 None - OpBranch %82 - %82 = OpLabel - %89 = OpUGreaterThanEqual %bool %86 %uint_4 - OpSelectionMerge %91 None - OpBranchConditional %89 %92 %91 - %92 = OpLabel + OpBranch %87 + %87 = OpLabel + %89 = OpPhi %uint %uint_0 %84 %90 %86 + OpLoopMerge %88 %86 None OpBranch %85 - %91 = OpLabel - %93 = OpAccessChain %_ptr_Function_Inner %76 %86 - %95 = OpLoad %Inner %93 None - %96 = OpAccessChain %_ptr_Function_Inner %78 %86 - OpStore %96 %95 None - OpBranch %83 - %83 = OpLabel - %87 = OpIAdd %uint %86 %uint_1 - OpBranch %84 %85 = OpLabel - %88 = OpLoad %_arr_Inner_uint_4_0 %78 None - OpReturnValue %88 + %92 = OpUGreaterThanEqual %bool %89 %uint_4 + OpSelectionMerge %94 None + OpBranchConditional %92 %95 %94 + %95 = OpLabel + OpBranch %88 + %94 = OpLabel + %96 = OpAccessChain %_ptr_Function_Inner %79 %89 + %98 = OpLoad %Inner %96 None + %99 = OpAccessChain %_ptr_Function_Inner %81 %89 + OpStore %99 %98 None + OpBranch %86 + %86 = OpLabel + %90 = OpIAdd %uint %89 %uint_1 + OpBranch %87 + %88 = OpLabel + %91 = OpLoad %_arr_Inner_uint_4_0 %81 None + OpReturnValue %91 OpFunctionEnd -%tint_convert_explicit_layout_0 = OpFunction %Outer None %99 +%tint_convert_explicit_layout_0 = OpFunction %Outer None %102 %tint_source_0 = OpFunctionParameter %Outer_tint_explicit_layout - %100 = OpLabel - %101 = OpCompositeExtract %_arr_Inner_uint_4 %tint_source_0 0 - %102 = OpFunctionCall %_arr_Inner_uint_4_0 %tint_convert_explicit_layout %101 - %103 = OpCompositeConstruct %Outer %102 - OpReturnValue %103 + %103 = OpLabel + %104 = OpCompositeExtract %_arr_Inner_uint_4 %tint_source_0 0 + %105 = OpFunctionCall %_arr_Inner_uint_4_0 %tint_convert_explicit_layout %104 + %106 = OpCompositeConstruct %Outer %105 + OpReturnValue %106 OpFunctionEnd -%tint_convert_explicit_layout_1 = OpFunction %_arr_Outer_uint_4 None %105 +%tint_convert_explicit_layout_1 = OpFunction %_arr_Outer_uint_4 None %108 %tint_source_1 = OpFunctionParameter %_arr_Outer_tint_explicit_layout_uint_4 - %106 = OpLabel - %107 = OpVariable %_ptr_Function__arr_Outer_tint_explicit_layout_uint_4 Function - %109 = OpVariable %_ptr_Function__arr_Outer_uint_4 Function %111 - OpStore %107 %tint_source_1 - OpBranch %112 - %112 = OpLabel + %109 = OpLabel + %110 = OpVariable %_ptr_Function__arr_Outer_tint_explicit_layout_uint_4 Function + %112 = OpVariable %_ptr_Function__arr_Outer_uint_4 Function %114 + OpStore %110 %tint_source_1 OpBranch %115 %115 = OpLabel - %117 = OpPhi %uint %uint_0 %112 %118 %114 - OpLoopMerge %116 %114 None - OpBranch %113 - %113 = OpLabel - %120 = OpUGreaterThanEqual %bool %117 %uint_4 - OpSelectionMerge %121 None - OpBranchConditional %120 %122 %121 - %122 = OpLabel + OpBranch %118 + %118 = OpLabel + %120 = OpPhi %uint %uint_0 %115 %121 %117 + OpLoopMerge %119 %117 None OpBranch %116 - %121 = OpLabel - %123 = OpAccessChain %_ptr_Function_Outer_tint_explicit_layout %107 %117 - %125 = OpLoad %Outer_tint_explicit_layout %123 None - %126 = OpFunctionCall %Outer %tint_convert_explicit_layout_0 %125 - %127 = OpAccessChain %_ptr_Function_Outer %109 %117 - OpStore %127 %126 None - OpBranch %114 - %114 = OpLabel - %118 = OpIAdd %uint %117 %uint_1 - OpBranch %115 %116 = OpLabel - %119 = OpLoad %_arr_Outer_uint_4 %109 None - OpReturnValue %119 + %123 = OpUGreaterThanEqual %bool %120 %uint_4 + OpSelectionMerge %124 None + OpBranchConditional %123 %125 %124 + %125 = OpLabel + OpBranch %119 + %124 = OpLabel + %126 = OpAccessChain %_ptr_Function_Outer_tint_explicit_layout %110 %120 + %128 = OpLoad %Outer_tint_explicit_layout %126 None + %129 = OpFunctionCall %Outer %tint_convert_explicit_layout_0 %128 + %130 = OpAccessChain %_ptr_Function_Outer %112 %120 + OpStore %130 %129 None + OpBranch %117 + %117 = OpLabel + %121 = OpIAdd %uint %120 %uint_1 + OpBranch %118 + %119 = OpLabel + %122 = OpLoad %_arr_Outer_uint_4 %112 None + OpReturnValue %122 OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/unnested/mat2x2_f16/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/unnested/mat2x2_f16/dynamic_index_via_ptr.wgsl.expected.glsl index c3370d2..6fdec26 100644 --- a/test/tint/buffer/uniform/std140/unnested/mat2x2_f16/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/unnested/mat2x2_f16/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -8,12 +8,13 @@ } v; int counter = 0; int i() { - counter = (counter + 1); + uint v_1 = uint(counter); + counter = int((v_1 + uint(1))); return counter; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - f16mat2 v_1 = f16mat2(v.inner_col0, v.inner_col1); - f16mat2 l_m = v_1; - f16vec2 l_m_i = v_1[min(uint(i()), 1u)]; + f16mat2 v_2 = f16mat2(v.inner_col0, v.inner_col1); + f16mat2 l_m = v_2; + f16vec2 l_m_i = v_2[min(uint(i()), 1u)]; }
diff --git a/test/tint/buffer/uniform/std140/unnested/mat2x2_f16/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/unnested/mat2x2_f16/dynamic_index_via_ptr.wgsl.expected.spvasm index d709a24..e8f38cc 100644 --- a/test/tint/buffer/uniform/std140/unnested/mat2x2_f16/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/unnested/mat2x2_f16/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,13 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 40 +; Bound: 43 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess - %36 = OpExtInstImport "GLSL.std.450" + %39 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -35,11 +35,11 @@ %int_0 = OpConstant %int 0 %counter = OpVariable %_ptr_Private_int Private %int_0 %11 = OpTypeFunction %int + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %void = OpTypeVoid - %19 = OpTypeFunction %void + %23 = OpTypeFunction %void %_ptr_Uniform_v2half = OpTypePointer Uniform %v2half - %uint = OpTypeInt 32 0 %uint_0 = OpConstant %uint 0 %uint_1 = OpConstant %uint 1 %mat2v2half = OpTypeMatrix %v2half 2 @@ -48,24 +48,27 @@ %i = OpFunction %int None %11 %12 = OpLabel %13 = OpLoad %int %counter None - %14 = OpIAdd %int %13 %int_1 - OpStore %counter %14 None - %16 = OpLoad %int %counter None - OpReturnValue %16 + %15 = OpBitcast %uint %13 + %16 = OpBitcast %uint %int_1 + %18 = OpIAdd %uint %15 %16 + %19 = OpBitcast %int %18 + OpStore %counter %19 None + %20 = OpLoad %int %counter None + OpReturnValue %20 OpFunctionEnd - %f = OpFunction %void None %19 - %20 = OpLabel - %31 = OpVariable %_ptr_Function_mat2v2half Function - %21 = OpAccessChain %_ptr_Uniform_v2half %1 %uint_0 - %25 = OpLoad %v2half %21 None - %26 = OpAccessChain %_ptr_Uniform_v2half %1 %uint_1 - %28 = OpLoad %v2half %26 None - %l_m = OpCompositeConstruct %mat2v2half %25 %28 - OpStore %31 %l_m - %33 = OpFunctionCall %int %i - %34 = OpBitcast %uint %33 - %35 = OpExtInst %uint %36 UMin %34 %uint_1 - %37 = OpAccessChain %_ptr_Function_v2half %31 %35 - %l_m_i = OpLoad %v2half %37 None + %f = OpFunction %void None %23 + %24 = OpLabel + %34 = OpVariable %_ptr_Function_mat2v2half Function + %25 = OpAccessChain %_ptr_Uniform_v2half %1 %uint_0 + %28 = OpLoad %v2half %25 None + %29 = OpAccessChain %_ptr_Uniform_v2half %1 %uint_1 + %31 = OpLoad %v2half %29 None + %l_m = OpCompositeConstruct %mat2v2half %28 %31 + OpStore %34 %l_m + %36 = OpFunctionCall %int %i + %37 = OpBitcast %uint %36 + %38 = OpExtInst %uint %39 UMin %37 %uint_1 + %40 = OpAccessChain %_ptr_Function_v2half %34 %38 + %l_m_i = OpLoad %v2half %40 None OpReturn OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/unnested/mat2x2_f32/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/unnested/mat2x2_f32/dynamic_index_via_ptr.wgsl.expected.glsl index 4978a8e..87d7a7d3 100644 --- a/test/tint/buffer/uniform/std140/unnested/mat2x2_f32/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/unnested/mat2x2_f32/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -7,12 +7,13 @@ } v; int counter = 0; int i() { - counter = (counter + 1); + uint v_1 = uint(counter); + counter = int((v_1 + uint(1))); return counter; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - mat2 v_1 = mat2(v.inner_col0, v.inner_col1); - mat2 l_m = v_1; - vec2 l_m_i = v_1[min(uint(i()), 1u)]; + mat2 v_2 = mat2(v.inner_col0, v.inner_col1); + mat2 l_m = v_2; + vec2 l_m_i = v_2[min(uint(i()), 1u)]; }
diff --git a/test/tint/buffer/uniform/std140/unnested/mat2x2_f32/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/unnested/mat2x2_f32/dynamic_index_via_ptr.wgsl.expected.spvasm index 15c091c..34d2034 100644 --- a/test/tint/buffer/uniform/std140/unnested/mat2x2_f32/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/unnested/mat2x2_f32/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,10 +1,10 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 40 +; Bound: 43 ; Schema: 0 OpCapability Shader - %36 = OpExtInstImport "GLSL.std.450" + %39 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -32,11 +32,11 @@ %int_0 = OpConstant %int 0 %counter = OpVariable %_ptr_Private_int Private %int_0 %11 = OpTypeFunction %int + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %void = OpTypeVoid - %19 = OpTypeFunction %void + %23 = OpTypeFunction %void %_ptr_Uniform_v2float = OpTypePointer Uniform %v2float - %uint = OpTypeInt 32 0 %uint_0 = OpConstant %uint 0 %uint_1 = OpConstant %uint 1 %mat2v2float = OpTypeMatrix %v2float 2 @@ -45,24 +45,27 @@ %i = OpFunction %int None %11 %12 = OpLabel %13 = OpLoad %int %counter None - %14 = OpIAdd %int %13 %int_1 - OpStore %counter %14 None - %16 = OpLoad %int %counter None - OpReturnValue %16 + %15 = OpBitcast %uint %13 + %16 = OpBitcast %uint %int_1 + %18 = OpIAdd %uint %15 %16 + %19 = OpBitcast %int %18 + OpStore %counter %19 None + %20 = OpLoad %int %counter None + OpReturnValue %20 OpFunctionEnd - %f = OpFunction %void None %19 - %20 = OpLabel - %31 = OpVariable %_ptr_Function_mat2v2float Function - %21 = OpAccessChain %_ptr_Uniform_v2float %1 %uint_0 - %25 = OpLoad %v2float %21 None - %26 = OpAccessChain %_ptr_Uniform_v2float %1 %uint_1 - %28 = OpLoad %v2float %26 None - %l_m = OpCompositeConstruct %mat2v2float %25 %28 - OpStore %31 %l_m - %33 = OpFunctionCall %int %i - %34 = OpBitcast %uint %33 - %35 = OpExtInst %uint %36 UMin %34 %uint_1 - %37 = OpAccessChain %_ptr_Function_v2float %31 %35 - %l_m_i = OpLoad %v2float %37 None + %f = OpFunction %void None %23 + %24 = OpLabel + %34 = OpVariable %_ptr_Function_mat2v2float Function + %25 = OpAccessChain %_ptr_Uniform_v2float %1 %uint_0 + %28 = OpLoad %v2float %25 None + %29 = OpAccessChain %_ptr_Uniform_v2float %1 %uint_1 + %31 = OpLoad %v2float %29 None + %l_m = OpCompositeConstruct %mat2v2float %28 %31 + OpStore %34 %l_m + %36 = OpFunctionCall %int %i + %37 = OpBitcast %uint %36 + %38 = OpExtInst %uint %39 UMin %37 %uint_1 + %40 = OpAccessChain %_ptr_Function_v2float %34 %38 + %l_m_i = OpLoad %v2float %40 None OpReturn OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/unnested/mat2x3_f16/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/unnested/mat2x3_f16/dynamic_index_via_ptr.wgsl.expected.glsl index 006d78e..846838d 100644 --- a/test/tint/buffer/uniform/std140/unnested/mat2x3_f16/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/unnested/mat2x3_f16/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -8,12 +8,13 @@ } v; int counter = 0; int i() { - counter = (counter + 1); + uint v_1 = uint(counter); + counter = int((v_1 + uint(1))); return counter; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - f16mat2x3 v_1 = f16mat2x3(v.inner_col0, v.inner_col1); - f16mat2x3 l_m = v_1; - f16vec3 l_m_i = v_1[min(uint(i()), 1u)]; + f16mat2x3 v_2 = f16mat2x3(v.inner_col0, v.inner_col1); + f16mat2x3 l_m = v_2; + f16vec3 l_m_i = v_2[min(uint(i()), 1u)]; }
diff --git a/test/tint/buffer/uniform/std140/unnested/mat2x3_f16/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/unnested/mat2x3_f16/dynamic_index_via_ptr.wgsl.expected.spvasm index 539e853..2f5f361 100644 --- a/test/tint/buffer/uniform/std140/unnested/mat2x3_f16/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/unnested/mat2x3_f16/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,13 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 40 +; Bound: 43 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess - %36 = OpExtInstImport "GLSL.std.450" + %39 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -35,11 +35,11 @@ %int_0 = OpConstant %int 0 %counter = OpVariable %_ptr_Private_int Private %int_0 %11 = OpTypeFunction %int + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %void = OpTypeVoid - %19 = OpTypeFunction %void + %23 = OpTypeFunction %void %_ptr_Uniform_v3half = OpTypePointer Uniform %v3half - %uint = OpTypeInt 32 0 %uint_0 = OpConstant %uint 0 %uint_1 = OpConstant %uint 1 %mat2v3half = OpTypeMatrix %v3half 2 @@ -48,24 +48,27 @@ %i = OpFunction %int None %11 %12 = OpLabel %13 = OpLoad %int %counter None - %14 = OpIAdd %int %13 %int_1 - OpStore %counter %14 None - %16 = OpLoad %int %counter None - OpReturnValue %16 + %15 = OpBitcast %uint %13 + %16 = OpBitcast %uint %int_1 + %18 = OpIAdd %uint %15 %16 + %19 = OpBitcast %int %18 + OpStore %counter %19 None + %20 = OpLoad %int %counter None + OpReturnValue %20 OpFunctionEnd - %f = OpFunction %void None %19 - %20 = OpLabel - %31 = OpVariable %_ptr_Function_mat2v3half Function - %21 = OpAccessChain %_ptr_Uniform_v3half %1 %uint_0 - %25 = OpLoad %v3half %21 None - %26 = OpAccessChain %_ptr_Uniform_v3half %1 %uint_1 - %28 = OpLoad %v3half %26 None - %l_m = OpCompositeConstruct %mat2v3half %25 %28 - OpStore %31 %l_m - %33 = OpFunctionCall %int %i - %34 = OpBitcast %uint %33 - %35 = OpExtInst %uint %36 UMin %34 %uint_1 - %37 = OpAccessChain %_ptr_Function_v3half %31 %35 - %l_m_i = OpLoad %v3half %37 None + %f = OpFunction %void None %23 + %24 = OpLabel + %34 = OpVariable %_ptr_Function_mat2v3half Function + %25 = OpAccessChain %_ptr_Uniform_v3half %1 %uint_0 + %28 = OpLoad %v3half %25 None + %29 = OpAccessChain %_ptr_Uniform_v3half %1 %uint_1 + %31 = OpLoad %v3half %29 None + %l_m = OpCompositeConstruct %mat2v3half %28 %31 + OpStore %34 %l_m + %36 = OpFunctionCall %int %i + %37 = OpBitcast %uint %36 + %38 = OpExtInst %uint %39 UMin %37 %uint_1 + %40 = OpAccessChain %_ptr_Function_v3half %34 %38 + %l_m_i = OpLoad %v3half %40 None OpReturn OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/unnested/mat2x3_f32/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/unnested/mat2x3_f32/dynamic_index_via_ptr.wgsl.expected.glsl index bc80aa9..d45cdec 100644 --- a/test/tint/buffer/uniform/std140/unnested/mat2x3_f32/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/unnested/mat2x3_f32/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -8,12 +8,13 @@ } v; int counter = 0; int i() { - counter = (counter + 1); + uint v_1 = uint(counter); + counter = int((v_1 + uint(1))); return counter; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - mat2x3 v_1 = mat2x3(v.inner_col0, v.inner_col1); - mat2x3 l_m = v_1; - vec3 l_m_i = v_1[min(uint(i()), 1u)]; + mat2x3 v_2 = mat2x3(v.inner_col0, v.inner_col1); + mat2x3 l_m = v_2; + vec3 l_m_i = v_2[min(uint(i()), 1u)]; }
diff --git a/test/tint/buffer/uniform/std140/unnested/mat2x3_f32/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/unnested/mat2x3_f32/dynamic_index_via_ptr.wgsl.expected.spvasm index a050239..6745710 100644 --- a/test/tint/buffer/uniform/std140/unnested/mat2x3_f32/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/unnested/mat2x3_f32/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,10 +1,10 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 40 +; Bound: 43 ; Schema: 0 OpCapability Shader - %36 = OpExtInstImport "GLSL.std.450" + %39 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -32,11 +32,11 @@ %int_0 = OpConstant %int 0 %counter = OpVariable %_ptr_Private_int Private %int_0 %11 = OpTypeFunction %int + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %void = OpTypeVoid - %19 = OpTypeFunction %void + %23 = OpTypeFunction %void %_ptr_Uniform_v3float = OpTypePointer Uniform %v3float - %uint = OpTypeInt 32 0 %uint_0 = OpConstant %uint 0 %uint_1 = OpConstant %uint 1 %mat2v3float = OpTypeMatrix %v3float 2 @@ -45,24 +45,27 @@ %i = OpFunction %int None %11 %12 = OpLabel %13 = OpLoad %int %counter None - %14 = OpIAdd %int %13 %int_1 - OpStore %counter %14 None - %16 = OpLoad %int %counter None - OpReturnValue %16 + %15 = OpBitcast %uint %13 + %16 = OpBitcast %uint %int_1 + %18 = OpIAdd %uint %15 %16 + %19 = OpBitcast %int %18 + OpStore %counter %19 None + %20 = OpLoad %int %counter None + OpReturnValue %20 OpFunctionEnd - %f = OpFunction %void None %19 - %20 = OpLabel - %31 = OpVariable %_ptr_Function_mat2v3float Function - %21 = OpAccessChain %_ptr_Uniform_v3float %1 %uint_0 - %25 = OpLoad %v3float %21 None - %26 = OpAccessChain %_ptr_Uniform_v3float %1 %uint_1 - %28 = OpLoad %v3float %26 None - %l_m = OpCompositeConstruct %mat2v3float %25 %28 - OpStore %31 %l_m - %33 = OpFunctionCall %int %i - %34 = OpBitcast %uint %33 - %35 = OpExtInst %uint %36 UMin %34 %uint_1 - %37 = OpAccessChain %_ptr_Function_v3float %31 %35 - %l_m_i = OpLoad %v3float %37 None + %f = OpFunction %void None %23 + %24 = OpLabel + %34 = OpVariable %_ptr_Function_mat2v3float Function + %25 = OpAccessChain %_ptr_Uniform_v3float %1 %uint_0 + %28 = OpLoad %v3float %25 None + %29 = OpAccessChain %_ptr_Uniform_v3float %1 %uint_1 + %31 = OpLoad %v3float %29 None + %l_m = OpCompositeConstruct %mat2v3float %28 %31 + OpStore %34 %l_m + %36 = OpFunctionCall %int %i + %37 = OpBitcast %uint %36 + %38 = OpExtInst %uint %39 UMin %37 %uint_1 + %40 = OpAccessChain %_ptr_Function_v3float %34 %38 + %l_m_i = OpLoad %v3float %40 None OpReturn OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/unnested/mat2x4_f16/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/unnested/mat2x4_f16/dynamic_index_via_ptr.wgsl.expected.glsl index 74224e3..a0664ea 100644 --- a/test/tint/buffer/uniform/std140/unnested/mat2x4_f16/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/unnested/mat2x4_f16/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -8,12 +8,13 @@ } v; int counter = 0; int i() { - counter = (counter + 1); + uint v_1 = uint(counter); + counter = int((v_1 + uint(1))); return counter; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - f16mat2x4 v_1 = f16mat2x4(v.inner_col0, v.inner_col1); - f16mat2x4 l_m = v_1; - f16vec4 l_m_i = v_1[min(uint(i()), 1u)]; + f16mat2x4 v_2 = f16mat2x4(v.inner_col0, v.inner_col1); + f16mat2x4 l_m = v_2; + f16vec4 l_m_i = v_2[min(uint(i()), 1u)]; }
diff --git a/test/tint/buffer/uniform/std140/unnested/mat2x4_f16/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/unnested/mat2x4_f16/dynamic_index_via_ptr.wgsl.expected.spvasm index 6899370..2355b65 100644 --- a/test/tint/buffer/uniform/std140/unnested/mat2x4_f16/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/unnested/mat2x4_f16/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,13 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 40 +; Bound: 43 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess - %36 = OpExtInstImport "GLSL.std.450" + %39 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -35,11 +35,11 @@ %int_0 = OpConstant %int 0 %counter = OpVariable %_ptr_Private_int Private %int_0 %11 = OpTypeFunction %int + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %void = OpTypeVoid - %19 = OpTypeFunction %void + %23 = OpTypeFunction %void %_ptr_Uniform_v4half = OpTypePointer Uniform %v4half - %uint = OpTypeInt 32 0 %uint_0 = OpConstant %uint 0 %uint_1 = OpConstant %uint 1 %mat2v4half = OpTypeMatrix %v4half 2 @@ -48,24 +48,27 @@ %i = OpFunction %int None %11 %12 = OpLabel %13 = OpLoad %int %counter None - %14 = OpIAdd %int %13 %int_1 - OpStore %counter %14 None - %16 = OpLoad %int %counter None - OpReturnValue %16 + %15 = OpBitcast %uint %13 + %16 = OpBitcast %uint %int_1 + %18 = OpIAdd %uint %15 %16 + %19 = OpBitcast %int %18 + OpStore %counter %19 None + %20 = OpLoad %int %counter None + OpReturnValue %20 OpFunctionEnd - %f = OpFunction %void None %19 - %20 = OpLabel - %31 = OpVariable %_ptr_Function_mat2v4half Function - %21 = OpAccessChain %_ptr_Uniform_v4half %1 %uint_0 - %25 = OpLoad %v4half %21 None - %26 = OpAccessChain %_ptr_Uniform_v4half %1 %uint_1 - %28 = OpLoad %v4half %26 None - %l_m = OpCompositeConstruct %mat2v4half %25 %28 - OpStore %31 %l_m - %33 = OpFunctionCall %int %i - %34 = OpBitcast %uint %33 - %35 = OpExtInst %uint %36 UMin %34 %uint_1 - %37 = OpAccessChain %_ptr_Function_v4half %31 %35 - %l_m_i = OpLoad %v4half %37 None + %f = OpFunction %void None %23 + %24 = OpLabel + %34 = OpVariable %_ptr_Function_mat2v4half Function + %25 = OpAccessChain %_ptr_Uniform_v4half %1 %uint_0 + %28 = OpLoad %v4half %25 None + %29 = OpAccessChain %_ptr_Uniform_v4half %1 %uint_1 + %31 = OpLoad %v4half %29 None + %l_m = OpCompositeConstruct %mat2v4half %28 %31 + OpStore %34 %l_m + %36 = OpFunctionCall %int %i + %37 = OpBitcast %uint %36 + %38 = OpExtInst %uint %39 UMin %37 %uint_1 + %40 = OpAccessChain %_ptr_Function_v4half %34 %38 + %l_m_i = OpLoad %v4half %40 None OpReturn OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/unnested/mat2x4_f32/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/unnested/mat2x4_f32/dynamic_index_via_ptr.wgsl.expected.glsl index 566f493..cafbe18 100644 --- a/test/tint/buffer/uniform/std140/unnested/mat2x4_f32/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/unnested/mat2x4_f32/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -6,12 +6,13 @@ } v; int counter = 0; int i() { - counter = (counter + 1); + uint v_1 = uint(counter); + counter = int((v_1 + uint(1))); return counter; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - uint v_1 = min(uint(i()), 1u); + uint v_2 = min(uint(i()), 1u); mat2x4 l_m = v.inner; - vec4 l_m_i = v.inner[v_1]; + vec4 l_m_i = v.inner[v_2]; }
diff --git a/test/tint/buffer/uniform/std140/unnested/mat2x4_f32/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/unnested/mat2x4_f32/dynamic_index_via_ptr.wgsl.expected.spvasm index 885aeb1..2332a91 100644 --- a/test/tint/buffer/uniform/std140/unnested/mat2x4_f32/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/unnested/mat2x4_f32/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,10 +1,10 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 35 +; Bound: 38 ; Schema: 0 OpCapability Shader - %29 = OpExtInstImport "GLSL.std.450" + %32 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -35,29 +35,32 @@ %int_0 = OpConstant %int 0 %counter = OpVariable %_ptr_Private_int Private %int_0 %12 = OpTypeFunction %int + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %void = OpTypeVoid - %20 = OpTypeFunction %void + %24 = OpTypeFunction %void %_ptr_Uniform_mat2v4float = OpTypePointer Uniform %mat2v4float - %uint = OpTypeInt 32 0 %uint_0 = OpConstant %uint 0 %uint_1 = OpConstant %uint 1 %_ptr_Uniform_v4float = OpTypePointer Uniform %v4float %i = OpFunction %int None %12 %13 = OpLabel %14 = OpLoad %int %counter None - %15 = OpIAdd %int %14 %int_1 - OpStore %counter %15 None - %17 = OpLoad %int %counter None - OpReturnValue %17 + %16 = OpBitcast %uint %14 + %17 = OpBitcast %uint %int_1 + %19 = OpIAdd %uint %16 %17 + %20 = OpBitcast %int %19 + OpStore %counter %20 None + %21 = OpLoad %int %counter None + OpReturnValue %21 OpFunctionEnd - %f = OpFunction %void None %20 - %21 = OpLabel + %f = OpFunction %void None %24 + %25 = OpLabel %p_m = OpAccessChain %_ptr_Uniform_mat2v4float %1 %uint_0 - %26 = OpFunctionCall %int %i - %27 = OpBitcast %uint %26 - %28 = OpExtInst %uint %29 UMin %27 %uint_1 - %p_m_i = OpAccessChain %_ptr_Uniform_v4float %p_m %28 + %29 = OpFunctionCall %int %i + %30 = OpBitcast %uint %29 + %31 = OpExtInst %uint %32 UMin %30 %uint_1 + %p_m_i = OpAccessChain %_ptr_Uniform_v4float %p_m %31 %l_m = OpLoad %mat2v4float %p_m None %l_m_i = OpLoad %v4float %p_m_i None OpReturn
diff --git a/test/tint/buffer/uniform/std140/unnested/mat3x2_f16/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/unnested/mat3x2_f16/dynamic_index_via_ptr.wgsl.expected.glsl index b11ca7d..3b7392b 100644 --- a/test/tint/buffer/uniform/std140/unnested/mat3x2_f16/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/unnested/mat3x2_f16/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -9,12 +9,13 @@ } v; int counter = 0; int i() { - counter = (counter + 1); + uint v_1 = uint(counter); + counter = int((v_1 + uint(1))); return counter; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - f16mat3x2 v_1 = f16mat3x2(v.inner_col0, v.inner_col1, v.inner_col2); - f16mat3x2 l_m = v_1; - f16vec2 l_m_i = v_1[min(uint(i()), 2u)]; + f16mat3x2 v_2 = f16mat3x2(v.inner_col0, v.inner_col1, v.inner_col2); + f16mat3x2 l_m = v_2; + f16vec2 l_m_i = v_2[min(uint(i()), 2u)]; }
diff --git a/test/tint/buffer/uniform/std140/unnested/mat3x2_f16/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/unnested/mat3x2_f16/dynamic_index_via_ptr.wgsl.expected.spvasm index 53588e8..7761bc5 100644 --- a/test/tint/buffer/uniform/std140/unnested/mat3x2_f16/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/unnested/mat3x2_f16/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,13 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 43 +; Bound: 46 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess - %39 = OpExtInstImport "GLSL.std.450" + %42 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -37,11 +37,11 @@ %int_0 = OpConstant %int 0 %counter = OpVariable %_ptr_Private_int Private %int_0 %11 = OpTypeFunction %int + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %void = OpTypeVoid - %19 = OpTypeFunction %void + %23 = OpTypeFunction %void %_ptr_Uniform_v2half = OpTypePointer Uniform %v2half - %uint = OpTypeInt 32 0 %uint_0 = OpConstant %uint 0 %uint_1 = OpConstant %uint 1 %uint_2 = OpConstant %uint 2 @@ -51,26 +51,29 @@ %i = OpFunction %int None %11 %12 = OpLabel %13 = OpLoad %int %counter None - %14 = OpIAdd %int %13 %int_1 - OpStore %counter %14 None - %16 = OpLoad %int %counter None - OpReturnValue %16 + %15 = OpBitcast %uint %13 + %16 = OpBitcast %uint %int_1 + %18 = OpIAdd %uint %15 %16 + %19 = OpBitcast %int %18 + OpStore %counter %19 None + %20 = OpLoad %int %counter None + OpReturnValue %20 OpFunctionEnd - %f = OpFunction %void None %19 - %20 = OpLabel - %34 = OpVariable %_ptr_Function_mat3v2half Function - %21 = OpAccessChain %_ptr_Uniform_v2half %1 %uint_0 - %25 = OpLoad %v2half %21 None - %26 = OpAccessChain %_ptr_Uniform_v2half %1 %uint_1 - %28 = OpLoad %v2half %26 None - %29 = OpAccessChain %_ptr_Uniform_v2half %1 %uint_2 + %f = OpFunction %void None %23 + %24 = OpLabel + %37 = OpVariable %_ptr_Function_mat3v2half Function + %25 = OpAccessChain %_ptr_Uniform_v2half %1 %uint_0 + %28 = OpLoad %v2half %25 None + %29 = OpAccessChain %_ptr_Uniform_v2half %1 %uint_1 %31 = OpLoad %v2half %29 None - %l_m = OpCompositeConstruct %mat3v2half %25 %28 %31 - OpStore %34 %l_m - %36 = OpFunctionCall %int %i - %37 = OpBitcast %uint %36 - %38 = OpExtInst %uint %39 UMin %37 %uint_2 - %40 = OpAccessChain %_ptr_Function_v2half %34 %38 - %l_m_i = OpLoad %v2half %40 None + %32 = OpAccessChain %_ptr_Uniform_v2half %1 %uint_2 + %34 = OpLoad %v2half %32 None + %l_m = OpCompositeConstruct %mat3v2half %28 %31 %34 + OpStore %37 %l_m + %39 = OpFunctionCall %int %i + %40 = OpBitcast %uint %39 + %41 = OpExtInst %uint %42 UMin %40 %uint_2 + %43 = OpAccessChain %_ptr_Function_v2half %37 %41 + %l_m_i = OpLoad %v2half %43 None OpReturn OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/unnested/mat3x2_f32/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/unnested/mat3x2_f32/dynamic_index_via_ptr.wgsl.expected.glsl index 3a5136e..e9207ee 100644 --- a/test/tint/buffer/uniform/std140/unnested/mat3x2_f32/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/unnested/mat3x2_f32/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -8,12 +8,13 @@ } v; int counter = 0; int i() { - counter = (counter + 1); + uint v_1 = uint(counter); + counter = int((v_1 + uint(1))); return counter; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - mat3x2 v_1 = mat3x2(v.inner_col0, v.inner_col1, v.inner_col2); - mat3x2 l_m = v_1; - vec2 l_m_i = v_1[min(uint(i()), 2u)]; + mat3x2 v_2 = mat3x2(v.inner_col0, v.inner_col1, v.inner_col2); + mat3x2 l_m = v_2; + vec2 l_m_i = v_2[min(uint(i()), 2u)]; }
diff --git a/test/tint/buffer/uniform/std140/unnested/mat3x2_f32/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/unnested/mat3x2_f32/dynamic_index_via_ptr.wgsl.expected.spvasm index fa1ce06..bfa8645 100644 --- a/test/tint/buffer/uniform/std140/unnested/mat3x2_f32/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/unnested/mat3x2_f32/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,10 +1,10 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 43 +; Bound: 46 ; Schema: 0 OpCapability Shader - %39 = OpExtInstImport "GLSL.std.450" + %42 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -34,11 +34,11 @@ %int_0 = OpConstant %int 0 %counter = OpVariable %_ptr_Private_int Private %int_0 %11 = OpTypeFunction %int + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %void = OpTypeVoid - %19 = OpTypeFunction %void + %23 = OpTypeFunction %void %_ptr_Uniform_v2float = OpTypePointer Uniform %v2float - %uint = OpTypeInt 32 0 %uint_0 = OpConstant %uint 0 %uint_1 = OpConstant %uint 1 %uint_2 = OpConstant %uint 2 @@ -48,26 +48,29 @@ %i = OpFunction %int None %11 %12 = OpLabel %13 = OpLoad %int %counter None - %14 = OpIAdd %int %13 %int_1 - OpStore %counter %14 None - %16 = OpLoad %int %counter None - OpReturnValue %16 + %15 = OpBitcast %uint %13 + %16 = OpBitcast %uint %int_1 + %18 = OpIAdd %uint %15 %16 + %19 = OpBitcast %int %18 + OpStore %counter %19 None + %20 = OpLoad %int %counter None + OpReturnValue %20 OpFunctionEnd - %f = OpFunction %void None %19 - %20 = OpLabel - %34 = OpVariable %_ptr_Function_mat3v2float Function - %21 = OpAccessChain %_ptr_Uniform_v2float %1 %uint_0 - %25 = OpLoad %v2float %21 None - %26 = OpAccessChain %_ptr_Uniform_v2float %1 %uint_1 - %28 = OpLoad %v2float %26 None - %29 = OpAccessChain %_ptr_Uniform_v2float %1 %uint_2 + %f = OpFunction %void None %23 + %24 = OpLabel + %37 = OpVariable %_ptr_Function_mat3v2float Function + %25 = OpAccessChain %_ptr_Uniform_v2float %1 %uint_0 + %28 = OpLoad %v2float %25 None + %29 = OpAccessChain %_ptr_Uniform_v2float %1 %uint_1 %31 = OpLoad %v2float %29 None - %l_m = OpCompositeConstruct %mat3v2float %25 %28 %31 - OpStore %34 %l_m - %36 = OpFunctionCall %int %i - %37 = OpBitcast %uint %36 - %38 = OpExtInst %uint %39 UMin %37 %uint_2 - %40 = OpAccessChain %_ptr_Function_v2float %34 %38 - %l_m_i = OpLoad %v2float %40 None + %32 = OpAccessChain %_ptr_Uniform_v2float %1 %uint_2 + %34 = OpLoad %v2float %32 None + %l_m = OpCompositeConstruct %mat3v2float %28 %31 %34 + OpStore %37 %l_m + %39 = OpFunctionCall %int %i + %40 = OpBitcast %uint %39 + %41 = OpExtInst %uint %42 UMin %40 %uint_2 + %43 = OpAccessChain %_ptr_Function_v2float %37 %41 + %l_m_i = OpLoad %v2float %43 None OpReturn OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/unnested/mat3x3_f16/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/unnested/mat3x3_f16/dynamic_index_via_ptr.wgsl.expected.glsl index 164799c..6e5f29f 100644 --- a/test/tint/buffer/uniform/std140/unnested/mat3x3_f16/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/unnested/mat3x3_f16/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -9,12 +9,13 @@ } v; int counter = 0; int i() { - counter = (counter + 1); + uint v_1 = uint(counter); + counter = int((v_1 + uint(1))); return counter; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - f16mat3 v_1 = f16mat3(v.inner_col0, v.inner_col1, v.inner_col2); - f16mat3 l_m = v_1; - f16vec3 l_m_i = v_1[min(uint(i()), 2u)]; + f16mat3 v_2 = f16mat3(v.inner_col0, v.inner_col1, v.inner_col2); + f16mat3 l_m = v_2; + f16vec3 l_m_i = v_2[min(uint(i()), 2u)]; }
diff --git a/test/tint/buffer/uniform/std140/unnested/mat3x3_f16/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/unnested/mat3x3_f16/dynamic_index_via_ptr.wgsl.expected.spvasm index e0d08b3..f724f5f 100644 --- a/test/tint/buffer/uniform/std140/unnested/mat3x3_f16/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/unnested/mat3x3_f16/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,13 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 43 +; Bound: 46 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess - %39 = OpExtInstImport "GLSL.std.450" + %42 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -37,11 +37,11 @@ %int_0 = OpConstant %int 0 %counter = OpVariable %_ptr_Private_int Private %int_0 %11 = OpTypeFunction %int + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %void = OpTypeVoid - %19 = OpTypeFunction %void + %23 = OpTypeFunction %void %_ptr_Uniform_v3half = OpTypePointer Uniform %v3half - %uint = OpTypeInt 32 0 %uint_0 = OpConstant %uint 0 %uint_1 = OpConstant %uint 1 %uint_2 = OpConstant %uint 2 @@ -51,26 +51,29 @@ %i = OpFunction %int None %11 %12 = OpLabel %13 = OpLoad %int %counter None - %14 = OpIAdd %int %13 %int_1 - OpStore %counter %14 None - %16 = OpLoad %int %counter None - OpReturnValue %16 + %15 = OpBitcast %uint %13 + %16 = OpBitcast %uint %int_1 + %18 = OpIAdd %uint %15 %16 + %19 = OpBitcast %int %18 + OpStore %counter %19 None + %20 = OpLoad %int %counter None + OpReturnValue %20 OpFunctionEnd - %f = OpFunction %void None %19 - %20 = OpLabel - %34 = OpVariable %_ptr_Function_mat3v3half Function - %21 = OpAccessChain %_ptr_Uniform_v3half %1 %uint_0 - %25 = OpLoad %v3half %21 None - %26 = OpAccessChain %_ptr_Uniform_v3half %1 %uint_1 - %28 = OpLoad %v3half %26 None - %29 = OpAccessChain %_ptr_Uniform_v3half %1 %uint_2 + %f = OpFunction %void None %23 + %24 = OpLabel + %37 = OpVariable %_ptr_Function_mat3v3half Function + %25 = OpAccessChain %_ptr_Uniform_v3half %1 %uint_0 + %28 = OpLoad %v3half %25 None + %29 = OpAccessChain %_ptr_Uniform_v3half %1 %uint_1 %31 = OpLoad %v3half %29 None - %l_m = OpCompositeConstruct %mat3v3half %25 %28 %31 - OpStore %34 %l_m - %36 = OpFunctionCall %int %i - %37 = OpBitcast %uint %36 - %38 = OpExtInst %uint %39 UMin %37 %uint_2 - %40 = OpAccessChain %_ptr_Function_v3half %34 %38 - %l_m_i = OpLoad %v3half %40 None + %32 = OpAccessChain %_ptr_Uniform_v3half %1 %uint_2 + %34 = OpLoad %v3half %32 None + %l_m = OpCompositeConstruct %mat3v3half %28 %31 %34 + OpStore %37 %l_m + %39 = OpFunctionCall %int %i + %40 = OpBitcast %uint %39 + %41 = OpExtInst %uint %42 UMin %40 %uint_2 + %43 = OpAccessChain %_ptr_Function_v3half %37 %41 + %l_m_i = OpLoad %v3half %43 None OpReturn OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/unnested/mat3x3_f32/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/unnested/mat3x3_f32/dynamic_index_via_ptr.wgsl.expected.glsl index 554813d..f499167 100644 --- a/test/tint/buffer/uniform/std140/unnested/mat3x3_f32/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/unnested/mat3x3_f32/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -10,12 +10,13 @@ } v; int counter = 0; int i() { - counter = (counter + 1); + uint v_1 = uint(counter); + counter = int((v_1 + uint(1))); return counter; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - mat3 v_1 = mat3(v.inner_col0, v.inner_col1, v.inner_col2); - mat3 l_m = v_1; - vec3 l_m_i = v_1[min(uint(i()), 2u)]; + mat3 v_2 = mat3(v.inner_col0, v.inner_col1, v.inner_col2); + mat3 l_m = v_2; + vec3 l_m_i = v_2[min(uint(i()), 2u)]; }
diff --git a/test/tint/buffer/uniform/std140/unnested/mat3x3_f32/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/unnested/mat3x3_f32/dynamic_index_via_ptr.wgsl.expected.spvasm index 8656d3b..2b3b77c 100644 --- a/test/tint/buffer/uniform/std140/unnested/mat3x3_f32/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/unnested/mat3x3_f32/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,10 +1,10 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 43 +; Bound: 46 ; Schema: 0 OpCapability Shader - %39 = OpExtInstImport "GLSL.std.450" + %42 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -34,11 +34,11 @@ %int_0 = OpConstant %int 0 %counter = OpVariable %_ptr_Private_int Private %int_0 %11 = OpTypeFunction %int + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %void = OpTypeVoid - %19 = OpTypeFunction %void + %23 = OpTypeFunction %void %_ptr_Uniform_v3float = OpTypePointer Uniform %v3float - %uint = OpTypeInt 32 0 %uint_0 = OpConstant %uint 0 %uint_1 = OpConstant %uint 1 %uint_2 = OpConstant %uint 2 @@ -48,26 +48,29 @@ %i = OpFunction %int None %11 %12 = OpLabel %13 = OpLoad %int %counter None - %14 = OpIAdd %int %13 %int_1 - OpStore %counter %14 None - %16 = OpLoad %int %counter None - OpReturnValue %16 + %15 = OpBitcast %uint %13 + %16 = OpBitcast %uint %int_1 + %18 = OpIAdd %uint %15 %16 + %19 = OpBitcast %int %18 + OpStore %counter %19 None + %20 = OpLoad %int %counter None + OpReturnValue %20 OpFunctionEnd - %f = OpFunction %void None %19 - %20 = OpLabel - %34 = OpVariable %_ptr_Function_mat3v3float Function - %21 = OpAccessChain %_ptr_Uniform_v3float %1 %uint_0 - %25 = OpLoad %v3float %21 None - %26 = OpAccessChain %_ptr_Uniform_v3float %1 %uint_1 - %28 = OpLoad %v3float %26 None - %29 = OpAccessChain %_ptr_Uniform_v3float %1 %uint_2 + %f = OpFunction %void None %23 + %24 = OpLabel + %37 = OpVariable %_ptr_Function_mat3v3float Function + %25 = OpAccessChain %_ptr_Uniform_v3float %1 %uint_0 + %28 = OpLoad %v3float %25 None + %29 = OpAccessChain %_ptr_Uniform_v3float %1 %uint_1 %31 = OpLoad %v3float %29 None - %l_m = OpCompositeConstruct %mat3v3float %25 %28 %31 - OpStore %34 %l_m - %36 = OpFunctionCall %int %i - %37 = OpBitcast %uint %36 - %38 = OpExtInst %uint %39 UMin %37 %uint_2 - %40 = OpAccessChain %_ptr_Function_v3float %34 %38 - %l_m_i = OpLoad %v3float %40 None + %32 = OpAccessChain %_ptr_Uniform_v3float %1 %uint_2 + %34 = OpLoad %v3float %32 None + %l_m = OpCompositeConstruct %mat3v3float %28 %31 %34 + OpStore %37 %l_m + %39 = OpFunctionCall %int %i + %40 = OpBitcast %uint %39 + %41 = OpExtInst %uint %42 UMin %40 %uint_2 + %43 = OpAccessChain %_ptr_Function_v3float %37 %41 + %l_m_i = OpLoad %v3float %43 None OpReturn OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/unnested/mat3x4_f16/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/unnested/mat3x4_f16/dynamic_index_via_ptr.wgsl.expected.glsl index 985459a..2e0db94 100644 --- a/test/tint/buffer/uniform/std140/unnested/mat3x4_f16/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/unnested/mat3x4_f16/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -9,12 +9,13 @@ } v; int counter = 0; int i() { - counter = (counter + 1); + uint v_1 = uint(counter); + counter = int((v_1 + uint(1))); return counter; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - f16mat3x4 v_1 = f16mat3x4(v.inner_col0, v.inner_col1, v.inner_col2); - f16mat3x4 l_m = v_1; - f16vec4 l_m_i = v_1[min(uint(i()), 2u)]; + f16mat3x4 v_2 = f16mat3x4(v.inner_col0, v.inner_col1, v.inner_col2); + f16mat3x4 l_m = v_2; + f16vec4 l_m_i = v_2[min(uint(i()), 2u)]; }
diff --git a/test/tint/buffer/uniform/std140/unnested/mat3x4_f16/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/unnested/mat3x4_f16/dynamic_index_via_ptr.wgsl.expected.spvasm index b746ddc..547475f 100644 --- a/test/tint/buffer/uniform/std140/unnested/mat3x4_f16/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/unnested/mat3x4_f16/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,13 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 43 +; Bound: 46 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess - %39 = OpExtInstImport "GLSL.std.450" + %42 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -37,11 +37,11 @@ %int_0 = OpConstant %int 0 %counter = OpVariable %_ptr_Private_int Private %int_0 %11 = OpTypeFunction %int + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %void = OpTypeVoid - %19 = OpTypeFunction %void + %23 = OpTypeFunction %void %_ptr_Uniform_v4half = OpTypePointer Uniform %v4half - %uint = OpTypeInt 32 0 %uint_0 = OpConstant %uint 0 %uint_1 = OpConstant %uint 1 %uint_2 = OpConstant %uint 2 @@ -51,26 +51,29 @@ %i = OpFunction %int None %11 %12 = OpLabel %13 = OpLoad %int %counter None - %14 = OpIAdd %int %13 %int_1 - OpStore %counter %14 None - %16 = OpLoad %int %counter None - OpReturnValue %16 + %15 = OpBitcast %uint %13 + %16 = OpBitcast %uint %int_1 + %18 = OpIAdd %uint %15 %16 + %19 = OpBitcast %int %18 + OpStore %counter %19 None + %20 = OpLoad %int %counter None + OpReturnValue %20 OpFunctionEnd - %f = OpFunction %void None %19 - %20 = OpLabel - %34 = OpVariable %_ptr_Function_mat3v4half Function - %21 = OpAccessChain %_ptr_Uniform_v4half %1 %uint_0 - %25 = OpLoad %v4half %21 None - %26 = OpAccessChain %_ptr_Uniform_v4half %1 %uint_1 - %28 = OpLoad %v4half %26 None - %29 = OpAccessChain %_ptr_Uniform_v4half %1 %uint_2 + %f = OpFunction %void None %23 + %24 = OpLabel + %37 = OpVariable %_ptr_Function_mat3v4half Function + %25 = OpAccessChain %_ptr_Uniform_v4half %1 %uint_0 + %28 = OpLoad %v4half %25 None + %29 = OpAccessChain %_ptr_Uniform_v4half %1 %uint_1 %31 = OpLoad %v4half %29 None - %l_m = OpCompositeConstruct %mat3v4half %25 %28 %31 - OpStore %34 %l_m - %36 = OpFunctionCall %int %i - %37 = OpBitcast %uint %36 - %38 = OpExtInst %uint %39 UMin %37 %uint_2 - %40 = OpAccessChain %_ptr_Function_v4half %34 %38 - %l_m_i = OpLoad %v4half %40 None + %32 = OpAccessChain %_ptr_Uniform_v4half %1 %uint_2 + %34 = OpLoad %v4half %32 None + %l_m = OpCompositeConstruct %mat3v4half %28 %31 %34 + OpStore %37 %l_m + %39 = OpFunctionCall %int %i + %40 = OpBitcast %uint %39 + %41 = OpExtInst %uint %42 UMin %40 %uint_2 + %43 = OpAccessChain %_ptr_Function_v4half %37 %41 + %l_m_i = OpLoad %v4half %43 None OpReturn OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/unnested/mat3x4_f32/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/unnested/mat3x4_f32/dynamic_index_via_ptr.wgsl.expected.glsl index 127e6c6..4a0c1eb 100644 --- a/test/tint/buffer/uniform/std140/unnested/mat3x4_f32/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/unnested/mat3x4_f32/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -6,12 +6,13 @@ } v; int counter = 0; int i() { - counter = (counter + 1); + uint v_1 = uint(counter); + counter = int((v_1 + uint(1))); return counter; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - uint v_1 = min(uint(i()), 2u); + uint v_2 = min(uint(i()), 2u); mat3x4 l_m = v.inner; - vec4 l_m_i = v.inner[v_1]; + vec4 l_m_i = v.inner[v_2]; }
diff --git a/test/tint/buffer/uniform/std140/unnested/mat3x4_f32/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/unnested/mat3x4_f32/dynamic_index_via_ptr.wgsl.expected.spvasm index 6129daf..e0a4b37 100644 --- a/test/tint/buffer/uniform/std140/unnested/mat3x4_f32/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/unnested/mat3x4_f32/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,10 +1,10 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 35 +; Bound: 38 ; Schema: 0 OpCapability Shader - %29 = OpExtInstImport "GLSL.std.450" + %32 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -35,29 +35,32 @@ %int_0 = OpConstant %int 0 %counter = OpVariable %_ptr_Private_int Private %int_0 %12 = OpTypeFunction %int + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %void = OpTypeVoid - %20 = OpTypeFunction %void + %24 = OpTypeFunction %void %_ptr_Uniform_mat3v4float = OpTypePointer Uniform %mat3v4float - %uint = OpTypeInt 32 0 %uint_0 = OpConstant %uint 0 %uint_2 = OpConstant %uint 2 %_ptr_Uniform_v4float = OpTypePointer Uniform %v4float %i = OpFunction %int None %12 %13 = OpLabel %14 = OpLoad %int %counter None - %15 = OpIAdd %int %14 %int_1 - OpStore %counter %15 None - %17 = OpLoad %int %counter None - OpReturnValue %17 + %16 = OpBitcast %uint %14 + %17 = OpBitcast %uint %int_1 + %19 = OpIAdd %uint %16 %17 + %20 = OpBitcast %int %19 + OpStore %counter %20 None + %21 = OpLoad %int %counter None + OpReturnValue %21 OpFunctionEnd - %f = OpFunction %void None %20 - %21 = OpLabel + %f = OpFunction %void None %24 + %25 = OpLabel %p_m = OpAccessChain %_ptr_Uniform_mat3v4float %1 %uint_0 - %26 = OpFunctionCall %int %i - %27 = OpBitcast %uint %26 - %28 = OpExtInst %uint %29 UMin %27 %uint_2 - %p_m_i = OpAccessChain %_ptr_Uniform_v4float %p_m %28 + %29 = OpFunctionCall %int %i + %30 = OpBitcast %uint %29 + %31 = OpExtInst %uint %32 UMin %30 %uint_2 + %p_m_i = OpAccessChain %_ptr_Uniform_v4float %p_m %31 %l_m = OpLoad %mat3v4float %p_m None %l_m_i = OpLoad %v4float %p_m_i None OpReturn
diff --git a/test/tint/buffer/uniform/std140/unnested/mat4x2_f16/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/unnested/mat4x2_f16/dynamic_index_via_ptr.wgsl.expected.glsl index 2a94775..eebcff6 100644 --- a/test/tint/buffer/uniform/std140/unnested/mat4x2_f16/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/unnested/mat4x2_f16/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -10,12 +10,13 @@ } v; int counter = 0; int i() { - counter = (counter + 1); + uint v_1 = uint(counter); + counter = int((v_1 + uint(1))); return counter; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - f16mat4x2 v_1 = f16mat4x2(v.inner_col0, v.inner_col1, v.inner_col2, v.inner_col3); - f16mat4x2 l_m = v_1; - f16vec2 l_m_i = v_1[min(uint(i()), 3u)]; + f16mat4x2 v_2 = f16mat4x2(v.inner_col0, v.inner_col1, v.inner_col2, v.inner_col3); + f16mat4x2 l_m = v_2; + f16vec2 l_m_i = v_2[min(uint(i()), 3u)]; }
diff --git a/test/tint/buffer/uniform/std140/unnested/mat4x2_f16/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/unnested/mat4x2_f16/dynamic_index_via_ptr.wgsl.expected.spvasm index b692f31..3f2c67a 100644 --- a/test/tint/buffer/uniform/std140/unnested/mat4x2_f16/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/unnested/mat4x2_f16/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,13 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 46 +; Bound: 49 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess - %42 = OpExtInstImport "GLSL.std.450" + %45 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -39,11 +39,11 @@ %int_0 = OpConstant %int 0 %counter = OpVariable %_ptr_Private_int Private %int_0 %11 = OpTypeFunction %int + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %void = OpTypeVoid - %19 = OpTypeFunction %void + %23 = OpTypeFunction %void %_ptr_Uniform_v2half = OpTypePointer Uniform %v2half - %uint = OpTypeInt 32 0 %uint_0 = OpConstant %uint 0 %uint_1 = OpConstant %uint 1 %uint_2 = OpConstant %uint 2 @@ -54,28 +54,31 @@ %i = OpFunction %int None %11 %12 = OpLabel %13 = OpLoad %int %counter None - %14 = OpIAdd %int %13 %int_1 - OpStore %counter %14 None - %16 = OpLoad %int %counter None - OpReturnValue %16 + %15 = OpBitcast %uint %13 + %16 = OpBitcast %uint %int_1 + %18 = OpIAdd %uint %15 %16 + %19 = OpBitcast %int %18 + OpStore %counter %19 None + %20 = OpLoad %int %counter None + OpReturnValue %20 OpFunctionEnd - %f = OpFunction %void None %19 - %20 = OpLabel - %37 = OpVariable %_ptr_Function_mat4v2half Function - %21 = OpAccessChain %_ptr_Uniform_v2half %1 %uint_0 - %25 = OpLoad %v2half %21 None - %26 = OpAccessChain %_ptr_Uniform_v2half %1 %uint_1 - %28 = OpLoad %v2half %26 None - %29 = OpAccessChain %_ptr_Uniform_v2half %1 %uint_2 + %f = OpFunction %void None %23 + %24 = OpLabel + %40 = OpVariable %_ptr_Function_mat4v2half Function + %25 = OpAccessChain %_ptr_Uniform_v2half %1 %uint_0 + %28 = OpLoad %v2half %25 None + %29 = OpAccessChain %_ptr_Uniform_v2half %1 %uint_1 %31 = OpLoad %v2half %29 None - %32 = OpAccessChain %_ptr_Uniform_v2half %1 %uint_3 + %32 = OpAccessChain %_ptr_Uniform_v2half %1 %uint_2 %34 = OpLoad %v2half %32 None - %l_m = OpCompositeConstruct %mat4v2half %25 %28 %31 %34 - OpStore %37 %l_m - %39 = OpFunctionCall %int %i - %40 = OpBitcast %uint %39 - %41 = OpExtInst %uint %42 UMin %40 %uint_3 - %43 = OpAccessChain %_ptr_Function_v2half %37 %41 - %l_m_i = OpLoad %v2half %43 None + %35 = OpAccessChain %_ptr_Uniform_v2half %1 %uint_3 + %37 = OpLoad %v2half %35 None + %l_m = OpCompositeConstruct %mat4v2half %28 %31 %34 %37 + OpStore %40 %l_m + %42 = OpFunctionCall %int %i + %43 = OpBitcast %uint %42 + %44 = OpExtInst %uint %45 UMin %43 %uint_3 + %46 = OpAccessChain %_ptr_Function_v2half %40 %44 + %l_m_i = OpLoad %v2half %46 None OpReturn OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/unnested/mat4x2_f32/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/unnested/mat4x2_f32/dynamic_index_via_ptr.wgsl.expected.glsl index 1fea73b..b3032c2 100644 --- a/test/tint/buffer/uniform/std140/unnested/mat4x2_f32/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/unnested/mat4x2_f32/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -9,12 +9,13 @@ } v; int counter = 0; int i() { - counter = (counter + 1); + uint v_1 = uint(counter); + counter = int((v_1 + uint(1))); return counter; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - mat4x2 v_1 = mat4x2(v.inner_col0, v.inner_col1, v.inner_col2, v.inner_col3); - mat4x2 l_m = v_1; - vec2 l_m_i = v_1[min(uint(i()), 3u)]; + mat4x2 v_2 = mat4x2(v.inner_col0, v.inner_col1, v.inner_col2, v.inner_col3); + mat4x2 l_m = v_2; + vec2 l_m_i = v_2[min(uint(i()), 3u)]; }
diff --git a/test/tint/buffer/uniform/std140/unnested/mat4x2_f32/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/unnested/mat4x2_f32/dynamic_index_via_ptr.wgsl.expected.spvasm index ec73bb5..e0ff0aa 100644 --- a/test/tint/buffer/uniform/std140/unnested/mat4x2_f32/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/unnested/mat4x2_f32/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,10 +1,10 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 46 +; Bound: 49 ; Schema: 0 OpCapability Shader - %42 = OpExtInstImport "GLSL.std.450" + %45 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -36,11 +36,11 @@ %int_0 = OpConstant %int 0 %counter = OpVariable %_ptr_Private_int Private %int_0 %11 = OpTypeFunction %int + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %void = OpTypeVoid - %19 = OpTypeFunction %void + %23 = OpTypeFunction %void %_ptr_Uniform_v2float = OpTypePointer Uniform %v2float - %uint = OpTypeInt 32 0 %uint_0 = OpConstant %uint 0 %uint_1 = OpConstant %uint 1 %uint_2 = OpConstant %uint 2 @@ -51,28 +51,31 @@ %i = OpFunction %int None %11 %12 = OpLabel %13 = OpLoad %int %counter None - %14 = OpIAdd %int %13 %int_1 - OpStore %counter %14 None - %16 = OpLoad %int %counter None - OpReturnValue %16 + %15 = OpBitcast %uint %13 + %16 = OpBitcast %uint %int_1 + %18 = OpIAdd %uint %15 %16 + %19 = OpBitcast %int %18 + OpStore %counter %19 None + %20 = OpLoad %int %counter None + OpReturnValue %20 OpFunctionEnd - %f = OpFunction %void None %19 - %20 = OpLabel - %37 = OpVariable %_ptr_Function_mat4v2float Function - %21 = OpAccessChain %_ptr_Uniform_v2float %1 %uint_0 - %25 = OpLoad %v2float %21 None - %26 = OpAccessChain %_ptr_Uniform_v2float %1 %uint_1 - %28 = OpLoad %v2float %26 None - %29 = OpAccessChain %_ptr_Uniform_v2float %1 %uint_2 + %f = OpFunction %void None %23 + %24 = OpLabel + %40 = OpVariable %_ptr_Function_mat4v2float Function + %25 = OpAccessChain %_ptr_Uniform_v2float %1 %uint_0 + %28 = OpLoad %v2float %25 None + %29 = OpAccessChain %_ptr_Uniform_v2float %1 %uint_1 %31 = OpLoad %v2float %29 None - %32 = OpAccessChain %_ptr_Uniform_v2float %1 %uint_3 + %32 = OpAccessChain %_ptr_Uniform_v2float %1 %uint_2 %34 = OpLoad %v2float %32 None - %l_m = OpCompositeConstruct %mat4v2float %25 %28 %31 %34 - OpStore %37 %l_m - %39 = OpFunctionCall %int %i - %40 = OpBitcast %uint %39 - %41 = OpExtInst %uint %42 UMin %40 %uint_3 - %43 = OpAccessChain %_ptr_Function_v2float %37 %41 - %l_m_i = OpLoad %v2float %43 None + %35 = OpAccessChain %_ptr_Uniform_v2float %1 %uint_3 + %37 = OpLoad %v2float %35 None + %l_m = OpCompositeConstruct %mat4v2float %28 %31 %34 %37 + OpStore %40 %l_m + %42 = OpFunctionCall %int %i + %43 = OpBitcast %uint %42 + %44 = OpExtInst %uint %45 UMin %43 %uint_3 + %46 = OpAccessChain %_ptr_Function_v2float %40 %44 + %l_m_i = OpLoad %v2float %46 None OpReturn OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/unnested/mat4x3_f16/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/unnested/mat4x3_f16/dynamic_index_via_ptr.wgsl.expected.glsl index 8f17a68..e022fe7 100644 --- a/test/tint/buffer/uniform/std140/unnested/mat4x3_f16/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/unnested/mat4x3_f16/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -10,12 +10,13 @@ } v; int counter = 0; int i() { - counter = (counter + 1); + uint v_1 = uint(counter); + counter = int((v_1 + uint(1))); return counter; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - f16mat4x3 v_1 = f16mat4x3(v.inner_col0, v.inner_col1, v.inner_col2, v.inner_col3); - f16mat4x3 l_m = v_1; - f16vec3 l_m_i = v_1[min(uint(i()), 3u)]; + f16mat4x3 v_2 = f16mat4x3(v.inner_col0, v.inner_col1, v.inner_col2, v.inner_col3); + f16mat4x3 l_m = v_2; + f16vec3 l_m_i = v_2[min(uint(i()), 3u)]; }
diff --git a/test/tint/buffer/uniform/std140/unnested/mat4x3_f16/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/unnested/mat4x3_f16/dynamic_index_via_ptr.wgsl.expected.spvasm index befd937..9a8388b 100644 --- a/test/tint/buffer/uniform/std140/unnested/mat4x3_f16/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/unnested/mat4x3_f16/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,13 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 46 +; Bound: 49 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess - %42 = OpExtInstImport "GLSL.std.450" + %45 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -39,11 +39,11 @@ %int_0 = OpConstant %int 0 %counter = OpVariable %_ptr_Private_int Private %int_0 %11 = OpTypeFunction %int + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %void = OpTypeVoid - %19 = OpTypeFunction %void + %23 = OpTypeFunction %void %_ptr_Uniform_v3half = OpTypePointer Uniform %v3half - %uint = OpTypeInt 32 0 %uint_0 = OpConstant %uint 0 %uint_1 = OpConstant %uint 1 %uint_2 = OpConstant %uint 2 @@ -54,28 +54,31 @@ %i = OpFunction %int None %11 %12 = OpLabel %13 = OpLoad %int %counter None - %14 = OpIAdd %int %13 %int_1 - OpStore %counter %14 None - %16 = OpLoad %int %counter None - OpReturnValue %16 + %15 = OpBitcast %uint %13 + %16 = OpBitcast %uint %int_1 + %18 = OpIAdd %uint %15 %16 + %19 = OpBitcast %int %18 + OpStore %counter %19 None + %20 = OpLoad %int %counter None + OpReturnValue %20 OpFunctionEnd - %f = OpFunction %void None %19 - %20 = OpLabel - %37 = OpVariable %_ptr_Function_mat4v3half Function - %21 = OpAccessChain %_ptr_Uniform_v3half %1 %uint_0 - %25 = OpLoad %v3half %21 None - %26 = OpAccessChain %_ptr_Uniform_v3half %1 %uint_1 - %28 = OpLoad %v3half %26 None - %29 = OpAccessChain %_ptr_Uniform_v3half %1 %uint_2 + %f = OpFunction %void None %23 + %24 = OpLabel + %40 = OpVariable %_ptr_Function_mat4v3half Function + %25 = OpAccessChain %_ptr_Uniform_v3half %1 %uint_0 + %28 = OpLoad %v3half %25 None + %29 = OpAccessChain %_ptr_Uniform_v3half %1 %uint_1 %31 = OpLoad %v3half %29 None - %32 = OpAccessChain %_ptr_Uniform_v3half %1 %uint_3 + %32 = OpAccessChain %_ptr_Uniform_v3half %1 %uint_2 %34 = OpLoad %v3half %32 None - %l_m = OpCompositeConstruct %mat4v3half %25 %28 %31 %34 - OpStore %37 %l_m - %39 = OpFunctionCall %int %i - %40 = OpBitcast %uint %39 - %41 = OpExtInst %uint %42 UMin %40 %uint_3 - %43 = OpAccessChain %_ptr_Function_v3half %37 %41 - %l_m_i = OpLoad %v3half %43 None + %35 = OpAccessChain %_ptr_Uniform_v3half %1 %uint_3 + %37 = OpLoad %v3half %35 None + %l_m = OpCompositeConstruct %mat4v3half %28 %31 %34 %37 + OpStore %40 %l_m + %42 = OpFunctionCall %int %i + %43 = OpBitcast %uint %42 + %44 = OpExtInst %uint %45 UMin %43 %uint_3 + %46 = OpAccessChain %_ptr_Function_v3half %40 %44 + %l_m_i = OpLoad %v3half %46 None OpReturn OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/unnested/mat4x3_f32/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/unnested/mat4x3_f32/dynamic_index_via_ptr.wgsl.expected.glsl index 8a04114..69a6791 100644 --- a/test/tint/buffer/uniform/std140/unnested/mat4x3_f32/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/unnested/mat4x3_f32/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -12,12 +12,13 @@ } v; int counter = 0; int i() { - counter = (counter + 1); + uint v_1 = uint(counter); + counter = int((v_1 + uint(1))); return counter; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - mat4x3 v_1 = mat4x3(v.inner_col0, v.inner_col1, v.inner_col2, v.inner_col3); - mat4x3 l_m = v_1; - vec3 l_m_i = v_1[min(uint(i()), 3u)]; + mat4x3 v_2 = mat4x3(v.inner_col0, v.inner_col1, v.inner_col2, v.inner_col3); + mat4x3 l_m = v_2; + vec3 l_m_i = v_2[min(uint(i()), 3u)]; }
diff --git a/test/tint/buffer/uniform/std140/unnested/mat4x3_f32/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/unnested/mat4x3_f32/dynamic_index_via_ptr.wgsl.expected.spvasm index 5dda853..46d0e67 100644 --- a/test/tint/buffer/uniform/std140/unnested/mat4x3_f32/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/unnested/mat4x3_f32/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,10 +1,10 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 46 +; Bound: 49 ; Schema: 0 OpCapability Shader - %42 = OpExtInstImport "GLSL.std.450" + %45 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -36,11 +36,11 @@ %int_0 = OpConstant %int 0 %counter = OpVariable %_ptr_Private_int Private %int_0 %11 = OpTypeFunction %int + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %void = OpTypeVoid - %19 = OpTypeFunction %void + %23 = OpTypeFunction %void %_ptr_Uniform_v3float = OpTypePointer Uniform %v3float - %uint = OpTypeInt 32 0 %uint_0 = OpConstant %uint 0 %uint_1 = OpConstant %uint 1 %uint_2 = OpConstant %uint 2 @@ -51,28 +51,31 @@ %i = OpFunction %int None %11 %12 = OpLabel %13 = OpLoad %int %counter None - %14 = OpIAdd %int %13 %int_1 - OpStore %counter %14 None - %16 = OpLoad %int %counter None - OpReturnValue %16 + %15 = OpBitcast %uint %13 + %16 = OpBitcast %uint %int_1 + %18 = OpIAdd %uint %15 %16 + %19 = OpBitcast %int %18 + OpStore %counter %19 None + %20 = OpLoad %int %counter None + OpReturnValue %20 OpFunctionEnd - %f = OpFunction %void None %19 - %20 = OpLabel - %37 = OpVariable %_ptr_Function_mat4v3float Function - %21 = OpAccessChain %_ptr_Uniform_v3float %1 %uint_0 - %25 = OpLoad %v3float %21 None - %26 = OpAccessChain %_ptr_Uniform_v3float %1 %uint_1 - %28 = OpLoad %v3float %26 None - %29 = OpAccessChain %_ptr_Uniform_v3float %1 %uint_2 + %f = OpFunction %void None %23 + %24 = OpLabel + %40 = OpVariable %_ptr_Function_mat4v3float Function + %25 = OpAccessChain %_ptr_Uniform_v3float %1 %uint_0 + %28 = OpLoad %v3float %25 None + %29 = OpAccessChain %_ptr_Uniform_v3float %1 %uint_1 %31 = OpLoad %v3float %29 None - %32 = OpAccessChain %_ptr_Uniform_v3float %1 %uint_3 + %32 = OpAccessChain %_ptr_Uniform_v3float %1 %uint_2 %34 = OpLoad %v3float %32 None - %l_m = OpCompositeConstruct %mat4v3float %25 %28 %31 %34 - OpStore %37 %l_m - %39 = OpFunctionCall %int %i - %40 = OpBitcast %uint %39 - %41 = OpExtInst %uint %42 UMin %40 %uint_3 - %43 = OpAccessChain %_ptr_Function_v3float %37 %41 - %l_m_i = OpLoad %v3float %43 None + %35 = OpAccessChain %_ptr_Uniform_v3float %1 %uint_3 + %37 = OpLoad %v3float %35 None + %l_m = OpCompositeConstruct %mat4v3float %28 %31 %34 %37 + OpStore %40 %l_m + %42 = OpFunctionCall %int %i + %43 = OpBitcast %uint %42 + %44 = OpExtInst %uint %45 UMin %43 %uint_3 + %46 = OpAccessChain %_ptr_Function_v3float %40 %44 + %l_m_i = OpLoad %v3float %46 None OpReturn OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/unnested/mat4x4_f16/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/unnested/mat4x4_f16/dynamic_index_via_ptr.wgsl.expected.glsl index c565af0..7f0962b 100644 --- a/test/tint/buffer/uniform/std140/unnested/mat4x4_f16/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/unnested/mat4x4_f16/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -10,12 +10,13 @@ } v; int counter = 0; int i() { - counter = (counter + 1); + uint v_1 = uint(counter); + counter = int((v_1 + uint(1))); return counter; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - f16mat4 v_1 = f16mat4(v.inner_col0, v.inner_col1, v.inner_col2, v.inner_col3); - f16mat4 l_m = v_1; - f16vec4 l_m_i = v_1[min(uint(i()), 3u)]; + f16mat4 v_2 = f16mat4(v.inner_col0, v.inner_col1, v.inner_col2, v.inner_col3); + f16mat4 l_m = v_2; + f16vec4 l_m_i = v_2[min(uint(i()), 3u)]; }
diff --git a/test/tint/buffer/uniform/std140/unnested/mat4x4_f16/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/unnested/mat4x4_f16/dynamic_index_via_ptr.wgsl.expected.spvasm index 9c41614..f081737 100644 --- a/test/tint/buffer/uniform/std140/unnested/mat4x4_f16/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/unnested/mat4x4_f16/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,13 +1,13 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 46 +; Bound: 49 ; Schema: 0 OpCapability Shader OpCapability Float16 OpCapability UniformAndStorageBuffer16BitAccess OpCapability StorageBuffer16BitAccess - %42 = OpExtInstImport "GLSL.std.450" + %45 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -39,11 +39,11 @@ %int_0 = OpConstant %int 0 %counter = OpVariable %_ptr_Private_int Private %int_0 %11 = OpTypeFunction %int + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %void = OpTypeVoid - %19 = OpTypeFunction %void + %23 = OpTypeFunction %void %_ptr_Uniform_v4half = OpTypePointer Uniform %v4half - %uint = OpTypeInt 32 0 %uint_0 = OpConstant %uint 0 %uint_1 = OpConstant %uint 1 %uint_2 = OpConstant %uint 2 @@ -54,28 +54,31 @@ %i = OpFunction %int None %11 %12 = OpLabel %13 = OpLoad %int %counter None - %14 = OpIAdd %int %13 %int_1 - OpStore %counter %14 None - %16 = OpLoad %int %counter None - OpReturnValue %16 + %15 = OpBitcast %uint %13 + %16 = OpBitcast %uint %int_1 + %18 = OpIAdd %uint %15 %16 + %19 = OpBitcast %int %18 + OpStore %counter %19 None + %20 = OpLoad %int %counter None + OpReturnValue %20 OpFunctionEnd - %f = OpFunction %void None %19 - %20 = OpLabel - %37 = OpVariable %_ptr_Function_mat4v4half Function - %21 = OpAccessChain %_ptr_Uniform_v4half %1 %uint_0 - %25 = OpLoad %v4half %21 None - %26 = OpAccessChain %_ptr_Uniform_v4half %1 %uint_1 - %28 = OpLoad %v4half %26 None - %29 = OpAccessChain %_ptr_Uniform_v4half %1 %uint_2 + %f = OpFunction %void None %23 + %24 = OpLabel + %40 = OpVariable %_ptr_Function_mat4v4half Function + %25 = OpAccessChain %_ptr_Uniform_v4half %1 %uint_0 + %28 = OpLoad %v4half %25 None + %29 = OpAccessChain %_ptr_Uniform_v4half %1 %uint_1 %31 = OpLoad %v4half %29 None - %32 = OpAccessChain %_ptr_Uniform_v4half %1 %uint_3 + %32 = OpAccessChain %_ptr_Uniform_v4half %1 %uint_2 %34 = OpLoad %v4half %32 None - %l_m = OpCompositeConstruct %mat4v4half %25 %28 %31 %34 - OpStore %37 %l_m - %39 = OpFunctionCall %int %i - %40 = OpBitcast %uint %39 - %41 = OpExtInst %uint %42 UMin %40 %uint_3 - %43 = OpAccessChain %_ptr_Function_v4half %37 %41 - %l_m_i = OpLoad %v4half %43 None + %35 = OpAccessChain %_ptr_Uniform_v4half %1 %uint_3 + %37 = OpLoad %v4half %35 None + %l_m = OpCompositeConstruct %mat4v4half %28 %31 %34 %37 + OpStore %40 %l_m + %42 = OpFunctionCall %int %i + %43 = OpBitcast %uint %42 + %44 = OpExtInst %uint %45 UMin %43 %uint_3 + %46 = OpAccessChain %_ptr_Function_v4half %40 %44 + %l_m_i = OpLoad %v4half %46 None OpReturn OpFunctionEnd
diff --git a/test/tint/buffer/uniform/std140/unnested/mat4x4_f32/dynamic_index_via_ptr.wgsl.expected.glsl b/test/tint/buffer/uniform/std140/unnested/mat4x4_f32/dynamic_index_via_ptr.wgsl.expected.glsl index bb405d0..3e385a8 100644 --- a/test/tint/buffer/uniform/std140/unnested/mat4x4_f32/dynamic_index_via_ptr.wgsl.expected.glsl +++ b/test/tint/buffer/uniform/std140/unnested/mat4x4_f32/dynamic_index_via_ptr.wgsl.expected.glsl
@@ -6,12 +6,13 @@ } v; int counter = 0; int i() { - counter = (counter + 1); + uint v_1 = uint(counter); + counter = int((v_1 + uint(1))); return counter; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - uint v_1 = min(uint(i()), 3u); + uint v_2 = min(uint(i()), 3u); mat4 l_m = v.inner; - vec4 l_m_i = v.inner[v_1]; + vec4 l_m_i = v.inner[v_2]; }
diff --git a/test/tint/buffer/uniform/std140/unnested/mat4x4_f32/dynamic_index_via_ptr.wgsl.expected.spvasm b/test/tint/buffer/uniform/std140/unnested/mat4x4_f32/dynamic_index_via_ptr.wgsl.expected.spvasm index 4b68d0f..1bdf9d3 100644 --- a/test/tint/buffer/uniform/std140/unnested/mat4x4_f32/dynamic_index_via_ptr.wgsl.expected.spvasm +++ b/test/tint/buffer/uniform/std140/unnested/mat4x4_f32/dynamic_index_via_ptr.wgsl.expected.spvasm
@@ -1,10 +1,10 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 35 +; Bound: 38 ; Schema: 0 OpCapability Shader - %29 = OpExtInstImport "GLSL.std.450" + %32 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %f "f" OpExecutionMode %f LocalSize 1 1 1 @@ -35,29 +35,32 @@ %int_0 = OpConstant %int 0 %counter = OpVariable %_ptr_Private_int Private %int_0 %12 = OpTypeFunction %int + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %void = OpTypeVoid - %20 = OpTypeFunction %void + %24 = OpTypeFunction %void %_ptr_Uniform_mat4v4float = OpTypePointer Uniform %mat4v4float - %uint = OpTypeInt 32 0 %uint_0 = OpConstant %uint 0 %uint_3 = OpConstant %uint 3 %_ptr_Uniform_v4float = OpTypePointer Uniform %v4float %i = OpFunction %int None %12 %13 = OpLabel %14 = OpLoad %int %counter None - %15 = OpIAdd %int %14 %int_1 - OpStore %counter %15 None - %17 = OpLoad %int %counter None - OpReturnValue %17 + %16 = OpBitcast %uint %14 + %17 = OpBitcast %uint %int_1 + %19 = OpIAdd %uint %16 %17 + %20 = OpBitcast %int %19 + OpStore %counter %20 None + %21 = OpLoad %int %counter None + OpReturnValue %21 OpFunctionEnd - %f = OpFunction %void None %20 - %21 = OpLabel + %f = OpFunction %void None %24 + %25 = OpLabel %p_m = OpAccessChain %_ptr_Uniform_mat4v4float %1 %uint_0 - %26 = OpFunctionCall %int %i - %27 = OpBitcast %uint %26 - %28 = OpExtInst %uint %29 UMin %27 %uint_3 - %p_m_i = OpAccessChain %_ptr_Uniform_v4float %p_m %28 + %29 = OpFunctionCall %int %i + %30 = OpBitcast %uint %29 + %31 = OpExtInst %uint %32 UMin %30 %uint_3 + %p_m_i = OpAccessChain %_ptr_Uniform_v4float %p_m %31 %l_m = OpLoad %mat4v4float %p_m None %l_m_i = OpLoad %v4float %p_m_i None OpReturn
diff --git a/test/tint/bug/chromium/344265982.wgsl.expected.glsl b/test/tint/bug/chromium/344265982.wgsl.expected.glsl index c37f44f..71876e0 100644 --- a/test/tint/bug/chromium/344265982.wgsl.expected.glsl +++ b/test/tint/bug/chromium/344265982.wgsl.expected.glsl
@@ -31,12 +31,14 @@ } if (tint_continue) { { - i = (i + 1); + uint v_3 = uint(i); + i = int((v_3 + uint(1))); } continue; } { - i = (i + 1); + uint v_3 = uint(i); + i = int((v_3 + uint(1))); } continue; }
diff --git a/test/tint/bug/chromium/344265982.wgsl.expected.spvasm b/test/tint/bug/chromium/344265982.wgsl.expected.spvasm index f9aab32..6700948 100644 --- a/test/tint/bug/chromium/344265982.wgsl.expected.spvasm +++ b/test/tint/bug/chromium/344265982.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 49 +; Bound: 52 ; Schema: 0 OpCapability Shader %29 = OpExtInstImport "GLSL.std.450" @@ -63,11 +63,11 @@ OpSelectionMerge %37 None OpSwitch %34 %35 1 %36 %35 = OpLabel - %41 = OpLoad %int %i None - %42 = OpBitcast %uint %41 - %43 = OpExtInst %uint %29 UMin %42 %uint_3 - %44 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 %43 - OpStore %44 %int_2 None + %44 = OpLoad %int %i None + %45 = OpBitcast %uint %44 + %46 = OpExtInst %uint %29 UMin %45 %uint_3 + %47 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 %46 + OpStore %47 %int_2 None OpBranch %37 %36 = OpLabel OpBranch %14 @@ -75,14 +75,17 @@ OpBranch %14 %14 = OpLabel %38 = OpLoad %int %i None - %39 = OpIAdd %int %38 %int_1 - OpStore %i %39 None + %39 = OpBitcast %uint %38 + %40 = OpBitcast %uint %int_1 + %42 = OpIAdd %uint %39 %40 + %43 = OpBitcast %int %42 + OpStore %i %43 None OpBranch %15 %16 = OpLabel OpReturn OpFunctionEnd %main = OpFunction %void None %10 - %47 = OpLabel - %48 = OpFunctionCall %void %foo + %50 = OpLabel + %51 = OpFunctionCall %void %foo OpReturn OpFunctionEnd
diff --git a/test/tint/bug/fxc/gradient_in_varying_loop/1112.wgsl.expected.glsl b/test/tint/bug/fxc/gradient_in_varying_loop/1112.wgsl.expected.glsl index 6054677..2a6712e 100644 --- a/test/tint/bug/fxc/gradient_in_varying_loop/1112.wgsl.expected.glsl +++ b/test/tint/bug/fxc/gradient_in_varying_loop/1112.wgsl.expected.glsl
@@ -38,7 +38,8 @@ v_2 = (offset.y > 1.0f); } if (v_2) { - i = (i + 1); + uint v_3 = uint(i); + i = int((v_3 + uint(1))); { uint tint_low_inc = (tint_loop_idx.x - 1u); tint_loop_idx.x = tint_low_inc; @@ -48,7 +49,8 @@ continue; } float sampleDepth = 0.0f; - i = (i + 1); + uint v_4 = uint(i); + i = int((v_4 + uint(1))); { uint tint_low_inc = (tint_loop_idx.x - 1u); tint_loop_idx.x = tint_low_inc;
diff --git a/test/tint/bug/fxc/gradient_in_varying_loop/1112.wgsl.expected.spvasm b/test/tint/bug/fxc/gradient_in_varying_loop/1112.wgsl.expected.spvasm index 931d53c..6564a4d 100644 --- a/test/tint/bug/fxc/gradient_in_varying_loop/1112.wgsl.expected.spvasm +++ b/test/tint/bug/fxc/gradient_in_varying_loop/1112.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 104 +; Bound: 110 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -63,7 +63,7 @@ %uint_0 = OpConstant %uint 0 %uint_1 = OpConstant %uint 1 %void = OpTypeVoid - %100 = OpTypeFunction %void + %106 = OpTypeFunction %void %main_inner = OpFunction %v4float None %16 %vUV = OpFunctionParameter %v2float %17 = OpLabel @@ -107,8 +107,8 @@ %61 = OpLabel OpBranch %60 %62 = OpLabel - %93 = OpCompositeExtract %float %offset 1 - %65 = OpFOrdLessThan %bool %93 %sampleDepth + %96 = OpCompositeExtract %float %offset 1 + %65 = OpFOrdLessThan %bool %96 %sampleDepth OpBranch %60 %60 = OpLabel %63 = OpPhi %bool %true %61 %65 %62 @@ -117,8 +117,8 @@ %67 = OpLabel OpBranch %66 %68 = OpLabel - %94 = OpCompositeExtract %float %offset 0 - %70 = OpFOrdGreaterThan %bool %94 %float_1 + %97 = OpCompositeExtract %float %offset 0 + %70 = OpFOrdGreaterThan %bool %97 %float_1 OpBranch %66 %66 = OpLabel %69 = OpPhi %bool %true %67 %70 %68 @@ -127,44 +127,50 @@ %72 = OpLabel OpBranch %71 %73 = OpLabel - %95 = OpCompositeExtract %float %offset 1 - %75 = OpFOrdGreaterThan %bool %95 %float_1 + %98 = OpCompositeExtract %float %offset 1 + %75 = OpFOrdGreaterThan %bool %98 %float_1 OpBranch %71 %71 = OpLabel %74 = OpPhi %bool %true %72 %75 %73 OpSelectionMerge %76 None OpBranchConditional %74 %77 %76 %77 = OpLabel - %96 = OpLoad %int %i None - %97 = OpIAdd %int %96 %int_1 - OpStore %i %97 None + %99 = OpLoad %int %i None + %100 = OpBitcast %uint %99 + %101 = OpBitcast %uint %int_1 + %102 = OpIAdd %uint %100 %101 + %103 = OpBitcast %int %102 + OpStore %i %103 None OpBranch %31 %76 = OpLabel %78 = OpLoad %int %i None - %79 = OpIAdd %int %78 %int_1 - OpStore %i %79 None + %79 = OpBitcast %uint %78 + %80 = OpBitcast %uint %int_1 + %81 = OpIAdd %uint %79 %80 + %82 = OpBitcast %int %81 + OpStore %i %82 None OpBranch %31 %31 = OpLabel - %80 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 - %83 = OpLoad %uint %80 None -%tint_low_inc = OpISub %uint %83 %uint_1 - %86 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 - OpStore %86 %tint_low_inc None - %87 = OpIEqual %bool %tint_low_inc %uint_4294967295 - %tint_carry = OpSelect %uint %87 %uint_1 %uint_0 - %89 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 - %90 = OpLoad %uint %89 None - %91 = OpISub %uint %90 %tint_carry + %83 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 + %86 = OpLoad %uint %83 None +%tint_low_inc = OpISub %uint %86 %uint_1 + %89 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 + OpStore %89 %tint_low_inc None + %90 = OpIEqual %bool %tint_low_inc %uint_4294967295 + %tint_carry = OpSelect %uint %90 %uint_1 %uint_0 %92 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 - OpStore %92 %91 None + %93 = OpLoad %uint %92 None + %94 = OpISub %uint %93 %tint_carry + %95 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 + OpStore %95 %94 None OpBranch %32 %33 = OpLabel OpReturnValue %34 OpFunctionEnd - %main = OpFunction %void None %100 - %101 = OpLabel - %102 = OpLoad %v2float %main_loc0_Input None - %103 = OpFunctionCall %v4float %main_inner %102 - OpStore %main_loc0_Output %103 None + %main = OpFunction %void None %106 + %107 = OpLabel + %108 = OpLoad %v2float %main_loc0_Input None + %109 = OpFunctionCall %v4float %main_inner %108 + OpStore %main_loc0_Output %109 None OpReturn OpFunctionEnd
diff --git a/test/tint/bug/fxc/vector_assignment_in_loop/loop_call_with_loop.wgsl.expected.glsl b/test/tint/bug/fxc/vector_assignment_in_loop/loop_call_with_loop.wgsl.expected.glsl index 06e4548..0f8e1a2 100644 --- a/test/tint/bug/fxc/vector_assignment_in_loop/loop_call_with_loop.wgsl.expected.glsl +++ b/test/tint/bug/fxc/vector_assignment_in_loop/loop_call_with_loop.wgsl.expected.glsl
@@ -17,7 +17,8 @@ v4u[min(uint(i), 3u)] = 1u; v2b[min(uint(i), 1u)] = true; { - i = (i + 1); + uint v = uint(i); + i = int((v + uint(1))); } continue; } @@ -34,7 +35,8 @@ } foo(); { - i = (i + 1); + uint v_1 = uint(i); + i = int((v_1 + uint(1))); } continue; }
diff --git a/test/tint/bug/fxc/vector_assignment_in_loop/loop_call_with_loop.wgsl.expected.spvasm b/test/tint/bug/fxc/vector_assignment_in_loop/loop_call_with_loop.wgsl.expected.spvasm index 4c33b38..2da2ce0 100644 --- a/test/tint/bug/fxc/vector_assignment_in_loop/loop_call_with_loop.wgsl.expected.spvasm +++ b/test/tint/bug/fxc/vector_assignment_in_loop/loop_call_with_loop.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 82 +; Bound: 88 ; Schema: 0 OpCapability Shader %41 = OpExtInstImport "GLSL.std.450" @@ -92,37 +92,43 @@ OpBranch %27 %27 = OpLabel %65 = OpLoad %int %i None - %66 = OpIAdd %int %65 %int_1 - OpStore %i %66 None + %66 = OpBitcast %uint %65 + %67 = OpBitcast %uint %int_1 + %68 = OpIAdd %uint %66 %67 + %69 = OpBitcast %int %68 + OpStore %i %69 None OpBranch %28 %29 = OpLabel OpReturn OpFunctionEnd %main = OpFunction %void None %23 - %68 = OpLabel + %71 = OpLabel %i_0 = OpVariable %_ptr_Function_int Function - OpBranch %69 - %69 = OpLabel - OpStore %i_0 %int_0 OpBranch %72 %72 = OpLabel - OpLoopMerge %73 %71 None - OpBranch %70 - %70 = OpLabel - %75 = OpLoad %int %i_0 None - %76 = OpSLessThan %bool %75 %int_2 - OpSelectionMerge %77 None - OpBranchConditional %76 %77 %78 - %78 = OpLabel + OpStore %i_0 %int_0 + OpBranch %75 + %75 = OpLabel + OpLoopMerge %76 %74 None OpBranch %73 - %77 = OpLabel - %79 = OpFunctionCall %void %foo - OpBranch %71 - %71 = OpLabel - %80 = OpLoad %int %i_0 None - %81 = OpIAdd %int %80 %int_1 - OpStore %i_0 %81 None - OpBranch %72 %73 = OpLabel + %78 = OpLoad %int %i_0 None + %79 = OpSLessThan %bool %78 %int_2 + OpSelectionMerge %80 None + OpBranchConditional %79 %80 %81 + %81 = OpLabel + OpBranch %76 + %80 = OpLabel + %82 = OpFunctionCall %void %foo + OpBranch %74 + %74 = OpLabel + %83 = OpLoad %int %i_0 None + %84 = OpBitcast %uint %83 + %85 = OpBitcast %uint %int_1 + %86 = OpIAdd %uint %84 %85 + %87 = OpBitcast %int %86 + OpStore %i_0 %87 None + OpBranch %75 + %76 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/bug/fxc/vector_assignment_in_loop/loop_call_with_no_loop.wgsl.expected.glsl b/test/tint/bug/fxc/vector_assignment_in_loop/loop_call_with_no_loop.wgsl.expected.glsl index 9cd1b74..dd0ebfb 100644 --- a/test/tint/bug/fxc/vector_assignment_in_loop/loop_call_with_no_loop.wgsl.expected.glsl +++ b/test/tint/bug/fxc/vector_assignment_in_loop/loop_call_with_no_loop.wgsl.expected.glsl
@@ -22,7 +22,8 @@ } foo(); { - i = (i + 1); + uint v = uint(i); + i = int((v + uint(1))); } continue; }
diff --git a/test/tint/bug/fxc/vector_assignment_in_loop/loop_call_with_no_loop.wgsl.expected.spvasm b/test/tint/bug/fxc/vector_assignment_in_loop/loop_call_with_no_loop.wgsl.expected.spvasm index a0bad64..c45b758 100644 --- a/test/tint/bug/fxc/vector_assignment_in_loop/loop_call_with_no_loop.wgsl.expected.spvasm +++ b/test/tint/bug/fxc/vector_assignment_in_loop/loop_call_with_no_loop.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 71 +; Bound: 74 ; Schema: 0 OpCapability Shader %31 = OpExtInstImport "GLSL.std.450" @@ -99,8 +99,11 @@ OpBranch %59 %59 = OpLabel %69 = OpLoad %int %i_0 None - %70 = OpIAdd %int %69 %int_1 - OpStore %i_0 %70 None + %70 = OpBitcast %uint %69 + %71 = OpBitcast %uint %int_1 + %72 = OpIAdd %uint %70 %71 + %73 = OpBitcast %int %72 + OpStore %i_0 %73 None OpBranch %60 %61 = OpLabel OpReturn
diff --git a/test/tint/bug/fxc/vector_assignment_in_loop/loop_types_all.wgsl.expected.glsl b/test/tint/bug/fxc/vector_assignment_in_loop/loop_types_all.wgsl.expected.glsl index d9c9d31..27cc20f 100644 --- a/test/tint/bug/fxc/vector_assignment_in_loop/loop_types_all.wgsl.expected.glsl +++ b/test/tint/bug/fxc/vector_assignment_in_loop/loop_types_all.wgsl.expected.glsl
@@ -34,7 +34,8 @@ v3b[min(uint(i), 2u)] = true; v4b[min(uint(i), 3u)] = true; { - i = (i + 1); + uint v = uint(i); + i = int((v + uint(1))); } continue; }
diff --git a/test/tint/bug/fxc/vector_assignment_in_loop/loop_types_all.wgsl.expected.spvasm b/test/tint/bug/fxc/vector_assignment_in_loop/loop_types_all.wgsl.expected.spvasm index 8ce5745..34f272c 100644 --- a/test/tint/bug/fxc/vector_assignment_in_loop/loop_types_all.wgsl.expected.spvasm +++ b/test/tint/bug/fxc/vector_assignment_in_loop/loop_types_all.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 130 +; Bound: 133 ; Schema: 0 OpCapability Shader %73 = OpExtInstImport "GLSL.std.450" @@ -169,8 +169,11 @@ OpBranch %59 %59 = OpLabel %128 = OpLoad %int %i None - %129 = OpIAdd %int %128 %int_1 - OpStore %i %129 None + %129 = OpBitcast %uint %128 + %130 = OpBitcast %uint %int_1 + %131 = OpIAdd %uint %129 %130 + %132 = OpBitcast %int %131 + OpStore %i %132 None OpBranch %60 %61 = OpLabel OpReturn
diff --git a/test/tint/bug/fxc/vector_assignment_in_loop/loop_types_repeated.wgsl.expected.glsl b/test/tint/bug/fxc/vector_assignment_in_loop/loop_types_repeated.wgsl.expected.glsl index 1215bd2..04e2484 100644 --- a/test/tint/bug/fxc/vector_assignment_in_loop/loop_types_repeated.wgsl.expected.glsl +++ b/test/tint/bug/fxc/vector_assignment_in_loop/loop_types_repeated.wgsl.expected.glsl
@@ -26,7 +26,8 @@ v4u_2[min(uint(i), 3u)] = 1u; v2b_2[min(uint(i), 1u)] = true; { - i = (i + 1); + uint v = uint(i); + i = int((v + uint(1))); } continue; }
diff --git a/test/tint/bug/fxc/vector_assignment_in_loop/loop_types_repeated.wgsl.expected.spvasm b/test/tint/bug/fxc/vector_assignment_in_loop/loop_types_repeated.wgsl.expected.spvasm index 30ec0c6..de73a5b 100644 --- a/test/tint/bug/fxc/vector_assignment_in_loop/loop_types_repeated.wgsl.expected.spvasm +++ b/test/tint/bug/fxc/vector_assignment_in_loop/loop_types_repeated.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 86 +; Bound: 89 ; Schema: 0 OpCapability Shader %45 = OpExtInstImport "GLSL.std.450" @@ -117,8 +117,11 @@ OpBranch %31 %31 = OpLabel %84 = OpLoad %int %i None - %85 = OpIAdd %int %84 %int_1 - OpStore %i %85 None + %85 = OpBitcast %uint %84 + %86 = OpBitcast %uint %int_1 + %87 = OpIAdd %uint %85 %86 + %88 = OpBitcast %int %87 + OpStore %i %88 None OpBranch %32 %33 = OpLabel OpReturn
diff --git a/test/tint/bug/fxc/vector_assignment_in_loop/loop_types_some.wgsl.expected.glsl b/test/tint/bug/fxc/vector_assignment_in_loop/loop_types_some.wgsl.expected.glsl index 42d897f..005c53f 100644 --- a/test/tint/bug/fxc/vector_assignment_in_loop/loop_types_some.wgsl.expected.glsl +++ b/test/tint/bug/fxc/vector_assignment_in_loop/loop_types_some.wgsl.expected.glsl
@@ -26,7 +26,8 @@ v2u[min(uint(i), 1u)] = 1u; v2b[min(uint(i), 1u)] = true; { - i = (i + 1); + uint v = uint(i); + i = int((v + uint(1))); } continue; }
diff --git a/test/tint/bug/fxc/vector_assignment_in_loop/loop_types_some.wgsl.expected.spvasm b/test/tint/bug/fxc/vector_assignment_in_loop/loop_types_some.wgsl.expected.spvasm index bd21757..7a84c7a 100644 --- a/test/tint/bug/fxc/vector_assignment_in_loop/loop_types_some.wgsl.expected.spvasm +++ b/test/tint/bug/fxc/vector_assignment_in_loop/loop_types_some.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 131 +; Bound: 134 ; Schema: 0 OpCapability Shader %68 = OpExtInstImport "GLSL.std.450" @@ -131,8 +131,11 @@ OpBranch %59 %59 = OpLabel %129 = OpLoad %int %i_0 None - %130 = OpIAdd %int %129 %int_1 - OpStore %i_0 %130 None + %130 = OpBitcast %uint %129 + %131 = OpBitcast %uint %int_1 + %132 = OpIAdd %uint %130 %131 + %133 = OpBitcast %int %132 + OpStore %i_0 %133 None OpBranch %60 %61 = OpLabel OpStore %i %int_0
diff --git a/test/tint/bug/tint/1121.wgsl.expected.glsl b/test/tint/bug/tint/1121.wgsl.expected.glsl index fd08b38..4453919 100644 --- a/test/tint/bug/tint/1121.wgsl.expected.glsl +++ b/test/tint/bug/tint/1121.wgsl.expected.glsl
@@ -103,12 +103,17 @@ } else { break; } - ivec2 tilePixel0Idx = ivec2((x * TILE_SIZE), (y * TILE_SIZE)); - vec2 v_19 = (2.0f * vec2(tilePixel0Idx)); - vec2 floorCoord = ((v_19 / v_2.inner.fullScreenSize.xy) - vec2(1.0f)); - ivec2 v_20 = tilePixel0Idx; - vec2 v_21 = (2.0f * vec2((v_20 + ivec2(TILE_SIZE)))); - vec2 ceilCoord = ((v_21 / v_2.inner.fullScreenSize.xy) - vec2(1.0f)); + uint v_19 = uint(x); + int v_20 = int((v_19 * uint(TILE_SIZE))); + uint v_21 = uint(y); + ivec2 tilePixel0Idx = ivec2(v_20, int((v_21 * uint(TILE_SIZE)))); + vec2 v_22 = (2.0f * vec2(tilePixel0Idx)); + vec2 floorCoord = ((v_22 / v_2.inner.fullScreenSize.xy) - vec2(1.0f)); + ivec2 v_23 = tilePixel0Idx; + ivec2 v_24 = ivec2(TILE_SIZE); + uvec2 v_25 = uvec2(v_23); + vec2 v_26 = (2.0f * vec2(ivec2((v_25 + uvec2(v_24))))); + vec2 ceilCoord = ((v_26 / v_2.inner.fullScreenSize.xy) - vec2(1.0f)); vec2 viewFloorCoord = vec2((((-(viewNear) * floorCoord.x) - (M[2u].x * viewNear)) / M[0u].x), (((-(viewNear) * floorCoord.y) - (M[2u].y * viewNear)) / M[1u].y)); vec2 viewCeilCoord = vec2((((-(viewNear) * ceilCoord.x) - (M[2u].x * viewNear)) / M[0u].x), (((-(viewNear) * ceilCoord.y) - (M[2u].y * viewNear)) / M[1u].y)); frustumPlanes[0u] = vec4(1.0f, 0.0f, (-(viewFloorCoord.x) / viewNear), 0.0f); @@ -124,29 +129,29 @@ break; } vec4 p = vec4(0.0f); - uint v_22 = min(i, 5u); - if ((frustumPlanes[v_22].x > 0.0f)) { + uint v_27 = min(i, 5u); + if ((frustumPlanes[v_27].x > 0.0f)) { p.x = boxMax.x; } else { p.x = boxMin.x; } - uint v_23 = min(i, 5u); - if ((frustumPlanes[v_23].y > 0.0f)) { + uint v_28 = min(i, 5u); + if ((frustumPlanes[v_28].y > 0.0f)) { p.y = boxMax.y; } else { p.y = boxMin.y; } - uint v_24 = min(i, 5u); - if ((frustumPlanes[v_24].z > 0.0f)) { + uint v_29 = min(i, 5u); + if ((frustumPlanes[v_29].z > 0.0f)) { p.z = boxMax.z; } else { p.z = boxMin.z; } p.w = 1.0f; - float v_25 = dp; - vec4 v_26 = p; - uint v_27 = min(i, 5u); - dp = (v_25 + min(0.0f, dot(v_26, frustumPlanes[v_27]))); + float v_30 = dp; + vec4 v_31 = p; + uint v_32 = min(i, 5u); + dp = (v_30 + min(0.0f, dot(v_31, frustumPlanes[v_32]))); { i = (i + 1u); } @@ -154,39 +159,47 @@ } } if ((dp >= 0.0f)) { - uint tileId = uint((x + (y * TILE_COUNT_X))); - bool v_28 = false; + int v_33 = x; + uint v_34 = uint(y); + int v_35 = int((v_34 * uint(TILE_COUNT_X))); + uint v_36 = uint(v_33); + uint tileId = uint(int((v_36 + uint(v_35)))); + bool v_37 = false; if ((tileId < 0u)) { - v_28 = true; + v_37 = true; } else { - v_28 = (tileId >= v_1.inner.numTiles); + v_37 = (tileId >= v_1.inner.numTiles); } - if (v_28) { + if (v_37) { { - x = (x + 1); + uint v_38 = uint(x); + x = int((v_38 + uint(1))); } continue; } - uint v_29 = min(tileId, 3u); - uint offset = atomicAdd(v.inner.data[v_29].count, 1u); + uint v_39 = min(tileId, 3u); + uint offset = atomicAdd(v.inner.data[v_39].count, 1u); if ((offset >= v_1.inner.numTileLightSlot)) { { - x = (x + 1); + uint v_38 = uint(x); + x = int((v_38 + uint(1))); } continue; } - uint v_30 = min(tileId, 3u); - uint v_31 = min(offset, 63u); - v.inner.data[v_30].lightId[v_31] = GlobalInvocationID.x; + uint v_40 = min(tileId, 3u); + uint v_41 = min(offset, 63u); + v.inner.data[v_40].lightId[v_41] = GlobalInvocationID.x; } { - x = (x + 1); + uint v_38 = uint(x); + x = int((v_38 + uint(1))); } continue; } } { - y = (y + 1); + uint v_42 = uint(y); + y = int((v_42 + uint(1))); } continue; }
diff --git a/test/tint/bug/tint/1121.wgsl.expected.spvasm b/test/tint/bug/tint/1121.wgsl.expected.spvasm index ef23ca4..61531d0 100644 --- a/test/tint/bug/tint/1121.wgsl.expected.spvasm +++ b/test/tint/bug/tint/1121.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 460 +; Bound: 482 ; Schema: 0 OpCapability Shader %55 = OpExtInstImport "GLSL.std.450" @@ -181,14 +181,15 @@ %_ptr_Function_v2int = OpTypePointer Function %v2int %v2float = OpTypeVector %float 2 %float_2 = OpConstant %float 2 - %236 = OpConstantComposite %v2float %float_1 %float_1 + %245 = OpConstantComposite %v2float %float_1 %float_1 %_ptr_Function_v2float = OpTypePointer Function %v2float - %358 = OpConstantNull %v4float + %v2uint = OpTypeVector %uint 2 + %374 = OpConstantNull %v4float %true = OpConstantTrue %bool %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint %uint_63 = OpConstant %uint 63 %_ptr_StorageBuffer_uint_0 = OpTypePointer StorageBuffer %uint - %456 = OpTypeFunction %void + %478 = OpTypeFunction %void %main_inner = OpFunction %void None %34 %GlobalInvocationID = OpFunctionParameter %v3uint %35 = OpLabel @@ -210,7 +211,7 @@ %viewCeilCoord = OpVariable %_ptr_Function_v2float Function %dp = OpVariable %_ptr_Function_float Function %i = OpVariable %_ptr_Function_uint Function - %p = OpVariable %_ptr_Function_v4float Function %358 + %p = OpVariable %_ptr_Function_v4float Function %374 %tileId = OpVariable %_ptr_Function_uint Function %offset = OpVariable %_ptr_Function_uint Function %36 = OpCompositeExtract %uint %GlobalInvocationID 0 @@ -373,303 +374,324 @@ OpLoopMerge %209 %207 None OpBranch %206 %206 = OpLabel - %214 = OpLoad %int %x None - %215 = OpSLessThan %bool %214 %TILE_COUNT_X - OpSelectionMerge %216 None - OpBranchConditional %215 %216 %217 - %217 = OpLabel + %217 = OpLoad %int %x None + %218 = OpSLessThan %bool %217 %TILE_COUNT_X + OpSelectionMerge %219 None + OpBranchConditional %218 %219 %220 + %220 = OpLabel OpBranch %209 - %216 = OpLabel - %218 = OpLoad %int %x None - %219 = OpIMul %int %218 %TILE_SIZE - %220 = OpLoad %int %y None - %221 = OpIMul %int %220 %TILE_SIZE - %223 = OpCompositeConstruct %v2int %219 %221 - OpStore %tilePixel0Idx %223 - %226 = OpLoad %v2int %tilePixel0Idx None - %228 = OpConvertSToF %v2float %226 - %229 = OpVectorTimesScalar %v2float %228 %float_2 - %231 = OpAccessChain %_ptr_Uniform_v4float %23 %uint_0 %uint_4 - %232 = OpLoad %v4float %231 None - %233 = OpVectorShuffle %v2float %232 %232 0 1 - %234 = OpFDiv %v2float %229 %233 - %235 = OpFSub %v2float %234 %236 - OpStore %floorCoord %235 - %239 = OpLoad %v2int %tilePixel0Idx None - %240 = OpCompositeConstruct %v2int %TILE_SIZE %TILE_SIZE - %241 = OpIAdd %v2int %239 %240 - %242 = OpConvertSToF %v2float %241 - %243 = OpVectorTimesScalar %v2float %242 %float_2 - %244 = OpAccessChain %_ptr_Uniform_v4float %23 %uint_0 %uint_4 - %245 = OpLoad %v4float %244 None - %246 = OpVectorShuffle %v2float %245 %245 0 1 - %247 = OpFDiv %v2float %243 %246 - %248 = OpFSub %v2float %247 %236 - OpStore %ceilCoord %248 - %250 = OpLoad %float %viewNear None - %251 = OpFNegate %float %250 - %252 = OpAccessChain %_ptr_Function_float %floorCoord %uint_0 - %253 = OpLoad %float %252 None - %254 = OpFMul %float %251 %253 - %255 = OpAccessChain %_ptr_Function_v4float %M %uint_2 - %256 = OpAccessChain %_ptr_Function_float %255 %uint_0 - %257 = OpLoad %float %256 None - %258 = OpLoad %float %viewNear None - %259 = OpFMul %float %257 %258 - %260 = OpFSub %float %254 %259 - %261 = OpAccessChain %_ptr_Function_v4float %M %uint_0 - %262 = OpAccessChain %_ptr_Function_float %261 %uint_0 - %263 = OpLoad %float %262 None - %264 = OpFDiv %float %260 %263 - %265 = OpLoad %float %viewNear None - %266 = OpFNegate %float %265 - %267 = OpAccessChain %_ptr_Function_float %floorCoord %uint_1 - %268 = OpLoad %float %267 None - %269 = OpFMul %float %266 %268 - %270 = OpAccessChain %_ptr_Function_v4float %M %uint_2 - %271 = OpAccessChain %_ptr_Function_float %270 %uint_1 - %272 = OpLoad %float %271 None - %273 = OpLoad %float %viewNear None - %274 = OpFMul %float %272 %273 - %275 = OpFSub %float %269 %274 - %276 = OpAccessChain %_ptr_Function_v4float %M %uint_1 - %277 = OpAccessChain %_ptr_Function_float %276 %uint_1 - %278 = OpLoad %float %277 None - %279 = OpFDiv %float %275 %278 - %280 = OpCompositeConstruct %v2float %264 %279 - OpStore %viewFloorCoord %280 - %282 = OpLoad %float %viewNear None - %283 = OpFNegate %float %282 - %284 = OpAccessChain %_ptr_Function_float %ceilCoord %uint_0 + %219 = OpLabel + %221 = OpLoad %int %x None + %222 = OpBitcast %uint %221 + %223 = OpBitcast %uint %TILE_SIZE + %224 = OpIMul %uint %222 %223 + %225 = OpBitcast %int %224 + %226 = OpLoad %int %y None + %227 = OpBitcast %uint %226 + %228 = OpBitcast %uint %TILE_SIZE + %229 = OpIMul %uint %227 %228 + %230 = OpBitcast %int %229 + %232 = OpCompositeConstruct %v2int %225 %230 + OpStore %tilePixel0Idx %232 + %235 = OpLoad %v2int %tilePixel0Idx None + %237 = OpConvertSToF %v2float %235 + %238 = OpVectorTimesScalar %v2float %237 %float_2 + %240 = OpAccessChain %_ptr_Uniform_v4float %23 %uint_0 %uint_4 + %241 = OpLoad %v4float %240 None + %242 = OpVectorShuffle %v2float %241 %241 0 1 + %243 = OpFDiv %v2float %238 %242 + %244 = OpFSub %v2float %243 %245 + OpStore %floorCoord %244 + %248 = OpLoad %v2int %tilePixel0Idx None + %249 = OpCompositeConstruct %v2int %TILE_SIZE %TILE_SIZE + %251 = OpBitcast %v2uint %248 + %252 = OpBitcast %v2uint %249 + %253 = OpIAdd %v2uint %251 %252 + %254 = OpBitcast %v2int %253 + %255 = OpConvertSToF %v2float %254 + %256 = OpVectorTimesScalar %v2float %255 %float_2 + %257 = OpAccessChain %_ptr_Uniform_v4float %23 %uint_0 %uint_4 + %258 = OpLoad %v4float %257 None + %259 = OpVectorShuffle %v2float %258 %258 0 1 + %260 = OpFDiv %v2float %256 %259 + %261 = OpFSub %v2float %260 %245 + OpStore %ceilCoord %261 + %263 = OpLoad %float %viewNear None + %264 = OpFNegate %float %263 + %265 = OpAccessChain %_ptr_Function_float %floorCoord %uint_0 + %266 = OpLoad %float %265 None + %267 = OpFMul %float %264 %266 + %268 = OpAccessChain %_ptr_Function_v4float %M %uint_2 + %269 = OpAccessChain %_ptr_Function_float %268 %uint_0 + %270 = OpLoad %float %269 None + %271 = OpLoad %float %viewNear None + %272 = OpFMul %float %270 %271 + %273 = OpFSub %float %267 %272 + %274 = OpAccessChain %_ptr_Function_v4float %M %uint_0 + %275 = OpAccessChain %_ptr_Function_float %274 %uint_0 + %276 = OpLoad %float %275 None + %277 = OpFDiv %float %273 %276 + %278 = OpLoad %float %viewNear None + %279 = OpFNegate %float %278 + %280 = OpAccessChain %_ptr_Function_float %floorCoord %uint_1 + %281 = OpLoad %float %280 None + %282 = OpFMul %float %279 %281 + %283 = OpAccessChain %_ptr_Function_v4float %M %uint_2 + %284 = OpAccessChain %_ptr_Function_float %283 %uint_1 %285 = OpLoad %float %284 None - %286 = OpFMul %float %283 %285 - %287 = OpAccessChain %_ptr_Function_v4float %M %uint_2 - %288 = OpAccessChain %_ptr_Function_float %287 %uint_0 - %289 = OpLoad %float %288 None - %290 = OpLoad %float %viewNear None - %291 = OpFMul %float %289 %290 - %292 = OpFSub %float %286 %291 - %293 = OpAccessChain %_ptr_Function_v4float %M %uint_0 - %294 = OpAccessChain %_ptr_Function_float %293 %uint_0 - %295 = OpLoad %float %294 None - %296 = OpFDiv %float %292 %295 - %297 = OpLoad %float %viewNear None - %298 = OpFNegate %float %297 - %299 = OpAccessChain %_ptr_Function_float %ceilCoord %uint_1 - %300 = OpLoad %float %299 None - %301 = OpFMul %float %298 %300 - %302 = OpAccessChain %_ptr_Function_v4float %M %uint_2 - %303 = OpAccessChain %_ptr_Function_float %302 %uint_1 - %304 = OpLoad %float %303 None - %305 = OpLoad %float %viewNear None - %306 = OpFMul %float %304 %305 - %307 = OpFSub %float %301 %306 - %308 = OpAccessChain %_ptr_Function_v4float %M %uint_1 - %309 = OpAccessChain %_ptr_Function_float %308 %uint_1 - %310 = OpLoad %float %309 None - %311 = OpFDiv %float %307 %310 - %312 = OpCompositeConstruct %v2float %296 %311 - OpStore %viewCeilCoord %312 - %314 = OpAccessChain %_ptr_Function_v4float %frustumPlanes %uint_0 - %315 = OpAccessChain %_ptr_Function_float %viewFloorCoord %uint_0 - %316 = OpLoad %float %315 None - %317 = OpFNegate %float %316 + %286 = OpLoad %float %viewNear None + %287 = OpFMul %float %285 %286 + %288 = OpFSub %float %282 %287 + %289 = OpAccessChain %_ptr_Function_v4float %M %uint_1 + %290 = OpAccessChain %_ptr_Function_float %289 %uint_1 + %291 = OpLoad %float %290 None + %292 = OpFDiv %float %288 %291 + %293 = OpCompositeConstruct %v2float %277 %292 + OpStore %viewFloorCoord %293 + %295 = OpLoad %float %viewNear None + %296 = OpFNegate %float %295 + %297 = OpAccessChain %_ptr_Function_float %ceilCoord %uint_0 + %298 = OpLoad %float %297 None + %299 = OpFMul %float %296 %298 + %300 = OpAccessChain %_ptr_Function_v4float %M %uint_2 + %301 = OpAccessChain %_ptr_Function_float %300 %uint_0 + %302 = OpLoad %float %301 None + %303 = OpLoad %float %viewNear None + %304 = OpFMul %float %302 %303 + %305 = OpFSub %float %299 %304 + %306 = OpAccessChain %_ptr_Function_v4float %M %uint_0 + %307 = OpAccessChain %_ptr_Function_float %306 %uint_0 + %308 = OpLoad %float %307 None + %309 = OpFDiv %float %305 %308 + %310 = OpLoad %float %viewNear None + %311 = OpFNegate %float %310 + %312 = OpAccessChain %_ptr_Function_float %ceilCoord %uint_1 + %313 = OpLoad %float %312 None + %314 = OpFMul %float %311 %313 + %315 = OpAccessChain %_ptr_Function_v4float %M %uint_2 + %316 = OpAccessChain %_ptr_Function_float %315 %uint_1 + %317 = OpLoad %float %316 None %318 = OpLoad %float %viewNear None - %319 = OpFDiv %float %317 %318 - %320 = OpCompositeConstruct %v4float %float_1 %float_0 %319 %float_0 - OpStore %314 %320 None - %321 = OpAccessChain %_ptr_Function_v4float %frustumPlanes %uint_1 - %322 = OpAccessChain %_ptr_Function_float %viewCeilCoord %uint_0 + %319 = OpFMul %float %317 %318 + %320 = OpFSub %float %314 %319 + %321 = OpAccessChain %_ptr_Function_v4float %M %uint_1 + %322 = OpAccessChain %_ptr_Function_float %321 %uint_1 %323 = OpLoad %float %322 None - %324 = OpLoad %float %viewNear None - %325 = OpFDiv %float %323 %324 - %326 = OpCompositeConstruct %v4float %float_n1 %float_0 %325 %float_0 - OpStore %321 %326 None - %327 = OpAccessChain %_ptr_Function_v4float %frustumPlanes %uint_2 - %328 = OpAccessChain %_ptr_Function_float %viewFloorCoord %uint_1 + %324 = OpFDiv %float %320 %323 + %325 = OpCompositeConstruct %v2float %309 %324 + OpStore %viewCeilCoord %325 + %327 = OpAccessChain %_ptr_Function_v4float %frustumPlanes %uint_0 + %328 = OpAccessChain %_ptr_Function_float %viewFloorCoord %uint_0 %329 = OpLoad %float %328 None %330 = OpFNegate %float %329 %331 = OpLoad %float %viewNear None %332 = OpFDiv %float %330 %331 - %333 = OpCompositeConstruct %v4float %float_0 %float_1 %332 %float_0 + %333 = OpCompositeConstruct %v4float %float_1 %float_0 %332 %float_0 OpStore %327 %333 None - %334 = OpAccessChain %_ptr_Function_v4float %frustumPlanes %uint_3 - %335 = OpAccessChain %_ptr_Function_float %viewCeilCoord %uint_1 + %334 = OpAccessChain %_ptr_Function_v4float %frustumPlanes %uint_1 + %335 = OpAccessChain %_ptr_Function_float %viewCeilCoord %uint_0 %336 = OpLoad %float %335 None %337 = OpLoad %float %viewNear None %338 = OpFDiv %float %336 %337 - %339 = OpCompositeConstruct %v4float %float_0 %float_n1 %338 %float_0 + %339 = OpCompositeConstruct %v4float %float_n1 %float_0 %338 %float_0 OpStore %334 %339 None + %340 = OpAccessChain %_ptr_Function_v4float %frustumPlanes %uint_2 + %341 = OpAccessChain %_ptr_Function_float %viewFloorCoord %uint_1 + %342 = OpLoad %float %341 None + %343 = OpFNegate %float %342 + %344 = OpLoad %float %viewNear None + %345 = OpFDiv %float %343 %344 + %346 = OpCompositeConstruct %v4float %float_0 %float_1 %345 %float_0 + OpStore %340 %346 None + %347 = OpAccessChain %_ptr_Function_v4float %frustumPlanes %uint_3 + %348 = OpAccessChain %_ptr_Function_float %viewCeilCoord %uint_1 + %349 = OpLoad %float %348 None + %350 = OpLoad %float %viewNear None + %351 = OpFDiv %float %349 %350 + %352 = OpCompositeConstruct %v4float %float_0 %float_n1 %351 %float_0 + OpStore %347 %352 None OpStore %dp %float_0 - OpBranch %341 - %341 = OpLabel + OpBranch %354 + %354 = OpLabel OpStore %i %uint_0 - OpBranch %344 - %344 = OpLabel - OpLoopMerge %345 %343 None - OpBranch %342 - %342 = OpLabel - %353 = OpLoad %uint %i None - %354 = OpULessThan %bool %353 %uint_6 - OpSelectionMerge %355 None - OpBranchConditional %354 %355 %356 - %356 = OpLabel - OpBranch %345 + OpBranch %357 + %357 = OpLabel + OpLoopMerge %358 %356 None + OpBranch %355 %355 = OpLabel - %359 = OpLoad %uint %i None - %360 = OpExtInst %uint %55 UMin %359 %uint_5 - %361 = OpAccessChain %_ptr_Function_v4float %frustumPlanes %360 - %362 = OpAccessChain %_ptr_Function_float %361 %uint_0 - %363 = OpLoad %float %362 None - %364 = OpFOrdGreaterThan %bool %363 %float_0 - OpSelectionMerge %365 None - OpBranchConditional %364 %366 %367 - %366 = OpLabel - %434 = OpAccessChain %_ptr_Function_float %boxMax %uint_0 - %435 = OpLoad %float %434 None - %436 = OpAccessChain %_ptr_Function_float %p %uint_0 - OpStore %436 %435 None - OpBranch %365 - %367 = OpLabel - %437 = OpAccessChain %_ptr_Function_float %boxMin %uint_0 - %438 = OpLoad %float %437 None - %439 = OpAccessChain %_ptr_Function_float %p %uint_0 - OpStore %439 %438 None - OpBranch %365 - %365 = OpLabel - %368 = OpLoad %uint %i None - %369 = OpExtInst %uint %55 UMin %368 %uint_5 - %370 = OpAccessChain %_ptr_Function_v4float %frustumPlanes %369 - %371 = OpAccessChain %_ptr_Function_float %370 %uint_1 - %372 = OpLoad %float %371 None - %373 = OpFOrdGreaterThan %bool %372 %float_0 - OpSelectionMerge %374 None - OpBranchConditional %373 %375 %376 - %375 = OpLabel - %440 = OpAccessChain %_ptr_Function_float %boxMax %uint_1 - %441 = OpLoad %float %440 None - %442 = OpAccessChain %_ptr_Function_float %p %uint_1 - OpStore %442 %441 None - OpBranch %374 - %376 = OpLabel - %443 = OpAccessChain %_ptr_Function_float %boxMin %uint_1 - %444 = OpLoad %float %443 None - %445 = OpAccessChain %_ptr_Function_float %p %uint_1 - OpStore %445 %444 None - OpBranch %374 - %374 = OpLabel - %377 = OpLoad %uint %i None - %378 = OpExtInst %uint %55 UMin %377 %uint_5 - %379 = OpAccessChain %_ptr_Function_v4float %frustumPlanes %378 - %380 = OpAccessChain %_ptr_Function_float %379 %uint_2 - %381 = OpLoad %float %380 None - %382 = OpFOrdGreaterThan %bool %381 %float_0 - OpSelectionMerge %383 None - OpBranchConditional %382 %384 %385 - %384 = OpLabel - %446 = OpAccessChain %_ptr_Function_float %boxMax %uint_2 - %447 = OpLoad %float %446 None - %448 = OpAccessChain %_ptr_Function_float %p %uint_2 - OpStore %448 %447 None - OpBranch %383 - %385 = OpLabel - %449 = OpAccessChain %_ptr_Function_float %boxMin %uint_2 - %450 = OpLoad %float %449 None - %451 = OpAccessChain %_ptr_Function_float %p %uint_2 - OpStore %451 %450 None - OpBranch %383 + %369 = OpLoad %uint %i None + %370 = OpULessThan %bool %369 %uint_6 + OpSelectionMerge %371 None + OpBranchConditional %370 %371 %372 + %372 = OpLabel + OpBranch %358 + %371 = OpLabel + %375 = OpLoad %uint %i None + %376 = OpExtInst %uint %55 UMin %375 %uint_5 + %377 = OpAccessChain %_ptr_Function_v4float %frustumPlanes %376 + %378 = OpAccessChain %_ptr_Function_float %377 %uint_0 + %379 = OpLoad %float %378 None + %380 = OpFOrdGreaterThan %bool %379 %float_0 + OpSelectionMerge %381 None + OpBranchConditional %380 %382 %383 + %382 = OpLabel + %456 = OpAccessChain %_ptr_Function_float %boxMax %uint_0 + %457 = OpLoad %float %456 None + %458 = OpAccessChain %_ptr_Function_float %p %uint_0 + OpStore %458 %457 None + OpBranch %381 %383 = OpLabel - %386 = OpAccessChain %_ptr_Function_float %p %uint_3 - OpStore %386 %float_1 None - %387 = OpLoad %float %dp None - %388 = OpLoad %v4float %p None - %389 = OpLoad %uint %i None - %390 = OpExtInst %uint %55 UMin %389 %uint_5 - %391 = OpAccessChain %_ptr_Function_v4float %frustumPlanes %390 - %392 = OpLoad %v4float %391 None - %393 = OpDot %float %388 %392 - %394 = OpExtInst %float %55 NMin %float_0 %393 - %395 = OpFAdd %float %387 %394 - OpStore %dp %395 None - OpBranch %343 - %343 = OpLabel - %396 = OpLoad %uint %i None - %397 = OpIAdd %uint %396 %uint_1 - OpStore %i %397 None - OpBranch %344 - %345 = OpLabel - %346 = OpLoad %float %dp None - %347 = OpFOrdGreaterThanEqual %bool %346 %float_0 - OpSelectionMerge %348 None - OpBranchConditional %347 %349 %348 - %349 = OpLabel - %398 = OpLoad %int %x None - %399 = OpLoad %int %y None - %400 = OpIMul %int %399 %TILE_COUNT_X - %401 = OpIAdd %int %398 %400 - %402 = OpBitcast %uint %401 - OpStore %tileId %402 - %404 = OpLoad %uint %tileId None - %405 = OpULessThan %bool %404 %uint_0 - OpSelectionMerge %406 None - OpBranchConditional %405 %407 %408 - %407 = OpLabel - OpBranch %406 - %408 = OpLabel - %452 = OpLoad %uint %tileId None - %453 = OpAccessChain %_ptr_Uniform_uint %19 %uint_0 %uint_1 - %454 = OpLoad %uint %453 None - %411 = OpUGreaterThanEqual %bool %452 %454 - OpBranch %406 - %406 = OpLabel - %409 = OpPhi %bool %true %407 %411 %408 - OpSelectionMerge %412 None - OpBranchConditional %409 %413 %412 - %413 = OpLabel - OpBranch %207 - %412 = OpLabel - %414 = OpLoad %uint %tileId None - %415 = OpExtInst %uint %55 UMin %414 %uint_3 - %416 = OpAccessChain %_ptr_StorageBuffer_uint %9 %uint_0 %uint_0 %415 %uint_0 - %418 = OpAtomicIAdd %uint %416 %uint_1 %uint_0 %uint_1 - OpStore %offset %418 - %420 = OpLoad %uint %offset None - %421 = OpAccessChain %_ptr_Uniform_uint %19 %uint_0 %uint_4 - %422 = OpLoad %uint %421 None - %423 = OpUGreaterThanEqual %bool %420 %422 - OpSelectionMerge %424 None - OpBranchConditional %423 %425 %424 - %425 = OpLabel - OpBranch %207 - %424 = OpLabel + %459 = OpAccessChain %_ptr_Function_float %boxMin %uint_0 + %460 = OpLoad %float %459 None + %461 = OpAccessChain %_ptr_Function_float %p %uint_0 + OpStore %461 %460 None + OpBranch %381 + %381 = OpLabel + %384 = OpLoad %uint %i None + %385 = OpExtInst %uint %55 UMin %384 %uint_5 + %386 = OpAccessChain %_ptr_Function_v4float %frustumPlanes %385 + %387 = OpAccessChain %_ptr_Function_float %386 %uint_1 + %388 = OpLoad %float %387 None + %389 = OpFOrdGreaterThan %bool %388 %float_0 + OpSelectionMerge %390 None + OpBranchConditional %389 %391 %392 + %391 = OpLabel + %462 = OpAccessChain %_ptr_Function_float %boxMax %uint_1 + %463 = OpLoad %float %462 None + %464 = OpAccessChain %_ptr_Function_float %p %uint_1 + OpStore %464 %463 None + OpBranch %390 + %392 = OpLabel + %465 = OpAccessChain %_ptr_Function_float %boxMin %uint_1 + %466 = OpLoad %float %465 None + %467 = OpAccessChain %_ptr_Function_float %p %uint_1 + OpStore %467 %466 None + OpBranch %390 + %390 = OpLabel + %393 = OpLoad %uint %i None + %394 = OpExtInst %uint %55 UMin %393 %uint_5 + %395 = OpAccessChain %_ptr_Function_v4float %frustumPlanes %394 + %396 = OpAccessChain %_ptr_Function_float %395 %uint_2 + %397 = OpLoad %float %396 None + %398 = OpFOrdGreaterThan %bool %397 %float_0 + OpSelectionMerge %399 None + OpBranchConditional %398 %400 %401 + %400 = OpLabel + %468 = OpAccessChain %_ptr_Function_float %boxMax %uint_2 + %469 = OpLoad %float %468 None + %470 = OpAccessChain %_ptr_Function_float %p %uint_2 + OpStore %470 %469 None + OpBranch %399 + %401 = OpLabel + %471 = OpAccessChain %_ptr_Function_float %boxMin %uint_2 + %472 = OpLoad %float %471 None + %473 = OpAccessChain %_ptr_Function_float %p %uint_2 + OpStore %473 %472 None + OpBranch %399 + %399 = OpLabel + %402 = OpAccessChain %_ptr_Function_float %p %uint_3 + OpStore %402 %float_1 None + %403 = OpLoad %float %dp None + %404 = OpLoad %v4float %p None + %405 = OpLoad %uint %i None + %406 = OpExtInst %uint %55 UMin %405 %uint_5 + %407 = OpAccessChain %_ptr_Function_v4float %frustumPlanes %406 + %408 = OpLoad %v4float %407 None + %409 = OpDot %float %404 %408 + %410 = OpExtInst %float %55 NMin %float_0 %409 + %411 = OpFAdd %float %403 %410 + OpStore %dp %411 None + OpBranch %356 + %356 = OpLabel + %412 = OpLoad %uint %i None + %413 = OpIAdd %uint %412 %uint_1 + OpStore %i %413 None + OpBranch %357 + %358 = OpLabel + %359 = OpLoad %float %dp None + %360 = OpFOrdGreaterThanEqual %bool %359 %float_0 + OpSelectionMerge %361 None + OpBranchConditional %360 %362 %361 + %362 = OpLabel + %414 = OpLoad %int %x None + %415 = OpLoad %int %y None + %416 = OpBitcast %uint %415 + %417 = OpBitcast %uint %TILE_COUNT_X + %418 = OpIMul %uint %416 %417 + %419 = OpBitcast %int %418 + %420 = OpBitcast %uint %414 + %421 = OpBitcast %uint %419 + %422 = OpIAdd %uint %420 %421 + %423 = OpBitcast %int %422 + %424 = OpBitcast %uint %423 + OpStore %tileId %424 %426 = OpLoad %uint %tileId None - %427 = OpLoad %uint %offset None - %428 = OpExtInst %uint %55 UMin %426 %uint_3 - %429 = OpExtInst %uint %55 UMin %427 %uint_63 - %431 = OpAccessChain %_ptr_StorageBuffer_uint_0 %9 %uint_0 %uint_0 %428 %uint_1 %429 - %433 = OpCompositeExtract %uint %GlobalInvocationID 0 - OpStore %431 %433 None - OpBranch %348 - %348 = OpLabel + %427 = OpULessThan %bool %426 %uint_0 + OpSelectionMerge %428 None + OpBranchConditional %427 %429 %430 + %429 = OpLabel + OpBranch %428 + %430 = OpLabel + %474 = OpLoad %uint %tileId None + %475 = OpAccessChain %_ptr_Uniform_uint %19 %uint_0 %uint_1 + %476 = OpLoad %uint %475 None + %433 = OpUGreaterThanEqual %bool %474 %476 + OpBranch %428 + %428 = OpLabel + %431 = OpPhi %bool %true %429 %433 %430 + OpSelectionMerge %434 None + OpBranchConditional %431 %435 %434 + %435 = OpLabel + OpBranch %207 + %434 = OpLabel + %436 = OpLoad %uint %tileId None + %437 = OpExtInst %uint %55 UMin %436 %uint_3 + %438 = OpAccessChain %_ptr_StorageBuffer_uint %9 %uint_0 %uint_0 %437 %uint_0 + %440 = OpAtomicIAdd %uint %438 %uint_1 %uint_0 %uint_1 + OpStore %offset %440 + %442 = OpLoad %uint %offset None + %443 = OpAccessChain %_ptr_Uniform_uint %19 %uint_0 %uint_4 + %444 = OpLoad %uint %443 None + %445 = OpUGreaterThanEqual %bool %442 %444 + OpSelectionMerge %446 None + OpBranchConditional %445 %447 %446 + %447 = OpLabel + OpBranch %207 + %446 = OpLabel + %448 = OpLoad %uint %tileId None + %449 = OpLoad %uint %offset None + %450 = OpExtInst %uint %55 UMin %448 %uint_3 + %451 = OpExtInst %uint %55 UMin %449 %uint_63 + %453 = OpAccessChain %_ptr_StorageBuffer_uint_0 %9 %uint_0 %uint_0 %450 %uint_1 %451 + %455 = OpCompositeExtract %uint %GlobalInvocationID 0 + OpStore %453 %455 None + OpBranch %361 + %361 = OpLabel OpBranch %207 %207 = OpLabel - %350 = OpLoad %int %x None - %351 = OpIAdd %int %350 %int_1 - OpStore %x %351 None + %363 = OpLoad %int %x None + %364 = OpBitcast %uint %363 + %365 = OpBitcast %uint %int_1 + %366 = OpIAdd %uint %364 %365 + %367 = OpBitcast %int %366 + OpStore %x %367 None OpBranch %208 %209 = OpLabel OpBranch %185 %185 = OpLabel %210 = OpLoad %int %y None - %211 = OpIAdd %int %210 %int_1 - OpStore %y %211 None + %211 = OpBitcast %uint %210 + %212 = OpBitcast %uint %int_1 + %214 = OpIAdd %uint %211 %212 + %215 = OpBitcast %int %214 + OpStore %y %215 None OpBranch %186 %187 = OpLabel OpReturn OpFunctionEnd - %main = OpFunction %void None %456 - %457 = OpLabel - %458 = OpLoad %v3uint %main_global_invocation_id_Input None - %459 = OpFunctionCall %void %main_inner %458 + %main = OpFunction %void None %478 + %479 = OpLabel + %480 = OpLoad %v3uint %main_global_invocation_id_Input None + %481 = OpFunctionCall %void %main_inner %480 OpReturn OpFunctionEnd
diff --git a/test/tint/bug/tint/1542.wgsl.expected.glsl b/test/tint/bug/tint/1542.wgsl.expected.glsl index 695e99b..f318657 100644 --- a/test/tint/bug/tint/1542.wgsl.expected.glsl +++ b/test/tint/bug/tint/1542.wgsl.expected.glsl
@@ -12,5 +12,5 @@ } v; layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - ivec3 temp = (v.inner.d << (uvec3(0u) & uvec3(31u))); + ivec3 temp = ivec3((uvec3(v.inner.d) << (uvec3(0u) & uvec3(31u)))); }
diff --git a/test/tint/bug/tint/1542.wgsl.expected.spvasm b/test/tint/bug/tint/1542.wgsl.expected.spvasm index c06e0d6..e2f77e1 100644 --- a/test/tint/bug/tint/1542.wgsl.expected.spvasm +++ b/test/tint/bug/tint/1542.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 22 +; Bound: 24 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -39,6 +39,8 @@ %11 = OpAccessChain %_ptr_Uniform_v3int %1 %uint_0 %uint_0 %15 = OpLoad %v3int %11 None %16 = OpBitwiseAnd %v3uint %17 %19 - %temp = OpShiftLeftLogical %v3int %15 %16 + %21 = OpBitcast %v3uint %15 + %22 = OpShiftLeftLogical %v3uint %21 %16 + %temp = OpBitcast %v3int %22 OpReturn OpFunctionEnd
diff --git a/test/tint/bug/tint/1557.wgsl.expected.glsl b/test/tint/bug/tint/1557.wgsl.expected.glsl index 8a1148d..9d73f41 100644 --- a/test/tint/bug/tint/1557.wgsl.expected.glsl +++ b/test/tint/bug/tint/1557.wgsl.expected.glsl
@@ -18,7 +18,8 @@ if ((j >= 1)) { break; } - j = (j + 1); + uint v_1 = uint(j); + j = int((v_1 + uint(1))); int k = f(); { uint tint_low_inc = (tint_loop_idx.x - 1u);
diff --git a/test/tint/bug/tint/1557.wgsl.expected.spvasm b/test/tint/bug/tint/1557.wgsl.expected.spvasm index 4fde7bb..34e1917 100644 --- a/test/tint/bug/tint/1557.wgsl.expected.spvasm +++ b/test/tint/bug/tint/1557.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 70 +; Bound: 73 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -78,48 +78,51 @@ OpBranch %19 %37 = OpLabel %39 = OpLoad %int %j None - %40 = OpIAdd %int %39 %int_1 - OpStore %j %40 None - %41 = OpFunctionCall %int %f - OpStore %k %41 + %40 = OpBitcast %uint %39 + %41 = OpBitcast %uint %int_1 + %42 = OpIAdd %uint %40 %41 + %43 = OpBitcast %int %42 + OpStore %j %43 None + %44 = OpFunctionCall %int %f + OpStore %k %44 OpBranch %17 %17 = OpLabel - %43 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 - %46 = OpLoad %uint %43 None -%tint_low_inc = OpISub %uint %46 %uint_1 - %49 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 - OpStore %49 %tint_low_inc None - %50 = OpIEqual %bool %tint_low_inc %uint_4294967295 - %tint_carry = OpSelect %uint %50 %uint_1 %uint_0 - %52 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 - %53 = OpLoad %uint %52 None - %54 = OpISub %uint %53 %tint_carry + %46 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 + %49 = OpLoad %uint %46 None +%tint_low_inc = OpISub %uint %49 %uint_1 + %52 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 + OpStore %52 %tint_low_inc None + %53 = OpIEqual %bool %tint_low_inc %uint_4294967295 + %tint_carry = OpSelect %uint %53 %uint_1 %uint_0 %55 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 - OpStore %55 %54 None + %56 = OpLoad %uint %55 None + %57 = OpISub %uint %56 %tint_carry + %58 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 + OpStore %58 %57 None OpBranch %18 %19 = OpLabel OpReturn OpFunctionEnd %main = OpFunction %void None %11 - %57 = OpLabel - %58 = OpAccessChain %_ptr_Uniform_int %1 %uint_0 - %60 = OpLoad %int %58 None - OpSelectionMerge %63 None - OpSwitch %60 %61 0 %62 - %61 = OpLabel - OpBranch %63 - %62 = OpLabel - %64 = OpAccessChain %_ptr_Uniform_int %1 %uint_0 - %65 = OpLoad %int %64 None - OpSelectionMerge %68 None - OpSwitch %65 %66 0 %67 + %60 = OpLabel + %61 = OpAccessChain %_ptr_Uniform_int %1 %uint_0 + %63 = OpLoad %int %61 None + OpSelectionMerge %66 None + OpSwitch %63 %64 0 %65 + %64 = OpLabel + OpBranch %66 + %65 = OpLabel + %67 = OpAccessChain %_ptr_Uniform_int %1 %uint_0 + %68 = OpLoad %int %67 None + OpSelectionMerge %71 None + OpSwitch %68 %69 0 %70 + %69 = OpLabel + %72 = OpFunctionCall %void %g + OpBranch %71 + %70 = OpLabel + OpBranch %71 + %71 = OpLabel + OpBranch %66 %66 = OpLabel - %69 = OpFunctionCall %void %g - OpBranch %68 - %67 = OpLabel - OpBranch %68 - %68 = OpLabel - OpBranch %63 - %63 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/bug/tint/1605.wgsl.expected.glsl b/test/tint/bug/tint/1605.wgsl.expected.glsl index f4fb323..7e40898 100644 --- a/test/tint/bug/tint/1605.wgsl.expected.glsl +++ b/test/tint/bug/tint/1605.wgsl.expected.glsl
@@ -35,7 +35,8 @@ tint_loop_idx.x = tint_low_inc; uint tint_carry = uint((tint_low_inc == 4294967295u)); tint_loop_idx.y = (tint_loop_idx.y - tint_carry); - i = (i + 1); + uint v_1 = uint(i); + i = int((v_1 + uint(1))); } continue; }
diff --git a/test/tint/bug/tint/1605.wgsl.expected.spvasm b/test/tint/bug/tint/1605.wgsl.expected.spvasm index 6ca170f..98e94bb 100644 --- a/test/tint/bug/tint/1605.wgsl.expected.spvasm +++ b/test/tint/bug/tint/1605.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 101 +; Bound: 107 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -52,7 +52,7 @@ %false = OpConstantFalse %bool %int_n1 = OpConstant %int -1 %void = OpTypeVoid - %98 = OpTypeFunction %void + %104 = OpTypeFunction %void %func_3 = OpFunction %bool None %7 %8 = OpLabel %return_value = OpVariable %_ptr_Function_bool Function %11 @@ -97,40 +97,43 @@ OpLoopMerge %51 %49 None OpBranch %48 %48 = OpLabel - %75 = OpLoad %v2uint %tint_loop_idx_0 None - %76 = OpIEqual %v2bool %75 %34 - %77 = OpAll %bool %76 - OpSelectionMerge %78 None - OpBranchConditional %77 %79 %78 - %79 = OpLabel - OpBranch %51 - %78 = OpLabel - %80 = OpLoad %int %j None - %81 = OpIEqual %bool %80 %int_1 - OpSelectionMerge %82 None - OpBranchConditional %81 %82 %83 - %83 = OpLabel - OpBranch %51 + %78 = OpLoad %v2uint %tint_loop_idx_0 None + %79 = OpIEqual %v2bool %78 %34 + %80 = OpAll %bool %79 + OpSelectionMerge %81 None + OpBranchConditional %80 %82 %81 %82 = OpLabel + OpBranch %51 + %81 = OpLabel + %83 = OpLoad %int %j None + %84 = OpIEqual %bool %83 %int_1 + OpSelectionMerge %85 None + OpBranchConditional %84 %85 %86 + %86 = OpLabel + OpBranch %51 + %85 = OpLabel OpStore %continue_execution %false None OpStore %return_value %false None OpBranch %51 %49 = OpLabel - %84 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_0 - %85 = OpLoad %uint %84 None -%tint_low_inc_1 = OpISub %uint %85 %uint_1 %87 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_0 - OpStore %87 %tint_low_inc_1 None - %88 = OpIEqual %bool %tint_low_inc_1 %uint_4294967295 -%tint_carry_1 = OpSelect %uint %88 %uint_1 %uint_0 - %90 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 - %91 = OpLoad %uint %90 None - %92 = OpISub %uint %91 %tint_carry_1 + %88 = OpLoad %uint %87 None +%tint_low_inc_1 = OpISub %uint %88 %uint_1 + %90 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_0 + OpStore %90 %tint_low_inc_1 None + %91 = OpIEqual %bool %tint_low_inc_1 %uint_4294967295 +%tint_carry_1 = OpSelect %uint %91 %uint_1 %uint_0 %93 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 - OpStore %93 %92 None - %94 = OpLoad %int %j None - %95 = OpIAdd %int %94 %int_1 - OpStore %j %95 None + %94 = OpLoad %uint %93 None + %95 = OpISub %uint %94 %tint_carry_1 + %96 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 + OpStore %96 %95 None + %97 = OpLoad %int %j None + %98 = OpBitcast %uint %97 + %99 = OpBitcast %uint %int_1 + %100 = OpIAdd %uint %98 %99 + %101 = OpBitcast %int %100 + OpStore %j %101 None OpBranch %50 %51 = OpLabel %52 = OpLoad %bool %continue_execution None @@ -155,8 +158,11 @@ %67 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 OpStore %67 %66 None %68 = OpLoad %int %i None - %69 = OpIAdd %int %68 %int_1 - OpStore %i %69 None + %69 = OpBitcast %uint %68 + %70 = OpBitcast %uint %int_1 + %72 = OpIAdd %uint %69 %70 + %73 = OpBitcast %int %72 + OpStore %i %73 None OpBranch %17 %18 = OpLabel %19 = OpLoad %bool %continue_execution None @@ -169,8 +175,8 @@ %22 = OpLoad %bool %return_value None OpReturnValue %22 OpFunctionEnd - %main = OpFunction %void None %98 - %99 = OpLabel - %100 = OpFunctionCall %bool %func_3 + %main = OpFunction %void None %104 + %105 = OpLabel + %106 = OpFunctionCall %bool %func_3 OpReturn OpFunctionEnd
diff --git a/test/tint/bug/tint/1664.wgsl.expected.glsl b/test/tint/bug/tint/1664.wgsl.expected.glsl index 27de912..43b2bb1 100644 --- a/test/tint/bug/tint/1664.wgsl.expected.glsl +++ b/test/tint/bug/tint/1664.wgsl.expected.glsl
@@ -4,5 +4,6 @@ void main() { int a = 2147483647; int b = 1; - int c = (a + 1); + uint v = uint(a); + int c = int((v + uint(1))); }
diff --git a/test/tint/bug/tint/1664.wgsl.expected.spvasm b/test/tint/bug/tint/1664.wgsl.expected.spvasm index 9adf942..985bf9f 100644 --- a/test/tint/bug/tint/1664.wgsl.expected.spvasm +++ b/test/tint/bug/tint/1664.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 9 +; Bound: 13 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -16,8 +16,12 @@ %int = OpTypeInt 32 1 %a = OpConstant %int 2147483647 %b = OpConstant %int 1 + %uint = OpTypeInt 32 0 %f0 = OpFunction %void None %3 %4 = OpLabel - %c = OpIAdd %int %a %b + %9 = OpBitcast %uint %a + %10 = OpBitcast %uint %b + %11 = OpIAdd %uint %9 %10 + %c = OpBitcast %int %11 OpReturn OpFunctionEnd
diff --git a/test/tint/bug/tint/1677.wgsl.expected.glsl b/test/tint/bug/tint/1677.wgsl.expected.glsl index 3574e4b..2a0e15c 100644 --- a/test/tint/bug/tint/1677.wgsl.expected.glsl +++ b/test/tint/bug/tint/1677.wgsl.expected.glsl
@@ -11,7 +11,8 @@ Input inner; } v; void main_inner(uvec3 id) { - ivec3 pos = (v.inner.position - ivec3(0)); + uvec3 v_1 = uvec3(v.inner.position); + ivec3 pos = ivec3((v_1 - uvec3(ivec3(0)))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/bug/tint/1677.wgsl.expected.spvasm b/test/tint/bug/tint/1677.wgsl.expected.spvasm index da708ae..c5d6286 100644 --- a/test/tint/bug/tint/1677.wgsl.expected.spvasm +++ b/test/tint/bug/tint/1677.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 27 +; Bound: 30 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -37,19 +37,22 @@ %14 = OpTypeFunction %void %v3uint %_ptr_StorageBuffer_v3int = OpTypePointer StorageBuffer %v3int %uint_0 = OpConstant %uint 0 - %21 = OpConstantNull %v3int - %23 = OpTypeFunction %void + %22 = OpConstantNull %v3int + %26 = OpTypeFunction %void %main_inner = OpFunction %void None %14 %id = OpFunctionParameter %v3uint %15 = OpLabel %16 = OpAccessChain %_ptr_StorageBuffer_v3int %1 %uint_0 %uint_0 %19 = OpLoad %v3int %16 None - %pos = OpISub %v3int %19 %21 + %20 = OpBitcast %v3uint %19 + %21 = OpBitcast %v3uint %22 + %23 = OpISub %v3uint %20 %21 + %pos = OpBitcast %v3int %23 OpReturn OpFunctionEnd - %main = OpFunction %void None %23 - %24 = OpLabel - %25 = OpLoad %v3uint %main_global_invocation_id_Input None - %26 = OpFunctionCall %void %main_inner %25 + %main = OpFunction %void None %26 + %27 = OpLabel + %28 = OpLoad %v3uint %main_global_invocation_id_Input None + %29 = OpFunctionCall %void %main_inner %28 OpReturn OpFunctionEnd
diff --git a/test/tint/bug/tint/2063.wgsl.expected.glsl b/test/tint/bug/tint/2063.wgsl.expected.glsl index 136f145..f4ec920 100644 --- a/test/tint/bug/tint/2063.wgsl.expected.glsl +++ b/test/tint/bug/tint/2063.wgsl.expected.glsl
@@ -6,7 +6,7 @@ atomicExchange(arg_0, 0); } barrier(); - int res = atomicAdd(arg_0, -(-1)); + int res = atomicAdd(arg_0, int((~(uint(-1)) + 1u))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/bug/tint/354627692.wgsl.expected.glsl b/test/tint/bug/tint/354627692.wgsl.expected.glsl index 63e8b22..b971705 100644 --- a/test/tint/bug/tint/354627692.wgsl.expected.glsl +++ b/test/tint/bug/tint/354627692.wgsl.expected.glsl
@@ -25,10 +25,12 @@ break; } if ((i > 5)) { - i = (i * 2); + uint v_1 = uint(i); + i = int((v_1 * uint(2))); break; } else { - i = (i * 2); + uint v_2 = uint(i); + i = int((v_2 * uint(2))); break; } /* unreachable */
diff --git a/test/tint/bug/tint/354627692.wgsl.expected.spvasm b/test/tint/bug/tint/354627692.wgsl.expected.spvasm index 25006b3..26d19af 100644 --- a/test/tint/bug/tint/354627692.wgsl.expected.spvasm +++ b/test/tint/bug/tint/354627692.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 83 +; Bound: 89 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -104,13 +104,19 @@ OpBranchConditional %63 %66 %67 %66 = OpLabel %78 = OpLoad %int %i None - %79 = OpIMul %int %78 %int_2 - OpStore %i %79 None + %79 = OpBitcast %uint %78 + %80 = OpBitcast %uint %int_2 + %82 = OpIMul %uint %79 %80 + %83 = OpBitcast %int %82 + OpStore %i %83 None OpBranch %52 %67 = OpLabel - %81 = OpLoad %int %i None - %82 = OpIMul %int %81 %int_2 - OpStore %i %82 None + %84 = OpLoad %int %i None + %85 = OpBitcast %uint %84 + %86 = OpBitcast %uint %int_2 + %87 = OpIMul %uint %85 %86 + %88 = OpBitcast %int %87 + OpStore %i %88 None OpBranch %52 %65 = OpLabel OpBranch %52
diff --git a/test/tint/bug/tint/379127084.wgsl.expected.glsl b/test/tint/bug/tint/379127084.wgsl.expected.glsl index 6c0554e..ff2011d 100644 --- a/test/tint/bug/tint/379127084.wgsl.expected.glsl +++ b/test/tint/bug/tint/379127084.wgsl.expected.glsl
@@ -125,7 +125,8 @@ tint_loop_idx_1.x = tint_low_inc_1; uint tint_carry_1 = uint((tint_low_inc_1 == 4294967295u)); tint_loop_idx_1.y = (tint_loop_idx_1.y - tint_carry_1); - _72_h = (_72_h + 1); + uint v_15 = uint(_72_h); + _72_h = int((v_15 + uint(1))); if ((_72_h >= 4)) { break; } } continue; @@ -148,7 +149,8 @@ tint_loop_idx.x = tint_low_inc; uint tint_carry = uint((tint_low_inc == 4294967295u)); tint_loop_idx.y = (tint_loop_idx.y - tint_carry); - _61_o = (_61_o + 1); + uint v_16 = uint(_61_o); + _61_o = int((v_16 + uint(1))); } continue; } @@ -158,14 +160,14 @@ } vec4 _skTemp15 = clamp(_58_l, vec4(0.0f), vec4(1.0f)); _58_l = _skTemp15; - vec3 v_15 = vec3(_58_l.xyz); - vec3 v_16 = vec3((v_15 * float(_58_l.w))); - float _skTemp16 = dot(vec3(0.21259999275207519531f, 0.71520000696182250977f, 0.07220000028610229492f), vec4(v_16, float(float(_58_l.w))).xyz); + vec3 v_17 = vec3(_58_l.xyz); + vec3 v_18 = vec3((v_17 * float(_58_l.w))); + float _skTemp16 = dot(vec3(0.21259999275207519531f, 0.71520000696182250977f, 0.07220000028610229492f), vec4(v_18, float(float(_58_l.w))).xyz); float _skTemp17 = clamp(_skTemp16, 0.0f, 1.0f); vec4 _84_a = vec4(0.0f, 0.0f, 0.0f, _skTemp17); - uint v_17 = shadingSsboIndex; - uint v_18 = min(v_17, (uint(_storage1.fsUniformData.length()) - 1u)); - int _85_d = _storage1.fsUniformData[v_18].inHSL_4; + uint v_19 = shadingSsboIndex; + uint v_20 = min(v_19, (uint(_storage1.fsUniformData.length()) - 1u)); + int _85_d = _storage1.fsUniformData[v_20].inHSL_4; if (bool(_85_d)) { vec4 _skTemp18 = vec4(0.0f); if ((_84_a.y < _84_a.z)) { @@ -195,13 +197,13 @@ float _skTemp23 = max(_84_a.w, 0.00009999999747378752f); _84_a = vec4((_84_a.xyz / _skTemp23), _84_a.w); } - uint v_19 = shadingSsboIndex; - uint v_20 = min(v_19, (uint(_storage1.fsUniformData.length()) - 1u)); - mat4 v_21 = _storage1.fsUniformData[v_20].matrix_4; - vec4 v_22 = (v_21 * vec4(_84_a)); - uint v_23 = shadingSsboIndex; - uint v_24 = min(v_23, (uint(_storage1.fsUniformData.length()) - 1u)); - vec4 _94_f = vec4((v_22 + _storage1.fsUniformData[v_24].translate_4)); + uint v_21 = shadingSsboIndex; + uint v_22 = min(v_21, (uint(_storage1.fsUniformData.length()) - 1u)); + mat4 v_23 = _storage1.fsUniformData[v_22].matrix_4; + vec4 v_24 = (v_23 * vec4(_84_a)); + uint v_25 = shadingSsboIndex; + uint v_26 = min(v_25, (uint(_storage1.fsUniformData.length()) - 1u)); + vec4 _94_f = vec4((v_24 + _storage1.fsUniformData[v_26].translate_4)); if (bool(_85_d)) { float _skTemp24 = abs(((2.0f * _94_f.z) - 1.0f)); float _95_b = ((1.0f - _skTemp24) * _94_f.y); @@ -213,9 +215,9 @@ vec4 _skTemp28 = clamp(vec4(((((_97_d - 0.5f) * _95_b) + _94_f.z) * _94_f.w), _94_f.w), vec4(0.0f), vec4(1.0f)); _94_f = _skTemp28; } else { - uint v_25 = shadingSsboIndex; - uint v_26 = min(v_25, (uint(_storage1.fsUniformData.length()) - 1u)); - if (bool(_storage1.fsUniformData[v_26].clampRGB_4)) { + uint v_27 = shadingSsboIndex; + uint v_28 = min(v_27, (uint(_storage1.fsUniformData.length()) - 1u)); + if (bool(_storage1.fsUniformData[v_28].clampRGB_4)) { vec4 _skTemp29 = clamp(_94_f, vec4(0.0f), vec4(1.0f)); _94_f = _skTemp29; } else {
diff --git a/test/tint/bug/tint/379127084.wgsl.expected.spvasm b/test/tint/bug/tint/379127084.wgsl.expected.spvasm index 42c66be..d33f65d 100644 --- a/test/tint/bug/tint/379127084.wgsl.expected.spvasm +++ b/test/tint/bug/tint/379127084.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 608 +; Bound: 614 ; Schema: 0 OpCapability Shader %48 = OpExtInstImport "GLSL.std.450" @@ -213,42 +213,42 @@ %v2bool = OpTypeVector %bool 2 %_ptr_Function_uint = OpTypePointer Function %uint %int_1 = OpConstant %int 1 - %197 = OpConstantComposite %v4float %float_0_5 %float_0_5 %float_0_5 %float_0_5 + %200 = OpConstantComposite %v4float %float_0_5 %float_0_5 %float_0_5 %float_0_5 %float_6 = OpConstant %float 6 %float_9_99999975en05 = OpConstant %float 9.99999975e-05 %float_2 = OpConstant %float 2 %float_0_666666687 = OpConstant %float 0.666666687 %float_0_333333343 = OpConstant %float 0.333333343 - %276 = OpConstantComposite %v3float %float_0 %float_0_666666687 %float_0_333333343 + %279 = OpConstantComposite %v3float %float_0 %float_0_666666687 %float_0_333333343 %float_3 = OpConstant %float 3 - %288 = OpConstantNull %v3float - %289 = OpConstantComposite %v3float %float_1 %float_1 %float_1 + %291 = OpConstantNull %v3float + %292 = OpConstantComposite %v3float %float_1 %float_1 %float_1 %uint_8 = OpConstant %uint 8 - %335 = OpConstantComposite %v2float %float_1 %float_1 + %338 = OpConstantComposite %v2float %float_1 %float_1 %uint_4 = OpConstant %uint 4 %float_0_00390625 = OpConstant %float 0.00390625 %float_n0_474999994 = OpConstant %float -0.474999994 %float_n16 = OpConstant %float -16 %float_15_9899998 = OpConstant %float 15.9899998 - %361 = OpTypeSampledImage %20 + %364 = OpTypeSampledImage %20 %false = OpConstantFalse %bool %float_256 = OpConstant %float 256 - %390 = OpConstantComposite %v4float %float_0_00390625 %float_0_00390625 %float_0_00390625 %float_0_00390625 - %395 = OpConstantNull %v2float - %400 = OpConstantComposite %v2float %float_2 %float_2 - %402 = OpConstantComposite %v2float %float_3 %float_3 + %393 = OpConstantComposite %v4float %float_0_00390625 %float_0_00390625 %float_0_00390625 %float_0_00390625 + %398 = OpConstantNull %v2float + %403 = OpConstantComposite %v2float %float_2 %float_2 + %405 = OpConstantComposite %v2float %float_3 %float_3 %float_n1 = OpConstant %float -1 %float_n0_333333343 = OpConstant %float -0.333333343 %float_255 = OpConstant %float 255 - %463 = OpConstantComposite %v2float %float_255 %float_255 - %466 = OpConstantComposite %v2float %float_0_5 %float_0_5 + %466 = OpConstantComposite %v2float %float_255 %float_255 + %469 = OpConstantComposite %v2float %float_0_5 %float_0_5 %float_0_00392156886 = OpConstant %float 0.00392156886 - %469 = OpConstantComposite %v2float %float_0_00392156886 %float_0_00392156886 + %472 = OpConstantComposite %v2float %float_0_00392156886 %float_0_00392156886 %float_0_25 = OpConstant %float 0.25 %int_4 = OpConstant %int 4 - %594 = OpTypeFunction %FSOut %FSIn - %597 = OpConstantNull %FSOut - %601 = OpTypeFunction %void + %600 = OpTypeFunction %FSOut %FSIn + %603 = OpConstantNull %FSOut + %607 = OpTypeFunction %void %_skslMain = OpFunction %void None %37 %_stageIn = OpFunctionParameter %FSIn %_stageOut_root = OpFunctionParameter %_ptr_Function_FSOut @@ -333,265 +333,268 @@ OpSelectionMerge %178 None OpBranchConditional %177 %179 %180 %179 = OpLabel - %325 = OpLoad %v2float %_57_k None - %_skTemp2 = OpExtInst %v2float %48 Floor %325 - %327 = OpLoad %v4float %_62_f None - %328 = OpVectorShuffle %v2float %327 %327 2 3 - %329 = OpCompositeConstruct %v4float %_skTemp2 %328 - OpStore %_62_f %329 None + %328 = OpLoad %v2float %_57_k None + %_skTemp2 = OpExtInst %v2float %48 Floor %328 %330 = OpLoad %v4float %_62_f None - %331 = OpVectorShuffle %v2float %330 %330 0 1 - %332 = OpLoad %v4float %_62_f None - %333 = OpVectorShuffle %v2float %332 %332 0 1 - %334 = OpFAdd %v2float %333 %335 - %336 = OpCompositeConstruct %v4float %331 %334 - OpStore %_62_f %336 None - %337 = OpLoad %uint %shadingSsboIndex None - %338 = OpAccessChain %_ptr_StorageBuffer__runtimearr_FSUniformData %_storage1 %uint_0 - %339 = OpArrayLength %uint %_storage1 0 - %340 = OpISub %uint %339 %uint_1 - %341 = OpExtInst %uint %48 UMin %337 %340 - %342 = OpAccessChain %_ptr_StorageBuffer_int %_storage1 %uint_0 %341 %uint_4 - %344 = OpLoad %int %342 None - %345 = OpINotEqual %bool %344 %126 - OpSelectionMerge %346 None - OpBranchConditional %345 %347 %346 - %347 = OpLabel - %452 = OpLoad %v2float %_59_m None - %453 = OpVectorShuffle %v4float %452 %452 0 1 0 1 - %454 = OpLoad %v4float %_62_f None - %_skTemp3 = OpExtInst %v4float %48 Step %453 %454 - %456 = OpLoad %v4float %_62_f None - %457 = OpLoad %v2float %_59_m None - %458 = OpVectorShuffle %v4float %457 %457 0 1 0 1 - %459 = OpFMul %v4float %_skTemp3 %458 - %460 = OpFSub %v4float %456 %459 - OpStore %_62_f %460 None - OpBranch %346 - %346 = OpLabel - %348 = OpLoad %20 %permutationsSampler_1_Texture None - %349 = OpLoad %17 %permutationsSampler_1_Sampler None - %350 = OpAccessChain %_ptr_Function_float %_62_f %uint_0 - %351 = OpLoad %float %350 None - %352 = OpFAdd %float %351 %float_0_5 - %353 = OpFMul %float %352 %float_0_00390625 - %355 = OpCompositeConstruct %v2float %353 %float_0_5 - %356 = OpExtInst %float %48 NClamp %float_n0_474999994 %float_n16 %float_15_9899998 - %360 = OpSampledImage %361 %348 %349 - %362 = OpImageSampleImplicitLod %v4float %360 %355 Bias %356 - %_63_g = OpCompositeExtract %float %362 0 - %364 = OpLoad %20 %permutationsSampler_1_Texture None - %365 = OpLoad %17 %permutationsSampler_1_Sampler None - %366 = OpAccessChain %_ptr_Function_float %_62_f %uint_2 - %367 = OpLoad %float %366 None - %368 = OpFAdd %float %367 %float_0_5 - %369 = OpFMul %float %368 %float_0_00390625 - %370 = OpCompositeConstruct %v2float %369 %float_0_5 - %371 = OpExtInst %float %48 NClamp %float_n0_474999994 %float_n16 %float_15_9899998 - %372 = OpSampledImage %361 %364 %365 - %373 = OpImageSampleImplicitLod %v4float %372 %370 Bias %371 - %_64_h = OpCompositeExtract %float %373 0 - %375 = OpCompositeConstruct %v2float %_63_g %_64_h - OpStore %_65_i %375 - OpSelectionMerge %377 None - OpBranchConditional %false %378 %377 - %378 = OpLabel - %461 = OpLoad %v2float %_65_i None - %462 = OpFMul %v2float %461 %463 - %465 = OpFAdd %v2float %462 %466 - %_skTemp4 = OpExtInst %v2float %48 Floor %465 - %468 = OpFMul %v2float %_skTemp4 %469 - OpStore %_65_i %468 None - OpBranch %377 - %377 = OpLabel - %380 = OpLoad %v2float %_65_i None - %381 = OpVectorShuffle %v4float %380 %380 0 1 0 1 - %382 = OpVectorTimesScalar %v4float %381 %float_256 - %384 = OpLoad %v4float %_62_f None - %385 = OpVectorShuffle %v4float %384 %384 1 1 3 3 - %386 = OpFAdd %v4float %382 %385 - OpStore %_66_j %386 - %388 = OpLoad %v4float %_66_j None - %389 = OpFMul %v4float %388 %390 - OpStore %_66_j %389 None + %331 = OpVectorShuffle %v2float %330 %330 2 3 + %332 = OpCompositeConstruct %v4float %_skTemp2 %331 + OpStore %_62_f %332 None + %333 = OpLoad %v4float %_62_f None + %334 = OpVectorShuffle %v2float %333 %333 0 1 + %335 = OpLoad %v4float %_62_f None + %336 = OpVectorShuffle %v2float %335 %335 0 1 + %337 = OpFAdd %v2float %336 %338 + %339 = OpCompositeConstruct %v4float %334 %337 + OpStore %_62_f %339 None + %340 = OpLoad %uint %shadingSsboIndex None + %341 = OpAccessChain %_ptr_StorageBuffer__runtimearr_FSUniformData %_storage1 %uint_0 + %342 = OpArrayLength %uint %_storage1 0 + %343 = OpISub %uint %342 %uint_1 + %344 = OpExtInst %uint %48 UMin %340 %343 + %345 = OpAccessChain %_ptr_StorageBuffer_int %_storage1 %uint_0 %344 %uint_4 + %347 = OpLoad %int %345 None + %348 = OpINotEqual %bool %347 %126 + OpSelectionMerge %349 None + OpBranchConditional %348 %350 %349 + %350 = OpLabel + %455 = OpLoad %v2float %_59_m None + %456 = OpVectorShuffle %v4float %455 %455 0 1 0 1 + %457 = OpLoad %v4float %_62_f None + %_skTemp3 = OpExtInst %v4float %48 Step %456 %457 + %459 = OpLoad %v4float %_62_f None + %460 = OpLoad %v2float %_59_m None + %461 = OpVectorShuffle %v4float %460 %460 0 1 0 1 + %462 = OpFMul %v4float %_skTemp3 %461 + %463 = OpFSub %v4float %459 %462 + OpStore %_62_f %463 None + OpBranch %349 + %349 = OpLabel + %351 = OpLoad %20 %permutationsSampler_1_Texture None + %352 = OpLoad %17 %permutationsSampler_1_Sampler None + %353 = OpAccessChain %_ptr_Function_float %_62_f %uint_0 + %354 = OpLoad %float %353 None + %355 = OpFAdd %float %354 %float_0_5 + %356 = OpFMul %float %355 %float_0_00390625 + %358 = OpCompositeConstruct %v2float %356 %float_0_5 + %359 = OpExtInst %float %48 NClamp %float_n0_474999994 %float_n16 %float_15_9899998 + %363 = OpSampledImage %364 %351 %352 + %365 = OpImageSampleImplicitLod %v4float %363 %358 Bias %359 + %_63_g = OpCompositeExtract %float %365 0 + %367 = OpLoad %20 %permutationsSampler_1_Texture None + %368 = OpLoad %17 %permutationsSampler_1_Sampler None + %369 = OpAccessChain %_ptr_Function_float %_62_f %uint_2 + %370 = OpLoad %float %369 None + %371 = OpFAdd %float %370 %float_0_5 + %372 = OpFMul %float %371 %float_0_00390625 + %373 = OpCompositeConstruct %v2float %372 %float_0_5 + %374 = OpExtInst %float %48 NClamp %float_n0_474999994 %float_n16 %float_15_9899998 + %375 = OpSampledImage %364 %367 %368 + %376 = OpImageSampleImplicitLod %v4float %375 %373 Bias %374 + %_64_h = OpCompositeExtract %float %376 0 + %378 = OpCompositeConstruct %v2float %_63_g %_64_h + OpStore %_65_i %378 + OpSelectionMerge %380 None + OpBranchConditional %false %381 %380 + %381 = OpLabel + %464 = OpLoad %v2float %_65_i None + %465 = OpFMul %v2float %464 %466 + %468 = OpFAdd %v2float %465 %469 + %_skTemp4 = OpExtInst %v2float %48 Floor %468 + %471 = OpFMul %v2float %_skTemp4 %472 + OpStore %_65_i %471 None + OpBranch %380 + %380 = OpLabel + %383 = OpLoad %v2float %_65_i None + %384 = OpVectorShuffle %v4float %383 %383 0 1 0 1 + %385 = OpVectorTimesScalar %v4float %384 %float_256 + %387 = OpLoad %v4float %_62_f None + %388 = OpVectorShuffle %v4float %387 %387 1 1 3 3 + %389 = OpFAdd %v4float %385 %388 + OpStore %_66_j %389 + %391 = OpLoad %v4float %_66_j None + %392 = OpFMul %v4float %391 %393 + OpStore %_66_j %392 None %_67_p = OpLoad %v4float %_66_j None - %392 = OpLoad %v2float %_57_k None - %_skTemp5 = OpExtInst %v2float %48 Fract %392 - %394 = OpFSub %v2float %_skTemp5 %395 - %396 = OpFSub %v2float %335 %395 - %397 = OpFDiv %v2float %394 %396 - %398 = OpExtInst %v2float %48 NClamp %397 %395 %335 - %399 = OpFMul %v2float %400 %398 - %401 = OpFSub %v2float %402 %399 - %403 = OpFMul %v2float %398 %401 - %_skTemp6 = OpFMul %v2float %398 %403 + %395 = OpLoad %v2float %_57_k None + %_skTemp5 = OpExtInst %v2float %48 Fract %395 + %397 = OpFSub %v2float %_skTemp5 %398 + %399 = OpFSub %v2float %338 %398 + %400 = OpFDiv %v2float %397 %399 + %401 = OpExtInst %v2float %48 NClamp %400 %398 %338 + %402 = OpFMul %v2float %403 %401 + %404 = OpFSub %v2float %405 %402 + %406 = OpFMul %v2float %401 %404 + %_skTemp6 = OpFMul %v2float %401 %406 OpStore %_72_h %int_0 - OpBranch %407 - %407 = OpLabel - OpStore %tint_loop_idx_0 %160 OpBranch %410 %410 = OpLabel - OpLoopMerge %411 %409 None - OpBranch %408 - %408 = OpLabel - %472 = OpLoad %v2uint %tint_loop_idx_0 None - %473 = OpIEqual %v2bool %472 %164 - %474 = OpAll %bool %473 - OpSelectionMerge %475 None - OpBranchConditional %474 %476 %475 - %476 = OpLabel + OpStore %tint_loop_idx_0 %160 + OpBranch %413 + %413 = OpLabel + OpLoopMerge %414 %412 None OpBranch %411 - %475 = OpLabel - %477 = OpLoad %int %_72_h None - %478 = OpConvertSToF %float %477 - %479 = OpFAdd %float %478 %float_0_5 - %_73_i = OpFMul %float %479 %float_0_25 - %482 = OpLoad %20 %noiseSampler_1_Texture None - %483 = OpLoad %17 %noiseSampler_1_Sampler None - %484 = OpCompositeExtract %float %_67_p 0 - %485 = OpCompositeConstruct %v2float %484 %_73_i - %486 = OpExtInst %float %48 NClamp %float_n0_474999994 %float_n16 %float_15_9899998 - %487 = OpSampledImage %361 %482 %483 - %_74_j = OpImageSampleImplicitLod %v4float %487 %485 Bias %486 - %489 = OpLoad %20 %noiseSampler_1_Texture None - %490 = OpLoad %17 %noiseSampler_1_Sampler None - %491 = OpCompositeExtract %float %_67_p 1 - %492 = OpCompositeConstruct %v2float %491 %_73_i - %493 = OpExtInst %float %48 NClamp %float_n0_474999994 %float_n16 %float_15_9899998 - %494 = OpSampledImage %361 %489 %490 - %_75_k = OpImageSampleImplicitLod %v4float %494 %492 Bias %493 - %496 = OpLoad %20 %noiseSampler_1_Texture None - %497 = OpLoad %17 %noiseSampler_1_Sampler None - %498 = OpCompositeExtract %float %_67_p 3 - %499 = OpCompositeConstruct %v2float %498 %_73_i - %500 = OpExtInst %float %48 NClamp %float_n0_474999994 %float_n16 %float_15_9899998 - %501 = OpSampledImage %361 %496 %497 - %_76_l = OpImageSampleImplicitLod %v4float %501 %499 Bias %500 - %503 = OpLoad %20 %noiseSampler_1_Texture None - %504 = OpLoad %17 %noiseSampler_1_Sampler None - %505 = OpCompositeExtract %float %_67_p 2 - %506 = OpCompositeConstruct %v2float %505 %_73_i - %507 = OpExtInst %float %48 NClamp %float_n0_474999994 %float_n16 %float_15_9899998 - %508 = OpSampledImage %361 %503 %504 - %_77_m = OpImageSampleImplicitLod %v4float %508 %506 Bias %507 - OpStore %_78_n %_skTemp5 - %511 = OpVectorShuffle %v2float %_74_j %_74_j 1 3 - %512 = OpVectorShuffle %v2float %_74_j %_74_j 0 2 - %513 = OpVectorTimesScalar %v2float %512 %float_0_00390625 - %514 = OpFAdd %v2float %511 %513 - %515 = OpVectorTimesScalar %v2float %514 %float_2 - %516 = OpCompositeConstruct %v2float %float_1 %float_1 - %517 = OpFSub %v2float %515 %516 - %518 = OpLoad %v2float %_78_n None - %_skTemp7 = OpDot %float %517 %518 - OpStore %_79_o %_skTemp7 - %521 = OpAccessChain %_ptr_Function_float %_78_n %uint_0 - %522 = OpLoad %float %521 None - %523 = OpFSub %float %522 %float_1 - %524 = OpAccessChain %_ptr_Function_float %_78_n %uint_0 - OpStore %524 %523 None - %525 = OpVectorShuffle %v2float %_75_k %_75_k 1 3 - %526 = OpVectorShuffle %v2float %_75_k %_75_k 0 2 - %527 = OpVectorTimesScalar %v2float %526 %float_0_00390625 - %528 = OpFAdd %v2float %525 %527 - %529 = OpVectorTimesScalar %v2float %528 %float_2 - %530 = OpCompositeConstruct %v2float %float_1 %float_1 - %531 = OpFSub %v2float %529 %530 - %532 = OpLoad %v2float %_78_n None - %_skTemp8 = OpDot %float %531 %532 - OpStore %_80_p %_skTemp8 - %535 = OpLoad %float %_79_o None - %536 = OpLoad %float %_80_p None - %537 = OpCompositeExtract %float %_skTemp6 0 - %_skTemp9 = OpExtInst %float %48 FMix %535 %536 %537 - %539 = OpAccessChain %_ptr_Function_float %_78_n %uint_1 - %540 = OpLoad %float %539 None - %541 = OpFSub %float %540 %float_1 - %542 = OpAccessChain %_ptr_Function_float %_78_n %uint_1 - OpStore %542 %541 None - %543 = OpVectorShuffle %v2float %_76_l %_76_l 1 3 - %544 = OpVectorShuffle %v2float %_76_l %_76_l 0 2 - %545 = OpVectorTimesScalar %v2float %544 %float_0_00390625 - %546 = OpFAdd %v2float %543 %545 - %547 = OpVectorTimesScalar %v2float %546 %float_2 - %548 = OpCompositeConstruct %v2float %float_1 %float_1 - %549 = OpFSub %v2float %547 %548 - %550 = OpLoad %v2float %_78_n None - %_skTemp10 = OpDot %float %549 %550 - OpStore %_80_p %_skTemp10 None - %552 = OpAccessChain %_ptr_Function_float %_78_n %uint_0 - %553 = OpLoad %float %552 None - %554 = OpFAdd %float %553 %float_1 - %555 = OpAccessChain %_ptr_Function_float %_78_n %uint_0 - OpStore %555 %554 None - %556 = OpVectorShuffle %v2float %_77_m %_77_m 1 3 - %557 = OpVectorShuffle %v2float %_77_m %_77_m 0 2 - %558 = OpVectorTimesScalar %v2float %557 %float_0_00390625 - %559 = OpFAdd %v2float %556 %558 - %560 = OpVectorTimesScalar %v2float %559 %float_2 - %561 = OpCompositeConstruct %v2float %float_1 %float_1 - %562 = OpFSub %v2float %560 %561 - %563 = OpLoad %v2float %_78_n None - %_skTemp11 = OpDot %float %562 %563 - OpStore %_79_o %_skTemp11 None - %565 = OpLoad %float %_79_o None - %566 = OpLoad %float %_80_p None - %567 = OpCompositeExtract %float %_skTemp6 0 - %_skTemp12 = OpExtInst %float %48 FMix %565 %566 %567 - %569 = OpCompositeExtract %float %_skTemp6 1 - %_skTemp13 = OpExtInst %float %48 FMix %_skTemp9 %_skTemp12 %569 - %571 = OpLoad %int %_72_h None - %572 = OpBitcast %uint %571 - %573 = OpExtInst %uint %48 UMin %572 %uint_3 - %574 = OpAccessChain %_ptr_Function_float %_71_g %573 - OpStore %574 %_skTemp13 None - OpBranch %409 - %409 = OpLabel - %575 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_0 - %576 = OpLoad %uint %575 None - %577 = OpISub %uint %576 %uint_1 - %578 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_0 - OpStore %578 %577 None - %579 = OpIEqual %bool %577 %uint_4294967295 - %580 = OpSelect %uint %579 %uint_1 %uint_0 - %581 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 - %582 = OpLoad %uint %581 None - %583 = OpISub %uint %582 %580 - %584 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 - OpStore %584 %583 None - %585 = OpLoad %int %_72_h None - %586 = OpIAdd %int %585 %int_1 - OpStore %_72_h %586 None - %587 = OpLoad %int %_72_h None - %588 = OpSGreaterThanEqual %bool %587 %int_4 - OpBranchConditional %588 %411 %410 %411 = OpLabel - %412 = OpLoad %v4float %_71_g None - OpStore %_83_q %412 - %414 = OpINotEqual %bool %_56_d %int_0 - OpSelectionMerge %415 None - OpBranchConditional %414 %416 %415 - %416 = OpLabel - %590 = OpLoad %v4float %_83_q None - %_skTemp14 = OpExtInst %v4float %48 FAbs %590 + %475 = OpLoad %v2uint %tint_loop_idx_0 None + %476 = OpIEqual %v2bool %475 %164 + %477 = OpAll %bool %476 + OpSelectionMerge %478 None + OpBranchConditional %477 %479 %478 + %479 = OpLabel + OpBranch %414 + %478 = OpLabel + %480 = OpLoad %int %_72_h None + %481 = OpConvertSToF %float %480 + %482 = OpFAdd %float %481 %float_0_5 + %_73_i = OpFMul %float %482 %float_0_25 + %485 = OpLoad %20 %noiseSampler_1_Texture None + %486 = OpLoad %17 %noiseSampler_1_Sampler None + %487 = OpCompositeExtract %float %_67_p 0 + %488 = OpCompositeConstruct %v2float %487 %_73_i + %489 = OpExtInst %float %48 NClamp %float_n0_474999994 %float_n16 %float_15_9899998 + %490 = OpSampledImage %364 %485 %486 + %_74_j = OpImageSampleImplicitLod %v4float %490 %488 Bias %489 + %492 = OpLoad %20 %noiseSampler_1_Texture None + %493 = OpLoad %17 %noiseSampler_1_Sampler None + %494 = OpCompositeExtract %float %_67_p 1 + %495 = OpCompositeConstruct %v2float %494 %_73_i + %496 = OpExtInst %float %48 NClamp %float_n0_474999994 %float_n16 %float_15_9899998 + %497 = OpSampledImage %364 %492 %493 + %_75_k = OpImageSampleImplicitLod %v4float %497 %495 Bias %496 + %499 = OpLoad %20 %noiseSampler_1_Texture None + %500 = OpLoad %17 %noiseSampler_1_Sampler None + %501 = OpCompositeExtract %float %_67_p 3 + %502 = OpCompositeConstruct %v2float %501 %_73_i + %503 = OpExtInst %float %48 NClamp %float_n0_474999994 %float_n16 %float_15_9899998 + %504 = OpSampledImage %364 %499 %500 + %_76_l = OpImageSampleImplicitLod %v4float %504 %502 Bias %503 + %506 = OpLoad %20 %noiseSampler_1_Texture None + %507 = OpLoad %17 %noiseSampler_1_Sampler None + %508 = OpCompositeExtract %float %_67_p 2 + %509 = OpCompositeConstruct %v2float %508 %_73_i + %510 = OpExtInst %float %48 NClamp %float_n0_474999994 %float_n16 %float_15_9899998 + %511 = OpSampledImage %364 %506 %507 + %_77_m = OpImageSampleImplicitLod %v4float %511 %509 Bias %510 + OpStore %_78_n %_skTemp5 + %514 = OpVectorShuffle %v2float %_74_j %_74_j 1 3 + %515 = OpVectorShuffle %v2float %_74_j %_74_j 0 2 + %516 = OpVectorTimesScalar %v2float %515 %float_0_00390625 + %517 = OpFAdd %v2float %514 %516 + %518 = OpVectorTimesScalar %v2float %517 %float_2 + %519 = OpCompositeConstruct %v2float %float_1 %float_1 + %520 = OpFSub %v2float %518 %519 + %521 = OpLoad %v2float %_78_n None + %_skTemp7 = OpDot %float %520 %521 + OpStore %_79_o %_skTemp7 + %524 = OpAccessChain %_ptr_Function_float %_78_n %uint_0 + %525 = OpLoad %float %524 None + %526 = OpFSub %float %525 %float_1 + %527 = OpAccessChain %_ptr_Function_float %_78_n %uint_0 + OpStore %527 %526 None + %528 = OpVectorShuffle %v2float %_75_k %_75_k 1 3 + %529 = OpVectorShuffle %v2float %_75_k %_75_k 0 2 + %530 = OpVectorTimesScalar %v2float %529 %float_0_00390625 + %531 = OpFAdd %v2float %528 %530 + %532 = OpVectorTimesScalar %v2float %531 %float_2 + %533 = OpCompositeConstruct %v2float %float_1 %float_1 + %534 = OpFSub %v2float %532 %533 + %535 = OpLoad %v2float %_78_n None + %_skTemp8 = OpDot %float %534 %535 + OpStore %_80_p %_skTemp8 + %538 = OpLoad %float %_79_o None + %539 = OpLoad %float %_80_p None + %540 = OpCompositeExtract %float %_skTemp6 0 + %_skTemp9 = OpExtInst %float %48 FMix %538 %539 %540 + %542 = OpAccessChain %_ptr_Function_float %_78_n %uint_1 + %543 = OpLoad %float %542 None + %544 = OpFSub %float %543 %float_1 + %545 = OpAccessChain %_ptr_Function_float %_78_n %uint_1 + OpStore %545 %544 None + %546 = OpVectorShuffle %v2float %_76_l %_76_l 1 3 + %547 = OpVectorShuffle %v2float %_76_l %_76_l 0 2 + %548 = OpVectorTimesScalar %v2float %547 %float_0_00390625 + %549 = OpFAdd %v2float %546 %548 + %550 = OpVectorTimesScalar %v2float %549 %float_2 + %551 = OpCompositeConstruct %v2float %float_1 %float_1 + %552 = OpFSub %v2float %550 %551 + %553 = OpLoad %v2float %_78_n None + %_skTemp10 = OpDot %float %552 %553 + OpStore %_80_p %_skTemp10 None + %555 = OpAccessChain %_ptr_Function_float %_78_n %uint_0 + %556 = OpLoad %float %555 None + %557 = OpFAdd %float %556 %float_1 + %558 = OpAccessChain %_ptr_Function_float %_78_n %uint_0 + OpStore %558 %557 None + %559 = OpVectorShuffle %v2float %_77_m %_77_m 1 3 + %560 = OpVectorShuffle %v2float %_77_m %_77_m 0 2 + %561 = OpVectorTimesScalar %v2float %560 %float_0_00390625 + %562 = OpFAdd %v2float %559 %561 + %563 = OpVectorTimesScalar %v2float %562 %float_2 + %564 = OpCompositeConstruct %v2float %float_1 %float_1 + %565 = OpFSub %v2float %563 %564 + %566 = OpLoad %v2float %_78_n None + %_skTemp11 = OpDot %float %565 %566 + OpStore %_79_o %_skTemp11 None + %568 = OpLoad %float %_79_o None + %569 = OpLoad %float %_80_p None + %570 = OpCompositeExtract %float %_skTemp6 0 + %_skTemp12 = OpExtInst %float %48 FMix %568 %569 %570 + %572 = OpCompositeExtract %float %_skTemp6 1 + %_skTemp13 = OpExtInst %float %48 FMix %_skTemp9 %_skTemp12 %572 + %574 = OpLoad %int %_72_h None + %575 = OpBitcast %uint %574 + %576 = OpExtInst %uint %48 UMin %575 %uint_3 + %577 = OpAccessChain %_ptr_Function_float %_71_g %576 + OpStore %577 %_skTemp13 None + OpBranch %412 + %412 = OpLabel + %578 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_0 + %579 = OpLoad %uint %578 None + %580 = OpISub %uint %579 %uint_1 + %581 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_0 + OpStore %581 %580 None + %582 = OpIEqual %bool %580 %uint_4294967295 + %583 = OpSelect %uint %582 %uint_1 %uint_0 + %584 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 + %585 = OpLoad %uint %584 None + %586 = OpISub %uint %585 %583 + %587 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 + OpStore %587 %586 None + %588 = OpLoad %int %_72_h None + %589 = OpBitcast %uint %588 + %590 = OpBitcast %uint %int_1 + %591 = OpIAdd %uint %589 %590 + %592 = OpBitcast %int %591 + OpStore %_72_h %592 None + %593 = OpLoad %int %_72_h None + %594 = OpSGreaterThanEqual %bool %593 %int_4 + OpBranchConditional %594 %414 %413 + %414 = OpLabel + %415 = OpLoad %v4float %_71_g None + OpStore %_83_q %415 + %417 = OpINotEqual %bool %_56_d %int_0 + OpSelectionMerge %418 None + OpBranchConditional %417 %419 %418 + %419 = OpLabel + %596 = OpLoad %v4float %_83_q None + %_skTemp14 = OpExtInst %v4float %48 FAbs %596 OpStore %_83_q %_skTemp14 None - OpBranch %415 - %415 = OpLabel - %417 = OpLoad %v4float %_58_l None - %418 = OpLoad %v4float %_83_q None - %419 = OpLoad %float %_60_n None - %420 = OpVectorTimesScalar %v4float %418 %419 - %421 = OpFAdd %v4float %417 %420 - OpStore %_58_l %421 None - %422 = OpLoad %v2float %_57_k None - %423 = OpFMul %v2float %422 %400 - OpStore %_57_k %423 None - %424 = OpLoad %float %_60_n None - %425 = OpFMul %float %424 %float_0_5 - OpStore %_60_n %425 None - %426 = OpLoad %v2float %_59_m None - %427 = OpFMul %v2float %426 %400 - OpStore %_59_m %427 None + OpBranch %418 + %418 = OpLabel + %420 = OpLoad %v4float %_58_l None + %421 = OpLoad %v4float %_83_q None + %422 = OpLoad %float %_60_n None + %423 = OpVectorTimesScalar %v4float %421 %422 + %424 = OpFAdd %v4float %420 %423 + OpStore %_58_l %424 None + %425 = OpLoad %v2float %_57_k None + %426 = OpFMul %v2float %425 %403 + OpStore %_57_k %426 None + %427 = OpLoad %float %_60_n None + %428 = OpFMul %float %427 %float_0_5 + OpStore %_60_n %428 None + %429 = OpLoad %v2float %_59_m None + %430 = OpFMul %v2float %429 %403 + OpStore %_59_m %430 None OpBranch %178 %180 = OpLabel OpBranch %89 @@ -611,18 +614,21 @@ %191 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 OpStore %191 %190 None %192 = OpLoad %int %_61_o None - %193 = OpIAdd %int %192 %int_1 - OpStore %_61_o %193 None + %193 = OpBitcast %uint %192 + %194 = OpBitcast %uint %int_1 + %196 = OpIAdd %uint %193 %194 + %197 = OpBitcast %int %196 + OpStore %_61_o %197 None OpBranch %88 %89 = OpLabel %90 = OpIEqual %bool %_56_d %int_0 OpSelectionMerge %92 None OpBranchConditional %90 %93 %92 %93 = OpLabel - %195 = OpLoad %v4float %_58_l None - %196 = OpFMul %v4float %195 %197 - %198 = OpFAdd %v4float %196 %197 - OpStore %_58_l %198 None + %198 = OpLoad %v4float %_58_l None + %199 = OpFMul %v4float %198 %200 + %201 = OpFAdd %v4float %199 %200 + OpStore %_58_l %201 None OpBranch %92 %92 = OpLabel %94 = OpLoad %v4float %_58_l None @@ -652,98 +658,98 @@ OpSelectionMerge %127 None OpBranchConditional %125 %128 %129 %128 = OpLabel - %200 = OpAccessChain %_ptr_Function_float %_84_a %uint_1 - %201 = OpLoad %float %200 None - %202 = OpAccessChain %_ptr_Function_float %_84_a %uint_2 - %203 = OpLoad %float %202 None - %204 = OpFOrdLessThan %bool %201 %203 - OpSelectionMerge %205 None - OpBranchConditional %204 %206 %207 - %206 = OpLabel - %428 = OpLoad %v4float %_84_a None - %429 = OpVectorShuffle %v2float %428 %428 2 1 - %430 = OpCompositeConstruct %v4float %429 %float_n1 %float_0_666666687 - OpStore %_skTemp18 %430 None - OpBranch %205 - %207 = OpLabel - %432 = OpLoad %v4float %_84_a None - %433 = OpVectorShuffle %v2float %432 %432 1 2 - %434 = OpCompositeConstruct %v4float %433 %float_0 %float_n0_333333343 - OpStore %_skTemp18 %434 None - OpBranch %205 - %205 = OpLabel + %203 = OpAccessChain %_ptr_Function_float %_84_a %uint_1 + %204 = OpLoad %float %203 None + %205 = OpAccessChain %_ptr_Function_float %_84_a %uint_2 + %206 = OpLoad %float %205 None + %207 = OpFOrdLessThan %bool %204 %206 + OpSelectionMerge %208 None + OpBranchConditional %207 %209 %210 + %209 = OpLabel + %431 = OpLoad %v4float %_84_a None + %432 = OpVectorShuffle %v2float %431 %431 2 1 + %433 = OpCompositeConstruct %v4float %432 %float_n1 %float_0_666666687 + OpStore %_skTemp18 %433 None + OpBranch %208 + %210 = OpLabel + %435 = OpLoad %v4float %_84_a None + %436 = OpVectorShuffle %v2float %435 %435 1 2 + %437 = OpCompositeConstruct %v4float %436 %float_0 %float_n0_333333343 + OpStore %_skTemp18 %437 None + OpBranch %208 + %208 = OpLabel %_86_e = OpLoad %v4float %_skTemp18 None - %210 = OpAccessChain %_ptr_Function_float %_84_a %uint_0 - %211 = OpLoad %float %210 None - %212 = OpCompositeExtract %float %_86_e 0 - %213 = OpFOrdLessThan %bool %211 %212 - OpSelectionMerge %214 None - OpBranchConditional %213 %215 %216 - %215 = OpLabel - %436 = OpCompositeExtract %float %_86_e 0 - %437 = OpAccessChain %_ptr_Function_float %_84_a %uint_0 - %438 = OpLoad %float %437 None - %439 = OpVectorShuffle %v2float %_86_e %_86_e 1 3 - %440 = OpCompositeConstruct %v4float %436 %438 %439 - OpStore %_skTemp19 %440 None - OpBranch %214 - %216 = OpLabel - %441 = OpAccessChain %_ptr_Function_float %_84_a %uint_0 - %442 = OpLoad %float %441 None - %443 = OpCompositeExtract %float %_86_e 0 - %444 = OpVectorShuffle %v2float %_86_e %_86_e 1 2 - %445 = OpCompositeConstruct %v4float %442 %443 %444 - OpStore %_skTemp19 %445 None - OpBranch %214 - %214 = OpLabel + %213 = OpAccessChain %_ptr_Function_float %_84_a %uint_0 + %214 = OpLoad %float %213 None + %215 = OpCompositeExtract %float %_86_e 0 + %216 = OpFOrdLessThan %bool %214 %215 + OpSelectionMerge %217 None + OpBranchConditional %216 %218 %219 + %218 = OpLabel + %439 = OpCompositeExtract %float %_86_e 0 + %440 = OpAccessChain %_ptr_Function_float %_84_a %uint_0 + %441 = OpLoad %float %440 None + %442 = OpVectorShuffle %v2float %_86_e %_86_e 1 3 + %443 = OpCompositeConstruct %v4float %439 %441 %442 + OpStore %_skTemp19 %443 None + OpBranch %217 + %219 = OpLabel + %444 = OpAccessChain %_ptr_Function_float %_84_a %uint_0 + %445 = OpLoad %float %444 None + %446 = OpCompositeExtract %float %_86_e 0 + %447 = OpVectorShuffle %v2float %_86_e %_86_e 1 2 + %448 = OpCompositeConstruct %v4float %445 %446 %447 + OpStore %_skTemp19 %448 None + OpBranch %217 + %217 = OpLabel %_87_f = OpLoad %v4float %_skTemp19 None %_88_h = OpCompositeExtract %float %_87_f 0 - %219 = OpCompositeExtract %float %_87_f 1 - %220 = OpCompositeExtract %float %_87_f 2 - %_skTemp20 = OpExtInst %float %48 NMin %219 %220 + %222 = OpCompositeExtract %float %_87_f 1 + %223 = OpCompositeExtract %float %_87_f 2 + %_skTemp20 = OpExtInst %float %48 NMin %222 %223 %_89_i = OpFSub %float %_88_h %_skTemp20 - %223 = OpFMul %float %_89_i %float_0_5 - %_90_j = OpFSub %float %_88_h %223 - %225 = OpCompositeExtract %float %_87_f 3 - %226 = OpCompositeExtract %float %_87_f 1 - %227 = OpCompositeExtract %float %_87_f 2 - %228 = OpFSub %float %226 %227 - %229 = OpFMul %float %_89_i %float_6 - %231 = OpFAdd %float %229 %float_9_99999975en05 - %233 = OpFDiv %float %228 %231 - %234 = OpFAdd %float %225 %233 - %_skTemp21 = OpExtInst %float %48 FAbs %234 - %236 = OpFMul %float %_90_j %float_2 - %238 = OpAccessChain %_ptr_Function_float %_84_a %uint_3 - %239 = OpLoad %float %238 None - %240 = OpFSub %float %236 %239 - %_skTemp22 = OpExtInst %float %48 FAbs %240 - %242 = OpAccessChain %_ptr_Function_float %_84_a %uint_3 - %243 = OpLoad %float %242 None - %244 = OpFAdd %float %243 %float_9_99999975en05 - %245 = OpFSub %float %244 %_skTemp22 - %_92_l = OpFDiv %float %_89_i %245 - %247 = OpAccessChain %_ptr_Function_float %_84_a %uint_3 - %248 = OpLoad %float %247 None - %249 = OpFAdd %float %248 %float_9_99999975en05 - %_93_m = OpFDiv %float %_90_j %249 - %251 = OpAccessChain %_ptr_Function_float %_84_a %uint_3 - %252 = OpLoad %float %251 None - %253 = OpCompositeConstruct %v4float %_skTemp21 %_92_l %_93_m %252 - OpStore %_84_a %253 None - OpBranch %127 - %129 = OpLabel + %226 = OpFMul %float %_89_i %float_0_5 + %_90_j = OpFSub %float %_88_h %226 + %228 = OpCompositeExtract %float %_87_f 3 + %229 = OpCompositeExtract %float %_87_f 1 + %230 = OpCompositeExtract %float %_87_f 2 + %231 = OpFSub %float %229 %230 + %232 = OpFMul %float %_89_i %float_6 + %234 = OpFAdd %float %232 %float_9_99999975en05 + %236 = OpFDiv %float %231 %234 + %237 = OpFAdd %float %228 %236 + %_skTemp21 = OpExtInst %float %48 FAbs %237 + %239 = OpFMul %float %_90_j %float_2 + %241 = OpAccessChain %_ptr_Function_float %_84_a %uint_3 + %242 = OpLoad %float %241 None + %243 = OpFSub %float %239 %242 + %_skTemp22 = OpExtInst %float %48 FAbs %243 + %245 = OpAccessChain %_ptr_Function_float %_84_a %uint_3 + %246 = OpLoad %float %245 None + %247 = OpFAdd %float %246 %float_9_99999975en05 + %248 = OpFSub %float %247 %_skTemp22 + %_92_l = OpFDiv %float %_89_i %248 + %250 = OpAccessChain %_ptr_Function_float %_84_a %uint_3 + %251 = OpLoad %float %250 None + %252 = OpFAdd %float %251 %float_9_99999975en05 + %_93_m = OpFDiv %float %_90_j %252 %254 = OpAccessChain %_ptr_Function_float %_84_a %uint_3 %255 = OpLoad %float %254 None - %_skTemp23 = OpExtInst %float %48 NMax %255 %float_9_99999975en05 - %257 = OpLoad %v4float %_84_a None - %258 = OpVectorShuffle %v3float %257 %257 0 1 2 - %259 = OpCompositeConstruct %v3float %_skTemp23 %_skTemp23 %_skTemp23 - %260 = OpFDiv %v3float %258 %259 - %261 = OpAccessChain %_ptr_Function_float %_84_a %uint_3 - %262 = OpLoad %float %261 None - %263 = OpCompositeConstruct %v4float %260 %262 - OpStore %_84_a %263 None + %256 = OpCompositeConstruct %v4float %_skTemp21 %_92_l %_93_m %255 + OpStore %_84_a %256 None + OpBranch %127 + %129 = OpLabel + %257 = OpAccessChain %_ptr_Function_float %_84_a %uint_3 + %258 = OpLoad %float %257 None + %_skTemp23 = OpExtInst %float %48 NMax %258 %float_9_99999975en05 + %260 = OpLoad %v4float %_84_a None + %261 = OpVectorShuffle %v3float %260 %260 0 1 2 + %262 = OpCompositeConstruct %v3float %_skTemp23 %_skTemp23 %_skTemp23 + %263 = OpFDiv %v3float %261 %262 + %264 = OpAccessChain %_ptr_Function_float %_84_a %uint_3 + %265 = OpLoad %float %264 None + %266 = OpCompositeConstruct %v4float %263 %265 + OpStore %_84_a %266 None OpBranch %127 %127 = OpLabel %130 = OpLoad %uint %shadingSsboIndex None @@ -768,75 +774,75 @@ OpSelectionMerge %153 None OpBranchConditional %152 %154 %155 %154 = OpLabel - %264 = OpAccessChain %_ptr_Function_float %_94_f %uint_2 - %265 = OpLoad %float %264 None - %266 = OpFMul %float %float_2 %265 - %267 = OpFSub %float %266 %float_1 - %_skTemp24 = OpExtInst %float %48 FAbs %267 - %269 = OpFSub %float %float_1 %_skTemp24 - %270 = OpAccessChain %_ptr_Function_float %_94_f %uint_1 - %271 = OpLoad %float %270 None - %_95_b = OpFMul %float %269 %271 - %273 = OpLoad %v4float %_94_f None - %274 = OpVectorShuffle %v3float %273 %273 0 0 0 - %_96_c = OpFAdd %v3float %274 %276 + %267 = OpAccessChain %_ptr_Function_float %_94_f %uint_2 + %268 = OpLoad %float %267 None + %269 = OpFMul %float %float_2 %268 + %270 = OpFSub %float %269 %float_1 + %_skTemp24 = OpExtInst %float %48 FAbs %270 + %272 = OpFSub %float %float_1 %_skTemp24 + %273 = OpAccessChain %_ptr_Function_float %_94_f %uint_1 + %274 = OpLoad %float %273 None + %_95_b = OpFMul %float %272 %274 + %276 = OpLoad %v4float %_94_f None + %277 = OpVectorShuffle %v3float %276 %276 0 0 0 + %_96_c = OpFAdd %v3float %277 %279 %_skTemp25 = OpExtInst %v3float %48 Fract %_96_c - %280 = OpVectorTimesScalar %v3float %_skTemp25 %float_6 - %281 = OpCompositeConstruct %v3float %float_3 %float_3 %float_3 - %283 = OpFSub %v3float %280 %281 - %_skTemp26 = OpExtInst %v3float %48 FAbs %283 - %285 = OpCompositeConstruct %v3float %float_1 %float_1 %float_1 - %286 = OpFSub %v3float %_skTemp26 %285 - %_skTemp27 = OpExtInst %v3float %48 NClamp %286 %288 %289 - %290 = OpCompositeConstruct %v3float %float_0_5 %float_0_5 %float_0_5 - %291 = OpFSub %v3float %_skTemp27 %290 - %292 = OpVectorTimesScalar %v3float %291 %_95_b - %293 = OpAccessChain %_ptr_Function_float %_94_f %uint_2 - %294 = OpLoad %float %293 None - %295 = OpCompositeConstruct %v3float %294 %294 %294 - %296 = OpFAdd %v3float %292 %295 - %297 = OpAccessChain %_ptr_Function_float %_94_f %uint_3 - %298 = OpLoad %float %297 None - %299 = OpVectorTimesScalar %v3float %296 %298 + %283 = OpVectorTimesScalar %v3float %_skTemp25 %float_6 + %284 = OpCompositeConstruct %v3float %float_3 %float_3 %float_3 + %286 = OpFSub %v3float %283 %284 + %_skTemp26 = OpExtInst %v3float %48 FAbs %286 + %288 = OpCompositeConstruct %v3float %float_1 %float_1 %float_1 + %289 = OpFSub %v3float %_skTemp26 %288 + %_skTemp27 = OpExtInst %v3float %48 NClamp %289 %291 %292 + %293 = OpCompositeConstruct %v3float %float_0_5 %float_0_5 %float_0_5 + %294 = OpFSub %v3float %_skTemp27 %293 + %295 = OpVectorTimesScalar %v3float %294 %_95_b + %296 = OpAccessChain %_ptr_Function_float %_94_f %uint_2 + %297 = OpLoad %float %296 None + %298 = OpCompositeConstruct %v3float %297 %297 %297 + %299 = OpFAdd %v3float %295 %298 %300 = OpAccessChain %_ptr_Function_float %_94_f %uint_3 %301 = OpLoad %float %300 None - %302 = OpCompositeConstruct %v4float %299 %301 - %_skTemp28 = OpExtInst %v4float %48 NClamp %302 %70 %96 + %302 = OpVectorTimesScalar %v3float %299 %301 + %303 = OpAccessChain %_ptr_Function_float %_94_f %uint_3 + %304 = OpLoad %float %303 None + %305 = OpCompositeConstruct %v4float %302 %304 + %_skTemp28 = OpExtInst %v4float %48 NClamp %305 %70 %96 OpStore %_94_f %_skTemp28 None OpBranch %153 %155 = OpLabel - %304 = OpLoad %uint %shadingSsboIndex None - %305 = OpAccessChain %_ptr_StorageBuffer__runtimearr_FSUniformData %_storage1 %uint_0 - %306 = OpArrayLength %uint %_storage1 0 - %307 = OpISub %uint %306 %uint_1 - %308 = OpExtInst %uint %48 UMin %304 %307 - %309 = OpAccessChain %_ptr_StorageBuffer_int %_storage1 %uint_0 %308 %uint_8 - %311 = OpLoad %int %309 None - %312 = OpINotEqual %bool %311 %126 - OpSelectionMerge %313 None - OpBranchConditional %312 %314 %315 - %314 = OpLabel - %446 = OpLoad %v4float %_94_f None - %_skTemp29 = OpExtInst %v4float %48 NClamp %446 %70 %96 + %307 = OpLoad %uint %shadingSsboIndex None + %308 = OpAccessChain %_ptr_StorageBuffer__runtimearr_FSUniformData %_storage1 %uint_0 + %309 = OpArrayLength %uint %_storage1 0 + %310 = OpISub %uint %309 %uint_1 + %311 = OpExtInst %uint %48 UMin %307 %310 + %312 = OpAccessChain %_ptr_StorageBuffer_int %_storage1 %uint_0 %311 %uint_8 + %314 = OpLoad %int %312 None + %315 = OpINotEqual %bool %314 %126 + OpSelectionMerge %316 None + OpBranchConditional %315 %317 %318 + %317 = OpLabel + %449 = OpLoad %v4float %_94_f None + %_skTemp29 = OpExtInst %v4float %48 NClamp %449 %70 %96 OpStore %_94_f %_skTemp29 None - OpBranch %313 - %315 = OpLabel - %448 = OpAccessChain %_ptr_Function_float %_94_f %uint_3 - %449 = OpLoad %float %448 None - %_skTemp30 = OpExtInst %float %48 NClamp %449 %float_0 %float_1 + OpBranch %316 + %318 = OpLabel %451 = OpAccessChain %_ptr_Function_float %_94_f %uint_3 - OpStore %451 %_skTemp30 None - OpBranch %313 - %313 = OpLabel - %316 = OpLoad %v4float %_94_f None - %317 = OpVectorShuffle %v3float %316 %316 0 1 2 - %318 = OpAccessChain %_ptr_Function_float %_94_f %uint_3 - %319 = OpLoad %float %318 None - %320 = OpVectorTimesScalar %v3float %317 %319 + %452 = OpLoad %float %451 None + %_skTemp30 = OpExtInst %float %48 NClamp %452 %float_0 %float_1 + %454 = OpAccessChain %_ptr_Function_float %_94_f %uint_3 + OpStore %454 %_skTemp30 None + OpBranch %316 + %316 = OpLabel + %319 = OpLoad %v4float %_94_f None + %320 = OpVectorShuffle %v3float %319 %319 0 1 2 %321 = OpAccessChain %_ptr_Function_float %_94_f %uint_3 %322 = OpLoad %float %321 None - %323 = OpCompositeConstruct %v4float %320 %322 - OpStore %_94_f %323 None + %323 = OpVectorTimesScalar %v3float %320 %322 + %324 = OpAccessChain %_ptr_Function_float %_94_f %uint_3 + %325 = OpLoad %float %324 None + %326 = OpCompositeConstruct %v4float %323 %325 + OpStore %_94_f %326 None OpBranch %153 %153 = OpLabel %outColor_0 = OpLoad %v4float %_94_f None @@ -844,21 +850,21 @@ OpStore %157 %outColor_0 None OpReturn OpFunctionEnd - %main_inner = OpFunction %FSOut None %594 + %main_inner = OpFunction %FSOut None %600 %_stageIn_0 = OpFunctionParameter %FSIn - %595 = OpLabel - %_stageOut = OpVariable %_ptr_Function_FSOut Function %597 - %598 = OpFunctionCall %void %_skslMain %_stageIn_0 %_stageOut - %599 = OpLoad %FSOut %_stageOut None - OpReturnValue %599 + %601 = OpLabel + %_stageOut = OpVariable %_ptr_Function_FSOut Function %603 + %604 = OpFunctionCall %void %_skslMain %_stageIn_0 %_stageOut + %605 = OpLoad %FSOut %_stageOut None + OpReturnValue %605 OpFunctionEnd - %main = OpFunction %void None %601 - %602 = OpLabel - %603 = OpLoad %v2uint %main_loc0_Input None - %604 = OpLoad %v2float %main_loc1_Input None - %605 = OpCompositeConstruct %FSIn %603 %604 - %606 = OpFunctionCall %FSOut %main_inner %605 - %607 = OpCompositeExtract %v4float %606 0 - OpStore %main_loc0_Output %607 None + %main = OpFunction %void None %607 + %608 = OpLabel + %609 = OpLoad %v2uint %main_loc0_Input None + %610 = OpLoad %v2float %main_loc1_Input None + %611 = OpCompositeConstruct %FSIn %609 %610 + %612 = OpFunctionCall %FSOut %main_inner %611 + %613 = OpCompositeExtract %v4float %612 0 + OpStore %main_loc0_Output %613 None OpReturn OpFunctionEnd
diff --git a/test/tint/bug/tint/948.wgsl.expected.glsl b/test/tint/bug/tint/948.wgsl.expected.glsl index a566e95..1c43333 100644 --- a/test/tint/bug/tint/948.wgsl.expected.glsl +++ b/test/tint/bug/tint/948.wgsl.expected.glsl
@@ -227,7 +227,8 @@ uint tint_carry = uint((tint_low_inc == 4294967295u)); tint_loop_idx.y = (tint_loop_idx.y - tint_carry); int x_304 = i; - i = (x_304 + 1); + uint v_6 = uint(x_304); + i = int((v_6 + uint(1))); } continue; }
diff --git a/test/tint/bug/tint/948.wgsl.expected.spvasm b/test/tint/bug/tint/948.wgsl.expected.spvasm index 0d6d1c0..d6b1143 100644 --- a/test/tint/bug/tint/948.wgsl.expected.spvasm +++ b/test/tint/bug/tint/948.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 418 +; Bound: 421 ; Schema: 0 OpCapability Shader %69 = OpExtInstImport "GLSL.std.450" @@ -282,11 +282,11 @@ %uint_2 = OpConstant %uint 2 %_ptr_Function_uint = OpTypePointer Function %uint %int_1 = OpConstant %int 1 - %283 = OpConstantComposite %v2float %float_0_5 %float_0_5 + %286 = OpConstantComposite %v2float %float_0_5 %float_0_5 %uint_3 = OpConstant %uint 3 %float_8 = OpConstant %float 8 %main_out = OpTypeStruct %v4float - %403 = OpTypeFunction %main_out %v2float %v2float %v2float %v2float %v3float %v2float + %406 = OpTypeFunction %main_out %v2float %v2float %v2float %v2float %v3float %v2float %getFrameData_f1_ = OpFunction %mat4v4float None %53 %frameID_root = OpFunctionParameter %_ptr_Function_float %54 = OpLabel @@ -412,31 +412,31 @@ OpBranch %205 %203 = OpLabel %x_150 = OpLoad %v2float %tileID None - %278 = OpAccessChain %_ptr_Uniform_v2float %1 %uint_0 %uint_4 - %x_154 = OpLoad %v2float %278 None - %280 = OpLoad %13 %tileMapsTexture1 None - %281 = OpLoad %16 %tileMapsSampler None - %282 = OpFAdd %v2float %x_150 %283 - %284 = OpFDiv %v2float %282 %x_154 - %285 = OpExtInst %float %69 NClamp %float_0 %float_n16 %float_15_9899998 - %286 = OpSampledImage %73 %280 %281 - %x_156 = OpImageSampleImplicitLod %v4float %286 %284 Bias %285 - %288 = OpCompositeExtract %float %x_156 0 - OpStore %frameID_1 %288 None + %281 = OpAccessChain %_ptr_Uniform_v2float %1 %uint_0 %uint_4 + %x_154 = OpLoad %v2float %281 None + %283 = OpLoad %13 %tileMapsTexture1 None + %284 = OpLoad %16 %tileMapsSampler None + %285 = OpFAdd %v2float %x_150 %286 + %287 = OpFDiv %v2float %285 %x_154 + %288 = OpExtInst %float %69 NClamp %float_0 %float_n16 %float_15_9899998 + %289 = OpSampledImage %73 %283 %284 + %x_156 = OpImageSampleImplicitLod %v4float %289 %287 Bias %288 + %291 = OpCompositeExtract %float %x_156 0 + OpStore %frameID_1 %291 None OpBranch %205 %204 = OpLabel %x_136 = OpLoad %v2float %tileID None - %290 = OpAccessChain %_ptr_Uniform_v2float %1 %uint_0 %uint_4 - %x_140 = OpLoad %v2float %290 None - %292 = OpLoad %13 %tileMapsTexture0 None - %293 = OpLoad %16 %tileMapsSampler None - %294 = OpFAdd %v2float %x_136 %283 - %295 = OpFDiv %v2float %294 %x_140 - %296 = OpExtInst %float %69 NClamp %float_0 %float_n16 %float_15_9899998 - %297 = OpSampledImage %73 %292 %293 - %x_142 = OpImageSampleImplicitLod %v4float %297 %295 Bias %296 - %299 = OpCompositeExtract %float %x_142 0 - OpStore %frameID_1 %299 None + %293 = OpAccessChain %_ptr_Uniform_v2float %1 %uint_0 %uint_4 + %x_140 = OpLoad %v2float %293 None + %295 = OpLoad %13 %tileMapsTexture0 None + %296 = OpLoad %16 %tileMapsSampler None + %297 = OpFAdd %v2float %x_136 %286 + %298 = OpFDiv %v2float %297 %x_140 + %299 = OpExtInst %float %69 NClamp %float_0 %float_n16 %float_15_9899998 + %300 = OpSampledImage %73 %295 %296 + %x_142 = OpImageSampleImplicitLod %v4float %300 %298 Bias %299 + %302 = OpCompositeExtract %float %x_142 0 + OpStore %frameID_1 %302 None OpBranch %205 %205 = OpLabel %x_166 = OpLoad %float %frameID_1 None @@ -457,73 +457,73 @@ OpSelectionMerge %220 None OpBranchConditional %219 %221 %220 %221 = OpLabel - %300 = OpAccessChain %_ptr_Uniform_float %1 %uint_0 %uint_0 - %x_181 = OpLoad %float %300 None - %302 = OpAccessChain %_ptr_Function_float %animationData %uint_2 - %x_184 = OpLoad %float %302 None - %304 = OpFMul %float %x_181 %x_184 - %305 = OpFRem %float %304 %float_1 - OpStore %mt %305 None + %303 = OpAccessChain %_ptr_Uniform_float %1 %uint_0 %uint_0 + %x_181 = OpLoad %float %303 None + %305 = OpAccessChain %_ptr_Function_float %animationData %uint_2 + %x_184 = OpLoad %float %305 None + %307 = OpFMul %float %x_181 %x_184 + %308 = OpFRem %float %307 %float_1 + OpStore %mt %308 None OpStore %f %float_0 None - OpBranch %306 - %306 = OpLabel - OpStore %tint_loop_idx_0 %186 OpBranch %309 %309 = OpLabel - OpLoopMerge %310 %308 None - OpBranch %307 - %307 = OpLabel - %361 = OpLoad %v2uint %tint_loop_idx_0 None - %362 = OpIEqual %v2bool %361 %190 - %363 = OpAll %bool %362 - OpSelectionMerge %364 None - OpBranchConditional %363 %365 %364 - %365 = OpLabel + OpStore %tint_loop_idx_0 %186 + OpBranch %312 + %312 = OpLabel + OpLoopMerge %313 %311 None OpBranch %310 - %364 = OpLabel + %310 = OpLabel + %364 = OpLoad %v2uint %tint_loop_idx_0 None + %365 = OpIEqual %v2bool %364 %190 + %366 = OpAll %bool %365 + OpSelectionMerge %367 None + OpBranchConditional %366 %368 %367 + %368 = OpLabel + OpBranch %313 + %367 = OpLabel %x_193 = OpLoad %float %f None - %367 = OpFOrdLessThan %bool %x_193 %float_8 - OpSelectionMerge %369 None - OpBranchConditional %367 %369 %370 - %370 = OpLabel - OpBranch %310 - %369 = OpLabel - %371 = OpAccessChain %_ptr_Function_float %animationData %uint_1 - %x_197 = OpLoad %float %371 None + %370 = OpFOrdLessThan %bool %x_193 %float_8 + OpSelectionMerge %372 None + OpBranchConditional %370 %372 %373 + %373 = OpLabel + OpBranch %313 + %372 = OpLabel + %374 = OpAccessChain %_ptr_Function_float %animationData %uint_1 + %x_197 = OpLoad %float %374 None %x_198 = OpLoad %float %mt None - %374 = OpFOrdGreaterThan %bool %x_197 %x_198 - OpSelectionMerge %375 None - OpBranchConditional %374 %376 %375 - %376 = OpLabel - %393 = OpAccessChain %_ptr_Function_float %animationData %uint_0 - %x_203 = OpLoad %float %393 None + %377 = OpFOrdGreaterThan %bool %x_197 %x_198 + OpSelectionMerge %378 None + OpBranchConditional %377 %379 %378 + %379 = OpLabel + %396 = OpAccessChain %_ptr_Function_float %animationData %uint_0 + %x_203 = OpLoad %float %396 None OpStore %frameID_1 %x_203 None - OpBranch %310 - %375 = OpLabel + OpBranch %313 + %378 = OpLabel %x_208 = OpLoad %float %frameID_1 None - %378 = OpAccessChain %_ptr_Uniform_float %1 %uint_0 %uint_7 - %x_211 = OpLoad %float %378 None + %381 = OpAccessChain %_ptr_Uniform_float %1 %uint_0 %uint_7 + %x_211 = OpLoad %float %381 None %x_214 = OpLoad %float %f None OpStore %animationData %x_217 None - OpBranch %308 - %308 = OpLabel - %381 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_0 - %382 = OpLoad %uint %381 None -%tint_low_inc_1 = OpISub %uint %382 %uint_1 + OpBranch %311 + %311 = OpLabel %384 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_0 - OpStore %384 %tint_low_inc_1 None - %385 = OpIEqual %bool %tint_low_inc_1 %uint_4294967295 -%tint_carry_1 = OpSelect %uint %385 %uint_1 %uint_0 - %387 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 - %388 = OpLoad %uint %387 None - %389 = OpISub %uint %388 %tint_carry_1 + %385 = OpLoad %uint %384 None +%tint_low_inc_1 = OpISub %uint %385 %uint_1 + %387 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_0 + OpStore %387 %tint_low_inc_1 None + %388 = OpIEqual %bool %tint_low_inc_1 %uint_4294967295 +%tint_carry_1 = OpSelect %uint %388 %uint_1 %uint_0 %390 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 - OpStore %390 %389 None + %391 = OpLoad %uint %390 None + %392 = OpISub %uint %391 %tint_carry_1 + %393 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 + OpStore %393 %392 None %x_218 = OpLoad %float %f None - %392 = OpFAdd %float %x_218 %float_1 - OpStore %f %392 None - OpBranch %309 - %310 = OpLabel + %395 = OpFAdd %float %x_218 %float_1 + OpStore %f %395 None + OpBranch %312 + %313 = OpLabel OpBranch %220 %220 = OpLabel %x_222 = OpLoad %float %frameID_1 None @@ -568,10 +568,10 @@ OpBranchConditional %255 %257 %256 %257 = OpLabel %x_252 = OpLoad %v2float %tileUV None - %312 = OpCompositeExtract %float %x_252 1 - %313 = OpCompositeExtract %float %x_252 0 - %314 = OpCompositeConstruct %v2float %312 %313 - OpStore %tileUV %314 None + %315 = OpCompositeExtract %float %x_252 1 + %316 = OpCompositeExtract %float %x_252 0 + %317 = OpCompositeConstruct %v2float %315 %316 + OpStore %tileUV %317 None OpBranch %256 %256 = OpLabel %x_254 = OpLoad %int %i None @@ -582,54 +582,54 @@ %x_263 = OpLoad %v2float %tileUV None %x_264 = OpLoad %v2float %frameSize None %x_266 = OpLoad %v2float %offset_1 None - %318 = OpLoad %13 %spriteSheetTexture None - %319 = OpLoad %16 %spriteSheetSampler None - %320 = OpFMul %v2float %x_263 %x_264 - %321 = OpFAdd %v2float %320 %x_266 - %322 = OpSampledImage %73 %318 %319 - %x_268 = OpImageSampleImplicitLod %v4float %322 %321 None + %321 = OpLoad %13 %spriteSheetTexture None + %322 = OpLoad %16 %spriteSheetSampler None + %323 = OpFMul %v2float %x_263 %x_264 + %324 = OpFAdd %v2float %323 %x_266 + %325 = OpSampledImage %73 %321 %322 + %x_268 = OpImageSampleImplicitLod %v4float %325 %324 None OpStore %color %x_268 None OpBranch %260 %262 = OpLabel %x_274 = OpLoad %v2float %tileUV None %x_275 = OpLoad %v2float %frameSize None %x_277 = OpLoad %v2float %offset_1 None - %327 = OpLoad %13 %spriteSheetTexture None - %328 = OpLoad %16 %spriteSheetSampler None - %329 = OpFMul %v2float %x_274 %x_275 - %330 = OpFAdd %v2float %329 %x_277 - %331 = OpSampledImage %73 %327 %328 - %x_279 = OpImageSampleImplicitLod %v4float %331 %330 None + %330 = OpLoad %13 %spriteSheetTexture None + %331 = OpLoad %16 %spriteSheetSampler None + %332 = OpFMul %v2float %x_274 %x_275 + %333 = OpFAdd %v2float %332 %x_277 + %334 = OpSampledImage %73 %330 %331 + %x_279 = OpImageSampleImplicitLod %v4float %334 %333 None OpStore %nc %x_279 None - %333 = OpAccessChain %_ptr_Function_float %color %uint_3 - %x_283 = OpLoad %float %333 None - %336 = OpAccessChain %_ptr_Function_float %nc %uint_3 - %x_285 = OpLoad %float %336 None - %338 = OpFAdd %float %x_283 %x_285 - %339 = OpExtInst %float %69 NMin %338 %float_1 - OpStore %alpha %339 None + %336 = OpAccessChain %_ptr_Function_float %color %uint_3 + %x_283 = OpLoad %float %336 None + %339 = OpAccessChain %_ptr_Function_float %nc %uint_3 + %x_285 = OpLoad %float %339 None + %341 = OpFAdd %float %x_283 %x_285 + %342 = OpExtInst %float %69 NMin %341 %float_1 + OpStore %alpha %342 None %x_290 = OpLoad %v4float %color None %x_292 = OpLoad %v4float %nc None - %342 = OpAccessChain %_ptr_Function_float %nc %uint_3 - %x_295 = OpLoad %float %342 None - %344 = OpCompositeExtract %float %x_290 0 - %345 = OpCompositeExtract %float %x_290 1 - %346 = OpCompositeExtract %float %x_290 2 - %347 = OpCompositeConstruct %v3float %344 %345 %346 - %348 = OpCompositeExtract %float %x_292 0 - %349 = OpCompositeExtract %float %x_292 1 - %350 = OpCompositeExtract %float %x_292 2 - %351 = OpCompositeConstruct %v3float %348 %349 %350 - %352 = OpCompositeConstruct %v3float %x_295 %x_295 %x_295 - %353 = OpExtInst %v3float %69 FMix %347 %351 %352 - OpStore %mixed %353 None + %345 = OpAccessChain %_ptr_Function_float %nc %uint_3 + %x_295 = OpLoad %float %345 None + %347 = OpCompositeExtract %float %x_290 0 + %348 = OpCompositeExtract %float %x_290 1 + %349 = OpCompositeExtract %float %x_290 2 + %350 = OpCompositeConstruct %v3float %347 %348 %349 + %351 = OpCompositeExtract %float %x_292 0 + %352 = OpCompositeExtract %float %x_292 1 + %353 = OpCompositeExtract %float %x_292 2 + %354 = OpCompositeConstruct %v3float %351 %352 %353 + %355 = OpCompositeConstruct %v3float %x_295 %x_295 %x_295 + %356 = OpExtInst %v3float %69 FMix %350 %354 %355 + OpStore %mixed %356 None %x_298 = OpLoad %v3float %mixed None %x_299 = OpLoad %float %alpha None - %356 = OpCompositeExtract %float %x_298 0 - %357 = OpCompositeExtract %float %x_298 1 - %358 = OpCompositeExtract %float %x_298 2 - %359 = OpCompositeConstruct %v4float %356 %357 %358 %x_299 - OpStore %color %359 None + %359 = OpCompositeExtract %float %x_298 0 + %360 = OpCompositeExtract %float %x_298 1 + %361 = OpCompositeExtract %float %x_298 2 + %362 = OpCompositeConstruct %v4float %359 %360 %361 %x_299 + OpStore %color %362 None OpBranch %260 %260 = OpLabel OpBranch %163 @@ -647,8 +647,11 @@ %273 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 OpStore %273 %272 None %x_304 = OpLoad %int %i None - %275 = OpIAdd %int %x_304 %int_1 - OpStore %i %275 None + %275 = OpBitcast %uint %x_304 + %276 = OpBitcast %uint %int_1 + %278 = OpIAdd %uint %275 %276 + %279 = OpBitcast %int %278 + OpStore %i %279 None OpBranch %164 %165 = OpLabel %166 = OpAccessChain %_ptr_Uniform_v3float %1 %uint_0 %uint_8 @@ -670,35 +673,35 @@ OpStore %glFragColor %x_318 None OpReturn OpFunctionEnd - %main_inner = OpFunction %main_out None %403 + %main_inner = OpFunction %main_out None %406 %tUV_param = OpFunctionParameter %v2float %tileID_1_param = OpFunctionParameter %v2float %levelUnits_param = OpFunctionParameter %v2float %stageUnits_1_param = OpFunctionParameter %v2float %vPosition_param = OpFunctionParameter %v3float %vUV_param = OpFunctionParameter %v2float - %404 = OpLabel + %407 = OpLabel OpStore %tUV %tUV_param None OpStore %tileID_1 %tileID_1_param None OpStore %levelUnits %levelUnits_param None OpStore %stageUnits_1 %stageUnits_1_param None OpStore %vPosition %vPosition_param None OpStore %vUV %vUV_param None - %405 = OpFunctionCall %void %main_1 - %406 = OpLoad %v4float %glFragColor None - %407 = OpCompositeConstruct %main_out %406 - OpReturnValue %407 + %408 = OpFunctionCall %void %main_1 + %409 = OpLoad %v4float %glFragColor None + %410 = OpCompositeConstruct %main_out %409 + OpReturnValue %410 OpFunctionEnd %main = OpFunction %void None %109 - %409 = OpLabel - %410 = OpLoad %v2float %main_loc2_Input None - %411 = OpLoad %v2float %main_loc5_Input None - %412 = OpLoad %v2float %main_loc4_Input None - %413 = OpLoad %v2float %main_loc3_Input None - %414 = OpLoad %v3float %main_loc0_Input None - %415 = OpLoad %v2float %main_loc1_Input None - %416 = OpFunctionCall %main_out %main_inner %410 %411 %412 %413 %414 %415 - %417 = OpCompositeExtract %v4float %416 0 - OpStore %main_loc0_Output %417 None + %412 = OpLabel + %413 = OpLoad %v2float %main_loc2_Input None + %414 = OpLoad %v2float %main_loc5_Input None + %415 = OpLoad %v2float %main_loc4_Input None + %416 = OpLoad %v2float %main_loc3_Input None + %417 = OpLoad %v3float %main_loc0_Input None + %418 = OpLoad %v2float %main_loc1_Input None + %419 = OpFunctionCall %main_out %main_inner %413 %414 %415 %416 %417 %418 + %420 = OpCompositeExtract %v4float %419 0 + OpStore %main_loc0_Output %420 None OpReturn OpFunctionEnd
diff --git a/test/tint/bug/tint/949.wgsl.expected.glsl b/test/tint/bug/tint/949.wgsl.expected.glsl index 13c1434..c6c2792 100644 --- a/test/tint/bug/tint/949.wgsl.expected.glsl +++ b/test/tint/bug/tint/949.wgsl.expected.glsl
@@ -368,7 +368,8 @@ uint tint_carry = uint((tint_low_inc == 4294967295u)); tint_loop_idx.y = (tint_loop_idx.y - tint_carry); int x_441 = i; - i = (x_441 + 1); + uint v_7 = uint(x_441); + i = int((v_7 + uint(1))); } continue; } @@ -443,10 +444,10 @@ vec3 x_548 = output3; glFragColor = vec4(x_548.x, x_548.y, x_548.z, 1.0f); } -main_out main_inner(vec2 vMainuv_param, vec4 v_output1_param, bool v_7, vec2 v_uv_param, vec4 v_output2_param) { +main_out main_inner(vec2 vMainuv_param, vec4 v_output1_param, bool v_8, vec2 v_uv_param, vec4 v_output2_param) { vMainuv = vMainuv_param; v_output1 = v_output1_param; - v_1 = v_7; + v_1 = v_8; v_uv = v_uv_param; v_output2 = v_output2_param; main_1();
diff --git a/test/tint/bug/tint/949.wgsl.expected.spvasm b/test/tint/bug/tint/949.wgsl.expected.spvasm index e2f7734..31b8a9e 100644 --- a/test/tint/bug/tint/949.wgsl.expected.spvasm +++ b/test/tint/bug/tint/949.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 645 +; Bound: 648 ; Schema: 0 OpCapability Shader %83 = OpExtInstImport "GLSL.std.450" @@ -475,7 +475,7 @@ %_ptr_Function_uint = OpTypePointer Function %uint %int_1 = OpConstant %int 1 %main_out = OpTypeStruct %v4float - %631 = OpTypeFunction %main_out %v2float %v4float %bool %v2float %v4float + %634 = OpTypeFunction %main_out %v2float %v4float %bool %v2float %v4float %cotangent_frame_vf3_vf3_vf2_vf2_ = OpFunction %mat3v3float None %60 %normal_1_root = OpFunctionParameter %_ptr_Function_v3float %p_root = OpFunctionParameter %_ptr_Function_v3float @@ -934,43 +934,43 @@ %577 = OpLabel %x_406 = OpLoad %float %currSampledHeight None %x_407 = OpLoad %float %currRayHeight None - %595 = OpFSub %float %x_406 %x_407 - OpStore %delta1 %595 None + %598 = OpFSub %float %x_406 %x_407 + OpStore %delta1 %598 None %x_410 = OpLoad %float %currRayHeight None %x_411 = OpLoad %float %stepSize None %x_413 = OpLoad %float %lastSampledHeight None - %599 = OpFAdd %float %x_410 %x_411 - %600 = OpFSub %float %599 %x_413 - OpStore %delta2 %600 None + %602 = OpFAdd %float %x_410 %x_411 + %603 = OpFSub %float %602 %x_413 + OpStore %delta2 %603 None %x_416 = OpLoad %float %delta1 None %x_417 = OpLoad %float %delta1 None %x_418 = OpLoad %float %delta2 None - %604 = OpFAdd %float %x_417 %x_418 - %605 = OpFDiv %float %x_416 %604 - OpStore %ratio %605 None + %607 = OpFAdd %float %x_417 %x_418 + %608 = OpFDiv %float %x_416 %607 + OpStore %ratio %608 None %x_421 = OpLoad %float %ratio None %x_422 = OpLoad %v2float %vLastOffset None %x_424 = OpLoad %float %ratio None %x_426 = OpLoad %v2float %vCurrOffset None - %610 = OpVectorTimesScalar %v2float %x_422 %x_421 - %611 = OpFSub %float %float_1 %x_424 - %612 = OpVectorTimesScalar %v2float %x_426 %611 - %613 = OpFAdd %v2float %610 %612 - OpStore %vCurrOffset %613 None + %613 = OpVectorTimesScalar %v2float %x_422 %x_421 + %614 = OpFSub %float %float_1 %x_424 + %615 = OpVectorTimesScalar %v2float %x_426 %614 + %616 = OpFAdd %v2float %613 %615 + OpStore %vCurrOffset %616 None OpBranch %448 %578 = OpLabel %x_431 = OpLoad %float %stepSize None %x_432 = OpLoad %float %currRayHeight None - %616 = OpFSub %float %x_432 %x_431 - OpStore %currRayHeight %616 None + %619 = OpFSub %float %x_432 %x_431 + OpStore %currRayHeight %619 None %x_434 = OpLoad %v2float %vCurrOffset None OpStore %vLastOffset %x_434 None %x_435 = OpLoad %float %stepSize None %x_436 = OpLoad %v2float %vMaxOffset None %x_438 = OpLoad %v2float %vCurrOffset None - %621 = OpVectorTimesScalar %v2float %x_436 %x_435 - %622 = OpFAdd %v2float %x_438 %621 - OpStore %vCurrOffset %622 None + %624 = OpVectorTimesScalar %v2float %x_436 %x_435 + %625 = OpFAdd %v2float %x_438 %624 + OpStore %vCurrOffset %625 None %x_440 = OpLoad %float %currSampledHeight None OpStore %lastSampledHeight %x_440 None OpBranch %576 @@ -990,8 +990,11 @@ %589 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 OpStore %589 %588 None %x_441 = OpLoad %int %i None - %591 = OpIAdd %int %x_441 %int_1 - OpStore %i %591 None + %591 = OpBitcast %uint %x_441 + %592 = OpBitcast %uint %int_1 + %594 = OpIAdd %uint %591 %592 + %595 = OpBitcast %int %594 + OpStore %i %595 None OpBranch %447 %448 = OpLabel %x_444 = OpLoad %v2float %vCurrOffset None @@ -1125,32 +1128,32 @@ OpStore %glFragColor %549 None OpReturn OpFunctionEnd - %main_inner = OpFunction %main_out None %631 + %main_inner = OpFunction %main_out None %634 %vMainuv_param = OpFunctionParameter %v2float %v_output1_param = OpFunctionParameter %v4float %gl_FrontFacing_param = OpFunctionParameter %bool %v_uv_param = OpFunctionParameter %v2float %v_output2_param = OpFunctionParameter %v4float - %632 = OpLabel + %635 = OpLabel OpStore %vMainuv %vMainuv_param None OpStore %v_output1 %v_output1_param None OpStore %gl_FrontFacing %gl_FrontFacing_param None OpStore %v_uv %v_uv_param None OpStore %v_output2 %v_output2_param None - %633 = OpFunctionCall %void %main_1 - %634 = OpLoad %v4float %glFragColor None - %635 = OpCompositeConstruct %main_out %634 - OpReturnValue %635 + %636 = OpFunctionCall %void %main_1 + %637 = OpLoad %v4float %glFragColor None + %638 = OpCompositeConstruct %main_out %637 + OpReturnValue %638 OpFunctionEnd %main = OpFunction %void None %280 - %637 = OpLabel - %638 = OpLoad %v2float %main_loc1_Input None - %639 = OpLoad %v4float %main_loc0_Input None - %640 = OpLoad %bool %main_front_facing_Input None - %641 = OpLoad %v2float %main_loc3_Input None - %642 = OpLoad %v4float %main_loc2_Input None - %643 = OpFunctionCall %main_out %main_inner %638 %639 %640 %641 %642 - %644 = OpCompositeExtract %v4float %643 0 - OpStore %main_loc0_Output %644 None + %640 = OpLabel + %641 = OpLoad %v2float %main_loc1_Input None + %642 = OpLoad %v4float %main_loc0_Input None + %643 = OpLoad %bool %main_front_facing_Input None + %644 = OpLoad %v2float %main_loc3_Input None + %645 = OpLoad %v4float %main_loc2_Input None + %646 = OpFunctionCall %main_out %main_inner %641 %642 %643 %644 %645 + %647 = OpCompositeExtract %v4float %646 0 + OpStore %main_loc0_Output %647 None OpReturn OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/atomicSub/051100.wgsl.expected.glsl b/test/tint/builtins/gen/literal/atomicSub/051100.wgsl.expected.glsl index e39d9fe..190adc4 100644 --- a/test/tint/builtins/gen/literal/atomicSub/051100.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/atomicSub/051100.wgsl.expected.glsl
@@ -19,7 +19,7 @@ SB_RW inner; } v_1; int atomicSub_051100() { - int res = atomicAdd(v_1.inner.arg_0, -(1)); + int res = atomicAdd(v_1.inner.arg_0, int((~(uint(1)) + 1u))); return res; } void main() { @@ -44,7 +44,7 @@ SB_RW inner; } v_1; int atomicSub_051100() { - int res = atomicAdd(v_1.inner.arg_0, -(1)); + int res = atomicAdd(v_1.inner.arg_0, int((~(uint(1)) + 1u))); return res; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
diff --git a/test/tint/builtins/gen/literal/atomicSub/77883a.wgsl.expected.glsl b/test/tint/builtins/gen/literal/atomicSub/77883a.wgsl.expected.glsl index 9f4a885..7128896 100644 --- a/test/tint/builtins/gen/literal/atomicSub/77883a.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/atomicSub/77883a.wgsl.expected.glsl
@@ -6,7 +6,7 @@ } v; shared int arg_0; int atomicSub_77883a() { - int res = atomicAdd(arg_0, -(1)); + int res = atomicAdd(arg_0, int((~(uint(1)) + 1u))); return res; } void compute_main_inner(uint tint_local_index) {
diff --git a/test/tint/builtins/gen/var/atomicSub/051100.wgsl.expected.glsl b/test/tint/builtins/gen/var/atomicSub/051100.wgsl.expected.glsl index 49caf03..fce7287 100644 --- a/test/tint/builtins/gen/var/atomicSub/051100.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/atomicSub/051100.wgsl.expected.glsl
@@ -20,7 +20,7 @@ } v_1; int atomicSub_051100() { int arg_1 = 1; - int res = atomicAdd(v_1.inner.arg_0, -(arg_1)); + int res = atomicAdd(v_1.inner.arg_0, int((~(uint(arg_1)) + 1u))); return res; } void main() { @@ -46,7 +46,7 @@ } v_1; int atomicSub_051100() { int arg_1 = 1; - int res = atomicAdd(v_1.inner.arg_0, -(arg_1)); + int res = atomicAdd(v_1.inner.arg_0, int((~(uint(arg_1)) + 1u))); return res; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
diff --git a/test/tint/builtins/gen/var/atomicSub/77883a.wgsl.expected.glsl b/test/tint/builtins/gen/var/atomicSub/77883a.wgsl.expected.glsl index 65821ba..4aa1ecd 100644 --- a/test/tint/builtins/gen/var/atomicSub/77883a.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/atomicSub/77883a.wgsl.expected.glsl
@@ -7,7 +7,7 @@ shared int arg_0; int atomicSub_77883a() { int arg_1 = 1; - int res = atomicAdd(arg_0, -(arg_1)); + int res = atomicAdd(arg_0, int((~(uint(arg_1)) + 1u))); return res; } void compute_main_inner(uint tint_local_index) {
diff --git a/test/tint/builtins/gen/var/dot/ef6b1d.wgsl.expected.glsl b/test/tint/builtins/gen/var/dot/ef6b1d.wgsl.expected.glsl index 6276acf..95899c7 100644 --- a/test/tint/builtins/gen/var/dot/ef6b1d.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/dot/ef6b1d.wgsl.expected.glsl
@@ -10,7 +10,20 @@ int inner; } v; int tint_int_dot(ivec4 x, ivec4 y) { - return ((((x.x * y.x) + (x.y * y.y)) + (x.z * y.z)) + (x.w * y.w)); + uint v_1 = uint(x.x); + int v_2 = int((v_1 * uint(y.x))); + uint v_3 = uint(x.y); + int v_4 = int((v_3 * uint(y.y))); + uint v_5 = uint(v_2); + int v_6 = int((v_5 + uint(v_4))); + uint v_7 = uint(x.z); + int v_8 = int((v_7 * uint(y.z))); + uint v_9 = uint(v_6); + int v_10 = int((v_9 + uint(v_8))); + uint v_11 = uint(x.w); + int v_12 = int((v_11 * uint(y.w))); + uint v_13 = uint(v_10); + return int((v_13 + uint(v_12))); } int dot_ef6b1d() { ivec4 arg_0 = ivec4(1); @@ -31,7 +44,20 @@ int inner; } v; int tint_int_dot(ivec4 x, ivec4 y) { - return ((((x.x * y.x) + (x.y * y.y)) + (x.z * y.z)) + (x.w * y.w)); + uint v_1 = uint(x.x); + int v_2 = int((v_1 * uint(y.x))); + uint v_3 = uint(x.y); + int v_4 = int((v_3 * uint(y.y))); + uint v_5 = uint(v_2); + int v_6 = int((v_5 + uint(v_4))); + uint v_7 = uint(x.z); + int v_8 = int((v_7 * uint(y.z))); + uint v_9 = uint(v_6); + int v_10 = int((v_9 + uint(v_8))); + uint v_11 = uint(x.w); + int v_12 = int((v_11 * uint(y.w))); + uint v_13 = uint(v_10); + return int((v_13 + uint(v_12))); } int dot_ef6b1d() { ivec4 arg_0 = ivec4(1); @@ -56,7 +82,20 @@ layout(location = 0) flat out int tint_interstage_location0; int tint_int_dot(ivec4 x, ivec4 y) { - return ((((x.x * y.x) + (x.y * y.y)) + (x.z * y.z)) + (x.w * y.w)); + uint v = uint(x.x); + int v_1 = int((v * uint(y.x))); + uint v_2 = uint(x.y); + int v_3 = int((v_2 * uint(y.y))); + uint v_4 = uint(v_1); + int v_5 = int((v_4 + uint(v_3))); + uint v_6 = uint(x.z); + int v_7 = int((v_6 * uint(y.z))); + uint v_8 = uint(v_5); + int v_9 = int((v_8 + uint(v_7))); + uint v_10 = uint(x.w); + int v_11 = int((v_10 * uint(y.w))); + uint v_12 = uint(v_9); + return int((v_12 + uint(v_11))); } int dot_ef6b1d() { ivec4 arg_0 = ivec4(1); @@ -65,14 +104,14 @@ return res; } VertexOutput vertex_main_inner() { - VertexOutput v = VertexOutput(vec4(0.0f), 0); - v.pos = vec4(0.0f); - v.prevent_dce = dot_ef6b1d(); - return v; + VertexOutput v_13 = VertexOutput(vec4(0.0f), 0); + v_13.pos = vec4(0.0f); + v_13.prevent_dce = dot_ef6b1d(); + return v_13; } void main() { - VertexOutput v_1 = vertex_main_inner(); - gl_Position = vec4(v_1.pos.x, -(v_1.pos.y), ((2.0f * v_1.pos.z) - v_1.pos.w), v_1.pos.w); - tint_interstage_location0 = v_1.prevent_dce; + VertexOutput v_14 = vertex_main_inner(); + gl_Position = vec4(v_14.pos.x, -(v_14.pos.y), ((2.0f * v_14.pos.z) - v_14.pos.w), v_14.pos.w); + tint_interstage_location0 = v_14.prevent_dce; gl_PointSize = 1.0f; }
diff --git a/test/tint/builtins/gen/var/dot/ef6b1d.wgsl.expected.msl b/test/tint/builtins/gen/var/dot/ef6b1d.wgsl.expected.msl index 6b18834..5f920c7 100644 --- a/test/tint/builtins/gen/var/dot/ef6b1d.wgsl.expected.msl +++ b/test/tint/builtins/gen/var/dot/ef6b1d.wgsl.expected.msl
@@ -9,7 +9,7 @@ }; int tint_dot(int4 lhs, int4 rhs) { - return ((((lhs * rhs).x + (lhs * rhs).y) + (lhs * rhs).z) + (lhs * rhs).w); + return as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(as_type<int4>((as_type<uint4>(lhs) * as_type<uint4>(rhs))).x) + as_type<uint>(as_type<int4>((as_type<uint4>(lhs) * as_type<uint4>(rhs))).y)))) + as_type<uint>(as_type<int4>((as_type<uint4>(lhs) * as_type<uint4>(rhs))).z)))) + as_type<uint>(as_type<int4>((as_type<uint4>(lhs) * as_type<uint4>(rhs))).w))); } int dot_ef6b1d() { @@ -34,7 +34,7 @@ }; int tint_dot(int4 lhs, int4 rhs) { - return ((((lhs * rhs).x + (lhs * rhs).y) + (lhs * rhs).z) + (lhs * rhs).w); + return as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(as_type<int4>((as_type<uint4>(lhs) * as_type<uint4>(rhs))).x) + as_type<uint>(as_type<int4>((as_type<uint4>(lhs) * as_type<uint4>(rhs))).y)))) + as_type<uint>(as_type<int4>((as_type<uint4>(lhs) * as_type<uint4>(rhs))).z)))) + as_type<uint>(as_type<int4>((as_type<uint4>(lhs) * as_type<uint4>(rhs))).w))); } int dot_ef6b1d() { @@ -65,7 +65,7 @@ }; int tint_dot(int4 lhs, int4 rhs) { - return ((((lhs * rhs).x + (lhs * rhs).y) + (lhs * rhs).z) + (lhs * rhs).w); + return as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(as_type<int4>((as_type<uint4>(lhs) * as_type<uint4>(rhs))).x) + as_type<uint>(as_type<int4>((as_type<uint4>(lhs) * as_type<uint4>(rhs))).y)))) + as_type<uint>(as_type<int4>((as_type<uint4>(lhs) * as_type<uint4>(rhs))).z)))) + as_type<uint>(as_type<int4>((as_type<uint4>(lhs) * as_type<uint4>(rhs))).w))); } int dot_ef6b1d() {
diff --git a/test/tint/builtins/gen/var/dot/ef6b1d.wgsl.expected.spvasm b/test/tint/builtins/gen/var/dot/ef6b1d.wgsl.expected.spvasm index 45f57be..0ca34c7 100644 --- a/test/tint/builtins/gen/var/dot/ef6b1d.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/var/dot/ef6b1d.wgsl.expected.spvasm
@@ -4,7 +4,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 43 +; Bound: 64 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -31,11 +31,11 @@ %_ptr_Function_v4int = OpTypePointer Function %v4int %int_1 = OpConstant %int 1 %11 = OpConstantComposite %v4int %int_1 %int_1 %int_1 %int_1 + %uint = OpTypeInt 32 0 %_ptr_Function_int = OpTypePointer Function %int %void = OpTypeVoid - %36 = OpTypeFunction %void + %58 = OpTypeFunction %void %_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int - %uint = OpTypeInt 32 0 %uint_0 = OpConstant %uint 0 %dot_ef6b1d = OpFunction %int None %6 %7 = OpLabel @@ -48,28 +48,49 @@ %15 = OpLoad %v4int %arg_1 None %16 = OpCompositeExtract %int %14 0 %17 = OpCompositeExtract %int %15 0 - %18 = OpIMul %int %16 %17 - %19 = OpCompositeExtract %int %14 1 - %20 = OpCompositeExtract %int %15 1 - %21 = OpIMul %int %19 %20 - %22 = OpIAdd %int %18 %21 - %23 = OpCompositeExtract %int %14 2 - %24 = OpCompositeExtract %int %15 2 - %25 = OpIMul %int %23 %24 - %26 = OpIAdd %int %22 %25 - %27 = OpCompositeExtract %int %14 3 - %28 = OpCompositeExtract %int %15 3 - %29 = OpIMul %int %27 %28 - %30 = OpIAdd %int %26 %29 - OpStore %res %30 - %33 = OpLoad %int %res None - OpReturnValue %33 + %19 = OpBitcast %uint %16 + %20 = OpBitcast %uint %17 + %21 = OpIMul %uint %19 %20 + %22 = OpBitcast %int %21 + %23 = OpCompositeExtract %int %14 1 + %24 = OpCompositeExtract %int %15 1 + %25 = OpBitcast %uint %23 + %26 = OpBitcast %uint %24 + %27 = OpIMul %uint %25 %26 + %28 = OpBitcast %int %27 + %29 = OpBitcast %uint %22 + %30 = OpBitcast %uint %28 + %31 = OpIAdd %uint %29 %30 + %32 = OpBitcast %int %31 + %33 = OpCompositeExtract %int %14 2 + %34 = OpCompositeExtract %int %15 2 + %35 = OpBitcast %uint %33 + %36 = OpBitcast %uint %34 + %37 = OpIMul %uint %35 %36 + %38 = OpBitcast %int %37 + %39 = OpBitcast %uint %32 + %40 = OpBitcast %uint %38 + %41 = OpIAdd %uint %39 %40 + %42 = OpBitcast %int %41 + %43 = OpCompositeExtract %int %14 3 + %44 = OpCompositeExtract %int %15 3 + %45 = OpBitcast %uint %43 + %46 = OpBitcast %uint %44 + %47 = OpIMul %uint %45 %46 + %48 = OpBitcast %int %47 + %49 = OpBitcast %uint %42 + %50 = OpBitcast %uint %48 + %51 = OpIAdd %uint %49 %50 + %52 = OpBitcast %int %51 + OpStore %res %52 + %55 = OpLoad %int %res None + OpReturnValue %55 OpFunctionEnd -%fragment_main = OpFunction %void None %36 - %37 = OpLabel - %38 = OpFunctionCall %int %dot_ef6b1d - %39 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 - OpStore %39 %38 None +%fragment_main = OpFunction %void None %58 + %59 = OpLabel + %60 = OpFunctionCall %int %dot_ef6b1d + %61 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 + OpStore %61 %60 None OpReturn OpFunctionEnd ; @@ -78,7 +99,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 43 +; Bound: 64 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -105,11 +126,11 @@ %_ptr_Function_v4int = OpTypePointer Function %v4int %int_1 = OpConstant %int 1 %11 = OpConstantComposite %v4int %int_1 %int_1 %int_1 %int_1 + %uint = OpTypeInt 32 0 %_ptr_Function_int = OpTypePointer Function %int %void = OpTypeVoid - %36 = OpTypeFunction %void + %58 = OpTypeFunction %void %_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int - %uint = OpTypeInt 32 0 %uint_0 = OpConstant %uint 0 %dot_ef6b1d = OpFunction %int None %6 %7 = OpLabel @@ -122,28 +143,49 @@ %15 = OpLoad %v4int %arg_1 None %16 = OpCompositeExtract %int %14 0 %17 = OpCompositeExtract %int %15 0 - %18 = OpIMul %int %16 %17 - %19 = OpCompositeExtract %int %14 1 - %20 = OpCompositeExtract %int %15 1 - %21 = OpIMul %int %19 %20 - %22 = OpIAdd %int %18 %21 - %23 = OpCompositeExtract %int %14 2 - %24 = OpCompositeExtract %int %15 2 - %25 = OpIMul %int %23 %24 - %26 = OpIAdd %int %22 %25 - %27 = OpCompositeExtract %int %14 3 - %28 = OpCompositeExtract %int %15 3 - %29 = OpIMul %int %27 %28 - %30 = OpIAdd %int %26 %29 - OpStore %res %30 - %33 = OpLoad %int %res None - OpReturnValue %33 + %19 = OpBitcast %uint %16 + %20 = OpBitcast %uint %17 + %21 = OpIMul %uint %19 %20 + %22 = OpBitcast %int %21 + %23 = OpCompositeExtract %int %14 1 + %24 = OpCompositeExtract %int %15 1 + %25 = OpBitcast %uint %23 + %26 = OpBitcast %uint %24 + %27 = OpIMul %uint %25 %26 + %28 = OpBitcast %int %27 + %29 = OpBitcast %uint %22 + %30 = OpBitcast %uint %28 + %31 = OpIAdd %uint %29 %30 + %32 = OpBitcast %int %31 + %33 = OpCompositeExtract %int %14 2 + %34 = OpCompositeExtract %int %15 2 + %35 = OpBitcast %uint %33 + %36 = OpBitcast %uint %34 + %37 = OpIMul %uint %35 %36 + %38 = OpBitcast %int %37 + %39 = OpBitcast %uint %32 + %40 = OpBitcast %uint %38 + %41 = OpIAdd %uint %39 %40 + %42 = OpBitcast %int %41 + %43 = OpCompositeExtract %int %14 3 + %44 = OpCompositeExtract %int %15 3 + %45 = OpBitcast %uint %43 + %46 = OpBitcast %uint %44 + %47 = OpIMul %uint %45 %46 + %48 = OpBitcast %int %47 + %49 = OpBitcast %uint %42 + %50 = OpBitcast %uint %48 + %51 = OpIAdd %uint %49 %50 + %52 = OpBitcast %int %51 + OpStore %res %52 + %55 = OpLoad %int %res None + OpReturnValue %55 OpFunctionEnd -%compute_main = OpFunction %void None %36 - %37 = OpLabel - %38 = OpFunctionCall %int %dot_ef6b1d - %39 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 - OpStore %39 %38 None +%compute_main = OpFunction %void None %58 + %59 = OpLabel + %60 = OpFunctionCall %int %dot_ef6b1d + %61 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 + OpStore %61 %60 None OpReturn OpFunctionEnd ; @@ -152,7 +194,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 63 +; Bound: 84 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -188,18 +230,18 @@ %_ptr_Function_v4int = OpTypePointer Function %v4int %int_1 = OpConstant %int 1 %16 = OpConstantComposite %v4int %int_1 %int_1 %int_1 %int_1 + %uint = OpTypeInt 32 0 %_ptr_Function_int = OpTypePointer Function %int %VertexOutput = OpTypeStruct %v4float %int - %41 = OpTypeFunction %VertexOutput + %63 = OpTypeFunction %VertexOutput %_ptr_Function_VertexOutput = OpTypePointer Function %VertexOutput - %45 = OpConstantNull %VertexOutput + %67 = OpConstantNull %VertexOutput %_ptr_Function_v4float = OpTypePointer Function %v4float - %uint = OpTypeInt 32 0 %uint_0 = OpConstant %uint 0 - %50 = OpConstantNull %v4float + %71 = OpConstantNull %v4float %uint_1 = OpConstant %uint 1 %void = OpTypeVoid - %57 = OpTypeFunction %void + %78 = OpTypeFunction %void %float_1 = OpConstant %float 1 %dot_ef6b1d = OpFunction %int None %11 %12 = OpLabel @@ -212,41 +254,62 @@ %20 = OpLoad %v4int %arg_1 None %21 = OpCompositeExtract %int %19 0 %22 = OpCompositeExtract %int %20 0 - %23 = OpIMul %int %21 %22 - %24 = OpCompositeExtract %int %19 1 - %25 = OpCompositeExtract %int %20 1 - %26 = OpIMul %int %24 %25 - %27 = OpIAdd %int %23 %26 - %28 = OpCompositeExtract %int %19 2 - %29 = OpCompositeExtract %int %20 2 - %30 = OpIMul %int %28 %29 - %31 = OpIAdd %int %27 %30 - %32 = OpCompositeExtract %int %19 3 - %33 = OpCompositeExtract %int %20 3 - %34 = OpIMul %int %32 %33 - %35 = OpIAdd %int %31 %34 - OpStore %res %35 - %38 = OpLoad %int %res None - OpReturnValue %38 + %24 = OpBitcast %uint %21 + %25 = OpBitcast %uint %22 + %26 = OpIMul %uint %24 %25 + %27 = OpBitcast %int %26 + %28 = OpCompositeExtract %int %19 1 + %29 = OpCompositeExtract %int %20 1 + %30 = OpBitcast %uint %28 + %31 = OpBitcast %uint %29 + %32 = OpIMul %uint %30 %31 + %33 = OpBitcast %int %32 + %34 = OpBitcast %uint %27 + %35 = OpBitcast %uint %33 + %36 = OpIAdd %uint %34 %35 + %37 = OpBitcast %int %36 + %38 = OpCompositeExtract %int %19 2 + %39 = OpCompositeExtract %int %20 2 + %40 = OpBitcast %uint %38 + %41 = OpBitcast %uint %39 + %42 = OpIMul %uint %40 %41 + %43 = OpBitcast %int %42 + %44 = OpBitcast %uint %37 + %45 = OpBitcast %uint %43 + %46 = OpIAdd %uint %44 %45 + %47 = OpBitcast %int %46 + %48 = OpCompositeExtract %int %19 3 + %49 = OpCompositeExtract %int %20 3 + %50 = OpBitcast %uint %48 + %51 = OpBitcast %uint %49 + %52 = OpIMul %uint %50 %51 + %53 = OpBitcast %int %52 + %54 = OpBitcast %uint %47 + %55 = OpBitcast %uint %53 + %56 = OpIAdd %uint %54 %55 + %57 = OpBitcast %int %56 + OpStore %res %57 + %60 = OpLoad %int %res None + OpReturnValue %60 OpFunctionEnd -%vertex_main_inner = OpFunction %VertexOutput None %41 - %42 = OpLabel - %out = OpVariable %_ptr_Function_VertexOutput Function %45 - %46 = OpAccessChain %_ptr_Function_v4float %out %uint_0 - OpStore %46 %50 None - %51 = OpAccessChain %_ptr_Function_int %out %uint_1 - %53 = OpFunctionCall %int %dot_ef6b1d - OpStore %51 %53 None - %54 = OpLoad %VertexOutput %out None - OpReturnValue %54 +%vertex_main_inner = OpFunction %VertexOutput None %63 + %64 = OpLabel + %out = OpVariable %_ptr_Function_VertexOutput Function %67 + %68 = OpAccessChain %_ptr_Function_v4float %out %uint_0 + OpStore %68 %71 None + %72 = OpAccessChain %_ptr_Function_int %out %uint_1 + %74 = OpFunctionCall %int %dot_ef6b1d + OpStore %72 %74 None + %75 = OpLoad %VertexOutput %out None + OpReturnValue %75 OpFunctionEnd -%vertex_main = OpFunction %void None %57 - %58 = OpLabel - %59 = OpFunctionCall %VertexOutput %vertex_main_inner - %60 = OpCompositeExtract %v4float %59 0 - OpStore %vertex_main_position_Output %60 None - %61 = OpCompositeExtract %int %59 1 - OpStore %vertex_main_loc0_Output %61 None +%vertex_main = OpFunction %void None %78 + %79 = OpLabel + %80 = OpFunctionCall %VertexOutput %vertex_main_inner + %81 = OpCompositeExtract %v4float %80 0 + OpStore %vertex_main_position_Output %81 None + %82 = OpCompositeExtract %int %80 1 + OpStore %vertex_main_loc0_Output %82 None OpStore %vertex_main___point_size_Output %float_1 None OpReturn OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/dot/f1312c.wgsl.expected.glsl b/test/tint/builtins/gen/var/dot/f1312c.wgsl.expected.glsl index b3ef3a2..ee99c9f 100644 --- a/test/tint/builtins/gen/var/dot/f1312c.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/dot/f1312c.wgsl.expected.glsl
@@ -10,7 +10,16 @@ int inner; } v; int tint_int_dot(ivec3 x, ivec3 y) { - return (((x.x * y.x) + (x.y * y.y)) + (x.z * y.z)); + uint v_1 = uint(x.x); + int v_2 = int((v_1 * uint(y.x))); + uint v_3 = uint(x.y); + int v_4 = int((v_3 * uint(y.y))); + uint v_5 = uint(v_2); + int v_6 = int((v_5 + uint(v_4))); + uint v_7 = uint(x.z); + int v_8 = int((v_7 * uint(y.z))); + uint v_9 = uint(v_6); + return int((v_9 + uint(v_8))); } int dot_f1312c() { ivec3 arg_0 = ivec3(1); @@ -31,7 +40,16 @@ int inner; } v; int tint_int_dot(ivec3 x, ivec3 y) { - return (((x.x * y.x) + (x.y * y.y)) + (x.z * y.z)); + uint v_1 = uint(x.x); + int v_2 = int((v_1 * uint(y.x))); + uint v_3 = uint(x.y); + int v_4 = int((v_3 * uint(y.y))); + uint v_5 = uint(v_2); + int v_6 = int((v_5 + uint(v_4))); + uint v_7 = uint(x.z); + int v_8 = int((v_7 * uint(y.z))); + uint v_9 = uint(v_6); + return int((v_9 + uint(v_8))); } int dot_f1312c() { ivec3 arg_0 = ivec3(1); @@ -56,7 +74,16 @@ layout(location = 0) flat out int tint_interstage_location0; int tint_int_dot(ivec3 x, ivec3 y) { - return (((x.x * y.x) + (x.y * y.y)) + (x.z * y.z)); + uint v = uint(x.x); + int v_1 = int((v * uint(y.x))); + uint v_2 = uint(x.y); + int v_3 = int((v_2 * uint(y.y))); + uint v_4 = uint(v_1); + int v_5 = int((v_4 + uint(v_3))); + uint v_6 = uint(x.z); + int v_7 = int((v_6 * uint(y.z))); + uint v_8 = uint(v_5); + return int((v_8 + uint(v_7))); } int dot_f1312c() { ivec3 arg_0 = ivec3(1); @@ -65,14 +92,14 @@ return res; } VertexOutput vertex_main_inner() { - VertexOutput v = VertexOutput(vec4(0.0f), 0); - v.pos = vec4(0.0f); - v.prevent_dce = dot_f1312c(); - return v; + VertexOutput v_9 = VertexOutput(vec4(0.0f), 0); + v_9.pos = vec4(0.0f); + v_9.prevent_dce = dot_f1312c(); + return v_9; } void main() { - VertexOutput v_1 = vertex_main_inner(); - gl_Position = vec4(v_1.pos.x, -(v_1.pos.y), ((2.0f * v_1.pos.z) - v_1.pos.w), v_1.pos.w); - tint_interstage_location0 = v_1.prevent_dce; + VertexOutput v_10 = vertex_main_inner(); + gl_Position = vec4(v_10.pos.x, -(v_10.pos.y), ((2.0f * v_10.pos.z) - v_10.pos.w), v_10.pos.w); + tint_interstage_location0 = v_10.prevent_dce; gl_PointSize = 1.0f; }
diff --git a/test/tint/builtins/gen/var/dot/f1312c.wgsl.expected.msl b/test/tint/builtins/gen/var/dot/f1312c.wgsl.expected.msl index 0b8e291..6fd104d 100644 --- a/test/tint/builtins/gen/var/dot/f1312c.wgsl.expected.msl +++ b/test/tint/builtins/gen/var/dot/f1312c.wgsl.expected.msl
@@ -9,7 +9,7 @@ }; int tint_dot(int3 lhs, int3 rhs) { - return (((lhs * rhs).x + (lhs * rhs).y) + (lhs * rhs).z); + return as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(as_type<int3>((as_type<uint3>(lhs) * as_type<uint3>(rhs))).x) + as_type<uint>(as_type<int3>((as_type<uint3>(lhs) * as_type<uint3>(rhs))).y)))) + as_type<uint>(as_type<int3>((as_type<uint3>(lhs) * as_type<uint3>(rhs))).z))); } int dot_f1312c() { @@ -34,7 +34,7 @@ }; int tint_dot(int3 lhs, int3 rhs) { - return (((lhs * rhs).x + (lhs * rhs).y) + (lhs * rhs).z); + return as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(as_type<int3>((as_type<uint3>(lhs) * as_type<uint3>(rhs))).x) + as_type<uint>(as_type<int3>((as_type<uint3>(lhs) * as_type<uint3>(rhs))).y)))) + as_type<uint>(as_type<int3>((as_type<uint3>(lhs) * as_type<uint3>(rhs))).z))); } int dot_f1312c() { @@ -65,7 +65,7 @@ }; int tint_dot(int3 lhs, int3 rhs) { - return (((lhs * rhs).x + (lhs * rhs).y) + (lhs * rhs).z); + return as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(as_type<int3>((as_type<uint3>(lhs) * as_type<uint3>(rhs))).x) + as_type<uint>(as_type<int3>((as_type<uint3>(lhs) * as_type<uint3>(rhs))).y)))) + as_type<uint>(as_type<int3>((as_type<uint3>(lhs) * as_type<uint3>(rhs))).z))); } int dot_f1312c() {
diff --git a/test/tint/builtins/gen/var/dot/f1312c.wgsl.expected.spvasm b/test/tint/builtins/gen/var/dot/f1312c.wgsl.expected.spvasm index 9d4e4f3..84b0059 100644 --- a/test/tint/builtins/gen/var/dot/f1312c.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/var/dot/f1312c.wgsl.expected.spvasm
@@ -4,7 +4,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 39 +; Bound: 54 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -31,11 +31,11 @@ %_ptr_Function_v3int = OpTypePointer Function %v3int %int_1 = OpConstant %int 1 %11 = OpConstantComposite %v3int %int_1 %int_1 %int_1 + %uint = OpTypeInt 32 0 %_ptr_Function_int = OpTypePointer Function %int %void = OpTypeVoid - %32 = OpTypeFunction %void + %48 = OpTypeFunction %void %_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int - %uint = OpTypeInt 32 0 %uint_0 = OpConstant %uint 0 %dot_f1312c = OpFunction %int None %6 %7 = OpLabel @@ -48,24 +48,39 @@ %15 = OpLoad %v3int %arg_1 None %16 = OpCompositeExtract %int %14 0 %17 = OpCompositeExtract %int %15 0 - %18 = OpIMul %int %16 %17 - %19 = OpCompositeExtract %int %14 1 - %20 = OpCompositeExtract %int %15 1 - %21 = OpIMul %int %19 %20 - %22 = OpIAdd %int %18 %21 - %23 = OpCompositeExtract %int %14 2 - %24 = OpCompositeExtract %int %15 2 - %25 = OpIMul %int %23 %24 - %26 = OpIAdd %int %22 %25 - OpStore %res %26 - %29 = OpLoad %int %res None - OpReturnValue %29 + %19 = OpBitcast %uint %16 + %20 = OpBitcast %uint %17 + %21 = OpIMul %uint %19 %20 + %22 = OpBitcast %int %21 + %23 = OpCompositeExtract %int %14 1 + %24 = OpCompositeExtract %int %15 1 + %25 = OpBitcast %uint %23 + %26 = OpBitcast %uint %24 + %27 = OpIMul %uint %25 %26 + %28 = OpBitcast %int %27 + %29 = OpBitcast %uint %22 + %30 = OpBitcast %uint %28 + %31 = OpIAdd %uint %29 %30 + %32 = OpBitcast %int %31 + %33 = OpCompositeExtract %int %14 2 + %34 = OpCompositeExtract %int %15 2 + %35 = OpBitcast %uint %33 + %36 = OpBitcast %uint %34 + %37 = OpIMul %uint %35 %36 + %38 = OpBitcast %int %37 + %39 = OpBitcast %uint %32 + %40 = OpBitcast %uint %38 + %41 = OpIAdd %uint %39 %40 + %42 = OpBitcast %int %41 + OpStore %res %42 + %45 = OpLoad %int %res None + OpReturnValue %45 OpFunctionEnd -%fragment_main = OpFunction %void None %32 - %33 = OpLabel - %34 = OpFunctionCall %int %dot_f1312c - %35 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 - OpStore %35 %34 None +%fragment_main = OpFunction %void None %48 + %49 = OpLabel + %50 = OpFunctionCall %int %dot_f1312c + %51 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 + OpStore %51 %50 None OpReturn OpFunctionEnd ; @@ -74,7 +89,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 39 +; Bound: 54 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -101,11 +116,11 @@ %_ptr_Function_v3int = OpTypePointer Function %v3int %int_1 = OpConstant %int 1 %11 = OpConstantComposite %v3int %int_1 %int_1 %int_1 + %uint = OpTypeInt 32 0 %_ptr_Function_int = OpTypePointer Function %int %void = OpTypeVoid - %32 = OpTypeFunction %void + %48 = OpTypeFunction %void %_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int - %uint = OpTypeInt 32 0 %uint_0 = OpConstant %uint 0 %dot_f1312c = OpFunction %int None %6 %7 = OpLabel @@ -118,24 +133,39 @@ %15 = OpLoad %v3int %arg_1 None %16 = OpCompositeExtract %int %14 0 %17 = OpCompositeExtract %int %15 0 - %18 = OpIMul %int %16 %17 - %19 = OpCompositeExtract %int %14 1 - %20 = OpCompositeExtract %int %15 1 - %21 = OpIMul %int %19 %20 - %22 = OpIAdd %int %18 %21 - %23 = OpCompositeExtract %int %14 2 - %24 = OpCompositeExtract %int %15 2 - %25 = OpIMul %int %23 %24 - %26 = OpIAdd %int %22 %25 - OpStore %res %26 - %29 = OpLoad %int %res None - OpReturnValue %29 + %19 = OpBitcast %uint %16 + %20 = OpBitcast %uint %17 + %21 = OpIMul %uint %19 %20 + %22 = OpBitcast %int %21 + %23 = OpCompositeExtract %int %14 1 + %24 = OpCompositeExtract %int %15 1 + %25 = OpBitcast %uint %23 + %26 = OpBitcast %uint %24 + %27 = OpIMul %uint %25 %26 + %28 = OpBitcast %int %27 + %29 = OpBitcast %uint %22 + %30 = OpBitcast %uint %28 + %31 = OpIAdd %uint %29 %30 + %32 = OpBitcast %int %31 + %33 = OpCompositeExtract %int %14 2 + %34 = OpCompositeExtract %int %15 2 + %35 = OpBitcast %uint %33 + %36 = OpBitcast %uint %34 + %37 = OpIMul %uint %35 %36 + %38 = OpBitcast %int %37 + %39 = OpBitcast %uint %32 + %40 = OpBitcast %uint %38 + %41 = OpIAdd %uint %39 %40 + %42 = OpBitcast %int %41 + OpStore %res %42 + %45 = OpLoad %int %res None + OpReturnValue %45 OpFunctionEnd -%compute_main = OpFunction %void None %32 - %33 = OpLabel - %34 = OpFunctionCall %int %dot_f1312c - %35 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 - OpStore %35 %34 None +%compute_main = OpFunction %void None %48 + %49 = OpLabel + %50 = OpFunctionCall %int %dot_f1312c + %51 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 + OpStore %51 %50 None OpReturn OpFunctionEnd ; @@ -144,7 +174,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 59 +; Bound: 74 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -180,18 +210,18 @@ %_ptr_Function_v3int = OpTypePointer Function %v3int %int_1 = OpConstant %int 1 %16 = OpConstantComposite %v3int %int_1 %int_1 %int_1 + %uint = OpTypeInt 32 0 %_ptr_Function_int = OpTypePointer Function %int %VertexOutput = OpTypeStruct %v4float %int - %37 = OpTypeFunction %VertexOutput + %53 = OpTypeFunction %VertexOutput %_ptr_Function_VertexOutput = OpTypePointer Function %VertexOutput - %41 = OpConstantNull %VertexOutput + %57 = OpConstantNull %VertexOutput %_ptr_Function_v4float = OpTypePointer Function %v4float - %uint = OpTypeInt 32 0 %uint_0 = OpConstant %uint 0 - %46 = OpConstantNull %v4float + %61 = OpConstantNull %v4float %uint_1 = OpConstant %uint 1 %void = OpTypeVoid - %53 = OpTypeFunction %void + %68 = OpTypeFunction %void %float_1 = OpConstant %float 1 %dot_f1312c = OpFunction %int None %11 %12 = OpLabel @@ -204,37 +234,52 @@ %20 = OpLoad %v3int %arg_1 None %21 = OpCompositeExtract %int %19 0 %22 = OpCompositeExtract %int %20 0 - %23 = OpIMul %int %21 %22 - %24 = OpCompositeExtract %int %19 1 - %25 = OpCompositeExtract %int %20 1 - %26 = OpIMul %int %24 %25 - %27 = OpIAdd %int %23 %26 - %28 = OpCompositeExtract %int %19 2 - %29 = OpCompositeExtract %int %20 2 - %30 = OpIMul %int %28 %29 - %31 = OpIAdd %int %27 %30 - OpStore %res %31 - %34 = OpLoad %int %res None - OpReturnValue %34 - OpFunctionEnd -%vertex_main_inner = OpFunction %VertexOutput None %37 - %38 = OpLabel - %out = OpVariable %_ptr_Function_VertexOutput Function %41 - %42 = OpAccessChain %_ptr_Function_v4float %out %uint_0 - OpStore %42 %46 None - %47 = OpAccessChain %_ptr_Function_int %out %uint_1 - %49 = OpFunctionCall %int %dot_f1312c - OpStore %47 %49 None - %50 = OpLoad %VertexOutput %out None + %24 = OpBitcast %uint %21 + %25 = OpBitcast %uint %22 + %26 = OpIMul %uint %24 %25 + %27 = OpBitcast %int %26 + %28 = OpCompositeExtract %int %19 1 + %29 = OpCompositeExtract %int %20 1 + %30 = OpBitcast %uint %28 + %31 = OpBitcast %uint %29 + %32 = OpIMul %uint %30 %31 + %33 = OpBitcast %int %32 + %34 = OpBitcast %uint %27 + %35 = OpBitcast %uint %33 + %36 = OpIAdd %uint %34 %35 + %37 = OpBitcast %int %36 + %38 = OpCompositeExtract %int %19 2 + %39 = OpCompositeExtract %int %20 2 + %40 = OpBitcast %uint %38 + %41 = OpBitcast %uint %39 + %42 = OpIMul %uint %40 %41 + %43 = OpBitcast %int %42 + %44 = OpBitcast %uint %37 + %45 = OpBitcast %uint %43 + %46 = OpIAdd %uint %44 %45 + %47 = OpBitcast %int %46 + OpStore %res %47 + %50 = OpLoad %int %res None OpReturnValue %50 OpFunctionEnd -%vertex_main = OpFunction %void None %53 +%vertex_main_inner = OpFunction %VertexOutput None %53 %54 = OpLabel - %55 = OpFunctionCall %VertexOutput %vertex_main_inner - %56 = OpCompositeExtract %v4float %55 0 - OpStore %vertex_main_position_Output %56 None - %57 = OpCompositeExtract %int %55 1 - OpStore %vertex_main_loc0_Output %57 None + %out = OpVariable %_ptr_Function_VertexOutput Function %57 + %58 = OpAccessChain %_ptr_Function_v4float %out %uint_0 + OpStore %58 %61 None + %62 = OpAccessChain %_ptr_Function_int %out %uint_1 + %64 = OpFunctionCall %int %dot_f1312c + OpStore %62 %64 None + %65 = OpLoad %VertexOutput %out None + OpReturnValue %65 + OpFunctionEnd +%vertex_main = OpFunction %void None %68 + %69 = OpLabel + %70 = OpFunctionCall %VertexOutput %vertex_main_inner + %71 = OpCompositeExtract %v4float %70 0 + OpStore %vertex_main_position_Output %71 None + %72 = OpCompositeExtract %int %70 1 + OpStore %vertex_main_loc0_Output %72 None OpStore %vertex_main___point_size_Output %float_1 None OpReturn OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/dot/fc5f7c.wgsl.expected.glsl b/test/tint/builtins/gen/var/dot/fc5f7c.wgsl.expected.glsl index 56f91e2..f0e4027 100644 --- a/test/tint/builtins/gen/var/dot/fc5f7c.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/dot/fc5f7c.wgsl.expected.glsl
@@ -10,7 +10,12 @@ int inner; } v; int tint_int_dot(ivec2 x, ivec2 y) { - return ((x.x * y.x) + (x.y * y.y)); + uint v_1 = uint(x.x); + int v_2 = int((v_1 * uint(y.x))); + uint v_3 = uint(x.y); + int v_4 = int((v_3 * uint(y.y))); + uint v_5 = uint(v_2); + return int((v_5 + uint(v_4))); } int dot_fc5f7c() { ivec2 arg_0 = ivec2(1); @@ -31,7 +36,12 @@ int inner; } v; int tint_int_dot(ivec2 x, ivec2 y) { - return ((x.x * y.x) + (x.y * y.y)); + uint v_1 = uint(x.x); + int v_2 = int((v_1 * uint(y.x))); + uint v_3 = uint(x.y); + int v_4 = int((v_3 * uint(y.y))); + uint v_5 = uint(v_2); + return int((v_5 + uint(v_4))); } int dot_fc5f7c() { ivec2 arg_0 = ivec2(1); @@ -56,7 +66,12 @@ layout(location = 0) flat out int tint_interstage_location0; int tint_int_dot(ivec2 x, ivec2 y) { - return ((x.x * y.x) + (x.y * y.y)); + uint v = uint(x.x); + int v_1 = int((v * uint(y.x))); + uint v_2 = uint(x.y); + int v_3 = int((v_2 * uint(y.y))); + uint v_4 = uint(v_1); + return int((v_4 + uint(v_3))); } int dot_fc5f7c() { ivec2 arg_0 = ivec2(1); @@ -65,14 +80,14 @@ return res; } VertexOutput vertex_main_inner() { - VertexOutput v = VertexOutput(vec4(0.0f), 0); - v.pos = vec4(0.0f); - v.prevent_dce = dot_fc5f7c(); - return v; + VertexOutput v_5 = VertexOutput(vec4(0.0f), 0); + v_5.pos = vec4(0.0f); + v_5.prevent_dce = dot_fc5f7c(); + return v_5; } void main() { - VertexOutput v_1 = vertex_main_inner(); - gl_Position = vec4(v_1.pos.x, -(v_1.pos.y), ((2.0f * v_1.pos.z) - v_1.pos.w), v_1.pos.w); - tint_interstage_location0 = v_1.prevent_dce; + VertexOutput v_6 = vertex_main_inner(); + gl_Position = vec4(v_6.pos.x, -(v_6.pos.y), ((2.0f * v_6.pos.z) - v_6.pos.w), v_6.pos.w); + tint_interstage_location0 = v_6.prevent_dce; gl_PointSize = 1.0f; }
diff --git a/test/tint/builtins/gen/var/dot/fc5f7c.wgsl.expected.msl b/test/tint/builtins/gen/var/dot/fc5f7c.wgsl.expected.msl index e8ae730..5a2f8c9 100644 --- a/test/tint/builtins/gen/var/dot/fc5f7c.wgsl.expected.msl +++ b/test/tint/builtins/gen/var/dot/fc5f7c.wgsl.expected.msl
@@ -9,7 +9,7 @@ }; int tint_dot(int2 lhs, int2 rhs) { - return ((lhs * rhs).x + (lhs * rhs).y); + return as_type<int>((as_type<uint>(as_type<int2>((as_type<uint2>(lhs) * as_type<uint2>(rhs))).x) + as_type<uint>(as_type<int2>((as_type<uint2>(lhs) * as_type<uint2>(rhs))).y))); } int dot_fc5f7c() { @@ -34,7 +34,7 @@ }; int tint_dot(int2 lhs, int2 rhs) { - return ((lhs * rhs).x + (lhs * rhs).y); + return as_type<int>((as_type<uint>(as_type<int2>((as_type<uint2>(lhs) * as_type<uint2>(rhs))).x) + as_type<uint>(as_type<int2>((as_type<uint2>(lhs) * as_type<uint2>(rhs))).y))); } int dot_fc5f7c() { @@ -65,7 +65,7 @@ }; int tint_dot(int2 lhs, int2 rhs) { - return ((lhs * rhs).x + (lhs * rhs).y); + return as_type<int>((as_type<uint>(as_type<int2>((as_type<uint2>(lhs) * as_type<uint2>(rhs))).x) + as_type<uint>(as_type<int2>((as_type<uint2>(lhs) * as_type<uint2>(rhs))).y))); } int dot_fc5f7c() {
diff --git a/test/tint/builtins/gen/var/dot/fc5f7c.wgsl.expected.spvasm b/test/tint/builtins/gen/var/dot/fc5f7c.wgsl.expected.spvasm index cec9f24..f8a63e2a 100644 --- a/test/tint/builtins/gen/var/dot/fc5f7c.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/var/dot/fc5f7c.wgsl.expected.spvasm
@@ -4,7 +4,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 35 +; Bound: 44 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -31,11 +31,11 @@ %_ptr_Function_v2int = OpTypePointer Function %v2int %int_1 = OpConstant %int 1 %11 = OpConstantComposite %v2int %int_1 %int_1 + %uint = OpTypeInt 32 0 %_ptr_Function_int = OpTypePointer Function %int %void = OpTypeVoid - %28 = OpTypeFunction %void + %38 = OpTypeFunction %void %_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int - %uint = OpTypeInt 32 0 %uint_0 = OpConstant %uint 0 %dot_fc5f7c = OpFunction %int None %6 %7 = OpLabel @@ -48,20 +48,29 @@ %15 = OpLoad %v2int %arg_1 None %16 = OpCompositeExtract %int %14 0 %17 = OpCompositeExtract %int %15 0 - %18 = OpIMul %int %16 %17 - %19 = OpCompositeExtract %int %14 1 - %20 = OpCompositeExtract %int %15 1 - %21 = OpIMul %int %19 %20 - %22 = OpIAdd %int %18 %21 - OpStore %res %22 - %25 = OpLoad %int %res None - OpReturnValue %25 + %19 = OpBitcast %uint %16 + %20 = OpBitcast %uint %17 + %21 = OpIMul %uint %19 %20 + %22 = OpBitcast %int %21 + %23 = OpCompositeExtract %int %14 1 + %24 = OpCompositeExtract %int %15 1 + %25 = OpBitcast %uint %23 + %26 = OpBitcast %uint %24 + %27 = OpIMul %uint %25 %26 + %28 = OpBitcast %int %27 + %29 = OpBitcast %uint %22 + %30 = OpBitcast %uint %28 + %31 = OpIAdd %uint %29 %30 + %32 = OpBitcast %int %31 + OpStore %res %32 + %35 = OpLoad %int %res None + OpReturnValue %35 OpFunctionEnd -%fragment_main = OpFunction %void None %28 - %29 = OpLabel - %30 = OpFunctionCall %int %dot_fc5f7c - %31 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 - OpStore %31 %30 None +%fragment_main = OpFunction %void None %38 + %39 = OpLabel + %40 = OpFunctionCall %int %dot_fc5f7c + %41 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 + OpStore %41 %40 None OpReturn OpFunctionEnd ; @@ -70,7 +79,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 35 +; Bound: 44 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -97,11 +106,11 @@ %_ptr_Function_v2int = OpTypePointer Function %v2int %int_1 = OpConstant %int 1 %11 = OpConstantComposite %v2int %int_1 %int_1 + %uint = OpTypeInt 32 0 %_ptr_Function_int = OpTypePointer Function %int %void = OpTypeVoid - %28 = OpTypeFunction %void + %38 = OpTypeFunction %void %_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int - %uint = OpTypeInt 32 0 %uint_0 = OpConstant %uint 0 %dot_fc5f7c = OpFunction %int None %6 %7 = OpLabel @@ -114,20 +123,29 @@ %15 = OpLoad %v2int %arg_1 None %16 = OpCompositeExtract %int %14 0 %17 = OpCompositeExtract %int %15 0 - %18 = OpIMul %int %16 %17 - %19 = OpCompositeExtract %int %14 1 - %20 = OpCompositeExtract %int %15 1 - %21 = OpIMul %int %19 %20 - %22 = OpIAdd %int %18 %21 - OpStore %res %22 - %25 = OpLoad %int %res None - OpReturnValue %25 + %19 = OpBitcast %uint %16 + %20 = OpBitcast %uint %17 + %21 = OpIMul %uint %19 %20 + %22 = OpBitcast %int %21 + %23 = OpCompositeExtract %int %14 1 + %24 = OpCompositeExtract %int %15 1 + %25 = OpBitcast %uint %23 + %26 = OpBitcast %uint %24 + %27 = OpIMul %uint %25 %26 + %28 = OpBitcast %int %27 + %29 = OpBitcast %uint %22 + %30 = OpBitcast %uint %28 + %31 = OpIAdd %uint %29 %30 + %32 = OpBitcast %int %31 + OpStore %res %32 + %35 = OpLoad %int %res None + OpReturnValue %35 OpFunctionEnd -%compute_main = OpFunction %void None %28 - %29 = OpLabel - %30 = OpFunctionCall %int %dot_fc5f7c - %31 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 - OpStore %31 %30 None +%compute_main = OpFunction %void None %38 + %39 = OpLabel + %40 = OpFunctionCall %int %dot_fc5f7c + %41 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 + OpStore %41 %40 None OpReturn OpFunctionEnd ; @@ -136,7 +154,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 55 +; Bound: 64 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -172,18 +190,18 @@ %_ptr_Function_v2int = OpTypePointer Function %v2int %int_1 = OpConstant %int 1 %16 = OpConstantComposite %v2int %int_1 %int_1 + %uint = OpTypeInt 32 0 %_ptr_Function_int = OpTypePointer Function %int %VertexOutput = OpTypeStruct %v4float %int - %33 = OpTypeFunction %VertexOutput + %43 = OpTypeFunction %VertexOutput %_ptr_Function_VertexOutput = OpTypePointer Function %VertexOutput - %37 = OpConstantNull %VertexOutput + %47 = OpConstantNull %VertexOutput %_ptr_Function_v4float = OpTypePointer Function %v4float - %uint = OpTypeInt 32 0 %uint_0 = OpConstant %uint 0 - %42 = OpConstantNull %v4float + %51 = OpConstantNull %v4float %uint_1 = OpConstant %uint 1 %void = OpTypeVoid - %49 = OpTypeFunction %void + %58 = OpTypeFunction %void %float_1 = OpConstant %float 1 %dot_fc5f7c = OpFunction %int None %11 %12 = OpLabel @@ -196,33 +214,42 @@ %20 = OpLoad %v2int %arg_1 None %21 = OpCompositeExtract %int %19 0 %22 = OpCompositeExtract %int %20 0 - %23 = OpIMul %int %21 %22 - %24 = OpCompositeExtract %int %19 1 - %25 = OpCompositeExtract %int %20 1 - %26 = OpIMul %int %24 %25 - %27 = OpIAdd %int %23 %26 - OpStore %res %27 - %30 = OpLoad %int %res None - OpReturnValue %30 + %24 = OpBitcast %uint %21 + %25 = OpBitcast %uint %22 + %26 = OpIMul %uint %24 %25 + %27 = OpBitcast %int %26 + %28 = OpCompositeExtract %int %19 1 + %29 = OpCompositeExtract %int %20 1 + %30 = OpBitcast %uint %28 + %31 = OpBitcast %uint %29 + %32 = OpIMul %uint %30 %31 + %33 = OpBitcast %int %32 + %34 = OpBitcast %uint %27 + %35 = OpBitcast %uint %33 + %36 = OpIAdd %uint %34 %35 + %37 = OpBitcast %int %36 + OpStore %res %37 + %40 = OpLoad %int %res None + OpReturnValue %40 OpFunctionEnd -%vertex_main_inner = OpFunction %VertexOutput None %33 - %34 = OpLabel - %out = OpVariable %_ptr_Function_VertexOutput Function %37 - %38 = OpAccessChain %_ptr_Function_v4float %out %uint_0 - OpStore %38 %42 None - %43 = OpAccessChain %_ptr_Function_int %out %uint_1 - %45 = OpFunctionCall %int %dot_fc5f7c - OpStore %43 %45 None - %46 = OpLoad %VertexOutput %out None - OpReturnValue %46 +%vertex_main_inner = OpFunction %VertexOutput None %43 + %44 = OpLabel + %out = OpVariable %_ptr_Function_VertexOutput Function %47 + %48 = OpAccessChain %_ptr_Function_v4float %out %uint_0 + OpStore %48 %51 None + %52 = OpAccessChain %_ptr_Function_int %out %uint_1 + %54 = OpFunctionCall %int %dot_fc5f7c + OpStore %52 %54 None + %55 = OpLoad %VertexOutput %out None + OpReturnValue %55 OpFunctionEnd -%vertex_main = OpFunction %void None %49 - %50 = OpLabel - %51 = OpFunctionCall %VertexOutput %vertex_main_inner - %52 = OpCompositeExtract %v4float %51 0 - OpStore %vertex_main_position_Output %52 None - %53 = OpCompositeExtract %int %51 1 - OpStore %vertex_main_loc0_Output %53 None +%vertex_main = OpFunction %void None %58 + %59 = OpLabel + %60 = OpFunctionCall %VertexOutput %vertex_main_inner + %61 = OpCompositeExtract %v4float %60 0 + OpStore %vertex_main_position_Output %61 None + %62 = OpCompositeExtract %int %60 1 + OpStore %vertex_main_loc0_Output %62 None OpStore %vertex_main___point_size_Output %float_1 None OpReturn OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/dot4I8Packed/881e62.wgsl.expected.glsl b/test/tint/builtins/gen/var/dot4I8Packed/881e62.wgsl.expected.glsl index 6ed2904..b97ac29 100644 --- a/test/tint/builtins/gen/var/dot4I8Packed/881e62.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/dot4I8Packed/881e62.wgsl.expected.glsl
@@ -10,19 +10,32 @@ int inner; } v; int tint_int_dot(ivec4 x, ivec4 y) { - return ((((x.x * y.x) + (x.y * y.y)) + (x.z * y.z)) + (x.w * y.w)); + uint v_1 = uint(x.x); + int v_2 = int((v_1 * uint(y.x))); + uint v_3 = uint(x.y); + int v_4 = int((v_3 * uint(y.y))); + uint v_5 = uint(v_2); + int v_6 = int((v_5 + uint(v_4))); + uint v_7 = uint(x.z); + int v_8 = int((v_7 * uint(y.z))); + uint v_9 = uint(v_6); + int v_10 = int((v_9 + uint(v_8))); + uint v_11 = uint(x.w); + int v_12 = int((v_11 * uint(y.w))); + uint v_13 = uint(v_10); + return int((v_13 + uint(v_12))); } int dot4I8Packed_881e62() { uint arg_0 = 1u; uint arg_1 = 1u; - uint v_1 = arg_0; - uint v_2 = arg_1; - uvec4 v_3 = uvec4(24u, 16u, 8u, 0u); - ivec4 v_4 = ivec4((uvec4(v_1) << v_3)); - ivec4 v_5 = (v_4 >> uvec4(24u)); - uvec4 v_6 = uvec4(24u, 16u, 8u, 0u); - ivec4 v_7 = ivec4((uvec4(v_2) << v_6)); - int res = tint_int_dot(v_5, (v_7 >> uvec4(24u))); + uint v_14 = arg_0; + uint v_15 = arg_1; + uvec4 v_16 = uvec4(24u, 16u, 8u, 0u); + ivec4 v_17 = ivec4((uvec4(v_14) << v_16)); + ivec4 v_18 = (v_17 >> uvec4(24u)); + uvec4 v_19 = uvec4(24u, 16u, 8u, 0u); + ivec4 v_20 = ivec4((uvec4(v_15) << v_19)); + int res = tint_int_dot(v_18, (v_20 >> uvec4(24u))); return res; } void main() { @@ -38,19 +51,32 @@ int inner; } v; int tint_int_dot(ivec4 x, ivec4 y) { - return ((((x.x * y.x) + (x.y * y.y)) + (x.z * y.z)) + (x.w * y.w)); + uint v_1 = uint(x.x); + int v_2 = int((v_1 * uint(y.x))); + uint v_3 = uint(x.y); + int v_4 = int((v_3 * uint(y.y))); + uint v_5 = uint(v_2); + int v_6 = int((v_5 + uint(v_4))); + uint v_7 = uint(x.z); + int v_8 = int((v_7 * uint(y.z))); + uint v_9 = uint(v_6); + int v_10 = int((v_9 + uint(v_8))); + uint v_11 = uint(x.w); + int v_12 = int((v_11 * uint(y.w))); + uint v_13 = uint(v_10); + return int((v_13 + uint(v_12))); } int dot4I8Packed_881e62() { uint arg_0 = 1u; uint arg_1 = 1u; - uint v_1 = arg_0; - uint v_2 = arg_1; - uvec4 v_3 = uvec4(24u, 16u, 8u, 0u); - ivec4 v_4 = ivec4((uvec4(v_1) << v_3)); - ivec4 v_5 = (v_4 >> uvec4(24u)); - uvec4 v_6 = uvec4(24u, 16u, 8u, 0u); - ivec4 v_7 = ivec4((uvec4(v_2) << v_6)); - int res = tint_int_dot(v_5, (v_7 >> uvec4(24u))); + uint v_14 = arg_0; + uint v_15 = arg_1; + uvec4 v_16 = uvec4(24u, 16u, 8u, 0u); + ivec4 v_17 = ivec4((uvec4(v_14) << v_16)); + ivec4 v_18 = (v_17 >> uvec4(24u)); + uvec4 v_19 = uvec4(24u, 16u, 8u, 0u); + ivec4 v_20 = ivec4((uvec4(v_15) << v_19)); + int res = tint_int_dot(v_18, (v_20 >> uvec4(24u))); return res; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; @@ -70,30 +96,43 @@ layout(location = 0) flat out int tint_interstage_location0; int tint_int_dot(ivec4 x, ivec4 y) { - return ((((x.x * y.x) + (x.y * y.y)) + (x.z * y.z)) + (x.w * y.w)); + uint v = uint(x.x); + int v_1 = int((v * uint(y.x))); + uint v_2 = uint(x.y); + int v_3 = int((v_2 * uint(y.y))); + uint v_4 = uint(v_1); + int v_5 = int((v_4 + uint(v_3))); + uint v_6 = uint(x.z); + int v_7 = int((v_6 * uint(y.z))); + uint v_8 = uint(v_5); + int v_9 = int((v_8 + uint(v_7))); + uint v_10 = uint(x.w); + int v_11 = int((v_10 * uint(y.w))); + uint v_12 = uint(v_9); + return int((v_12 + uint(v_11))); } int dot4I8Packed_881e62() { uint arg_0 = 1u; uint arg_1 = 1u; - uint v = arg_0; - uint v_1 = arg_1; - uvec4 v_2 = uvec4(24u, 16u, 8u, 0u); - ivec4 v_3 = ivec4((uvec4(v) << v_2)); - ivec4 v_4 = (v_3 >> uvec4(24u)); - uvec4 v_5 = uvec4(24u, 16u, 8u, 0u); - ivec4 v_6 = ivec4((uvec4(v_1) << v_5)); - int res = tint_int_dot(v_4, (v_6 >> uvec4(24u))); + uint v_13 = arg_0; + uint v_14 = arg_1; + uvec4 v_15 = uvec4(24u, 16u, 8u, 0u); + ivec4 v_16 = ivec4((uvec4(v_13) << v_15)); + ivec4 v_17 = (v_16 >> uvec4(24u)); + uvec4 v_18 = uvec4(24u, 16u, 8u, 0u); + ivec4 v_19 = ivec4((uvec4(v_14) << v_18)); + int res = tint_int_dot(v_17, (v_19 >> uvec4(24u))); return res; } VertexOutput vertex_main_inner() { - VertexOutput v_7 = VertexOutput(vec4(0.0f), 0); - v_7.pos = vec4(0.0f); - v_7.prevent_dce = dot4I8Packed_881e62(); - return v_7; + VertexOutput v_20 = VertexOutput(vec4(0.0f), 0); + v_20.pos = vec4(0.0f); + v_20.prevent_dce = dot4I8Packed_881e62(); + return v_20; } void main() { - VertexOutput v_8 = vertex_main_inner(); - gl_Position = vec4(v_8.pos.x, -(v_8.pos.y), ((2.0f * v_8.pos.z) - v_8.pos.w), v_8.pos.w); - tint_interstage_location0 = v_8.prevent_dce; + VertexOutput v_21 = vertex_main_inner(); + gl_Position = vec4(v_21.pos.x, -(v_21.pos.y), ((2.0f * v_21.pos.z) - v_21.pos.w), v_21.pos.w); + tint_interstage_location0 = v_21.prevent_dce; gl_PointSize = 1.0f; }
diff --git a/test/tint/builtins/gen/var/dot4I8Packed/881e62.wgsl.expected.msl b/test/tint/builtins/gen/var/dot4I8Packed/881e62.wgsl.expected.msl index a62c622..e5af3a5 100644 --- a/test/tint/builtins/gen/var/dot4I8Packed/881e62.wgsl.expected.msl +++ b/test/tint/builtins/gen/var/dot4I8Packed/881e62.wgsl.expected.msl
@@ -9,7 +9,7 @@ }; int tint_dot(int4 lhs, int4 rhs) { - return ((((lhs * rhs).x + (lhs * rhs).y) + (lhs * rhs).z) + (lhs * rhs).w); + return as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(as_type<int4>((as_type<uint4>(lhs) * as_type<uint4>(rhs))).x) + as_type<uint>(as_type<int4>((as_type<uint4>(lhs) * as_type<uint4>(rhs))).y)))) + as_type<uint>(as_type<int4>((as_type<uint4>(lhs) * as_type<uint4>(rhs))).z)))) + as_type<uint>(as_type<int4>((as_type<uint4>(lhs) * as_type<uint4>(rhs))).w))); } int dot4I8Packed_881e62() { @@ -41,7 +41,7 @@ }; int tint_dot(int4 lhs, int4 rhs) { - return ((((lhs * rhs).x + (lhs * rhs).y) + (lhs * rhs).z) + (lhs * rhs).w); + return as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(as_type<int4>((as_type<uint4>(lhs) * as_type<uint4>(rhs))).x) + as_type<uint>(as_type<int4>((as_type<uint4>(lhs) * as_type<uint4>(rhs))).y)))) + as_type<uint>(as_type<int4>((as_type<uint4>(lhs) * as_type<uint4>(rhs))).z)))) + as_type<uint>(as_type<int4>((as_type<uint4>(lhs) * as_type<uint4>(rhs))).w))); } int dot4I8Packed_881e62() { @@ -79,7 +79,7 @@ }; int tint_dot(int4 lhs, int4 rhs) { - return ((((lhs * rhs).x + (lhs * rhs).y) + (lhs * rhs).z) + (lhs * rhs).w); + return as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(as_type<int>((as_type<uint>(as_type<int4>((as_type<uint4>(lhs) * as_type<uint4>(rhs))).x) + as_type<uint>(as_type<int4>((as_type<uint4>(lhs) * as_type<uint4>(rhs))).y)))) + as_type<uint>(as_type<int4>((as_type<uint4>(lhs) * as_type<uint4>(rhs))).z)))) + as_type<uint>(as_type<int4>((as_type<uint4>(lhs) * as_type<uint4>(rhs))).w))); } int dot4I8Packed_881e62() {
diff --git a/test/tint/builtins/workgroupUniformLoad/for_loop.wgsl.expected.glsl b/test/tint/builtins/workgroupUniformLoad/for_loop.wgsl.expected.glsl index 9768621..3b1aecc 100644 --- a/test/tint/builtins/workgroupUniformLoad/for_loop.wgsl.expected.glsl +++ b/test/tint/builtins/workgroupUniformLoad/for_loop.wgsl.expected.glsl
@@ -26,7 +26,8 @@ barrier(); int v_2 = b; barrier(); - i = (i + v_2); + uint v_3 = uint(i); + i = int((v_3 + uint(v_2))); } continue; }
diff --git a/test/tint/builtins/workgroupUniformLoad/for_loop.wgsl.expected.spvasm b/test/tint/builtins/workgroupUniformLoad/for_loop.wgsl.expected.spvasm index 4cb0020..51145ac 100644 --- a/test/tint/builtins/workgroupUniformLoad/for_loop.wgsl.expected.spvasm +++ b/test/tint/builtins/workgroupUniformLoad/for_loop.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 60 +; Bound: 63 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -85,13 +85,16 @@ %54 = OpLoad %int %b None OpControlBarrier %uint_2 %uint_2 %uint_264 %56 = OpLoad %int %i None - %57 = OpIAdd %int %56 %54 - OpStore %i %57 None + %57 = OpBitcast %uint %56 + %58 = OpBitcast %uint %54 + %59 = OpIAdd %uint %57 %58 + %60 = OpBitcast %int %59 + OpStore %i %60 None OpBranch %12 %13 = OpLabel OpReturn OpFunctionEnd %unused_entry_point = OpFunction %void None %7 - %59 = OpLabel + %62 = OpLabel OpReturn OpFunctionEnd
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 5e3a0d2..4c2e5a7 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
@@ -4,5 +4,6 @@ void main() { int a = 1; int b = 2; - int r = (a + b); + uint v = uint(a); + int r = int((v + uint(b))); }
diff --git a/test/tint/expressions/binary/add/scalar-scalar/i32.wgsl.expected.spvasm b/test/tint/expressions/binary/add/scalar-scalar/i32.wgsl.expected.spvasm index 821ab06..d2570cf 100644 --- a/test/tint/expressions/binary/add/scalar-scalar/i32.wgsl.expected.spvasm +++ b/test/tint/expressions/binary/add/scalar-scalar/i32.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 9 +; Bound: 13 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -16,8 +16,12 @@ %int = OpTypeInt 32 1 %a = OpConstant %int 1 %b = OpConstant %int 2 + %uint = OpTypeInt 32 0 %f = OpFunction %void None %3 %4 = OpLabel - %r = OpIAdd %int %a %b + %9 = OpBitcast %uint %a + %10 = OpBitcast %uint %b + %11 = OpIAdd %uint %9 %10 + %r = OpBitcast %int %11 OpReturn OpFunctionEnd
diff --git a/test/tint/expressions/binary/add/scalar-vec3/i32.wgsl.expected.glsl b/test/tint/expressions/binary/add/scalar-vec3/i32.wgsl.expected.glsl index 50e268c..771c019 100644 --- a/test/tint/expressions/binary/add/scalar-vec3/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/add/scalar-vec3/i32.wgsl.expected.glsl
@@ -4,5 +4,6 @@ void main() { int a = 4; ivec3 b = ivec3(1, 2, 3); - ivec3 r = (a + b); + uint v = uint(a); + ivec3 r = ivec3((v + uvec3(b))); }
diff --git a/test/tint/expressions/binary/add/scalar-vec3/i32.wgsl.expected.spvasm b/test/tint/expressions/binary/add/scalar-vec3/i32.wgsl.expected.spvasm index 8e29b0f..9df6313 100644 --- a/test/tint/expressions/binary/add/scalar-vec3/i32.wgsl.expected.spvasm +++ b/test/tint/expressions/binary/add/scalar-vec3/i32.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 14 +; Bound: 19 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -20,9 +20,14 @@ %int_2 = OpConstant %int 2 %int_3 = OpConstant %int 3 %b = OpConstantComposite %v3int %int_1 %int_2 %int_3 + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 %f = OpFunction %void None %3 %4 = OpLabel %12 = OpCompositeConstruct %v3int %a %a %a - %r = OpIAdd %v3int %12 %b + %15 = OpBitcast %v3uint %12 + %16 = OpBitcast %v3uint %b + %17 = OpIAdd %v3uint %15 %16 + %r = OpBitcast %v3int %17 OpReturn OpFunctionEnd
diff --git a/test/tint/expressions/binary/add/vec3-scalar/i32.wgsl.expected.glsl b/test/tint/expressions/binary/add/vec3-scalar/i32.wgsl.expected.glsl index 594226f..7b9314f 100644 --- a/test/tint/expressions/binary/add/vec3-scalar/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/add/vec3-scalar/i32.wgsl.expected.glsl
@@ -4,5 +4,6 @@ void main() { ivec3 a = ivec3(1, 2, 3); int b = 4; - ivec3 r = (a + b); + uvec3 v = uvec3(a); + ivec3 r = ivec3((v + uint(b))); }
diff --git a/test/tint/expressions/binary/add/vec3-scalar/i32.wgsl.expected.spvasm b/test/tint/expressions/binary/add/vec3-scalar/i32.wgsl.expected.spvasm index d527eba..31246a4 100644 --- a/test/tint/expressions/binary/add/vec3-scalar/i32.wgsl.expected.spvasm +++ b/test/tint/expressions/binary/add/vec3-scalar/i32.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 14 +; Bound: 19 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -20,9 +20,14 @@ %int_3 = OpConstant %int 3 %a = OpConstantComposite %v3int %int_1 %int_2 %int_3 %b = OpConstant %int 4 + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 %f = OpFunction %void None %3 %4 = OpLabel %12 = OpCompositeConstruct %v3int %b %b %b - %r = OpIAdd %v3int %a %12 + %15 = OpBitcast %v3uint %a + %16 = OpBitcast %v3uint %12 + %17 = OpIAdd %v3uint %15 %16 + %r = OpBitcast %v3int %17 OpReturn OpFunctionEnd
diff --git a/test/tint/expressions/binary/add/vec3-vec3/i32.wgsl.expected.glsl b/test/tint/expressions/binary/add/vec3-vec3/i32.wgsl.expected.glsl index f6c5bc2..78a6c92 100644 --- a/test/tint/expressions/binary/add/vec3-vec3/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/add/vec3-vec3/i32.wgsl.expected.glsl
@@ -4,5 +4,6 @@ void main() { ivec3 a = ivec3(1, 2, 3); ivec3 b = ivec3(4, 5, 6); - ivec3 r = (a + b); + uvec3 v = uvec3(a); + ivec3 r = ivec3((v + uvec3(b))); }
diff --git a/test/tint/expressions/binary/add/vec3-vec3/i32.wgsl.expected.spvasm b/test/tint/expressions/binary/add/vec3-vec3/i32.wgsl.expected.spvasm index afe2c6a..91771ab 100644 --- a/test/tint/expressions/binary/add/vec3-vec3/i32.wgsl.expected.spvasm +++ b/test/tint/expressions/binary/add/vec3-vec3/i32.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 16 +; Bound: 21 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -23,8 +23,13 @@ %int_5 = OpConstant %int 5 %int_6 = OpConstant %int 6 %b = OpConstantComposite %v3int %int_4 %int_5 %int_6 + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 %f = OpFunction %void None %3 %4 = OpLabel - %r = OpIAdd %v3int %a %b + %17 = OpBitcast %v3uint %a + %18 = OpBitcast %v3uint %b + %19 = OpIAdd %v3uint %17 %18 + %r = OpBitcast %v3int %19 OpReturn OpFunctionEnd
diff --git a/test/tint/expressions/binary/div_by_zero/by_expression/scalar-scalar/i32.wgsl.expected.glsl b/test/tint/expressions/binary/div_by_zero/by_expression/scalar-scalar/i32.wgsl.expected.glsl index f6dfde1..6572c96 100644 --- a/test/tint/expressions/binary/div_by_zero/by_expression/scalar-scalar/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/div_by_zero/by_expression/scalar-scalar/i32.wgsl.expected.glsl
@@ -10,5 +10,8 @@ void main() { int a = 1; int b = 0; - int r = tint_div_i32(a, (b + b)); + int v_3 = a; + int v_4 = b; + uint v_5 = uint(b); + int r = tint_div_i32(v_3, int((v_5 + uint(v_4)))); }
diff --git a/test/tint/expressions/binary/div_by_zero/by_expression/scalar-scalar/i32.wgsl.expected.spvasm b/test/tint/expressions/binary/div_by_zero/by_expression/scalar-scalar/i32.wgsl.expected.spvasm index 89db611..c15cdd0 100644 --- a/test/tint/expressions/binary/div_by_zero/by_expression/scalar-scalar/i32.wgsl.expected.spvasm +++ b/test/tint/expressions/binary/div_by_zero/by_expression/scalar-scalar/i32.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 31 +; Bound: 35 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -20,7 +20,8 @@ %_ptr_Function_int = OpTypePointer Function %int %int_1 = OpConstant %int 1 %int_0 = OpConstant %int 0 - %19 = OpTypeFunction %int %int %int + %uint = OpTypeInt 32 0 + %23 = OpTypeFunction %int %int %int %bool = OpTypeBool %int_n2147483648 = OpConstant %int -2147483648 %int_n1 = OpConstant %int -1 @@ -33,20 +34,23 @@ %11 = OpLoad %int %a None %12 = OpLoad %int %b None %13 = OpLoad %int %b None - %14 = OpIAdd %int %12 %13 - %r = OpFunctionCall %int %tint_div_i32 %11 %14 + %15 = OpBitcast %uint %12 + %16 = OpBitcast %uint %13 + %17 = OpIAdd %uint %15 %16 + %18 = OpBitcast %int %17 + %r = OpFunctionCall %int %tint_div_i32 %11 %18 OpReturn OpFunctionEnd -%tint_div_i32 = OpFunction %int None %19 +%tint_div_i32 = OpFunction %int None %23 %lhs = OpFunctionParameter %int %rhs = OpFunctionParameter %int - %20 = OpLabel - %21 = OpIEqual %bool %rhs %int_0 - %23 = OpIEqual %bool %lhs %int_n2147483648 - %25 = OpIEqual %bool %rhs %int_n1 - %27 = OpLogicalAnd %bool %23 %25 - %28 = OpLogicalOr %bool %21 %27 - %29 = OpSelect %int %28 %int_1 %rhs - %30 = OpSDiv %int %lhs %29 - OpReturnValue %30 + %24 = OpLabel + %25 = OpIEqual %bool %rhs %int_0 + %27 = OpIEqual %bool %lhs %int_n2147483648 + %29 = OpIEqual %bool %rhs %int_n1 + %31 = OpLogicalAnd %bool %27 %29 + %32 = OpLogicalOr %bool %25 %31 + %33 = OpSelect %int %32 %int_1 %rhs + %34 = OpSDiv %int %lhs %33 + OpReturnValue %34 OpFunctionEnd
diff --git a/test/tint/expressions/binary/div_by_zero/by_expression/scalar-vec3/i32.wgsl.expected.glsl b/test/tint/expressions/binary/div_by_zero/by_expression/scalar-vec3/i32.wgsl.expected.glsl index 545b393..c73572b 100644 --- a/test/tint/expressions/binary/div_by_zero/by_expression/scalar-vec3/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/div_by_zero/by_expression/scalar-vec3/i32.wgsl.expected.glsl
@@ -10,6 +10,9 @@ void main() { int a = 4; ivec3 b = ivec3(0, 2, 0); - ivec3 v_3 = (b + b); - ivec3 r = tint_div_v3i32(ivec3(a), v_3); + int v_3 = a; + ivec3 v_4 = b; + uvec3 v_5 = uvec3(b); + ivec3 v_6 = ivec3((v_5 + uvec3(v_4))); + ivec3 r = tint_div_v3i32(ivec3(v_3), v_6); }
diff --git a/test/tint/expressions/binary/div_by_zero/by_expression/scalar-vec3/i32.wgsl.expected.spvasm b/test/tint/expressions/binary/div_by_zero/by_expression/scalar-vec3/i32.wgsl.expected.spvasm index 864f584..15619f1 100644 --- a/test/tint/expressions/binary/div_by_zero/by_expression/scalar-vec3/i32.wgsl.expected.spvasm +++ b/test/tint/expressions/binary/div_by_zero/by_expression/scalar-vec3/i32.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 42 +; Bound: 47 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -24,16 +24,18 @@ %int_0 = OpConstant %int 0 %int_2 = OpConstant %int 2 %12 = OpConstantComposite %v3int %int_0 %int_2 %int_0 - %24 = OpTypeFunction %v3int %v3int %v3int - %27 = OpConstantNull %v3int + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 + %29 = OpTypeFunction %v3int %v3int %v3int + %32 = OpConstantNull %v3int %bool = OpTypeBool %v3bool = OpTypeVector %bool 3 %int_n2147483648 = OpConstant %int -2147483648 - %31 = OpConstantComposite %v3int %int_n2147483648 %int_n2147483648 %int_n2147483648 + %36 = OpConstantComposite %v3int %int_n2147483648 %int_n2147483648 %int_n2147483648 %int_n1 = OpConstant %int -1 - %34 = OpConstantComposite %v3int %int_n1 %int_n1 %int_n1 + %39 = OpConstantComposite %v3int %int_n1 %int_n1 %int_n1 %int_1 = OpConstant %int 1 - %39 = OpConstantComposite %v3int %int_1 %int_1 %int_1 + %44 = OpConstantComposite %v3int %int_1 %int_1 %int_1 %f = OpFunction %void None %3 %4 = OpLabel %a = OpVariable %_ptr_Function_int Function @@ -43,21 +45,24 @@ %15 = OpLoad %int %a None %16 = OpLoad %v3int %b None %17 = OpLoad %v3int %b None - %18 = OpIAdd %v3int %16 %17 - %19 = OpCompositeConstruct %v3int %15 %15 %15 - %r = OpFunctionCall %v3int %tint_div_v3i32 %19 %18 + %20 = OpBitcast %v3uint %16 + %21 = OpBitcast %v3uint %17 + %22 = OpIAdd %v3uint %20 %21 + %23 = OpBitcast %v3int %22 + %24 = OpCompositeConstruct %v3int %15 %15 %15 + %r = OpFunctionCall %v3int %tint_div_v3i32 %24 %23 OpReturn OpFunctionEnd -%tint_div_v3i32 = OpFunction %v3int None %24 +%tint_div_v3i32 = OpFunction %v3int None %29 %lhs = OpFunctionParameter %v3int %rhs = OpFunctionParameter %v3int - %25 = OpLabel - %26 = OpIEqual %v3bool %rhs %27 - %30 = OpIEqual %v3bool %lhs %31 - %33 = OpIEqual %v3bool %rhs %34 - %36 = OpLogicalAnd %v3bool %30 %33 - %37 = OpLogicalOr %v3bool %26 %36 - %38 = OpSelect %v3int %37 %39 %rhs - %41 = OpSDiv %v3int %lhs %38 - OpReturnValue %41 + %30 = OpLabel + %31 = OpIEqual %v3bool %rhs %32 + %35 = OpIEqual %v3bool %lhs %36 + %38 = OpIEqual %v3bool %rhs %39 + %41 = OpLogicalAnd %v3bool %35 %38 + %42 = OpLogicalOr %v3bool %31 %41 + %43 = OpSelect %v3int %42 %44 %rhs + %46 = OpSDiv %v3int %lhs %43 + OpReturnValue %46 OpFunctionEnd
diff --git a/test/tint/expressions/binary/div_by_zero/by_expression/vec3-scalar/i32.wgsl.expected.glsl b/test/tint/expressions/binary/div_by_zero/by_expression/vec3-scalar/i32.wgsl.expected.glsl index 4bb5cc0..ad05090 100644 --- a/test/tint/expressions/binary/div_by_zero/by_expression/vec3-scalar/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/div_by_zero/by_expression/vec3-scalar/i32.wgsl.expected.glsl
@@ -11,5 +11,7 @@ ivec3 a = ivec3(1, 2, 3); int b = 0; ivec3 v_3 = a; - ivec3 r = tint_div_v3i32(v_3, ivec3((b + b))); + int v_4 = b; + uint v_5 = uint(b); + ivec3 r = tint_div_v3i32(v_3, ivec3(int((v_5 + uint(v_4))))); }
diff --git a/test/tint/expressions/binary/div_by_zero/by_expression/vec3-scalar/i32.wgsl.expected.spvasm b/test/tint/expressions/binary/div_by_zero/by_expression/vec3-scalar/i32.wgsl.expected.spvasm index a8f86a9..773753d 100644 --- a/test/tint/expressions/binary/div_by_zero/by_expression/vec3-scalar/i32.wgsl.expected.spvasm +++ b/test/tint/expressions/binary/div_by_zero/by_expression/vec3-scalar/i32.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 42 +; Bound: 46 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -25,15 +25,16 @@ %9 = OpConstantComposite %v3int %int_1 %int_2 %int_3 %_ptr_Function_int = OpTypePointer Function %int %int_0 = OpConstant %int 0 - %25 = OpTypeFunction %v3int %v3int %v3int - %28 = OpConstantNull %v3int + %uint = OpTypeInt 32 0 + %29 = OpTypeFunction %v3int %v3int %v3int + %32 = OpConstantNull %v3int %bool = OpTypeBool %v3bool = OpTypeVector %bool 3 %int_n2147483648 = OpConstant %int -2147483648 - %32 = OpConstantComposite %v3int %int_n2147483648 %int_n2147483648 %int_n2147483648 + %36 = OpConstantComposite %v3int %int_n2147483648 %int_n2147483648 %int_n2147483648 %int_n1 = OpConstant %int -1 - %35 = OpConstantComposite %v3int %int_n1 %int_n1 %int_n1 - %40 = OpConstantComposite %v3int %int_1 %int_1 %int_1 + %39 = OpConstantComposite %v3int %int_n1 %int_n1 %int_n1 + %44 = OpConstantComposite %v3int %int_1 %int_1 %int_1 %f = OpFunction %void None %3 %4 = OpLabel %a = OpVariable %_ptr_Function_v3int Function @@ -43,21 +44,24 @@ %16 = OpLoad %v3int %a None %17 = OpLoad %int %b None %18 = OpLoad %int %b None - %19 = OpIAdd %int %17 %18 - %20 = OpCompositeConstruct %v3int %19 %19 %19 - %r = OpFunctionCall %v3int %tint_div_v3i32 %16 %20 + %20 = OpBitcast %uint %17 + %21 = OpBitcast %uint %18 + %22 = OpIAdd %uint %20 %21 + %23 = OpBitcast %int %22 + %24 = OpCompositeConstruct %v3int %23 %23 %23 + %r = OpFunctionCall %v3int %tint_div_v3i32 %16 %24 OpReturn OpFunctionEnd -%tint_div_v3i32 = OpFunction %v3int None %25 +%tint_div_v3i32 = OpFunction %v3int None %29 %lhs = OpFunctionParameter %v3int %rhs = OpFunctionParameter %v3int - %26 = OpLabel - %27 = OpIEqual %v3bool %rhs %28 - %31 = OpIEqual %v3bool %lhs %32 - %34 = OpIEqual %v3bool %rhs %35 - %37 = OpLogicalAnd %v3bool %31 %34 - %38 = OpLogicalOr %v3bool %27 %37 - %39 = OpSelect %v3int %38 %40 %rhs - %41 = OpSDiv %v3int %lhs %39 - OpReturnValue %41 + %30 = OpLabel + %31 = OpIEqual %v3bool %rhs %32 + %35 = OpIEqual %v3bool %lhs %36 + %38 = OpIEqual %v3bool %rhs %39 + %41 = OpLogicalAnd %v3bool %35 %38 + %42 = OpLogicalOr %v3bool %31 %41 + %43 = OpSelect %v3int %42 %44 %rhs + %45 = OpSDiv %v3int %lhs %43 + OpReturnValue %45 OpFunctionEnd
diff --git a/test/tint/expressions/binary/div_by_zero/by_expression/vec3-vec3/i32.wgsl.expected.glsl b/test/tint/expressions/binary/div_by_zero/by_expression/vec3-vec3/i32.wgsl.expected.glsl index 50c8c1d..355e798 100644 --- a/test/tint/expressions/binary/div_by_zero/by_expression/vec3-vec3/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/div_by_zero/by_expression/vec3-vec3/i32.wgsl.expected.glsl
@@ -10,5 +10,8 @@ void main() { ivec3 a = ivec3(1, 2, 3); ivec3 b = ivec3(0, 5, 0); - ivec3 r = tint_div_v3i32(a, (b + b)); + ivec3 v_3 = a; + ivec3 v_4 = b; + uvec3 v_5 = uvec3(b); + ivec3 r = tint_div_v3i32(v_3, ivec3((v_5 + uvec3(v_4)))); }
diff --git a/test/tint/expressions/binary/div_by_zero/by_expression/vec3-vec3/i32.wgsl.expected.spvasm b/test/tint/expressions/binary/div_by_zero/by_expression/vec3-vec3/i32.wgsl.expected.spvasm index 234faca..0bc0bf3 100644 --- a/test/tint/expressions/binary/div_by_zero/by_expression/vec3-vec3/i32.wgsl.expected.spvasm +++ b/test/tint/expressions/binary/div_by_zero/by_expression/vec3-vec3/i32.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 42 +; Bound: 47 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -26,15 +26,17 @@ %int_0 = OpConstant %int 0 %int_5 = OpConstant %int 5 %14 = OpConstantComposite %v3int %int_0 %int_5 %int_0 - %25 = OpTypeFunction %v3int %v3int %v3int - %28 = OpConstantNull %v3int + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 + %30 = OpTypeFunction %v3int %v3int %v3int + %33 = OpConstantNull %v3int %bool = OpTypeBool %v3bool = OpTypeVector %bool 3 %int_n2147483648 = OpConstant %int -2147483648 - %32 = OpConstantComposite %v3int %int_n2147483648 %int_n2147483648 %int_n2147483648 + %37 = OpConstantComposite %v3int %int_n2147483648 %int_n2147483648 %int_n2147483648 %int_n1 = OpConstant %int -1 - %35 = OpConstantComposite %v3int %int_n1 %int_n1 %int_n1 - %40 = OpConstantComposite %v3int %int_1 %int_1 %int_1 + %40 = OpConstantComposite %v3int %int_n1 %int_n1 %int_n1 + %45 = OpConstantComposite %v3int %int_1 %int_1 %int_1 %f = OpFunction %void None %3 %4 = OpLabel %a = OpVariable %_ptr_Function_v3int Function @@ -44,20 +46,23 @@ %17 = OpLoad %v3int %a None %18 = OpLoad %v3int %b None %19 = OpLoad %v3int %b None - %20 = OpIAdd %v3int %18 %19 - %r = OpFunctionCall %v3int %tint_div_v3i32 %17 %20 + %22 = OpBitcast %v3uint %18 + %23 = OpBitcast %v3uint %19 + %24 = OpIAdd %v3uint %22 %23 + %25 = OpBitcast %v3int %24 + %r = OpFunctionCall %v3int %tint_div_v3i32 %17 %25 OpReturn OpFunctionEnd -%tint_div_v3i32 = OpFunction %v3int None %25 +%tint_div_v3i32 = OpFunction %v3int None %30 %lhs = OpFunctionParameter %v3int %rhs = OpFunctionParameter %v3int - %26 = OpLabel - %27 = OpIEqual %v3bool %rhs %28 - %31 = OpIEqual %v3bool %lhs %32 - %34 = OpIEqual %v3bool %rhs %35 - %37 = OpLogicalAnd %v3bool %31 %34 - %38 = OpLogicalOr %v3bool %27 %37 - %39 = OpSelect %v3int %38 %40 %rhs - %41 = OpSDiv %v3int %lhs %39 - OpReturnValue %41 + %31 = OpLabel + %32 = OpIEqual %v3bool %rhs %33 + %36 = OpIEqual %v3bool %lhs %37 + %39 = OpIEqual %v3bool %rhs %40 + %42 = OpLogicalAnd %v3bool %36 %39 + %43 = OpLogicalOr %v3bool %32 %42 + %44 = OpSelect %v3int %43 %45 %rhs + %46 = OpSDiv %v3int %lhs %44 + OpReturnValue %46 OpFunctionEnd
diff --git a/test/tint/expressions/binary/left-shift/scalar-scalar/i32.wgsl.expected.glsl b/test/tint/expressions/binary/left-shift/scalar-scalar/i32.wgsl.expected.glsl index 02827a8..55d5d6e 100644 --- a/test/tint/expressions/binary/left-shift/scalar-scalar/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/left-shift/scalar-scalar/i32.wgsl.expected.glsl
@@ -4,5 +4,5 @@ void main() { int a = 1; uint b = 2u; - int r = (a << (b & 31u)); + int r = int((uint(a) << (b & 31u))); }
diff --git a/test/tint/expressions/binary/left-shift/scalar-scalar/i32.wgsl.expected.spvasm b/test/tint/expressions/binary/left-shift/scalar-scalar/i32.wgsl.expected.spvasm index a7ae97d..703fe9e 100644 --- a/test/tint/expressions/binary/left-shift/scalar-scalar/i32.wgsl.expected.spvasm +++ b/test/tint/expressions/binary/left-shift/scalar-scalar/i32.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 12 +; Bound: 14 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -21,6 +21,8 @@ %f = OpFunction %void None %3 %4 = OpLabel %9 = OpBitwiseAnd %uint %b %uint_31 - %r = OpShiftLeftLogical %int %a %9 + %11 = OpBitcast %uint %a + %12 = OpShiftLeftLogical %uint %11 %9 + %r = OpBitcast %int %12 OpReturn OpFunctionEnd
diff --git a/test/tint/expressions/binary/left-shift/vector-vector/i32.wgsl.expected.glsl b/test/tint/expressions/binary/left-shift/vector-vector/i32.wgsl.expected.glsl index 2458667..499466e 100644 --- a/test/tint/expressions/binary/left-shift/vector-vector/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/left-shift/vector-vector/i32.wgsl.expected.glsl
@@ -4,5 +4,5 @@ void main() { ivec3 a = ivec3(1, 2, 3); uvec3 b = uvec3(4u, 5u, 6u); - ivec3 r = (a << (b & uvec3(31u))); + ivec3 r = ivec3((uvec3(a) << (b & uvec3(31u)))); }
diff --git a/test/tint/expressions/binary/left-shift/vector-vector/i32.wgsl.expected.spvasm b/test/tint/expressions/binary/left-shift/vector-vector/i32.wgsl.expected.spvasm index 957d1f4..4783052 100644 --- a/test/tint/expressions/binary/left-shift/vector-vector/i32.wgsl.expected.spvasm +++ b/test/tint/expressions/binary/left-shift/vector-vector/i32.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 21 +; Bound: 23 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -30,6 +30,8 @@ %f = OpFunction %void None %3 %4 = OpLabel %17 = OpBitwiseAnd %v3uint %b %18 - %r = OpShiftLeftLogical %v3int %a %17 + %20 = OpBitcast %v3uint %a + %21 = OpShiftLeftLogical %v3uint %20 %17 + %r = OpBitcast %v3int %21 OpReturn OpFunctionEnd
diff --git a/test/tint/expressions/binary/mod/scalar-scalar/i32.wgsl.expected.glsl b/test/tint/expressions/binary/mod/scalar-scalar/i32.wgsl.expected.glsl index c70ad4a..652723d 100644 --- a/test/tint/expressions/binary/mod/scalar-scalar/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mod/scalar-scalar/i32.wgsl.expected.glsl
@@ -5,7 +5,10 @@ bool v_1 = bool((v & uint((rhs == -1)))); uint v_2 = uint((rhs == 0)); int v_3 = mix(rhs, 1, bool((v_2 | uint(v_1)))); - return (lhs - ((lhs / v_3) * v_3)); + uint v_4 = uint((lhs / v_3)); + int v_5 = int((v_4 * uint(v_3))); + uint v_6 = uint(lhs); + return int((v_6 - uint(v_5))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/expressions/binary/mod/scalar-scalar/i32.wgsl.expected.spvasm b/test/tint/expressions/binary/mod/scalar-scalar/i32.wgsl.expected.spvasm index ab4f89f..75f73b5 100644 --- a/test/tint/expressions/binary/mod/scalar-scalar/i32.wgsl.expected.spvasm +++ b/test/tint/expressions/binary/mod/scalar-scalar/i32.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 27 +; Bound: 34 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -24,6 +24,7 @@ %bool = OpTypeBool %int_n2147483648 = OpConstant %int -2147483648 %int_n1 = OpConstant %int -1 + %uint = OpTypeInt 32 0 %f = OpFunction %void None %3 %4 = OpLabel %r = OpFunctionCall %int %tint_mod_i32 %a %b @@ -40,7 +41,13 @@ %22 = OpLogicalOr %bool %14 %21 %23 = OpSelect %int %22 %a %rhs %24 = OpSDiv %int %lhs %23 - %25 = OpIMul %int %24 %23 - %26 = OpISub %int %lhs %25 - OpReturnValue %26 + %26 = OpBitcast %uint %24 + %27 = OpBitcast %uint %23 + %28 = OpIMul %uint %26 %27 + %29 = OpBitcast %int %28 + %30 = OpBitcast %uint %lhs + %31 = OpBitcast %uint %29 + %32 = OpISub %uint %30 %31 + %33 = OpBitcast %int %32 + OpReturnValue %33 OpFunctionEnd
diff --git a/test/tint/expressions/binary/mod/scalar-vec3/i32.wgsl.expected.glsl b/test/tint/expressions/binary/mod/scalar-vec3/i32.wgsl.expected.glsl index 719ca0b..c0881fa 100644 --- a/test/tint/expressions/binary/mod/scalar-vec3/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mod/scalar-vec3/i32.wgsl.expected.glsl
@@ -5,7 +5,10 @@ bvec3 v_1 = bvec3((v & uvec3(equal(rhs, ivec3(-1))))); uvec3 v_2 = uvec3(equal(rhs, ivec3(0))); ivec3 v_3 = mix(rhs, ivec3(1), bvec3((v_2 | uvec3(v_1)))); - return (lhs - ((lhs / v_3) * v_3)); + uvec3 v_4 = uvec3((lhs / v_3)); + ivec3 v_5 = ivec3((v_4 * uvec3(v_3))); + uvec3 v_6 = uvec3(lhs); + return ivec3((v_6 - uvec3(v_5))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/expressions/binary/mod/scalar-vec3/i32.wgsl.expected.spvasm b/test/tint/expressions/binary/mod/scalar-vec3/i32.wgsl.expected.spvasm index 980ecac..50f87e8 100644 --- a/test/tint/expressions/binary/mod/scalar-vec3/i32.wgsl.expected.spvasm +++ b/test/tint/expressions/binary/mod/scalar-vec3/i32.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 36 +; Bound: 44 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -32,6 +32,8 @@ %int_n1 = OpConstant %int -1 %27 = OpConstantComposite %v3int %int_n1 %int_n1 %int_n1 %32 = OpConstantComposite %v3int %int_1 %int_1 %int_1 + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 %f = OpFunction %void None %3 %4 = OpLabel %12 = OpCompositeConstruct %v3int %a %a %a @@ -49,7 +51,13 @@ %30 = OpLogicalOr %v3bool %19 %29 %31 = OpSelect %v3int %30 %32 %rhs %33 = OpSDiv %v3int %lhs %31 - %34 = OpIMul %v3int %33 %31 - %35 = OpISub %v3int %lhs %34 - OpReturnValue %35 + %36 = OpBitcast %v3uint %33 + %37 = OpBitcast %v3uint %31 + %38 = OpIMul %v3uint %36 %37 + %39 = OpBitcast %v3int %38 + %40 = OpBitcast %v3uint %lhs + %41 = OpBitcast %v3uint %39 + %42 = OpISub %v3uint %40 %41 + %43 = OpBitcast %v3int %42 + OpReturnValue %43 OpFunctionEnd
diff --git a/test/tint/expressions/binary/mod/vec3-scalar/i32.wgsl.expected.glsl b/test/tint/expressions/binary/mod/vec3-scalar/i32.wgsl.expected.glsl index 58899e5..0e9a8ee 100644 --- a/test/tint/expressions/binary/mod/vec3-scalar/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mod/vec3-scalar/i32.wgsl.expected.glsl
@@ -5,7 +5,10 @@ bvec3 v_1 = bvec3((v & uvec3(equal(rhs, ivec3(-1))))); uvec3 v_2 = uvec3(equal(rhs, ivec3(0))); ivec3 v_3 = mix(rhs, ivec3(1), bvec3((v_2 | uvec3(v_1)))); - return (lhs - ((lhs / v_3) * v_3)); + uvec3 v_4 = uvec3((lhs / v_3)); + ivec3 v_5 = ivec3((v_4 * uvec3(v_3))); + uvec3 v_6 = uvec3(lhs); + return ivec3((v_6 - uvec3(v_5))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/expressions/binary/mod/vec3-scalar/i32.wgsl.expected.spvasm b/test/tint/expressions/binary/mod/vec3-scalar/i32.wgsl.expected.spvasm index cf04abe..b02fc26 100644 --- a/test/tint/expressions/binary/mod/vec3-scalar/i32.wgsl.expected.spvasm +++ b/test/tint/expressions/binary/mod/vec3-scalar/i32.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 36 +; Bound: 44 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -32,6 +32,8 @@ %int_n1 = OpConstant %int -1 %27 = OpConstantComposite %v3int %int_n1 %int_n1 %int_n1 %32 = OpConstantComposite %v3int %int_1 %int_1 %int_1 + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 %f = OpFunction %void None %3 %4 = OpLabel %12 = OpCompositeConstruct %v3int %b %b %b @@ -49,7 +51,13 @@ %30 = OpLogicalOr %v3bool %19 %29 %31 = OpSelect %v3int %30 %32 %rhs %33 = OpSDiv %v3int %lhs %31 - %34 = OpIMul %v3int %33 %31 - %35 = OpISub %v3int %lhs %34 - OpReturnValue %35 + %36 = OpBitcast %v3uint %33 + %37 = OpBitcast %v3uint %31 + %38 = OpIMul %v3uint %36 %37 + %39 = OpBitcast %v3int %38 + %40 = OpBitcast %v3uint %lhs + %41 = OpBitcast %v3uint %39 + %42 = OpISub %v3uint %40 %41 + %43 = OpBitcast %v3int %42 + OpReturnValue %43 OpFunctionEnd
diff --git a/test/tint/expressions/binary/mod/vec3-vec3/i32.wgsl.expected.glsl b/test/tint/expressions/binary/mod/vec3-vec3/i32.wgsl.expected.glsl index df1cb0e..324ff55 100644 --- a/test/tint/expressions/binary/mod/vec3-vec3/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mod/vec3-vec3/i32.wgsl.expected.glsl
@@ -5,7 +5,10 @@ bvec3 v_1 = bvec3((v & uvec3(equal(rhs, ivec3(-1))))); uvec3 v_2 = uvec3(equal(rhs, ivec3(0))); ivec3 v_3 = mix(rhs, ivec3(1), bvec3((v_2 | uvec3(v_1)))); - return (lhs - ((lhs / v_3) * v_3)); + uvec3 v_4 = uvec3((lhs / v_3)); + ivec3 v_5 = ivec3((v_4 * uvec3(v_3))); + uvec3 v_6 = uvec3(lhs); + return ivec3((v_6 - uvec3(v_5))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/expressions/binary/mod/vec3-vec3/i32.wgsl.expected.spvasm b/test/tint/expressions/binary/mod/vec3-vec3/i32.wgsl.expected.spvasm index a789b2a..2b35ab6 100644 --- a/test/tint/expressions/binary/mod/vec3-vec3/i32.wgsl.expected.spvasm +++ b/test/tint/expressions/binary/mod/vec3-vec3/i32.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 38 +; Bound: 46 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -35,6 +35,8 @@ %int_n1 = OpConstant %int -1 %29 = OpConstantComposite %v3int %int_n1 %int_n1 %int_n1 %34 = OpConstantComposite %v3int %int_1 %int_1 %int_1 + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 %f = OpFunction %void None %3 %4 = OpLabel %r = OpFunctionCall %v3int %tint_mod_v3i32 %a %b @@ -51,7 +53,13 @@ %32 = OpLogicalOr %v3bool %21 %31 %33 = OpSelect %v3int %32 %34 %rhs %35 = OpSDiv %v3int %lhs %33 - %36 = OpIMul %v3int %35 %33 - %37 = OpISub %v3int %lhs %36 - OpReturnValue %37 + %38 = OpBitcast %v3uint %35 + %39 = OpBitcast %v3uint %33 + %40 = OpIMul %v3uint %38 %39 + %41 = OpBitcast %v3int %40 + %42 = OpBitcast %v3uint %lhs + %43 = OpBitcast %v3uint %41 + %44 = OpISub %v3uint %42 %43 + %45 = OpBitcast %v3int %44 + OpReturnValue %45 OpFunctionEnd
diff --git a/test/tint/expressions/binary/mod_by_zero/by_constant/scalar-scalar/i32.wgsl.expected.glsl b/test/tint/expressions/binary/mod_by_zero/by_constant/scalar-scalar/i32.wgsl.expected.glsl index 0277f57..1ac8c32 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_constant/scalar-scalar/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mod_by_zero/by_constant/scalar-scalar/i32.wgsl.expected.glsl
@@ -5,7 +5,10 @@ bool v_1 = bool((v & uint((rhs == -1)))); uint v_2 = uint((rhs == 0)); int v_3 = mix(rhs, 1, bool((v_2 | uint(v_1)))); - return (lhs - ((lhs / v_3) * v_3)); + uint v_4 = uint((lhs / v_3)); + int v_5 = int((v_4 * uint(v_3))); + uint v_6 = uint(lhs); + return int((v_6 - uint(v_5))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/expressions/binary/mod_by_zero/by_constant/scalar-scalar/i32.wgsl.expected.spvasm b/test/tint/expressions/binary/mod_by_zero/by_constant/scalar-scalar/i32.wgsl.expected.spvasm index f445481..5820300 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_constant/scalar-scalar/i32.wgsl.expected.spvasm +++ b/test/tint/expressions/binary/mod_by_zero/by_constant/scalar-scalar/i32.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 26 +; Bound: 33 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -23,6 +23,7 @@ %bool = OpTypeBool %int_n2147483648 = OpConstant %int -2147483648 %int_n1 = OpConstant %int -1 + %uint = OpTypeInt 32 0 %f = OpFunction %void None %3 %4 = OpLabel %r = OpFunctionCall %int %tint_mod_i32 %a %b @@ -39,7 +40,13 @@ %21 = OpLogicalOr %bool %14 %20 %22 = OpSelect %int %21 %a %rhs %23 = OpSDiv %int %lhs %22 - %24 = OpIMul %int %23 %22 - %25 = OpISub %int %lhs %24 - OpReturnValue %25 + %25 = OpBitcast %uint %23 + %26 = OpBitcast %uint %22 + %27 = OpIMul %uint %25 %26 + %28 = OpBitcast %int %27 + %29 = OpBitcast %uint %lhs + %30 = OpBitcast %uint %28 + %31 = OpISub %uint %29 %30 + %32 = OpBitcast %int %31 + OpReturnValue %32 OpFunctionEnd
diff --git a/test/tint/expressions/binary/mod_by_zero/by_constant/scalar-vec3/i32.wgsl.expected.glsl b/test/tint/expressions/binary/mod_by_zero/by_constant/scalar-vec3/i32.wgsl.expected.glsl index d05c957..3a650c7 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_constant/scalar-vec3/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mod_by_zero/by_constant/scalar-vec3/i32.wgsl.expected.glsl
@@ -5,7 +5,10 @@ bvec3 v_1 = bvec3((v & uvec3(equal(rhs, ivec3(-1))))); uvec3 v_2 = uvec3(equal(rhs, ivec3(0))); ivec3 v_3 = mix(rhs, ivec3(1), bvec3((v_2 | uvec3(v_1)))); - return (lhs - ((lhs / v_3) * v_3)); + uvec3 v_4 = uvec3((lhs / v_3)); + ivec3 v_5 = ivec3((v_4 * uvec3(v_3))); + uvec3 v_6 = uvec3(lhs); + return ivec3((v_6 - uvec3(v_5))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/expressions/binary/mod_by_zero/by_constant/scalar-vec3/i32.wgsl.expected.spvasm b/test/tint/expressions/binary/mod_by_zero/by_constant/scalar-vec3/i32.wgsl.expected.spvasm index f5822f8..c0ccbda 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_constant/scalar-vec3/i32.wgsl.expected.spvasm +++ b/test/tint/expressions/binary/mod_by_zero/by_constant/scalar-vec3/i32.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 36 +; Bound: 44 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -32,6 +32,8 @@ %26 = OpConstantComposite %v3int %int_n1 %int_n1 %int_n1 %int_1 = OpConstant %int 1 %31 = OpConstantComposite %v3int %int_1 %int_1 %int_1 + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 %f = OpFunction %void None %3 %4 = OpLabel %11 = OpCompositeConstruct %v3int %a %a %a @@ -49,7 +51,13 @@ %29 = OpLogicalOr %v3bool %18 %28 %30 = OpSelect %v3int %29 %31 %rhs %33 = OpSDiv %v3int %lhs %30 - %34 = OpIMul %v3int %33 %30 - %35 = OpISub %v3int %lhs %34 - OpReturnValue %35 + %36 = OpBitcast %v3uint %33 + %37 = OpBitcast %v3uint %30 + %38 = OpIMul %v3uint %36 %37 + %39 = OpBitcast %v3int %38 + %40 = OpBitcast %v3uint %lhs + %41 = OpBitcast %v3uint %39 + %42 = OpISub %v3uint %40 %41 + %43 = OpBitcast %v3int %42 + OpReturnValue %43 OpFunctionEnd
diff --git a/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-scalar/i32.wgsl.expected.glsl b/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-scalar/i32.wgsl.expected.glsl index 64f94d7..1e5176c 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-scalar/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-scalar/i32.wgsl.expected.glsl
@@ -5,7 +5,10 @@ bvec3 v_1 = bvec3((v & uvec3(equal(rhs, ivec3(-1))))); uvec3 v_2 = uvec3(equal(rhs, ivec3(0))); ivec3 v_3 = mix(rhs, ivec3(1), bvec3((v_2 | uvec3(v_1)))); - return (lhs - ((lhs / v_3) * v_3)); + uvec3 v_4 = uvec3((lhs / v_3)); + ivec3 v_5 = ivec3((v_4 * uvec3(v_3))); + uvec3 v_6 = uvec3(lhs); + return ivec3((v_6 - uvec3(v_5))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-scalar/i32.wgsl.expected.spvasm b/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-scalar/i32.wgsl.expected.spvasm index 2b24142..b89d82a 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-scalar/i32.wgsl.expected.spvasm +++ b/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-scalar/i32.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 36 +; Bound: 44 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -32,6 +32,8 @@ %int_n1 = OpConstant %int -1 %27 = OpConstantComposite %v3int %int_n1 %int_n1 %int_n1 %32 = OpConstantComposite %v3int %int_1 %int_1 %int_1 + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 %f = OpFunction %void None %3 %4 = OpLabel %12 = OpCompositeConstruct %v3int %b %b %b @@ -49,7 +51,13 @@ %30 = OpLogicalOr %v3bool %19 %29 %31 = OpSelect %v3int %30 %32 %rhs %33 = OpSDiv %v3int %lhs %31 - %34 = OpIMul %v3int %33 %31 - %35 = OpISub %v3int %lhs %34 - OpReturnValue %35 + %36 = OpBitcast %v3uint %33 + %37 = OpBitcast %v3uint %31 + %38 = OpIMul %v3uint %36 %37 + %39 = OpBitcast %v3int %38 + %40 = OpBitcast %v3uint %lhs + %41 = OpBitcast %v3uint %39 + %42 = OpISub %v3uint %40 %41 + %43 = OpBitcast %v3int %42 + OpReturnValue %43 OpFunctionEnd
diff --git a/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-vec3/i32.wgsl.expected.glsl b/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-vec3/i32.wgsl.expected.glsl index 2691a87..171bcaa 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-vec3/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-vec3/i32.wgsl.expected.glsl
@@ -5,7 +5,10 @@ bvec3 v_1 = bvec3((v & uvec3(equal(rhs, ivec3(-1))))); uvec3 v_2 = uvec3(equal(rhs, ivec3(0))); ivec3 v_3 = mix(rhs, ivec3(1), bvec3((v_2 | uvec3(v_1)))); - return (lhs - ((lhs / v_3) * v_3)); + uvec3 v_4 = uvec3((lhs / v_3)); + ivec3 v_5 = ivec3((v_4 * uvec3(v_3))); + uvec3 v_6 = uvec3(lhs); + return ivec3((v_6 - uvec3(v_5))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-vec3/i32.wgsl.expected.spvasm b/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-vec3/i32.wgsl.expected.spvasm index 295c6f7..18868e5 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-vec3/i32.wgsl.expected.spvasm +++ b/test/tint/expressions/binary/mod_by_zero/by_constant/vec3-vec3/i32.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 37 +; Bound: 45 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -34,6 +34,8 @@ %int_n1 = OpConstant %int -1 %28 = OpConstantComposite %v3int %int_n1 %int_n1 %int_n1 %33 = OpConstantComposite %v3int %int_1 %int_1 %int_1 + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 %f = OpFunction %void None %3 %4 = OpLabel %r = OpFunctionCall %v3int %tint_mod_v3i32 %a %b @@ -50,7 +52,13 @@ %31 = OpLogicalOr %v3bool %20 %30 %32 = OpSelect %v3int %31 %33 %rhs %34 = OpSDiv %v3int %lhs %32 - %35 = OpIMul %v3int %34 %32 - %36 = OpISub %v3int %lhs %35 - OpReturnValue %36 + %37 = OpBitcast %v3uint %34 + %38 = OpBitcast %v3uint %32 + %39 = OpIMul %v3uint %37 %38 + %40 = OpBitcast %v3int %39 + %41 = OpBitcast %v3uint %lhs + %42 = OpBitcast %v3uint %40 + %43 = OpISub %v3uint %41 %42 + %44 = OpBitcast %v3int %43 + OpReturnValue %44 OpFunctionEnd
diff --git a/test/tint/expressions/binary/mod_by_zero/by_expression/scalar-scalar/i32.wgsl.expected.glsl b/test/tint/expressions/binary/mod_by_zero/by_expression/scalar-scalar/i32.wgsl.expected.glsl index fb8206e..c2876bf 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_expression/scalar-scalar/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mod_by_zero/by_expression/scalar-scalar/i32.wgsl.expected.glsl
@@ -5,11 +5,17 @@ bool v_1 = bool((v & uint((rhs == -1)))); uint v_2 = uint((rhs == 0)); int v_3 = mix(rhs, 1, bool((v_2 | uint(v_1)))); - return (lhs - ((lhs / v_3) * v_3)); + uint v_4 = uint((lhs / v_3)); + int v_5 = int((v_4 * uint(v_3))); + uint v_6 = uint(lhs); + return int((v_6 - uint(v_5))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { int a = 1; int b = 0; - int r = tint_mod_i32(a, (b + b)); + int v_7 = a; + int v_8 = b; + uint v_9 = uint(b); + int r = tint_mod_i32(v_7, int((v_9 + uint(v_8)))); }
diff --git a/test/tint/expressions/binary/mod_by_zero/by_expression/scalar-scalar/i32.wgsl.expected.spvasm b/test/tint/expressions/binary/mod_by_zero/by_expression/scalar-scalar/i32.wgsl.expected.spvasm index a1b93d0..1b111cc 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_expression/scalar-scalar/i32.wgsl.expected.spvasm +++ b/test/tint/expressions/binary/mod_by_zero/by_expression/scalar-scalar/i32.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 33 +; Bound: 43 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -20,7 +20,8 @@ %_ptr_Function_int = OpTypePointer Function %int %int_1 = OpConstant %int 1 %int_0 = OpConstant %int 0 - %19 = OpTypeFunction %int %int %int + %uint = OpTypeInt 32 0 + %23 = OpTypeFunction %int %int %int %bool = OpTypeBool %int_n2147483648 = OpConstant %int -2147483648 %int_n1 = OpConstant %int -1 @@ -33,22 +34,31 @@ %11 = OpLoad %int %a None %12 = OpLoad %int %b None %13 = OpLoad %int %b None - %14 = OpIAdd %int %12 %13 - %r = OpFunctionCall %int %tint_mod_i32 %11 %14 + %15 = OpBitcast %uint %12 + %16 = OpBitcast %uint %13 + %17 = OpIAdd %uint %15 %16 + %18 = OpBitcast %int %17 + %r = OpFunctionCall %int %tint_mod_i32 %11 %18 OpReturn OpFunctionEnd -%tint_mod_i32 = OpFunction %int None %19 +%tint_mod_i32 = OpFunction %int None %23 %lhs = OpFunctionParameter %int %rhs = OpFunctionParameter %int - %20 = OpLabel - %21 = OpIEqual %bool %rhs %int_0 - %23 = OpIEqual %bool %lhs %int_n2147483648 - %25 = OpIEqual %bool %rhs %int_n1 - %27 = OpLogicalAnd %bool %23 %25 - %28 = OpLogicalOr %bool %21 %27 - %29 = OpSelect %int %28 %int_1 %rhs - %30 = OpSDiv %int %lhs %29 - %31 = OpIMul %int %30 %29 - %32 = OpISub %int %lhs %31 - OpReturnValue %32 + %24 = OpLabel + %25 = OpIEqual %bool %rhs %int_0 + %27 = OpIEqual %bool %lhs %int_n2147483648 + %29 = OpIEqual %bool %rhs %int_n1 + %31 = OpLogicalAnd %bool %27 %29 + %32 = OpLogicalOr %bool %25 %31 + %33 = OpSelect %int %32 %int_1 %rhs + %34 = OpSDiv %int %lhs %33 + %35 = OpBitcast %uint %34 + %36 = OpBitcast %uint %33 + %37 = OpIMul %uint %35 %36 + %38 = OpBitcast %int %37 + %39 = OpBitcast %uint %lhs + %40 = OpBitcast %uint %38 + %41 = OpISub %uint %39 %40 + %42 = OpBitcast %int %41 + OpReturnValue %42 OpFunctionEnd
diff --git a/test/tint/expressions/binary/mod_by_zero/by_expression/scalar-vec3/i32.wgsl.expected.glsl b/test/tint/expressions/binary/mod_by_zero/by_expression/scalar-vec3/i32.wgsl.expected.glsl index d77248a..a165a7b 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_expression/scalar-vec3/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mod_by_zero/by_expression/scalar-vec3/i32.wgsl.expected.glsl
@@ -5,12 +5,18 @@ bvec3 v_1 = bvec3((v & uvec3(equal(rhs, ivec3(-1))))); uvec3 v_2 = uvec3(equal(rhs, ivec3(0))); ivec3 v_3 = mix(rhs, ivec3(1), bvec3((v_2 | uvec3(v_1)))); - return (lhs - ((lhs / v_3) * v_3)); + uvec3 v_4 = uvec3((lhs / v_3)); + ivec3 v_5 = ivec3((v_4 * uvec3(v_3))); + uvec3 v_6 = uvec3(lhs); + return ivec3((v_6 - uvec3(v_5))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { int a = 4; ivec3 b = ivec3(0, 2, 0); - ivec3 v_4 = (b + b); - ivec3 r = tint_mod_v3i32(ivec3(a), v_4); + int v_7 = a; + ivec3 v_8 = b; + uvec3 v_9 = uvec3(b); + ivec3 v_10 = ivec3((v_9 + uvec3(v_8))); + ivec3 r = tint_mod_v3i32(ivec3(v_7), v_10); }
diff --git a/test/tint/expressions/binary/mod_by_zero/by_expression/scalar-vec3/i32.wgsl.expected.spvasm b/test/tint/expressions/binary/mod_by_zero/by_expression/scalar-vec3/i32.wgsl.expected.spvasm index e8bb769..4e5a459 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_expression/scalar-vec3/i32.wgsl.expected.spvasm +++ b/test/tint/expressions/binary/mod_by_zero/by_expression/scalar-vec3/i32.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 44 +; Bound: 55 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -24,16 +24,18 @@ %int_0 = OpConstant %int 0 %int_2 = OpConstant %int 2 %12 = OpConstantComposite %v3int %int_0 %int_2 %int_0 - %24 = OpTypeFunction %v3int %v3int %v3int - %27 = OpConstantNull %v3int + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 + %29 = OpTypeFunction %v3int %v3int %v3int + %32 = OpConstantNull %v3int %bool = OpTypeBool %v3bool = OpTypeVector %bool 3 %int_n2147483648 = OpConstant %int -2147483648 - %31 = OpConstantComposite %v3int %int_n2147483648 %int_n2147483648 %int_n2147483648 + %36 = OpConstantComposite %v3int %int_n2147483648 %int_n2147483648 %int_n2147483648 %int_n1 = OpConstant %int -1 - %34 = OpConstantComposite %v3int %int_n1 %int_n1 %int_n1 + %39 = OpConstantComposite %v3int %int_n1 %int_n1 %int_n1 %int_1 = OpConstant %int 1 - %39 = OpConstantComposite %v3int %int_1 %int_1 %int_1 + %44 = OpConstantComposite %v3int %int_1 %int_1 %int_1 %f = OpFunction %void None %3 %4 = OpLabel %a = OpVariable %_ptr_Function_int Function @@ -43,23 +45,32 @@ %15 = OpLoad %int %a None %16 = OpLoad %v3int %b None %17 = OpLoad %v3int %b None - %18 = OpIAdd %v3int %16 %17 - %19 = OpCompositeConstruct %v3int %15 %15 %15 - %r = OpFunctionCall %v3int %tint_mod_v3i32 %19 %18 + %20 = OpBitcast %v3uint %16 + %21 = OpBitcast %v3uint %17 + %22 = OpIAdd %v3uint %20 %21 + %23 = OpBitcast %v3int %22 + %24 = OpCompositeConstruct %v3int %15 %15 %15 + %r = OpFunctionCall %v3int %tint_mod_v3i32 %24 %23 OpReturn OpFunctionEnd -%tint_mod_v3i32 = OpFunction %v3int None %24 +%tint_mod_v3i32 = OpFunction %v3int None %29 %lhs = OpFunctionParameter %v3int %rhs = OpFunctionParameter %v3int - %25 = OpLabel - %26 = OpIEqual %v3bool %rhs %27 - %30 = OpIEqual %v3bool %lhs %31 - %33 = OpIEqual %v3bool %rhs %34 - %36 = OpLogicalAnd %v3bool %30 %33 - %37 = OpLogicalOr %v3bool %26 %36 - %38 = OpSelect %v3int %37 %39 %rhs - %41 = OpSDiv %v3int %lhs %38 - %42 = OpIMul %v3int %41 %38 - %43 = OpISub %v3int %lhs %42 - OpReturnValue %43 + %30 = OpLabel + %31 = OpIEqual %v3bool %rhs %32 + %35 = OpIEqual %v3bool %lhs %36 + %38 = OpIEqual %v3bool %rhs %39 + %41 = OpLogicalAnd %v3bool %35 %38 + %42 = OpLogicalOr %v3bool %31 %41 + %43 = OpSelect %v3int %42 %44 %rhs + %46 = OpSDiv %v3int %lhs %43 + %47 = OpBitcast %v3uint %46 + %48 = OpBitcast %v3uint %43 + %49 = OpIMul %v3uint %47 %48 + %50 = OpBitcast %v3int %49 + %51 = OpBitcast %v3uint %lhs + %52 = OpBitcast %v3uint %50 + %53 = OpISub %v3uint %51 %52 + %54 = OpBitcast %v3int %53 + OpReturnValue %54 OpFunctionEnd
diff --git a/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-scalar/i32.wgsl.expected.glsl b/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-scalar/i32.wgsl.expected.glsl index eaadd55..d809b83 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-scalar/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-scalar/i32.wgsl.expected.glsl
@@ -5,12 +5,17 @@ bvec3 v_1 = bvec3((v & uvec3(equal(rhs, ivec3(-1))))); uvec3 v_2 = uvec3(equal(rhs, ivec3(0))); ivec3 v_3 = mix(rhs, ivec3(1), bvec3((v_2 | uvec3(v_1)))); - return (lhs - ((lhs / v_3) * v_3)); + uvec3 v_4 = uvec3((lhs / v_3)); + ivec3 v_5 = ivec3((v_4 * uvec3(v_3))); + uvec3 v_6 = uvec3(lhs); + return ivec3((v_6 - uvec3(v_5))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { ivec3 a = ivec3(1, 2, 3); int b = 0; - ivec3 v_4 = a; - ivec3 r = tint_mod_v3i32(v_4, ivec3((b + b))); + ivec3 v_7 = a; + int v_8 = b; + uint v_9 = uint(b); + ivec3 r = tint_mod_v3i32(v_7, ivec3(int((v_9 + uint(v_8))))); }
diff --git a/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-scalar/i32.wgsl.expected.spvasm b/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-scalar/i32.wgsl.expected.spvasm index f6f111c..150fb51 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-scalar/i32.wgsl.expected.spvasm +++ b/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-scalar/i32.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 44 +; Bound: 55 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -25,15 +25,17 @@ %9 = OpConstantComposite %v3int %int_1 %int_2 %int_3 %_ptr_Function_int = OpTypePointer Function %int %int_0 = OpConstant %int 0 - %25 = OpTypeFunction %v3int %v3int %v3int - %28 = OpConstantNull %v3int + %uint = OpTypeInt 32 0 + %29 = OpTypeFunction %v3int %v3int %v3int + %32 = OpConstantNull %v3int %bool = OpTypeBool %v3bool = OpTypeVector %bool 3 %int_n2147483648 = OpConstant %int -2147483648 - %32 = OpConstantComposite %v3int %int_n2147483648 %int_n2147483648 %int_n2147483648 + %36 = OpConstantComposite %v3int %int_n2147483648 %int_n2147483648 %int_n2147483648 %int_n1 = OpConstant %int -1 - %35 = OpConstantComposite %v3int %int_n1 %int_n1 %int_n1 - %40 = OpConstantComposite %v3int %int_1 %int_1 %int_1 + %39 = OpConstantComposite %v3int %int_n1 %int_n1 %int_n1 + %44 = OpConstantComposite %v3int %int_1 %int_1 %int_1 + %v3uint = OpTypeVector %uint 3 %f = OpFunction %void None %3 %4 = OpLabel %a = OpVariable %_ptr_Function_v3int Function @@ -43,23 +45,32 @@ %16 = OpLoad %v3int %a None %17 = OpLoad %int %b None %18 = OpLoad %int %b None - %19 = OpIAdd %int %17 %18 - %20 = OpCompositeConstruct %v3int %19 %19 %19 - %r = OpFunctionCall %v3int %tint_mod_v3i32 %16 %20 + %20 = OpBitcast %uint %17 + %21 = OpBitcast %uint %18 + %22 = OpIAdd %uint %20 %21 + %23 = OpBitcast %int %22 + %24 = OpCompositeConstruct %v3int %23 %23 %23 + %r = OpFunctionCall %v3int %tint_mod_v3i32 %16 %24 OpReturn OpFunctionEnd -%tint_mod_v3i32 = OpFunction %v3int None %25 +%tint_mod_v3i32 = OpFunction %v3int None %29 %lhs = OpFunctionParameter %v3int %rhs = OpFunctionParameter %v3int - %26 = OpLabel - %27 = OpIEqual %v3bool %rhs %28 - %31 = OpIEqual %v3bool %lhs %32 - %34 = OpIEqual %v3bool %rhs %35 - %37 = OpLogicalAnd %v3bool %31 %34 - %38 = OpLogicalOr %v3bool %27 %37 - %39 = OpSelect %v3int %38 %40 %rhs - %41 = OpSDiv %v3int %lhs %39 - %42 = OpIMul %v3int %41 %39 - %43 = OpISub %v3int %lhs %42 - OpReturnValue %43 + %30 = OpLabel + %31 = OpIEqual %v3bool %rhs %32 + %35 = OpIEqual %v3bool %lhs %36 + %38 = OpIEqual %v3bool %rhs %39 + %41 = OpLogicalAnd %v3bool %35 %38 + %42 = OpLogicalOr %v3bool %31 %41 + %43 = OpSelect %v3int %42 %44 %rhs + %45 = OpSDiv %v3int %lhs %43 + %47 = OpBitcast %v3uint %45 + %48 = OpBitcast %v3uint %43 + %49 = OpIMul %v3uint %47 %48 + %50 = OpBitcast %v3int %49 + %51 = OpBitcast %v3uint %lhs + %52 = OpBitcast %v3uint %50 + %53 = OpISub %v3uint %51 %52 + %54 = OpBitcast %v3int %53 + OpReturnValue %54 OpFunctionEnd
diff --git a/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-vec3/i32.wgsl.expected.glsl b/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-vec3/i32.wgsl.expected.glsl index 6610ea0..b8725f9 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-vec3/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-vec3/i32.wgsl.expected.glsl
@@ -5,11 +5,17 @@ bvec3 v_1 = bvec3((v & uvec3(equal(rhs, ivec3(-1))))); uvec3 v_2 = uvec3(equal(rhs, ivec3(0))); ivec3 v_3 = mix(rhs, ivec3(1), bvec3((v_2 | uvec3(v_1)))); - return (lhs - ((lhs / v_3) * v_3)); + uvec3 v_4 = uvec3((lhs / v_3)); + ivec3 v_5 = ivec3((v_4 * uvec3(v_3))); + uvec3 v_6 = uvec3(lhs); + return ivec3((v_6 - uvec3(v_5))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { ivec3 a = ivec3(1, 2, 3); ivec3 b = ivec3(0, 5, 0); - ivec3 r = tint_mod_v3i32(a, (b + b)); + ivec3 v_7 = a; + ivec3 v_8 = b; + uvec3 v_9 = uvec3(b); + ivec3 r = tint_mod_v3i32(v_7, ivec3((v_9 + uvec3(v_8)))); }
diff --git a/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-vec3/i32.wgsl.expected.spvasm b/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-vec3/i32.wgsl.expected.spvasm index f1c584f..16d11d1 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-vec3/i32.wgsl.expected.spvasm +++ b/test/tint/expressions/binary/mod_by_zero/by_expression/vec3-vec3/i32.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 44 +; Bound: 55 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -26,15 +26,17 @@ %int_0 = OpConstant %int 0 %int_5 = OpConstant %int 5 %14 = OpConstantComposite %v3int %int_0 %int_5 %int_0 - %25 = OpTypeFunction %v3int %v3int %v3int - %28 = OpConstantNull %v3int + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 + %30 = OpTypeFunction %v3int %v3int %v3int + %33 = OpConstantNull %v3int %bool = OpTypeBool %v3bool = OpTypeVector %bool 3 %int_n2147483648 = OpConstant %int -2147483648 - %32 = OpConstantComposite %v3int %int_n2147483648 %int_n2147483648 %int_n2147483648 + %37 = OpConstantComposite %v3int %int_n2147483648 %int_n2147483648 %int_n2147483648 %int_n1 = OpConstant %int -1 - %35 = OpConstantComposite %v3int %int_n1 %int_n1 %int_n1 - %40 = OpConstantComposite %v3int %int_1 %int_1 %int_1 + %40 = OpConstantComposite %v3int %int_n1 %int_n1 %int_n1 + %45 = OpConstantComposite %v3int %int_1 %int_1 %int_1 %f = OpFunction %void None %3 %4 = OpLabel %a = OpVariable %_ptr_Function_v3int Function @@ -44,22 +46,31 @@ %17 = OpLoad %v3int %a None %18 = OpLoad %v3int %b None %19 = OpLoad %v3int %b None - %20 = OpIAdd %v3int %18 %19 - %r = OpFunctionCall %v3int %tint_mod_v3i32 %17 %20 + %22 = OpBitcast %v3uint %18 + %23 = OpBitcast %v3uint %19 + %24 = OpIAdd %v3uint %22 %23 + %25 = OpBitcast %v3int %24 + %r = OpFunctionCall %v3int %tint_mod_v3i32 %17 %25 OpReturn OpFunctionEnd -%tint_mod_v3i32 = OpFunction %v3int None %25 +%tint_mod_v3i32 = OpFunction %v3int None %30 %lhs = OpFunctionParameter %v3int %rhs = OpFunctionParameter %v3int - %26 = OpLabel - %27 = OpIEqual %v3bool %rhs %28 - %31 = OpIEqual %v3bool %lhs %32 - %34 = OpIEqual %v3bool %rhs %35 - %37 = OpLogicalAnd %v3bool %31 %34 - %38 = OpLogicalOr %v3bool %27 %37 - %39 = OpSelect %v3int %38 %40 %rhs - %41 = OpSDiv %v3int %lhs %39 - %42 = OpIMul %v3int %41 %39 - %43 = OpISub %v3int %lhs %42 - OpReturnValue %43 + %31 = OpLabel + %32 = OpIEqual %v3bool %rhs %33 + %36 = OpIEqual %v3bool %lhs %37 + %39 = OpIEqual %v3bool %rhs %40 + %42 = OpLogicalAnd %v3bool %36 %39 + %43 = OpLogicalOr %v3bool %32 %42 + %44 = OpSelect %v3int %43 %45 %rhs + %46 = OpSDiv %v3int %lhs %44 + %47 = OpBitcast %v3uint %46 + %48 = OpBitcast %v3uint %44 + %49 = OpIMul %v3uint %47 %48 + %50 = OpBitcast %v3int %49 + %51 = OpBitcast %v3uint %lhs + %52 = OpBitcast %v3uint %50 + %53 = OpISub %v3uint %51 %52 + %54 = OpBitcast %v3int %53 + OpReturnValue %54 OpFunctionEnd
diff --git a/test/tint/expressions/binary/mod_by_zero/by_identifier/scalar-scalar/i32.wgsl.expected.glsl b/test/tint/expressions/binary/mod_by_zero/by_identifier/scalar-scalar/i32.wgsl.expected.glsl index 0277f57..1ac8c32 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_identifier/scalar-scalar/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mod_by_zero/by_identifier/scalar-scalar/i32.wgsl.expected.glsl
@@ -5,7 +5,10 @@ bool v_1 = bool((v & uint((rhs == -1)))); uint v_2 = uint((rhs == 0)); int v_3 = mix(rhs, 1, bool((v_2 | uint(v_1)))); - return (lhs - ((lhs / v_3) * v_3)); + uint v_4 = uint((lhs / v_3)); + int v_5 = int((v_4 * uint(v_3))); + uint v_6 = uint(lhs); + return int((v_6 - uint(v_5))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/expressions/binary/mod_by_zero/by_identifier/scalar-scalar/i32.wgsl.expected.spvasm b/test/tint/expressions/binary/mod_by_zero/by_identifier/scalar-scalar/i32.wgsl.expected.spvasm index 2d3c7ea..bcaceac 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_identifier/scalar-scalar/i32.wgsl.expected.spvasm +++ b/test/tint/expressions/binary/mod_by_zero/by_identifier/scalar-scalar/i32.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 31 +; Bound: 38 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -24,6 +24,7 @@ %bool = OpTypeBool %int_n2147483648 = OpConstant %int -2147483648 %int_n1 = OpConstant %int -1 + %uint = OpTypeInt 32 0 %f = OpFunction %void None %3 %4 = OpLabel %a = OpVariable %_ptr_Function_int Function @@ -46,7 +47,13 @@ %26 = OpLogicalOr %bool %19 %25 %27 = OpSelect %int %26 %int_1 %rhs %28 = OpSDiv %int %lhs %27 - %29 = OpIMul %int %28 %27 - %30 = OpISub %int %lhs %29 - OpReturnValue %30 + %30 = OpBitcast %uint %28 + %31 = OpBitcast %uint %27 + %32 = OpIMul %uint %30 %31 + %33 = OpBitcast %int %32 + %34 = OpBitcast %uint %lhs + %35 = OpBitcast %uint %33 + %36 = OpISub %uint %34 %35 + %37 = OpBitcast %int %36 + OpReturnValue %37 OpFunctionEnd
diff --git a/test/tint/expressions/binary/mod_by_zero/by_identifier/scalar-vec3/i32.wgsl.expected.glsl b/test/tint/expressions/binary/mod_by_zero/by_identifier/scalar-vec3/i32.wgsl.expected.glsl index b96a4d2..717e97a 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_identifier/scalar-vec3/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mod_by_zero/by_identifier/scalar-vec3/i32.wgsl.expected.glsl
@@ -5,12 +5,15 @@ bvec3 v_1 = bvec3((v & uvec3(equal(rhs, ivec3(-1))))); uvec3 v_2 = uvec3(equal(rhs, ivec3(0))); ivec3 v_3 = mix(rhs, ivec3(1), bvec3((v_2 | uvec3(v_1)))); - return (lhs - ((lhs / v_3) * v_3)); + uvec3 v_4 = uvec3((lhs / v_3)); + ivec3 v_5 = ivec3((v_4 * uvec3(v_3))); + uvec3 v_6 = uvec3(lhs); + return ivec3((v_6 - uvec3(v_5))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { int a = 4; ivec3 b = ivec3(0, 2, 0); - ivec3 v_4 = b; - ivec3 r = tint_mod_v3i32(ivec3(a), v_4); + ivec3 v_7 = b; + ivec3 r = tint_mod_v3i32(ivec3(a), v_7); }
diff --git a/test/tint/expressions/binary/mod_by_zero/by_identifier/scalar-vec3/i32.wgsl.expected.spvasm b/test/tint/expressions/binary/mod_by_zero/by_identifier/scalar-vec3/i32.wgsl.expected.spvasm index c686cad..2276d48 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_identifier/scalar-vec3/i32.wgsl.expected.spvasm +++ b/test/tint/expressions/binary/mod_by_zero/by_identifier/scalar-vec3/i32.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 42 +; Bound: 50 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -34,6 +34,8 @@ %32 = OpConstantComposite %v3int %int_n1 %int_n1 %int_n1 %int_1 = OpConstant %int 1 %37 = OpConstantComposite %v3int %int_1 %int_1 %int_1 + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 %f = OpFunction %void None %3 %4 = OpLabel %a = OpVariable %_ptr_Function_int Function @@ -57,7 +59,13 @@ %35 = OpLogicalOr %v3bool %24 %34 %36 = OpSelect %v3int %35 %37 %rhs %39 = OpSDiv %v3int %lhs %36 - %40 = OpIMul %v3int %39 %36 - %41 = OpISub %v3int %lhs %40 - OpReturnValue %41 + %42 = OpBitcast %v3uint %39 + %43 = OpBitcast %v3uint %36 + %44 = OpIMul %v3uint %42 %43 + %45 = OpBitcast %v3int %44 + %46 = OpBitcast %v3uint %lhs + %47 = OpBitcast %v3uint %45 + %48 = OpISub %v3uint %46 %47 + %49 = OpBitcast %v3int %48 + OpReturnValue %49 OpFunctionEnd
diff --git a/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-scalar/i32.wgsl.expected.glsl b/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-scalar/i32.wgsl.expected.glsl index dc5b400..660a2e5 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-scalar/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-scalar/i32.wgsl.expected.glsl
@@ -5,12 +5,15 @@ bvec3 v_1 = bvec3((v & uvec3(equal(rhs, ivec3(-1))))); uvec3 v_2 = uvec3(equal(rhs, ivec3(0))); ivec3 v_3 = mix(rhs, ivec3(1), bvec3((v_2 | uvec3(v_1)))); - return (lhs - ((lhs / v_3) * v_3)); + uvec3 v_4 = uvec3((lhs / v_3)); + ivec3 v_5 = ivec3((v_4 * uvec3(v_3))); + uvec3 v_6 = uvec3(lhs); + return ivec3((v_6 - uvec3(v_5))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { ivec3 a = ivec3(1, 2, 3); int b = 0; - ivec3 v_4 = a; - ivec3 r = tint_mod_v3i32(v_4, ivec3(b)); + ivec3 v_7 = a; + ivec3 r = tint_mod_v3i32(v_7, ivec3(b)); }
diff --git a/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-scalar/i32.wgsl.expected.spvasm b/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-scalar/i32.wgsl.expected.spvasm index 20b2582..91e76ca 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-scalar/i32.wgsl.expected.spvasm +++ b/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-scalar/i32.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 42 +; Bound: 50 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -34,6 +34,8 @@ %int_n1 = OpConstant %int -1 %33 = OpConstantComposite %v3int %int_n1 %int_n1 %int_n1 %38 = OpConstantComposite %v3int %int_1 %int_1 %int_1 + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 %f = OpFunction %void None %3 %4 = OpLabel %a = OpVariable %_ptr_Function_v3int Function @@ -57,7 +59,13 @@ %36 = OpLogicalOr %v3bool %25 %35 %37 = OpSelect %v3int %36 %38 %rhs %39 = OpSDiv %v3int %lhs %37 - %40 = OpIMul %v3int %39 %37 - %41 = OpISub %v3int %lhs %40 - OpReturnValue %41 + %42 = OpBitcast %v3uint %39 + %43 = OpBitcast %v3uint %37 + %44 = OpIMul %v3uint %42 %43 + %45 = OpBitcast %v3int %44 + %46 = OpBitcast %v3uint %lhs + %47 = OpBitcast %v3uint %45 + %48 = OpISub %v3uint %46 %47 + %49 = OpBitcast %v3int %48 + OpReturnValue %49 OpFunctionEnd
diff --git a/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-vec3/i32.wgsl.expected.glsl b/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-vec3/i32.wgsl.expected.glsl index 2691a87..171bcaa 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-vec3/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-vec3/i32.wgsl.expected.glsl
@@ -5,7 +5,10 @@ bvec3 v_1 = bvec3((v & uvec3(equal(rhs, ivec3(-1))))); uvec3 v_2 = uvec3(equal(rhs, ivec3(0))); ivec3 v_3 = mix(rhs, ivec3(1), bvec3((v_2 | uvec3(v_1)))); - return (lhs - ((lhs / v_3) * v_3)); + uvec3 v_4 = uvec3((lhs / v_3)); + ivec3 v_5 = ivec3((v_4 * uvec3(v_3))); + uvec3 v_6 = uvec3(lhs); + return ivec3((v_6 - uvec3(v_5))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-vec3/i32.wgsl.expected.spvasm b/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-vec3/i32.wgsl.expected.spvasm index 213281f..163655c 100644 --- a/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-vec3/i32.wgsl.expected.spvasm +++ b/test/tint/expressions/binary/mod_by_zero/by_identifier/vec3-vec3/i32.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 42 +; Bound: 50 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -35,6 +35,8 @@ %int_n1 = OpConstant %int -1 %33 = OpConstantComposite %v3int %int_n1 %int_n1 %int_n1 %38 = OpConstantComposite %v3int %int_1 %int_1 %int_1 + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 %f = OpFunction %void None %3 %4 = OpLabel %a = OpVariable %_ptr_Function_v3int Function @@ -57,7 +59,13 @@ %36 = OpLogicalOr %v3bool %25 %35 %37 = OpSelect %v3int %36 %38 %rhs %39 = OpSDiv %v3int %lhs %37 - %40 = OpIMul %v3int %39 %37 - %41 = OpISub %v3int %lhs %40 - OpReturnValue %41 + %42 = OpBitcast %v3uint %39 + %43 = OpBitcast %v3uint %37 + %44 = OpIMul %v3uint %42 %43 + %45 = OpBitcast %v3int %44 + %46 = OpBitcast %v3uint %lhs + %47 = OpBitcast %v3uint %45 + %48 = OpISub %v3uint %46 %47 + %49 = OpBitcast %v3int %48 + OpReturnValue %49 OpFunctionEnd
diff --git a/test/tint/expressions/binary/mul/scalar-scalar/i32.wgsl.expected.glsl b/test/tint/expressions/binary/mul/scalar-scalar/i32.wgsl.expected.glsl index d84a345..befefb7 100644 --- a/test/tint/expressions/binary/mul/scalar-scalar/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mul/scalar-scalar/i32.wgsl.expected.glsl
@@ -4,5 +4,6 @@ void main() { int a = 1; int b = 2; - int r = (a * b); + uint v = uint(a); + int r = int((v * uint(b))); }
diff --git a/test/tint/expressions/binary/mul/scalar-scalar/i32.wgsl.expected.spvasm b/test/tint/expressions/binary/mul/scalar-scalar/i32.wgsl.expected.spvasm index daff6c9..9eb88ac 100644 --- a/test/tint/expressions/binary/mul/scalar-scalar/i32.wgsl.expected.spvasm +++ b/test/tint/expressions/binary/mul/scalar-scalar/i32.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 9 +; Bound: 13 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -16,8 +16,12 @@ %int = OpTypeInt 32 1 %a = OpConstant %int 1 %b = OpConstant %int 2 + %uint = OpTypeInt 32 0 %f = OpFunction %void None %3 %4 = OpLabel - %r = OpIMul %int %a %b + %9 = OpBitcast %uint %a + %10 = OpBitcast %uint %b + %11 = OpIMul %uint %9 %10 + %r = OpBitcast %int %11 OpReturn OpFunctionEnd
diff --git a/test/tint/expressions/binary/mul/scalar-vec3/i32.wgsl.expected.glsl b/test/tint/expressions/binary/mul/scalar-vec3/i32.wgsl.expected.glsl index e561784..27e40fb 100644 --- a/test/tint/expressions/binary/mul/scalar-vec3/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mul/scalar-vec3/i32.wgsl.expected.glsl
@@ -4,5 +4,6 @@ void main() { int a = 4; ivec3 b = ivec3(1, 2, 3); - ivec3 r = (a * b); + uint v = uint(a); + ivec3 r = ivec3((v * uvec3(b))); }
diff --git a/test/tint/expressions/binary/mul/scalar-vec3/i32.wgsl.expected.spvasm b/test/tint/expressions/binary/mul/scalar-vec3/i32.wgsl.expected.spvasm index 89b5324..6ac084f 100644 --- a/test/tint/expressions/binary/mul/scalar-vec3/i32.wgsl.expected.spvasm +++ b/test/tint/expressions/binary/mul/scalar-vec3/i32.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 14 +; Bound: 19 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -20,9 +20,14 @@ %int_2 = OpConstant %int 2 %int_3 = OpConstant %int 3 %b = OpConstantComposite %v3int %int_1 %int_2 %int_3 + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 %f = OpFunction %void None %3 %4 = OpLabel %12 = OpCompositeConstruct %v3int %a %a %a - %r = OpIMul %v3int %12 %b + %15 = OpBitcast %v3uint %12 + %16 = OpBitcast %v3uint %b + %17 = OpIMul %v3uint %15 %16 + %r = OpBitcast %v3int %17 OpReturn OpFunctionEnd
diff --git a/test/tint/expressions/binary/mul/vec3-scalar/i32.wgsl.expected.glsl b/test/tint/expressions/binary/mul/vec3-scalar/i32.wgsl.expected.glsl index 403e496..48d1790 100644 --- a/test/tint/expressions/binary/mul/vec3-scalar/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mul/vec3-scalar/i32.wgsl.expected.glsl
@@ -4,5 +4,6 @@ void main() { ivec3 a = ivec3(1, 2, 3); int b = 4; - ivec3 r = (a * b); + uvec3 v = uvec3(a); + ivec3 r = ivec3((v * uint(b))); }
diff --git a/test/tint/expressions/binary/mul/vec3-scalar/i32.wgsl.expected.spvasm b/test/tint/expressions/binary/mul/vec3-scalar/i32.wgsl.expected.spvasm index c0d5afe..8f34a50 100644 --- a/test/tint/expressions/binary/mul/vec3-scalar/i32.wgsl.expected.spvasm +++ b/test/tint/expressions/binary/mul/vec3-scalar/i32.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 14 +; Bound: 19 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -20,9 +20,14 @@ %int_3 = OpConstant %int 3 %a = OpConstantComposite %v3int %int_1 %int_2 %int_3 %b = OpConstant %int 4 + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 %f = OpFunction %void None %3 %4 = OpLabel %12 = OpCompositeConstruct %v3int %b %b %b - %r = OpIMul %v3int %a %12 + %15 = OpBitcast %v3uint %a + %16 = OpBitcast %v3uint %12 + %17 = OpIMul %v3uint %15 %16 + %r = OpBitcast %v3int %17 OpReturn OpFunctionEnd
diff --git a/test/tint/expressions/binary/mul/vec3-vec3/i32.wgsl.expected.glsl b/test/tint/expressions/binary/mul/vec3-vec3/i32.wgsl.expected.glsl index f65b0c2..629b7d6 100644 --- a/test/tint/expressions/binary/mul/vec3-vec3/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/mul/vec3-vec3/i32.wgsl.expected.glsl
@@ -4,5 +4,6 @@ void main() { ivec3 a = ivec3(1, 2, 3); ivec3 b = ivec3(4, 5, 6); - ivec3 r = (a * b); + uvec3 v = uvec3(a); + ivec3 r = ivec3((v * uvec3(b))); }
diff --git a/test/tint/expressions/binary/mul/vec3-vec3/i32.wgsl.expected.spvasm b/test/tint/expressions/binary/mul/vec3-vec3/i32.wgsl.expected.spvasm index 4426d5d..780b80b 100644 --- a/test/tint/expressions/binary/mul/vec3-vec3/i32.wgsl.expected.spvasm +++ b/test/tint/expressions/binary/mul/vec3-vec3/i32.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 16 +; Bound: 21 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -23,8 +23,13 @@ %int_5 = OpConstant %int 5 %int_6 = OpConstant %int 6 %b = OpConstantComposite %v3int %int_4 %int_5 %int_6 + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 %f = OpFunction %void None %3 %4 = OpLabel - %r = OpIMul %v3int %a %b + %17 = OpBitcast %v3uint %a + %18 = OpBitcast %v3uint %b + %19 = OpIMul %v3uint %17 %18 + %r = OpBitcast %v3int %19 OpReturn OpFunctionEnd
diff --git a/test/tint/expressions/binary/sub/scalar-scalar/i32.wgsl.expected.glsl b/test/tint/expressions/binary/sub/scalar-scalar/i32.wgsl.expected.glsl index 4c5edfa..717c494 100644 --- a/test/tint/expressions/binary/sub/scalar-scalar/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/sub/scalar-scalar/i32.wgsl.expected.glsl
@@ -4,5 +4,6 @@ void main() { int a = 1; int b = 2; - int r = (a - b); + uint v = uint(a); + int r = int((v - uint(b))); }
diff --git a/test/tint/expressions/binary/sub/scalar-scalar/i32.wgsl.expected.spvasm b/test/tint/expressions/binary/sub/scalar-scalar/i32.wgsl.expected.spvasm index d7188cd..e25fbb2 100644 --- a/test/tint/expressions/binary/sub/scalar-scalar/i32.wgsl.expected.spvasm +++ b/test/tint/expressions/binary/sub/scalar-scalar/i32.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 9 +; Bound: 13 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -16,8 +16,12 @@ %int = OpTypeInt 32 1 %a = OpConstant %int 1 %b = OpConstant %int 2 + %uint = OpTypeInt 32 0 %f = OpFunction %void None %3 %4 = OpLabel - %r = OpISub %int %a %b + %9 = OpBitcast %uint %a + %10 = OpBitcast %uint %b + %11 = OpISub %uint %9 %10 + %r = OpBitcast %int %11 OpReturn OpFunctionEnd
diff --git a/test/tint/expressions/binary/sub/scalar-vec3/i32.wgsl.expected.glsl b/test/tint/expressions/binary/sub/scalar-vec3/i32.wgsl.expected.glsl index 0f9b198..ccadf15 100644 --- a/test/tint/expressions/binary/sub/scalar-vec3/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/sub/scalar-vec3/i32.wgsl.expected.glsl
@@ -4,5 +4,6 @@ void main() { int a = 4; ivec3 b = ivec3(1, 2, 3); - ivec3 r = (a - b); + uint v = uint(a); + ivec3 r = ivec3((v - uvec3(b))); }
diff --git a/test/tint/expressions/binary/sub/scalar-vec3/i32.wgsl.expected.spvasm b/test/tint/expressions/binary/sub/scalar-vec3/i32.wgsl.expected.spvasm index b8aa4da..52bb6c8 100644 --- a/test/tint/expressions/binary/sub/scalar-vec3/i32.wgsl.expected.spvasm +++ b/test/tint/expressions/binary/sub/scalar-vec3/i32.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 14 +; Bound: 19 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -20,9 +20,14 @@ %int_2 = OpConstant %int 2 %int_3 = OpConstant %int 3 %b = OpConstantComposite %v3int %int_1 %int_2 %int_3 + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 %f = OpFunction %void None %3 %4 = OpLabel %12 = OpCompositeConstruct %v3int %a %a %a - %r = OpISub %v3int %12 %b + %15 = OpBitcast %v3uint %12 + %16 = OpBitcast %v3uint %b + %17 = OpISub %v3uint %15 %16 + %r = OpBitcast %v3int %17 OpReturn OpFunctionEnd
diff --git a/test/tint/expressions/binary/sub/vec3-scalar/i32.wgsl.expected.glsl b/test/tint/expressions/binary/sub/vec3-scalar/i32.wgsl.expected.glsl index 278fe3f..a4a6394 100644 --- a/test/tint/expressions/binary/sub/vec3-scalar/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/sub/vec3-scalar/i32.wgsl.expected.glsl
@@ -4,5 +4,6 @@ void main() { ivec3 a = ivec3(1, 2, 3); int b = 4; - ivec3 r = (a - b); + uvec3 v = uvec3(a); + ivec3 r = ivec3((v - uint(b))); }
diff --git a/test/tint/expressions/binary/sub/vec3-scalar/i32.wgsl.expected.spvasm b/test/tint/expressions/binary/sub/vec3-scalar/i32.wgsl.expected.spvasm index d7c5d19..5f8eb90 100644 --- a/test/tint/expressions/binary/sub/vec3-scalar/i32.wgsl.expected.spvasm +++ b/test/tint/expressions/binary/sub/vec3-scalar/i32.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 14 +; Bound: 19 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -20,9 +20,14 @@ %int_3 = OpConstant %int 3 %a = OpConstantComposite %v3int %int_1 %int_2 %int_3 %b = OpConstant %int 4 + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 %f = OpFunction %void None %3 %4 = OpLabel %12 = OpCompositeConstruct %v3int %b %b %b - %r = OpISub %v3int %a %12 + %15 = OpBitcast %v3uint %a + %16 = OpBitcast %v3uint %12 + %17 = OpISub %v3uint %15 %16 + %r = OpBitcast %v3int %17 OpReturn OpFunctionEnd
diff --git a/test/tint/expressions/binary/sub/vec3-vec3/i32.wgsl.expected.glsl b/test/tint/expressions/binary/sub/vec3-vec3/i32.wgsl.expected.glsl index 06c418a..fbe4e35 100644 --- a/test/tint/expressions/binary/sub/vec3-vec3/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/sub/vec3-vec3/i32.wgsl.expected.glsl
@@ -4,5 +4,6 @@ void main() { ivec3 a = ivec3(1, 2, 3); ivec3 b = ivec3(4, 5, 6); - ivec3 r = (a - b); + uvec3 v = uvec3(a); + ivec3 r = ivec3((v - uvec3(b))); }
diff --git a/test/tint/expressions/binary/sub/vec3-vec3/i32.wgsl.expected.spvasm b/test/tint/expressions/binary/sub/vec3-vec3/i32.wgsl.expected.spvasm index 68c571d..ab1217b 100644 --- a/test/tint/expressions/binary/sub/vec3-vec3/i32.wgsl.expected.spvasm +++ b/test/tint/expressions/binary/sub/vec3-vec3/i32.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 16 +; Bound: 21 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -23,8 +23,13 @@ %int_5 = OpConstant %int 5 %int_6 = OpConstant %int 6 %b = OpConstantComposite %v3int %int_4 %int_5 %int_6 + %uint = OpTypeInt 32 0 + %v3uint = OpTypeVector %uint 3 %f = OpFunction %void None %3 %4 = OpLabel - %r = OpISub %v3int %a %b + %17 = OpBitcast %v3uint %a + %18 = OpBitcast %v3uint %b + %19 = OpISub %v3uint %17 %18 + %r = OpBitcast %v3int %19 OpReturn OpFunctionEnd
diff --git a/test/tint/expressions/literals/intmin.wgsl.expected.glsl b/test/tint/expressions/literals/intmin.wgsl.expected.glsl index f1999ac..eec3272 100644 --- a/test/tint/expressions/literals/intmin.wgsl.expected.glsl +++ b/test/tint/expressions/literals/intmin.wgsl.expected.glsl
@@ -2,7 +2,8 @@ int add_int_min_explicit() { int a = (-2147483647 - 1); - int b = (a + 1); + uint v = uint(a); + int b = int((v + uint(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 c2161cf..c37d758 100644 --- a/test/tint/expressions/literals/intmin.wgsl.expected.spvasm +++ b/test/tint/expressions/literals/intmin.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 19 +; Bound: 23 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -16,10 +16,11 @@ %3 = OpTypeFunction %int %_ptr_Function_int = OpTypePointer Function %int %int_n2147483648 = OpConstant %int -2147483648 + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %int_n2147483647 = OpConstant %int -2147483647 %void = OpTypeVoid - %17 = OpTypeFunction %void + %21 = OpTypeFunction %void %add_int_min_explicit = OpFunction %int None %3 %4 = OpLabel %a = OpVariable %_ptr_Function_int Function @@ -27,13 +28,16 @@ %c = OpVariable %_ptr_Function_int Function OpStore %a %int_n2147483648 %8 = OpLoad %int %a None - %9 = OpIAdd %int %8 %int_1 - OpStore %b %9 + %10 = OpBitcast %uint %8 + %11 = OpBitcast %uint %int_1 + %13 = OpIAdd %uint %10 %11 + %14 = OpBitcast %int %13 + OpStore %b %14 OpStore %c %int_n2147483647 - %14 = OpLoad %int %c None - OpReturnValue %14 + %18 = OpLoad %int %c None + OpReturnValue %18 OpFunctionEnd -%unused_entry_point = OpFunction %void None %17 - %18 = OpLabel +%unused_entry_point = OpFunction %void None %21 + %22 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/expressions/unary/negate/negate.wgsl.expected.glsl b/test/tint/expressions/unary/negate/negate.wgsl.expected.glsl index 1048469..c3cf709 100644 --- a/test/tint/expressions/unary/negate/negate.wgsl.expected.glsl +++ b/test/tint/expressions/unary/negate/negate.wgsl.expected.glsl
@@ -1,10 +1,10 @@ #version 310 es int i(int x) { - return -(x); + return int((~(uint(x)) + 1u)); } ivec4 vi(ivec4 x) { - return -(x); + return ivec4((~(uvec4(x)) + uvec4(1u))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/expressions/unary/negate/negate.wgsl.expected.spvasm b/test/tint/expressions/unary/negate/negate.wgsl.expected.spvasm index 8d982b5..ba54b0d 100644 --- a/test/tint/expressions/unary/negate/negate.wgsl.expected.spvasm +++ b/test/tint/expressions/unary/negate/negate.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 17 +; Bound: 27 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -14,23 +14,33 @@ OpName %unused_entry_point "unused_entry_point" %int = OpTypeInt 32 1 %4 = OpTypeFunction %int %int + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 %v4int = OpTypeVector %int 4 - %10 = OpTypeFunction %v4int %v4int + %15 = OpTypeFunction %v4int %v4int + %v4uint = OpTypeVector %uint 4 + %21 = OpConstantComposite %v4uint %uint_1 %uint_1 %uint_1 %uint_1 %void = OpTypeVoid - %15 = OpTypeFunction %void + %25 = OpTypeFunction %void %i = OpFunction %int None %4 %x = OpFunctionParameter %int %5 = OpLabel - %6 = OpSNegate %int %x - OpReturnValue %6 + %7 = OpBitcast %uint %x + %8 = OpNot %uint %7 + %9 = OpIAdd %uint %8 %uint_1 + %11 = OpBitcast %int %9 + OpReturnValue %11 OpFunctionEnd - %vi = OpFunction %v4int None %10 + %vi = OpFunction %v4int None %15 %x_0 = OpFunctionParameter %v4int - %11 = OpLabel - %12 = OpSNegate %v4int %x_0 - OpReturnValue %12 - OpFunctionEnd -%unused_entry_point = OpFunction %void None %15 %16 = OpLabel + %18 = OpBitcast %v4uint %x_0 + %19 = OpNot %v4uint %18 + %20 = OpIAdd %v4uint %19 %21 + %22 = OpBitcast %v4int %20 + OpReturnValue %22 + OpFunctionEnd +%unused_entry_point = OpFunction %void None %25 + %26 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/expressions/user_call/multi_param_no_return.wgsl.expected.glsl b/test/tint/expressions/user_call/multi_param_no_return.wgsl.expected.glsl index f147152..bf144e9 100644 --- a/test/tint/expressions/user_call/multi_param_no_return.wgsl.expected.glsl +++ b/test/tint/expressions/user_call/multi_param_no_return.wgsl.expected.glsl
@@ -1,8 +1,12 @@ #version 310 es void c(int x, int y, int z) { - int a = (((1 + x) + y) + z); - a = (a + 2); + uint v = uint(1); + uint v_1 = uint(int((v + uint(x)))); + uint v_2 = uint(int((v_1 + uint(y)))); + int a = int((v_2 + uint(z))); + uint v_3 = uint(a); + a = int((v_3 + uint(2))); } void b() { c(1, 2, 3);
diff --git a/test/tint/expressions/user_call/multi_param_no_return.wgsl.expected.spvasm b/test/tint/expressions/user_call/multi_param_no_return.wgsl.expected.spvasm index 258b418..a785188 100644 --- a/test/tint/expressions/user_call/multi_param_no_return.wgsl.expected.spvasm +++ b/test/tint/expressions/user_call/multi_param_no_return.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 29 +; Bound: 42 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -17,10 +17,11 @@ %void = OpTypeVoid %int = OpTypeInt 32 1 %7 = OpTypeFunction %void %int %int %int + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %_ptr_Function_int = OpTypePointer Function %int %int_2 = OpConstant %int 2 - %19 = OpTypeFunction %void + %32 = OpTypeFunction %void %int_3 = OpConstant %int 3 %int_4 = OpConstant %int 4 %int_5 = OpConstant %int 5 @@ -31,22 +32,34 @@ %z = OpFunctionParameter %int %8 = OpLabel %a = OpVariable %_ptr_Function_int Function - %9 = OpIAdd %int %int_1 %x - %11 = OpIAdd %int %9 %y - %12 = OpIAdd %int %11 %z - OpStore %a %12 - %15 = OpLoad %int %a None - %16 = OpIAdd %int %15 %int_2 - OpStore %a %16 None + %10 = OpBitcast %uint %int_1 + %12 = OpBitcast %uint %x + %13 = OpIAdd %uint %10 %12 + %14 = OpBitcast %int %13 + %15 = OpBitcast %uint %14 + %16 = OpBitcast %uint %y + %17 = OpIAdd %uint %15 %16 + %18 = OpBitcast %int %17 + %19 = OpBitcast %uint %18 + %20 = OpBitcast %uint %z + %21 = OpIAdd %uint %19 %20 + %22 = OpBitcast %int %21 + OpStore %a %22 + %25 = OpLoad %int %a None + %26 = OpBitcast %uint %25 + %27 = OpBitcast %uint %int_2 + %29 = OpIAdd %uint %26 %27 + %30 = OpBitcast %int %29 + OpStore %a %30 None OpReturn OpFunctionEnd - %b = OpFunction %void None %19 - %20 = OpLabel - %21 = OpFunctionCall %void %c %int_1 %int_2 %int_3 - %23 = OpFunctionCall %void %c %int_4 %int_5 %int_6 + %b = OpFunction %void None %32 + %33 = OpLabel + %34 = OpFunctionCall %void %c %int_1 %int_2 %int_3 + %36 = OpFunctionCall %void %c %int_4 %int_5 %int_6 OpReturn OpFunctionEnd -%unused_entry_point = OpFunction %void None %19 - %28 = OpLabel +%unused_entry_point = OpFunction %void None %32 + %41 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/expressions/user_call/multi_param_return.wgsl.expected.glsl b/test/tint/expressions/user_call/multi_param_return.wgsl.expected.glsl index 3fd11b0..cc0ab06 100644 --- a/test/tint/expressions/user_call/multi_param_return.wgsl.expected.glsl +++ b/test/tint/expressions/user_call/multi_param_return.wgsl.expected.glsl
@@ -1,14 +1,19 @@ #version 310 es int c(int x, int y, int z) { - int a = (((1 + x) + y) + z); - a = (a + 2); + uint v = uint(1); + uint v_1 = uint(int((v + uint(x)))); + uint v_2 = uint(int((v_1 + uint(y)))); + int a = int((v_2 + uint(z))); + uint v_3 = uint(a); + a = int((v_3 + uint(2))); return a; } void b() { int b_1 = c(2, 3, 4); - int v = c(3, 4, 5); - b_1 = (b_1 + v); + int v_4 = c(3, 4, 5); + uint v_5 = uint(b_1); + b_1 = int((v_5 + uint(v_4))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/expressions/user_call/multi_param_return.wgsl.expected.spvasm b/test/tint/expressions/user_call/multi_param_return.wgsl.expected.spvasm index 3fb41db..926fec5 100644 --- a/test/tint/expressions/user_call/multi_param_return.wgsl.expected.spvasm +++ b/test/tint/expressions/user_call/multi_param_return.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 32 +; Bound: 48 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -17,11 +17,12 @@ OpName %unused_entry_point "unused_entry_point" %int = OpTypeInt 32 1 %6 = OpTypeFunction %int %int %int %int + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %_ptr_Function_int = OpTypePointer Function %int %int_2 = OpConstant %int 2 %void = OpTypeVoid - %20 = OpTypeFunction %void + %33 = OpTypeFunction %void %int_3 = OpConstant %int 3 %int_4 = OpConstant %int 4 %int_5 = OpConstant %int 5 @@ -31,28 +32,43 @@ %z = OpFunctionParameter %int %7 = OpLabel %a = OpVariable %_ptr_Function_int Function - %8 = OpIAdd %int %int_1 %x - %10 = OpIAdd %int %8 %y - %11 = OpIAdd %int %10 %z - OpStore %a %11 - %14 = OpLoad %int %a None - %15 = OpIAdd %int %14 %int_2 - OpStore %a %15 None - %17 = OpLoad %int %a None - OpReturnValue %17 + %9 = OpBitcast %uint %int_1 + %11 = OpBitcast %uint %x + %12 = OpIAdd %uint %9 %11 + %13 = OpBitcast %int %12 + %14 = OpBitcast %uint %13 + %15 = OpBitcast %uint %y + %16 = OpIAdd %uint %14 %15 + %17 = OpBitcast %int %16 + %18 = OpBitcast %uint %17 + %19 = OpBitcast %uint %z + %20 = OpIAdd %uint %18 %19 + %21 = OpBitcast %int %20 + OpStore %a %21 + %24 = OpLoad %int %a None + %25 = OpBitcast %uint %24 + %26 = OpBitcast %uint %int_2 + %28 = OpIAdd %uint %25 %26 + %29 = OpBitcast %int %28 + OpStore %a %29 None + %30 = OpLoad %int %a None + OpReturnValue %30 OpFunctionEnd - %b = OpFunction %void None %20 - %21 = OpLabel + %b = OpFunction %void None %33 + %34 = OpLabel %b_0 = OpVariable %_ptr_Function_int Function - %22 = OpFunctionCall %int %c %int_2 %int_3 %int_4 - OpStore %b_0 %22 - %26 = OpFunctionCall %int %c %int_3 %int_4 %int_5 - %28 = OpLoad %int %b_0 None - %29 = OpIAdd %int %28 %26 - OpStore %b_0 %29 None + %35 = OpFunctionCall %int %c %int_2 %int_3 %int_4 + OpStore %b_0 %35 + %39 = OpFunctionCall %int %c %int_3 %int_4 %int_5 + %41 = OpLoad %int %b_0 None + %42 = OpBitcast %uint %41 + %43 = OpBitcast %uint %39 + %44 = OpIAdd %uint %42 %43 + %45 = OpBitcast %int %44 + OpStore %b_0 %45 None OpReturn OpFunctionEnd -%unused_entry_point = OpFunction %void None %20 - %31 = OpLabel +%unused_entry_point = OpFunction %void None %33 + %47 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/expressions/user_call/no_params_no_return.wgsl.expected.glsl b/test/tint/expressions/user_call/no_params_no_return.wgsl.expected.glsl index 3a063cf..ca45d0a 100644 --- a/test/tint/expressions/user_call/no_params_no_return.wgsl.expected.glsl +++ b/test/tint/expressions/user_call/no_params_no_return.wgsl.expected.glsl
@@ -2,7 +2,8 @@ void c() { int a = 1; - a = (a + 2); + uint v = uint(a); + a = int((v + uint(2))); } void b() { c();
diff --git a/test/tint/expressions/user_call/no_params_no_return.wgsl.expected.spvasm b/test/tint/expressions/user_call/no_params_no_return.wgsl.expected.spvasm index e83e83a..fa7500e 100644 --- a/test/tint/expressions/user_call/no_params_no_return.wgsl.expected.spvasm +++ b/test/tint/expressions/user_call/no_params_no_return.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 18 +; Bound: 22 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -16,23 +16,27 @@ %int = OpTypeInt 32 1 %_ptr_Function_int = OpTypePointer Function %int %int_1 = OpConstant %int 1 + %uint = OpTypeInt 32 0 %int_2 = OpConstant %int 2 %c = OpFunction %void None %3 %4 = OpLabel %a = OpVariable %_ptr_Function_int Function OpStore %a %int_1 %9 = OpLoad %int %a None - %10 = OpIAdd %int %9 %int_2 - OpStore %a %10 None + %11 = OpBitcast %uint %9 + %12 = OpBitcast %uint %int_2 + %14 = OpIAdd %uint %11 %12 + %15 = OpBitcast %int %14 + OpStore %a %15 None OpReturn OpFunctionEnd %b = OpFunction %void None %3 - %13 = OpLabel - %14 = OpFunctionCall %void %c - %15 = OpFunctionCall %void %c + %17 = OpLabel + %18 = OpFunctionCall %void %c + %19 = OpFunctionCall %void %c OpReturn OpFunctionEnd %unused_entry_point = OpFunction %void None %3 - %17 = OpLabel + %21 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/expressions/user_call/no_params_return.wgsl.expected.glsl b/test/tint/expressions/user_call/no_params_return.wgsl.expected.glsl index f6c9676..5e5235a 100644 --- a/test/tint/expressions/user_call/no_params_return.wgsl.expected.glsl +++ b/test/tint/expressions/user_call/no_params_return.wgsl.expected.glsl
@@ -2,13 +2,15 @@ int c() { int a = 1; - a = (a + 2); + uint v = uint(a); + a = int((v + uint(2))); return a; } void b() { int b_1 = c(); - int v = c(); - b_1 = (b_1 + v); + int v_1 = c(); + uint v_2 = uint(b_1); + b_1 = int((v_2 + uint(v_1))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/expressions/user_call/no_params_return.wgsl.expected.spvasm b/test/tint/expressions/user_call/no_params_return.wgsl.expected.spvasm index d2a2583..2139b85 100644 --- a/test/tint/expressions/user_call/no_params_return.wgsl.expected.spvasm +++ b/test/tint/expressions/user_call/no_params_return.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 23 +; Bound: 30 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -16,31 +16,38 @@ %3 = OpTypeFunction %int %_ptr_Function_int = OpTypePointer Function %int %int_1 = OpConstant %int 1 + %uint = OpTypeInt 32 0 %int_2 = OpConstant %int 2 %void = OpTypeVoid - %14 = OpTypeFunction %void + %18 = OpTypeFunction %void %c = OpFunction %int None %3 %4 = OpLabel %a = OpVariable %_ptr_Function_int Function OpStore %a %int_1 %8 = OpLoad %int %a None - %9 = OpIAdd %int %8 %int_2 - OpStore %a %9 None - %11 = OpLoad %int %a None - OpReturnValue %11 + %10 = OpBitcast %uint %8 + %11 = OpBitcast %uint %int_2 + %13 = OpIAdd %uint %10 %11 + %14 = OpBitcast %int %13 + OpStore %a %14 None + %15 = OpLoad %int %a None + OpReturnValue %15 OpFunctionEnd - %b = OpFunction %void None %14 - %15 = OpLabel + %b = OpFunction %void None %18 + %19 = OpLabel %b_0 = OpVariable %_ptr_Function_int Function - %16 = OpFunctionCall %int %c - OpStore %b_0 %16 - %18 = OpFunctionCall %int %c - %19 = OpLoad %int %b_0 None - %20 = OpIAdd %int %19 %18 - OpStore %b_0 %20 None + %20 = OpFunctionCall %int %c + OpStore %b_0 %20 + %22 = OpFunctionCall %int %c + %23 = OpLoad %int %b_0 None + %24 = OpBitcast %uint %23 + %25 = OpBitcast %uint %22 + %26 = OpIAdd %uint %24 %25 + %27 = OpBitcast %int %26 + OpStore %b_0 %27 None OpReturn OpFunctionEnd -%unused_entry_point = OpFunction %void None %14 - %22 = OpLabel +%unused_entry_point = OpFunction %void None %18 + %29 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/expressions/user_call/one_param_no_return.wgsl.expected.glsl b/test/tint/expressions/user_call/one_param_no_return.wgsl.expected.glsl index a8618b6..e4538b1 100644 --- a/test/tint/expressions/user_call/one_param_no_return.wgsl.expected.glsl +++ b/test/tint/expressions/user_call/one_param_no_return.wgsl.expected.glsl
@@ -1,8 +1,10 @@ #version 310 es void c(int z) { - int a = (1 + z); - a = (a + 2); + uint v = uint(1); + int a = int((v + uint(z))); + uint v_1 = uint(a); + a = int((v_1 + uint(2))); } void b() { c(2);
diff --git a/test/tint/expressions/user_call/one_param_no_return.wgsl.expected.spvasm b/test/tint/expressions/user_call/one_param_no_return.wgsl.expected.spvasm index 0d8c53a..fdf9ead 100644 --- a/test/tint/expressions/user_call/one_param_no_return.wgsl.expected.spvasm +++ b/test/tint/expressions/user_call/one_param_no_return.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 22 +; Bound: 29 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -15,29 +15,36 @@ %void = OpTypeVoid %int = OpTypeInt 32 1 %5 = OpTypeFunction %void %int + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %_ptr_Function_int = OpTypePointer Function %int %int_2 = OpConstant %int 2 - %15 = OpTypeFunction %void + %22 = OpTypeFunction %void %int_3 = OpConstant %int 3 %c = OpFunction %void None %5 %z = OpFunctionParameter %int %6 = OpLabel %a = OpVariable %_ptr_Function_int Function - %7 = OpIAdd %int %int_1 %z - OpStore %a %7 - %11 = OpLoad %int %a None - %12 = OpIAdd %int %11 %int_2 - OpStore %a %12 None + %8 = OpBitcast %uint %int_1 + %10 = OpBitcast %uint %z + %11 = OpIAdd %uint %8 %10 + %12 = OpBitcast %int %11 + OpStore %a %12 + %15 = OpLoad %int %a None + %16 = OpBitcast %uint %15 + %17 = OpBitcast %uint %int_2 + %19 = OpIAdd %uint %16 %17 + %20 = OpBitcast %int %19 + OpStore %a %20 None OpReturn OpFunctionEnd - %b = OpFunction %void None %15 - %16 = OpLabel - %17 = OpFunctionCall %void %c %int_2 - %18 = OpFunctionCall %void %c %int_3 + %b = OpFunction %void None %22 + %23 = OpLabel + %24 = OpFunctionCall %void %c %int_2 + %25 = OpFunctionCall %void %c %int_3 OpReturn OpFunctionEnd -%unused_entry_point = OpFunction %void None %15 - %21 = OpLabel +%unused_entry_point = OpFunction %void None %22 + %28 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/expressions/user_call/one_param_return.wgsl.expected.glsl b/test/tint/expressions/user_call/one_param_return.wgsl.expected.glsl index 98d339a..b423ed3 100644 --- a/test/tint/expressions/user_call/one_param_return.wgsl.expected.glsl +++ b/test/tint/expressions/user_call/one_param_return.wgsl.expected.glsl
@@ -1,14 +1,17 @@ #version 310 es int c(int z) { - int a = (1 + z); - a = (a + 2); + uint v = uint(1); + int a = int((v + uint(z))); + uint v_1 = uint(a); + a = int((v_1 + uint(2))); return a; } void b() { int b_1 = c(2); - int v = c(3); - b_1 = (b_1 + v); + int v_2 = c(3); + uint v_3 = uint(b_1); + b_1 = int((v_3 + uint(v_2))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/expressions/user_call/one_param_return.wgsl.expected.spvasm b/test/tint/expressions/user_call/one_param_return.wgsl.expected.spvasm index 82f2227..3b4a9df 100644 --- a/test/tint/expressions/user_call/one_param_return.wgsl.expected.spvasm +++ b/test/tint/expressions/user_call/one_param_return.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 26 +; Bound: 36 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -15,36 +15,46 @@ OpName %unused_entry_point "unused_entry_point" %int = OpTypeInt 32 1 %4 = OpTypeFunction %int %int + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %_ptr_Function_int = OpTypePointer Function %int %int_2 = OpConstant %int 2 %void = OpTypeVoid - %16 = OpTypeFunction %void + %23 = OpTypeFunction %void %int_3 = OpConstant %int 3 %c = OpFunction %int None %4 %z = OpFunctionParameter %int %5 = OpLabel %a = OpVariable %_ptr_Function_int Function - %6 = OpIAdd %int %int_1 %z - OpStore %a %6 - %10 = OpLoad %int %a None - %11 = OpIAdd %int %10 %int_2 - OpStore %a %11 None - %13 = OpLoad %int %a None - OpReturnValue %13 + %7 = OpBitcast %uint %int_1 + %9 = OpBitcast %uint %z + %10 = OpIAdd %uint %7 %9 + %11 = OpBitcast %int %10 + OpStore %a %11 + %14 = OpLoad %int %a None + %15 = OpBitcast %uint %14 + %16 = OpBitcast %uint %int_2 + %18 = OpIAdd %uint %15 %16 + %19 = OpBitcast %int %18 + OpStore %a %19 None + %20 = OpLoad %int %a None + OpReturnValue %20 OpFunctionEnd - %b = OpFunction %void None %16 - %17 = OpLabel + %b = OpFunction %void None %23 + %24 = OpLabel %b_0 = OpVariable %_ptr_Function_int Function - %18 = OpFunctionCall %int %c %int_2 - OpStore %b_0 %18 - %20 = OpFunctionCall %int %c %int_3 - %22 = OpLoad %int %b_0 None - %23 = OpIAdd %int %22 %20 - OpStore %b_0 %23 None + %25 = OpFunctionCall %int %c %int_2 + OpStore %b_0 %25 + %27 = OpFunctionCall %int %c %int_3 + %29 = OpLoad %int %b_0 None + %30 = OpBitcast %uint %29 + %31 = OpBitcast %uint %27 + %32 = OpIAdd %uint %30 %31 + %33 = OpBitcast %int %32 + OpStore %b_0 %33 None OpReturn OpFunctionEnd -%unused_entry_point = OpFunction %void None %16 - %25 = OpLabel +%unused_entry_point = OpFunction %void None %23 + %35 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/identifiers/underscore/double/alias.wgsl.expected.glsl b/test/tint/identifiers/underscore/double/alias.wgsl.expected.glsl index 67c38dc..5dd46a1 100644 --- a/test/tint/identifiers/underscore/double/alias.wgsl.expected.glsl +++ b/test/tint/identifiers/underscore/double/alias.wgsl.expected.glsl
@@ -8,5 +8,7 @@ void main() { int c = 0; int d = 0; - v.inner = (c + d); + int v_1 = d; + uint v_2 = uint(c); + v.inner = int((v_2 + uint(v_1))); }
diff --git a/test/tint/identifiers/underscore/double/alias.wgsl.expected.spvasm b/test/tint/identifiers/underscore/double/alias.wgsl.expected.spvasm index f5d464f..7730e3a 100644 --- a/test/tint/identifiers/underscore/double/alias.wgsl.expected.spvasm +++ b/test/tint/identifiers/underscore/double/alias.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 20 +; Bound: 23 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -25,8 +25,8 @@ %7 = OpTypeFunction %void %_ptr_Function_int = OpTypePointer Function %int %11 = OpConstantNull %int -%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int %uint = OpTypeInt 32 0 +%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int %uint_0 = OpConstant %uint 0 %f = OpFunction %void None %7 %8 = OpLabel @@ -34,8 +34,11 @@ %d = OpVariable %_ptr_Function_int Function %11 %13 = OpLoad %int %c None %14 = OpLoad %int %d None - %15 = OpIAdd %int %13 %14 - %16 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 - OpStore %16 %15 None + %16 = OpBitcast %uint %13 + %17 = OpBitcast %uint %14 + %18 = OpIAdd %uint %16 %17 + %19 = OpBitcast %int %18 + %20 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 + OpStore %20 %19 None OpReturn OpFunctionEnd
diff --git a/test/tint/identifiers/underscore/double/let.wgsl.expected.glsl b/test/tint/identifiers/underscore/double/let.wgsl.expected.glsl index eea1104..a1bbbfd 100644 --- a/test/tint/identifiers/underscore/double/let.wgsl.expected.glsl +++ b/test/tint/identifiers/underscore/double/let.wgsl.expected.glsl
@@ -10,5 +10,8 @@ int v_1 = a; int b = a; int v_2 = v_1; - v.inner = (((a + v_1) + b) + v_2); + uint v_3 = uint(a); + uint v_4 = uint(int((v_3 + uint(v_1)))); + uint v_5 = uint(int((v_4 + uint(b)))); + v.inner = int((v_5 + uint(v_2))); }
diff --git a/test/tint/identifiers/underscore/double/let.wgsl.expected.spvasm b/test/tint/identifiers/underscore/double/let.wgsl.expected.spvasm index 4899b7a..e693c67 100644 --- a/test/tint/identifiers/underscore/double/let.wgsl.expected.spvasm +++ b/test/tint/identifiers/underscore/double/let.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 17 +; Bound: 26 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -26,15 +26,24 @@ %void = OpTypeVoid %7 = OpTypeFunction %void %a = OpConstant %int 1 -%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int %uint = OpTypeInt 32 0 +%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int %uint_0 = OpConstant %uint 0 %f = OpFunction %void None %7 %8 = OpLabel - %10 = OpIAdd %int %a %a - %11 = OpIAdd %int %10 %a - %12 = OpIAdd %int %11 %a - %13 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 - OpStore %13 %12 None + %11 = OpBitcast %uint %a + %12 = OpBitcast %uint %a + %13 = OpIAdd %uint %11 %12 + %14 = OpBitcast %int %13 + %15 = OpBitcast %uint %14 + %16 = OpBitcast %uint %a + %17 = OpIAdd %uint %15 %16 + %18 = OpBitcast %int %17 + %19 = OpBitcast %uint %18 + %20 = OpBitcast %uint %a + %21 = OpIAdd %uint %19 %20 + %22 = OpBitcast %int %21 + %23 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 + OpStore %23 %22 None OpReturn OpFunctionEnd
diff --git a/test/tint/identifiers/underscore/double/struct.wgsl.expected.glsl b/test/tint/identifiers/underscore/double/struct.wgsl.expected.glsl index f3c5029..512feef 100644 --- a/test/tint/identifiers/underscore/double/struct.wgsl.expected.glsl +++ b/test/tint/identifiers/underscore/double/struct.wgsl.expected.glsl
@@ -13,5 +13,6 @@ void main() { tint_struct c = tint_struct(0); int d = c.member_0; - v.inner = (c.member_0 + d); + uint v_1 = uint(c.member_0); + v.inner = int((v_1 + uint(d))); }
diff --git a/test/tint/identifiers/underscore/double/struct.wgsl.expected.spvasm b/test/tint/identifiers/underscore/double/struct.wgsl.expected.spvasm index 088b54b..540444a 100644 --- a/test/tint/identifiers/underscore/double/struct.wgsl.expected.spvasm +++ b/test/tint/identifiers/underscore/double/struct.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 18 +; Bound: 21 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -27,15 +27,18 @@ %7 = OpTypeFunction %void %a__ = OpTypeStruct %int %c = OpConstantNull %a__ -%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int %uint = OpTypeInt 32 0 +%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int %uint_0 = OpConstant %uint 0 %f = OpFunction %void None %7 %8 = OpLabel %d = OpCompositeExtract %int %c 0 %12 = OpCompositeExtract %int %c 0 - %13 = OpIAdd %int %12 %d - %14 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 - OpStore %14 %13 None + %14 = OpBitcast %uint %12 + %15 = OpBitcast %uint %d + %16 = OpIAdd %uint %14 %15 + %17 = OpBitcast %int %16 + %18 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 + OpStore %18 %17 None OpReturn OpFunctionEnd
diff --git a/test/tint/identifiers/underscore/double/var.wgsl.expected.glsl b/test/tint/identifiers/underscore/double/var.wgsl.expected.glsl index 56b0f56..02c8e11 100644 --- a/test/tint/identifiers/underscore/double/var.wgsl.expected.glsl +++ b/test/tint/identifiers/underscore/double/var.wgsl.expected.glsl
@@ -10,5 +10,7 @@ void main() { int b = a; int v_2 = v_1; - v.inner = (b + v_2); + int v_3 = v_2; + uint v_4 = uint(b); + v.inner = int((v_4 + uint(v_3))); }
diff --git a/test/tint/identifiers/underscore/double/var.wgsl.expected.spvasm b/test/tint/identifiers/underscore/double/var.wgsl.expected.spvasm index 8962887..75a1961 100644 --- a/test/tint/identifiers/underscore/double/var.wgsl.expected.spvasm +++ b/test/tint/identifiers/underscore/double/var.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 26 +; Bound: 29 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -31,8 +31,8 @@ %void = OpTypeVoid %12 = OpTypeFunction %void %_ptr_Function_int = OpTypePointer Function %int -%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int %uint = OpTypeInt 32 0 +%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int %uint_0 = OpConstant %uint 0 %f = OpFunction %void None %12 %13 = OpLabel @@ -44,8 +44,11 @@ OpStore %b__ %17 %19 = OpLoad %int %b None %20 = OpLoad %int %b__ None - %21 = OpIAdd %int %19 %20 - %22 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 - OpStore %22 %21 None + %22 = OpBitcast %uint %19 + %23 = OpBitcast %uint %20 + %24 = OpIAdd %uint %22 %23 + %25 = OpBitcast %int %24 + %26 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 + OpStore %26 %25 None OpReturn OpFunctionEnd
diff --git a/test/tint/identifiers/underscore/prefix/lower/alias.wgsl.expected.glsl b/test/tint/identifiers/underscore/prefix/lower/alias.wgsl.expected.glsl index 67c38dc..5dd46a1 100644 --- a/test/tint/identifiers/underscore/prefix/lower/alias.wgsl.expected.glsl +++ b/test/tint/identifiers/underscore/prefix/lower/alias.wgsl.expected.glsl
@@ -8,5 +8,7 @@ void main() { int c = 0; int d = 0; - v.inner = (c + d); + int v_1 = d; + uint v_2 = uint(c); + v.inner = int((v_2 + uint(v_1))); }
diff --git a/test/tint/identifiers/underscore/prefix/lower/alias.wgsl.expected.spvasm b/test/tint/identifiers/underscore/prefix/lower/alias.wgsl.expected.spvasm index f5d464f..7730e3a 100644 --- a/test/tint/identifiers/underscore/prefix/lower/alias.wgsl.expected.spvasm +++ b/test/tint/identifiers/underscore/prefix/lower/alias.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 20 +; Bound: 23 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -25,8 +25,8 @@ %7 = OpTypeFunction %void %_ptr_Function_int = OpTypePointer Function %int %11 = OpConstantNull %int -%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int %uint = OpTypeInt 32 0 +%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int %uint_0 = OpConstant %uint 0 %f = OpFunction %void None %7 %8 = OpLabel @@ -34,8 +34,11 @@ %d = OpVariable %_ptr_Function_int Function %11 %13 = OpLoad %int %c None %14 = OpLoad %int %d None - %15 = OpIAdd %int %13 %14 - %16 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 - OpStore %16 %15 None + %16 = OpBitcast %uint %13 + %17 = OpBitcast %uint %14 + %18 = OpIAdd %uint %16 %17 + %19 = OpBitcast %int %18 + %20 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 + OpStore %20 %19 None OpReturn OpFunctionEnd
diff --git a/test/tint/identifiers/underscore/prefix/lower/let.wgsl.expected.glsl b/test/tint/identifiers/underscore/prefix/lower/let.wgsl.expected.glsl index 3cbfec9..12d0f64 100644 --- a/test/tint/identifiers/underscore/prefix/lower/let.wgsl.expected.glsl +++ b/test/tint/identifiers/underscore/prefix/lower/let.wgsl.expected.glsl
@@ -10,5 +10,8 @@ int _a = a; int b = a; int _b = _a; - v.inner = (((a + _a) + b) + _b); + uint v_1 = uint(a); + uint v_2 = uint(int((v_1 + uint(_a)))); + uint v_3 = uint(int((v_2 + uint(b)))); + v.inner = int((v_3 + uint(_b))); }
diff --git a/test/tint/identifiers/underscore/prefix/lower/let.wgsl.expected.spvasm b/test/tint/identifiers/underscore/prefix/lower/let.wgsl.expected.spvasm index 57b60e3..11f2739 100644 --- a/test/tint/identifiers/underscore/prefix/lower/let.wgsl.expected.spvasm +++ b/test/tint/identifiers/underscore/prefix/lower/let.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 17 +; Bound: 26 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -26,15 +26,24 @@ %void = OpTypeVoid %7 = OpTypeFunction %void %a = OpConstant %int 1 -%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int %uint = OpTypeInt 32 0 +%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int %uint_0 = OpConstant %uint 0 %f = OpFunction %void None %7 %8 = OpLabel - %10 = OpIAdd %int %a %a - %11 = OpIAdd %int %10 %a - %12 = OpIAdd %int %11 %a - %13 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 - OpStore %13 %12 None + %11 = OpBitcast %uint %a + %12 = OpBitcast %uint %a + %13 = OpIAdd %uint %11 %12 + %14 = OpBitcast %int %13 + %15 = OpBitcast %uint %14 + %16 = OpBitcast %uint %a + %17 = OpIAdd %uint %15 %16 + %18 = OpBitcast %int %17 + %19 = OpBitcast %uint %18 + %20 = OpBitcast %uint %a + %21 = OpIAdd %uint %19 %20 + %22 = OpBitcast %int %21 + %23 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 + OpStore %23 %22 None OpReturn OpFunctionEnd
diff --git a/test/tint/identifiers/underscore/prefix/lower/struct.wgsl.expected.glsl b/test/tint/identifiers/underscore/prefix/lower/struct.wgsl.expected.glsl index f6624e5..82f2211 100644 --- a/test/tint/identifiers/underscore/prefix/lower/struct.wgsl.expected.glsl +++ b/test/tint/identifiers/underscore/prefix/lower/struct.wgsl.expected.glsl
@@ -13,5 +13,6 @@ void main() { _a c = _a(0); int d = c._b; - v.inner = (c._b + d); + uint v_1 = uint(c._b); + v.inner = int((v_1 + uint(d))); }
diff --git a/test/tint/identifiers/underscore/prefix/lower/struct.wgsl.expected.spvasm b/test/tint/identifiers/underscore/prefix/lower/struct.wgsl.expected.spvasm index eaf63b5..f441f70 100644 --- a/test/tint/identifiers/underscore/prefix/lower/struct.wgsl.expected.spvasm +++ b/test/tint/identifiers/underscore/prefix/lower/struct.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 18 +; Bound: 21 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -27,15 +27,18 @@ %7 = OpTypeFunction %void %_a = OpTypeStruct %int %c = OpConstantNull %_a -%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int %uint = OpTypeInt 32 0 +%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int %uint_0 = OpConstant %uint 0 %f = OpFunction %void None %7 %8 = OpLabel %d = OpCompositeExtract %int %c 0 %12 = OpCompositeExtract %int %c 0 - %13 = OpIAdd %int %12 %d - %14 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 - OpStore %14 %13 None + %14 = OpBitcast %uint %12 + %15 = OpBitcast %uint %d + %16 = OpIAdd %uint %14 %15 + %17 = OpBitcast %int %16 + %18 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 + OpStore %18 %17 None OpReturn OpFunctionEnd
diff --git a/test/tint/identifiers/underscore/prefix/lower/var.wgsl.expected.glsl b/test/tint/identifiers/underscore/prefix/lower/var.wgsl.expected.glsl index e4a7eaf..14189c5 100644 --- a/test/tint/identifiers/underscore/prefix/lower/var.wgsl.expected.glsl +++ b/test/tint/identifiers/underscore/prefix/lower/var.wgsl.expected.glsl
@@ -10,5 +10,7 @@ void main() { int b = a; int _b = _a; - v.inner = (b + _b); + int v_1 = _b; + uint v_2 = uint(b); + v.inner = int((v_2 + uint(v_1))); }
diff --git a/test/tint/identifiers/underscore/prefix/lower/var.wgsl.expected.spvasm b/test/tint/identifiers/underscore/prefix/lower/var.wgsl.expected.spvasm index 493a14b..68ee95d 100644 --- a/test/tint/identifiers/underscore/prefix/lower/var.wgsl.expected.spvasm +++ b/test/tint/identifiers/underscore/prefix/lower/var.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 26 +; Bound: 29 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -31,8 +31,8 @@ %void = OpTypeVoid %12 = OpTypeFunction %void %_ptr_Function_int = OpTypePointer Function %int -%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int %uint = OpTypeInt 32 0 +%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int %uint_0 = OpConstant %uint 0 %f = OpFunction %void None %12 %13 = OpLabel @@ -44,8 +44,11 @@ OpStore %_b %17 %19 = OpLoad %int %b None %20 = OpLoad %int %_b None - %21 = OpIAdd %int %19 %20 - %22 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 - OpStore %22 %21 None + %22 = OpBitcast %uint %19 + %23 = OpBitcast %uint %20 + %24 = OpIAdd %uint %22 %23 + %25 = OpBitcast %int %24 + %26 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 + OpStore %26 %25 None OpReturn OpFunctionEnd
diff --git a/test/tint/identifiers/underscore/prefix/upper/alias.wgsl.expected.glsl b/test/tint/identifiers/underscore/prefix/upper/alias.wgsl.expected.glsl index 67c38dc..5dd46a1 100644 --- a/test/tint/identifiers/underscore/prefix/upper/alias.wgsl.expected.glsl +++ b/test/tint/identifiers/underscore/prefix/upper/alias.wgsl.expected.glsl
@@ -8,5 +8,7 @@ void main() { int c = 0; int d = 0; - v.inner = (c + d); + int v_1 = d; + uint v_2 = uint(c); + v.inner = int((v_2 + uint(v_1))); }
diff --git a/test/tint/identifiers/underscore/prefix/upper/alias.wgsl.expected.spvasm b/test/tint/identifiers/underscore/prefix/upper/alias.wgsl.expected.spvasm index f5d464f..7730e3a 100644 --- a/test/tint/identifiers/underscore/prefix/upper/alias.wgsl.expected.spvasm +++ b/test/tint/identifiers/underscore/prefix/upper/alias.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 20 +; Bound: 23 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -25,8 +25,8 @@ %7 = OpTypeFunction %void %_ptr_Function_int = OpTypePointer Function %int %11 = OpConstantNull %int -%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int %uint = OpTypeInt 32 0 +%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int %uint_0 = OpConstant %uint 0 %f = OpFunction %void None %7 %8 = OpLabel @@ -34,8 +34,11 @@ %d = OpVariable %_ptr_Function_int Function %11 %13 = OpLoad %int %c None %14 = OpLoad %int %d None - %15 = OpIAdd %int %13 %14 - %16 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 - OpStore %16 %15 None + %16 = OpBitcast %uint %13 + %17 = OpBitcast %uint %14 + %18 = OpIAdd %uint %16 %17 + %19 = OpBitcast %int %18 + %20 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 + OpStore %20 %19 None OpReturn OpFunctionEnd
diff --git a/test/tint/identifiers/underscore/prefix/upper/let.wgsl.expected.glsl b/test/tint/identifiers/underscore/prefix/upper/let.wgsl.expected.glsl index a643f8a..6f53d70 100644 --- a/test/tint/identifiers/underscore/prefix/upper/let.wgsl.expected.glsl +++ b/test/tint/identifiers/underscore/prefix/upper/let.wgsl.expected.glsl
@@ -10,5 +10,8 @@ int _A = 2; int B = A; int _B = _A; - v.inner = (((A + _A) + B) + _B); + uint v_1 = uint(A); + uint v_2 = uint(int((v_1 + uint(_A)))); + uint v_3 = uint(int((v_2 + uint(B)))); + v.inner = int((v_3 + uint(_B))); }
diff --git a/test/tint/identifiers/underscore/prefix/upper/let.wgsl.expected.spvasm b/test/tint/identifiers/underscore/prefix/upper/let.wgsl.expected.spvasm index f8e3ef1..8171bcd 100644 --- a/test/tint/identifiers/underscore/prefix/upper/let.wgsl.expected.spvasm +++ b/test/tint/identifiers/underscore/prefix/upper/let.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 18 +; Bound: 27 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -27,15 +27,24 @@ %7 = OpTypeFunction %void %A = OpConstant %int 1 %_A = OpConstant %int 2 -%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int %uint = OpTypeInt 32 0 +%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int %uint_0 = OpConstant %uint 0 %f = OpFunction %void None %7 %8 = OpLabel - %11 = OpIAdd %int %A %_A - %12 = OpIAdd %int %11 %A - %13 = OpIAdd %int %12 %_A - %14 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 - OpStore %14 %13 None + %12 = OpBitcast %uint %A + %13 = OpBitcast %uint %_A + %14 = OpIAdd %uint %12 %13 + %15 = OpBitcast %int %14 + %16 = OpBitcast %uint %15 + %17 = OpBitcast %uint %A + %18 = OpIAdd %uint %16 %17 + %19 = OpBitcast %int %18 + %20 = OpBitcast %uint %19 + %21 = OpBitcast %uint %_A + %22 = OpIAdd %uint %20 %21 + %23 = OpBitcast %int %22 + %24 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 + OpStore %24 %23 None OpReturn OpFunctionEnd
diff --git a/test/tint/identifiers/underscore/prefix/upper/struct.wgsl.expected.glsl b/test/tint/identifiers/underscore/prefix/upper/struct.wgsl.expected.glsl index 013ea7c..272c6e6 100644 --- a/test/tint/identifiers/underscore/prefix/upper/struct.wgsl.expected.glsl +++ b/test/tint/identifiers/underscore/prefix/upper/struct.wgsl.expected.glsl
@@ -13,5 +13,6 @@ void main() { _A c = _A(0); int d = c._B; - v.inner = (c._B + d); + uint v_1 = uint(c._B); + v.inner = int((v_1 + uint(d))); }
diff --git a/test/tint/identifiers/underscore/prefix/upper/struct.wgsl.expected.spvasm b/test/tint/identifiers/underscore/prefix/upper/struct.wgsl.expected.spvasm index e3776b6a..4b31726 100644 --- a/test/tint/identifiers/underscore/prefix/upper/struct.wgsl.expected.spvasm +++ b/test/tint/identifiers/underscore/prefix/upper/struct.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 18 +; Bound: 21 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -27,15 +27,18 @@ %7 = OpTypeFunction %void %_A = OpTypeStruct %int %c = OpConstantNull %_A -%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int %uint = OpTypeInt 32 0 +%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int %uint_0 = OpConstant %uint 0 %f = OpFunction %void None %7 %8 = OpLabel %d = OpCompositeExtract %int %c 0 %12 = OpCompositeExtract %int %c 0 - %13 = OpIAdd %int %12 %d - %14 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 - OpStore %14 %13 None + %14 = OpBitcast %uint %12 + %15 = OpBitcast %uint %d + %16 = OpIAdd %uint %14 %15 + %17 = OpBitcast %int %16 + %18 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 + OpStore %18 %17 None OpReturn OpFunctionEnd
diff --git a/test/tint/identifiers/underscore/prefix/upper/var.wgsl.expected.glsl b/test/tint/identifiers/underscore/prefix/upper/var.wgsl.expected.glsl index 6f062ec..1d33b1f 100644 --- a/test/tint/identifiers/underscore/prefix/upper/var.wgsl.expected.glsl +++ b/test/tint/identifiers/underscore/prefix/upper/var.wgsl.expected.glsl
@@ -10,5 +10,7 @@ void main() { int B = A; int _B = _A; - v.inner = (B + _B); + int v_1 = _B; + uint v_2 = uint(B); + v.inner = int((v_2 + uint(v_1))); }
diff --git a/test/tint/identifiers/underscore/prefix/upper/var.wgsl.expected.spvasm b/test/tint/identifiers/underscore/prefix/upper/var.wgsl.expected.spvasm index 82f92b0..2e10df8 100644 --- a/test/tint/identifiers/underscore/prefix/upper/var.wgsl.expected.spvasm +++ b/test/tint/identifiers/underscore/prefix/upper/var.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 26 +; Bound: 29 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -31,8 +31,8 @@ %void = OpTypeVoid %12 = OpTypeFunction %void %_ptr_Function_int = OpTypePointer Function %int -%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int %uint = OpTypeInt 32 0 +%_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int %uint_0 = OpConstant %uint 0 %f = OpFunction %void None %12 %13 = OpLabel @@ -44,8 +44,11 @@ OpStore %_B %17 %19 = OpLoad %int %B None %20 = OpLoad %int %_B None - %21 = OpIAdd %int %19 %20 - %22 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 - OpStore %22 %21 None + %22 = OpBitcast %uint %19 + %23 = OpBitcast %uint %20 + %24 = OpIAdd %uint %22 %23 + %25 = OpBitcast %int %24 + %26 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 + OpStore %26 %25 None OpReturn OpFunctionEnd
diff --git a/test/tint/loops/continue_in_switch.wgsl.expected.glsl b/test/tint/loops/continue_in_switch.wgsl.expected.glsl index 27f7439..4a8900d 100644 --- a/test/tint/loops/continue_in_switch.wgsl.expected.glsl +++ b/test/tint/loops/continue_in_switch.wgsl.expected.glsl
@@ -23,12 +23,14 @@ } if (tint_continue) { { - i = (i + 1); + uint v = uint(i); + i = int((v + uint(1))); } continue; } { - i = (i + 1); + uint v = uint(i); + i = int((v + uint(1))); } continue; }
diff --git a/test/tint/loops/continue_in_switch.wgsl.expected.spvasm b/test/tint/loops/continue_in_switch.wgsl.expected.spvasm index c129631..a125480 100644 --- a/test/tint/loops/continue_in_switch.wgsl.expected.spvasm +++ b/test/tint/loops/continue_in_switch.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 27 +; Bound: 31 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -16,6 +16,7 @@ %int_0 = OpConstant %int 0 %int_4 = OpConstant %int 4 %bool = OpTypeBool + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %f = OpFunction %void None %3 %4 = OpLabel @@ -46,8 +47,11 @@ OpBranch %7 %7 = OpLabel %24 = OpLoad %int %i None - %25 = OpIAdd %int %24 %int_1 - OpStore %i %25 None + %26 = OpBitcast %uint %24 + %27 = OpBitcast %uint %int_1 + %29 = OpIAdd %uint %26 %27 + %30 = OpBitcast %int %29 + OpStore %i %30 None OpBranch %8 %9 = OpLabel OpReturn
diff --git a/test/tint/loops/continue_in_switch_robustness.wgsl.expected.glsl b/test/tint/loops/continue_in_switch_robustness.wgsl.expected.glsl index 27f7439..4a8900d 100644 --- a/test/tint/loops/continue_in_switch_robustness.wgsl.expected.glsl +++ b/test/tint/loops/continue_in_switch_robustness.wgsl.expected.glsl
@@ -23,12 +23,14 @@ } if (tint_continue) { { - i = (i + 1); + uint v = uint(i); + i = int((v + uint(1))); } continue; } { - i = (i + 1); + uint v = uint(i); + i = int((v + uint(1))); } continue; }
diff --git a/test/tint/loops/continue_in_switch_robustness.wgsl.expected.spvasm b/test/tint/loops/continue_in_switch_robustness.wgsl.expected.spvasm index c129631..a125480 100644 --- a/test/tint/loops/continue_in_switch_robustness.wgsl.expected.spvasm +++ b/test/tint/loops/continue_in_switch_robustness.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 27 +; Bound: 31 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -16,6 +16,7 @@ %int_0 = OpConstant %int 0 %int_4 = OpConstant %int 4 %bool = OpTypeBool + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %f = OpFunction %void None %3 %4 = OpLabel @@ -46,8 +47,11 @@ OpBranch %7 %7 = OpLabel %24 = OpLoad %int %i None - %25 = OpIAdd %int %24 %int_1 - OpStore %i %25 None + %26 = OpBitcast %uint %24 + %27 = OpBitcast %uint %int_1 + %29 = OpIAdd %uint %26 %27 + %30 = OpBitcast %int %29 + OpStore %i %30 None OpBranch %8 %9 = OpLabel OpReturn
diff --git a/test/tint/loops/continue_in_switch_with_breakif.wgsl.expected.glsl b/test/tint/loops/continue_in_switch_with_breakif.wgsl.expected.glsl index f2b05e9..8cf0ccd 100644 --- a/test/tint/loops/continue_in_switch_with_breakif.wgsl.expected.glsl +++ b/test/tint/loops/continue_in_switch_with_breakif.wgsl.expected.glsl
@@ -27,7 +27,8 @@ tint_loop_idx.x = tint_low_inc; uint tint_carry = uint((tint_low_inc == 4294967295u)); tint_loop_idx.y = (tint_loop_idx.y - tint_carry); - i = (i + 1); + uint v = uint(i); + i = int((v + uint(1))); if ((i >= 4)) { break; } } continue; @@ -37,7 +38,8 @@ tint_loop_idx.x = tint_low_inc; uint tint_carry = uint((tint_low_inc == 4294967295u)); tint_loop_idx.y = (tint_loop_idx.y - tint_carry); - i = (i + 1); + uint v = uint(i); + i = int((v + uint(1))); if ((i >= 4)) { break; } } continue;
diff --git a/test/tint/loops/continue_in_switch_with_breakif.wgsl.expected.spvasm b/test/tint/loops/continue_in_switch_with_breakif.wgsl.expected.spvasm index 4d678b1a..885403f 100644 --- a/test/tint/loops/continue_in_switch_with_breakif.wgsl.expected.spvasm +++ b/test/tint/loops/continue_in_switch_with_breakif.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 51 +; Bound: 54 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -74,11 +74,14 @@ %44 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 OpStore %44 %43 None %45 = OpLoad %int %i None - %46 = OpIAdd %int %45 %int_1 - OpStore %i %46 None - %48 = OpLoad %int %i None - %49 = OpSGreaterThanEqual %bool %48 %int_4 - OpBranchConditional %49 %13 %12 + %46 = OpBitcast %uint %45 + %47 = OpBitcast %uint %int_1 + %49 = OpIAdd %uint %46 %47 + %50 = OpBitcast %int %49 + OpStore %i %50 None + %51 = OpLoad %int %i None + %52 = OpSGreaterThanEqual %bool %51 %int_4 + OpBranchConditional %52 %13 %12 %13 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/loops/continue_in_switch_with_breakif_robustness.wgsl.expected.glsl b/test/tint/loops/continue_in_switch_with_breakif_robustness.wgsl.expected.glsl index f2b05e9..8cf0ccd 100644 --- a/test/tint/loops/continue_in_switch_with_breakif_robustness.wgsl.expected.glsl +++ b/test/tint/loops/continue_in_switch_with_breakif_robustness.wgsl.expected.glsl
@@ -27,7 +27,8 @@ tint_loop_idx.x = tint_low_inc; uint tint_carry = uint((tint_low_inc == 4294967295u)); tint_loop_idx.y = (tint_loop_idx.y - tint_carry); - i = (i + 1); + uint v = uint(i); + i = int((v + uint(1))); if ((i >= 4)) { break; } } continue; @@ -37,7 +38,8 @@ tint_loop_idx.x = tint_low_inc; uint tint_carry = uint((tint_low_inc == 4294967295u)); tint_loop_idx.y = (tint_loop_idx.y - tint_carry); - i = (i + 1); + uint v = uint(i); + i = int((v + uint(1))); if ((i >= 4)) { break; } } continue;
diff --git a/test/tint/loops/continue_in_switch_with_breakif_robustness.wgsl.expected.spvasm b/test/tint/loops/continue_in_switch_with_breakif_robustness.wgsl.expected.spvasm index 4d678b1a..885403f 100644 --- a/test/tint/loops/continue_in_switch_with_breakif_robustness.wgsl.expected.spvasm +++ b/test/tint/loops/continue_in_switch_with_breakif_robustness.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 51 +; Bound: 54 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -74,11 +74,14 @@ %44 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 OpStore %44 %43 None %45 = OpLoad %int %i None - %46 = OpIAdd %int %45 %int_1 - OpStore %i %46 None - %48 = OpLoad %int %i None - %49 = OpSGreaterThanEqual %bool %48 %int_4 - OpBranchConditional %49 %13 %12 + %46 = OpBitcast %uint %45 + %47 = OpBitcast %uint %int_1 + %49 = OpIAdd %uint %46 %47 + %50 = OpBitcast %int %49 + OpStore %i %50 None + %51 = OpLoad %int %i None + %52 = OpSGreaterThanEqual %bool %51 %int_4 + OpBranchConditional %52 %13 %12 %13 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/loops/loop.wgsl.expected.glsl b/test/tint/loops/loop.wgsl.expected.glsl index 4e736ff..cdaf9db 100644 --- a/test/tint/loops/loop.wgsl.expected.glsl +++ b/test/tint/loops/loop.wgsl.expected.glsl
@@ -8,7 +8,8 @@ if (all(equal(tint_loop_idx, uvec2(0u)))) { break; } - i = (i + 1); + uint v = uint(i); + i = int((v + uint(1))); if ((i > 4)) { return i; }
diff --git a/test/tint/loops/loop.wgsl.expected.spvasm b/test/tint/loops/loop.wgsl.expected.spvasm index f14b31a..b6b0e5b 100644 --- a/test/tint/loops/loop.wgsl.expected.spvasm +++ b/test/tint/loops/loop.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 63 +; Bound: 66 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -36,7 +36,7 @@ %uint_1 = OpConstant %uint 1 %false = OpConstantFalse %bool %void = OpTypeVoid - %61 = OpTypeFunction %void + %64 = OpTypeFunction %void %f = OpFunction %int None %3 %4 = OpLabel %return_value = OpVariable %_ptr_Function_int Function %7 @@ -61,45 +61,48 @@ OpBranch %17 %30 = OpLabel %32 = OpLoad %int %i None - %33 = OpIAdd %int %32 %int_1 - OpStore %i %33 None - %35 = OpLoad %int %i None - %36 = OpSGreaterThan %bool %35 %int_4 - OpSelectionMerge %38 None - OpBranchConditional %36 %39 %38 - %39 = OpLabel - %57 = OpLoad %int %i None - OpStore %continue_execution %false None - OpStore %return_value %57 None - OpBranch %38 - %38 = OpLabel - %40 = OpLoad %bool %continue_execution None - %41 = OpLogicalNot %bool %40 - OpSelectionMerge %42 None - OpBranchConditional %41 %43 %42 - %43 = OpLabel - OpBranch %17 + %33 = OpBitcast %uint %32 + %34 = OpBitcast %uint %int_1 + %36 = OpIAdd %uint %33 %34 + %37 = OpBitcast %int %36 + OpStore %i %37 None + %38 = OpLoad %int %i None + %39 = OpSGreaterThan %bool %38 %int_4 + OpSelectionMerge %41 None + OpBranchConditional %39 %42 %41 %42 = OpLabel + %60 = OpLoad %int %i None + OpStore %continue_execution %false None + OpStore %return_value %60 None + OpBranch %41 + %41 = OpLabel + %43 = OpLoad %bool %continue_execution None + %44 = OpLogicalNot %bool %43 + OpSelectionMerge %45 None + OpBranchConditional %44 %46 %45 + %46 = OpLabel + OpBranch %17 + %45 = OpLabel OpBranch %15 %15 = OpLabel - %44 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 - %47 = OpLoad %uint %44 None -%tint_low_inc = OpISub %uint %47 %uint_1 - %50 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 - OpStore %50 %tint_low_inc None - %51 = OpIEqual %bool %tint_low_inc %uint_4294967295 - %tint_carry = OpSelect %uint %51 %uint_1 %uint_0 - %53 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 - %54 = OpLoad %uint %53 None - %55 = OpISub %uint %54 %tint_carry + %47 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 + %50 = OpLoad %uint %47 None +%tint_low_inc = OpISub %uint %50 %uint_1 + %53 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 + OpStore %53 %tint_low_inc None + %54 = OpIEqual %bool %tint_low_inc %uint_4294967295 + %tint_carry = OpSelect %uint %54 %uint_1 %uint_0 %56 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 - OpStore %56 %55 None + %57 = OpLoad %uint %56 None + %58 = OpISub %uint %57 %tint_carry + %59 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 + OpStore %59 %58 None OpBranch %16 %17 = OpLabel %18 = OpLoad %int %return_value None OpReturnValue %18 OpFunctionEnd -%unused_entry_point = OpFunction %void None %61 - %62 = OpLabel +%unused_entry_point = OpFunction %void None %64 + %65 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/loops/loop_robustness.wgsl.expected.glsl b/test/tint/loops/loop_robustness.wgsl.expected.glsl index 4e736ff..cdaf9db 100644 --- a/test/tint/loops/loop_robustness.wgsl.expected.glsl +++ b/test/tint/loops/loop_robustness.wgsl.expected.glsl
@@ -8,7 +8,8 @@ if (all(equal(tint_loop_idx, uvec2(0u)))) { break; } - i = (i + 1); + uint v = uint(i); + i = int((v + uint(1))); if ((i > 4)) { return i; }
diff --git a/test/tint/loops/loop_robustness.wgsl.expected.spvasm b/test/tint/loops/loop_robustness.wgsl.expected.spvasm index f14b31a..b6b0e5b 100644 --- a/test/tint/loops/loop_robustness.wgsl.expected.spvasm +++ b/test/tint/loops/loop_robustness.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 63 +; Bound: 66 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -36,7 +36,7 @@ %uint_1 = OpConstant %uint 1 %false = OpConstantFalse %bool %void = OpTypeVoid - %61 = OpTypeFunction %void + %64 = OpTypeFunction %void %f = OpFunction %int None %3 %4 = OpLabel %return_value = OpVariable %_ptr_Function_int Function %7 @@ -61,45 +61,48 @@ OpBranch %17 %30 = OpLabel %32 = OpLoad %int %i None - %33 = OpIAdd %int %32 %int_1 - OpStore %i %33 None - %35 = OpLoad %int %i None - %36 = OpSGreaterThan %bool %35 %int_4 - OpSelectionMerge %38 None - OpBranchConditional %36 %39 %38 - %39 = OpLabel - %57 = OpLoad %int %i None - OpStore %continue_execution %false None - OpStore %return_value %57 None - OpBranch %38 - %38 = OpLabel - %40 = OpLoad %bool %continue_execution None - %41 = OpLogicalNot %bool %40 - OpSelectionMerge %42 None - OpBranchConditional %41 %43 %42 - %43 = OpLabel - OpBranch %17 + %33 = OpBitcast %uint %32 + %34 = OpBitcast %uint %int_1 + %36 = OpIAdd %uint %33 %34 + %37 = OpBitcast %int %36 + OpStore %i %37 None + %38 = OpLoad %int %i None + %39 = OpSGreaterThan %bool %38 %int_4 + OpSelectionMerge %41 None + OpBranchConditional %39 %42 %41 %42 = OpLabel + %60 = OpLoad %int %i None + OpStore %continue_execution %false None + OpStore %return_value %60 None + OpBranch %41 + %41 = OpLabel + %43 = OpLoad %bool %continue_execution None + %44 = OpLogicalNot %bool %43 + OpSelectionMerge %45 None + OpBranchConditional %44 %46 %45 + %46 = OpLabel + OpBranch %17 + %45 = OpLabel OpBranch %15 %15 = OpLabel - %44 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 - %47 = OpLoad %uint %44 None -%tint_low_inc = OpISub %uint %47 %uint_1 - %50 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 - OpStore %50 %tint_low_inc None - %51 = OpIEqual %bool %tint_low_inc %uint_4294967295 - %tint_carry = OpSelect %uint %51 %uint_1 %uint_0 - %53 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 - %54 = OpLoad %uint %53 None - %55 = OpISub %uint %54 %tint_carry + %47 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 + %50 = OpLoad %uint %47 None +%tint_low_inc = OpISub %uint %50 %uint_1 + %53 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 + OpStore %53 %tint_low_inc None + %54 = OpIEqual %bool %tint_low_inc %uint_4294967295 + %tint_carry = OpSelect %uint %54 %uint_1 %uint_0 %56 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 - OpStore %56 %55 None + %57 = OpLoad %uint %56 None + %58 = OpISub %uint %57 %tint_carry + %59 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 + OpStore %59 %58 None OpBranch %16 %17 = OpLabel %18 = OpLoad %int %return_value None OpReturnValue %18 OpFunctionEnd -%unused_entry_point = OpFunction %void None %61 - %62 = OpLabel +%unused_entry_point = OpFunction %void None %64 + %65 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/loops/loop_with_break_if.wgsl.expected.glsl b/test/tint/loops/loop_with_break_if.wgsl.expected.glsl index 1600fa7..e6c0927 100644 --- a/test/tint/loops/loop_with_break_if.wgsl.expected.glsl +++ b/test/tint/loops/loop_with_break_if.wgsl.expected.glsl
@@ -16,7 +16,8 @@ tint_loop_idx.x = tint_low_inc; uint tint_carry = uint((tint_low_inc == 4294967295u)); tint_loop_idx.y = (tint_loop_idx.y - tint_carry); - i = (i + 1); + uint v = uint(i); + i = int((v + uint(1))); if ((i == 4)) { break; } } continue;
diff --git a/test/tint/loops/loop_with_break_if.wgsl.expected.spvasm b/test/tint/loops/loop_with_break_if.wgsl.expected.spvasm index 9003ecf..c7fb7b6 100644 --- a/test/tint/loops/loop_with_break_if.wgsl.expected.spvasm +++ b/test/tint/loops/loop_with_break_if.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 69 +; Bound: 72 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -36,7 +36,7 @@ %int_1 = OpConstant %int 1 %false = OpConstantFalse %bool %void = OpTypeVoid - %67 = OpTypeFunction %void + %70 = OpTypeFunction %void %f = OpFunction %int None %3 %4 = OpLabel %return_value = OpVariable %_ptr_Function_int Function %7 @@ -65,9 +65,9 @@ OpSelectionMerge %38 None OpBranchConditional %36 %39 %38 %39 = OpLabel - %63 = OpLoad %int %i None + %66 = OpLoad %int %i None OpStore %continue_execution %false None - OpStore %return_value %63 None + OpStore %return_value %66 None OpBranch %38 %38 = OpLabel %40 = OpLoad %bool %continue_execution None @@ -92,24 +92,27 @@ %56 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 OpStore %56 %55 None %57 = OpLoad %int %i None - %58 = OpIAdd %int %57 %int_1 - OpStore %i %58 None - %60 = OpLoad %int %i None - %61 = OpIEqual %bool %60 %int_4 - OpBranchConditional %61 %17 %16 + %58 = OpBitcast %uint %57 + %59 = OpBitcast %uint %int_1 + %61 = OpIAdd %uint %58 %59 + %62 = OpBitcast %int %61 + OpStore %i %62 None + %63 = OpLoad %int %i None + %64 = OpIEqual %bool %63 %int_4 + OpBranchConditional %64 %17 %16 %17 = OpLabel %18 = OpLoad %bool %continue_execution None OpSelectionMerge %19 None OpBranchConditional %18 %20 %19 %20 = OpLabel - %62 = OpLoad %int %i None - OpStore %return_value %62 None + %65 = OpLoad %int %i None + OpStore %return_value %65 None OpBranch %19 %19 = OpLabel %21 = OpLoad %int %return_value None OpReturnValue %21 OpFunctionEnd -%unused_entry_point = OpFunction %void None %67 - %68 = OpLabel +%unused_entry_point = OpFunction %void None %70 + %71 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/loops/loop_with_break_if_robustness.wgsl.expected.glsl b/test/tint/loops/loop_with_break_if_robustness.wgsl.expected.glsl index 1600fa7..e6c0927 100644 --- a/test/tint/loops/loop_with_break_if_robustness.wgsl.expected.glsl +++ b/test/tint/loops/loop_with_break_if_robustness.wgsl.expected.glsl
@@ -16,7 +16,8 @@ tint_loop_idx.x = tint_low_inc; uint tint_carry = uint((tint_low_inc == 4294967295u)); tint_loop_idx.y = (tint_loop_idx.y - tint_carry); - i = (i + 1); + uint v = uint(i); + i = int((v + uint(1))); if ((i == 4)) { break; } } continue;
diff --git a/test/tint/loops/loop_with_break_if_robustness.wgsl.expected.spvasm b/test/tint/loops/loop_with_break_if_robustness.wgsl.expected.spvasm index 9003ecf..c7fb7b6 100644 --- a/test/tint/loops/loop_with_break_if_robustness.wgsl.expected.spvasm +++ b/test/tint/loops/loop_with_break_if_robustness.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 69 +; Bound: 72 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -36,7 +36,7 @@ %int_1 = OpConstant %int 1 %false = OpConstantFalse %bool %void = OpTypeVoid - %67 = OpTypeFunction %void + %70 = OpTypeFunction %void %f = OpFunction %int None %3 %4 = OpLabel %return_value = OpVariable %_ptr_Function_int Function %7 @@ -65,9 +65,9 @@ OpSelectionMerge %38 None OpBranchConditional %36 %39 %38 %39 = OpLabel - %63 = OpLoad %int %i None + %66 = OpLoad %int %i None OpStore %continue_execution %false None - OpStore %return_value %63 None + OpStore %return_value %66 None OpBranch %38 %38 = OpLabel %40 = OpLoad %bool %continue_execution None @@ -92,24 +92,27 @@ %56 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 OpStore %56 %55 None %57 = OpLoad %int %i None - %58 = OpIAdd %int %57 %int_1 - OpStore %i %58 None - %60 = OpLoad %int %i None - %61 = OpIEqual %bool %60 %int_4 - OpBranchConditional %61 %17 %16 + %58 = OpBitcast %uint %57 + %59 = OpBitcast %uint %int_1 + %61 = OpIAdd %uint %58 %59 + %62 = OpBitcast %int %61 + OpStore %i %62 None + %63 = OpLoad %int %i None + %64 = OpIEqual %bool %63 %int_4 + OpBranchConditional %64 %17 %16 %17 = OpLabel %18 = OpLoad %bool %continue_execution None OpSelectionMerge %19 None OpBranchConditional %18 %20 %19 %20 = OpLabel - %62 = OpLoad %int %i None - OpStore %return_value %62 None + %65 = OpLoad %int %i None + OpStore %return_value %65 None OpBranch %19 %19 = OpLabel %21 = OpLoad %int %return_value None OpReturnValue %21 OpFunctionEnd -%unused_entry_point = OpFunction %void None %67 - %68 = OpLabel +%unused_entry_point = OpFunction %void None %70 + %71 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/loops/loop_with_continuing.wgsl.expected.glsl b/test/tint/loops/loop_with_continuing.wgsl.expected.glsl index 85f0c3f..32571a3 100644 --- a/test/tint/loops/loop_with_continuing.wgsl.expected.glsl +++ b/test/tint/loops/loop_with_continuing.wgsl.expected.glsl
@@ -16,7 +16,8 @@ tint_loop_idx.x = tint_low_inc; uint tint_carry = uint((tint_low_inc == 4294967295u)); tint_loop_idx.y = (tint_loop_idx.y - tint_carry); - i = (i + 1); + uint v = uint(i); + i = int((v + uint(1))); } continue; }
diff --git a/test/tint/loops/loop_with_continuing.wgsl.expected.spvasm b/test/tint/loops/loop_with_continuing.wgsl.expected.spvasm index fe402e7..e050952 100644 --- a/test/tint/loops/loop_with_continuing.wgsl.expected.spvasm +++ b/test/tint/loops/loop_with_continuing.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 63 +; Bound: 66 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -36,7 +36,7 @@ %int_1 = OpConstant %int 1 %false = OpConstantFalse %bool %void = OpTypeVoid - %61 = OpTypeFunction %void + %64 = OpTypeFunction %void %f = OpFunction %int None %3 %4 = OpLabel %return_value = OpVariable %_ptr_Function_int Function %7 @@ -65,9 +65,9 @@ OpSelectionMerge %35 None OpBranchConditional %33 %36 %35 %36 = OpLabel - %57 = OpLoad %int %i None + %60 = OpLoad %int %i None OpStore %continue_execution %false None - OpStore %return_value %57 None + OpStore %return_value %60 None OpBranch %35 %35 = OpLabel %37 = OpLoad %bool %continue_execution None @@ -92,14 +92,17 @@ %53 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 OpStore %53 %52 None %54 = OpLoad %int %i None - %55 = OpIAdd %int %54 %int_1 - OpStore %i %55 None + %55 = OpBitcast %uint %54 + %56 = OpBitcast %uint %int_1 + %58 = OpIAdd %uint %55 %56 + %59 = OpBitcast %int %58 + OpStore %i %59 None OpBranch %16 %17 = OpLabel %18 = OpLoad %int %return_value None OpReturnValue %18 OpFunctionEnd -%unused_entry_point = OpFunction %void None %61 - %62 = OpLabel +%unused_entry_point = OpFunction %void None %64 + %65 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/loops/loop_with_continuing_robustness.wgsl.expected.glsl b/test/tint/loops/loop_with_continuing_robustness.wgsl.expected.glsl index 85f0c3f..32571a3 100644 --- a/test/tint/loops/loop_with_continuing_robustness.wgsl.expected.glsl +++ b/test/tint/loops/loop_with_continuing_robustness.wgsl.expected.glsl
@@ -16,7 +16,8 @@ tint_loop_idx.x = tint_low_inc; uint tint_carry = uint((tint_low_inc == 4294967295u)); tint_loop_idx.y = (tint_loop_idx.y - tint_carry); - i = (i + 1); + uint v = uint(i); + i = int((v + uint(1))); } continue; }
diff --git a/test/tint/loops/loop_with_continuing_robustness.wgsl.expected.spvasm b/test/tint/loops/loop_with_continuing_robustness.wgsl.expected.spvasm index fe402e7..e050952 100644 --- a/test/tint/loops/loop_with_continuing_robustness.wgsl.expected.spvasm +++ b/test/tint/loops/loop_with_continuing_robustness.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 63 +; Bound: 66 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -36,7 +36,7 @@ %int_1 = OpConstant %int 1 %false = OpConstantFalse %bool %void = OpTypeVoid - %61 = OpTypeFunction %void + %64 = OpTypeFunction %void %f = OpFunction %int None %3 %4 = OpLabel %return_value = OpVariable %_ptr_Function_int Function %7 @@ -65,9 +65,9 @@ OpSelectionMerge %35 None OpBranchConditional %33 %36 %35 %36 = OpLabel - %57 = OpLoad %int %i None + %60 = OpLoad %int %i None OpStore %continue_execution %false None - OpStore %return_value %57 None + OpStore %return_value %60 None OpBranch %35 %35 = OpLabel %37 = OpLoad %bool %continue_execution None @@ -92,14 +92,17 @@ %53 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 OpStore %53 %52 None %54 = OpLoad %int %i None - %55 = OpIAdd %int %54 %int_1 - OpStore %i %55 None + %55 = OpBitcast %uint %54 + %56 = OpBitcast %uint %int_1 + %58 = OpIAdd %uint %55 %56 + %59 = OpBitcast %int %58 + OpStore %i %59 None OpBranch %16 %17 = OpLabel %18 = OpLoad %int %return_value None OpReturnValue %18 OpFunctionEnd -%unused_entry_point = OpFunction %void None %61 - %62 = OpLabel +%unused_entry_point = OpFunction %void None %64 + %65 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/loops/multiple_continues.wgsl.expected.glsl b/test/tint/loops/multiple_continues.wgsl.expected.glsl index 993c63b..f235e7c 100644 --- a/test/tint/loops/multiple_continues.wgsl.expected.glsl +++ b/test/tint/loops/multiple_continues.wgsl.expected.glsl
@@ -33,12 +33,14 @@ } if (tint_continue) { { - i = (i + 1); + uint v = uint(i); + i = int((v + uint(1))); } continue; } { - i = (i + 1); + uint v = uint(i); + i = int((v + uint(1))); } continue; }
diff --git a/test/tint/loops/multiple_continues.wgsl.expected.spvasm b/test/tint/loops/multiple_continues.wgsl.expected.spvasm index 6a5bed9..fda8470 100644 --- a/test/tint/loops/multiple_continues.wgsl.expected.spvasm +++ b/test/tint/loops/multiple_continues.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 29 +; Bound: 33 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -16,6 +16,7 @@ %int_0 = OpConstant %int 0 %int_2 = OpConstant %int 2 %bool = OpTypeBool + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %main = OpFunction %void None %3 %4 = OpLabel @@ -50,8 +51,11 @@ OpBranch %7 %7 = OpLabel %26 = OpLoad %int %i None - %27 = OpIAdd %int %26 %int_1 - OpStore %i %27 None + %28 = OpBitcast %uint %26 + %29 = OpBitcast %uint %int_1 + %31 = OpIAdd %uint %28 %29 + %32 = OpBitcast %int %31 + OpStore %i %32 None OpBranch %8 %9 = OpLabel OpReturn
diff --git a/test/tint/loops/multiple_continues_robustness.wgsl.expected.glsl b/test/tint/loops/multiple_continues_robustness.wgsl.expected.glsl index 993c63b..f235e7c 100644 --- a/test/tint/loops/multiple_continues_robustness.wgsl.expected.glsl +++ b/test/tint/loops/multiple_continues_robustness.wgsl.expected.glsl
@@ -33,12 +33,14 @@ } if (tint_continue) { { - i = (i + 1); + uint v = uint(i); + i = int((v + uint(1))); } continue; } { - i = (i + 1); + uint v = uint(i); + i = int((v + uint(1))); } continue; }
diff --git a/test/tint/loops/multiple_continues_robustness.wgsl.expected.spvasm b/test/tint/loops/multiple_continues_robustness.wgsl.expected.spvasm index 6a5bed9..fda8470 100644 --- a/test/tint/loops/multiple_continues_robustness.wgsl.expected.spvasm +++ b/test/tint/loops/multiple_continues_robustness.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 29 +; Bound: 33 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -16,6 +16,7 @@ %int_0 = OpConstant %int 0 %int_2 = OpConstant %int 2 %bool = OpTypeBool + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %main = OpFunction %void None %3 %4 = OpLabel @@ -50,8 +51,11 @@ OpBranch %7 %7 = OpLabel %26 = OpLoad %int %i None - %27 = OpIAdd %int %26 %int_1 - OpStore %i %27 None + %28 = OpBitcast %uint %26 + %29 = OpBitcast %uint %int_1 + %31 = OpIAdd %uint %28 %29 + %32 = OpBitcast %int %31 + OpStore %i %32 None OpBranch %8 %9 = OpLabel OpReturn
diff --git a/test/tint/loops/multiple_switch.wgsl.expected.glsl b/test/tint/loops/multiple_switch.wgsl.expected.glsl index b3ab152..44f4d73 100644 --- a/test/tint/loops/multiple_switch.wgsl.expected.glsl +++ b/test/tint/loops/multiple_switch.wgsl.expected.glsl
@@ -24,7 +24,8 @@ } if (tint_continue) { { - i_1 = (i_1 + 1); + uint v = uint(i_1); + i_1 = int((v + uint(1))); } continue; } @@ -42,12 +43,14 @@ } if (tint_continue_1) { { - i_1 = (i_1 + 1); + uint v = uint(i_1); + i_1 = int((v + uint(1))); } continue; } { - i_1 = (i_1 + 1); + uint v = uint(i_1); + i_1 = int((v + uint(1))); } continue; }
diff --git a/test/tint/loops/multiple_switch.wgsl.expected.spvasm b/test/tint/loops/multiple_switch.wgsl.expected.spvasm index 688e102..e6b2b2a 100644 --- a/test/tint/loops/multiple_switch.wgsl.expected.spvasm +++ b/test/tint/loops/multiple_switch.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 32 +; Bound: 36 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -17,6 +17,7 @@ %int_0 = OpConstant %int 0 %int_2 = OpConstant %int 2 %bool = OpTypeBool + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %main = OpFunction %void None %3 %4 = OpLabel @@ -57,8 +58,11 @@ OpBranch %11 %11 = OpLabel %29 = OpLoad %int %i_0 None - %30 = OpIAdd %int %29 %int_1 - OpStore %i_0 %30 None + %31 = OpBitcast %uint %29 + %32 = OpBitcast %uint %int_1 + %34 = OpIAdd %uint %31 %32 + %35 = OpBitcast %int %34 + OpStore %i_0 %35 None OpBranch %12 %13 = OpLabel OpReturn
diff --git a/test/tint/loops/multiple_switch_robustness.wgsl.expected.glsl b/test/tint/loops/multiple_switch_robustness.wgsl.expected.glsl index b3ab152..44f4d73 100644 --- a/test/tint/loops/multiple_switch_robustness.wgsl.expected.glsl +++ b/test/tint/loops/multiple_switch_robustness.wgsl.expected.glsl
@@ -24,7 +24,8 @@ } if (tint_continue) { { - i_1 = (i_1 + 1); + uint v = uint(i_1); + i_1 = int((v + uint(1))); } continue; } @@ -42,12 +43,14 @@ } if (tint_continue_1) { { - i_1 = (i_1 + 1); + uint v = uint(i_1); + i_1 = int((v + uint(1))); } continue; } { - i_1 = (i_1 + 1); + uint v = uint(i_1); + i_1 = int((v + uint(1))); } continue; }
diff --git a/test/tint/loops/multiple_switch_robustness.wgsl.expected.spvasm b/test/tint/loops/multiple_switch_robustness.wgsl.expected.spvasm index 688e102..e6b2b2a 100644 --- a/test/tint/loops/multiple_switch_robustness.wgsl.expected.spvasm +++ b/test/tint/loops/multiple_switch_robustness.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 32 +; Bound: 36 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -17,6 +17,7 @@ %int_0 = OpConstant %int 0 %int_2 = OpConstant %int 2 %bool = OpTypeBool + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %main = OpFunction %void None %3 %4 = OpLabel @@ -57,8 +58,11 @@ OpBranch %11 %11 = OpLabel %29 = OpLoad %int %i_0 None - %30 = OpIAdd %int %29 %int_1 - OpStore %i_0 %30 None + %31 = OpBitcast %uint %29 + %32 = OpBitcast %uint %int_1 + %34 = OpIAdd %uint %31 %32 + %35 = OpBitcast %int %34 + OpStore %i_0 %35 None OpBranch %12 %13 = OpLabel OpReturn
diff --git a/test/tint/loops/nested_loop_loop_switch.wgsl.expected.glsl b/test/tint/loops/nested_loop_loop_switch.wgsl.expected.glsl index 9d4e46f..66b44a9 100644 --- a/test/tint/loops/nested_loop_loop_switch.wgsl.expected.glsl +++ b/test/tint/loops/nested_loop_loop_switch.wgsl.expected.glsl
@@ -42,7 +42,8 @@ tint_loop_idx_1.x = tint_low_inc_1; uint tint_carry_1 = uint((tint_low_inc_1 == 4294967295u)); tint_loop_idx_1.y = (tint_loop_idx_1.y - tint_carry_1); - j = (j + 2); + uint v = uint(j); + j = int((v + uint(2))); } continue; } @@ -51,7 +52,8 @@ tint_loop_idx_1.x = tint_low_inc_1; uint tint_carry_1 = uint((tint_low_inc_1 == 4294967295u)); tint_loop_idx_1.y = (tint_loop_idx_1.y - tint_carry_1); - j = (j + 2); + uint v = uint(j); + j = int((v + uint(2))); } continue; } @@ -61,7 +63,8 @@ tint_loop_idx.x = tint_low_inc; uint tint_carry = uint((tint_low_inc == 4294967295u)); tint_loop_idx.y = (tint_loop_idx.y - tint_carry); - i = (i + 2); + uint v_1 = uint(i); + i = int((v_1 + uint(2))); } continue; }
diff --git a/test/tint/loops/nested_loop_loop_switch.wgsl.expected.spvasm b/test/tint/loops/nested_loop_loop_switch.wgsl.expected.spvasm index e79293e..4c15133 100644 --- a/test/tint/loops/nested_loop_loop_switch.wgsl.expected.spvasm +++ b/test/tint/loops/nested_loop_loop_switch.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 80 +; Bound: 86 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -72,46 +72,49 @@ OpLoopMerge %37 %35 None OpBranch %34 %34 = OpLabel - %55 = OpLoad %v2uint %tint_loop_idx_0 None - %56 = OpIEqual %v2bool %55 %22 - %57 = OpAll %bool %56 - OpSelectionMerge %58 None - OpBranchConditional %57 %59 %58 - %59 = OpLabel - OpBranch %37 - %58 = OpLabel - %60 = OpLoad %int %j None - %61 = OpSLessThan %bool %60 %int_2 - OpSelectionMerge %62 None - OpBranchConditional %61 %62 %63 - %63 = OpLabel - OpBranch %37 + %58 = OpLoad %v2uint %tint_loop_idx_0 None + %59 = OpIEqual %v2bool %58 %22 + %60 = OpAll %bool %59 + OpSelectionMerge %61 None + OpBranchConditional %60 %62 %61 %62 = OpLabel - %64 = OpLoad %int %i None - OpSelectionMerge %67 None - OpSwitch %64 %65 0 %66 - %65 = OpLabel - OpBranch %67 + OpBranch %37 + %61 = OpLabel + %63 = OpLoad %int %j None + %64 = OpSLessThan %bool %63 %int_2 + OpSelectionMerge %65 None + OpBranchConditional %64 %65 %66 %66 = OpLabel + OpBranch %37 + %65 = OpLabel + %67 = OpLoad %int %i None + OpSelectionMerge %70 None + OpSwitch %67 %68 0 %69 + %68 = OpLabel + OpBranch %70 + %69 = OpLabel OpBranch %35 - %67 = OpLabel + %70 = OpLabel OpBranch %35 %35 = OpLabel - %68 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_0 - %69 = OpLoad %uint %68 None -%tint_low_inc_1 = OpISub %uint %69 %uint_1 %71 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_0 - OpStore %71 %tint_low_inc_1 None - %72 = OpIEqual %bool %tint_low_inc_1 %uint_4294967295 -%tint_carry_1 = OpSelect %uint %72 %uint_1 %uint_0 - %74 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 - %75 = OpLoad %uint %74 None - %76 = OpISub %uint %75 %tint_carry_1 + %72 = OpLoad %uint %71 None +%tint_low_inc_1 = OpISub %uint %72 %uint_1 + %74 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_0 + OpStore %74 %tint_low_inc_1 None + %75 = OpIEqual %bool %tint_low_inc_1 %uint_4294967295 +%tint_carry_1 = OpSelect %uint %75 %uint_1 %uint_0 %77 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 - OpStore %77 %76 None - %78 = OpLoad %int %j None - %79 = OpIAdd %int %78 %int_2 - OpStore %j %79 None + %78 = OpLoad %uint %77 None + %79 = OpISub %uint %78 %tint_carry_1 + %80 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 + OpStore %80 %79 None + %81 = OpLoad %int %j None + %82 = OpBitcast %uint %81 + %83 = OpBitcast %uint %int_2 + %84 = OpIAdd %uint %82 %83 + %85 = OpBitcast %int %84 + OpStore %j %85 None OpBranch %36 %37 = OpLabel OpBranch %7 @@ -129,8 +132,11 @@ %50 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 OpStore %50 %49 None %51 = OpLoad %int %i None - %52 = OpIAdd %int %51 %int_2 - OpStore %i %52 None + %52 = OpBitcast %uint %51 + %53 = OpBitcast %uint %int_2 + %54 = OpIAdd %uint %52 %53 + %55 = OpBitcast %int %54 + OpStore %i %55 None OpBranch %8 %9 = OpLabel OpReturn
diff --git a/test/tint/loops/nested_loop_loop_switch_robustness.wgsl.expected.glsl b/test/tint/loops/nested_loop_loop_switch_robustness.wgsl.expected.glsl index 9d4e46f..66b44a9 100644 --- a/test/tint/loops/nested_loop_loop_switch_robustness.wgsl.expected.glsl +++ b/test/tint/loops/nested_loop_loop_switch_robustness.wgsl.expected.glsl
@@ -42,7 +42,8 @@ tint_loop_idx_1.x = tint_low_inc_1; uint tint_carry_1 = uint((tint_low_inc_1 == 4294967295u)); tint_loop_idx_1.y = (tint_loop_idx_1.y - tint_carry_1); - j = (j + 2); + uint v = uint(j); + j = int((v + uint(2))); } continue; } @@ -51,7 +52,8 @@ tint_loop_idx_1.x = tint_low_inc_1; uint tint_carry_1 = uint((tint_low_inc_1 == 4294967295u)); tint_loop_idx_1.y = (tint_loop_idx_1.y - tint_carry_1); - j = (j + 2); + uint v = uint(j); + j = int((v + uint(2))); } continue; } @@ -61,7 +63,8 @@ tint_loop_idx.x = tint_low_inc; uint tint_carry = uint((tint_low_inc == 4294967295u)); tint_loop_idx.y = (tint_loop_idx.y - tint_carry); - i = (i + 2); + uint v_1 = uint(i); + i = int((v_1 + uint(2))); } continue; }
diff --git a/test/tint/loops/nested_loop_loop_switch_robustness.wgsl.expected.spvasm b/test/tint/loops/nested_loop_loop_switch_robustness.wgsl.expected.spvasm index e79293e..4c15133 100644 --- a/test/tint/loops/nested_loop_loop_switch_robustness.wgsl.expected.spvasm +++ b/test/tint/loops/nested_loop_loop_switch_robustness.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 80 +; Bound: 86 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -72,46 +72,49 @@ OpLoopMerge %37 %35 None OpBranch %34 %34 = OpLabel - %55 = OpLoad %v2uint %tint_loop_idx_0 None - %56 = OpIEqual %v2bool %55 %22 - %57 = OpAll %bool %56 - OpSelectionMerge %58 None - OpBranchConditional %57 %59 %58 - %59 = OpLabel - OpBranch %37 - %58 = OpLabel - %60 = OpLoad %int %j None - %61 = OpSLessThan %bool %60 %int_2 - OpSelectionMerge %62 None - OpBranchConditional %61 %62 %63 - %63 = OpLabel - OpBranch %37 + %58 = OpLoad %v2uint %tint_loop_idx_0 None + %59 = OpIEqual %v2bool %58 %22 + %60 = OpAll %bool %59 + OpSelectionMerge %61 None + OpBranchConditional %60 %62 %61 %62 = OpLabel - %64 = OpLoad %int %i None - OpSelectionMerge %67 None - OpSwitch %64 %65 0 %66 - %65 = OpLabel - OpBranch %67 + OpBranch %37 + %61 = OpLabel + %63 = OpLoad %int %j None + %64 = OpSLessThan %bool %63 %int_2 + OpSelectionMerge %65 None + OpBranchConditional %64 %65 %66 %66 = OpLabel + OpBranch %37 + %65 = OpLabel + %67 = OpLoad %int %i None + OpSelectionMerge %70 None + OpSwitch %67 %68 0 %69 + %68 = OpLabel + OpBranch %70 + %69 = OpLabel OpBranch %35 - %67 = OpLabel + %70 = OpLabel OpBranch %35 %35 = OpLabel - %68 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_0 - %69 = OpLoad %uint %68 None -%tint_low_inc_1 = OpISub %uint %69 %uint_1 %71 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_0 - OpStore %71 %tint_low_inc_1 None - %72 = OpIEqual %bool %tint_low_inc_1 %uint_4294967295 -%tint_carry_1 = OpSelect %uint %72 %uint_1 %uint_0 - %74 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 - %75 = OpLoad %uint %74 None - %76 = OpISub %uint %75 %tint_carry_1 + %72 = OpLoad %uint %71 None +%tint_low_inc_1 = OpISub %uint %72 %uint_1 + %74 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_0 + OpStore %74 %tint_low_inc_1 None + %75 = OpIEqual %bool %tint_low_inc_1 %uint_4294967295 +%tint_carry_1 = OpSelect %uint %75 %uint_1 %uint_0 %77 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 - OpStore %77 %76 None - %78 = OpLoad %int %j None - %79 = OpIAdd %int %78 %int_2 - OpStore %j %79 None + %78 = OpLoad %uint %77 None + %79 = OpISub %uint %78 %tint_carry_1 + %80 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 + OpStore %80 %79 None + %81 = OpLoad %int %j None + %82 = OpBitcast %uint %81 + %83 = OpBitcast %uint %int_2 + %84 = OpIAdd %uint %82 %83 + %85 = OpBitcast %int %84 + OpStore %j %85 None OpBranch %36 %37 = OpLabel OpBranch %7 @@ -129,8 +132,11 @@ %50 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 OpStore %50 %49 None %51 = OpLoad %int %i None - %52 = OpIAdd %int %51 %int_2 - OpStore %i %52 None + %52 = OpBitcast %uint %51 + %53 = OpBitcast %uint %int_2 + %54 = OpIAdd %uint %52 %53 + %55 = OpBitcast %int %54 + OpStore %i %55 None OpBranch %8 %9 = OpLabel OpReturn
diff --git a/test/tint/loops/nested_loop_switch_loop_switch.wgsl.expected.glsl b/test/tint/loops/nested_loop_switch_loop_switch.wgsl.expected.glsl index b74b006..e193c57 100644 --- a/test/tint/loops/nested_loop_switch_loop_switch.wgsl.expected.glsl +++ b/test/tint/loops/nested_loop_switch_loop_switch.wgsl.expected.glsl
@@ -46,7 +46,8 @@ tint_loop_idx_1.x = tint_low_inc_1; uint tint_carry_1 = uint((tint_low_inc_1 == 4294967295u)); tint_loop_idx_1.y = (tint_loop_idx_1.y - tint_carry_1); - j = (j + 2); + uint v = uint(j); + j = int((v + uint(2))); } continue; } @@ -55,7 +56,8 @@ tint_loop_idx_1.x = tint_low_inc_1; uint tint_carry_1 = uint((tint_low_inc_1 == 4294967295u)); tint_loop_idx_1.y = (tint_loop_idx_1.y - tint_carry_1); - j = (j + 2); + uint v = uint(j); + j = int((v + uint(2))); } continue; } @@ -74,7 +76,8 @@ tint_loop_idx.x = tint_low_inc; uint tint_carry = uint((tint_low_inc == 4294967295u)); tint_loop_idx.y = (tint_loop_idx.y - tint_carry); - i = (i + 2); + uint v_1 = uint(i); + i = int((v_1 + uint(2))); } continue; } @@ -83,7 +86,8 @@ tint_loop_idx.x = tint_low_inc; uint tint_carry = uint((tint_low_inc == 4294967295u)); tint_loop_idx.y = (tint_loop_idx.y - tint_carry); - i = (i + 2); + uint v_1 = uint(i); + i = int((v_1 + uint(2))); } continue; }
diff --git a/test/tint/loops/nested_loop_switch_loop_switch.wgsl.expected.spvasm b/test/tint/loops/nested_loop_switch_loop_switch.wgsl.expected.spvasm index 7463eab..fb1a146 100644 --- a/test/tint/loops/nested_loop_switch_loop_switch.wgsl.expected.spvasm +++ b/test/tint/loops/nested_loop_switch_loop_switch.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 84 +; Bound: 90 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -69,57 +69,60 @@ %34 = OpLabel OpBranch %36 %35 = OpLabel - OpBranch %52 - %52 = OpLabel - OpStore %tint_loop_idx_0 %14 - OpStore %j %int_0 OpBranch %55 %55 = OpLabel - OpLoopMerge %56 %54 None - OpBranch %53 - %53 = OpLabel - %59 = OpLoad %v2uint %tint_loop_idx_0 None - %60 = OpIEqual %v2bool %59 %22 - %61 = OpAll %bool %60 - OpSelectionMerge %62 None - OpBranchConditional %61 %63 %62 - %63 = OpLabel + OpStore %tint_loop_idx_0 %14 + OpStore %j %int_0 + OpBranch %58 + %58 = OpLabel + OpLoopMerge %59 %57 None OpBranch %56 - %62 = OpLabel - %64 = OpLoad %int %j None - %65 = OpSLessThan %bool %64 %int_2 - OpSelectionMerge %66 None - OpBranchConditional %65 %66 %67 - %67 = OpLabel - OpBranch %56 - %66 = OpLabel - %68 = OpLoad %int %j None - OpSelectionMerge %71 None - OpSwitch %68 %69 0 %70 - %69 = OpLabel - OpBranch %71 - %70 = OpLabel - OpBranch %54 - %71 = OpLabel - OpBranch %54 - %54 = OpLabel - %72 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_0 - %73 = OpLoad %uint %72 None -%tint_low_inc_1 = OpISub %uint %73 %uint_1 - %75 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_0 - OpStore %75 %tint_low_inc_1 None - %76 = OpIEqual %bool %tint_low_inc_1 %uint_4294967295 -%tint_carry_1 = OpSelect %uint %76 %uint_1 %uint_0 - %78 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 - %79 = OpLoad %uint %78 None - %80 = OpISub %uint %79 %tint_carry_1 - %81 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 - OpStore %81 %80 None - %82 = OpLoad %int %j None - %83 = OpIAdd %int %82 %int_2 - OpStore %j %83 None - OpBranch %55 %56 = OpLabel + %62 = OpLoad %v2uint %tint_loop_idx_0 None + %63 = OpIEqual %v2bool %62 %22 + %64 = OpAll %bool %63 + OpSelectionMerge %65 None + OpBranchConditional %64 %66 %65 + %66 = OpLabel + OpBranch %59 + %65 = OpLabel + %67 = OpLoad %int %j None + %68 = OpSLessThan %bool %67 %int_2 + OpSelectionMerge %69 None + OpBranchConditional %68 %69 %70 + %70 = OpLabel + OpBranch %59 + %69 = OpLabel + %71 = OpLoad %int %j None + OpSelectionMerge %74 None + OpSwitch %71 %72 0 %73 + %72 = OpLabel + OpBranch %74 + %73 = OpLabel + OpBranch %57 + %74 = OpLabel + OpBranch %57 + %57 = OpLabel + %75 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_0 + %76 = OpLoad %uint %75 None +%tint_low_inc_1 = OpISub %uint %76 %uint_1 + %78 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_0 + OpStore %78 %tint_low_inc_1 None + %79 = OpIEqual %bool %tint_low_inc_1 %uint_4294967295 +%tint_carry_1 = OpSelect %uint %79 %uint_1 %uint_0 + %81 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 + %82 = OpLoad %uint %81 None + %83 = OpISub %uint %82 %tint_carry_1 + %84 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 + OpStore %84 %83 None + %85 = OpLoad %int %j None + %86 = OpBitcast %uint %85 + %87 = OpBitcast %uint %int_2 + %88 = OpIAdd %uint %86 %87 + %89 = OpBitcast %int %88 + OpStore %j %89 None + OpBranch %58 + %59 = OpLabel OpBranch %7 %36 = OpLabel OpBranch %7 @@ -137,8 +140,11 @@ %49 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 OpStore %49 %48 None %50 = OpLoad %int %i None - %51 = OpIAdd %int %50 %int_2 - OpStore %i %51 None + %51 = OpBitcast %uint %50 + %52 = OpBitcast %uint %int_2 + %53 = OpIAdd %uint %51 %52 + %54 = OpBitcast %int %53 + OpStore %i %54 None OpBranch %8 %9 = OpLabel OpReturn
diff --git a/test/tint/loops/nested_loop_switch_loop_switch_robustness.wgsl.expected.glsl b/test/tint/loops/nested_loop_switch_loop_switch_robustness.wgsl.expected.glsl index b74b006..e193c57 100644 --- a/test/tint/loops/nested_loop_switch_loop_switch_robustness.wgsl.expected.glsl +++ b/test/tint/loops/nested_loop_switch_loop_switch_robustness.wgsl.expected.glsl
@@ -46,7 +46,8 @@ tint_loop_idx_1.x = tint_low_inc_1; uint tint_carry_1 = uint((tint_low_inc_1 == 4294967295u)); tint_loop_idx_1.y = (tint_loop_idx_1.y - tint_carry_1); - j = (j + 2); + uint v = uint(j); + j = int((v + uint(2))); } continue; } @@ -55,7 +56,8 @@ tint_loop_idx_1.x = tint_low_inc_1; uint tint_carry_1 = uint((tint_low_inc_1 == 4294967295u)); tint_loop_idx_1.y = (tint_loop_idx_1.y - tint_carry_1); - j = (j + 2); + uint v = uint(j); + j = int((v + uint(2))); } continue; } @@ -74,7 +76,8 @@ tint_loop_idx.x = tint_low_inc; uint tint_carry = uint((tint_low_inc == 4294967295u)); tint_loop_idx.y = (tint_loop_idx.y - tint_carry); - i = (i + 2); + uint v_1 = uint(i); + i = int((v_1 + uint(2))); } continue; } @@ -83,7 +86,8 @@ tint_loop_idx.x = tint_low_inc; uint tint_carry = uint((tint_low_inc == 4294967295u)); tint_loop_idx.y = (tint_loop_idx.y - tint_carry); - i = (i + 2); + uint v_1 = uint(i); + i = int((v_1 + uint(2))); } continue; }
diff --git a/test/tint/loops/nested_loop_switch_loop_switch_robustness.wgsl.expected.spvasm b/test/tint/loops/nested_loop_switch_loop_switch_robustness.wgsl.expected.spvasm index 7463eab..fb1a146 100644 --- a/test/tint/loops/nested_loop_switch_loop_switch_robustness.wgsl.expected.spvasm +++ b/test/tint/loops/nested_loop_switch_loop_switch_robustness.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 84 +; Bound: 90 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -69,57 +69,60 @@ %34 = OpLabel OpBranch %36 %35 = OpLabel - OpBranch %52 - %52 = OpLabel - OpStore %tint_loop_idx_0 %14 - OpStore %j %int_0 OpBranch %55 %55 = OpLabel - OpLoopMerge %56 %54 None - OpBranch %53 - %53 = OpLabel - %59 = OpLoad %v2uint %tint_loop_idx_0 None - %60 = OpIEqual %v2bool %59 %22 - %61 = OpAll %bool %60 - OpSelectionMerge %62 None - OpBranchConditional %61 %63 %62 - %63 = OpLabel + OpStore %tint_loop_idx_0 %14 + OpStore %j %int_0 + OpBranch %58 + %58 = OpLabel + OpLoopMerge %59 %57 None OpBranch %56 - %62 = OpLabel - %64 = OpLoad %int %j None - %65 = OpSLessThan %bool %64 %int_2 - OpSelectionMerge %66 None - OpBranchConditional %65 %66 %67 - %67 = OpLabel - OpBranch %56 - %66 = OpLabel - %68 = OpLoad %int %j None - OpSelectionMerge %71 None - OpSwitch %68 %69 0 %70 - %69 = OpLabel - OpBranch %71 - %70 = OpLabel - OpBranch %54 - %71 = OpLabel - OpBranch %54 - %54 = OpLabel - %72 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_0 - %73 = OpLoad %uint %72 None -%tint_low_inc_1 = OpISub %uint %73 %uint_1 - %75 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_0 - OpStore %75 %tint_low_inc_1 None - %76 = OpIEqual %bool %tint_low_inc_1 %uint_4294967295 -%tint_carry_1 = OpSelect %uint %76 %uint_1 %uint_0 - %78 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 - %79 = OpLoad %uint %78 None - %80 = OpISub %uint %79 %tint_carry_1 - %81 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 - OpStore %81 %80 None - %82 = OpLoad %int %j None - %83 = OpIAdd %int %82 %int_2 - OpStore %j %83 None - OpBranch %55 %56 = OpLabel + %62 = OpLoad %v2uint %tint_loop_idx_0 None + %63 = OpIEqual %v2bool %62 %22 + %64 = OpAll %bool %63 + OpSelectionMerge %65 None + OpBranchConditional %64 %66 %65 + %66 = OpLabel + OpBranch %59 + %65 = OpLabel + %67 = OpLoad %int %j None + %68 = OpSLessThan %bool %67 %int_2 + OpSelectionMerge %69 None + OpBranchConditional %68 %69 %70 + %70 = OpLabel + OpBranch %59 + %69 = OpLabel + %71 = OpLoad %int %j None + OpSelectionMerge %74 None + OpSwitch %71 %72 0 %73 + %72 = OpLabel + OpBranch %74 + %73 = OpLabel + OpBranch %57 + %74 = OpLabel + OpBranch %57 + %57 = OpLabel + %75 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_0 + %76 = OpLoad %uint %75 None +%tint_low_inc_1 = OpISub %uint %76 %uint_1 + %78 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_0 + OpStore %78 %tint_low_inc_1 None + %79 = OpIEqual %bool %tint_low_inc_1 %uint_4294967295 +%tint_carry_1 = OpSelect %uint %79 %uint_1 %uint_0 + %81 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 + %82 = OpLoad %uint %81 None + %83 = OpISub %uint %82 %tint_carry_1 + %84 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 + OpStore %84 %83 None + %85 = OpLoad %int %j None + %86 = OpBitcast %uint %85 + %87 = OpBitcast %uint %int_2 + %88 = OpIAdd %uint %86 %87 + %89 = OpBitcast %int %88 + OpStore %j %89 None + OpBranch %58 + %59 = OpLabel OpBranch %7 %36 = OpLabel OpBranch %7 @@ -137,8 +140,11 @@ %49 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 OpStore %49 %48 None %50 = OpLoad %int %i None - %51 = OpIAdd %int %50 %int_2 - OpStore %i %51 None + %51 = OpBitcast %uint %50 + %52 = OpBitcast %uint %int_2 + %53 = OpIAdd %uint %51 %52 + %54 = OpBitcast %int %53 + OpStore %i %54 None OpBranch %8 %9 = OpLabel OpReturn
diff --git a/test/tint/loops/nested_loop_switch_loop_switch_switch.wgsl.expected.glsl b/test/tint/loops/nested_loop_switch_loop_switch_switch.wgsl.expected.glsl index 5c7b5f8..af21a5e 100644 --- a/test/tint/loops/nested_loop_switch_loop_switch_switch.wgsl.expected.glsl +++ b/test/tint/loops/nested_loop_switch_loop_switch_switch.wgsl.expected.glsl
@@ -67,7 +67,8 @@ tint_loop_idx_1.x = tint_low_inc_1; uint tint_carry_1 = uint((tint_low_inc_1 == 4294967295u)); tint_loop_idx_1.y = (tint_loop_idx_1.y - tint_carry_1); - j = (j + 2); + uint v = uint(j); + j = int((v + uint(2))); } continue; } @@ -76,7 +77,8 @@ tint_loop_idx_1.x = tint_low_inc_1; uint tint_carry_1 = uint((tint_low_inc_1 == 4294967295u)); tint_loop_idx_1.y = (tint_loop_idx_1.y - tint_carry_1); - j = (j + 2); + uint v = uint(j); + j = int((v + uint(2))); } continue; } @@ -95,7 +97,8 @@ tint_loop_idx.x = tint_low_inc; uint tint_carry = uint((tint_low_inc == 4294967295u)); tint_loop_idx.y = (tint_loop_idx.y - tint_carry); - i = (i + 2); + uint v_1 = uint(i); + i = int((v_1 + uint(2))); } continue; } @@ -104,7 +107,8 @@ tint_loop_idx.x = tint_low_inc; uint tint_carry = uint((tint_low_inc == 4294967295u)); tint_loop_idx.y = (tint_loop_idx.y - tint_carry); - i = (i + 2); + uint v_1 = uint(i); + i = int((v_1 + uint(2))); } continue; }
diff --git a/test/tint/loops/nested_loop_switch_loop_switch_switch.wgsl.expected.spvasm b/test/tint/loops/nested_loop_switch_loop_switch_switch.wgsl.expected.spvasm index 8484bee..b25d76f 100644 --- a/test/tint/loops/nested_loop_switch_loop_switch_switch.wgsl.expected.spvasm +++ b/test/tint/loops/nested_loop_switch_loop_switch_switch.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 90 +; Bound: 96 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -72,67 +72,70 @@ %35 = OpLabel OpBranch %37 %36 = OpLabel - OpBranch %53 - %53 = OpLabel - OpStore %tint_loop_idx_0 %18 - OpStore %j %int_0 OpBranch %56 %56 = OpLabel - OpLoopMerge %57 %55 None - OpBranch %54 - %54 = OpLabel - %60 = OpLoad %v2uint %tint_loop_idx_0 None - %61 = OpIEqual %v2bool %60 %23 - %62 = OpAll %bool %61 - OpSelectionMerge %63 None - OpBranchConditional %62 %64 %63 - %64 = OpLabel + OpStore %tint_loop_idx_0 %18 + OpStore %j %int_0 + OpBranch %59 + %59 = OpLabel + OpLoopMerge %60 %58 None OpBranch %57 - %63 = OpLabel - %65 = OpLoad %int %j None - %66 = OpSLessThan %bool %65 %int_2 - OpSelectionMerge %67 None - OpBranchConditional %66 %67 %68 - %68 = OpLabel - OpBranch %57 - %67 = OpLabel - %69 = OpLoad %int %j None - OpSelectionMerge %73 None - OpSwitch %69 %70 0 %71 1 %72 - %70 = OpLabel - OpBranch %73 - %71 = OpLabel - OpBranch %55 - %72 = OpLabel - %86 = OpLoad %int %k None - OpSelectionMerge %89 None - OpSwitch %86 %87 0 %88 - %87 = OpLabel - OpBranch %89 - %88 = OpLabel - OpBranch %55 - %89 = OpLabel - OpBranch %73 - %73 = OpLabel - OpBranch %55 - %55 = OpLabel - %74 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_0 - %75 = OpLoad %uint %74 None -%tint_low_inc_1 = OpISub %uint %75 %uint_1 - %77 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_0 - OpStore %77 %tint_low_inc_1 None - %78 = OpIEqual %bool %tint_low_inc_1 %uint_4294967295 -%tint_carry_1 = OpSelect %uint %78 %uint_1 %uint_0 - %80 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 - %81 = OpLoad %uint %80 None - %82 = OpISub %uint %81 %tint_carry_1 - %83 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 - OpStore %83 %82 None - %84 = OpLoad %int %j None - %85 = OpIAdd %int %84 %int_2 - OpStore %j %85 None - OpBranch %56 %57 = OpLabel + %63 = OpLoad %v2uint %tint_loop_idx_0 None + %64 = OpIEqual %v2bool %63 %23 + %65 = OpAll %bool %64 + OpSelectionMerge %66 None + OpBranchConditional %65 %67 %66 + %67 = OpLabel + OpBranch %60 + %66 = OpLabel + %68 = OpLoad %int %j None + %69 = OpSLessThan %bool %68 %int_2 + OpSelectionMerge %70 None + OpBranchConditional %69 %70 %71 + %71 = OpLabel + OpBranch %60 + %70 = OpLabel + %72 = OpLoad %int %j None + OpSelectionMerge %76 None + OpSwitch %72 %73 0 %74 1 %75 + %73 = OpLabel + OpBranch %76 + %74 = OpLabel + OpBranch %58 + %75 = OpLabel + %92 = OpLoad %int %k None + OpSelectionMerge %95 None + OpSwitch %92 %93 0 %94 + %93 = OpLabel + OpBranch %95 + %94 = OpLabel + OpBranch %58 + %95 = OpLabel + OpBranch %76 + %76 = OpLabel + OpBranch %58 + %58 = OpLabel + %77 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_0 + %78 = OpLoad %uint %77 None +%tint_low_inc_1 = OpISub %uint %78 %uint_1 + %80 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_0 + OpStore %80 %tint_low_inc_1 None + %81 = OpIEqual %bool %tint_low_inc_1 %uint_4294967295 +%tint_carry_1 = OpSelect %uint %81 %uint_1 %uint_0 + %83 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 + %84 = OpLoad %uint %83 None + %85 = OpISub %uint %84 %tint_carry_1 + %86 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 + OpStore %86 %85 None + %87 = OpLoad %int %j None + %88 = OpBitcast %uint %87 + %89 = OpBitcast %uint %int_2 + %90 = OpIAdd %uint %88 %89 + %91 = OpBitcast %int %90 + OpStore %j %91 None + OpBranch %59 + %60 = OpLabel OpBranch %11 %37 = OpLabel OpBranch %11 @@ -150,8 +153,11 @@ %50 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 OpStore %50 %49 None %51 = OpLoad %int %i None - %52 = OpIAdd %int %51 %int_2 - OpStore %i %52 None + %52 = OpBitcast %uint %51 + %53 = OpBitcast %uint %int_2 + %54 = OpIAdd %uint %52 %53 + %55 = OpBitcast %int %54 + OpStore %i %55 None OpBranch %12 %13 = OpLabel OpReturn
diff --git a/test/tint/loops/nested_loop_switch_loop_switch_switch_robustness.wgsl.expected.glsl b/test/tint/loops/nested_loop_switch_loop_switch_switch_robustness.wgsl.expected.glsl index 5c7b5f8..af21a5e 100644 --- a/test/tint/loops/nested_loop_switch_loop_switch_switch_robustness.wgsl.expected.glsl +++ b/test/tint/loops/nested_loop_switch_loop_switch_switch_robustness.wgsl.expected.glsl
@@ -67,7 +67,8 @@ tint_loop_idx_1.x = tint_low_inc_1; uint tint_carry_1 = uint((tint_low_inc_1 == 4294967295u)); tint_loop_idx_1.y = (tint_loop_idx_1.y - tint_carry_1); - j = (j + 2); + uint v = uint(j); + j = int((v + uint(2))); } continue; } @@ -76,7 +77,8 @@ tint_loop_idx_1.x = tint_low_inc_1; uint tint_carry_1 = uint((tint_low_inc_1 == 4294967295u)); tint_loop_idx_1.y = (tint_loop_idx_1.y - tint_carry_1); - j = (j + 2); + uint v = uint(j); + j = int((v + uint(2))); } continue; } @@ -95,7 +97,8 @@ tint_loop_idx.x = tint_low_inc; uint tint_carry = uint((tint_low_inc == 4294967295u)); tint_loop_idx.y = (tint_loop_idx.y - tint_carry); - i = (i + 2); + uint v_1 = uint(i); + i = int((v_1 + uint(2))); } continue; } @@ -104,7 +107,8 @@ tint_loop_idx.x = tint_low_inc; uint tint_carry = uint((tint_low_inc == 4294967295u)); tint_loop_idx.y = (tint_loop_idx.y - tint_carry); - i = (i + 2); + uint v_1 = uint(i); + i = int((v_1 + uint(2))); } continue; }
diff --git a/test/tint/loops/nested_loop_switch_loop_switch_switch_robustness.wgsl.expected.spvasm b/test/tint/loops/nested_loop_switch_loop_switch_switch_robustness.wgsl.expected.spvasm index 8484bee..b25d76f 100644 --- a/test/tint/loops/nested_loop_switch_loop_switch_switch_robustness.wgsl.expected.spvasm +++ b/test/tint/loops/nested_loop_switch_loop_switch_switch_robustness.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 90 +; Bound: 96 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -72,67 +72,70 @@ %35 = OpLabel OpBranch %37 %36 = OpLabel - OpBranch %53 - %53 = OpLabel - OpStore %tint_loop_idx_0 %18 - OpStore %j %int_0 OpBranch %56 %56 = OpLabel - OpLoopMerge %57 %55 None - OpBranch %54 - %54 = OpLabel - %60 = OpLoad %v2uint %tint_loop_idx_0 None - %61 = OpIEqual %v2bool %60 %23 - %62 = OpAll %bool %61 - OpSelectionMerge %63 None - OpBranchConditional %62 %64 %63 - %64 = OpLabel + OpStore %tint_loop_idx_0 %18 + OpStore %j %int_0 + OpBranch %59 + %59 = OpLabel + OpLoopMerge %60 %58 None OpBranch %57 - %63 = OpLabel - %65 = OpLoad %int %j None - %66 = OpSLessThan %bool %65 %int_2 - OpSelectionMerge %67 None - OpBranchConditional %66 %67 %68 - %68 = OpLabel - OpBranch %57 - %67 = OpLabel - %69 = OpLoad %int %j None - OpSelectionMerge %73 None - OpSwitch %69 %70 0 %71 1 %72 - %70 = OpLabel - OpBranch %73 - %71 = OpLabel - OpBranch %55 - %72 = OpLabel - %86 = OpLoad %int %k None - OpSelectionMerge %89 None - OpSwitch %86 %87 0 %88 - %87 = OpLabel - OpBranch %89 - %88 = OpLabel - OpBranch %55 - %89 = OpLabel - OpBranch %73 - %73 = OpLabel - OpBranch %55 - %55 = OpLabel - %74 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_0 - %75 = OpLoad %uint %74 None -%tint_low_inc_1 = OpISub %uint %75 %uint_1 - %77 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_0 - OpStore %77 %tint_low_inc_1 None - %78 = OpIEqual %bool %tint_low_inc_1 %uint_4294967295 -%tint_carry_1 = OpSelect %uint %78 %uint_1 %uint_0 - %80 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 - %81 = OpLoad %uint %80 None - %82 = OpISub %uint %81 %tint_carry_1 - %83 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 - OpStore %83 %82 None - %84 = OpLoad %int %j None - %85 = OpIAdd %int %84 %int_2 - OpStore %j %85 None - OpBranch %56 %57 = OpLabel + %63 = OpLoad %v2uint %tint_loop_idx_0 None + %64 = OpIEqual %v2bool %63 %23 + %65 = OpAll %bool %64 + OpSelectionMerge %66 None + OpBranchConditional %65 %67 %66 + %67 = OpLabel + OpBranch %60 + %66 = OpLabel + %68 = OpLoad %int %j None + %69 = OpSLessThan %bool %68 %int_2 + OpSelectionMerge %70 None + OpBranchConditional %69 %70 %71 + %71 = OpLabel + OpBranch %60 + %70 = OpLabel + %72 = OpLoad %int %j None + OpSelectionMerge %76 None + OpSwitch %72 %73 0 %74 1 %75 + %73 = OpLabel + OpBranch %76 + %74 = OpLabel + OpBranch %58 + %75 = OpLabel + %92 = OpLoad %int %k None + OpSelectionMerge %95 None + OpSwitch %92 %93 0 %94 + %93 = OpLabel + OpBranch %95 + %94 = OpLabel + OpBranch %58 + %95 = OpLabel + OpBranch %76 + %76 = OpLabel + OpBranch %58 + %58 = OpLabel + %77 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_0 + %78 = OpLoad %uint %77 None +%tint_low_inc_1 = OpISub %uint %78 %uint_1 + %80 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_0 + OpStore %80 %tint_low_inc_1 None + %81 = OpIEqual %bool %tint_low_inc_1 %uint_4294967295 +%tint_carry_1 = OpSelect %uint %81 %uint_1 %uint_0 + %83 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 + %84 = OpLoad %uint %83 None + %85 = OpISub %uint %84 %tint_carry_1 + %86 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 + OpStore %86 %85 None + %87 = OpLoad %int %j None + %88 = OpBitcast %uint %87 + %89 = OpBitcast %uint %int_2 + %90 = OpIAdd %uint %88 %89 + %91 = OpBitcast %int %90 + OpStore %j %91 None + OpBranch %59 + %60 = OpLabel OpBranch %11 %37 = OpLabel OpBranch %11 @@ -150,8 +153,11 @@ %50 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 OpStore %50 %49 None %51 = OpLoad %int %i None - %52 = OpIAdd %int %51 %int_2 - OpStore %i %52 None + %52 = OpBitcast %uint %51 + %53 = OpBitcast %uint %int_2 + %54 = OpIAdd %uint %52 %53 + %55 = OpBitcast %int %54 + OpStore %i %55 None OpBranch %12 %13 = OpLabel OpReturn
diff --git a/test/tint/loops/nested_loop_switch_switch.wgsl.expected.glsl b/test/tint/loops/nested_loop_switch_switch.wgsl.expected.glsl index dfcd0ad..f0e0adb 100644 --- a/test/tint/loops/nested_loop_switch_switch.wgsl.expected.glsl +++ b/test/tint/loops/nested_loop_switch_switch.wgsl.expected.glsl
@@ -47,7 +47,8 @@ tint_loop_idx.x = tint_low_inc; uint tint_carry = uint((tint_low_inc == 4294967295u)); tint_loop_idx.y = (tint_loop_idx.y - tint_carry); - i = (i + 2); + uint v = uint(i); + i = int((v + uint(2))); } continue; } @@ -56,7 +57,8 @@ tint_loop_idx.x = tint_low_inc; uint tint_carry = uint((tint_low_inc == 4294967295u)); tint_loop_idx.y = (tint_loop_idx.y - tint_carry); - i = (i + 2); + uint v = uint(i); + i = int((v + uint(2))); } continue; }
diff --git a/test/tint/loops/nested_loop_switch_switch.wgsl.expected.spvasm b/test/tint/loops/nested_loop_switch_switch.wgsl.expected.spvasm index 458006a..d68e811 100644 --- a/test/tint/loops/nested_loop_switch_switch.wgsl.expected.spvasm +++ b/test/tint/loops/nested_loop_switch_switch.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 57 +; Bound: 60 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -66,14 +66,14 @@ %35 = OpLabel OpBranch %37 %36 = OpLabel - %53 = OpLoad %int %j None - OpSelectionMerge %56 None - OpSwitch %53 %54 0 %55 - %54 = OpLabel - OpBranch %56 - %55 = OpLabel + %56 = OpLoad %int %j None + OpSelectionMerge %59 None + OpSwitch %56 %57 0 %58 + %57 = OpLabel + OpBranch %59 + %58 = OpLabel OpBranch %11 - %56 = OpLabel + %59 = OpLabel OpBranch %37 %37 = OpLabel OpBranch %11 @@ -91,8 +91,11 @@ %50 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 OpStore %50 %49 None %51 = OpLoad %int %i None - %52 = OpIAdd %int %51 %int_2 - OpStore %i %52 None + %52 = OpBitcast %uint %51 + %53 = OpBitcast %uint %int_2 + %54 = OpIAdd %uint %52 %53 + %55 = OpBitcast %int %54 + OpStore %i %55 None OpBranch %12 %13 = OpLabel OpReturn
diff --git a/test/tint/loops/nested_loop_switch_switch_robustness.wgsl.expected.glsl b/test/tint/loops/nested_loop_switch_switch_robustness.wgsl.expected.glsl index dfcd0ad..f0e0adb 100644 --- a/test/tint/loops/nested_loop_switch_switch_robustness.wgsl.expected.glsl +++ b/test/tint/loops/nested_loop_switch_switch_robustness.wgsl.expected.glsl
@@ -47,7 +47,8 @@ tint_loop_idx.x = tint_low_inc; uint tint_carry = uint((tint_low_inc == 4294967295u)); tint_loop_idx.y = (tint_loop_idx.y - tint_carry); - i = (i + 2); + uint v = uint(i); + i = int((v + uint(2))); } continue; } @@ -56,7 +57,8 @@ tint_loop_idx.x = tint_low_inc; uint tint_carry = uint((tint_low_inc == 4294967295u)); tint_loop_idx.y = (tint_loop_idx.y - tint_carry); - i = (i + 2); + uint v = uint(i); + i = int((v + uint(2))); } continue; }
diff --git a/test/tint/loops/nested_loop_switch_switch_robustness.wgsl.expected.spvasm b/test/tint/loops/nested_loop_switch_switch_robustness.wgsl.expected.spvasm index 458006a..d68e811 100644 --- a/test/tint/loops/nested_loop_switch_switch_robustness.wgsl.expected.spvasm +++ b/test/tint/loops/nested_loop_switch_switch_robustness.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 57 +; Bound: 60 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -66,14 +66,14 @@ %35 = OpLabel OpBranch %37 %36 = OpLabel - %53 = OpLoad %int %j None - OpSelectionMerge %56 None - OpSwitch %53 %54 0 %55 - %54 = OpLabel - OpBranch %56 - %55 = OpLabel + %56 = OpLoad %int %j None + OpSelectionMerge %59 None + OpSwitch %56 %57 0 %58 + %57 = OpLabel + OpBranch %59 + %58 = OpLabel OpBranch %11 - %56 = OpLabel + %59 = OpLabel OpBranch %37 %37 = OpLabel OpBranch %11 @@ -91,8 +91,11 @@ %50 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 OpStore %50 %49 None %51 = OpLoad %int %i None - %52 = OpIAdd %int %51 %int_2 - OpStore %i %52 None + %52 = OpBitcast %uint %51 + %53 = OpBitcast %uint %int_2 + %54 = OpIAdd %uint %52 %53 + %55 = OpBitcast %int %54 + OpStore %i %55 None OpBranch %12 %13 = OpLabel OpReturn
diff --git a/test/tint/loops/nested_loops.wgsl.expected.glsl b/test/tint/loops/nested_loops.wgsl.expected.glsl index 78ac004..4435461 100644 --- a/test/tint/loops/nested_loops.wgsl.expected.glsl +++ b/test/tint/loops/nested_loops.wgsl.expected.glsl
@@ -9,7 +9,8 @@ if (all(equal(tint_loop_idx, uvec2(0u)))) { break; } - i = (i + 1); + uint v = uint(i); + i = int((v + uint(1))); if ((i > 4)) { return 1; } @@ -19,7 +20,8 @@ if (all(equal(tint_loop_idx_1, uvec2(0u)))) { break; } - j = (j + 1); + uint v_1 = uint(j); + j = int((v_1 + uint(1))); if ((j > 4)) { return 2; }
diff --git a/test/tint/loops/nested_loops.wgsl.expected.spvasm b/test/tint/loops/nested_loops.wgsl.expected.spvasm index 10b1cd7..eccd4e3 100644 --- a/test/tint/loops/nested_loops.wgsl.expected.spvasm +++ b/test/tint/loops/nested_loops.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 99 +; Bound: 105 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -41,7 +41,7 @@ %false = OpConstantFalse %bool %int_2 = OpConstant %int 2 %void = OpTypeVoid - %97 = OpTypeFunction %void + %103 = OpTypeFunction %void %f = OpFunction %int None %3 %4 = OpLabel %return_value = OpVariable %_ptr_Function_int Function %7 @@ -68,102 +68,108 @@ OpBranch %18 %31 = OpLabel %33 = OpLoad %int %i None - %34 = OpIAdd %int %33 %int_1 - OpStore %i %34 None - %36 = OpLoad %int %i None - %37 = OpSGreaterThan %bool %36 %int_4 - OpSelectionMerge %39 None - OpBranchConditional %37 %40 %39 - %40 = OpLabel + %34 = OpBitcast %uint %33 + %35 = OpBitcast %uint %int_1 + %37 = OpIAdd %uint %34 %35 + %38 = OpBitcast %int %37 + OpStore %i %38 None + %39 = OpLoad %int %i None + %40 = OpSGreaterThan %bool %39 %int_4 + OpSelectionMerge %42 None + OpBranchConditional %40 %43 %42 + %43 = OpLabel OpStore %continue_execution %false None OpStore %return_value %int_1 None - OpBranch %39 - %39 = OpLabel - %41 = OpLoad %bool %continue_execution None - %42 = OpLogicalNot %bool %41 - OpSelectionMerge %43 None - OpBranchConditional %42 %44 %43 - %44 = OpLabel + OpBranch %42 + %42 = OpLabel + %44 = OpLoad %bool %continue_execution None + %45 = OpLogicalNot %bool %44 + OpSelectionMerge %46 None + OpBranchConditional %45 %47 %46 + %47 = OpLabel OpBranch %18 - %43 = OpLabel - OpBranch %45 - %45 = OpLabel - OpStore %tint_loop_idx_0 %24 + %46 = OpLabel OpBranch %48 %48 = OpLabel - OpLoopMerge %49 %47 None - OpBranch %46 - %46 = OpLabel - %69 = OpLoad %v2uint %tint_loop_idx_0 None - %70 = OpIEqual %v2bool %69 %28 - %71 = OpAll %bool %70 - OpSelectionMerge %72 None - OpBranchConditional %71 %73 %72 - %73 = OpLabel + OpStore %tint_loop_idx_0 %24 + OpBranch %51 + %51 = OpLabel + OpLoopMerge %52 %50 None OpBranch %49 - %72 = OpLabel - %74 = OpLoad %int %j None - %75 = OpIAdd %int %74 %int_1 - OpStore %j %75 None - %76 = OpLoad %int %j None - %77 = OpSGreaterThan %bool %76 %int_4 - OpSelectionMerge %78 None - OpBranchConditional %77 %79 %78 - %79 = OpLabel + %49 = OpLabel + %72 = OpLoad %v2uint %tint_loop_idx_0 None + %73 = OpIEqual %v2bool %72 %28 + %74 = OpAll %bool %73 + OpSelectionMerge %75 None + OpBranchConditional %74 %76 %75 + %76 = OpLabel + OpBranch %52 + %75 = OpLabel + %77 = OpLoad %int %j None + %78 = OpBitcast %uint %77 + %79 = OpBitcast %uint %int_1 + %80 = OpIAdd %uint %78 %79 + %81 = OpBitcast %int %80 + OpStore %j %81 None + %82 = OpLoad %int %j None + %83 = OpSGreaterThan %bool %82 %int_4 + OpSelectionMerge %84 None + OpBranchConditional %83 %85 %84 + %85 = OpLabel OpStore %continue_execution %false None OpStore %return_value %int_2 None - OpBranch %78 - %78 = OpLabel - %80 = OpLoad %bool %continue_execution None - %81 = OpLogicalNot %bool %80 - OpSelectionMerge %82 None - OpBranchConditional %81 %83 %82 - %83 = OpLabel - OpBranch %49 - %82 = OpLabel - OpBranch %47 - %47 = OpLabel - %84 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_0 - %85 = OpLoad %uint %84 None -%tint_low_inc_1 = OpISub %uint %85 %uint_1 - %87 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_0 - OpStore %87 %tint_low_inc_1 None - %88 = OpIEqual %bool %tint_low_inc_1 %uint_4294967295 -%tint_carry_1 = OpSelect %uint %88 %uint_1 %uint_0 - %90 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 + OpBranch %84 + %84 = OpLabel + %86 = OpLoad %bool %continue_execution None + %87 = OpLogicalNot %bool %86 + OpSelectionMerge %88 None + OpBranchConditional %87 %89 %88 + %89 = OpLabel + OpBranch %52 + %88 = OpLabel + OpBranch %50 + %50 = OpLabel + %90 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_0 %91 = OpLoad %uint %90 None - %92 = OpISub %uint %91 %tint_carry_1 - %93 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 - OpStore %93 %92 None - OpBranch %48 - %49 = OpLabel - %50 = OpLoad %bool %continue_execution None - %51 = OpLogicalNot %bool %50 - OpSelectionMerge %52 None - OpBranchConditional %51 %53 %52 - %53 = OpLabel - OpBranch %18 +%tint_low_inc_1 = OpISub %uint %91 %uint_1 + %93 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_0 + OpStore %93 %tint_low_inc_1 None + %94 = OpIEqual %bool %tint_low_inc_1 %uint_4294967295 +%tint_carry_1 = OpSelect %uint %94 %uint_1 %uint_0 + %96 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 + %97 = OpLoad %uint %96 None + %98 = OpISub %uint %97 %tint_carry_1 + %99 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 + OpStore %99 %98 None + OpBranch %51 %52 = OpLabel + %53 = OpLoad %bool %continue_execution None + %54 = OpLogicalNot %bool %53 + OpSelectionMerge %55 None + OpBranchConditional %54 %56 %55 + %56 = OpLabel + OpBranch %18 + %55 = OpLabel OpUnreachable %16 = OpLabel - %54 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 - %57 = OpLoad %uint %54 None -%tint_low_inc = OpISub %uint %57 %uint_1 - %60 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 - OpStore %60 %tint_low_inc None - %61 = OpIEqual %bool %tint_low_inc %uint_4294967295 - %tint_carry = OpSelect %uint %61 %uint_1 %uint_0 - %63 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 - %64 = OpLoad %uint %63 None - %65 = OpISub %uint %64 %tint_carry + %57 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 + %60 = OpLoad %uint %57 None +%tint_low_inc = OpISub %uint %60 %uint_1 + %63 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 + OpStore %63 %tint_low_inc None + %64 = OpIEqual %bool %tint_low_inc %uint_4294967295 + %tint_carry = OpSelect %uint %64 %uint_1 %uint_0 %66 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 - OpStore %66 %65 None + %67 = OpLoad %uint %66 None + %68 = OpISub %uint %67 %tint_carry + %69 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 + OpStore %69 %68 None OpBranch %17 %18 = OpLabel %19 = OpLoad %int %return_value None OpReturnValue %19 OpFunctionEnd -%unused_entry_point = OpFunction %void None %97 - %98 = OpLabel +%unused_entry_point = OpFunction %void None %103 + %104 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/loops/nested_loops_robustness.wgsl.expected.glsl b/test/tint/loops/nested_loops_robustness.wgsl.expected.glsl index 78ac004..4435461 100644 --- a/test/tint/loops/nested_loops_robustness.wgsl.expected.glsl +++ b/test/tint/loops/nested_loops_robustness.wgsl.expected.glsl
@@ -9,7 +9,8 @@ if (all(equal(tint_loop_idx, uvec2(0u)))) { break; } - i = (i + 1); + uint v = uint(i); + i = int((v + uint(1))); if ((i > 4)) { return 1; } @@ -19,7 +20,8 @@ if (all(equal(tint_loop_idx_1, uvec2(0u)))) { break; } - j = (j + 1); + uint v_1 = uint(j); + j = int((v_1 + uint(1))); if ((j > 4)) { return 2; }
diff --git a/test/tint/loops/nested_loops_robustness.wgsl.expected.spvasm b/test/tint/loops/nested_loops_robustness.wgsl.expected.spvasm index 10b1cd7..eccd4e3 100644 --- a/test/tint/loops/nested_loops_robustness.wgsl.expected.spvasm +++ b/test/tint/loops/nested_loops_robustness.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 99 +; Bound: 105 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -41,7 +41,7 @@ %false = OpConstantFalse %bool %int_2 = OpConstant %int 2 %void = OpTypeVoid - %97 = OpTypeFunction %void + %103 = OpTypeFunction %void %f = OpFunction %int None %3 %4 = OpLabel %return_value = OpVariable %_ptr_Function_int Function %7 @@ -68,102 +68,108 @@ OpBranch %18 %31 = OpLabel %33 = OpLoad %int %i None - %34 = OpIAdd %int %33 %int_1 - OpStore %i %34 None - %36 = OpLoad %int %i None - %37 = OpSGreaterThan %bool %36 %int_4 - OpSelectionMerge %39 None - OpBranchConditional %37 %40 %39 - %40 = OpLabel + %34 = OpBitcast %uint %33 + %35 = OpBitcast %uint %int_1 + %37 = OpIAdd %uint %34 %35 + %38 = OpBitcast %int %37 + OpStore %i %38 None + %39 = OpLoad %int %i None + %40 = OpSGreaterThan %bool %39 %int_4 + OpSelectionMerge %42 None + OpBranchConditional %40 %43 %42 + %43 = OpLabel OpStore %continue_execution %false None OpStore %return_value %int_1 None - OpBranch %39 - %39 = OpLabel - %41 = OpLoad %bool %continue_execution None - %42 = OpLogicalNot %bool %41 - OpSelectionMerge %43 None - OpBranchConditional %42 %44 %43 - %44 = OpLabel + OpBranch %42 + %42 = OpLabel + %44 = OpLoad %bool %continue_execution None + %45 = OpLogicalNot %bool %44 + OpSelectionMerge %46 None + OpBranchConditional %45 %47 %46 + %47 = OpLabel OpBranch %18 - %43 = OpLabel - OpBranch %45 - %45 = OpLabel - OpStore %tint_loop_idx_0 %24 + %46 = OpLabel OpBranch %48 %48 = OpLabel - OpLoopMerge %49 %47 None - OpBranch %46 - %46 = OpLabel - %69 = OpLoad %v2uint %tint_loop_idx_0 None - %70 = OpIEqual %v2bool %69 %28 - %71 = OpAll %bool %70 - OpSelectionMerge %72 None - OpBranchConditional %71 %73 %72 - %73 = OpLabel + OpStore %tint_loop_idx_0 %24 + OpBranch %51 + %51 = OpLabel + OpLoopMerge %52 %50 None OpBranch %49 - %72 = OpLabel - %74 = OpLoad %int %j None - %75 = OpIAdd %int %74 %int_1 - OpStore %j %75 None - %76 = OpLoad %int %j None - %77 = OpSGreaterThan %bool %76 %int_4 - OpSelectionMerge %78 None - OpBranchConditional %77 %79 %78 - %79 = OpLabel + %49 = OpLabel + %72 = OpLoad %v2uint %tint_loop_idx_0 None + %73 = OpIEqual %v2bool %72 %28 + %74 = OpAll %bool %73 + OpSelectionMerge %75 None + OpBranchConditional %74 %76 %75 + %76 = OpLabel + OpBranch %52 + %75 = OpLabel + %77 = OpLoad %int %j None + %78 = OpBitcast %uint %77 + %79 = OpBitcast %uint %int_1 + %80 = OpIAdd %uint %78 %79 + %81 = OpBitcast %int %80 + OpStore %j %81 None + %82 = OpLoad %int %j None + %83 = OpSGreaterThan %bool %82 %int_4 + OpSelectionMerge %84 None + OpBranchConditional %83 %85 %84 + %85 = OpLabel OpStore %continue_execution %false None OpStore %return_value %int_2 None - OpBranch %78 - %78 = OpLabel - %80 = OpLoad %bool %continue_execution None - %81 = OpLogicalNot %bool %80 - OpSelectionMerge %82 None - OpBranchConditional %81 %83 %82 - %83 = OpLabel - OpBranch %49 - %82 = OpLabel - OpBranch %47 - %47 = OpLabel - %84 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_0 - %85 = OpLoad %uint %84 None -%tint_low_inc_1 = OpISub %uint %85 %uint_1 - %87 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_0 - OpStore %87 %tint_low_inc_1 None - %88 = OpIEqual %bool %tint_low_inc_1 %uint_4294967295 -%tint_carry_1 = OpSelect %uint %88 %uint_1 %uint_0 - %90 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 + OpBranch %84 + %84 = OpLabel + %86 = OpLoad %bool %continue_execution None + %87 = OpLogicalNot %bool %86 + OpSelectionMerge %88 None + OpBranchConditional %87 %89 %88 + %89 = OpLabel + OpBranch %52 + %88 = OpLabel + OpBranch %50 + %50 = OpLabel + %90 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_0 %91 = OpLoad %uint %90 None - %92 = OpISub %uint %91 %tint_carry_1 - %93 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 - OpStore %93 %92 None - OpBranch %48 - %49 = OpLabel - %50 = OpLoad %bool %continue_execution None - %51 = OpLogicalNot %bool %50 - OpSelectionMerge %52 None - OpBranchConditional %51 %53 %52 - %53 = OpLabel - OpBranch %18 +%tint_low_inc_1 = OpISub %uint %91 %uint_1 + %93 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_0 + OpStore %93 %tint_low_inc_1 None + %94 = OpIEqual %bool %tint_low_inc_1 %uint_4294967295 +%tint_carry_1 = OpSelect %uint %94 %uint_1 %uint_0 + %96 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 + %97 = OpLoad %uint %96 None + %98 = OpISub %uint %97 %tint_carry_1 + %99 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 + OpStore %99 %98 None + OpBranch %51 %52 = OpLabel + %53 = OpLoad %bool %continue_execution None + %54 = OpLogicalNot %bool %53 + OpSelectionMerge %55 None + OpBranchConditional %54 %56 %55 + %56 = OpLabel + OpBranch %18 + %55 = OpLabel OpUnreachable %16 = OpLabel - %54 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 - %57 = OpLoad %uint %54 None -%tint_low_inc = OpISub %uint %57 %uint_1 - %60 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 - OpStore %60 %tint_low_inc None - %61 = OpIEqual %bool %tint_low_inc %uint_4294967295 - %tint_carry = OpSelect %uint %61 %uint_1 %uint_0 - %63 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 - %64 = OpLoad %uint %63 None - %65 = OpISub %uint %64 %tint_carry + %57 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 + %60 = OpLoad %uint %57 None +%tint_low_inc = OpISub %uint %60 %uint_1 + %63 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 + OpStore %63 %tint_low_inc None + %64 = OpIEqual %bool %tint_low_inc %uint_4294967295 + %tint_carry = OpSelect %uint %64 %uint_1 %uint_0 %66 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 - OpStore %66 %65 None + %67 = OpLoad %uint %66 None + %68 = OpISub %uint %67 %tint_carry + %69 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 + OpStore %69 %68 None OpBranch %17 %18 = OpLabel %19 = OpLoad %int %return_value None OpReturnValue %19 OpFunctionEnd -%unused_entry_point = OpFunction %void None %97 - %98 = OpLabel +%unused_entry_point = OpFunction %void None %103 + %104 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/loops/nested_loops_with_continuing.wgsl.expected.glsl b/test/tint/loops/nested_loops_with_continuing.wgsl.expected.glsl index 088d3b2..e642ef8 100644 --- a/test/tint/loops/nested_loops_with_continuing.wgsl.expected.glsl +++ b/test/tint/loops/nested_loops_with_continuing.wgsl.expected.glsl
@@ -26,7 +26,8 @@ tint_loop_idx_1.x = tint_low_inc_1; uint tint_carry_1 = uint((tint_low_inc_1 == 4294967295u)); tint_loop_idx_1.y = (tint_loop_idx_1.y - tint_carry_1); - j = (j + 1); + uint v = uint(j); + j = int((v + uint(1))); } continue; }
diff --git a/test/tint/loops/nested_loops_with_continuing.wgsl.expected.spvasm b/test/tint/loops/nested_loops_with_continuing.wgsl.expected.spvasm index 1c01831..7487191 100644 --- a/test/tint/loops/nested_loops_with_continuing.wgsl.expected.spvasm +++ b/test/tint/loops/nested_loops_with_continuing.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 97 +; Bound: 100 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -41,7 +41,7 @@ %int_1 = OpConstant %int 1 %int_2 = OpConstant %int 2 %void = OpTypeVoid - %95 = OpTypeFunction %void + %98 = OpTypeFunction %void %f = OpFunction %int None %3 %4 = OpLabel %return_value = OpVariable %_ptr_Function_int Function %7 @@ -130,8 +130,11 @@ %89 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 OpStore %89 %88 None %90 = OpLoad %int %j None - %91 = OpIAdd %int %90 %int_1 - OpStore %j %91 None + %91 = OpBitcast %uint %90 + %92 = OpBitcast %uint %int_1 + %93 = OpIAdd %uint %91 %92 + %94 = OpBitcast %int %93 + OpStore %j %94 None OpBranch %45 %46 = OpLabel %47 = OpLoad %bool %continue_execution None @@ -160,7 +163,7 @@ %19 = OpLoad %int %return_value None OpReturnValue %19 OpFunctionEnd -%unused_entry_point = OpFunction %void None %95 - %96 = OpLabel +%unused_entry_point = OpFunction %void None %98 + %99 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/loops/nested_loops_with_continuing_robustness.wgsl.expected.glsl b/test/tint/loops/nested_loops_with_continuing_robustness.wgsl.expected.glsl index 088d3b2..e642ef8 100644 --- a/test/tint/loops/nested_loops_with_continuing_robustness.wgsl.expected.glsl +++ b/test/tint/loops/nested_loops_with_continuing_robustness.wgsl.expected.glsl
@@ -26,7 +26,8 @@ tint_loop_idx_1.x = tint_low_inc_1; uint tint_carry_1 = uint((tint_low_inc_1 == 4294967295u)); tint_loop_idx_1.y = (tint_loop_idx_1.y - tint_carry_1); - j = (j + 1); + uint v = uint(j); + j = int((v + uint(1))); } continue; }
diff --git a/test/tint/loops/nested_loops_with_continuing_robustness.wgsl.expected.spvasm b/test/tint/loops/nested_loops_with_continuing_robustness.wgsl.expected.spvasm index 1c01831..7487191 100644 --- a/test/tint/loops/nested_loops_with_continuing_robustness.wgsl.expected.spvasm +++ b/test/tint/loops/nested_loops_with_continuing_robustness.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 97 +; Bound: 100 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -41,7 +41,7 @@ %int_1 = OpConstant %int 1 %int_2 = OpConstant %int 2 %void = OpTypeVoid - %95 = OpTypeFunction %void + %98 = OpTypeFunction %void %f = OpFunction %int None %3 %4 = OpLabel %return_value = OpVariable %_ptr_Function_int Function %7 @@ -130,8 +130,11 @@ %89 = OpAccessChain %_ptr_Function_uint %tint_loop_idx_0 %uint_1 OpStore %89 %88 None %90 = OpLoad %int %j None - %91 = OpIAdd %int %90 %int_1 - OpStore %j %91 None + %91 = OpBitcast %uint %90 + %92 = OpBitcast %uint %int_1 + %93 = OpIAdd %uint %91 %92 + %94 = OpBitcast %int %93 + OpStore %j %94 None OpBranch %45 %46 = OpLabel %47 = OpLoad %bool %continue_execution None @@ -160,7 +163,7 @@ %19 = OpLoad %int %return_value None OpReturnValue %19 OpFunctionEnd -%unused_entry_point = OpFunction %void None %95 - %96 = OpLabel +%unused_entry_point = OpFunction %void None %98 + %99 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/loops/single_continue.wgsl.expected.glsl b/test/tint/loops/single_continue.wgsl.expected.glsl index 4abaca6..03a66f8 100644 --- a/test/tint/loops/single_continue.wgsl.expected.glsl +++ b/test/tint/loops/single_continue.wgsl.expected.glsl
@@ -23,12 +23,14 @@ } if (tint_continue) { { - i = (i + 1); + uint v = uint(i); + i = int((v + uint(1))); } continue; } { - i = (i + 1); + uint v = uint(i); + i = int((v + uint(1))); } continue; }
diff --git a/test/tint/loops/single_continue.wgsl.expected.spvasm b/test/tint/loops/single_continue.wgsl.expected.spvasm index 882a203..65cddcd 100644 --- a/test/tint/loops/single_continue.wgsl.expected.spvasm +++ b/test/tint/loops/single_continue.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 27 +; Bound: 31 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -16,6 +16,7 @@ %int_0 = OpConstant %int 0 %int_2 = OpConstant %int 2 %bool = OpTypeBool + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %main = OpFunction %void None %3 %4 = OpLabel @@ -46,8 +47,11 @@ OpBranch %7 %7 = OpLabel %24 = OpLoad %int %i None - %25 = OpIAdd %int %24 %int_1 - OpStore %i %25 None + %26 = OpBitcast %uint %24 + %27 = OpBitcast %uint %int_1 + %29 = OpIAdd %uint %26 %27 + %30 = OpBitcast %int %29 + OpStore %i %30 None OpBranch %8 %9 = OpLabel OpReturn
diff --git a/test/tint/loops/single_continue_robustness.wgsl.expected.glsl b/test/tint/loops/single_continue_robustness.wgsl.expected.glsl index 4abaca6..03a66f8 100644 --- a/test/tint/loops/single_continue_robustness.wgsl.expected.glsl +++ b/test/tint/loops/single_continue_robustness.wgsl.expected.glsl
@@ -23,12 +23,14 @@ } if (tint_continue) { { - i = (i + 1); + uint v = uint(i); + i = int((v + uint(1))); } continue; } { - i = (i + 1); + uint v = uint(i); + i = int((v + uint(1))); } continue; }
diff --git a/test/tint/loops/single_continue_robustness.wgsl.expected.spvasm b/test/tint/loops/single_continue_robustness.wgsl.expected.spvasm index 882a203..65cddcd 100644 --- a/test/tint/loops/single_continue_robustness.wgsl.expected.spvasm +++ b/test/tint/loops/single_continue_robustness.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 27 +; Bound: 31 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -16,6 +16,7 @@ %int_0 = OpConstant %int 0 %int_2 = OpConstant %int 2 %bool = OpTypeBool + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %main = OpFunction %void None %3 %4 = OpLabel @@ -46,8 +47,11 @@ OpBranch %7 %7 = OpLabel %24 = OpLoad %int %i None - %25 = OpIAdd %int %24 %int_1 - OpStore %i %25 None + %26 = OpBitcast %uint %24 + %27 = OpBitcast %uint %int_1 + %29 = OpIAdd %uint %26 %27 + %30 = OpBitcast %int %29 + OpStore %i %30 None OpBranch %8 %9 = OpLabel OpReturn
diff --git a/test/tint/loops/while.wgsl.expected.glsl b/test/tint/loops/while.wgsl.expected.glsl index 2280d1b..7493c94 100644 --- a/test/tint/loops/while.wgsl.expected.glsl +++ b/test/tint/loops/while.wgsl.expected.glsl
@@ -12,7 +12,8 @@ } else { break; } - i = (i + 1); + uint v = uint(i); + i = int((v + uint(1))); { uint tint_low_inc = (tint_loop_idx.x - 1u); tint_loop_idx.x = tint_low_inc;
diff --git a/test/tint/loops/while.wgsl.expected.spvasm b/test/tint/loops/while.wgsl.expected.spvasm index b26011f..cde37f7 100644 --- a/test/tint/loops/while.wgsl.expected.spvasm +++ b/test/tint/loops/while.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 53 +; Bound: 56 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -31,7 +31,7 @@ %uint_0 = OpConstant %uint 0 %uint_1 = OpConstant %uint 1 %void = OpTypeVoid - %51 = OpTypeFunction %void + %54 = OpTypeFunction %void %f = OpFunction %int None %3 %4 = OpLabel %i = OpVariable %_ptr_Function_int Function %7 @@ -60,28 +60,31 @@ OpBranch %12 %31 = OpLabel %33 = OpLoad %int %i None - %34 = OpIAdd %int %33 %int_1 - OpStore %i %34 None + %34 = OpBitcast %uint %33 + %35 = OpBitcast %uint %int_1 + %37 = OpIAdd %uint %34 %35 + %38 = OpBitcast %int %37 + OpStore %i %38 None OpBranch %10 %10 = OpLabel - %36 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 - %39 = OpLoad %uint %36 None -%tint_low_inc = OpISub %uint %39 %uint_1 - %42 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 - OpStore %42 %tint_low_inc None - %43 = OpIEqual %bool %tint_low_inc %uint_4294967295 - %tint_carry = OpSelect %uint %43 %uint_1 %uint_0 - %45 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 - %46 = OpLoad %uint %45 None - %47 = OpISub %uint %46 %tint_carry + %39 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 + %42 = OpLoad %uint %39 None +%tint_low_inc = OpISub %uint %42 %uint_1 + %45 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 + OpStore %45 %tint_low_inc None + %46 = OpIEqual %bool %tint_low_inc %uint_4294967295 + %tint_carry = OpSelect %uint %46 %uint_1 %uint_0 %48 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 - OpStore %48 %47 None + %49 = OpLoad %uint %48 None + %50 = OpISub %uint %49 %tint_carry + %51 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 + OpStore %51 %50 None OpBranch %11 %12 = OpLabel %13 = OpLoad %int %i None OpReturnValue %13 OpFunctionEnd -%unused_entry_point = OpFunction %void None %51 - %52 = OpLabel +%unused_entry_point = OpFunction %void None %54 + %55 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/loops/while_robustness.wgsl.expected.glsl b/test/tint/loops/while_robustness.wgsl.expected.glsl index 2280d1b..7493c94 100644 --- a/test/tint/loops/while_robustness.wgsl.expected.glsl +++ b/test/tint/loops/while_robustness.wgsl.expected.glsl
@@ -12,7 +12,8 @@ } else { break; } - i = (i + 1); + uint v = uint(i); + i = int((v + uint(1))); { uint tint_low_inc = (tint_loop_idx.x - 1u); tint_loop_idx.x = tint_low_inc;
diff --git a/test/tint/loops/while_robustness.wgsl.expected.spvasm b/test/tint/loops/while_robustness.wgsl.expected.spvasm index b26011f..cde37f7 100644 --- a/test/tint/loops/while_robustness.wgsl.expected.spvasm +++ b/test/tint/loops/while_robustness.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 53 +; Bound: 56 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -31,7 +31,7 @@ %uint_0 = OpConstant %uint 0 %uint_1 = OpConstant %uint 1 %void = OpTypeVoid - %51 = OpTypeFunction %void + %54 = OpTypeFunction %void %f = OpFunction %int None %3 %4 = OpLabel %i = OpVariable %_ptr_Function_int Function %7 @@ -60,28 +60,31 @@ OpBranch %12 %31 = OpLabel %33 = OpLoad %int %i None - %34 = OpIAdd %int %33 %int_1 - OpStore %i %34 None + %34 = OpBitcast %uint %33 + %35 = OpBitcast %uint %int_1 + %37 = OpIAdd %uint %34 %35 + %38 = OpBitcast %int %37 + OpStore %i %38 None OpBranch %10 %10 = OpLabel - %36 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 - %39 = OpLoad %uint %36 None -%tint_low_inc = OpISub %uint %39 %uint_1 - %42 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 - OpStore %42 %tint_low_inc None - %43 = OpIEqual %bool %tint_low_inc %uint_4294967295 - %tint_carry = OpSelect %uint %43 %uint_1 %uint_0 - %45 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 - %46 = OpLoad %uint %45 None - %47 = OpISub %uint %46 %tint_carry + %39 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 + %42 = OpLoad %uint %39 None +%tint_low_inc = OpISub %uint %42 %uint_1 + %45 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 + OpStore %45 %tint_low_inc None + %46 = OpIEqual %bool %tint_low_inc %uint_4294967295 + %tint_carry = OpSelect %uint %46 %uint_1 %uint_0 %48 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 - OpStore %48 %47 None + %49 = OpLoad %uint %48 None + %50 = OpISub %uint %49 %tint_carry + %51 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 + OpStore %51 %50 None OpBranch %11 %12 = OpLabel %13 = OpLoad %int %i None OpReturnValue %13 OpFunctionEnd -%unused_entry_point = OpFunction %void None %51 - %52 = OpLabel +%unused_entry_point = OpFunction %void None %54 + %55 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/loops/while_with_continue.wgsl.expected.glsl b/test/tint/loops/while_with_continue.wgsl.expected.glsl index 2280d1b..7493c94 100644 --- a/test/tint/loops/while_with_continue.wgsl.expected.glsl +++ b/test/tint/loops/while_with_continue.wgsl.expected.glsl
@@ -12,7 +12,8 @@ } else { break; } - i = (i + 1); + uint v = uint(i); + i = int((v + uint(1))); { uint tint_low_inc = (tint_loop_idx.x - 1u); tint_loop_idx.x = tint_low_inc;
diff --git a/test/tint/loops/while_with_continue.wgsl.expected.spvasm b/test/tint/loops/while_with_continue.wgsl.expected.spvasm index b26011f..cde37f7 100644 --- a/test/tint/loops/while_with_continue.wgsl.expected.spvasm +++ b/test/tint/loops/while_with_continue.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 53 +; Bound: 56 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -31,7 +31,7 @@ %uint_0 = OpConstant %uint 0 %uint_1 = OpConstant %uint 1 %void = OpTypeVoid - %51 = OpTypeFunction %void + %54 = OpTypeFunction %void %f = OpFunction %int None %3 %4 = OpLabel %i = OpVariable %_ptr_Function_int Function %7 @@ -60,28 +60,31 @@ OpBranch %12 %31 = OpLabel %33 = OpLoad %int %i None - %34 = OpIAdd %int %33 %int_1 - OpStore %i %34 None + %34 = OpBitcast %uint %33 + %35 = OpBitcast %uint %int_1 + %37 = OpIAdd %uint %34 %35 + %38 = OpBitcast %int %37 + OpStore %i %38 None OpBranch %10 %10 = OpLabel - %36 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 - %39 = OpLoad %uint %36 None -%tint_low_inc = OpISub %uint %39 %uint_1 - %42 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 - OpStore %42 %tint_low_inc None - %43 = OpIEqual %bool %tint_low_inc %uint_4294967295 - %tint_carry = OpSelect %uint %43 %uint_1 %uint_0 - %45 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 - %46 = OpLoad %uint %45 None - %47 = OpISub %uint %46 %tint_carry + %39 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 + %42 = OpLoad %uint %39 None +%tint_low_inc = OpISub %uint %42 %uint_1 + %45 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 + OpStore %45 %tint_low_inc None + %46 = OpIEqual %bool %tint_low_inc %uint_4294967295 + %tint_carry = OpSelect %uint %46 %uint_1 %uint_0 %48 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 - OpStore %48 %47 None + %49 = OpLoad %uint %48 None + %50 = OpISub %uint %49 %tint_carry + %51 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 + OpStore %51 %50 None OpBranch %11 %12 = OpLabel %13 = OpLoad %int %i None OpReturnValue %13 OpFunctionEnd -%unused_entry_point = OpFunction %void None %51 - %52 = OpLabel +%unused_entry_point = OpFunction %void None %54 + %55 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/loops/while_with_continue_robustness.wgsl.expected.glsl b/test/tint/loops/while_with_continue_robustness.wgsl.expected.glsl index 2280d1b..7493c94 100644 --- a/test/tint/loops/while_with_continue_robustness.wgsl.expected.glsl +++ b/test/tint/loops/while_with_continue_robustness.wgsl.expected.glsl
@@ -12,7 +12,8 @@ } else { break; } - i = (i + 1); + uint v = uint(i); + i = int((v + uint(1))); { uint tint_low_inc = (tint_loop_idx.x - 1u); tint_loop_idx.x = tint_low_inc;
diff --git a/test/tint/loops/while_with_continue_robustness.wgsl.expected.spvasm b/test/tint/loops/while_with_continue_robustness.wgsl.expected.spvasm index b26011f..cde37f7 100644 --- a/test/tint/loops/while_with_continue_robustness.wgsl.expected.spvasm +++ b/test/tint/loops/while_with_continue_robustness.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 53 +; Bound: 56 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -31,7 +31,7 @@ %uint_0 = OpConstant %uint 0 %uint_1 = OpConstant %uint 1 %void = OpTypeVoid - %51 = OpTypeFunction %void + %54 = OpTypeFunction %void %f = OpFunction %int None %3 %4 = OpLabel %i = OpVariable %_ptr_Function_int Function %7 @@ -60,28 +60,31 @@ OpBranch %12 %31 = OpLabel %33 = OpLoad %int %i None - %34 = OpIAdd %int %33 %int_1 - OpStore %i %34 None + %34 = OpBitcast %uint %33 + %35 = OpBitcast %uint %int_1 + %37 = OpIAdd %uint %34 %35 + %38 = OpBitcast %int %37 + OpStore %i %38 None OpBranch %10 %10 = OpLabel - %36 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 - %39 = OpLoad %uint %36 None -%tint_low_inc = OpISub %uint %39 %uint_1 - %42 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 - OpStore %42 %tint_low_inc None - %43 = OpIEqual %bool %tint_low_inc %uint_4294967295 - %tint_carry = OpSelect %uint %43 %uint_1 %uint_0 - %45 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 - %46 = OpLoad %uint %45 None - %47 = OpISub %uint %46 %tint_carry + %39 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 + %42 = OpLoad %uint %39 None +%tint_low_inc = OpISub %uint %42 %uint_1 + %45 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 + OpStore %45 %tint_low_inc None + %46 = OpIEqual %bool %tint_low_inc %uint_4294967295 + %tint_carry = OpSelect %uint %46 %uint_1 %uint_0 %48 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 - OpStore %48 %47 None + %49 = OpLoad %uint %48 None + %50 = OpISub %uint %49 %tint_carry + %51 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 + OpStore %51 %50 None OpBranch %11 %12 = OpLabel %13 = OpLoad %int %i None OpReturnValue %13 OpFunctionEnd -%unused_entry_point = OpFunction %void None %51 - %52 = OpLabel +%unused_entry_point = OpFunction %void None %54 + %55 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/ptr_ref/load/global/i32.wgsl.expected.glsl b/test/tint/ptr_ref/load/global/i32.wgsl.expected.glsl index 0adb927..6cb80a8 100644 --- a/test/tint/ptr_ref/load/global/i32.wgsl.expected.glsl +++ b/test/tint/ptr_ref/load/global/i32.wgsl.expected.glsl
@@ -4,5 +4,6 @@ layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { int i = I; - int u = (i + 1); + uint v = uint(i); + int u = int((v + uint(1))); }
diff --git a/test/tint/ptr_ref/load/global/i32.wgsl.expected.spvasm b/test/tint/ptr_ref/load/global/i32.wgsl.expected.spvasm index 8280edc..814d366 100644 --- a/test/tint/ptr_ref/load/global/i32.wgsl.expected.spvasm +++ b/test/tint/ptr_ref/load/global/i32.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 12 +; Bound: 16 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -17,10 +17,14 @@ %I = OpVariable %_ptr_Private_int Private %4 %void = OpTypeVoid %7 = OpTypeFunction %void + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %main = OpFunction %void None %7 %8 = OpLabel %i = OpLoad %int %I None - %u = OpIAdd %int %i %int_1 + %11 = OpBitcast %uint %i + %12 = OpBitcast %uint %int_1 + %14 = OpIAdd %uint %11 %12 + %u = OpBitcast %int %14 OpReturn OpFunctionEnd
diff --git a/test/tint/ptr_ref/load/local/i32.wgsl.expected.glsl b/test/tint/ptr_ref/load/local/i32.wgsl.expected.glsl index 25381ce..ea2c704 100644 --- a/test/tint/ptr_ref/load/local/i32.wgsl.expected.glsl +++ b/test/tint/ptr_ref/load/local/i32.wgsl.expected.glsl
@@ -3,5 +3,6 @@ layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { int i = 123; - int u = (i + 1); + uint v = uint(i); + int u = int((v + uint(1))); }
diff --git a/test/tint/ptr_ref/load/local/i32.wgsl.expected.spvasm b/test/tint/ptr_ref/load/local/i32.wgsl.expected.spvasm index f2889ac..a06d697 100644 --- a/test/tint/ptr_ref/load/local/i32.wgsl.expected.spvasm +++ b/test/tint/ptr_ref/load/local/i32.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 12 +; Bound: 16 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -15,12 +15,16 @@ %int = OpTypeInt 32 1 %_ptr_Function_int = OpTypePointer Function %int %int_123 = OpConstant %int 123 + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %main = OpFunction %void None %3 %4 = OpLabel %i = OpVariable %_ptr_Function_int Function OpStore %i %int_123 %9 = OpLoad %int %i None - %u = OpIAdd %int %9 %int_1 + %11 = OpBitcast %uint %9 + %12 = OpBitcast %uint %int_1 + %14 = OpIAdd %uint %11 %12 + %u = OpBitcast %int %14 OpReturn OpFunctionEnd
diff --git a/test/tint/ptr_ref/load/local/ptr_function.wgsl.expected.glsl b/test/tint/ptr_ref/load/local/ptr_function.wgsl.expected.glsl index 25381ce..ea2c704 100644 --- a/test/tint/ptr_ref/load/local/ptr_function.wgsl.expected.glsl +++ b/test/tint/ptr_ref/load/local/ptr_function.wgsl.expected.glsl
@@ -3,5 +3,6 @@ layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { int i = 123; - int u = (i + 1); + uint v = uint(i); + int u = int((v + uint(1))); }
diff --git a/test/tint/ptr_ref/load/local/ptr_function.wgsl.expected.spvasm b/test/tint/ptr_ref/load/local/ptr_function.wgsl.expected.spvasm index 72e6abf..c1204e5 100644 --- a/test/tint/ptr_ref/load/local/ptr_function.wgsl.expected.spvasm +++ b/test/tint/ptr_ref/load/local/ptr_function.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 12 +; Bound: 16 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -16,12 +16,16 @@ %int = OpTypeInt 32 1 %_ptr_Function_int = OpTypePointer Function %int %int_123 = OpConstant %int 123 + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %main = OpFunction %void None %3 %4 = OpLabel %i = OpVariable %_ptr_Function_int Function OpStore %i %int_123 %9 = OpLoad %int %i None - %u = OpIAdd %int %9 %int_1 + %11 = OpBitcast %uint %9 + %12 = OpBitcast %uint %int_1 + %14 = OpIAdd %uint %11 %12 + %u = OpBitcast %int %14 OpReturn OpFunctionEnd
diff --git a/test/tint/ptr_ref/load/local/ptr_private.wgsl.expected.glsl b/test/tint/ptr_ref/load/local/ptr_private.wgsl.expected.glsl index c1b85c7..d779074 100644 --- a/test/tint/ptr_ref/load/local/ptr_private.wgsl.expected.glsl +++ b/test/tint/ptr_ref/load/local/ptr_private.wgsl.expected.glsl
@@ -3,5 +3,6 @@ int i = 123; layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - int u = (i + 1); + uint v = uint(i); + int u = int((v + uint(1))); }
diff --git a/test/tint/ptr_ref/load/local/ptr_private.wgsl.expected.spvasm b/test/tint/ptr_ref/load/local/ptr_private.wgsl.expected.spvasm index c068d87..76b6cc3 100644 --- a/test/tint/ptr_ref/load/local/ptr_private.wgsl.expected.spvasm +++ b/test/tint/ptr_ref/load/local/ptr_private.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 12 +; Bound: 16 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -17,10 +17,14 @@ %i = OpVariable %_ptr_Private_int Private %int_123 %void = OpTypeVoid %7 = OpTypeFunction %void + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %main = OpFunction %void None %7 %8 = OpLabel %9 = OpLoad %int %i None - %u = OpIAdd %int %9 %int_1 + %11 = OpBitcast %uint %9 + %12 = OpBitcast %uint %int_1 + %14 = OpIAdd %uint %11 %12 + %u = OpBitcast %int %14 OpReturn OpFunctionEnd
diff --git a/test/tint/ptr_ref/load/local/ptr_storage.wgsl.expected.glsl b/test/tint/ptr_ref/load/local/ptr_storage.wgsl.expected.glsl index 8c87d98..0ecfe7b 100644 --- a/test/tint/ptr_ref/load/local/ptr_storage.wgsl.expected.glsl +++ b/test/tint/ptr_ref/load/local/ptr_storage.wgsl.expected.glsl
@@ -11,5 +11,6 @@ } v_1; layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - int u = (v_1.inner.a + 1); + uint v_2 = uint(v_1.inner.a); + int u = int((v_2 + uint(1))); }
diff --git a/test/tint/ptr_ref/load/local/ptr_storage.wgsl.expected.spvasm b/test/tint/ptr_ref/load/local/ptr_storage.wgsl.expected.spvasm index 059cb5c..408fb21 100644 --- a/test/tint/ptr_ref/load/local/ptr_storage.wgsl.expected.spvasm +++ b/test/tint/ptr_ref/load/local/ptr_storage.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 17 +; Bound: 20 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -35,6 +35,9 @@ %9 = OpLabel %p = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 %uint_0 %14 = OpLoad %int %p None - %u = OpIAdd %int %14 %int_1 + %15 = OpBitcast %uint %14 + %16 = OpBitcast %uint %int_1 + %18 = OpIAdd %uint %15 %16 + %u = OpBitcast %int %18 OpReturn OpFunctionEnd
diff --git a/test/tint/ptr_ref/load/local/ptr_uniform.wgsl.expected.glsl b/test/tint/ptr_ref/load/local/ptr_uniform.wgsl.expected.glsl index 8efd233..393639f 100644 --- a/test/tint/ptr_ref/load/local/ptr_uniform.wgsl.expected.glsl +++ b/test/tint/ptr_ref/load/local/ptr_uniform.wgsl.expected.glsl
@@ -11,5 +11,6 @@ } v_1; layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - int u = (v_1.inner.a + 1); + uint v_2 = uint(v_1.inner.a); + int u = int((v_2 + uint(1))); }
diff --git a/test/tint/ptr_ref/load/local/ptr_uniform.wgsl.expected.spvasm b/test/tint/ptr_ref/load/local/ptr_uniform.wgsl.expected.spvasm index 2927719..3dde4f5 100644 --- a/test/tint/ptr_ref/load/local/ptr_uniform.wgsl.expected.spvasm +++ b/test/tint/ptr_ref/load/local/ptr_uniform.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 17 +; Bound: 20 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -35,6 +35,9 @@ %9 = OpLabel %p = OpAccessChain %_ptr_Uniform_int %1 %uint_0 %uint_0 %14 = OpLoad %int %p None - %u = OpIAdd %int %14 %int_1 + %15 = OpBitcast %uint %14 + %16 = OpBitcast %uint %int_1 + %18 = OpIAdd %uint %15 %16 + %u = OpBitcast %int %18 OpReturn OpFunctionEnd
diff --git a/test/tint/ptr_ref/load/local/ptr_workgroup.wgsl.expected.glsl b/test/tint/ptr_ref/load/local/ptr_workgroup.wgsl.expected.glsl index 47ee968..337ee21 100644 --- a/test/tint/ptr_ref/load/local/ptr_workgroup.wgsl.expected.glsl +++ b/test/tint/ptr_ref/load/local/ptr_workgroup.wgsl.expected.glsl
@@ -7,7 +7,8 @@ } barrier(); i = 123; - int u = (i + 1); + uint v = uint(i); + int u = int((v + uint(1))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/ptr_ref/load/local/ptr_workgroup.wgsl.expected.spvasm b/test/tint/ptr_ref/load/local/ptr_workgroup.wgsl.expected.spvasm index 74a2de5..e8f51ea 100644 --- a/test/tint/ptr_ref/load/local/ptr_workgroup.wgsl.expected.spvasm +++ b/test/tint/ptr_ref/load/local/ptr_workgroup.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 30 +; Bound: 33 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -30,7 +30,7 @@ %int_123 = OpConstant %int 123 %int_1 = OpConstant %int 1 %int_0 = OpConstant %int 0 - %26 = OpTypeFunction %void + %29 = OpTypeFunction %void %main_inner = OpFunction %void None %10 %tint_local_index = OpFunctionParameter %uint %11 = OpLabel @@ -44,12 +44,15 @@ OpControlBarrier %uint_2 %uint_2 %uint_264 OpStore %i %int_123 None %21 = OpLoad %int %i None - %u = OpIAdd %int %21 %int_1 + %22 = OpBitcast %uint %21 + %23 = OpBitcast %uint %int_1 + %25 = OpIAdd %uint %22 %23 + %u = OpBitcast %int %25 OpReturn OpFunctionEnd - %main = OpFunction %void None %26 - %27 = OpLabel - %28 = OpLoad %uint %main_local_invocation_index_Input None - %29 = OpFunctionCall %void %main_inner %28 + %main = OpFunction %void None %29 + %30 = OpLabel + %31 = OpLoad %uint %main_local_invocation_index_Input None + %32 = OpFunctionCall %void %main_inner %31 OpReturn OpFunctionEnd
diff --git a/test/tint/ptr_ref/load/param/ptr.wgsl.expected.glsl b/test/tint/ptr_ref/load/param/ptr.wgsl.expected.glsl index f5dc821..811775a 100644 --- a/test/tint/ptr_ref/load/param/ptr.wgsl.expected.glsl +++ b/test/tint/ptr_ref/load/param/ptr.wgsl.expected.glsl
@@ -1,7 +1,9 @@ #version 310 es int func(int value, inout int pointer) { - return (value + pointer); + int v = pointer; + uint v_1 = uint(value); + return int((v_1 + uint(v))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/ptr_ref/load/param/ptr.wgsl.expected.spvasm b/test/tint/ptr_ref/load/param/ptr.wgsl.expected.spvasm index 4d68c3f..fc35e1f 100644 --- a/test/tint/ptr_ref/load/param/ptr.wgsl.expected.spvasm +++ b/test/tint/ptr_ref/load/param/ptr.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 18 +; Bound: 22 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -16,22 +16,26 @@ %int = OpTypeInt 32 1 %_ptr_Function_int = OpTypePointer Function %int %6 = OpTypeFunction %int %int %_ptr_Function_int + %uint = OpTypeInt 32 0 %void = OpTypeVoid - %12 = OpTypeFunction %void + %16 = OpTypeFunction %void %int_123 = OpConstant %int 123 %func = OpFunction %int None %6 %value = OpFunctionParameter %int %pointer_root = OpFunctionParameter %_ptr_Function_int %7 = OpLabel %8 = OpLoad %int %pointer_root None - %9 = OpIAdd %int %value %8 - OpReturnValue %9 + %10 = OpBitcast %uint %value + %11 = OpBitcast %uint %8 + %12 = OpIAdd %uint %10 %11 + %13 = OpBitcast %int %12 + OpReturnValue %13 OpFunctionEnd - %main = OpFunction %void None %12 - %13 = OpLabel + %main = OpFunction %void None %16 + %17 = OpLabel %i = OpVariable %_ptr_Function_int Function OpStore %i %int_123 - %16 = OpLoad %int %i None - %r = OpFunctionCall %int %func %16 %i + %20 = OpLoad %int %i None + %r = OpFunctionCall %int %func %20 %i OpReturn OpFunctionEnd
diff --git a/test/tint/ptr_sugar/compound_assign_index.wgsl.expected.glsl b/test/tint/ptr_sugar/compound_assign_index.wgsl.expected.glsl index b6d4cff..07e2935 100644 --- a/test/tint/ptr_sugar/compound_assign_index.wgsl.expected.glsl +++ b/test/tint/ptr_sugar/compound_assign_index.wgsl.expected.glsl
@@ -2,19 +2,23 @@ void deref() { ivec3 a = ivec3(0); - a.x = (a.x + 42); + uint v = uint(a.x); + a.x = int((v + uint(42))); } void no_deref() { ivec3 a = ivec3(0); - a.x = (a.x + 42); + uint v_1 = uint(a.x); + a.x = int((v_1 + uint(42))); } void deref_inc() { ivec3 a = ivec3(0); - a.x = (a.x + 1); + uint v_2 = uint(a.x); + a.x = int((v_2 + uint(1))); } void no_deref_inc() { ivec3 a = ivec3(0); - a.x = (a.x + 1); + uint v_3 = uint(a.x); + a.x = int((v_3 + uint(1))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/ptr_sugar/compound_assign_index.wgsl.expected.spvasm b/test/tint/ptr_sugar/compound_assign_index.wgsl.expected.spvasm index 1a48662..284a7c7 100644 --- a/test/tint/ptr_sugar/compound_assign_index.wgsl.expected.spvasm +++ b/test/tint/ptr_sugar/compound_assign_index.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 46 +; Bound: 58 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -36,46 +36,58 @@ %a = OpVariable %_ptr_Function_v3int Function %9 %10 = OpAccessChain %_ptr_Function_int %a %uint_0 %14 = OpLoad %int %10 None - %15 = OpIAdd %int %14 %int_42 - %17 = OpAccessChain %_ptr_Function_int %a %uint_0 - OpStore %17 %15 None + %15 = OpBitcast %uint %14 + %16 = OpBitcast %uint %int_42 + %18 = OpIAdd %uint %15 %16 + %19 = OpBitcast %int %18 + %20 = OpAccessChain %_ptr_Function_int %a %uint_0 + OpStore %20 %19 None OpReturn OpFunctionEnd %no_deref = OpFunction %void None %3 - %19 = OpLabel + %22 = OpLabel %a_0 = OpVariable %_ptr_Function_v3int Function %9 - %21 = OpAccessChain %_ptr_Function_int %a_0 %uint_0 - %22 = OpLoad %int %21 None - %23 = OpIAdd %int %22 %int_42 %24 = OpAccessChain %_ptr_Function_int %a_0 %uint_0 - OpStore %24 %23 None + %25 = OpLoad %int %24 None + %26 = OpBitcast %uint %25 + %27 = OpBitcast %uint %int_42 + %28 = OpIAdd %uint %26 %27 + %29 = OpBitcast %int %28 + %30 = OpAccessChain %_ptr_Function_int %a_0 %uint_0 + OpStore %30 %29 None OpReturn OpFunctionEnd %deref_inc = OpFunction %void None %3 - %26 = OpLabel + %32 = OpLabel %a_1 = OpVariable %_ptr_Function_v3int Function %9 - %28 = OpAccessChain %_ptr_Function_int %a_1 %uint_0 - %29 = OpLoad %int %28 None - %30 = OpIAdd %int %29 %int_1 - %32 = OpAccessChain %_ptr_Function_int %a_1 %uint_0 - OpStore %32 %30 None + %34 = OpAccessChain %_ptr_Function_int %a_1 %uint_0 + %35 = OpLoad %int %34 None + %36 = OpBitcast %uint %35 + %37 = OpBitcast %uint %int_1 + %39 = OpIAdd %uint %36 %37 + %40 = OpBitcast %int %39 + %41 = OpAccessChain %_ptr_Function_int %a_1 %uint_0 + OpStore %41 %40 None OpReturn OpFunctionEnd %no_deref_inc = OpFunction %void None %3 - %34 = OpLabel + %43 = OpLabel %a_2 = OpVariable %_ptr_Function_v3int Function %9 - %36 = OpAccessChain %_ptr_Function_int %a_2 %uint_0 - %37 = OpLoad %int %36 None - %38 = OpIAdd %int %37 %int_1 - %39 = OpAccessChain %_ptr_Function_int %a_2 %uint_0 - OpStore %39 %38 None + %45 = OpAccessChain %_ptr_Function_int %a_2 %uint_0 + %46 = OpLoad %int %45 None + %47 = OpBitcast %uint %46 + %48 = OpBitcast %uint %int_1 + %49 = OpIAdd %uint %47 %48 + %50 = OpBitcast %int %49 + %51 = OpAccessChain %_ptr_Function_int %a_2 %uint_0 + OpStore %51 %50 None OpReturn OpFunctionEnd %main = OpFunction %void None %3 - %41 = OpLabel - %42 = OpFunctionCall %void %deref - %43 = OpFunctionCall %void %no_deref - %44 = OpFunctionCall %void %deref_inc - %45 = OpFunctionCall %void %no_deref_inc + %53 = OpLabel + %54 = OpFunctionCall %void %deref + %55 = OpFunctionCall %void %no_deref + %56 = OpFunctionCall %void %deref_inc + %57 = OpFunctionCall %void %no_deref_inc OpReturn OpFunctionEnd
diff --git a/test/tint/ptr_sugar/compound_assign_member.wgsl.expected.glsl b/test/tint/ptr_sugar/compound_assign_member.wgsl.expected.glsl index b8f2865..bdd8751 100644 --- a/test/tint/ptr_sugar/compound_assign_member.wgsl.expected.glsl +++ b/test/tint/ptr_sugar/compound_assign_member.wgsl.expected.glsl
@@ -2,11 +2,13 @@ void deref() { ivec3 a = ivec3(0); - a.x = (a.x + 42); + uint v = uint(a.x); + a.x = int((v + uint(42))); } void no_deref() { ivec3 a = ivec3(0); - a.x = (a.x + 42); + uint v_1 = uint(a.x); + a.x = int((v_1 + uint(42))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/ptr_sugar/compound_assign_member.wgsl.expected.spvasm b/test/tint/ptr_sugar/compound_assign_member.wgsl.expected.spvasm index 0119c96..90effc4 100644 --- a/test/tint/ptr_sugar/compound_assign_member.wgsl.expected.spvasm +++ b/test/tint/ptr_sugar/compound_assign_member.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 29 +; Bound: 35 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -29,24 +29,30 @@ %a = OpVariable %_ptr_Function_v3int Function %9 %10 = OpAccessChain %_ptr_Function_int %a %uint_0 %14 = OpLoad %int %10 None - %15 = OpIAdd %int %14 %int_42 - %17 = OpAccessChain %_ptr_Function_int %a %uint_0 - OpStore %17 %15 None + %15 = OpBitcast %uint %14 + %16 = OpBitcast %uint %int_42 + %18 = OpIAdd %uint %15 %16 + %19 = OpBitcast %int %18 + %20 = OpAccessChain %_ptr_Function_int %a %uint_0 + OpStore %20 %19 None OpReturn OpFunctionEnd %no_deref = OpFunction %void None %3 - %19 = OpLabel + %22 = OpLabel %a_0 = OpVariable %_ptr_Function_v3int Function %9 - %21 = OpAccessChain %_ptr_Function_int %a_0 %uint_0 - %22 = OpLoad %int %21 None - %23 = OpIAdd %int %22 %int_42 %24 = OpAccessChain %_ptr_Function_int %a_0 %uint_0 - OpStore %24 %23 None + %25 = OpLoad %int %24 None + %26 = OpBitcast %uint %25 + %27 = OpBitcast %uint %int_42 + %28 = OpIAdd %uint %26 %27 + %29 = OpBitcast %int %28 + %30 = OpAccessChain %_ptr_Function_int %a_0 %uint_0 + OpStore %30 %29 None OpReturn OpFunctionEnd %main = OpFunction %void None %3 - %26 = OpLabel - %27 = OpFunctionCall %void %deref - %28 = OpFunctionCall %void %no_deref + %32 = OpLabel + %33 = OpFunctionCall %void %deref + %34 = OpFunctionCall %void %no_deref OpReturn OpFunctionEnd
diff --git a/test/tint/samples/compute_boids.wgsl.expected.glsl b/test/tint/samples/compute_boids.wgsl.expected.glsl index 4d9b07d..8c2cc88 100644 --- a/test/tint/samples/compute_boids.wgsl.expected.glsl +++ b/test/tint/samples/compute_boids.wgsl.expected.glsl
@@ -102,14 +102,16 @@ vel = v_1.inner.particles[v_7].vel.xy; if ((distance(pos, vPos) < v.inner.rule1Distance)) { cMass = (cMass + pos); - cMassCount = (cMassCount + 1); + uint v_8 = uint(cMassCount); + cMassCount = int((v_8 + uint(1))); } if ((distance(pos, vPos) < v.inner.rule2Distance)) { colVel = (colVel - (pos - vPos)); } if ((distance(pos, vPos) < v.inner.rule3Distance)) { cVel = (cVel + vel); - cVelCount = (cVelCount + 1); + uint v_9 = uint(cVelCount); + cVelCount = int((v_9 + uint(1))); } { i = (i + 1u); @@ -118,15 +120,15 @@ } } if ((cMassCount > 0)) { - vec2 v_8 = cMass; - float v_9 = float(cMassCount); - vec2 v_10 = (v_8 / vec2(v_9, float(cMassCount))); - cMass = (v_10 - vPos); + vec2 v_10 = cMass; + float v_11 = float(cMassCount); + vec2 v_12 = (v_10 / vec2(v_11, float(cMassCount))); + cMass = (v_12 - vPos); } if ((cVelCount > 0)) { - vec2 v_11 = cVel; - float v_12 = float(cVelCount); - cVel = (v_11 / vec2(v_12, float(cVelCount))); + vec2 v_13 = cVel; + float v_14 = float(cVelCount); + cVel = (v_13 / vec2(v_14, float(cVelCount))); } vVel = (((vVel + (cMass * v.inner.rule1Scale)) + (colVel * v.inner.rule2Scale)) + (cVel * v.inner.rule3Scale)); vVel = (normalize(vVel) * clamp(length(vVel), 0.0f, 0.10000000149011611938f)); @@ -143,10 +145,10 @@ if ((vPos.y > 1.0f)) { vPos.y = -1.0f; } - uint v_13 = min(index, 4u); - v_2.inner.particles[v_13].pos = vPos; - uint v_14 = min(index, 4u); - v_2.inner.particles[v_14].vel = vVel; + uint v_15 = min(index, 4u); + v_2.inner.particles[v_15].pos = vPos; + uint v_16 = min(index, 4u); + v_2.inner.particles[v_16].vel = vVel; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/samples/compute_boids.wgsl.expected.spvasm b/test/tint/samples/compute_boids.wgsl.expected.spvasm index dbea510..ec040e6 100644 --- a/test/tint/samples/compute_boids.wgsl.expected.spvasm +++ b/test/tint/samples/compute_boids.wgsl.expected.spvasm
@@ -133,7 +133,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 226 +; Bound: 232 ; Schema: 0 OpCapability Shader %36 = OpExtInstImport "GLSL.std.450" @@ -244,7 +244,7 @@ %uint_2 = OpConstant %uint 2 %uint_3 = OpConstant %uint 3 %int_1 = OpConstant %int 1 - %222 = OpTypeFunction %void + %228 = OpTypeFunction %void %comp_main_inner = OpFunction %void None %24 %gl_GlobalInvocationID = OpFunctionParameter %v3uint %25 = OpLabel @@ -332,8 +332,11 @@ %207 = OpFAdd %v2float %205 %206 OpStore %cMass %207 None %208 = OpLoad %int %cMassCount None - %209 = OpIAdd %int %208 %int_1 - OpStore %cMassCount %209 None + %209 = OpBitcast %uint %208 + %210 = OpBitcast %uint %int_1 + %212 = OpIAdd %uint %209 %210 + %213 = OpBitcast %int %212 + OpStore %cMassCount %213 None OpBranch %163 %163 = OpLabel %165 = OpLoad %v2float %pos None @@ -345,12 +348,12 @@ OpSelectionMerge %172 None OpBranchConditional %171 %173 %172 %173 = OpLabel - %211 = OpLoad %v2float %colVel None - %212 = OpLoad %v2float %pos None - %213 = OpLoad %v2float %vPos None - %214 = OpFSub %v2float %212 %213 - %215 = OpFSub %v2float %211 %214 - OpStore %colVel %215 None + %214 = OpLoad %v2float %colVel None + %215 = OpLoad %v2float %pos None + %216 = OpLoad %v2float %vPos None + %217 = OpFSub %v2float %215 %216 + %218 = OpFSub %v2float %214 %217 + OpStore %colVel %218 None OpBranch %172 %172 = OpLabel %174 = OpLoad %v2float %pos None @@ -362,13 +365,16 @@ OpSelectionMerge %181 None OpBranchConditional %180 %182 %181 %182 = OpLabel - %216 = OpLoad %v2float %cVel None - %217 = OpLoad %v2float %vel None - %218 = OpFAdd %v2float %216 %217 - OpStore %cVel %218 None - %219 = OpLoad %int %cVelCount None - %220 = OpIAdd %int %219 %int_1 - OpStore %cVelCount %220 None + %219 = OpLoad %v2float %cVel None + %220 = OpLoad %v2float %vel None + %221 = OpFAdd %v2float %219 %220 + OpStore %cVel %221 None + %222 = OpLoad %int %cVelCount None + %223 = OpBitcast %uint %222 + %224 = OpBitcast %uint %int_1 + %225 = OpIAdd %uint %223 %224 + %226 = OpBitcast %int %225 + OpStore %cVelCount %226 None OpBranch %181 %181 = OpLabel OpBranch %63 @@ -493,9 +499,9 @@ OpStore %135 %136 None OpReturn OpFunctionEnd - %comp_main = OpFunction %void None %222 - %223 = OpLabel - %224 = OpLoad %v3uint %comp_main_global_invocation_id_Input None - %225 = OpFunctionCall %void %comp_main_inner %224 + %comp_main = OpFunction %void None %228 + %229 = OpLabel + %230 = OpLoad %v3uint %comp_main_global_invocation_id_Input None + %231 = OpFunctionCall %void %comp_main_inner %230 OpReturn OpFunctionEnd
diff --git a/test/tint/samples/compute_boids_arg_buffer.wgsl.expected.glsl b/test/tint/samples/compute_boids_arg_buffer.wgsl.expected.glsl index 2381b4e..4ff3720 100644 --- a/test/tint/samples/compute_boids_arg_buffer.wgsl.expected.glsl +++ b/test/tint/samples/compute_boids_arg_buffer.wgsl.expected.glsl
@@ -67,14 +67,16 @@ vel = v_1.inner.particles[v_7].vel.xy; if ((distance(pos, vPos) < v.inner.rule1Distance)) { cMass = (cMass + pos); - cMassCount = (cMassCount + 1); + uint v_8 = uint(cMassCount); + cMassCount = int((v_8 + uint(1))); } if ((distance(pos, vPos) < v.inner.rule2Distance)) { colVel = (colVel - (pos - vPos)); } if ((distance(pos, vPos) < v.inner.rule3Distance)) { cVel = (cVel + vel); - cVelCount = (cVelCount + 1); + uint v_9 = uint(cVelCount); + cVelCount = int((v_9 + uint(1))); } { i = (i + 1u); @@ -83,15 +85,15 @@ } } if ((cMassCount > 0)) { - vec2 v_8 = cMass; - float v_9 = float(cMassCount); - vec2 v_10 = (v_8 / vec2(v_9, float(cMassCount))); - cMass = (v_10 - vPos); + vec2 v_10 = cMass; + float v_11 = float(cMassCount); + vec2 v_12 = (v_10 / vec2(v_11, float(cMassCount))); + cMass = (v_12 - vPos); } if ((cVelCount > 0)) { - vec2 v_11 = cVel; - float v_12 = float(cVelCount); - cVel = (v_11 / vec2(v_12, float(cVelCount))); + vec2 v_13 = cVel; + float v_14 = float(cVelCount); + cVel = (v_13 / vec2(v_14, float(cVelCount))); } vVel = (((vVel + (cMass * v.inner.rule1Scale)) + (colVel * v.inner.rule2Scale)) + (cVel * v.inner.rule3Scale)); vVel = (normalize(vVel) * clamp(length(vVel), 0.0f, 0.10000000149011611938f)); @@ -108,10 +110,10 @@ if ((vPos.y > 1.0f)) { vPos.y = -1.0f; } - uint v_13 = min(index, 4u); - v_2.inner.particles[v_13].pos = vPos; - uint v_14 = min(index, 4u); - v_2.inner.particles[v_14].vel = vVel; + uint v_15 = min(index, 4u); + v_2.inner.particles[v_15].pos = vPos; + uint v_16 = min(index, 4u); + v_2.inner.particles[v_16].vel = vVel; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/samples/compute_boids_arg_buffer.wgsl.expected.spvasm b/test/tint/samples/compute_boids_arg_buffer.wgsl.expected.spvasm index 4698914..70109d5 100644 --- a/test/tint/samples/compute_boids_arg_buffer.wgsl.expected.spvasm +++ b/test/tint/samples/compute_boids_arg_buffer.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 226 +; Bound: 232 ; Schema: 0 OpCapability Shader %36 = OpExtInstImport "GLSL.std.450" @@ -112,7 +112,7 @@ %uint_2 = OpConstant %uint 2 %uint_3 = OpConstant %uint 3 %int_1 = OpConstant %int 1 - %222 = OpTypeFunction %void + %228 = OpTypeFunction %void %comp_main_inner = OpFunction %void None %24 %gl_GlobalInvocationID = OpFunctionParameter %v3uint %25 = OpLabel @@ -200,8 +200,11 @@ %207 = OpFAdd %v2float %205 %206 OpStore %cMass %207 None %208 = OpLoad %int %cMassCount None - %209 = OpIAdd %int %208 %int_1 - OpStore %cMassCount %209 None + %209 = OpBitcast %uint %208 + %210 = OpBitcast %uint %int_1 + %212 = OpIAdd %uint %209 %210 + %213 = OpBitcast %int %212 + OpStore %cMassCount %213 None OpBranch %163 %163 = OpLabel %165 = OpLoad %v2float %pos None @@ -213,12 +216,12 @@ OpSelectionMerge %172 None OpBranchConditional %171 %173 %172 %173 = OpLabel - %211 = OpLoad %v2float %colVel None - %212 = OpLoad %v2float %pos None - %213 = OpLoad %v2float %vPos None - %214 = OpFSub %v2float %212 %213 - %215 = OpFSub %v2float %211 %214 - OpStore %colVel %215 None + %214 = OpLoad %v2float %colVel None + %215 = OpLoad %v2float %pos None + %216 = OpLoad %v2float %vPos None + %217 = OpFSub %v2float %215 %216 + %218 = OpFSub %v2float %214 %217 + OpStore %colVel %218 None OpBranch %172 %172 = OpLabel %174 = OpLoad %v2float %pos None @@ -230,13 +233,16 @@ OpSelectionMerge %181 None OpBranchConditional %180 %182 %181 %182 = OpLabel - %216 = OpLoad %v2float %cVel None - %217 = OpLoad %v2float %vel None - %218 = OpFAdd %v2float %216 %217 - OpStore %cVel %218 None - %219 = OpLoad %int %cVelCount None - %220 = OpIAdd %int %219 %int_1 - OpStore %cVelCount %220 None + %219 = OpLoad %v2float %cVel None + %220 = OpLoad %v2float %vel None + %221 = OpFAdd %v2float %219 %220 + OpStore %cVel %221 None + %222 = OpLoad %int %cVelCount None + %223 = OpBitcast %uint %222 + %224 = OpBitcast %uint %int_1 + %225 = OpIAdd %uint %223 %224 + %226 = OpBitcast %int %225 + OpStore %cVelCount %226 None OpBranch %181 %181 = OpLabel OpBranch %63 @@ -361,9 +367,9 @@ OpStore %135 %136 None OpReturn OpFunctionEnd - %comp_main = OpFunction %void None %222 - %223 = OpLabel - %224 = OpLoad %v3uint %comp_main_global_invocation_id_Input None - %225 = OpFunctionCall %void %comp_main_inner %224 + %comp_main = OpFunction %void None %228 + %229 = OpLabel + %230 = OpLoad %v3uint %comp_main_global_invocation_id_Input None + %231 = OpFunctionCall %void %comp_main_inner %230 OpReturn OpFunctionEnd
diff --git a/test/tint/shadowing/loop.wgsl.expected.glsl b/test/tint/shadowing/loop.wgsl.expected.glsl index 6cb8f46..156fcdd 100644 --- a/test/tint/shadowing/loop.wgsl.expected.glsl +++ b/test/tint/shadowing/loop.wgsl.expected.glsl
@@ -22,7 +22,9 @@ tint_loop_idx.y = (tint_loop_idx.y - tint_carry); uint v_2 = min(uint(x), 9u); int x_1 = v.inner[v_2]; - i = (i + x_1); + int v_3 = x_1; + uint v_4 = uint(i); + i = int((v_4 + uint(v_3))); if ((i > 10)) { break; } } continue;
diff --git a/test/tint/shadowing/loop.wgsl.expected.spvasm b/test/tint/shadowing/loop.wgsl.expected.spvasm index 9227000..bbc659a 100644 --- a/test/tint/shadowing/loop.wgsl.expected.spvasm +++ b/test/tint/shadowing/loop.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 69 +; Bound: 72 ; Schema: 0 OpCapability Shader %40 = OpExtInstImport "GLSL.std.450" @@ -98,11 +98,14 @@ OpStore %x_0 %61 %63 = OpLoad %int %x_0 None %64 = OpLoad %int %i None - %65 = OpIAdd %int %64 %63 - OpStore %i %65 None - %66 = OpLoad %int %i None - %67 = OpSGreaterThan %bool %66 %int_10 - OpBranchConditional %67 %19 %18 + %65 = OpBitcast %uint %64 + %66 = OpBitcast %uint %63 + %67 = OpIAdd %uint %65 %66 + %68 = OpBitcast %int %67 + OpStore %i %68 None + %69 = OpLoad %int %i None + %70 = OpSGreaterThan %bool %69 %int_10 + OpBranchConditional %70 %19 %18 %19 = OpLabel %20 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 %uint_0 %23 = OpLoad %int %i None
diff --git a/test/tint/statements/assign/indexed_assign_to_array_in_struct/in_for_loop_body.wgsl.expected.glsl b/test/tint/statements/assign/indexed_assign_to_array_in_struct/in_for_loop_body.wgsl.expected.glsl index c3ae2f0..82dc51e 100644 --- a/test/tint/statements/assign/indexed_assign_to_array_in_struct/in_for_loop_body.wgsl.expected.glsl +++ b/test/tint/statements/assign/indexed_assign_to_array_in_struct/in_for_loop_body.wgsl.expected.glsl
@@ -31,7 +31,8 @@ uint v_2 = min(v_1.inner.i, 7u); s1.a1[v_2] = v; { - i = (i + 1); + uint v_3 = uint(i); + i = int((v_3 + uint(1))); } continue; }
diff --git a/test/tint/statements/assign/indexed_assign_to_array_in_struct/in_for_loop_body.wgsl.expected.spvasm b/test/tint/statements/assign/indexed_assign_to_array_in_struct/in_for_loop_body.wgsl.expected.spvasm index b6c00d5..d29ea96 100644 --- a/test/tint/statements/assign/indexed_assign_to_array_in_struct/in_for_loop_body.wgsl.expected.spvasm +++ b/test/tint/statements/assign/indexed_assign_to_array_in_struct/in_for_loop_body.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 47 +; Bound: 50 ; Schema: 0 OpCapability Shader %40 = OpExtInstImport "GLSL.std.450" @@ -79,8 +79,11 @@ OpBranch %23 %23 = OpLabel %44 = OpLoad %int %i None - %45 = OpIAdd %int %44 %int_1 - OpStore %i %45 None + %45 = OpBitcast %uint %44 + %46 = OpBitcast %uint %int_1 + %48 = OpIAdd %uint %45 %46 + %49 = OpBitcast %int %48 + OpStore %i %49 None OpBranch %24 %25 = OpLabel OpReturn
diff --git a/test/tint/statements/assign/indexed_assign_to_array_in_struct/in_for_loop_continuing.wgsl.expected.glsl b/test/tint/statements/assign/indexed_assign_to_array_in_struct/in_for_loop_continuing.wgsl.expected.glsl index cd16bc6..f6b909e 100644 --- a/test/tint/statements/assign/indexed_assign_to_array_in_struct/in_for_loop_continuing.wgsl.expected.glsl +++ b/test/tint/statements/assign/indexed_assign_to_array_in_struct/in_for_loop_continuing.wgsl.expected.glsl
@@ -32,14 +32,15 @@ } else { break; } - i = (i + 1); + uint v_2 = uint(i); + i = int((v_2 + uint(1))); { uint tint_low_inc = (tint_loop_idx.x - 1u); tint_loop_idx.x = tint_low_inc; uint tint_carry = uint((tint_low_inc == 4294967295u)); tint_loop_idx.y = (tint_loop_idx.y - tint_carry); - uint v_2 = min(v_1.inner.i, 7u); - s1.a1[v_2] = v; + uint v_3 = min(v_1.inner.i, 7u); + s1.a1[v_3] = v; } continue; }
diff --git a/test/tint/statements/assign/indexed_assign_to_array_in_struct/in_for_loop_continuing.wgsl.expected.spvasm b/test/tint/statements/assign/indexed_assign_to_array_in_struct/in_for_loop_continuing.wgsl.expected.spvasm index 743f225..92264bb 100644 --- a/test/tint/statements/assign/indexed_assign_to_array_in_struct/in_for_loop_continuing.wgsl.expected.spvasm +++ b/test/tint/statements/assign/indexed_assign_to_array_in_struct/in_for_loop_continuing.wgsl.expected.spvasm
@@ -1,10 +1,10 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 71 +; Bound: 74 ; Schema: 0 OpCapability Shader - %67 = OpExtInstImport "GLSL.std.450" + %70 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %main "main" OpExecutionMode %main LocalSize 1 1 1 @@ -92,28 +92,31 @@ OpBranch %25 %45 = OpLabel %47 = OpLoad %int %i None - %48 = OpIAdd %int %47 %int_1 - OpStore %i %48 None + %48 = OpBitcast %uint %47 + %49 = OpBitcast %uint %int_1 + %51 = OpIAdd %uint %48 %49 + %52 = OpBitcast %int %51 + OpStore %i %52 None OpBranch %23 %23 = OpLabel - %50 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 - %53 = OpLoad %uint %50 None -%tint_low_inc = OpISub %uint %53 %uint_1 - %56 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 - OpStore %56 %tint_low_inc None - %57 = OpIEqual %bool %tint_low_inc %uint_4294967295 - %tint_carry = OpSelect %uint %57 %uint_1 %uint_0 - %59 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 - %60 = OpLoad %uint %59 None - %61 = OpISub %uint %60 %tint_carry + %53 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 + %56 = OpLoad %uint %53 None +%tint_low_inc = OpISub %uint %56 %uint_1 + %59 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 + OpStore %59 %tint_low_inc None + %60 = OpIEqual %bool %tint_low_inc %uint_4294967295 + %tint_carry = OpSelect %uint %60 %uint_1 %uint_0 %62 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 - OpStore %62 %61 None - %63 = OpAccessChain %_ptr_Uniform_uint %1 %uint_0 %uint_0 - %65 = OpLoad %uint %63 None - %66 = OpExtInst %uint %67 UMin %65 %uint_7 - %69 = OpAccessChain %_ptr_Function_InnerS %s1 %uint_0 %66 - %70 = OpLoad %InnerS %v None - OpStore %69 %70 None + %63 = OpLoad %uint %62 None + %64 = OpISub %uint %63 %tint_carry + %65 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 + OpStore %65 %64 None + %66 = OpAccessChain %_ptr_Uniform_uint %1 %uint_0 %uint_0 + %68 = OpLoad %uint %66 None + %69 = OpExtInst %uint %70 UMin %68 %uint_7 + %72 = OpAccessChain %_ptr_Function_InnerS %s1 %uint_0 %69 + %73 = OpLoad %InnerS %v None + OpStore %72 %73 None OpBranch %24 %25 = OpLabel OpReturn
diff --git a/test/tint/statements/assign/indexed_assign_to_array_in_struct/in_for_loop_init.wgsl.expected.glsl b/test/tint/statements/assign/indexed_assign_to_array_in_struct/in_for_loop_init.wgsl.expected.glsl index 5f49b88..5e9143b 100644 --- a/test/tint/statements/assign/indexed_assign_to_array_in_struct/in_for_loop_init.wgsl.expected.glsl +++ b/test/tint/statements/assign/indexed_assign_to_array_in_struct/in_for_loop_init.wgsl.expected.glsl
@@ -39,7 +39,8 @@ tint_loop_idx.x = tint_low_inc; uint tint_carry = uint((tint_low_inc == 4294967295u)); tint_loop_idx.y = (tint_loop_idx.y - tint_carry); - i = (i + 1); + uint v_3 = uint(i); + i = int((v_3 + uint(1))); } continue; }
diff --git a/test/tint/statements/assign/indexed_assign_to_array_in_struct/in_for_loop_init.wgsl.expected.spvasm b/test/tint/statements/assign/indexed_assign_to_array_in_struct/in_for_loop_init.wgsl.expected.spvasm index 4710a86..3adc248 100644 --- a/test/tint/statements/assign/indexed_assign_to_array_in_struct/in_for_loop_init.wgsl.expected.spvasm +++ b/test/tint/statements/assign/indexed_assign_to_array_in_struct/in_for_loop_init.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 71 +; Bound: 74 ; Schema: 0 OpCapability Shader %39 = OpExtInstImport "GLSL.std.450" @@ -112,8 +112,11 @@ %67 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 OpStore %67 %66 None %68 = OpLoad %int %i None - %69 = OpIAdd %int %68 %int_1 - OpStore %i %69 None + %69 = OpBitcast %uint %68 + %70 = OpBitcast %uint %int_1 + %72 = OpIAdd %uint %69 %70 + %73 = OpBitcast %int %72 + OpStore %i %73 None OpBranch %27 %28 = OpLabel OpReturn
diff --git a/test/tint/statements/assign/phony/call.wgsl.expected.glsl b/test/tint/statements/assign/phony/call.wgsl.expected.glsl index 20f7498..88c40bc 100644 --- a/test/tint/statements/assign/phony/call.wgsl.expected.glsl +++ b/test/tint/statements/assign/phony/call.wgsl.expected.glsl
@@ -1,7 +1,9 @@ #version 310 es int f(int a, int b, int c) { - return ((a * b) + c); + uint v = uint(a); + uint v_1 = uint(int((v * uint(b)))); + return int((v_1 + uint(c))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/statements/assign/phony/call.wgsl.expected.spvasm b/test/tint/statements/assign/phony/call.wgsl.expected.spvasm index 37c3756..19a52e8 100644 --- a/test/tint/statements/assign/phony/call.wgsl.expected.spvasm +++ b/test/tint/statements/assign/phony/call.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 18 +; Bound: 25 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -14,8 +14,9 @@ OpName %main "main" %int = OpTypeInt 32 1 %6 = OpTypeFunction %int %int %int %int + %uint = OpTypeInt 32 0 %void = OpTypeVoid - %12 = OpTypeFunction %void + %19 = OpTypeFunction %void %int_1 = OpConstant %int 1 %int_2 = OpConstant %int 2 %int_3 = OpConstant %int 3 @@ -24,12 +25,18 @@ %b = OpFunctionParameter %int %c = OpFunctionParameter %int %7 = OpLabel - %8 = OpIMul %int %a %b - %9 = OpIAdd %int %8 %c - OpReturnValue %9 + %9 = OpBitcast %uint %a + %10 = OpBitcast %uint %b + %11 = OpIMul %uint %9 %10 + %12 = OpBitcast %int %11 + %13 = OpBitcast %uint %12 + %14 = OpBitcast %uint %c + %15 = OpIAdd %uint %13 %14 + %16 = OpBitcast %int %15 + OpReturnValue %16 OpFunctionEnd - %main = OpFunction %void None %12 - %13 = OpLabel - %14 = OpFunctionCall %int %f %int_1 %int_2 %int_3 + %main = OpFunction %void None %19 + %20 = OpLabel + %21 = OpFunctionCall %int %f %int_1 %int_2 %int_3 OpReturn OpFunctionEnd
diff --git a/test/tint/statements/assign/phony/multiple_side_effects.wgsl.expected.glsl b/test/tint/statements/assign/phony/multiple_side_effects.wgsl.expected.glsl index 0a272b1..2ff11b5 100644 --- a/test/tint/statements/assign/phony/multiple_side_effects.wgsl.expected.glsl +++ b/test/tint/statements/assign/phony/multiple_side_effects.wgsl.expected.glsl
@@ -1,11 +1,17 @@ #version 310 es int f(int a, int b, int c) { - return ((a * b) + c); + uint v = uint(a); + uint v_1 = uint(int((v * uint(b)))); + return int((v_1 + uint(c))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - int v = f(1, 2, 3); - int v_1 = f(4, 5, 6); - int v_2 = (v + (v_1 * f(7, f(8, 9, 10), 11))); + int v_2 = f(1, 2, 3); + int v_3 = f(4, 5, 6); + int v_4 = f(7, f(8, 9, 10), 11); + uint v_5 = uint(v_3); + int v_6 = int((v_5 * uint(v_4))); + uint v_7 = uint(v_2); + int v_8 = int((v_7 + uint(v_6))); }
diff --git a/test/tint/statements/assign/phony/multiple_side_effects.wgsl.expected.spvasm b/test/tint/statements/assign/phony/multiple_side_effects.wgsl.expected.spvasm index 6d8eb9e..3dd6f69 100644 --- a/test/tint/statements/assign/phony/multiple_side_effects.wgsl.expected.spvasm +++ b/test/tint/statements/assign/phony/multiple_side_effects.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 31 +; Bound: 44 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -14,8 +14,9 @@ OpName %main "main" %int = OpTypeInt 32 1 %6 = OpTypeFunction %int %int %int %int + %uint = OpTypeInt 32 0 %void = OpTypeVoid - %12 = OpTypeFunction %void + %19 = OpTypeFunction %void %int_1 = OpConstant %int 1 %int_2 = OpConstant %int 2 %int_3 = OpConstant %int 3 @@ -32,17 +33,29 @@ %b = OpFunctionParameter %int %c = OpFunctionParameter %int %7 = OpLabel - %8 = OpIMul %int %a %b - %9 = OpIAdd %int %8 %c - OpReturnValue %9 + %9 = OpBitcast %uint %a + %10 = OpBitcast %uint %b + %11 = OpIMul %uint %9 %10 + %12 = OpBitcast %int %11 + %13 = OpBitcast %uint %12 + %14 = OpBitcast %uint %c + %15 = OpIAdd %uint %13 %14 + %16 = OpBitcast %int %15 + OpReturnValue %16 OpFunctionEnd - %main = OpFunction %void None %12 - %13 = OpLabel - %14 = OpFunctionCall %int %f %int_1 %int_2 %int_3 - %18 = OpFunctionCall %int %f %int_4 %int_5 %int_6 - %22 = OpFunctionCall %int %f %int_8 %int_9 %int_10 - %26 = OpFunctionCall %int %f %int_7 %22 %int_11 - %29 = OpIMul %int %18 %26 - %30 = OpIAdd %int %14 %29 + %main = OpFunction %void None %19 + %20 = OpLabel + %21 = OpFunctionCall %int %f %int_1 %int_2 %int_3 + %25 = OpFunctionCall %int %f %int_4 %int_5 %int_6 + %29 = OpFunctionCall %int %f %int_8 %int_9 %int_10 + %33 = OpFunctionCall %int %f %int_7 %29 %int_11 + %36 = OpBitcast %uint %25 + %37 = OpBitcast %uint %33 + %38 = OpIMul %uint %36 %37 + %39 = OpBitcast %int %38 + %40 = OpBitcast %uint %21 + %41 = OpBitcast %uint %39 + %42 = OpIAdd %uint %40 %41 + %43 = OpBitcast %int %42 OpReturn OpFunctionEnd
diff --git a/test/tint/statements/compound_assign/complex_lhs.wgsl.expected.glsl b/test/tint/statements/compound_assign/complex_lhs.wgsl.expected.glsl index 7a6a72a..93c1a89 100644 --- a/test/tint/statements/compound_assign/complex_lhs.wgsl.expected.glsl +++ b/test/tint/statements/compound_assign/complex_lhs.wgsl.expected.glsl
@@ -7,19 +7,22 @@ int counter = 0; int foo() { - counter = (counter + 1); + uint v = uint(counter); + counter = int((v + uint(1))); return counter; } int bar() { - counter = (counter + 2); + uint v_1 = uint(counter); + counter = int((v_1 + uint(2))); return counter; } -void v() { +void v_2() { S x = S(ivec4[4](ivec4(0), ivec4(0), ivec4(0), ivec4(0))); - uint v_1 = min(uint(foo()), 3u); - int v_2 = bar(); - int v_3 = (x.a[v_1][min(uint(v_2), 3u)] + 5); - x.a[v_1][min(uint(v_2), 3u)] = v_3; + uint v_3 = min(uint(foo()), 3u); + int v_4 = bar(); + uint v_5 = uint(x.a[v_3][min(uint(v_4), 3u)]); + int v_6 = int((v_5 + uint(5))); + x.a[v_3][min(uint(v_4), 3u)] = v_6; } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/statements/compound_assign/complex_lhs.wgsl.expected.spvasm b/test/tint/statements/compound_assign/complex_lhs.wgsl.expected.spvasm index aaf23a2..fffba7b 100644 --- a/test/tint/statements/compound_assign/complex_lhs.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/complex_lhs.wgsl.expected.spvasm
@@ -1,10 +1,10 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 51 +; Bound: 60 ; Schema: 0 OpCapability Shader - %33 = OpExtInstImport "GLSL.std.450" + %39 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %unused_entry_point "unused_entry_point" OpExecutionMode %unused_entry_point LocalSize 1 1 1 @@ -22,17 +22,17 @@ %4 = OpConstantNull %int %counter = OpVariable %_ptr_Private_int Private %4 %6 = OpTypeFunction %int + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %int_2 = OpConstant %int 2 %void = OpTypeVoid - %20 = OpTypeFunction %void + %27 = OpTypeFunction %void %v4int = OpTypeVector %int 4 - %uint = OpTypeInt 32 0 %uint_4 = OpConstant %uint 4 %_arr_v4int_uint_4 = OpTypeArray %v4int %uint_4 %S = OpTypeStruct %_arr_v4int_uint_4 %_ptr_Function_S = OpTypePointer Function %S - %29 = OpConstantNull %S + %35 = OpConstantNull %S %uint_3 = OpConstant %uint 3 %_ptr_Function_v4int = OpTypePointer Function %v4int %uint_0 = OpConstant %uint 0 @@ -41,40 +41,49 @@ %foo = OpFunction %int None %6 %7 = OpLabel %8 = OpLoad %int %counter None - %9 = OpIAdd %int %8 %int_1 - OpStore %counter %9 None - %11 = OpLoad %int %counter None - OpReturnValue %11 + %10 = OpBitcast %uint %8 + %11 = OpBitcast %uint %int_1 + %13 = OpIAdd %uint %10 %11 + %14 = OpBitcast %int %13 + OpStore %counter %14 None + %15 = OpLoad %int %counter None + OpReturnValue %15 OpFunctionEnd %bar = OpFunction %int None %6 - %13 = OpLabel - %14 = OpLoad %int %counter None - %15 = OpIAdd %int %14 %int_2 - OpStore %counter %15 None - %17 = OpLoad %int %counter None - OpReturnValue %17 + %17 = OpLabel + %18 = OpLoad %int %counter None + %19 = OpBitcast %uint %18 + %20 = OpBitcast %uint %int_2 + %22 = OpIAdd %uint %19 %20 + %23 = OpBitcast %int %22 + OpStore %counter %23 None + %24 = OpLoad %int %counter None + OpReturnValue %24 OpFunctionEnd - %main = OpFunction %void None %20 - %21 = OpLabel + %main = OpFunction %void None %27 + %28 = OpLabel %x = OpVariable %_ptr_Function_S Function - OpStore %x %29 - %30 = OpFunctionCall %int %foo - %31 = OpBitcast %uint %30 - %32 = OpExtInst %uint %33 UMin %31 %uint_3 - %35 = OpAccessChain %_ptr_Function_v4int %x %uint_0 %32 - %38 = OpFunctionCall %int %bar - %39 = OpBitcast %uint %38 - %40 = OpExtInst %uint %33 UMin %39 %uint_3 - %41 = OpAccessChain %_ptr_Function_int %35 %40 - %43 = OpLoad %int %41 None - %44 = OpIAdd %int %43 %int_5 - %46 = OpBitcast %uint %38 - %47 = OpExtInst %uint %33 UMin %46 %uint_3 - %48 = OpAccessChain %_ptr_Function_int %35 %47 - OpStore %48 %44 None + OpStore %x %35 + %36 = OpFunctionCall %int %foo + %37 = OpBitcast %uint %36 + %38 = OpExtInst %uint %39 UMin %37 %uint_3 + %41 = OpAccessChain %_ptr_Function_v4int %x %uint_0 %38 + %44 = OpFunctionCall %int %bar + %45 = OpBitcast %uint %44 + %46 = OpExtInst %uint %39 UMin %45 %uint_3 + %47 = OpAccessChain %_ptr_Function_int %41 %46 + %49 = OpLoad %int %47 None + %50 = OpBitcast %uint %49 + %51 = OpBitcast %uint %int_5 + %53 = OpIAdd %uint %50 %51 + %54 = OpBitcast %int %53 + %55 = OpBitcast %uint %44 + %56 = OpExtInst %uint %39 UMin %55 %uint_3 + %57 = OpAccessChain %_ptr_Function_int %41 %56 + OpStore %57 %54 None OpReturn OpFunctionEnd -%unused_entry_point = OpFunction %void None %20 - %50 = OpLabel +%unused_entry_point = OpFunction %void None %27 + %59 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/statements/compound_assign/divide_by_zero.wgsl.expected.glsl b/test/tint/statements/compound_assign/divide_by_zero.wgsl.expected.glsl index 8a2d327..8df1c9e 100644 --- a/test/tint/statements/compound_assign/divide_by_zero.wgsl.expected.glsl +++ b/test/tint/statements/compound_assign/divide_by_zero.wgsl.expected.glsl
@@ -10,23 +10,26 @@ bool v_1 = bool((v & uint((rhs == -1)))); uint v_2 = uint((rhs == 0)); int v_3 = mix(rhs, 1, bool((v_2 | uint(v_1)))); - return (lhs - ((lhs / v_3) * v_3)); + uint v_4 = uint((lhs / v_3)); + int v_5 = int((v_4 * uint(v_3))); + uint v_6 = uint(lhs); + return int((v_6 - uint(v_5))); } int tint_div_i32(int lhs, int rhs) { - uint v_4 = uint((lhs == (-2147483647 - 1))); - bool v_5 = bool((v_4 & uint((rhs == -1)))); - uint v_6 = uint((rhs == 0)); - return (lhs / mix(rhs, 1, bool((v_6 | uint(v_5))))); + uint v_7 = uint((lhs == (-2147483647 - 1))); + bool v_8 = bool((v_7 & uint((rhs == -1)))); + uint v_9 = uint((rhs == 0)); + return (lhs / mix(rhs, 1, bool((v_9 | uint(v_8))))); } void foo(int maybe_zero) { a = tint_div_i32(a, maybe_zero); a = tint_mod_i32(a, maybe_zero); b = (b / 0.0f); b = tint_float_modulo(b, 0.0f); - float v_7 = float(maybe_zero); - b = (b / v_7); - float v_8 = float(maybe_zero); - b = tint_float_modulo(b, v_8); + float v_10 = float(maybe_zero); + b = (b / v_10); + float v_11 = float(maybe_zero); + b = tint_float_modulo(b, v_11); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/statements/compound_assign/divide_by_zero.wgsl.expected.spvasm b/test/tint/statements/compound_assign/divide_by_zero.wgsl.expected.spvasm index 4bc339a..b7fe1ae 100644 --- a/test/tint/statements/compound_assign/divide_by_zero.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/divide_by_zero.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 62 +; Bound: 69 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -35,7 +35,8 @@ %int_n2147483648 = OpConstant %int -2147483648 %int_n1 = OpConstant %int -1 %int_1 = OpConstant %int 1 - %60 = OpTypeFunction %void + %uint = OpTypeInt 32 0 + %67 = OpTypeFunction %void %foo = OpFunction %void None %12 %maybe_zero = OpFunctionParameter %int %13 = OpLabel @@ -85,11 +86,17 @@ %54 = OpLogicalOr %bool %50 %53 %55 = OpSelect %int %54 %int_1 %rhs_0 %56 = OpSDiv %int %lhs_0 %55 - %57 = OpIMul %int %56 %55 - %58 = OpISub %int %lhs_0 %57 - OpReturnValue %58 + %58 = OpBitcast %uint %56 + %59 = OpBitcast %uint %55 + %60 = OpIMul %uint %58 %59 + %61 = OpBitcast %int %60 + %62 = OpBitcast %uint %lhs_0 + %63 = OpBitcast %uint %61 + %64 = OpISub %uint %62 %63 + %65 = OpBitcast %int %64 + OpReturnValue %65 OpFunctionEnd -%unused_entry_point = OpFunction %void None %60 - %61 = OpLabel +%unused_entry_point = OpFunction %void None %67 + %68 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/statements/compound_assign/scalar/minus.wgsl.expected.glsl b/test/tint/statements/compound_assign/scalar/minus.wgsl.expected.glsl index 76ce1a9..7df3fc0 100644 --- a/test/tint/statements/compound_assign/scalar/minus.wgsl.expected.glsl +++ b/test/tint/statements/compound_assign/scalar/minus.wgsl.expected.glsl
@@ -10,7 +10,8 @@ S inner; } v_1; void foo() { - v_1.inner.a = (v_1.inner.a - 2); + uint v_2 = uint(v_1.inner.a); + v_1.inner.a = int((v_2 - uint(2))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/statements/compound_assign/scalar/minus.wgsl.expected.spvasm b/test/tint/statements/compound_assign/scalar/minus.wgsl.expected.spvasm index 20abb6c..3f11bac 100644 --- a/test/tint/statements/compound_assign/scalar/minus.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/scalar/minus.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 19 +; Bound: 22 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -34,11 +34,14 @@ %9 = OpLabel %10 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 %uint_0 %14 = OpLoad %int %10 None - %15 = OpISub %int %14 %int_2 - OpStore %10 %15 None + %15 = OpBitcast %uint %14 + %16 = OpBitcast %uint %int_2 + %18 = OpISub %uint %15 %16 + %19 = OpBitcast %int %18 + OpStore %10 %19 None OpReturn OpFunctionEnd %unused_entry_point = OpFunction %void None %8 - %18 = OpLabel + %21 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/statements/compound_assign/scalar/modulo.wgsl.expected.glsl b/test/tint/statements/compound_assign/scalar/modulo.wgsl.expected.glsl index 7876859..07f388a 100644 --- a/test/tint/statements/compound_assign/scalar/modulo.wgsl.expected.glsl +++ b/test/tint/statements/compound_assign/scalar/modulo.wgsl.expected.glsl
@@ -14,7 +14,10 @@ bool v_3 = bool((v_2 & uint((rhs == -1)))); uint v_4 = uint((rhs == 0)); int v_5 = mix(rhs, 1, bool((v_4 | uint(v_3)))); - return (lhs - ((lhs / v_5) * v_5)); + uint v_6 = uint((lhs / v_5)); + int v_7 = int((v_6 * uint(v_5))); + uint v_8 = uint(lhs); + return int((v_8 - uint(v_7))); } void foo() { v_1.inner.a = tint_mod_i32(v_1.inner.a, 2);
diff --git a/test/tint/statements/compound_assign/scalar/modulo.wgsl.expected.spvasm b/test/tint/statements/compound_assign/scalar/modulo.wgsl.expected.spvasm index 6c7c7d5..b54a9cd 100644 --- a/test/tint/statements/compound_assign/scalar/modulo.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/scalar/modulo.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 38 +; Bound: 44 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -58,11 +58,17 @@ %30 = OpLogicalOr %bool %22 %29 %31 = OpSelect %int %30 %int_1 %rhs %33 = OpSDiv %int %lhs %31 - %34 = OpIMul %int %33 %31 - %35 = OpISub %int %lhs %34 - OpReturnValue %35 + %34 = OpBitcast %uint %33 + %35 = OpBitcast %uint %31 + %36 = OpIMul %uint %34 %35 + %37 = OpBitcast %int %36 + %38 = OpBitcast %uint %lhs + %39 = OpBitcast %uint %37 + %40 = OpISub %uint %38 %39 + %41 = OpBitcast %int %40 + OpReturnValue %41 OpFunctionEnd %unused_entry_point = OpFunction %void None %8 - %37 = OpLabel + %43 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/statements/compound_assign/scalar/plus.wgsl.expected.glsl b/test/tint/statements/compound_assign/scalar/plus.wgsl.expected.glsl index 4d3f824..67d2371 100644 --- a/test/tint/statements/compound_assign/scalar/plus.wgsl.expected.glsl +++ b/test/tint/statements/compound_assign/scalar/plus.wgsl.expected.glsl
@@ -10,7 +10,8 @@ S inner; } v_1; void foo() { - v_1.inner.a = (v_1.inner.a + 2); + uint v_2 = uint(v_1.inner.a); + v_1.inner.a = int((v_2 + uint(2))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/statements/compound_assign/scalar/plus.wgsl.expected.spvasm b/test/tint/statements/compound_assign/scalar/plus.wgsl.expected.spvasm index f2bc8b6..be59495 100644 --- a/test/tint/statements/compound_assign/scalar/plus.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/scalar/plus.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 19 +; Bound: 22 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -34,11 +34,14 @@ %9 = OpLabel %10 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 %uint_0 %14 = OpLoad %int %10 None - %15 = OpIAdd %int %14 %int_2 - OpStore %10 %15 None + %15 = OpBitcast %uint %14 + %16 = OpBitcast %uint %int_2 + %18 = OpIAdd %uint %15 %16 + %19 = OpBitcast %int %18 + OpStore %10 %19 None OpReturn OpFunctionEnd %unused_entry_point = OpFunction %void None %8 - %18 = OpLabel + %21 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/statements/compound_assign/scalar/shift_left.wgsl.expected.glsl b/test/tint/statements/compound_assign/scalar/shift_left.wgsl.expected.glsl index cf67c86b..8a54da0 100644 --- a/test/tint/statements/compound_assign/scalar/shift_left.wgsl.expected.glsl +++ b/test/tint/statements/compound_assign/scalar/shift_left.wgsl.expected.glsl
@@ -10,7 +10,7 @@ S inner; } v_1; void foo() { - v_1.inner.a = (v_1.inner.a << (2u & 31u)); + v_1.inner.a = int((uint(v_1.inner.a) << (2u & 31u))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/statements/compound_assign/scalar/shift_left.wgsl.expected.spvasm b/test/tint/statements/compound_assign/scalar/shift_left.wgsl.expected.spvasm index a7d5f5d..3b19cb9 100644 --- a/test/tint/statements/compound_assign/scalar/shift_left.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/scalar/shift_left.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 21 +; Bound: 23 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -36,11 +36,13 @@ %10 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 %uint_0 %14 = OpLoad %int %10 None %15 = OpBitwiseAnd %uint %uint_2 %uint_31 - %18 = OpShiftLeftLogical %int %14 %15 - OpStore %10 %18 None + %18 = OpBitcast %uint %14 + %19 = OpShiftLeftLogical %uint %18 %15 + %20 = OpBitcast %int %19 + OpStore %10 %20 None OpReturn OpFunctionEnd %unused_entry_point = OpFunction %void None %8 - %20 = OpLabel + %22 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/statements/compound_assign/scalar/times.wgsl.expected.glsl b/test/tint/statements/compound_assign/scalar/times.wgsl.expected.glsl index bf5957f..fbc2c49 100644 --- a/test/tint/statements/compound_assign/scalar/times.wgsl.expected.glsl +++ b/test/tint/statements/compound_assign/scalar/times.wgsl.expected.glsl
@@ -10,7 +10,8 @@ S inner; } v_1; void foo() { - v_1.inner.a = (v_1.inner.a * 2); + uint v_2 = uint(v_1.inner.a); + v_1.inner.a = int((v_2 * uint(2))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/statements/compound_assign/scalar/times.wgsl.expected.spvasm b/test/tint/statements/compound_assign/scalar/times.wgsl.expected.spvasm index 3cfa0cf..ec455c1 100644 --- a/test/tint/statements/compound_assign/scalar/times.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/scalar/times.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 19 +; Bound: 22 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -34,11 +34,14 @@ %9 = OpLabel %10 = OpAccessChain %_ptr_StorageBuffer_int %1 %uint_0 %uint_0 %14 = OpLoad %int %10 None - %15 = OpIMul %int %14 %int_2 - OpStore %10 %15 None + %15 = OpBitcast %uint %14 + %16 = OpBitcast %uint %int_2 + %18 = OpIMul %uint %15 %16 + %19 = OpBitcast %int %18 + OpStore %10 %19 None OpReturn OpFunctionEnd %unused_entry_point = OpFunction %void None %8 - %18 = OpLabel + %21 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/statements/compound_assign/vector/minus.wgsl.expected.glsl b/test/tint/statements/compound_assign/vector/minus.wgsl.expected.glsl index 17aa919..ad1e343 100644 --- a/test/tint/statements/compound_assign/vector/minus.wgsl.expected.glsl +++ b/test/tint/statements/compound_assign/vector/minus.wgsl.expected.glsl
@@ -10,7 +10,8 @@ S inner; } v_1; void foo() { - v_1.inner.a = (v_1.inner.a - ivec4(2)); + uvec4 v_2 = uvec4(v_1.inner.a); + v_1.inner.a = ivec4((v_2 - uvec4(ivec4(2)))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/statements/compound_assign/vector/minus.wgsl.expected.spvasm b/test/tint/statements/compound_assign/vector/minus.wgsl.expected.spvasm index fab704c..4607168 100644 --- a/test/tint/statements/compound_assign/vector/minus.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/vector/minus.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 21 +; Bound: 25 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -30,17 +30,21 @@ %_ptr_StorageBuffer_v4int = OpTypePointer StorageBuffer %v4int %uint = OpTypeInt 32 0 %uint_0 = OpConstant %uint 0 + %v4uint = OpTypeVector %uint 4 %int_2 = OpConstant %int 2 - %17 = OpConstantComposite %v4int %int_2 %int_2 %int_2 %int_2 + %19 = OpConstantComposite %v4int %int_2 %int_2 %int_2 %int_2 %foo = OpFunction %void None %9 %10 = OpLabel %11 = OpAccessChain %_ptr_StorageBuffer_v4int %1 %uint_0 %uint_0 %15 = OpLoad %v4int %11 None - %16 = OpISub %v4int %15 %17 - OpStore %11 %16 None + %17 = OpBitcast %v4uint %15 + %18 = OpBitcast %v4uint %19 + %21 = OpISub %v4uint %17 %18 + %22 = OpBitcast %v4int %21 + OpStore %11 %22 None OpReturn OpFunctionEnd %unused_entry_point = OpFunction %void None %9 - %20 = OpLabel + %24 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/statements/compound_assign/vector/modulo-scalar.wgsl.expected.glsl b/test/tint/statements/compound_assign/vector/modulo-scalar.wgsl.expected.glsl index 9e14fa4..9a4c74e 100644 --- a/test/tint/statements/compound_assign/vector/modulo-scalar.wgsl.expected.glsl +++ b/test/tint/statements/compound_assign/vector/modulo-scalar.wgsl.expected.glsl
@@ -14,11 +14,14 @@ bvec4 v_3 = bvec4((v_2 & uvec4(equal(rhs, ivec4(-1))))); uvec4 v_4 = uvec4(equal(rhs, ivec4(0))); ivec4 v_5 = mix(rhs, ivec4(1), bvec4((v_4 | uvec4(v_3)))); - return (lhs - ((lhs / v_5) * v_5)); + uvec4 v_6 = uvec4((lhs / v_5)); + ivec4 v_7 = ivec4((v_6 * uvec4(v_5))); + uvec4 v_8 = uvec4(lhs); + return ivec4((v_8 - uvec4(v_7))); } void foo() { - ivec4 v_6 = v_1.inner.a; - v_1.inner.a = tint_mod_v4i32(v_6, ivec4(2)); + ivec4 v_9 = v_1.inner.a; + v_1.inner.a = tint_mod_v4i32(v_9, ivec4(2)); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/statements/compound_assign/vector/modulo-scalar.wgsl.expected.spvasm b/test/tint/statements/compound_assign/vector/modulo-scalar.wgsl.expected.spvasm index b669a0d..27db001 100644 --- a/test/tint/statements/compound_assign/vector/modulo-scalar.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/vector/modulo-scalar.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 44 +; Bound: 51 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -44,6 +44,7 @@ %32 = OpConstantComposite %v4int %int_n1 %int_n1 %int_n1 %int_n1 %int_1 = OpConstant %int 1 %37 = OpConstantComposite %v4int %int_1 %int_1 %int_1 %int_1 + %v4uint = OpTypeVector %uint 4 %foo = OpFunction %void None %9 %10 = OpLabel %11 = OpAccessChain %_ptr_StorageBuffer_v4int %1 %uint_0 %uint_0 @@ -64,11 +65,17 @@ %35 = OpLogicalOr %v4bool %24 %34 %36 = OpSelect %v4int %35 %37 %rhs %39 = OpSDiv %v4int %lhs %36 - %40 = OpIMul %v4int %39 %36 - %41 = OpISub %v4int %lhs %40 - OpReturnValue %41 + %41 = OpBitcast %v4uint %39 + %42 = OpBitcast %v4uint %36 + %43 = OpIMul %v4uint %41 %42 + %44 = OpBitcast %v4int %43 + %45 = OpBitcast %v4uint %lhs + %46 = OpBitcast %v4uint %44 + %47 = OpISub %v4uint %45 %46 + %48 = OpBitcast %v4int %47 + OpReturnValue %48 OpFunctionEnd %unused_entry_point = OpFunction %void None %9 - %43 = OpLabel + %50 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/statements/compound_assign/vector/modulo.wgsl.expected.glsl b/test/tint/statements/compound_assign/vector/modulo.wgsl.expected.glsl index 2c22851..5022d385 100644 --- a/test/tint/statements/compound_assign/vector/modulo.wgsl.expected.glsl +++ b/test/tint/statements/compound_assign/vector/modulo.wgsl.expected.glsl
@@ -14,7 +14,10 @@ bvec4 v_3 = bvec4((v_2 & uvec4(equal(rhs, ivec4(-1))))); uvec4 v_4 = uvec4(equal(rhs, ivec4(0))); ivec4 v_5 = mix(rhs, ivec4(1), bvec4((v_4 | uvec4(v_3)))); - return (lhs - ((lhs / v_5) * v_5)); + uvec4 v_6 = uvec4((lhs / v_5)); + ivec4 v_7 = ivec4((v_6 * uvec4(v_5))); + uvec4 v_8 = uvec4(lhs); + return ivec4((v_8 - uvec4(v_7))); } void foo() { v_1.inner.a = tint_mod_v4i32(v_1.inner.a, ivec4(2));
diff --git a/test/tint/statements/compound_assign/vector/modulo.wgsl.expected.spvasm b/test/tint/statements/compound_assign/vector/modulo.wgsl.expected.spvasm index a7cfdb7..baa2a4d 100644 --- a/test/tint/statements/compound_assign/vector/modulo.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/vector/modulo.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 44 +; Bound: 51 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -45,6 +45,7 @@ %32 = OpConstantComposite %v4int %int_n1 %int_n1 %int_n1 %int_n1 %int_1 = OpConstant %int 1 %37 = OpConstantComposite %v4int %int_1 %int_1 %int_1 %int_1 + %v4uint = OpTypeVector %uint 4 %foo = OpFunction %void None %9 %10 = OpLabel %11 = OpAccessChain %_ptr_StorageBuffer_v4int %1 %uint_0 %uint_0 @@ -64,11 +65,17 @@ %35 = OpLogicalOr %v4bool %24 %34 %36 = OpSelect %v4int %35 %37 %rhs %39 = OpSDiv %v4int %lhs %36 - %40 = OpIMul %v4int %39 %36 - %41 = OpISub %v4int %lhs %40 - OpReturnValue %41 + %41 = OpBitcast %v4uint %39 + %42 = OpBitcast %v4uint %36 + %43 = OpIMul %v4uint %41 %42 + %44 = OpBitcast %v4int %43 + %45 = OpBitcast %v4uint %lhs + %46 = OpBitcast %v4uint %44 + %47 = OpISub %v4uint %45 %46 + %48 = OpBitcast %v4int %47 + OpReturnValue %48 OpFunctionEnd %unused_entry_point = OpFunction %void None %9 - %43 = OpLabel + %50 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/statements/compound_assign/vector/plus.wgsl.expected.glsl b/test/tint/statements/compound_assign/vector/plus.wgsl.expected.glsl index e43847d..f7c0e1a 100644 --- a/test/tint/statements/compound_assign/vector/plus.wgsl.expected.glsl +++ b/test/tint/statements/compound_assign/vector/plus.wgsl.expected.glsl
@@ -10,7 +10,8 @@ S inner; } v_1; void foo() { - v_1.inner.a = (v_1.inner.a + ivec4(2)); + uvec4 v_2 = uvec4(v_1.inner.a); + v_1.inner.a = ivec4((v_2 + uvec4(ivec4(2)))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/statements/compound_assign/vector/plus.wgsl.expected.spvasm b/test/tint/statements/compound_assign/vector/plus.wgsl.expected.spvasm index 87c5c77..e7ab783 100644 --- a/test/tint/statements/compound_assign/vector/plus.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/vector/plus.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 21 +; Bound: 25 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -30,17 +30,21 @@ %_ptr_StorageBuffer_v4int = OpTypePointer StorageBuffer %v4int %uint = OpTypeInt 32 0 %uint_0 = OpConstant %uint 0 + %v4uint = OpTypeVector %uint 4 %int_2 = OpConstant %int 2 - %17 = OpConstantComposite %v4int %int_2 %int_2 %int_2 %int_2 + %19 = OpConstantComposite %v4int %int_2 %int_2 %int_2 %int_2 %foo = OpFunction %void None %9 %10 = OpLabel %11 = OpAccessChain %_ptr_StorageBuffer_v4int %1 %uint_0 %uint_0 %15 = OpLoad %v4int %11 None - %16 = OpIAdd %v4int %15 %17 - OpStore %11 %16 None + %17 = OpBitcast %v4uint %15 + %18 = OpBitcast %v4uint %19 + %21 = OpIAdd %v4uint %17 %18 + %22 = OpBitcast %v4int %21 + OpStore %11 %22 None OpReturn OpFunctionEnd %unused_entry_point = OpFunction %void None %9 - %20 = OpLabel + %24 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/statements/compound_assign/vector/shift_left.wgsl.expected.glsl b/test/tint/statements/compound_assign/vector/shift_left.wgsl.expected.glsl index 889fafa..b026dd2 100644 --- a/test/tint/statements/compound_assign/vector/shift_left.wgsl.expected.glsl +++ b/test/tint/statements/compound_assign/vector/shift_left.wgsl.expected.glsl
@@ -10,7 +10,7 @@ S inner; } v_1; void foo() { - v_1.inner.a = (v_1.inner.a << (uvec4(2u) & uvec4(31u))); + v_1.inner.a = ivec4((uvec4(v_1.inner.a) << (uvec4(2u) & uvec4(31u)))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/statements/compound_assign/vector/shift_left.wgsl.expected.spvasm b/test/tint/statements/compound_assign/vector/shift_left.wgsl.expected.spvasm index 98c284b..b862ca2 100644 --- a/test/tint/statements/compound_assign/vector/shift_left.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/vector/shift_left.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 25 +; Bound: 27 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -40,11 +40,13 @@ %11 = OpAccessChain %_ptr_StorageBuffer_v4int %1 %uint_0 %uint_0 %15 = OpLoad %v4int %11 None %16 = OpBitwiseAnd %v4uint %17 %20 - %22 = OpShiftLeftLogical %v4int %15 %16 - OpStore %11 %22 None + %22 = OpBitcast %v4uint %15 + %23 = OpShiftLeftLogical %v4uint %22 %16 + %24 = OpBitcast %v4int %23 + OpStore %11 %24 None OpReturn OpFunctionEnd %unused_entry_point = OpFunction %void None %9 - %24 = OpLabel + %26 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/statements/compound_assign/vector/times.wgsl.expected.glsl b/test/tint/statements/compound_assign/vector/times.wgsl.expected.glsl index 892fba2..28d6b33 100644 --- a/test/tint/statements/compound_assign/vector/times.wgsl.expected.glsl +++ b/test/tint/statements/compound_assign/vector/times.wgsl.expected.glsl
@@ -10,7 +10,8 @@ S inner; } v_1; void foo() { - v_1.inner.a = (v_1.inner.a * ivec4(2)); + uvec4 v_2 = uvec4(v_1.inner.a); + v_1.inner.a = ivec4((v_2 * uvec4(ivec4(2)))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/statements/compound_assign/vector/times.wgsl.expected.spvasm b/test/tint/statements/compound_assign/vector/times.wgsl.expected.spvasm index 65fe438..9818576 100644 --- a/test/tint/statements/compound_assign/vector/times.wgsl.expected.spvasm +++ b/test/tint/statements/compound_assign/vector/times.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 21 +; Bound: 25 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -30,17 +30,21 @@ %_ptr_StorageBuffer_v4int = OpTypePointer StorageBuffer %v4int %uint = OpTypeInt 32 0 %uint_0 = OpConstant %uint 0 + %v4uint = OpTypeVector %uint 4 %int_2 = OpConstant %int 2 - %17 = OpConstantComposite %v4int %int_2 %int_2 %int_2 %int_2 + %19 = OpConstantComposite %v4int %int_2 %int_2 %int_2 %int_2 %foo = OpFunction %void None %9 %10 = OpLabel %11 = OpAccessChain %_ptr_StorageBuffer_v4int %1 %uint_0 %uint_0 %15 = OpLoad %v4int %11 None - %16 = OpIMul %v4int %15 %17 - OpStore %11 %16 None + %17 = OpBitcast %v4uint %15 + %18 = OpBitcast %v4uint %19 + %21 = OpIMul %v4uint %17 %18 + %22 = OpBitcast %v4int %21 + OpStore %11 %22 None OpReturn OpFunctionEnd %unused_entry_point = OpFunction %void None %9 - %20 = OpLabel + %24 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/statements/decrement/complex.wgsl.expected.glsl b/test/tint/statements/decrement/complex.wgsl.expected.glsl index 7cf031d..1fd4509 100644 --- a/test/tint/statements/decrement/complex.wgsl.expected.glsl +++ b/test/tint/statements/decrement/complex.wgsl.expected.glsl
@@ -43,8 +43,9 @@ uint v_6 = min(uint(v_3), v_5); uint v_7 = min(uint(v_4), 3u); int v_8 = idx3(); - int v_9 = (v_1.inner[v_6].a[v_7][min(uint(v_8), 3u)] - 1); - v_1.inner[v_6].a[v_7][min(uint(v_8), 3u)] = v_9; + uint v_9 = uint(v_1.inner[v_6].a[v_7][min(uint(v_8), 3u)]); + int v_10 = int((v_9 - uint(1))); + v_1.inner[v_6].a[v_7][min(uint(v_8), 3u)] = v_10; while(true) { if (all(equal(tint_loop_idx, uvec2(0u)))) { break; @@ -58,14 +59,15 @@ tint_loop_idx.x = tint_low_inc; uint tint_carry = uint((tint_low_inc == 4294967295u)); tint_loop_idx.y = (tint_loop_idx.y - tint_carry); - int v_10 = idx4(); - int v_11 = idx5(); - uint v_12 = (uint(v_1.inner.length()) - 1u); - uint v_13 = min(uint(v_10), v_12); - uint v_14 = min(uint(v_11), 3u); - int v_15 = idx6(); - int v_16 = (v_1.inner[v_13].a[v_14][min(uint(v_15), 3u)] - 1); - v_1.inner[v_13].a[v_14][min(uint(v_15), 3u)] = v_16; + int v_11 = idx4(); + int v_12 = idx5(); + uint v_13 = (uint(v_1.inner.length()) - 1u); + uint v_14 = min(uint(v_11), v_13); + uint v_15 = min(uint(v_12), 3u); + int v_16 = idx6(); + uint v_17 = uint(v_1.inner[v_14].a[v_15][min(uint(v_16), 3u)]); + int v_18 = int((v_17 - uint(1))); + v_1.inner[v_14].a[v_15][min(uint(v_16), 3u)] = v_18; } continue; }
diff --git a/test/tint/statements/decrement/complex.wgsl.expected.spvasm b/test/tint/statements/decrement/complex.wgsl.expected.spvasm index aea01bc..46441e3 100644 --- a/test/tint/statements/decrement/complex.wgsl.expected.spvasm +++ b/test/tint/statements/decrement/complex.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 129 +; Bound: 135 ; Schema: 0 OpCapability Shader %68 = OpExtInstImport "GLSL.std.450" @@ -63,7 +63,7 @@ %uint_3 = OpConstant %uint 3 %_ptr_StorageBuffer_v4int = OpTypePointer StorageBuffer %v4int %_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int - %86 = OpConstantNull %v2uint + %89 = OpConstantNull %v2uint %bool = OpTypeBool %v2bool = OpTypeVector %bool 2 %uint_10 = OpConstant %uint 10 @@ -131,70 +131,76 @@ %76 = OpExtInst %uint %68 UMin %75 %uint_3 %77 = OpAccessChain %_ptr_StorageBuffer_int %72 %76 %79 = OpLoad %int %77 None - %80 = OpISub %int %79 %int_1 - %81 = OpBitcast %uint %74 - %82 = OpExtInst %uint %68 UMin %81 %uint_3 - %83 = OpAccessChain %_ptr_StorageBuffer_int %72 %82 - OpStore %83 %80 None + %80 = OpBitcast %uint %79 + %81 = OpBitcast %uint %int_1 + %82 = OpISub %uint %80 %81 + %83 = OpBitcast %int %82 + %84 = OpBitcast %uint %74 + %85 = OpExtInst %uint %68 UMin %84 %uint_3 + %86 = OpAccessChain %_ptr_StorageBuffer_int %72 %85 + OpStore %86 %83 None OpBranch %52 %52 = OpLabel OpLoopMerge %53 %51 None OpBranch %50 %50 = OpLabel - %84 = OpLoad %v2uint %tint_loop_idx None - %85 = OpIEqual %v2bool %84 %86 - %89 = OpAll %bool %85 - OpSelectionMerge %90 None - OpBranchConditional %89 %91 %90 - %91 = OpLabel + %87 = OpLoad %v2uint %tint_loop_idx None + %88 = OpIEqual %v2bool %87 %89 + %92 = OpAll %bool %88 + OpSelectionMerge %93 None + OpBranchConditional %92 %94 %93 + %94 = OpLabel OpBranch %53 - %90 = OpLabel - %92 = OpLoad %uint %v None - %93 = OpULessThan %bool %92 %uint_10 - OpSelectionMerge %95 None - OpBranchConditional %93 %95 %96 - %96 = OpLabel + %93 = OpLabel + %95 = OpLoad %uint %v None + %96 = OpULessThan %bool %95 %uint_10 + OpSelectionMerge %98 None + OpBranchConditional %96 %98 %99 + %99 = OpLabel OpBranch %53 - %95 = OpLabel + %98 = OpLabel OpBranch %51 %51 = OpLabel - %97 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 - %99 = OpLoad %uint %97 None -%tint_low_inc = OpISub %uint %99 %uint_1 - %101 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 - OpStore %101 %tint_low_inc None - %102 = OpIEqual %bool %tint_low_inc %uint_4294967295 - %tint_carry = OpSelect %uint %102 %uint_1 %uint_0 - %104 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 - %105 = OpLoad %uint %104 None - %106 = OpISub %uint %105 %tint_carry + %100 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 + %102 = OpLoad %uint %100 None +%tint_low_inc = OpISub %uint %102 %uint_1 + %104 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 + OpStore %104 %tint_low_inc None + %105 = OpIEqual %bool %tint_low_inc %uint_4294967295 + %tint_carry = OpSelect %uint %105 %uint_1 %uint_0 %107 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 - OpStore %107 %106 None - %108 = OpFunctionCall %int %idx4 - %109 = OpFunctionCall %int %idx5 - %110 = OpAccessChain %_ptr_StorageBuffer__runtimearr_S_tint_explicit_layout %1 %uint_0 - %111 = OpArrayLength %uint %1 0 - %112 = OpISub %uint %111 %uint_1 - %113 = OpBitcast %uint %108 - %114 = OpExtInst %uint %68 UMin %113 %112 - %115 = OpBitcast %uint %109 - %116 = OpExtInst %uint %68 UMin %115 %uint_3 - %117 = OpAccessChain %_ptr_StorageBuffer_v4int %1 %uint_0 %114 %uint_0 %116 - %118 = OpFunctionCall %int %idx6 - %119 = OpBitcast %uint %118 - %120 = OpExtInst %uint %68 UMin %119 %uint_3 - %121 = OpAccessChain %_ptr_StorageBuffer_int %117 %120 - %122 = OpLoad %int %121 None - %123 = OpISub %int %122 %int_1 - %124 = OpBitcast %uint %118 - %125 = OpExtInst %uint %68 UMin %124 %uint_3 - %126 = OpAccessChain %_ptr_StorageBuffer_int %117 %125 - OpStore %126 %123 None + %108 = OpLoad %uint %107 None + %109 = OpISub %uint %108 %tint_carry + %110 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 + OpStore %110 %109 None + %111 = OpFunctionCall %int %idx4 + %112 = OpFunctionCall %int %idx5 + %113 = OpAccessChain %_ptr_StorageBuffer__runtimearr_S_tint_explicit_layout %1 %uint_0 + %114 = OpArrayLength %uint %1 0 + %115 = OpISub %uint %114 %uint_1 + %116 = OpBitcast %uint %111 + %117 = OpExtInst %uint %68 UMin %116 %115 + %118 = OpBitcast %uint %112 + %119 = OpExtInst %uint %68 UMin %118 %uint_3 + %120 = OpAccessChain %_ptr_StorageBuffer_v4int %1 %uint_0 %117 %uint_0 %119 + %121 = OpFunctionCall %int %idx6 + %122 = OpBitcast %uint %121 + %123 = OpExtInst %uint %68 UMin %122 %uint_3 + %124 = OpAccessChain %_ptr_StorageBuffer_int %120 %123 + %125 = OpLoad %int %124 None + %126 = OpBitcast %uint %125 + %127 = OpBitcast %uint %int_1 + %128 = OpISub %uint %126 %127 + %129 = OpBitcast %int %128 + %130 = OpBitcast %uint %121 + %131 = OpExtInst %uint %68 UMin %130 %uint_3 + %132 = OpAccessChain %_ptr_StorageBuffer_int %120 %131 + OpStore %132 %129 None OpBranch %52 %53 = OpLabel OpReturn OpFunctionEnd %unused_entry_point = OpFunction %void None %47 - %128 = OpLabel + %134 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/statements/decrement/function.wgsl.expected.glsl b/test/tint/statements/decrement/function.wgsl.expected.glsl index 743a65e..00b79db 100644 --- a/test/tint/statements/decrement/function.wgsl.expected.glsl +++ b/test/tint/statements/decrement/function.wgsl.expected.glsl
@@ -2,7 +2,8 @@ void v() { int i = 0; - i = (i - 1); + uint v_1 = uint(i); + i = int((v_1 - uint(1))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/statements/decrement/function.wgsl.expected.spvasm b/test/tint/statements/decrement/function.wgsl.expected.spvasm index 6f2ae7c..ff62a78 100644 --- a/test/tint/statements/decrement/function.wgsl.expected.spvasm +++ b/test/tint/statements/decrement/function.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 14 +; Bound: 18 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -15,17 +15,21 @@ %int = OpTypeInt 32 1 %_ptr_Function_int = OpTypePointer Function %int %int_0 = OpConstant %int 0 + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %main = OpFunction %void None %3 %4 = OpLabel %i = OpVariable %_ptr_Function_int Function OpStore %i %int_0 %9 = OpLoad %int %i None - %10 = OpISub %int %9 %int_1 - OpStore %i %10 None + %11 = OpBitcast %uint %9 + %12 = OpBitcast %uint %int_1 + %14 = OpISub %uint %11 %12 + %15 = OpBitcast %int %14 + OpStore %i %15 None OpReturn OpFunctionEnd %unused_entry_point = OpFunction %void None %3 - %13 = OpLabel + %17 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/statements/decrement/private.wgsl.expected.glsl b/test/tint/statements/decrement/private.wgsl.expected.glsl index c7aa6e4..a8a638b 100644 --- a/test/tint/statements/decrement/private.wgsl.expected.glsl +++ b/test/tint/statements/decrement/private.wgsl.expected.glsl
@@ -2,7 +2,8 @@ int i = 0; void v() { - i = (i - 1); + uint v_1 = uint(i); + i = int((v_1 - uint(1))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/statements/decrement/private.wgsl.expected.spvasm b/test/tint/statements/decrement/private.wgsl.expected.spvasm index a0d72db..5db9a7f 100644 --- a/test/tint/statements/decrement/private.wgsl.expected.spvasm +++ b/test/tint/statements/decrement/private.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 14 +; Bound: 18 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -16,15 +16,19 @@ %i = OpVariable %_ptr_Private_int Private %int_0 %void = OpTypeVoid %7 = OpTypeFunction %void + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %main = OpFunction %void None %7 %8 = OpLabel %9 = OpLoad %int %i None - %10 = OpISub %int %9 %int_1 - OpStore %i %10 None + %11 = OpBitcast %uint %9 + %12 = OpBitcast %uint %int_1 + %14 = OpISub %uint %11 %12 + %15 = OpBitcast %int %14 + OpStore %i %15 None OpReturn OpFunctionEnd %unused_entry_point = OpFunction %void None %7 - %13 = OpLabel + %17 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/statements/decrement/split.wgsl.expected.glsl b/test/tint/statements/decrement/split.wgsl.expected.glsl index 0318a6d..5d2b52b 100644 --- a/test/tint/statements/decrement/split.wgsl.expected.glsl +++ b/test/tint/statements/decrement/split.wgsl.expected.glsl
@@ -2,7 +2,10 @@ void v() { int b = 2; - int c = (b - -(b)); + int v_1 = b; + int v_2 = int((~(uint(b)) + 1u)); + uint v_3 = uint(v_1); + int c = int((v_3 - uint(v_2))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/statements/decrement/split.wgsl.expected.spvasm b/test/tint/statements/decrement/split.wgsl.expected.spvasm index d9143c5..dad0131 100644 --- a/test/tint/statements/decrement/split.wgsl.expected.spvasm +++ b/test/tint/statements/decrement/split.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 16 +; Bound: 24 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -16,6 +16,8 @@ %int = OpTypeInt 32 1 %_ptr_Function_int = OpTypePointer Function %int %int_2 = OpConstant %int 2 + %uint = OpTypeInt 32 0 + %uint_1 = OpConstant %uint 1 %main = OpFunction %void None %3 %4 = OpLabel %b = OpVariable %_ptr_Function_int Function @@ -23,12 +25,18 @@ OpStore %b %int_2 %9 = OpLoad %int %b None %10 = OpLoad %int %b None - %11 = OpSNegate %int %10 - %12 = OpISub %int %9 %11 - OpStore %c %12 + %12 = OpBitcast %uint %10 + %13 = OpNot %uint %12 + %14 = OpIAdd %uint %13 %uint_1 + %16 = OpBitcast %int %14 + %17 = OpBitcast %uint %9 + %18 = OpBitcast %uint %16 + %19 = OpISub %uint %17 %18 + %20 = OpBitcast %int %19 + OpStore %c %20 OpReturn OpFunctionEnd %unused_entry_point = OpFunction %void None %3 - %15 = OpLabel + %23 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/statements/decrement/workgroup.wgsl.expected.glsl b/test/tint/statements/decrement/workgroup.wgsl.expected.glsl index 91f4834..aa70b2c 100644 --- a/test/tint/statements/decrement/workgroup.wgsl.expected.glsl +++ b/test/tint/statements/decrement/workgroup.wgsl.expected.glsl
@@ -2,7 +2,8 @@ shared int i; void v() { - i = (i - 1); + uint v_1 = uint(i); + i = int((v_1 - uint(1))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/statements/decrement/workgroup.wgsl.expected.spvasm b/test/tint/statements/decrement/workgroup.wgsl.expected.spvasm index 39203b8..33d523c 100644 --- a/test/tint/statements/decrement/workgroup.wgsl.expected.spvasm +++ b/test/tint/statements/decrement/workgroup.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 13 +; Bound: 17 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -15,15 +15,19 @@ %i = OpVariable %_ptr_Workgroup_int Workgroup %void = OpTypeVoid %6 = OpTypeFunction %void + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %main = OpFunction %void None %6 %7 = OpLabel %8 = OpLoad %int %i None - %9 = OpISub %int %8 %int_1 - OpStore %i %9 None + %10 = OpBitcast %uint %8 + %11 = OpBitcast %uint %int_1 + %13 = OpISub %uint %10 %11 + %14 = OpBitcast %int %13 + OpStore %i %14 None OpReturn OpFunctionEnd %unused_entry_point = OpFunction %void None %6 - %12 = OpLabel + %16 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/statements/discard/atomic_in_for_loop_continuing.wgsl.expected.glsl b/test/tint/statements/discard/atomic_in_for_loop_continuing.wgsl.expected.glsl index d8b459d..1c2bf98 100644 --- a/test/tint/statements/discard/atomic_in_for_loop_continuing.wgsl.expected.glsl +++ b/test/tint/statements/discard/atomic_in_for_loop_continuing.wgsl.expected.glsl
@@ -30,17 +30,19 @@ } else { break; } - result = (result + i); + int v_2 = i; + uint v_3 = uint(result); + result = int((v_3 + uint(v_2))); { uint tint_low_inc = (tint_loop_idx.x - 1u); tint_loop_idx.x = tint_low_inc; uint tint_carry = uint((tint_low_inc == 4294967295u)); tint_loop_idx.y = (tint_loop_idx.y - tint_carry); - int v_2 = 0; + int v_4 = 0; if (continue_execution) { - v_2 = atomicAdd(v.inner, 1); + v_4 = atomicAdd(v.inner, 1); } - i = v_2; + i = v_4; } continue; }
diff --git a/test/tint/statements/discard/atomic_in_for_loop_continuing.wgsl.expected.spvasm b/test/tint/statements/discard/atomic_in_for_loop_continuing.wgsl.expected.spvasm index 2c81dd2..34ec0a5 100644 --- a/test/tint/statements/discard/atomic_in_for_loop_continuing.wgsl.expected.spvasm +++ b/test/tint/statements/discard/atomic_in_for_loop_continuing.wgsl.expected.spvasm
@@ -1,10 +1,10 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 115 +; Bound: 118 ; Schema: 0 OpCapability Shader - %104 = OpExtInstImport "GLSL.std.450" + %107 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Fragment %foo "foo" %foo_loc0_Input %foo_loc1_Input %foo_loc0_Output OpExecutionMode %foo OriginUpperLeft @@ -80,13 +80,13 @@ %uint_0 = OpConstant %uint 0 %uint_1 = OpConstant %uint 1 %_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int - %98 = OpUndef %int + %101 = OpUndef %int %int_1 = OpConstant %int 1 - %101 = OpTypeFunction %int %float + %104 = OpTypeFunction %int %float %float_n2_14748365e_09 = OpConstant %float -2.14748365e+09 %float_2_14748352e_09 = OpConstant %float 2.14748352e+09 %void = OpTypeVoid - %110 = OpTypeFunction %void + %113 = OpTypeFunction %void %foo_inner = OpFunction %int None %26 %in = OpFunctionParameter %float %coord = OpFunctionParameter %v2float @@ -134,34 +134,37 @@ %72 = OpLabel %74 = OpLoad %int %i None %75 = OpLoad %int %result None - %76 = OpIAdd %int %75 %74 - OpStore %result %76 None + %76 = OpBitcast %uint %75 + %77 = OpBitcast %uint %74 + %78 = OpIAdd %uint %76 %77 + %79 = OpBitcast %int %78 + OpStore %result %79 None OpBranch %45 %45 = OpLabel - %77 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 - %80 = OpLoad %uint %77 None -%tint_low_inc = OpISub %uint %80 %uint_1 - %83 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 - OpStore %83 %tint_low_inc None - %84 = OpIEqual %bool %tint_low_inc %uint_4294967295 - %tint_carry = OpSelect %uint %84 %uint_1 %uint_0 - %86 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 - %87 = OpLoad %uint %86 None - %88 = OpISub %uint %87 %tint_carry + %80 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 + %83 = OpLoad %uint %80 None +%tint_low_inc = OpISub %uint %83 %uint_1 + %86 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 + OpStore %86 %tint_low_inc None + %87 = OpIEqual %bool %tint_low_inc %uint_4294967295 + %tint_carry = OpSelect %uint %87 %uint_1 %uint_0 %89 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 - OpStore %89 %88 None - %90 = OpAccessChain %_ptr_StorageBuffer_int %8 %uint_0 - %92 = OpLoad %bool %continue_execution None - OpSelectionMerge %93 None - OpBranchConditional %92 %94 %95 - %94 = OpLabel - %97 = OpAtomicIAdd %int %90 %uint_1 %uint_0 %int_1 - OpBranch %93 - %95 = OpLabel - OpBranch %93 - %93 = OpLabel - %96 = OpPhi %int %97 %94 %98 %95 - OpStore %i %96 None + %90 = OpLoad %uint %89 None + %91 = OpISub %uint %90 %tint_carry + %92 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 + OpStore %92 %91 None + %93 = OpAccessChain %_ptr_StorageBuffer_int %8 %uint_0 + %95 = OpLoad %bool %continue_execution None + OpSelectionMerge %96 None + OpBranchConditional %95 %97 %98 + %97 = OpLabel + %100 = OpAtomicIAdd %int %93 %uint_1 %uint_0 %int_1 + OpBranch %96 + %98 = OpLabel + OpBranch %96 + %96 = OpLabel + %99 = OpPhi %int %100 %97 %101 %98 + OpStore %i %99 None OpBranch %46 %47 = OpLabel %48 = OpLoad %int %result None @@ -174,18 +177,18 @@ %51 = OpLabel OpReturnValue %48 OpFunctionEnd -%tint_f32_to_i32 = OpFunction %int None %101 +%tint_f32_to_i32 = OpFunction %int None %104 %value = OpFunctionParameter %float - %102 = OpLabel - %103 = OpExtInst %float %104 NClamp %value %float_n2_14748365e_09 %float_2_14748352e_09 - %107 = OpConvertFToS %int %103 - OpReturnValue %107 + %105 = OpLabel + %106 = OpExtInst %float %107 NClamp %value %float_n2_14748365e_09 %float_2_14748352e_09 + %110 = OpConvertFToS %int %106 + OpReturnValue %110 OpFunctionEnd - %foo = OpFunction %void None %110 - %111 = OpLabel - %112 = OpLoad %float %foo_loc0_Input None - %113 = OpLoad %v2float %foo_loc1_Input None - %114 = OpFunctionCall %int %foo_inner %112 %113 - OpStore %foo_loc0_Output %114 None + %foo = OpFunction %void None %113 + %114 = OpLabel + %115 = OpLoad %float %foo_loc0_Input None + %116 = OpLoad %v2float %foo_loc1_Input None + %117 = OpFunctionCall %int %foo_inner %115 %116 + OpStore %foo_loc0_Output %117 None OpReturn OpFunctionEnd
diff --git a/test/tint/statements/discard/multiple_returns.wgsl.expected.glsl b/test/tint/statements/discard/multiple_returns.wgsl.expected.glsl index 0a6d77c..344c7b7 100644 --- a/test/tint/statements/discard/multiple_returns.wgsl.expected.glsl +++ b/test/tint/statements/discard/multiple_returns.wgsl.expected.glsl
@@ -43,7 +43,8 @@ tint_loop_idx.x = tint_low_inc; uint tint_carry = uint((tint_low_inc == 4294967295u)); tint_loop_idx.y = (tint_loop_idx.y - tint_carry); - i = (i + 1); + uint v_5 = uint(i); + i = int((v_5 + uint(1))); if ((i == 5)) { break; } } continue;
diff --git a/test/tint/statements/discard/multiple_returns.wgsl.expected.spvasm b/test/tint/statements/discard/multiple_returns.wgsl.expected.spvasm index 1023180..c4c033f 100644 --- a/test/tint/statements/discard/multiple_returns.wgsl.expected.spvasm +++ b/test/tint/statements/discard/multiple_returns.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 102 +; Bound: 105 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -113,23 +113,23 @@ OpSelectionMerge %72 None OpBranchConditional %71 %73 %72 %73 = OpLabel - %92 = OpLoad %int %i None - %93 = OpConvertSToF %float %92 - %94 = OpAccessChain %_ptr_StorageBuffer_float %5 %uint_0 - %95 = OpLoad %bool %continue_execution None - OpSelectionMerge %96 None - OpBranchConditional %95 %97 %96 - %97 = OpLabel - OpStore %94 %93 None - OpBranch %96 - %96 = OpLabel + %95 = OpLoad %int %i None + %96 = OpConvertSToF %float %95 + %97 = OpAccessChain %_ptr_StorageBuffer_float %5 %uint_0 %98 = OpLoad %bool %continue_execution None - %99 = OpLogicalNot %bool %98 - OpSelectionMerge %100 None - OpBranchConditional %99 %101 %100 - %101 = OpLabel - OpKill + OpSelectionMerge %99 None + OpBranchConditional %98 %100 %99 %100 = OpLabel + OpStore %97 %96 None + OpBranch %99 + %99 = OpLabel + %101 = OpLoad %bool %continue_execution None + %102 = OpLogicalNot %bool %101 + OpSelectionMerge %103 None + OpBranchConditional %102 %104 %103 + %104 = OpLabel + OpKill + %103 = OpLabel OpReturn %72 = OpLabel OpBranch %48 @@ -147,11 +147,14 @@ %85 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 OpStore %85 %84 None %86 = OpLoad %int %i None - %87 = OpIAdd %int %86 %int_1 - OpStore %i %87 None - %89 = OpLoad %int %i None - %90 = OpIEqual %bool %89 %int_5 - OpBranchConditional %90 %50 %49 + %87 = OpBitcast %uint %86 + %88 = OpBitcast %uint %int_1 + %90 = OpIAdd %uint %87 %88 + %91 = OpBitcast %int %90 + OpStore %i %91 None + %92 = OpLoad %int %i None + %93 = OpIEqual %bool %92 %int_5 + OpBranchConditional %93 %50 %49 %50 = OpLabel %51 = OpLoad %bool %continue_execution None %52 = OpLogicalNot %bool %51
diff --git a/test/tint/statements/for/basic.wgsl.expected.glsl b/test/tint/statements/for/basic.wgsl.expected.glsl index 65a3aca..340aadd 100644 --- a/test/tint/statements/for/basic.wgsl.expected.glsl +++ b/test/tint/statements/for/basic.wgsl.expected.glsl
@@ -12,7 +12,8 @@ } some_loop_body(); { - i = (i + 1); + uint v = uint(i); + i = int((v + uint(1))); } continue; }
diff --git a/test/tint/statements/for/basic.wgsl.expected.spvasm b/test/tint/statements/for/basic.wgsl.expected.spvasm index dad73e4..f6b402c 100644 --- a/test/tint/statements/for/basic.wgsl.expected.spvasm +++ b/test/tint/statements/for/basic.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 28 +; Bound: 32 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -18,6 +18,7 @@ %int_0 = OpConstant %int 0 %int_5 = OpConstant %int 5 %bool = OpTypeBool + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %some_loop_body = OpFunction %void None %3 %4 = OpLabel @@ -45,13 +46,16 @@ OpBranch %9 %9 = OpLabel %23 = OpLoad %int %i None - %24 = OpIAdd %int %23 %int_1 - OpStore %i %24 None + %25 = OpBitcast %uint %23 + %26 = OpBitcast %uint %int_1 + %28 = OpIAdd %uint %25 %26 + %29 = OpBitcast %int %28 + OpStore %i %29 None OpBranch %10 %11 = OpLabel OpReturn OpFunctionEnd %unused_entry_point = OpFunction %void None %3 - %27 = OpLabel + %31 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/statements/for/complex.wgsl.expected.glsl b/test/tint/statements/for/complex.wgsl.expected.glsl index 26904e9..0197469 100644 --- a/test/tint/statements/for/complex.wgsl.expected.glsl +++ b/test/tint/statements/for/complex.wgsl.expected.glsl
@@ -22,13 +22,15 @@ break; } some_loop_body(); - j = (i * 30); + uint v_1 = uint(i); + j = int((v_1 * uint(30))); { uint tint_low_inc = (tint_loop_idx.x - 1u); tint_loop_idx.x = tint_low_inc; uint tint_carry = uint((tint_low_inc == 4294967295u)); tint_loop_idx.y = (tint_loop_idx.y - tint_carry); - i = (i + 1); + uint v_2 = uint(i); + i = int((v_2 + uint(1))); } continue; }
diff --git a/test/tint/statements/for/complex.wgsl.expected.spvasm b/test/tint/statements/for/complex.wgsl.expected.spvasm index 1619b7e..9de9a23 100644 --- a/test/tint/statements/for/complex.wgsl.expected.spvasm +++ b/test/tint/statements/for/complex.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 67 +; Bound: 73 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -68,8 +68,8 @@ OpSelectionMerge %35 None OpBranchConditional %33 %36 %37 %36 = OpLabel - %63 = OpLoad %int %j None - %39 = OpSLessThan %bool %63 %int_10 + %69 = OpLoad %int %j None + %39 = OpSLessThan %bool %69 %int_10 OpBranch %35 %37 = OpLabel OpBranch %35 @@ -82,30 +82,36 @@ %41 = OpLabel %43 = OpFunctionCall %void %some_loop_body %44 = OpLoad %int %i None - %45 = OpIMul %int %44 %int_30 - OpStore %j %45 None + %45 = OpBitcast %uint %44 + %46 = OpBitcast %uint %int_30 + %48 = OpIMul %uint %45 %46 + %49 = OpBitcast %int %48 + OpStore %j %49 None OpBranch %13 %13 = OpLabel - %47 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 - %50 = OpLoad %uint %47 None -%tint_low_inc = OpISub %uint %50 %uint_1 - %53 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 - OpStore %53 %tint_low_inc None - %54 = OpIEqual %bool %tint_low_inc %uint_4294967295 - %tint_carry = OpSelect %uint %54 %uint_1 %uint_0 - %56 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 - %57 = OpLoad %uint %56 None - %58 = OpISub %uint %57 %tint_carry + %50 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 + %53 = OpLoad %uint %50 None +%tint_low_inc = OpISub %uint %53 %uint_1 + %56 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 + OpStore %56 %tint_low_inc None + %57 = OpIEqual %bool %tint_low_inc %uint_4294967295 + %tint_carry = OpSelect %uint %57 %uint_1 %uint_0 %59 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 - OpStore %59 %58 None - %60 = OpLoad %int %i None - %61 = OpIAdd %int %60 %int_1 - OpStore %i %61 None + %60 = OpLoad %uint %59 None + %61 = OpISub %uint %60 %tint_carry + %62 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 + OpStore %62 %61 None + %63 = OpLoad %int %i None + %64 = OpBitcast %uint %63 + %65 = OpBitcast %uint %int_1 + %67 = OpIAdd %uint %64 %65 + %68 = OpBitcast %int %67 + OpStore %i %68 None OpBranch %14 %15 = OpLabel OpReturn OpFunctionEnd %unused_entry_point = OpFunction %void None %3 - %66 = OpLabel + %72 = OpLabel OpReturn OpFunctionEnd
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 5e66156..e06fdc8 100644 --- a/test/tint/statements/for/continuing/array_ctor.wgsl.expected.glsl +++ b/test/tint/statements/for/continuing/array_ctor.wgsl.expected.glsl
@@ -17,7 +17,8 @@ tint_loop_idx.x = tint_low_inc; uint tint_carry = uint((tint_low_inc == 4294967295u)); tint_loop_idx.y = (tint_loop_idx.y - tint_carry); - i = (i + 1); + uint v = uint(i); + i = int((v + uint(1))); } continue; }
diff --git a/test/tint/statements/for/continuing/array_ctor.wgsl.expected.spvasm b/test/tint/statements/for/continuing/array_ctor.wgsl.expected.spvasm index ffa6233..92785c8 100644 --- a/test/tint/statements/for/continuing/array_ctor.wgsl.expected.spvasm +++ b/test/tint/statements/for/continuing/array_ctor.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 49 +; Bound: 52 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -71,13 +71,16 @@ %43 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 OpStore %43 %42 None %44 = OpLoad %int %i None - %45 = OpIAdd %int %44 %int_1 - OpStore %i %45 None + %45 = OpBitcast %uint %44 + %46 = OpBitcast %uint %int_1 + %48 = OpIAdd %uint %45 %46 + %49 = OpBitcast %int %48 + OpStore %i %49 None OpBranch %12 %13 = OpLabel OpReturn OpFunctionEnd %unused_entry_point = OpFunction %void None %3 - %48 = OpLabel + %51 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/statements/for/continuing/basic.wgsl.expected.glsl b/test/tint/statements/for/continuing/basic.wgsl.expected.glsl index 5e66156..e06fdc8 100644 --- a/test/tint/statements/for/continuing/basic.wgsl.expected.glsl +++ b/test/tint/statements/for/continuing/basic.wgsl.expected.glsl
@@ -17,7 +17,8 @@ tint_loop_idx.x = tint_low_inc; uint tint_carry = uint((tint_low_inc == 4294967295u)); tint_loop_idx.y = (tint_loop_idx.y - tint_carry); - i = (i + 1); + uint v = uint(i); + i = int((v + uint(1))); } continue; }
diff --git a/test/tint/statements/for/continuing/basic.wgsl.expected.spvasm b/test/tint/statements/for/continuing/basic.wgsl.expected.spvasm index ffa6233..92785c8 100644 --- a/test/tint/statements/for/continuing/basic.wgsl.expected.spvasm +++ b/test/tint/statements/for/continuing/basic.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 49 +; Bound: 52 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -71,13 +71,16 @@ %43 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 OpStore %43 %42 None %44 = OpLoad %int %i None - %45 = OpIAdd %int %44 %int_1 - OpStore %i %45 None + %45 = OpBitcast %uint %44 + %46 = OpBitcast %uint %int_1 + %48 = OpIAdd %uint %45 %46 + %49 = OpBitcast %int %48 + OpStore %i %49 None OpBranch %12 %13 = OpLabel OpReturn OpFunctionEnd %unused_entry_point = OpFunction %void None %3 - %48 = OpLabel + %51 = OpLabel OpReturn OpFunctionEnd
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 ada6764..1ca2a12 100644 --- a/test/tint/statements/for/continuing/struct_ctor.wgsl.expected.glsl +++ b/test/tint/statements/for/continuing/struct_ctor.wgsl.expected.glsl
@@ -17,7 +17,8 @@ tint_loop_idx.x = tint_low_inc; uint tint_carry = uint((tint_low_inc == 4294967295u)); tint_loop_idx.y = (tint_loop_idx.y - tint_carry); - i = (i + 1); + uint v = uint(i); + i = int((v + uint(1))); } continue; }
diff --git a/test/tint/statements/for/continuing/struct_ctor.wgsl.expected.spvasm b/test/tint/statements/for/continuing/struct_ctor.wgsl.expected.spvasm index cf27d7b..9a24363 100644 --- a/test/tint/statements/for/continuing/struct_ctor.wgsl.expected.spvasm +++ b/test/tint/statements/for/continuing/struct_ctor.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 49 +; Bound: 52 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -72,13 +72,16 @@ %43 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 OpStore %43 %42 None %44 = OpLoad %int %i None - %45 = OpIAdd %int %44 %int_1 - OpStore %i %45 None + %45 = OpBitcast %uint %44 + %46 = OpBitcast %uint %int_1 + %48 = OpIAdd %uint %45 %46 + %49 = OpBitcast %int %48 + OpStore %i %49 None OpBranch %8 %9 = OpLabel OpReturn OpFunctionEnd %unused_entry_point = OpFunction %void None %3 - %48 = OpLabel + %51 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/statements/increment/complex.wgsl.expected.glsl b/test/tint/statements/increment/complex.wgsl.expected.glsl index 8d231e2..907e976 100644 --- a/test/tint/statements/increment/complex.wgsl.expected.glsl +++ b/test/tint/statements/increment/complex.wgsl.expected.glsl
@@ -43,8 +43,9 @@ uint v_6 = min(uint(v_3), v_5); uint v_7 = min(uint(v_4), 3u); int v_8 = idx3(); - int v_9 = (v_1.inner[v_6].a[v_7][min(uint(v_8), 3u)] + 1); - v_1.inner[v_6].a[v_7][min(uint(v_8), 3u)] = v_9; + uint v_9 = uint(v_1.inner[v_6].a[v_7][min(uint(v_8), 3u)]); + int v_10 = int((v_9 + uint(1))); + v_1.inner[v_6].a[v_7][min(uint(v_8), 3u)] = v_10; while(true) { if (all(equal(tint_loop_idx, uvec2(0u)))) { break; @@ -58,14 +59,15 @@ tint_loop_idx.x = tint_low_inc; uint tint_carry = uint((tint_low_inc == 4294967295u)); tint_loop_idx.y = (tint_loop_idx.y - tint_carry); - int v_10 = idx4(); - int v_11 = idx5(); - uint v_12 = (uint(v_1.inner.length()) - 1u); - uint v_13 = min(uint(v_10), v_12); - uint v_14 = min(uint(v_11), 3u); - int v_15 = idx6(); - int v_16 = (v_1.inner[v_13].a[v_14][min(uint(v_15), 3u)] + 1); - v_1.inner[v_13].a[v_14][min(uint(v_15), 3u)] = v_16; + int v_11 = idx4(); + int v_12 = idx5(); + uint v_13 = (uint(v_1.inner.length()) - 1u); + uint v_14 = min(uint(v_11), v_13); + uint v_15 = min(uint(v_12), 3u); + int v_16 = idx6(); + uint v_17 = uint(v_1.inner[v_14].a[v_15][min(uint(v_16), 3u)]); + int v_18 = int((v_17 + uint(1))); + v_1.inner[v_14].a[v_15][min(uint(v_16), 3u)] = v_18; } continue; }
diff --git a/test/tint/statements/increment/complex.wgsl.expected.spvasm b/test/tint/statements/increment/complex.wgsl.expected.spvasm index 5bcf359..c6b5b15 100644 --- a/test/tint/statements/increment/complex.wgsl.expected.spvasm +++ b/test/tint/statements/increment/complex.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 129 +; Bound: 135 ; Schema: 0 OpCapability Shader %68 = OpExtInstImport "GLSL.std.450" @@ -63,7 +63,7 @@ %uint_3 = OpConstant %uint 3 %_ptr_StorageBuffer_v4int = OpTypePointer StorageBuffer %v4int %_ptr_StorageBuffer_int = OpTypePointer StorageBuffer %int - %86 = OpConstantNull %v2uint + %89 = OpConstantNull %v2uint %bool = OpTypeBool %v2bool = OpTypeVector %bool 2 %uint_10 = OpConstant %uint 10 @@ -131,70 +131,76 @@ %76 = OpExtInst %uint %68 UMin %75 %uint_3 %77 = OpAccessChain %_ptr_StorageBuffer_int %72 %76 %79 = OpLoad %int %77 None - %80 = OpIAdd %int %79 %int_1 - %81 = OpBitcast %uint %74 - %82 = OpExtInst %uint %68 UMin %81 %uint_3 - %83 = OpAccessChain %_ptr_StorageBuffer_int %72 %82 - OpStore %83 %80 None + %80 = OpBitcast %uint %79 + %81 = OpBitcast %uint %int_1 + %82 = OpIAdd %uint %80 %81 + %83 = OpBitcast %int %82 + %84 = OpBitcast %uint %74 + %85 = OpExtInst %uint %68 UMin %84 %uint_3 + %86 = OpAccessChain %_ptr_StorageBuffer_int %72 %85 + OpStore %86 %83 None OpBranch %52 %52 = OpLabel OpLoopMerge %53 %51 None OpBranch %50 %50 = OpLabel - %84 = OpLoad %v2uint %tint_loop_idx None - %85 = OpIEqual %v2bool %84 %86 - %89 = OpAll %bool %85 - OpSelectionMerge %90 None - OpBranchConditional %89 %91 %90 - %91 = OpLabel + %87 = OpLoad %v2uint %tint_loop_idx None + %88 = OpIEqual %v2bool %87 %89 + %92 = OpAll %bool %88 + OpSelectionMerge %93 None + OpBranchConditional %92 %94 %93 + %94 = OpLabel OpBranch %53 - %90 = OpLabel - %92 = OpLoad %uint %v None - %93 = OpULessThan %bool %92 %uint_10 - OpSelectionMerge %95 None - OpBranchConditional %93 %95 %96 - %96 = OpLabel + %93 = OpLabel + %95 = OpLoad %uint %v None + %96 = OpULessThan %bool %95 %uint_10 + OpSelectionMerge %98 None + OpBranchConditional %96 %98 %99 + %99 = OpLabel OpBranch %53 - %95 = OpLabel + %98 = OpLabel OpBranch %51 %51 = OpLabel - %97 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 - %99 = OpLoad %uint %97 None -%tint_low_inc = OpISub %uint %99 %uint_1 - %101 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 - OpStore %101 %tint_low_inc None - %102 = OpIEqual %bool %tint_low_inc %uint_4294967295 - %tint_carry = OpSelect %uint %102 %uint_1 %uint_0 - %104 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 - %105 = OpLoad %uint %104 None - %106 = OpISub %uint %105 %tint_carry + %100 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 + %102 = OpLoad %uint %100 None +%tint_low_inc = OpISub %uint %102 %uint_1 + %104 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_0 + OpStore %104 %tint_low_inc None + %105 = OpIEqual %bool %tint_low_inc %uint_4294967295 + %tint_carry = OpSelect %uint %105 %uint_1 %uint_0 %107 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 - OpStore %107 %106 None - %108 = OpFunctionCall %int %idx4 - %109 = OpFunctionCall %int %idx5 - %110 = OpAccessChain %_ptr_StorageBuffer__runtimearr_S_tint_explicit_layout %1 %uint_0 - %111 = OpArrayLength %uint %1 0 - %112 = OpISub %uint %111 %uint_1 - %113 = OpBitcast %uint %108 - %114 = OpExtInst %uint %68 UMin %113 %112 - %115 = OpBitcast %uint %109 - %116 = OpExtInst %uint %68 UMin %115 %uint_3 - %117 = OpAccessChain %_ptr_StorageBuffer_v4int %1 %uint_0 %114 %uint_0 %116 - %118 = OpFunctionCall %int %idx6 - %119 = OpBitcast %uint %118 - %120 = OpExtInst %uint %68 UMin %119 %uint_3 - %121 = OpAccessChain %_ptr_StorageBuffer_int %117 %120 - %122 = OpLoad %int %121 None - %123 = OpIAdd %int %122 %int_1 - %124 = OpBitcast %uint %118 - %125 = OpExtInst %uint %68 UMin %124 %uint_3 - %126 = OpAccessChain %_ptr_StorageBuffer_int %117 %125 - OpStore %126 %123 None + %108 = OpLoad %uint %107 None + %109 = OpISub %uint %108 %tint_carry + %110 = OpAccessChain %_ptr_Function_uint %tint_loop_idx %uint_1 + OpStore %110 %109 None + %111 = OpFunctionCall %int %idx4 + %112 = OpFunctionCall %int %idx5 + %113 = OpAccessChain %_ptr_StorageBuffer__runtimearr_S_tint_explicit_layout %1 %uint_0 + %114 = OpArrayLength %uint %1 0 + %115 = OpISub %uint %114 %uint_1 + %116 = OpBitcast %uint %111 + %117 = OpExtInst %uint %68 UMin %116 %115 + %118 = OpBitcast %uint %112 + %119 = OpExtInst %uint %68 UMin %118 %uint_3 + %120 = OpAccessChain %_ptr_StorageBuffer_v4int %1 %uint_0 %117 %uint_0 %119 + %121 = OpFunctionCall %int %idx6 + %122 = OpBitcast %uint %121 + %123 = OpExtInst %uint %68 UMin %122 %uint_3 + %124 = OpAccessChain %_ptr_StorageBuffer_int %120 %123 + %125 = OpLoad %int %124 None + %126 = OpBitcast %uint %125 + %127 = OpBitcast %uint %int_1 + %128 = OpIAdd %uint %126 %127 + %129 = OpBitcast %int %128 + %130 = OpBitcast %uint %121 + %131 = OpExtInst %uint %68 UMin %130 %uint_3 + %132 = OpAccessChain %_ptr_StorageBuffer_int %120 %131 + OpStore %132 %129 None OpBranch %52 %53 = OpLabel OpReturn OpFunctionEnd %unused_entry_point = OpFunction %void None %47 - %128 = OpLabel + %134 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/statements/increment/function.wgsl.expected.glsl b/test/tint/statements/increment/function.wgsl.expected.glsl index f569c14..077e49c 100644 --- a/test/tint/statements/increment/function.wgsl.expected.glsl +++ b/test/tint/statements/increment/function.wgsl.expected.glsl
@@ -2,7 +2,8 @@ void v() { int i = 0; - i = (i + 1); + uint v_1 = uint(i); + i = int((v_1 + uint(1))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/statements/increment/function.wgsl.expected.spvasm b/test/tint/statements/increment/function.wgsl.expected.spvasm index f8796a5..1fe4994 100644 --- a/test/tint/statements/increment/function.wgsl.expected.spvasm +++ b/test/tint/statements/increment/function.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 14 +; Bound: 18 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -15,17 +15,21 @@ %int = OpTypeInt 32 1 %_ptr_Function_int = OpTypePointer Function %int %int_0 = OpConstant %int 0 + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %main = OpFunction %void None %3 %4 = OpLabel %i = OpVariable %_ptr_Function_int Function OpStore %i %int_0 %9 = OpLoad %int %i None - %10 = OpIAdd %int %9 %int_1 - OpStore %i %10 None + %11 = OpBitcast %uint %9 + %12 = OpBitcast %uint %int_1 + %14 = OpIAdd %uint %11 %12 + %15 = OpBitcast %int %14 + OpStore %i %15 None OpReturn OpFunctionEnd %unused_entry_point = OpFunction %void None %3 - %13 = OpLabel + %17 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/statements/increment/private.wgsl.expected.glsl b/test/tint/statements/increment/private.wgsl.expected.glsl index 447803f..1c39826 100644 --- a/test/tint/statements/increment/private.wgsl.expected.glsl +++ b/test/tint/statements/increment/private.wgsl.expected.glsl
@@ -2,7 +2,8 @@ int i = 0; void v() { - i = (i + 1); + uint v_1 = uint(i); + i = int((v_1 + uint(1))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/statements/increment/private.wgsl.expected.spvasm b/test/tint/statements/increment/private.wgsl.expected.spvasm index a4b1c84..0b775ff 100644 --- a/test/tint/statements/increment/private.wgsl.expected.spvasm +++ b/test/tint/statements/increment/private.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 14 +; Bound: 18 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -16,15 +16,19 @@ %i = OpVariable %_ptr_Private_int Private %int_0 %void = OpTypeVoid %7 = OpTypeFunction %void + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %main = OpFunction %void None %7 %8 = OpLabel %9 = OpLoad %int %i None - %10 = OpIAdd %int %9 %int_1 - OpStore %i %10 None + %11 = OpBitcast %uint %9 + %12 = OpBitcast %uint %int_1 + %14 = OpIAdd %uint %11 %12 + %15 = OpBitcast %int %14 + OpStore %i %15 None OpReturn OpFunctionEnd %unused_entry_point = OpFunction %void None %7 - %13 = OpLabel + %17 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/statements/increment/workgroup.wgsl.expected.glsl b/test/tint/statements/increment/workgroup.wgsl.expected.glsl index ea4092e..cd765640 100644 --- a/test/tint/statements/increment/workgroup.wgsl.expected.glsl +++ b/test/tint/statements/increment/workgroup.wgsl.expected.glsl
@@ -2,7 +2,8 @@ shared int i; void v() { - i = (i + 1); + uint v_1 = uint(i); + i = int((v_1 + uint(1))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() {
diff --git a/test/tint/statements/increment/workgroup.wgsl.expected.spvasm b/test/tint/statements/increment/workgroup.wgsl.expected.spvasm index dee4d3d..5290dba 100644 --- a/test/tint/statements/increment/workgroup.wgsl.expected.spvasm +++ b/test/tint/statements/increment/workgroup.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 13 +; Bound: 17 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -15,15 +15,19 @@ %i = OpVariable %_ptr_Workgroup_int Workgroup %void = OpTypeVoid %6 = OpTypeFunction %void + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %main = OpFunction %void None %6 %7 = OpLabel %8 = OpLoad %int %i None - %9 = OpIAdd %int %8 %int_1 - OpStore %i %9 None + %10 = OpBitcast %uint %8 + %11 = OpBitcast %uint %int_1 + %13 = OpIAdd %uint %10 %11 + %14 = OpBitcast %int %13 + OpStore %i %14 None OpReturn OpFunctionEnd %unused_entry_point = OpFunction %void None %6 - %12 = OpLabel + %16 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/struct/type_initializer.wgsl.expected.glsl b/test/tint/struct/type_initializer.wgsl.expected.glsl index 8828e88..3578302 100644 --- a/test/tint/struct/type_initializer.wgsl.expected.glsl +++ b/test/tint/struct/type_initializer.wgsl.expected.glsl
@@ -28,18 +28,23 @@ int x = 42; S1 empty = S1(0, 0, 0, 0); S1 nonempty = S1(1, 2, 3, 4); - S1 nonempty_with_expr = S1(1, x, (x + 1), nonempty.d); + uint v = uint(x); + S1 nonempty_with_expr = S1(1, x, int((v + uint(1))), nonempty.d); S3 nested_empty = S3(0, S1(0, 0, 0, 0), S2(0, S1(0, 0, 0, 0))); S3 nested_nonempty = S3(1, S1(2, 3, 4, 5), S2(6, S1(7, 8, 9, 10))); - S1 v = S1(2, x, (x + 1), nested_nonempty.i.f.d); - S3 nested_nonempty_with_expr = S3(1, v, S2(6, nonempty)); + uint v_1 = uint(x); + S1 v_2 = S1(2, x, int((v_1 + uint(1))), nested_nonempty.i.f.d); + S3 nested_nonempty_with_expr = S3(1, v_2, S2(6, nonempty)); int subexpr_empty = 0; int subexpr_nonempty = 2; - int subexpr_nonempty_with_expr = S1(1, x, (x + 1), nonempty.d).c; + uint v_3 = uint(x); + int subexpr_nonempty_with_expr = S1(1, x, int((v_3 + uint(1))), nonempty.d).c; S1 subexpr_nested_empty = S1(0, 0, 0, 0); S1 subexpr_nested_nonempty = S1(2, 3, 4, 5); - S1 subexpr_nested_nonempty_with_expr = S2(1, S1(2, x, (x + 1), nested_nonempty.i.f.d)).f; + uint v_4 = uint(x); + S1 subexpr_nested_nonempty_with_expr = S2(1, S1(2, x, int((v_4 + uint(1))), nested_nonempty.i.f.d)).f; T aosoa_empty[2] = T[2](T(int[2](0, 0)), T(int[2](0, 0))); T aosoa_nonempty[2] = T[2](T(int[2](1, 2)), T(int[2](3, 4))); - T aosoa_nonempty_with_expr[2] = T[2](T(int[2](1, (aosoa_nonempty[0u].a[0u] + 1))), aosoa_nonempty[1u]); + uint v_5 = uint(aosoa_nonempty[0u].a[0u]); + T aosoa_nonempty_with_expr[2] = T[2](T(int[2](1, int((v_5 + uint(1))))), aosoa_nonempty[1u]); }
diff --git a/test/tint/struct/type_initializer.wgsl.expected.spvasm b/test/tint/struct/type_initializer.wgsl.expected.spvasm index 885f128..b672c81 100644 --- a/test/tint/struct/type_initializer.wgsl.expected.spvasm +++ b/test/tint/struct/type_initializer.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 62 +; Bound: 77 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -49,6 +49,7 @@ %int_3 = OpConstant %int 3 %int_4 = OpConstant %int 4 %nonempty = OpConstantComposite %S1 %int_1 %subexpr_nonempty %int_3 %int_4 + %uint = OpTypeInt 32 0 %S2 = OpTypeStruct %int %S1 %S3 = OpTypeStruct %int %S1 %S2 %nested_empty = OpConstantNull %S3 @@ -59,45 +60,59 @@ %int_8 = OpConstant %int 8 %int_9 = OpConstant %int 9 %int_10 = OpConstant %int 10 - %25 = OpConstantComposite %S1 %int_7 %int_8 %int_9 %int_10 - %23 = OpConstantComposite %S2 %int_6 %25 -%nested_nonempty = OpConstantComposite %S3 %int_1 %subexpr_nested_nonempty %23 + %29 = OpConstantComposite %S1 %int_7 %int_8 %int_9 %int_10 + %27 = OpConstantComposite %S2 %int_6 %29 +%nested_nonempty = OpConstantComposite %S3 %int_1 %subexpr_nested_nonempty %27 %subexpr_empty = OpConstant %int 0 - %uint = OpTypeInt 32 0 %uint_2 = OpConstant %uint 2 %_arr_int_uint_2 = OpTypeArray %int %uint_2 %T = OpTypeStruct %_arr_int_uint_2 %_arr_T_uint_2 = OpTypeArray %T %uint_2 %aosoa_empty = OpConstantNull %_arr_T_uint_2 - %53 = OpConstantComposite %_arr_int_uint_2 %int_1 %subexpr_nonempty - %52 = OpConstantComposite %T %53 - %55 = OpConstantComposite %_arr_int_uint_2 %int_3 %int_4 - %54 = OpConstantComposite %T %55 -%aosoa_nonempty = OpConstantComposite %_arr_T_uint_2 %52 %54 + %65 = OpConstantComposite %_arr_int_uint_2 %int_1 %subexpr_nonempty + %64 = OpConstantComposite %T %65 + %67 = OpConstantComposite %_arr_int_uint_2 %int_3 %int_4 + %66 = OpConstantComposite %T %67 +%aosoa_nonempty = OpConstantComposite %_arr_T_uint_2 %64 %66 %main = OpFunction %void None %3 %4 = OpLabel - %14 = OpIAdd %int %x %int_1 - %15 = OpCompositeExtract %int %nonempty 3 -%nonempty_with_expr = OpCompositeConstruct %S1 %int_1 %x %14 %15 - %30 = OpIAdd %int %x %int_1 - %31 = OpCompositeExtract %int %nested_nonempty 2 1 3 - %32 = OpCompositeConstruct %S1 %subexpr_nonempty %x %30 %31 - %33 = OpCompositeConstruct %S2 %int_6 %nonempty -%nested_nonempty_with_expr = OpCompositeConstruct %S3 %int_1 %32 %33 - %36 = OpIAdd %int %x %int_1 - %37 = OpCompositeExtract %int %nonempty 3 - %38 = OpCompositeConstruct %S1 %int_1 %x %36 %37 -%subexpr_nonempty_with_expr = OpCompositeExtract %int %38 2 - %40 = OpIAdd %int %x %int_1 - %41 = OpCompositeExtract %int %nested_nonempty 2 1 3 - %42 = OpCompositeConstruct %S1 %subexpr_nonempty %x %40 %41 - %43 = OpCompositeConstruct %S2 %int_1 %42 -%subexpr_nested_nonempty_with_expr = OpCompositeExtract %S1 %43 1 - %56 = OpCompositeExtract %int %aosoa_nonempty 0 0 0 - %57 = OpIAdd %int %56 %int_1 - %58 = OpCompositeConstruct %_arr_int_uint_2 %int_1 %57 - %59 = OpCompositeConstruct %T %58 - %60 = OpCompositeExtract %T %aosoa_nonempty 1 -%aosoa_nonempty_with_expr = OpCompositeConstruct %_arr_T_uint_2 %59 %60 + %15 = OpBitcast %uint %x + %16 = OpBitcast %uint %int_1 + %17 = OpIAdd %uint %15 %16 + %18 = OpBitcast %int %17 + %19 = OpCompositeExtract %int %nonempty 3 +%nonempty_with_expr = OpCompositeConstruct %S1 %int_1 %x %18 %19 + %34 = OpBitcast %uint %x + %35 = OpBitcast %uint %int_1 + %36 = OpIAdd %uint %34 %35 + %37 = OpBitcast %int %36 + %38 = OpCompositeExtract %int %nested_nonempty 2 1 3 + %39 = OpCompositeConstruct %S1 %subexpr_nonempty %x %37 %38 + %40 = OpCompositeConstruct %S2 %int_6 %nonempty +%nested_nonempty_with_expr = OpCompositeConstruct %S3 %int_1 %39 %40 + %43 = OpBitcast %uint %x + %44 = OpBitcast %uint %int_1 + %45 = OpIAdd %uint %43 %44 + %46 = OpBitcast %int %45 + %47 = OpCompositeExtract %int %nonempty 3 + %48 = OpCompositeConstruct %S1 %int_1 %x %46 %47 +%subexpr_nonempty_with_expr = OpCompositeExtract %int %48 2 + %50 = OpBitcast %uint %x + %51 = OpBitcast %uint %int_1 + %52 = OpIAdd %uint %50 %51 + %53 = OpBitcast %int %52 + %54 = OpCompositeExtract %int %nested_nonempty 2 1 3 + %55 = OpCompositeConstruct %S1 %subexpr_nonempty %x %53 %54 + %56 = OpCompositeConstruct %S2 %int_1 %55 +%subexpr_nested_nonempty_with_expr = OpCompositeExtract %S1 %56 1 + %68 = OpCompositeExtract %int %aosoa_nonempty 0 0 0 + %69 = OpBitcast %uint %68 + %70 = OpBitcast %uint %int_1 + %71 = OpIAdd %uint %69 %70 + %72 = OpBitcast %int %71 + %73 = OpCompositeConstruct %_arr_int_uint_2 %int_1 %72 + %74 = OpCompositeConstruct %T %73 + %75 = OpCompositeExtract %T %aosoa_nonempty 1 +%aosoa_nonempty_with_expr = OpCompositeConstruct %_arr_T_uint_2 %74 %75 OpReturn OpFunctionEnd
diff --git a/test/tint/switch/switch.wgsl.expected.glsl b/test/tint/switch/switch.wgsl.expected.glsl index 1d966dd..a15f008 100644 --- a/test/tint/switch/switch.wgsl.expected.glsl +++ b/test/tint/switch/switch.wgsl.expected.glsl
@@ -13,7 +13,8 @@ } default: { - a_1 = (a_1 + 2); + uint v = uint(a_1); + a_1 = int((v + uint(2))); break; } }
diff --git a/test/tint/switch/switch.wgsl.expected.spvasm b/test/tint/switch/switch.wgsl.expected.spvasm index 2ec658b..2ced473 100644 --- a/test/tint/switch/switch.wgsl.expected.spvasm +++ b/test/tint/switch/switch.wgsl.expected.spvasm
@@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 19 +; Bound: 23 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -15,6 +15,7 @@ %int = OpTypeInt 32 1 %_ptr_Function_int = OpTypePointer Function %int %int_0 = OpConstant %int 0 + %uint = OpTypeInt 32 0 %int_2 = OpConstant %int 2 %a = OpFunction %void None %3 %4 = OpLabel @@ -25,8 +26,11 @@ OpSwitch %9 %10 0 %11 1 %12 %10 = OpLabel %14 = OpLoad %int %a_0 None - %15 = OpIAdd %int %14 %int_2 - OpStore %a_0 %15 None + %16 = OpBitcast %uint %14 + %17 = OpBitcast %uint %int_2 + %19 = OpIAdd %uint %16 %17 + %20 = OpBitcast %int %19 + OpStore %a_0 %20 None OpBranch %13 %11 = OpLabel OpBranch %13 @@ -36,6 +40,6 @@ OpReturn OpFunctionEnd %unused_entry_point = OpFunction %void None %3 - %18 = OpLabel + %22 = OpLabel OpReturn OpFunctionEnd
diff --git a/test/tint/var/uses/private.wgsl.expected.glsl b/test/tint/var/uses/private.wgsl.expected.glsl index cfcabf5..0c2aa45 100644 --- a/test/tint/var/uses/private.wgsl.expected.glsl +++ b/test/tint/var/uses/private.wgsl.expected.glsl
@@ -5,7 +5,8 @@ int a = 0; void uses_a() { - a = (a + 1); + uint v = uint(a); + a = int((v + uint(1))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { @@ -19,7 +20,8 @@ int b = 0; void uses_b() { - b = (b * 2); + uint v = uint(b); + b = int((v * uint(2))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { @@ -34,10 +36,12 @@ int a = 0; int b = 0; void uses_a() { - a = (a + 1); + uint v = uint(a); + a = int((v + uint(1))); } void uses_b() { - b = (b * 2); + uint v_1 = uint(b); + b = int((v_1 * uint(2))); } void uses_a_and_b() { b = a;
diff --git a/test/tint/var/uses/private.wgsl.expected.spvasm b/test/tint/var/uses/private.wgsl.expected.spvasm index ad1c8a7..33d5b74 100644 --- a/test/tint/var/uses/private.wgsl.expected.spvasm +++ b/test/tint/var/uses/private.wgsl.expected.spvasm
@@ -4,7 +4,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 16 +; Bound: 20 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -19,19 +19,23 @@ %a = OpVariable %_ptr_Private_int Private %4 %void = OpTypeVoid %7 = OpTypeFunction %void + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %int_42 = OpConstant %int 42 %uses_a = OpFunction %void None %7 %8 = OpLabel %9 = OpLoad %int %a None - %10 = OpIAdd %int %9 %int_1 - OpStore %a %10 None + %11 = OpBitcast %uint %9 + %12 = OpBitcast %uint %int_1 + %14 = OpIAdd %uint %11 %12 + %15 = OpBitcast %int %14 + OpStore %a %15 None OpReturn OpFunctionEnd %main1 = OpFunction %void None %7 - %13 = OpLabel + %17 = OpLabel OpStore %a %int_42 None - %15 = OpFunctionCall %void %uses_a + %19 = OpFunctionCall %void %uses_a OpReturn OpFunctionEnd ; @@ -40,7 +44,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 16 +; Bound: 20 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -55,19 +59,23 @@ %b = OpVariable %_ptr_Private_int Private %4 %void = OpTypeVoid %7 = OpTypeFunction %void + %uint = OpTypeInt 32 0 %int_2 = OpConstant %int 2 %int_7 = OpConstant %int 7 %uses_b = OpFunction %void None %7 %8 = OpLabel %9 = OpLoad %int %b None - %10 = OpIMul %int %9 %int_2 - OpStore %b %10 None + %11 = OpBitcast %uint %9 + %12 = OpBitcast %uint %int_2 + %14 = OpIMul %uint %11 %12 + %15 = OpBitcast %int %14 + OpStore %b %15 None OpReturn OpFunctionEnd %main2 = OpFunction %void None %7 - %13 = OpLabel + %17 = OpLabel OpStore %b %int_7 None - %15 = OpFunctionCall %void %uses_b + %19 = OpFunctionCall %void %uses_b OpReturn OpFunctionEnd ; @@ -76,7 +84,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 34 +; Bound: 41 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -97,46 +105,53 @@ %b = OpVariable %_ptr_Private_int Private %4 %void = OpTypeVoid %8 = OpTypeFunction %void + %uint = OpTypeInt 32 0 %int_1 = OpConstant %int 1 %int_2 = OpConstant %int 2 %int_0 = OpConstant %int 0 %uses_a = OpFunction %void None %8 %9 = OpLabel %10 = OpLoad %int %a None - %11 = OpIAdd %int %10 %int_1 - OpStore %a %11 None + %12 = OpBitcast %uint %10 + %13 = OpBitcast %uint %int_1 + %15 = OpIAdd %uint %12 %13 + %16 = OpBitcast %int %15 + OpStore %a %16 None OpReturn OpFunctionEnd %uses_b = OpFunction %void None %8 - %14 = OpLabel - %15 = OpLoad %int %b None - %16 = OpIMul %int %15 %int_2 - OpStore %b %16 None + %18 = OpLabel + %19 = OpLoad %int %b None + %20 = OpBitcast %uint %19 + %21 = OpBitcast %uint %int_2 + %23 = OpIMul %uint %20 %21 + %24 = OpBitcast %int %23 + OpStore %b %24 None OpReturn OpFunctionEnd %uses_a_and_b = OpFunction %void None %8 - %19 = OpLabel - %20 = OpLoad %int %a None - OpStore %b %20 None + %26 = OpLabel + %27 = OpLoad %int %a None + OpStore %b %27 None OpReturn OpFunctionEnd %no_uses = OpFunction %void None %8 - %22 = OpLabel + %29 = OpLabel OpReturn OpFunctionEnd %outer = OpFunction %void None %8 - %24 = OpLabel + %31 = OpLabel OpStore %a %int_0 None - %26 = OpFunctionCall %void %uses_a - %27 = OpFunctionCall %void %uses_a_and_b - %28 = OpFunctionCall %void %uses_b - %29 = OpFunctionCall %void %no_uses + %33 = OpFunctionCall %void %uses_a + %34 = OpFunctionCall %void %uses_a_and_b + %35 = OpFunctionCall %void %uses_b + %36 = OpFunctionCall %void %no_uses OpReturn OpFunctionEnd %main3 = OpFunction %void None %8 - %31 = OpLabel - %32 = OpFunctionCall %void %outer - %33 = OpFunctionCall %void %no_uses + %38 = OpLabel + %39 = OpFunctionCall %void %outer + %40 = OpFunctionCall %void %no_uses OpReturn OpFunctionEnd ;
diff --git a/test/tint/var/uses/workgroup.wgsl.expected.glsl b/test/tint/var/uses/workgroup.wgsl.expected.glsl index d487230..3a6e420 100644 --- a/test/tint/var/uses/workgroup.wgsl.expected.glsl +++ b/test/tint/var/uses/workgroup.wgsl.expected.glsl
@@ -5,7 +5,8 @@ shared int a; void uses_a() { - a = (a + 1); + uint v = uint(a); + a = int((v + uint(1))); } void main1_inner(uint tint_local_index) { if ((tint_local_index < 1u)) { @@ -26,7 +27,8 @@ shared int b; void uses_b() { - b = (b * 2); + uint v = uint(b); + b = int((v * uint(2))); } void main2_inner(uint tint_local_index) { if ((tint_local_index < 1u)) { @@ -48,10 +50,12 @@ shared int a; shared int b; void uses_a() { - a = (a + 1); + uint v = uint(a); + a = int((v + uint(1))); } void uses_b() { - b = (b * 2); + uint v_1 = uint(b); + b = int((v_1 * uint(2))); } void uses_a_and_b() { b = a;
diff --git a/test/tint/var/uses/workgroup.wgsl.expected.spvasm b/test/tint/var/uses/workgroup.wgsl.expected.spvasm index 6d86d8b..aeee50d 100644 --- a/test/tint/var/uses/workgroup.wgsl.expected.spvasm +++ b/test/tint/var/uses/workgroup.wgsl.expected.spvasm
@@ -4,7 +4,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 33 +; Bound: 36 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -26,7 +26,7 @@ %void = OpTypeVoid %9 = OpTypeFunction %void %int_1 = OpConstant %int 1 - %16 = OpTypeFunction %void %uint + %19 = OpTypeFunction %void %uint %uint_1 = OpConstant %uint 1 %bool = OpTypeBool %uint_2 = OpConstant %uint 2 @@ -36,29 +36,32 @@ %uses_a = OpFunction %void None %9 %10 = OpLabel %11 = OpLoad %int %a None - %12 = OpIAdd %int %11 %int_1 - OpStore %a %12 None + %12 = OpBitcast %uint %11 + %13 = OpBitcast %uint %int_1 + %15 = OpIAdd %uint %12 %13 + %16 = OpBitcast %int %15 + OpStore %a %16 None OpReturn OpFunctionEnd -%main1_inner = OpFunction %void None %16 +%main1_inner = OpFunction %void None %19 %tint_local_index = OpFunctionParameter %uint - %17 = OpLabel - %18 = OpULessThan %bool %tint_local_index %uint_1 - OpSelectionMerge %21 None - OpBranchConditional %18 %22 %21 - %22 = OpLabel + %20 = OpLabel + %21 = OpULessThan %bool %tint_local_index %uint_1 + OpSelectionMerge %24 None + OpBranchConditional %21 %25 %24 + %25 = OpLabel OpStore %a %int_0 None - OpBranch %21 - %21 = OpLabel + OpBranch %24 + %24 = OpLabel OpControlBarrier %uint_2 %uint_2 %uint_264 OpStore %a %int_42 None - %27 = OpFunctionCall %void %uses_a + %30 = OpFunctionCall %void %uses_a OpReturn OpFunctionEnd %main1 = OpFunction %void None %9 - %30 = OpLabel - %31 = OpLoad %uint %main1_local_invocation_index_Input None - %32 = OpFunctionCall %void %main1_inner %31 + %33 = OpLabel + %34 = OpLoad %uint %main1_local_invocation_index_Input None + %35 = OpFunctionCall %void %main1_inner %34 OpReturn OpFunctionEnd ; @@ -67,7 +70,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 33 +; Bound: 36 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -89,7 +92,7 @@ %void = OpTypeVoid %9 = OpTypeFunction %void %int_2 = OpConstant %int 2 - %16 = OpTypeFunction %void %uint + %19 = OpTypeFunction %void %uint %uint_1 = OpConstant %uint 1 %bool = OpTypeBool %uint_2 = OpConstant %uint 2 @@ -99,29 +102,32 @@ %uses_b = OpFunction %void None %9 %10 = OpLabel %11 = OpLoad %int %b None - %12 = OpIMul %int %11 %int_2 - OpStore %b %12 None + %12 = OpBitcast %uint %11 + %13 = OpBitcast %uint %int_2 + %15 = OpIMul %uint %12 %13 + %16 = OpBitcast %int %15 + OpStore %b %16 None OpReturn OpFunctionEnd -%main2_inner = OpFunction %void None %16 +%main2_inner = OpFunction %void None %19 %tint_local_index = OpFunctionParameter %uint - %17 = OpLabel - %18 = OpULessThan %bool %tint_local_index %uint_1 - OpSelectionMerge %21 None - OpBranchConditional %18 %22 %21 - %22 = OpLabel + %20 = OpLabel + %21 = OpULessThan %bool %tint_local_index %uint_1 + OpSelectionMerge %24 None + OpBranchConditional %21 %25 %24 + %25 = OpLabel OpStore %b %int_0 None - OpBranch %21 - %21 = OpLabel + OpBranch %24 + %24 = OpLabel OpControlBarrier %uint_2 %uint_2 %uint_264 OpStore %b %int_7 None - %27 = OpFunctionCall %void %uses_b + %30 = OpFunctionCall %void %uses_b OpReturn OpFunctionEnd %main2 = OpFunction %void None %9 - %30 = OpLabel - %31 = OpLoad %uint %main2_local_invocation_index_Input None - %32 = OpFunctionCall %void %main2_inner %31 + %33 = OpLabel + %34 = OpLoad %uint %main2_local_invocation_index_Input None + %35 = OpFunctionCall %void %main2_inner %34 OpReturn OpFunctionEnd ; @@ -130,7 +136,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 1 -; Bound: 50 +; Bound: 56 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -160,7 +166,7 @@ %int_1 = OpConstant %int 1 %int_2 = OpConstant %int 2 %int_0 = OpConstant %int 0 - %34 = OpTypeFunction %void %uint + %40 = OpTypeFunction %void %uint %uint_1 = OpConstant %uint 1 %bool = OpTypeBool %uint_2 = OpConstant %uint 2 @@ -168,56 +174,62 @@ %uses_a = OpFunction %void None %10 %11 = OpLabel %12 = OpLoad %int %a None - %13 = OpIAdd %int %12 %int_1 - OpStore %a %13 None + %13 = OpBitcast %uint %12 + %14 = OpBitcast %uint %int_1 + %16 = OpIAdd %uint %13 %14 + %17 = OpBitcast %int %16 + OpStore %a %17 None OpReturn OpFunctionEnd %uses_b = OpFunction %void None %10 - %16 = OpLabel - %17 = OpLoad %int %b None - %18 = OpIMul %int %17 %int_2 - OpStore %b %18 None + %19 = OpLabel + %20 = OpLoad %int %b None + %21 = OpBitcast %uint %20 + %22 = OpBitcast %uint %int_2 + %24 = OpIMul %uint %21 %22 + %25 = OpBitcast %int %24 + OpStore %b %25 None OpReturn OpFunctionEnd %uses_a_and_b = OpFunction %void None %10 - %21 = OpLabel - %22 = OpLoad %int %a None - OpStore %b %22 None + %27 = OpLabel + %28 = OpLoad %int %a None + OpStore %b %28 None OpReturn OpFunctionEnd %no_uses = OpFunction %void None %10 - %24 = OpLabel + %30 = OpLabel OpReturn OpFunctionEnd %outer = OpFunction %void None %10 - %26 = OpLabel + %32 = OpLabel OpStore %a %int_0 None - %28 = OpFunctionCall %void %uses_a - %29 = OpFunctionCall %void %uses_a_and_b - %30 = OpFunctionCall %void %uses_b - %31 = OpFunctionCall %void %no_uses + %34 = OpFunctionCall %void %uses_a + %35 = OpFunctionCall %void %uses_a_and_b + %36 = OpFunctionCall %void %uses_b + %37 = OpFunctionCall %void %no_uses OpReturn OpFunctionEnd -%main3_inner = OpFunction %void None %34 +%main3_inner = OpFunction %void None %40 %tint_local_index = OpFunctionParameter %uint - %35 = OpLabel - %36 = OpULessThan %bool %tint_local_index %uint_1 - OpSelectionMerge %39 None - OpBranchConditional %36 %40 %39 - %40 = OpLabel + %41 = OpLabel + %42 = OpULessThan %bool %tint_local_index %uint_1 + OpSelectionMerge %45 None + OpBranchConditional %42 %46 %45 + %46 = OpLabel OpStore %a %int_0 None OpStore %b %int_0 None - OpBranch %39 - %39 = OpLabel + OpBranch %45 + %45 = OpLabel OpControlBarrier %uint_2 %uint_2 %uint_264 - %44 = OpFunctionCall %void %outer - %45 = OpFunctionCall %void %no_uses + %50 = OpFunctionCall %void %outer + %51 = OpFunctionCall %void %no_uses OpReturn OpFunctionEnd %main3 = OpFunction %void None %10 - %47 = OpLabel - %48 = OpLoad %uint %main3_local_invocation_index_Input None - %49 = OpFunctionCall %void %main3_inner %48 + %53 = OpLabel + %54 = OpLoad %uint %main3_local_invocation_index_Input None + %55 = OpFunctionCall %void %main3_inner %54 OpReturn OpFunctionEnd ;