From 02f04d914d21b30fdda5d69dea08076043be36de Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Thu, 3 Nov 2022 19:15:17 +0000 Subject: [PATCH] tint/transform: Polyfill bit-shift with RHS modulo Fixed: tint:1453 Fixed: tint:1543 Change-Id: Idb5af752d7a3bb9e181cc47430ad4ddfb707873d Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108440 Auto-Submit: Ben Clayton Kokoro: Kokoro Commit-Queue: Ben Clayton Reviewed-by: Dan Sinclair --- src/tint/transform/builtin_polyfill.cc | 239 ++++++++++-------- src/tint/transform/builtin_polyfill.h | 4 +- src/tint/transform/builtin_polyfill_test.cc | 139 ++++++++++ src/tint/writer/glsl/generator_impl.cc | 1 + src/tint/writer/hlsl/generator_impl.cc | 1 + src/tint/writer/msl/generator_impl.cc | 1 + src/tint/writer/spirv/generator_impl.cc | 1 + .../scalar-scalar/i32.wgsl.expected.dxc.hlsl | 2 +- .../scalar-scalar/i32.wgsl.expected.fxc.hlsl | 2 +- .../scalar-scalar/i32.wgsl.expected.glsl | 2 +- .../scalar-scalar/i32.wgsl.expected.msl | 2 +- .../scalar-scalar/i32.wgsl.expected.spvasm | 6 +- .../scalar-scalar/u32.wgsl.expected.dxc.hlsl | 2 +- .../scalar-scalar/u32.wgsl.expected.fxc.hlsl | 2 +- .../scalar-scalar/u32.wgsl.expected.glsl | 2 +- .../scalar-scalar/u32.wgsl.expected.msl | 2 +- .../scalar-scalar/u32.wgsl.expected.spvasm | 6 +- .../vector-vector/i32.wgsl.expected.dxc.hlsl | 2 +- .../vector-vector/i32.wgsl.expected.fxc.hlsl | 2 +- .../vector-vector/i32.wgsl.expected.glsl | 2 +- .../vector-vector/i32.wgsl.expected.msl | 2 +- .../vector-vector/i32.wgsl.expected.spvasm | 7 +- .../vector-vector/u32.wgsl.expected.dxc.hlsl | 2 +- .../vector-vector/u32.wgsl.expected.fxc.hlsl | 2 +- .../vector-vector/u32.wgsl.expected.glsl | 2 +- .../vector-vector/u32.wgsl.expected.msl | 2 +- .../vector-vector/u32.wgsl.expected.spvasm | 7 +- .../scalar-scalar/i32.wgsl.expected.dxc.hlsl | 2 +- .../scalar-scalar/i32.wgsl.expected.fxc.hlsl | 2 +- .../scalar-scalar/i32.wgsl.expected.glsl | 2 +- .../scalar-scalar/i32.wgsl.expected.msl | 2 +- .../scalar-scalar/i32.wgsl.expected.spvasm | 6 +- .../scalar-scalar/u32.wgsl.expected.dxc.hlsl | 2 +- .../scalar-scalar/u32.wgsl.expected.fxc.hlsl | 2 +- .../scalar-scalar/u32.wgsl.expected.glsl | 2 +- .../scalar-scalar/u32.wgsl.expected.msl | 2 +- .../scalar-scalar/u32.wgsl.expected.spvasm | 6 +- .../vector-vector/i32.wgsl.expected.dxc.hlsl | 2 +- .../vector-vector/i32.wgsl.expected.fxc.hlsl | 2 +- .../vector-vector/i32.wgsl.expected.glsl | 2 +- .../vector-vector/i32.wgsl.expected.msl | 2 +- .../vector-vector/i32.wgsl.expected.spvasm | 7 +- .../vector-vector/u32.wgsl.expected.dxc.hlsl | 2 +- .../vector-vector/u32.wgsl.expected.fxc.hlsl | 2 +- .../vector-vector/u32.wgsl.expected.glsl | 2 +- .../vector-vector/u32.wgsl.expected.msl | 2 +- .../vector-vector/u32.wgsl.expected.spvasm | 7 +- 47 files changed, 345 insertions(+), 157 deletions(-) diff --git a/src/tint/transform/builtin_polyfill.cc b/src/tint/transform/builtin_polyfill.cc index db200e4ce9..e80436d0d8 100644 --- a/src/tint/transform/builtin_polyfill.cc +++ b/src/tint/transform/builtin_polyfill.cc @@ -614,7 +614,7 @@ Transform::ApplyResult BuiltinPolyfill::Apply(const Program* src, auto& builtins = cfg->builtins; - utils::Hashmap polyfills; + utils::Hashmap builtin_polyfills; ProgramBuilder b; CloneContext ctx{&b, src, /* auto_clone_symbols */ true}; @@ -622,114 +622,137 @@ Transform::ApplyResult BuiltinPolyfill::Apply(const Program* src, bool made_changes = false; for (auto* node : src->ASTNodes().Objects()) { - if (auto* call = src->Sem().Get(node)) { - if (auto* builtin = call->Target()->As()) { - if (call->Stage() == sem::EvaluationStage::kConstant) { - continue; // Don't polyfill @const expressions - } - Symbol polyfill; - switch (builtin->Type()) { - case sem::BuiltinType::kAcosh: - if (builtins.acosh != Level::kNone) { - polyfill = polyfills.GetOrCreate( - builtin, [&] { return s.acosh(builtin->ReturnType()); }); - } - break; - case sem::BuiltinType::kAsinh: - if (builtins.asinh) { - polyfill = polyfills.GetOrCreate( - builtin, [&] { return s.asinh(builtin->ReturnType()); }); - } - break; - case sem::BuiltinType::kAtanh: - if (builtins.atanh != Level::kNone) { - polyfill = polyfills.GetOrCreate( - builtin, [&] { return s.atanh(builtin->ReturnType()); }); - } - break; - case sem::BuiltinType::kClamp: - if (builtins.clamp_int) { - auto& sig = builtin->Signature(); - if (sig.parameters[0]->Type()->is_integer_scalar_or_vector()) { - polyfill = polyfills.GetOrCreate( - builtin, [&] { return s.clampInteger(builtin->ReturnType()); }); - } - } - break; - case sem::BuiltinType::kCountLeadingZeros: - if (builtins.count_leading_zeros) { - polyfill = polyfills.GetOrCreate(builtin, [&] { - return s.countLeadingZeros(builtin->ReturnType()); - }); - } - break; - case sem::BuiltinType::kCountTrailingZeros: - if (builtins.count_trailing_zeros) { - polyfill = polyfills.GetOrCreate(builtin, [&] { - return s.countTrailingZeros(builtin->ReturnType()); - }); - } - break; - case sem::BuiltinType::kExtractBits: - if (builtins.extract_bits != Level::kNone) { - polyfill = polyfills.GetOrCreate( - builtin, [&] { return s.extractBits(builtin->ReturnType()); }); - } - break; - case sem::BuiltinType::kFirstLeadingBit: - if (builtins.first_leading_bit) { - polyfill = polyfills.GetOrCreate( - builtin, [&] { return s.firstLeadingBit(builtin->ReturnType()); }); - } - break; - case sem::BuiltinType::kFirstTrailingBit: - if (builtins.first_trailing_bit) { - polyfill = polyfills.GetOrCreate( - builtin, [&] { return s.firstTrailingBit(builtin->ReturnType()); }); - } - break; - case sem::BuiltinType::kInsertBits: - if (builtins.insert_bits != Level::kNone) { - polyfill = polyfills.GetOrCreate( - builtin, [&] { return s.insertBits(builtin->ReturnType()); }); - } - break; - case sem::BuiltinType::kSaturate: - if (builtins.saturate) { - polyfill = polyfills.GetOrCreate( - builtin, [&] { return s.saturate(builtin->ReturnType()); }); - } - break; - case sem::BuiltinType::kTextureSampleBaseClampToEdge: - if (builtins.texture_sample_base_clamp_to_edge_2d_f32) { - auto& sig = builtin->Signature(); - auto* tex = sig.Parameter(sem::ParameterUsage::kTexture); - if (auto* stex = tex->Type()->As()) { - if (stex->type()->Is()) { - polyfill = polyfills.GetOrCreate(builtin, [&] { - return s.textureSampleBaseClampToEdge_2d_f32(); - }); - } - } - } - break; - case sem::BuiltinType::kQuantizeToF16: - if (builtins.quantize_to_vec_f16) { - if (auto* vec = builtin->ReturnType()->As()) { - polyfill = polyfills.GetOrCreate( - builtin, [&] { return s.quantizeToF16(vec); }); - } - } - break; + auto* expr = src->Sem().Get(node); + if (!expr || expr->Stage() == sem::EvaluationStage::kConstant) { + continue; // Don't polyfill @const expressions + } - default: - break; - } - if (polyfill.IsValid()) { - auto* replacement = s.b.Call(polyfill, ctx.Clone(call->Declaration()->args)); - ctx.Replace(call->Declaration(), replacement); - made_changes = true; - } + if (auto* call = expr->As()) { + auto* builtin = call->Target()->As(); + if (!builtin) { + continue; + } + Symbol polyfill; + switch (builtin->Type()) { + case sem::BuiltinType::kAcosh: + if (builtins.acosh != Level::kNone) { + polyfill = builtin_polyfills.GetOrCreate( + builtin, [&] { return s.acosh(builtin->ReturnType()); }); + } + break; + case sem::BuiltinType::kAsinh: + if (builtins.asinh) { + polyfill = builtin_polyfills.GetOrCreate( + builtin, [&] { return s.asinh(builtin->ReturnType()); }); + } + break; + case sem::BuiltinType::kAtanh: + if (builtins.atanh != Level::kNone) { + polyfill = builtin_polyfills.GetOrCreate( + builtin, [&] { return s.atanh(builtin->ReturnType()); }); + } + break; + case sem::BuiltinType::kClamp: + if (builtins.clamp_int) { + auto& sig = builtin->Signature(); + if (sig.parameters[0]->Type()->is_integer_scalar_or_vector()) { + polyfill = builtin_polyfills.GetOrCreate( + builtin, [&] { return s.clampInteger(builtin->ReturnType()); }); + } + } + break; + case sem::BuiltinType::kCountLeadingZeros: + if (builtins.count_leading_zeros) { + polyfill = builtin_polyfills.GetOrCreate( + builtin, [&] { return s.countLeadingZeros(builtin->ReturnType()); }); + } + break; + case sem::BuiltinType::kCountTrailingZeros: + if (builtins.count_trailing_zeros) { + polyfill = builtin_polyfills.GetOrCreate( + builtin, [&] { return s.countTrailingZeros(builtin->ReturnType()); }); + } + break; + case sem::BuiltinType::kExtractBits: + if (builtins.extract_bits != Level::kNone) { + polyfill = builtin_polyfills.GetOrCreate( + builtin, [&] { return s.extractBits(builtin->ReturnType()); }); + } + break; + case sem::BuiltinType::kFirstLeadingBit: + if (builtins.first_leading_bit) { + polyfill = builtin_polyfills.GetOrCreate( + builtin, [&] { return s.firstLeadingBit(builtin->ReturnType()); }); + } + break; + case sem::BuiltinType::kFirstTrailingBit: + if (builtins.first_trailing_bit) { + polyfill = builtin_polyfills.GetOrCreate( + builtin, [&] { return s.firstTrailingBit(builtin->ReturnType()); }); + } + break; + case sem::BuiltinType::kInsertBits: + if (builtins.insert_bits != Level::kNone) { + polyfill = builtin_polyfills.GetOrCreate( + builtin, [&] { return s.insertBits(builtin->ReturnType()); }); + } + break; + case sem::BuiltinType::kSaturate: + if (builtins.saturate) { + polyfill = builtin_polyfills.GetOrCreate( + builtin, [&] { return s.saturate(builtin->ReturnType()); }); + } + break; + case sem::BuiltinType::kTextureSampleBaseClampToEdge: + if (builtins.texture_sample_base_clamp_to_edge_2d_f32) { + auto& sig = builtin->Signature(); + auto* tex = sig.Parameter(sem::ParameterUsage::kTexture); + if (auto* stex = tex->Type()->As()) { + if (stex->type()->Is()) { + polyfill = builtin_polyfills.GetOrCreate(builtin, [&] { + return s.textureSampleBaseClampToEdge_2d_f32(); + }); + } + } + } + break; + case sem::BuiltinType::kQuantizeToF16: + if (builtins.quantize_to_vec_f16) { + if (auto* vec = builtin->ReturnType()->As()) { + polyfill = builtin_polyfills.GetOrCreate( + builtin, [&] { return s.quantizeToF16(vec); }); + } + } + break; + + default: + break; + } + + if (polyfill.IsValid()) { + auto* replacement = s.b.Call(polyfill, ctx.Clone(call->Declaration()->args)); + ctx.Replace(call->Declaration(), replacement); + made_changes = true; + } + } else if (auto* bin_op = node->As()) { + switch (bin_op->op) { + case ast::BinaryOp::kShiftLeft: + case ast::BinaryOp::kShiftRight: + if (builtins.bitshift_modulo) { + auto* lhs_ty = src->TypeOf(bin_op->lhs)->UnwrapRef(); + auto* rhs_ty = src->TypeOf(bin_op->rhs)->UnwrapRef(); + auto* lhs_el_ty = sem::Type::DeepestElementOf(lhs_ty); + const ast::Expression* mask = b.Expr(AInt(lhs_el_ty->Size() * 8 - 1)); + if (rhs_ty->Is()) { + mask = b.Construct(CreateASTTypeFor(ctx, rhs_ty), mask); + } + auto* mod = b.And(ctx.Clone(bin_op->rhs), mask); + ctx.Replace(bin_op->rhs, mod); + made_changes = true; + } + break; + default: + break; } } } diff --git a/src/tint/transform/builtin_polyfill.h b/src/tint/transform/builtin_polyfill.h index 231d753571..7083aa7f23 100644 --- a/src/tint/transform/builtin_polyfill.h +++ b/src/tint/transform/builtin_polyfill.h @@ -47,6 +47,8 @@ class BuiltinPolyfill final : public Castable { bool asinh = false; /// What level should `atanh` be polyfilled? Level atanh = Level::kNone; + /// Should the RHS of `<<` and `>>` be wrapped in a modulo bit-width of LHS? + bool bitshift_modulo = false; /// Should `clamp()` be polyfilled for integer values (scalar or vector)? bool clamp_int = false; /// Should `countLeadingZeros()` be polyfilled? @@ -66,7 +68,7 @@ class BuiltinPolyfill final : public Castable { /// Should `textureSampleBaseClampToEdge()` be polyfilled for texture_2d textures? bool texture_sample_base_clamp_to_edge_2d_f32 = false; /// Should the vector form of `quantizeToF16()` be polyfilled with a scalar implementation? - /// See crbug.com/tint/1741 + /// See crbug.com/tint/1741 bool quantize_to_vec_f16 = false; }; diff --git a/src/tint/transform/builtin_polyfill_test.cc b/src/tint/transform/builtin_polyfill_test.cc index 4bff0ff974..3b7a42c5f2 100644 --- a/src/tint/transform/builtin_polyfill_test.cc +++ b/src/tint/transform/builtin_polyfill_test.cc @@ -398,6 +398,145 @@ fn f() { EXPECT_EQ(expect, str(got)); } +//////////////////////////////////////////////////////////////////////////////// +// bitshiftModulo +//////////////////////////////////////////////////////////////////////////////// +DataMap polyfillBitshiftModulo() { + BuiltinPolyfill::Builtins builtins; + builtins.bitshift_modulo = true; + DataMap data; + data.Add(builtins); + return data; +} + +TEST_F(BuiltinPolyfillTest, ShouldRunBitshiftModulo_shl_scalar) { + auto* src = R"( +fn f() { + let v = 15u; + let r = 1i << v; +} +)"; + + EXPECT_FALSE(ShouldRun(src)); + EXPECT_TRUE(ShouldRun(src, polyfillBitshiftModulo())); +} + +TEST_F(BuiltinPolyfillTest, ShouldRunBitshiftModulo_shl_vector) { + auto* src = R"( +fn f() { + let v = 15u; + let r = vec3(1i) << vec3(v); +} +)"; + + EXPECT_FALSE(ShouldRun(src)); + EXPECT_TRUE(ShouldRun(src, polyfillBitshiftModulo())); +} + +TEST_F(BuiltinPolyfillTest, ShouldRunBitshiftModulo_shr_scalar) { + auto* src = R"( +fn f() { + let v = 15u; + let r = 1i >> v; +} +)"; + + EXPECT_FALSE(ShouldRun(src)); + EXPECT_TRUE(ShouldRun(src, polyfillBitshiftModulo())); +} + +TEST_F(BuiltinPolyfillTest, ShouldRunBitshiftModulo_shr_vector) { + auto* src = R"( +fn f() { + let v = 15u; + let r = vec3(1i) >> vec3(v); +} +)"; + + EXPECT_FALSE(ShouldRun(src)); + EXPECT_TRUE(ShouldRun(src, polyfillBitshiftModulo())); +} + +TEST_F(BuiltinPolyfillTest, BitshiftModulo_shl_scalar) { + auto* src = R"( +fn f() { + let v = 15u; + let r = 1i << v; +} +)"; + + auto* expect = R"( +fn f() { + let v = 15u; + let r = (1i << (v & 31)); +} +)"; + + auto got = Run(src, polyfillBitshiftModulo()); + + EXPECT_EQ(expect, str(got)); +} + +TEST_F(BuiltinPolyfillTest, BitshiftModulo_shl_vector) { + auto* src = R"( +fn f() { + let v = 15u; + let r = vec3(1i) << vec3(v); +} +)"; + + auto* expect = R"( +fn f() { + let v = 15u; + let r = (vec3(1i) << (vec3(v) & vec3(31))); +} +)"; + + auto got = Run(src, polyfillBitshiftModulo()); + + EXPECT_EQ(expect, str(got)); +} + +TEST_F(BuiltinPolyfillTest, BitshiftModulo_shr_scalar) { + auto* src = R"( +fn f() { + let v = 15u; + let r = 1i >> v; +} +)"; + + auto* expect = R"( +fn f() { + let v = 15u; + let r = (1i >> (v & 31)); +} +)"; + + auto got = Run(src, polyfillBitshiftModulo()); + + EXPECT_EQ(expect, str(got)); +} + +TEST_F(BuiltinPolyfillTest, BitshiftModulo_shr_vector) { + auto* src = R"( +fn f() { + let v = 15u; + let r = vec3(1i) >> vec3(v); +} +)"; + + auto* expect = R"( +fn f() { + let v = 15u; + let r = (vec3(1i) >> (vec3(v) & vec3(31))); +} +)"; + + auto got = Run(src, polyfillBitshiftModulo()); + + EXPECT_EQ(expect, str(got)); +} + //////////////////////////////////////////////////////////////////////////////// // clampInteger //////////////////////////////////////////////////////////////////////////////// diff --git a/src/tint/writer/glsl/generator_impl.cc b/src/tint/writer/glsl/generator_impl.cc index a48d71b60d..50cdbcf716 100644 --- a/src/tint/writer/glsl/generator_impl.cc +++ b/src/tint/writer/glsl/generator_impl.cc @@ -186,6 +186,7 @@ SanitizedResult Sanitize(const Program* in, transform::BuiltinPolyfill::Builtins polyfills; polyfills.acosh = transform::BuiltinPolyfill::Level::kRangeCheck; polyfills.atanh = transform::BuiltinPolyfill::Level::kRangeCheck; + polyfills.bitshift_modulo = true; polyfills.count_leading_zeros = true; polyfills.count_trailing_zeros = true; polyfills.extract_bits = transform::BuiltinPolyfill::Level::kClampParameters; diff --git a/src/tint/writer/hlsl/generator_impl.cc b/src/tint/writer/hlsl/generator_impl.cc index 248da3807e..92e0cc5595 100644 --- a/src/tint/writer/hlsl/generator_impl.cc +++ b/src/tint/writer/hlsl/generator_impl.cc @@ -162,6 +162,7 @@ SanitizedResult Sanitize(const Program* in, const Options& options) { polyfills.acosh = transform::BuiltinPolyfill::Level::kFull; polyfills.asinh = true; polyfills.atanh = transform::BuiltinPolyfill::Level::kFull; + polyfills.bitshift_modulo = true; polyfills.clamp_int = true; // TODO(crbug.com/tint/1449): Some of these can map to HLSL's `firstbitlow` // and `firstbithigh`. diff --git a/src/tint/writer/msl/generator_impl.cc b/src/tint/writer/msl/generator_impl.cc index 2cdbbf9202..65b52756e5 100644 --- a/src/tint/writer/msl/generator_impl.cc +++ b/src/tint/writer/msl/generator_impl.cc @@ -171,6 +171,7 @@ SanitizedResult Sanitize(const Program* in, const Options& options) { transform::BuiltinPolyfill::Builtins polyfills; polyfills.acosh = transform::BuiltinPolyfill::Level::kRangeCheck; polyfills.atanh = transform::BuiltinPolyfill::Level::kRangeCheck; + polyfills.bitshift_modulo = true; // crbug.com/tint/1543 polyfills.clamp_int = true; polyfills.extract_bits = transform::BuiltinPolyfill::Level::kClampParameters; polyfills.first_leading_bit = true; diff --git a/src/tint/writer/spirv/generator_impl.cc b/src/tint/writer/spirv/generator_impl.cc index 44744eaa97..aa5d4493f8 100644 --- a/src/tint/writer/spirv/generator_impl.cc +++ b/src/tint/writer/spirv/generator_impl.cc @@ -52,6 +52,7 @@ SanitizedResult Sanitize(const Program* in, const Options& options) { transform::BuiltinPolyfill::Builtins polyfills; polyfills.acosh = transform::BuiltinPolyfill::Level::kRangeCheck; polyfills.atanh = transform::BuiltinPolyfill::Level::kRangeCheck; + polyfills.bitshift_modulo = true; polyfills.clamp_int = true; polyfills.count_leading_zeros = true; polyfills.count_trailing_zeros = true; diff --git a/test/tint/expressions/binary/left-shift/scalar-scalar/i32.wgsl.expected.dxc.hlsl b/test/tint/expressions/binary/left-shift/scalar-scalar/i32.wgsl.expected.dxc.hlsl index 50ecc21231..0b8fc7b7ff 100644 --- a/test/tint/expressions/binary/left-shift/scalar-scalar/i32.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/binary/left-shift/scalar-scalar/i32.wgsl.expected.dxc.hlsl @@ -2,6 +2,6 @@ void f() { const int a = 1; const uint b = 2u; - const int r = (a << b); + const int r = (a << (b & 31u)); return; } diff --git a/test/tint/expressions/binary/left-shift/scalar-scalar/i32.wgsl.expected.fxc.hlsl b/test/tint/expressions/binary/left-shift/scalar-scalar/i32.wgsl.expected.fxc.hlsl index 50ecc21231..0b8fc7b7ff 100644 --- a/test/tint/expressions/binary/left-shift/scalar-scalar/i32.wgsl.expected.fxc.hlsl +++ b/test/tint/expressions/binary/left-shift/scalar-scalar/i32.wgsl.expected.fxc.hlsl @@ -2,6 +2,6 @@ void f() { const int a = 1; const uint b = 2u; - const int r = (a << b); + const int r = (a << (b & 31u)); return; } 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 67be9edf3b..459fe5c632 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 @@ -3,7 +3,7 @@ void f() { int a = 1; uint b = 2u; - int r = (a << b); + int r = (a << (b & 31u)); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; diff --git a/test/tint/expressions/binary/left-shift/scalar-scalar/i32.wgsl.expected.msl b/test/tint/expressions/binary/left-shift/scalar-scalar/i32.wgsl.expected.msl index 3c5ec179ee..99bc013c5b 100644 --- a/test/tint/expressions/binary/left-shift/scalar-scalar/i32.wgsl.expected.msl +++ b/test/tint/expressions/binary/left-shift/scalar-scalar/i32.wgsl.expected.msl @@ -4,7 +4,7 @@ using namespace metal; kernel void f() { int const a = 1; uint const b = 2u; - int const r = as_type((as_type(a) << b)); + int const r = as_type((as_type(a) << (b & 31u))); return; } 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 d623dc4434..999857a921 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; 0 -; Bound: 10 +; Bound: 12 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -14,8 +14,10 @@ %int_1 = OpConstant %int 1 %uint = OpTypeInt 32 0 %uint_2 = OpConstant %uint 2 + %uint_31 = OpConstant %uint 31 %f = OpFunction %void None %1 %4 = OpLabel - %9 = OpShiftLeftLogical %int %int_1 %uint_2 + %10 = OpBitwiseAnd %uint %uint_2 %uint_31 + %11 = OpShiftLeftLogical %int %int_1 %10 OpReturn OpFunctionEnd diff --git a/test/tint/expressions/binary/left-shift/scalar-scalar/u32.wgsl.expected.dxc.hlsl b/test/tint/expressions/binary/left-shift/scalar-scalar/u32.wgsl.expected.dxc.hlsl index 913458792f..4db204fe15 100644 --- a/test/tint/expressions/binary/left-shift/scalar-scalar/u32.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/binary/left-shift/scalar-scalar/u32.wgsl.expected.dxc.hlsl @@ -2,6 +2,6 @@ void f() { const uint a = 1u; const uint b = 2u; - const uint r = (a << b); + const uint r = (a << (b & 31u)); return; } diff --git a/test/tint/expressions/binary/left-shift/scalar-scalar/u32.wgsl.expected.fxc.hlsl b/test/tint/expressions/binary/left-shift/scalar-scalar/u32.wgsl.expected.fxc.hlsl index 913458792f..4db204fe15 100644 --- a/test/tint/expressions/binary/left-shift/scalar-scalar/u32.wgsl.expected.fxc.hlsl +++ b/test/tint/expressions/binary/left-shift/scalar-scalar/u32.wgsl.expected.fxc.hlsl @@ -2,6 +2,6 @@ void f() { const uint a = 1u; const uint b = 2u; - const uint r = (a << b); + const uint r = (a << (b & 31u)); return; } diff --git a/test/tint/expressions/binary/left-shift/scalar-scalar/u32.wgsl.expected.glsl b/test/tint/expressions/binary/left-shift/scalar-scalar/u32.wgsl.expected.glsl index 9fc3402ffb..7679fbdb7e 100644 --- a/test/tint/expressions/binary/left-shift/scalar-scalar/u32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/left-shift/scalar-scalar/u32.wgsl.expected.glsl @@ -3,7 +3,7 @@ void f() { uint a = 1u; uint b = 2u; - uint r = (a << b); + uint r = (a << (b & 31u)); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; diff --git a/test/tint/expressions/binary/left-shift/scalar-scalar/u32.wgsl.expected.msl b/test/tint/expressions/binary/left-shift/scalar-scalar/u32.wgsl.expected.msl index 90ec5fb2ae..389cde860a 100644 --- a/test/tint/expressions/binary/left-shift/scalar-scalar/u32.wgsl.expected.msl +++ b/test/tint/expressions/binary/left-shift/scalar-scalar/u32.wgsl.expected.msl @@ -4,7 +4,7 @@ using namespace metal; kernel void f() { uint const a = 1u; uint const b = 2u; - uint const r = (a << b); + uint const r = (a << (b & 31u)); return; } diff --git a/test/tint/expressions/binary/left-shift/scalar-scalar/u32.wgsl.expected.spvasm b/test/tint/expressions/binary/left-shift/scalar-scalar/u32.wgsl.expected.spvasm index 17c61e3a0f..4a2c2bb742 100644 --- a/test/tint/expressions/binary/left-shift/scalar-scalar/u32.wgsl.expected.spvasm +++ b/test/tint/expressions/binary/left-shift/scalar-scalar/u32.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 9 +; Bound: 11 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -13,8 +13,10 @@ %uint = OpTypeInt 32 0 %uint_1 = OpConstant %uint 1 %uint_2 = OpConstant %uint 2 + %uint_31 = OpConstant %uint 31 %f = OpFunction %void None %1 %4 = OpLabel - %8 = OpShiftLeftLogical %uint %uint_1 %uint_2 + %9 = OpBitwiseAnd %uint %uint_2 %uint_31 + %10 = OpShiftLeftLogical %uint %uint_1 %9 OpReturn OpFunctionEnd diff --git a/test/tint/expressions/binary/left-shift/vector-vector/i32.wgsl.expected.dxc.hlsl b/test/tint/expressions/binary/left-shift/vector-vector/i32.wgsl.expected.dxc.hlsl index d43dfb6f80..1cd18f93e0 100644 --- a/test/tint/expressions/binary/left-shift/vector-vector/i32.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/binary/left-shift/vector-vector/i32.wgsl.expected.dxc.hlsl @@ -2,6 +2,6 @@ void f() { const int3 a = int3(1, 2, 3); const uint3 b = uint3(4u, 5u, 6u); - const int3 r = (a << b); + const int3 r = (a << (b & (31u).xxx)); return; } diff --git a/test/tint/expressions/binary/left-shift/vector-vector/i32.wgsl.expected.fxc.hlsl b/test/tint/expressions/binary/left-shift/vector-vector/i32.wgsl.expected.fxc.hlsl index d43dfb6f80..1cd18f93e0 100644 --- a/test/tint/expressions/binary/left-shift/vector-vector/i32.wgsl.expected.fxc.hlsl +++ b/test/tint/expressions/binary/left-shift/vector-vector/i32.wgsl.expected.fxc.hlsl @@ -2,6 +2,6 @@ void f() { const int3 a = int3(1, 2, 3); const uint3 b = uint3(4u, 5u, 6u); - const int3 r = (a << b); + const int3 r = (a << (b & (31u).xxx)); return; } 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 68dccd8c0d..3421aca55b 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 @@ -3,7 +3,7 @@ void f() { ivec3 a = ivec3(1, 2, 3); uvec3 b = uvec3(4u, 5u, 6u); - ivec3 r = (a << b); + ivec3 r = (a << (b & uvec3(31u))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; diff --git a/test/tint/expressions/binary/left-shift/vector-vector/i32.wgsl.expected.msl b/test/tint/expressions/binary/left-shift/vector-vector/i32.wgsl.expected.msl index f97db25d1b..a446c3d429 100644 --- a/test/tint/expressions/binary/left-shift/vector-vector/i32.wgsl.expected.msl +++ b/test/tint/expressions/binary/left-shift/vector-vector/i32.wgsl.expected.msl @@ -4,7 +4,7 @@ using namespace metal; kernel void f() { int3 const a = int3(1, 2, 3); uint3 const b = uint3(4u, 5u, 6u); - int3 const r = as_type((as_type(a) << b)); + int3 const r = as_type((as_type(a) << (b & uint3(31u)))); return; } 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 42f104e930..4f8a50d1b6 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; 0 -; Bound: 18 +; Bound: 21 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -22,8 +22,11 @@ %uint_5 = OpConstant %uint 5 %uint_6 = OpConstant %uint 6 %16 = OpConstantComposite %v3uint %uint_4 %uint_5 %uint_6 + %uint_31 = OpConstant %uint 31 + %18 = OpConstantComposite %v3uint %uint_31 %uint_31 %uint_31 %f = OpFunction %void None %1 %4 = OpLabel - %17 = OpShiftLeftLogical %v3int %10 %16 + %19 = OpBitwiseAnd %v3uint %16 %18 + %20 = OpShiftLeftLogical %v3int %10 %19 OpReturn OpFunctionEnd diff --git a/test/tint/expressions/binary/left-shift/vector-vector/u32.wgsl.expected.dxc.hlsl b/test/tint/expressions/binary/left-shift/vector-vector/u32.wgsl.expected.dxc.hlsl index 2de16f0c9b..5be626e96e 100644 --- a/test/tint/expressions/binary/left-shift/vector-vector/u32.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/binary/left-shift/vector-vector/u32.wgsl.expected.dxc.hlsl @@ -2,6 +2,6 @@ void f() { const uint3 a = uint3(1u, 2u, 3u); const uint3 b = uint3(4u, 5u, 6u); - const uint3 r = (a << b); + const uint3 r = (a << (b & (31u).xxx)); return; } diff --git a/test/tint/expressions/binary/left-shift/vector-vector/u32.wgsl.expected.fxc.hlsl b/test/tint/expressions/binary/left-shift/vector-vector/u32.wgsl.expected.fxc.hlsl index 2de16f0c9b..5be626e96e 100644 --- a/test/tint/expressions/binary/left-shift/vector-vector/u32.wgsl.expected.fxc.hlsl +++ b/test/tint/expressions/binary/left-shift/vector-vector/u32.wgsl.expected.fxc.hlsl @@ -2,6 +2,6 @@ void f() { const uint3 a = uint3(1u, 2u, 3u); const uint3 b = uint3(4u, 5u, 6u); - const uint3 r = (a << b); + const uint3 r = (a << (b & (31u).xxx)); return; } diff --git a/test/tint/expressions/binary/left-shift/vector-vector/u32.wgsl.expected.glsl b/test/tint/expressions/binary/left-shift/vector-vector/u32.wgsl.expected.glsl index ba5db9c65c..a7038f0e7e 100644 --- a/test/tint/expressions/binary/left-shift/vector-vector/u32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/left-shift/vector-vector/u32.wgsl.expected.glsl @@ -3,7 +3,7 @@ void f() { uvec3 a = uvec3(1u, 2u, 3u); uvec3 b = uvec3(4u, 5u, 6u); - uvec3 r = (a << b); + uvec3 r = (a << (b & uvec3(31u))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; diff --git a/test/tint/expressions/binary/left-shift/vector-vector/u32.wgsl.expected.msl b/test/tint/expressions/binary/left-shift/vector-vector/u32.wgsl.expected.msl index c80e57e6a8..d7b8452a56 100644 --- a/test/tint/expressions/binary/left-shift/vector-vector/u32.wgsl.expected.msl +++ b/test/tint/expressions/binary/left-shift/vector-vector/u32.wgsl.expected.msl @@ -4,7 +4,7 @@ using namespace metal; kernel void f() { uint3 const a = uint3(1u, 2u, 3u); uint3 const b = uint3(4u, 5u, 6u); - uint3 const r = (a << b); + uint3 const r = (a << (b & uint3(31u))); return; } diff --git a/test/tint/expressions/binary/left-shift/vector-vector/u32.wgsl.expected.spvasm b/test/tint/expressions/binary/left-shift/vector-vector/u32.wgsl.expected.spvasm index 27379ecff2..376820e1d8 100644 --- a/test/tint/expressions/binary/left-shift/vector-vector/u32.wgsl.expected.spvasm +++ b/test/tint/expressions/binary/left-shift/vector-vector/u32.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 16 +; Bound: 19 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -20,8 +20,11 @@ %uint_5 = OpConstant %uint 5 %uint_6 = OpConstant %uint 6 %14 = OpConstantComposite %v3uint %uint_4 %uint_5 %uint_6 + %uint_31 = OpConstant %uint 31 + %16 = OpConstantComposite %v3uint %uint_31 %uint_31 %uint_31 %f = OpFunction %void None %1 %4 = OpLabel - %15 = OpShiftLeftLogical %v3uint %10 %14 + %17 = OpBitwiseAnd %v3uint %14 %16 + %18 = OpShiftLeftLogical %v3uint %10 %17 OpReturn OpFunctionEnd diff --git a/test/tint/expressions/binary/right-shift/scalar-scalar/i32.wgsl.expected.dxc.hlsl b/test/tint/expressions/binary/right-shift/scalar-scalar/i32.wgsl.expected.dxc.hlsl index afd60870b9..c408e6224c 100644 --- a/test/tint/expressions/binary/right-shift/scalar-scalar/i32.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/binary/right-shift/scalar-scalar/i32.wgsl.expected.dxc.hlsl @@ -2,6 +2,6 @@ void f() { const int a = 1; const uint b = 2u; - const int r = (a >> b); + const int r = (a >> (b & 31u)); return; } diff --git a/test/tint/expressions/binary/right-shift/scalar-scalar/i32.wgsl.expected.fxc.hlsl b/test/tint/expressions/binary/right-shift/scalar-scalar/i32.wgsl.expected.fxc.hlsl index afd60870b9..c408e6224c 100644 --- a/test/tint/expressions/binary/right-shift/scalar-scalar/i32.wgsl.expected.fxc.hlsl +++ b/test/tint/expressions/binary/right-shift/scalar-scalar/i32.wgsl.expected.fxc.hlsl @@ -2,6 +2,6 @@ void f() { const int a = 1; const uint b = 2u; - const int r = (a >> b); + const int r = (a >> (b & 31u)); return; } diff --git a/test/tint/expressions/binary/right-shift/scalar-scalar/i32.wgsl.expected.glsl b/test/tint/expressions/binary/right-shift/scalar-scalar/i32.wgsl.expected.glsl index b51d4f3634..66258ec385 100644 --- a/test/tint/expressions/binary/right-shift/scalar-scalar/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/right-shift/scalar-scalar/i32.wgsl.expected.glsl @@ -3,7 +3,7 @@ void f() { int a = 1; uint b = 2u; - int r = (a >> b); + int r = (a >> (b & 31u)); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; diff --git a/test/tint/expressions/binary/right-shift/scalar-scalar/i32.wgsl.expected.msl b/test/tint/expressions/binary/right-shift/scalar-scalar/i32.wgsl.expected.msl index 9d9f74941d..1f3190c23d 100644 --- a/test/tint/expressions/binary/right-shift/scalar-scalar/i32.wgsl.expected.msl +++ b/test/tint/expressions/binary/right-shift/scalar-scalar/i32.wgsl.expected.msl @@ -4,7 +4,7 @@ using namespace metal; kernel void f() { int const a = 1; uint const b = 2u; - int const r = (a >> b); + int const r = (a >> (b & 31u)); return; } diff --git a/test/tint/expressions/binary/right-shift/scalar-scalar/i32.wgsl.expected.spvasm b/test/tint/expressions/binary/right-shift/scalar-scalar/i32.wgsl.expected.spvasm index 10b58f2cf6..e65b24f724 100644 --- a/test/tint/expressions/binary/right-shift/scalar-scalar/i32.wgsl.expected.spvasm +++ b/test/tint/expressions/binary/right-shift/scalar-scalar/i32.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 10 +; Bound: 12 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -14,8 +14,10 @@ %int_1 = OpConstant %int 1 %uint = OpTypeInt 32 0 %uint_2 = OpConstant %uint 2 + %uint_31 = OpConstant %uint 31 %f = OpFunction %void None %1 %4 = OpLabel - %9 = OpShiftRightArithmetic %int %int_1 %uint_2 + %10 = OpBitwiseAnd %uint %uint_2 %uint_31 + %11 = OpShiftRightArithmetic %int %int_1 %10 OpReturn OpFunctionEnd diff --git a/test/tint/expressions/binary/right-shift/scalar-scalar/u32.wgsl.expected.dxc.hlsl b/test/tint/expressions/binary/right-shift/scalar-scalar/u32.wgsl.expected.dxc.hlsl index b97620ff33..1cdc247184 100644 --- a/test/tint/expressions/binary/right-shift/scalar-scalar/u32.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/binary/right-shift/scalar-scalar/u32.wgsl.expected.dxc.hlsl @@ -2,6 +2,6 @@ void f() { const uint a = 1u; const uint b = 2u; - const uint r = (a >> b); + const uint r = (a >> (b & 31u)); return; } diff --git a/test/tint/expressions/binary/right-shift/scalar-scalar/u32.wgsl.expected.fxc.hlsl b/test/tint/expressions/binary/right-shift/scalar-scalar/u32.wgsl.expected.fxc.hlsl index b97620ff33..1cdc247184 100644 --- a/test/tint/expressions/binary/right-shift/scalar-scalar/u32.wgsl.expected.fxc.hlsl +++ b/test/tint/expressions/binary/right-shift/scalar-scalar/u32.wgsl.expected.fxc.hlsl @@ -2,6 +2,6 @@ void f() { const uint a = 1u; const uint b = 2u; - const uint r = (a >> b); + const uint r = (a >> (b & 31u)); return; } diff --git a/test/tint/expressions/binary/right-shift/scalar-scalar/u32.wgsl.expected.glsl b/test/tint/expressions/binary/right-shift/scalar-scalar/u32.wgsl.expected.glsl index d81e2dee95..bdd0e58817 100644 --- a/test/tint/expressions/binary/right-shift/scalar-scalar/u32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/right-shift/scalar-scalar/u32.wgsl.expected.glsl @@ -3,7 +3,7 @@ void f() { uint a = 1u; uint b = 2u; - uint r = (a >> b); + uint r = (a >> (b & 31u)); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; diff --git a/test/tint/expressions/binary/right-shift/scalar-scalar/u32.wgsl.expected.msl b/test/tint/expressions/binary/right-shift/scalar-scalar/u32.wgsl.expected.msl index 68036b5ce6..448647e160 100644 --- a/test/tint/expressions/binary/right-shift/scalar-scalar/u32.wgsl.expected.msl +++ b/test/tint/expressions/binary/right-shift/scalar-scalar/u32.wgsl.expected.msl @@ -4,7 +4,7 @@ using namespace metal; kernel void f() { uint const a = 1u; uint const b = 2u; - uint const r = (a >> b); + uint const r = (a >> (b & 31u)); return; } diff --git a/test/tint/expressions/binary/right-shift/scalar-scalar/u32.wgsl.expected.spvasm b/test/tint/expressions/binary/right-shift/scalar-scalar/u32.wgsl.expected.spvasm index 04adcf8923..8517337fa1 100644 --- a/test/tint/expressions/binary/right-shift/scalar-scalar/u32.wgsl.expected.spvasm +++ b/test/tint/expressions/binary/right-shift/scalar-scalar/u32.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 9 +; Bound: 11 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -13,8 +13,10 @@ %uint = OpTypeInt 32 0 %uint_1 = OpConstant %uint 1 %uint_2 = OpConstant %uint 2 + %uint_31 = OpConstant %uint 31 %f = OpFunction %void None %1 %4 = OpLabel - %8 = OpShiftRightLogical %uint %uint_1 %uint_2 + %9 = OpBitwiseAnd %uint %uint_2 %uint_31 + %10 = OpShiftRightLogical %uint %uint_1 %9 OpReturn OpFunctionEnd diff --git a/test/tint/expressions/binary/right-shift/vector-vector/i32.wgsl.expected.dxc.hlsl b/test/tint/expressions/binary/right-shift/vector-vector/i32.wgsl.expected.dxc.hlsl index 2520c5e787..0421b5f171 100644 --- a/test/tint/expressions/binary/right-shift/vector-vector/i32.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/binary/right-shift/vector-vector/i32.wgsl.expected.dxc.hlsl @@ -2,6 +2,6 @@ void f() { const int3 a = int3(1, 2, 3); const uint3 b = uint3(4u, 5u, 6u); - const int3 r = (a >> b); + const int3 r = (a >> (b & (31u).xxx)); return; } diff --git a/test/tint/expressions/binary/right-shift/vector-vector/i32.wgsl.expected.fxc.hlsl b/test/tint/expressions/binary/right-shift/vector-vector/i32.wgsl.expected.fxc.hlsl index 2520c5e787..0421b5f171 100644 --- a/test/tint/expressions/binary/right-shift/vector-vector/i32.wgsl.expected.fxc.hlsl +++ b/test/tint/expressions/binary/right-shift/vector-vector/i32.wgsl.expected.fxc.hlsl @@ -2,6 +2,6 @@ void f() { const int3 a = int3(1, 2, 3); const uint3 b = uint3(4u, 5u, 6u); - const int3 r = (a >> b); + const int3 r = (a >> (b & (31u).xxx)); return; } diff --git a/test/tint/expressions/binary/right-shift/vector-vector/i32.wgsl.expected.glsl b/test/tint/expressions/binary/right-shift/vector-vector/i32.wgsl.expected.glsl index ca2842cd0a..191817d4e4 100644 --- a/test/tint/expressions/binary/right-shift/vector-vector/i32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/right-shift/vector-vector/i32.wgsl.expected.glsl @@ -3,7 +3,7 @@ void f() { ivec3 a = ivec3(1, 2, 3); uvec3 b = uvec3(4u, 5u, 6u); - ivec3 r = (a >> b); + ivec3 r = (a >> (b & uvec3(31u))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; diff --git a/test/tint/expressions/binary/right-shift/vector-vector/i32.wgsl.expected.msl b/test/tint/expressions/binary/right-shift/vector-vector/i32.wgsl.expected.msl index 5c3fd63d2d..d691234e9a 100644 --- a/test/tint/expressions/binary/right-shift/vector-vector/i32.wgsl.expected.msl +++ b/test/tint/expressions/binary/right-shift/vector-vector/i32.wgsl.expected.msl @@ -4,7 +4,7 @@ using namespace metal; kernel void f() { int3 const a = int3(1, 2, 3); uint3 const b = uint3(4u, 5u, 6u); - int3 const r = (a >> b); + int3 const r = (a >> (b & uint3(31u))); return; } diff --git a/test/tint/expressions/binary/right-shift/vector-vector/i32.wgsl.expected.spvasm b/test/tint/expressions/binary/right-shift/vector-vector/i32.wgsl.expected.spvasm index 227bd0212e..317ba4a922 100644 --- a/test/tint/expressions/binary/right-shift/vector-vector/i32.wgsl.expected.spvasm +++ b/test/tint/expressions/binary/right-shift/vector-vector/i32.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 18 +; Bound: 21 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -22,8 +22,11 @@ %uint_5 = OpConstant %uint 5 %uint_6 = OpConstant %uint 6 %16 = OpConstantComposite %v3uint %uint_4 %uint_5 %uint_6 + %uint_31 = OpConstant %uint 31 + %18 = OpConstantComposite %v3uint %uint_31 %uint_31 %uint_31 %f = OpFunction %void None %1 %4 = OpLabel - %17 = OpShiftRightArithmetic %v3int %10 %16 + %19 = OpBitwiseAnd %v3uint %16 %18 + %20 = OpShiftRightArithmetic %v3int %10 %19 OpReturn OpFunctionEnd diff --git a/test/tint/expressions/binary/right-shift/vector-vector/u32.wgsl.expected.dxc.hlsl b/test/tint/expressions/binary/right-shift/vector-vector/u32.wgsl.expected.dxc.hlsl index 1c57ee7a4d..8a9e6df9e5 100644 --- a/test/tint/expressions/binary/right-shift/vector-vector/u32.wgsl.expected.dxc.hlsl +++ b/test/tint/expressions/binary/right-shift/vector-vector/u32.wgsl.expected.dxc.hlsl @@ -2,6 +2,6 @@ void f() { const uint3 a = uint3(1u, 2u, 3u); const uint3 b = uint3(4u, 5u, 6u); - const uint3 r = (a >> b); + const uint3 r = (a >> (b & (31u).xxx)); return; } diff --git a/test/tint/expressions/binary/right-shift/vector-vector/u32.wgsl.expected.fxc.hlsl b/test/tint/expressions/binary/right-shift/vector-vector/u32.wgsl.expected.fxc.hlsl index 1c57ee7a4d..8a9e6df9e5 100644 --- a/test/tint/expressions/binary/right-shift/vector-vector/u32.wgsl.expected.fxc.hlsl +++ b/test/tint/expressions/binary/right-shift/vector-vector/u32.wgsl.expected.fxc.hlsl @@ -2,6 +2,6 @@ void f() { const uint3 a = uint3(1u, 2u, 3u); const uint3 b = uint3(4u, 5u, 6u); - const uint3 r = (a >> b); + const uint3 r = (a >> (b & (31u).xxx)); return; } diff --git a/test/tint/expressions/binary/right-shift/vector-vector/u32.wgsl.expected.glsl b/test/tint/expressions/binary/right-shift/vector-vector/u32.wgsl.expected.glsl index a29237718e..1b4c41cdb7 100644 --- a/test/tint/expressions/binary/right-shift/vector-vector/u32.wgsl.expected.glsl +++ b/test/tint/expressions/binary/right-shift/vector-vector/u32.wgsl.expected.glsl @@ -3,7 +3,7 @@ void f() { uvec3 a = uvec3(1u, 2u, 3u); uvec3 b = uvec3(4u, 5u, 6u); - uvec3 r = (a >> b); + uvec3 r = (a >> (b & uvec3(31u))); } layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; diff --git a/test/tint/expressions/binary/right-shift/vector-vector/u32.wgsl.expected.msl b/test/tint/expressions/binary/right-shift/vector-vector/u32.wgsl.expected.msl index b5aa9e9f95..fe0ab3d359 100644 --- a/test/tint/expressions/binary/right-shift/vector-vector/u32.wgsl.expected.msl +++ b/test/tint/expressions/binary/right-shift/vector-vector/u32.wgsl.expected.msl @@ -4,7 +4,7 @@ using namespace metal; kernel void f() { uint3 const a = uint3(1u, 2u, 3u); uint3 const b = uint3(4u, 5u, 6u); - uint3 const r = (a >> b); + uint3 const r = (a >> (b & uint3(31u))); return; } diff --git a/test/tint/expressions/binary/right-shift/vector-vector/u32.wgsl.expected.spvasm b/test/tint/expressions/binary/right-shift/vector-vector/u32.wgsl.expected.spvasm index 17932f21fd..5aeebd10b1 100644 --- a/test/tint/expressions/binary/right-shift/vector-vector/u32.wgsl.expected.spvasm +++ b/test/tint/expressions/binary/right-shift/vector-vector/u32.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 16 +; Bound: 19 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -20,8 +20,11 @@ %uint_5 = OpConstant %uint 5 %uint_6 = OpConstant %uint 6 %14 = OpConstantComposite %v3uint %uint_4 %uint_5 %uint_6 + %uint_31 = OpConstant %uint 31 + %16 = OpConstantComposite %v3uint %uint_31 %uint_31 %uint_31 %f = OpFunction %void None %1 %4 = OpLabel - %15 = OpShiftRightLogical %v3uint %10 %14 + %17 = OpBitwiseAnd %v3uint %14 %16 + %18 = OpShiftRightLogical %v3uint %10 %17 OpReturn OpFunctionEnd