From 2be5167e3e099668081110ae9d5bd22b116cd414 Mon Sep 17 00:00:00 2001 From: Antonio Maiorano Date: Sat, 29 Oct 2022 14:02:38 +0000 Subject: [PATCH] tint: const eval of countLeadingZeros Bug: tint:1581 Change-Id: Ib7ae9f36dad64c1eed3ce223af47e92aa0a663f1 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107661 Kokoro: Kokoro Reviewed-by: Ben Clayton --- src/tint/intrinsics.def | 4 +- src/tint/resolver/const_eval.cc | 35 +++++ src/tint/resolver/const_eval.h | 9 ++ src/tint/resolver/const_eval_builtin_test.cc | 46 +++++++ src/tint/resolver/const_eval_test.h | 4 +- src/tint/resolver/intrinsic_table.inl | 4 +- .../208d46.wgsl.expected.dxc.hlsl | 17 +-- .../208d46.wgsl.expected.fxc.hlsl | 17 +-- .../208d46.wgsl.expected.glsl | 51 +------- .../208d46.wgsl.expected.msl | 2 +- .../208d46.wgsl.expected.spvasm | 99 +++----------- .../6d4656.wgsl.expected.dxc.hlsl | 17 +-- .../6d4656.wgsl.expected.fxc.hlsl | 17 +-- .../6d4656.wgsl.expected.glsl | 51 +------- .../6d4656.wgsl.expected.msl | 2 +- .../6d4656.wgsl.expected.spvasm | 109 ++++------------ .../70783f.wgsl.expected.dxc.hlsl | 17 +-- .../70783f.wgsl.expected.fxc.hlsl | 17 +-- .../70783f.wgsl.expected.glsl | 51 +------- .../70783f.wgsl.expected.msl | 2 +- .../70783f.wgsl.expected.spvasm | 115 ++++------------ .../7c38a6.wgsl.expected.dxc.hlsl | 17 +-- .../7c38a6.wgsl.expected.fxc.hlsl | 17 +-- .../7c38a6.wgsl.expected.glsl | 51 +------- .../7c38a6.wgsl.expected.msl | 2 +- .../7c38a6.wgsl.expected.spvasm | 123 ++++-------------- .../858d40.wgsl.expected.dxc.hlsl | 17 +-- .../858d40.wgsl.expected.fxc.hlsl | 17 +-- .../858d40.wgsl.expected.glsl | 51 +------- .../858d40.wgsl.expected.msl | 2 +- .../858d40.wgsl.expected.spvasm | 123 ++++-------------- .../ab6345.wgsl.expected.dxc.hlsl | 17 +-- .../ab6345.wgsl.expected.fxc.hlsl | 17 +-- .../ab6345.wgsl.expected.glsl | 51 +------- .../ab6345.wgsl.expected.msl | 2 +- .../ab6345.wgsl.expected.spvasm | 115 ++++------------ .../eab32b.wgsl.expected.dxc.hlsl | 17 +-- .../eab32b.wgsl.expected.fxc.hlsl | 17 +-- .../eab32b.wgsl.expected.glsl | 51 +------- .../eab32b.wgsl.expected.msl | 2 +- .../eab32b.wgsl.expected.spvasm | 123 ++++-------------- .../f70103.wgsl.expected.dxc.hlsl | 17 +-- .../f70103.wgsl.expected.fxc.hlsl | 17 +-- .../f70103.wgsl.expected.glsl | 51 +------- .../f70103.wgsl.expected.msl | 2 +- .../f70103.wgsl.expected.spvasm | 115 ++++------------ 46 files changed, 333 insertions(+), 1387 deletions(-) diff --git a/src/tint/intrinsics.def b/src/tint/intrinsics.def index 7a335e7d6d..9b3206b40a 100644 --- a/src/tint/intrinsics.def +++ b/src/tint/intrinsics.def @@ -433,8 +433,8 @@ fn cos(T) -> T fn cos(vec) -> vec fn cosh(T) -> T fn cosh(vec) -> vec -fn countLeadingZeros(T) -> T -fn countLeadingZeros(vec) -> vec +@const fn countLeadingZeros(T) -> T +@const fn countLeadingZeros(vec) -> vec fn countOneBits(T) -> T fn countOneBits(vec) -> vec fn countTrailingZeros(T) -> T diff --git a/src/tint/resolver/const_eval.cc b/src/tint/resolver/const_eval.cc index cdca20230a..31b3796ef7 100644 --- a/src/tint/resolver/const_eval.cc +++ b/src/tint/resolver/const_eval.cc @@ -53,6 +53,16 @@ T First(T&& first, ...) { return std::forward(first); } +/// Helper that calls `f` passing in the value of all `cs`. +/// Calls `f` with all constants cast to the type of the first `cs` argument. +template +auto Dispatch_iu32(F&& f, CONSTANTS&&... cs) { + return Switch( + First(cs...)->Type(), // + [&](const sem::I32*) { return f(cs->template As()...); }, + [&](const sem::U32*) { return f(cs->template As()...); }); +} + /// Helper that calls `f` passing in the value of all `cs`. /// Calls `f` with all constants cast to the type of the first `cs` argument. template @@ -1616,6 +1626,31 @@ ConstEval::Result ConstEval::clamp(const sem::Type* ty, return TransformElements(builder, ty, transform, args[0], args[1], args[2]); } +ConstEval::Result ConstEval::countLeadingZeros(const sem::Type* ty, + utils::VectorRef args, + const Source&) { + auto transform = [&](const sem::Constant* c0) { + auto create = [&](auto e) { + using NumberT = decltype(e); + using T = UnwrapNumber; + using UT = std::make_unsigned_t; + constexpr UT kNumBits = sizeof(UT) * 8; + constexpr UT kLeftMost = UT{1} << (kNumBits - 1); + + auto v = static_cast(e); + auto count = UT{0}; + while ((count < kNumBits) && ((v & kLeftMost) == 0)) { + ++count; + v <<= 1; + } + + return CreateElement(builder, c0->Type(), NumberT(count)); + }; + return Dispatch_iu32(create, c0); + }; + return TransformElements(builder, ty, transform, args[0]); +} + ConstEval::Result ConstEval::saturate(const sem::Type* ty, utils::VectorRef args, const Source&) { diff --git a/src/tint/resolver/const_eval.h b/src/tint/resolver/const_eval.h index 009a92f823..980a3104df 100644 --- a/src/tint/resolver/const_eval.h +++ b/src/tint/resolver/const_eval.h @@ -431,6 +431,15 @@ class ConstEval { utils::VectorRef args, const Source& source); + /// countLeadingZeros builtin + /// @param ty the expression type + /// @param args the input arguments + /// @param source the source location of the conversion + /// @return the result value, or null if the value cannot be calculated + Result countLeadingZeros(const sem::Type* ty, + utils::VectorRef args, + const Source& source); + /// saturate builtin /// @param ty the expression type /// @param args the input arguments diff --git a/src/tint/resolver/const_eval_builtin_test.cc b/src/tint/resolver/const_eval_builtin_test.cc index d004b0262c..6378230256 100644 --- a/src/tint/resolver/const_eval_builtin_test.cc +++ b/src/tint/resolver/const_eval_builtin_test.cc @@ -460,6 +460,52 @@ INSTANTIATE_TEST_SUITE_P( // ClampCases(), ClampCases())))); +template +std::vector CountLeadingZerosCases() { + using B = BitValues; + return { + C({B::Lsh(1, 31)}, T(0)), // + C({B::Lsh(1, 30)}, T(1)), // + C({B::Lsh(1, 29)}, T(2)), // + C({B::Lsh(1, 28)}, T(3)), + //... + C({B::Lsh(1, 3)}, T(28)), // + C({B::Lsh(1, 2)}, T(29)), // + C({B::Lsh(1, 1)}, T(30)), // + C({B::Lsh(1, 0)}, T(31)), + + C({T(0b1111'0000'1111'0000'1111'0000'1111'0000)}, T(0)), + C({T(0b0111'1000'0111'1000'0111'1000'0111'1000)}, T(1)), + C({T(0b0011'1100'0011'1100'0011'1100'0011'1100)}, T(2)), + C({T(0b0001'1110'0001'1110'0001'1110'0001'1110)}, T(3)), + //... + C({T(0b0000'0000'0000'0000'0000'0000'0000'0111)}, T(29)), + C({T(0b0000'0000'0000'0000'0000'0000'0000'0011)}, T(30)), + C({T(0b0000'0000'0000'0000'0000'0000'0000'0001)}, T(31)), + C({T(0b0000'0000'0000'0000'0000'0000'0000'0000)}, T(32)), + + // Same as above, but remove leading 0 + C({T(0b1111'1000'0111'1000'0111'1000'0111'1000)}, T(0)), + C({T(0b1011'1100'0011'1100'0011'1100'0011'1100)}, T(0)), + C({T(0b1001'1110'0001'1110'0001'1110'0001'1110)}, T(0)), + //... + C({T(0b1000'0000'0000'0000'0000'0000'0000'0111)}, T(0)), + C({T(0b1000'0000'0000'0000'0000'0000'0000'0011)}, T(0)), + C({T(0b1000'0000'0000'0000'0000'0000'0000'0001)}, T(0)), + C({T(0b1000'0000'0000'0000'0000'0000'0000'0000)}, T(0)), + + // Vector tests + C({Vec(B::Lsh(1, 31), B::Lsh(1, 30), B::Lsh(1, 29))}, Vec(T(0), T(1), T(2))), + C({Vec(B::Lsh(1, 2), B::Lsh(1, 1), B::Lsh(1, 0))}, Vec(T(29), T(30), T(31))), + }; +} +INSTANTIATE_TEST_SUITE_P( // + CountLeadingZeros, + ResolverConstEvalBuiltinTest, + testing::Combine(testing::Values(sem::BuiltinType::kCountLeadingZeros), + testing::ValuesIn(Concat(CountLeadingZerosCases(), // + CountLeadingZerosCases())))); + template std::vector SaturateCases() { return { diff --git a/src/tint/resolver/const_eval_test.h b/src/tint/resolver/const_eval_test.h index 1915c05e52..2f000f82b6 100644 --- a/src/tint/resolver/const_eval_test.h +++ b/src/tint/resolver/const_eval_test.h @@ -236,6 +236,8 @@ template struct BitValues { /// The unwrapped number type using T = UnwrapNumber; + /// The unsigned unwrapped number type + using UT = std::make_unsigned_t; /// Details struct detail { /// Unsigned type of `T` @@ -281,7 +283,7 @@ struct BitValues { /// @returns the shifted value template static constexpr NumberT Lsh(U val, V shiftBy) { - return NumberT{static_cast(val) << static_cast(shiftBy)}; + return NumberT{static_cast(static_cast(val) << static_cast(shiftBy))}; } }; diff --git a/src/tint/resolver/intrinsic_table.inl b/src/tint/resolver/intrinsic_table.inl index 30ab9267d1..38bba685fa 100644 --- a/src/tint/resolver/intrinsic_table.inl +++ b/src/tint/resolver/intrinsic_table.inl @@ -13012,7 +13012,7 @@ constexpr OverloadInfo kOverloads[] = { /* parameters */ &kParameters[950], /* return matcher indices */ &kMatcherIndices[1], /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), - /* const eval */ nullptr, + /* const eval */ &ConstEval::countLeadingZeros, }, { /* [391] */ @@ -13024,7 +13024,7 @@ constexpr OverloadInfo kOverloads[] = { /* parameters */ &kParameters[947], /* return matcher indices */ &kMatcherIndices[30], /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), - /* const eval */ nullptr, + /* const eval */ &ConstEval::countLeadingZeros, }, { /* [392] */ diff --git a/test/tint/builtins/gen/literal/countLeadingZeros/208d46.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/countLeadingZeros/208d46.wgsl.expected.dxc.hlsl index 297947f9c6..96eac70558 100644 --- a/test/tint/builtins/gen/literal/countLeadingZeros/208d46.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/countLeadingZeros/208d46.wgsl.expected.dxc.hlsl @@ -1,20 +1,5 @@ -uint tint_count_leading_zeros(uint v) { - uint x = uint(v); - const uint b16 = ((x <= 65535u) ? 16u : 0u); - x = (x << b16); - const uint b8 = ((x <= 16777215u) ? 8u : 0u); - x = (x << b8); - const uint b4 = ((x <= 268435455u) ? 4u : 0u); - x = (x << b4); - const uint b2 = ((x <= 1073741823u) ? 2u : 0u); - x = (x << b2); - const uint b1 = ((x <= 2147483647u) ? 1u : 0u); - const uint is_zero = ((x == 0u) ? 1u : 0u); - return uint((((((b16 | b8) | b4) | b2) | b1) + is_zero)); -} - void countLeadingZeros_208d46() { - uint res = tint_count_leading_zeros(1u); + uint res = 31u; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countLeadingZeros/208d46.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/countLeadingZeros/208d46.wgsl.expected.fxc.hlsl index 297947f9c6..96eac70558 100644 --- a/test/tint/builtins/gen/literal/countLeadingZeros/208d46.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/countLeadingZeros/208d46.wgsl.expected.fxc.hlsl @@ -1,20 +1,5 @@ -uint tint_count_leading_zeros(uint v) { - uint x = uint(v); - const uint b16 = ((x <= 65535u) ? 16u : 0u); - x = (x << b16); - const uint b8 = ((x <= 16777215u) ? 8u : 0u); - x = (x << b8); - const uint b4 = ((x <= 268435455u) ? 4u : 0u); - x = (x << b4); - const uint b2 = ((x <= 1073741823u) ? 2u : 0u); - x = (x << b2); - const uint b1 = ((x <= 2147483647u) ? 1u : 0u); - const uint is_zero = ((x == 0u) ? 1u : 0u); - return uint((((((b16 | b8) | b4) | b2) | b1) + is_zero)); -} - void countLeadingZeros_208d46() { - uint res = tint_count_leading_zeros(1u); + uint res = 31u; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countLeadingZeros/208d46.wgsl.expected.glsl b/test/tint/builtins/gen/literal/countLeadingZeros/208d46.wgsl.expected.glsl index 4282edf614..feb6fa06ff 100644 --- a/test/tint/builtins/gen/literal/countLeadingZeros/208d46.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/countLeadingZeros/208d46.wgsl.expected.glsl @@ -1,22 +1,7 @@ #version 310 es -uint tint_count_leading_zeros(uint v) { - uint x = uint(v); - uint b16 = ((x <= 65535u) ? 16u : 0u); - x = (x << b16); - uint b8 = ((x <= 16777215u) ? 8u : 0u); - x = (x << b8); - uint b4 = ((x <= 268435455u) ? 4u : 0u); - x = (x << b4); - uint b2 = ((x <= 1073741823u) ? 2u : 0u); - x = (x << b2); - uint b1 = ((x <= 2147483647u) ? 1u : 0u); - uint is_zero = ((x == 0u) ? 1u : 0u); - return uint((((((b16 | b8) | b4) | b2) | b1) + is_zero)); -} - void countLeadingZeros_208d46() { - uint res = tint_count_leading_zeros(1u); + uint res = 31u; } vec4 vertex_main() { @@ -35,23 +20,8 @@ void main() { #version 310 es precision mediump float; -uint tint_count_leading_zeros(uint v) { - uint x = uint(v); - uint b16 = ((x <= 65535u) ? 16u : 0u); - x = (x << b16); - uint b8 = ((x <= 16777215u) ? 8u : 0u); - x = (x << b8); - uint b4 = ((x <= 268435455u) ? 4u : 0u); - x = (x << b4); - uint b2 = ((x <= 1073741823u) ? 2u : 0u); - x = (x << b2); - uint b1 = ((x <= 2147483647u) ? 1u : 0u); - uint is_zero = ((x == 0u) ? 1u : 0u); - return uint((((((b16 | b8) | b4) | b2) | b1) + is_zero)); -} - void countLeadingZeros_208d46() { - uint res = tint_count_leading_zeros(1u); + uint res = 31u; } void fragment_main() { @@ -64,23 +34,8 @@ void main() { } #version 310 es -uint tint_count_leading_zeros(uint v) { - uint x = uint(v); - uint b16 = ((x <= 65535u) ? 16u : 0u); - x = (x << b16); - uint b8 = ((x <= 16777215u) ? 8u : 0u); - x = (x << b8); - uint b4 = ((x <= 268435455u) ? 4u : 0u); - x = (x << b4); - uint b2 = ((x <= 1073741823u) ? 2u : 0u); - x = (x << b2); - uint b1 = ((x <= 2147483647u) ? 1u : 0u); - uint is_zero = ((x == 0u) ? 1u : 0u); - return uint((((((b16 | b8) | b4) | b2) | b1) + is_zero)); -} - void countLeadingZeros_208d46() { - uint res = tint_count_leading_zeros(1u); + uint res = 31u; } void compute_main() { diff --git a/test/tint/builtins/gen/literal/countLeadingZeros/208d46.wgsl.expected.msl b/test/tint/builtins/gen/literal/countLeadingZeros/208d46.wgsl.expected.msl index da0f3aec1b..29fb7c7108 100644 --- a/test/tint/builtins/gen/literal/countLeadingZeros/208d46.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/countLeadingZeros/208d46.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void countLeadingZeros_208d46() { - uint res = clz(1u); + uint res = 31u; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countLeadingZeros/208d46.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/countLeadingZeros/208d46.wgsl.expected.spvasm index 472bf589bf..6763e3272c 100644 --- a/test/tint/builtins/gen/literal/countLeadingZeros/208d46.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/countLeadingZeros/208d46.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 81 +; Bound: 32 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -12,9 +12,6 @@ OpExecutionMode %compute_main LocalSize 1 1 1 OpName %value "value" OpName %vertex_point_size "vertex_point_size" - OpName %tint_count_leading_zeros "tint_count_leading_zeros" - OpName %v "v" - OpName %x "x" OpName %countLeadingZeros_208d46 "countLeadingZeros_208d46" OpName %res "res" OpName %vertex_main_inner "vertex_main_inner" @@ -31,93 +28,39 @@ %_ptr_Output_float = OpTypePointer Output %float %8 = OpConstantNull %float %vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void %uint = OpTypeInt 32 0 - %9 = OpTypeFunction %uint %uint + %uint_31 = OpConstant %uint 31 %_ptr_Function_uint = OpTypePointer Function %uint %17 = OpConstantNull %uint - %uint_65535 = OpConstant %uint 65535 - %bool = OpTypeBool - %uint_16 = OpConstant %uint 16 -%uint_16777215 = OpConstant %uint 16777215 - %uint_8 = OpConstant %uint 8 -%uint_268435455 = OpConstant %uint 268435455 - %uint_4 = OpConstant %uint 4 -%uint_1073741823 = OpConstant %uint 1073741823 - %uint_2 = OpConstant %uint 2 -%uint_2147483647 = OpConstant %uint 2147483647 - %uint_1 = OpConstant %uint 1 - %void = OpTypeVoid - %61 = OpTypeFunction %void - %67 = OpTypeFunction %v4float + %18 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 -%tint_count_leading_zeros = OpFunction %uint None %9 - %v = OpFunctionParameter %uint - %13 = OpLabel - %x = OpVariable %_ptr_Function_uint Function %17 - OpStore %x %v - %19 = OpLoad %uint %x - %21 = OpULessThanEqual %bool %19 %uint_65535 - %18 = OpSelect %uint %21 %uint_16 %17 - %24 = OpLoad %uint %x - %25 = OpShiftLeftLogical %uint %24 %18 - OpStore %x %25 - %27 = OpLoad %uint %x - %29 = OpULessThanEqual %bool %27 %uint_16777215 - %26 = OpSelect %uint %29 %uint_8 %17 - %31 = OpLoad %uint %x - %32 = OpShiftLeftLogical %uint %31 %26 - OpStore %x %32 - %34 = OpLoad %uint %x - %36 = OpULessThanEqual %bool %34 %uint_268435455 - %33 = OpSelect %uint %36 %uint_4 %17 - %38 = OpLoad %uint %x - %39 = OpShiftLeftLogical %uint %38 %33 - OpStore %x %39 - %41 = OpLoad %uint %x - %43 = OpULessThanEqual %bool %41 %uint_1073741823 - %40 = OpSelect %uint %43 %uint_2 %17 - %45 = OpLoad %uint %x - %46 = OpShiftLeftLogical %uint %45 %40 - OpStore %x %46 - %48 = OpLoad %uint %x - %50 = OpULessThanEqual %bool %48 %uint_2147483647 - %47 = OpSelect %uint %50 %uint_1 %17 - %53 = OpLoad %uint %x - %54 = OpIEqual %bool %53 %17 - %52 = OpSelect %uint %54 %uint_1 %17 - %56 = OpBitwiseOr %uint %18 %26 - %57 = OpBitwiseOr %uint %56 %33 - %58 = OpBitwiseOr %uint %57 %40 - %59 = OpBitwiseOr %uint %58 %47 - %60 = OpIAdd %uint %59 %52 - OpReturnValue %60 - OpFunctionEnd -%countLeadingZeros_208d46 = OpFunction %void None %61 - %64 = OpLabel +%countLeadingZeros_208d46 = OpFunction %void None %9 + %12 = OpLabel %res = OpVariable %_ptr_Function_uint Function %17 - %65 = OpFunctionCall %uint %tint_count_leading_zeros %uint_1 - OpStore %res %65 + OpStore %res %uint_31 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %67 - %69 = OpLabel - %70 = OpFunctionCall %void %countLeadingZeros_208d46 +%vertex_main_inner = OpFunction %v4float None %18 + %20 = OpLabel + %21 = OpFunctionCall %void %countLeadingZeros_208d46 OpReturnValue %5 OpFunctionEnd -%vertex_main = OpFunction %void None %61 - %72 = OpLabel - %73 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %73 +%vertex_main = OpFunction %void None %9 + %23 = OpLabel + %24 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %24 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd -%fragment_main = OpFunction %void None %61 - %76 = OpLabel - %77 = OpFunctionCall %void %countLeadingZeros_208d46 +%fragment_main = OpFunction %void None %9 + %27 = OpLabel + %28 = OpFunctionCall %void %countLeadingZeros_208d46 OpReturn OpFunctionEnd -%compute_main = OpFunction %void None %61 - %79 = OpLabel - %80 = OpFunctionCall %void %countLeadingZeros_208d46 +%compute_main = OpFunction %void None %9 + %30 = OpLabel + %31 = OpFunctionCall %void %countLeadingZeros_208d46 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/countLeadingZeros/6d4656.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/countLeadingZeros/6d4656.wgsl.expected.dxc.hlsl index c31a77cf2e..5bf5346847 100644 --- a/test/tint/builtins/gen/literal/countLeadingZeros/6d4656.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/countLeadingZeros/6d4656.wgsl.expected.dxc.hlsl @@ -1,20 +1,5 @@ -int tint_count_leading_zeros(int v) { - uint x = uint(v); - const uint b16 = ((x <= 65535u) ? 16u : 0u); - x = (x << b16); - const uint b8 = ((x <= 16777215u) ? 8u : 0u); - x = (x << b8); - const uint b4 = ((x <= 268435455u) ? 4u : 0u); - x = (x << b4); - const uint b2 = ((x <= 1073741823u) ? 2u : 0u); - x = (x << b2); - const uint b1 = ((x <= 2147483647u) ? 1u : 0u); - const uint is_zero = ((x == 0u) ? 1u : 0u); - return int((((((b16 | b8) | b4) | b2) | b1) + is_zero)); -} - void countLeadingZeros_6d4656() { - int res = tint_count_leading_zeros(1); + int res = 31; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countLeadingZeros/6d4656.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/countLeadingZeros/6d4656.wgsl.expected.fxc.hlsl index c31a77cf2e..5bf5346847 100644 --- a/test/tint/builtins/gen/literal/countLeadingZeros/6d4656.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/countLeadingZeros/6d4656.wgsl.expected.fxc.hlsl @@ -1,20 +1,5 @@ -int tint_count_leading_zeros(int v) { - uint x = uint(v); - const uint b16 = ((x <= 65535u) ? 16u : 0u); - x = (x << b16); - const uint b8 = ((x <= 16777215u) ? 8u : 0u); - x = (x << b8); - const uint b4 = ((x <= 268435455u) ? 4u : 0u); - x = (x << b4); - const uint b2 = ((x <= 1073741823u) ? 2u : 0u); - x = (x << b2); - const uint b1 = ((x <= 2147483647u) ? 1u : 0u); - const uint is_zero = ((x == 0u) ? 1u : 0u); - return int((((((b16 | b8) | b4) | b2) | b1) + is_zero)); -} - void countLeadingZeros_6d4656() { - int res = tint_count_leading_zeros(1); + int res = 31; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countLeadingZeros/6d4656.wgsl.expected.glsl b/test/tint/builtins/gen/literal/countLeadingZeros/6d4656.wgsl.expected.glsl index d9b4f1d9e6..cb7bcb7a65 100644 --- a/test/tint/builtins/gen/literal/countLeadingZeros/6d4656.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/countLeadingZeros/6d4656.wgsl.expected.glsl @@ -1,22 +1,7 @@ #version 310 es -int tint_count_leading_zeros(int v) { - uint x = uint(v); - uint b16 = ((x <= 65535u) ? 16u : 0u); - x = (x << b16); - uint b8 = ((x <= 16777215u) ? 8u : 0u); - x = (x << b8); - uint b4 = ((x <= 268435455u) ? 4u : 0u); - x = (x << b4); - uint b2 = ((x <= 1073741823u) ? 2u : 0u); - x = (x << b2); - uint b1 = ((x <= 2147483647u) ? 1u : 0u); - uint is_zero = ((x == 0u) ? 1u : 0u); - return int((((((b16 | b8) | b4) | b2) | b1) + is_zero)); -} - void countLeadingZeros_6d4656() { - int res = tint_count_leading_zeros(1); + int res = 31; } vec4 vertex_main() { @@ -35,23 +20,8 @@ void main() { #version 310 es precision mediump float; -int tint_count_leading_zeros(int v) { - uint x = uint(v); - uint b16 = ((x <= 65535u) ? 16u : 0u); - x = (x << b16); - uint b8 = ((x <= 16777215u) ? 8u : 0u); - x = (x << b8); - uint b4 = ((x <= 268435455u) ? 4u : 0u); - x = (x << b4); - uint b2 = ((x <= 1073741823u) ? 2u : 0u); - x = (x << b2); - uint b1 = ((x <= 2147483647u) ? 1u : 0u); - uint is_zero = ((x == 0u) ? 1u : 0u); - return int((((((b16 | b8) | b4) | b2) | b1) + is_zero)); -} - void countLeadingZeros_6d4656() { - int res = tint_count_leading_zeros(1); + int res = 31; } void fragment_main() { @@ -64,23 +34,8 @@ void main() { } #version 310 es -int tint_count_leading_zeros(int v) { - uint x = uint(v); - uint b16 = ((x <= 65535u) ? 16u : 0u); - x = (x << b16); - uint b8 = ((x <= 16777215u) ? 8u : 0u); - x = (x << b8); - uint b4 = ((x <= 268435455u) ? 4u : 0u); - x = (x << b4); - uint b2 = ((x <= 1073741823u) ? 2u : 0u); - x = (x << b2); - uint b1 = ((x <= 2147483647u) ? 1u : 0u); - uint is_zero = ((x == 0u) ? 1u : 0u); - return int((((((b16 | b8) | b4) | b2) | b1) + is_zero)); -} - void countLeadingZeros_6d4656() { - int res = tint_count_leading_zeros(1); + int res = 31; } void compute_main() { diff --git a/test/tint/builtins/gen/literal/countLeadingZeros/6d4656.wgsl.expected.msl b/test/tint/builtins/gen/literal/countLeadingZeros/6d4656.wgsl.expected.msl index 3a085a5dbf..fdfcd6dc31 100644 --- a/test/tint/builtins/gen/literal/countLeadingZeros/6d4656.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/countLeadingZeros/6d4656.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void countLeadingZeros_6d4656() { - int res = clz(1); + int res = 31; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countLeadingZeros/6d4656.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/countLeadingZeros/6d4656.wgsl.expected.spvasm index 4e73e3f0a9..de27ef12de 100644 --- a/test/tint/builtins/gen/literal/countLeadingZeros/6d4656.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/countLeadingZeros/6d4656.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 85 +; Bound: 32 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -12,9 +12,6 @@ OpExecutionMode %compute_main LocalSize 1 1 1 OpName %value "value" OpName %vertex_point_size "vertex_point_size" - OpName %tint_count_leading_zeros "tint_count_leading_zeros" - OpName %v "v" - OpName %x "x" OpName %countLeadingZeros_6d4656 "countLeadingZeros_6d4656" OpName %res "res" OpName %vertex_main_inner "vertex_main_inner" @@ -31,99 +28,39 @@ %_ptr_Output_float = OpTypePointer Output %float %8 = OpConstantNull %float %vertex_point_size = OpVariable %_ptr_Output_float Output %8 - %int = OpTypeInt 32 1 - %9 = OpTypeFunction %int %int - %uint = OpTypeInt 32 0 -%_ptr_Function_uint = OpTypePointer Function %uint - %18 = OpConstantNull %uint - %uint_65535 = OpConstant %uint 65535 - %bool = OpTypeBool - %uint_16 = OpConstant %uint 16 -%uint_16777215 = OpConstant %uint 16777215 - %uint_8 = OpConstant %uint 8 -%uint_268435455 = OpConstant %uint 268435455 - %uint_4 = OpConstant %uint 4 -%uint_1073741823 = OpConstant %uint 1073741823 - %uint_2 = OpConstant %uint 2 -%uint_2147483647 = OpConstant %uint 2147483647 - %uint_1 = OpConstant %uint 1 %void = OpTypeVoid - %62 = OpTypeFunction %void - %int_1 = OpConstant %int 1 + %9 = OpTypeFunction %void + %int = OpTypeInt 32 1 + %int_31 = OpConstant %int 31 %_ptr_Function_int = OpTypePointer Function %int - %70 = OpConstantNull %int - %71 = OpTypeFunction %v4float + %17 = OpConstantNull %int + %18 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 -%tint_count_leading_zeros = OpFunction %int None %9 - %v = OpFunctionParameter %int - %13 = OpLabel - %x = OpVariable %_ptr_Function_uint Function %18 - %14 = OpBitcast %uint %v - OpStore %x %14 - %20 = OpLoad %uint %x - %22 = OpULessThanEqual %bool %20 %uint_65535 - %19 = OpSelect %uint %22 %uint_16 %18 - %25 = OpLoad %uint %x - %26 = OpShiftLeftLogical %uint %25 %19 - OpStore %x %26 - %28 = OpLoad %uint %x - %30 = OpULessThanEqual %bool %28 %uint_16777215 - %27 = OpSelect %uint %30 %uint_8 %18 - %32 = OpLoad %uint %x - %33 = OpShiftLeftLogical %uint %32 %27 - OpStore %x %33 - %35 = OpLoad %uint %x - %37 = OpULessThanEqual %bool %35 %uint_268435455 - %34 = OpSelect %uint %37 %uint_4 %18 - %39 = OpLoad %uint %x - %40 = OpShiftLeftLogical %uint %39 %34 - OpStore %x %40 - %42 = OpLoad %uint %x - %44 = OpULessThanEqual %bool %42 %uint_1073741823 - %41 = OpSelect %uint %44 %uint_2 %18 - %46 = OpLoad %uint %x - %47 = OpShiftLeftLogical %uint %46 %41 - OpStore %x %47 - %49 = OpLoad %uint %x - %51 = OpULessThanEqual %bool %49 %uint_2147483647 - %48 = OpSelect %uint %51 %uint_1 %18 - %54 = OpLoad %uint %x - %55 = OpIEqual %bool %54 %18 - %53 = OpSelect %uint %55 %uint_1 %18 - %57 = OpBitwiseOr %uint %19 %27 - %58 = OpBitwiseOr %uint %57 %34 - %59 = OpBitwiseOr %uint %58 %41 - %60 = OpBitwiseOr %uint %59 %48 - %61 = OpIAdd %uint %60 %53 - %56 = OpBitcast %int %61 - OpReturnValue %56 - OpFunctionEnd -%countLeadingZeros_6d4656 = OpFunction %void None %62 - %65 = OpLabel - %res = OpVariable %_ptr_Function_int Function %70 - %66 = OpFunctionCall %int %tint_count_leading_zeros %int_1 - OpStore %res %66 +%countLeadingZeros_6d4656 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_int Function %17 + OpStore %res %int_31 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %71 - %73 = OpLabel - %74 = OpFunctionCall %void %countLeadingZeros_6d4656 +%vertex_main_inner = OpFunction %v4float None %18 + %20 = OpLabel + %21 = OpFunctionCall %void %countLeadingZeros_6d4656 OpReturnValue %5 OpFunctionEnd -%vertex_main = OpFunction %void None %62 - %76 = OpLabel - %77 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %77 +%vertex_main = OpFunction %void None %9 + %23 = OpLabel + %24 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %24 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd -%fragment_main = OpFunction %void None %62 - %80 = OpLabel - %81 = OpFunctionCall %void %countLeadingZeros_6d4656 +%fragment_main = OpFunction %void None %9 + %27 = OpLabel + %28 = OpFunctionCall %void %countLeadingZeros_6d4656 OpReturn OpFunctionEnd -%compute_main = OpFunction %void None %62 - %83 = OpLabel - %84 = OpFunctionCall %void %countLeadingZeros_6d4656 +%compute_main = OpFunction %void None %9 + %30 = OpLabel + %31 = OpFunctionCall %void %countLeadingZeros_6d4656 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/countLeadingZeros/70783f.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/countLeadingZeros/70783f.wgsl.expected.dxc.hlsl index 60ae7159e9..81dd0ff75f 100644 --- a/test/tint/builtins/gen/literal/countLeadingZeros/70783f.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/countLeadingZeros/70783f.wgsl.expected.dxc.hlsl @@ -1,20 +1,5 @@ -uint2 tint_count_leading_zeros(uint2 v) { - uint2 x = uint2(v); - const uint2 b16 = ((x <= (65535u).xx) ? (16u).xx : (0u).xx); - x = (x << b16); - const uint2 b8 = ((x <= (16777215u).xx) ? (8u).xx : (0u).xx); - x = (x << b8); - const uint2 b4 = ((x <= (268435455u).xx) ? (4u).xx : (0u).xx); - x = (x << b4); - const uint2 b2 = ((x <= (1073741823u).xx) ? (2u).xx : (0u).xx); - x = (x << b2); - const uint2 b1 = ((x <= (2147483647u).xx) ? (1u).xx : (0u).xx); - const uint2 is_zero = ((x == (0u).xx) ? (1u).xx : (0u).xx); - return uint2((((((b16 | b8) | b4) | b2) | b1) + is_zero)); -} - void countLeadingZeros_70783f() { - uint2 res = tint_count_leading_zeros((1u).xx); + uint2 res = (31u).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countLeadingZeros/70783f.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/countLeadingZeros/70783f.wgsl.expected.fxc.hlsl index 60ae7159e9..81dd0ff75f 100644 --- a/test/tint/builtins/gen/literal/countLeadingZeros/70783f.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/countLeadingZeros/70783f.wgsl.expected.fxc.hlsl @@ -1,20 +1,5 @@ -uint2 tint_count_leading_zeros(uint2 v) { - uint2 x = uint2(v); - const uint2 b16 = ((x <= (65535u).xx) ? (16u).xx : (0u).xx); - x = (x << b16); - const uint2 b8 = ((x <= (16777215u).xx) ? (8u).xx : (0u).xx); - x = (x << b8); - const uint2 b4 = ((x <= (268435455u).xx) ? (4u).xx : (0u).xx); - x = (x << b4); - const uint2 b2 = ((x <= (1073741823u).xx) ? (2u).xx : (0u).xx); - x = (x << b2); - const uint2 b1 = ((x <= (2147483647u).xx) ? (1u).xx : (0u).xx); - const uint2 is_zero = ((x == (0u).xx) ? (1u).xx : (0u).xx); - return uint2((((((b16 | b8) | b4) | b2) | b1) + is_zero)); -} - void countLeadingZeros_70783f() { - uint2 res = tint_count_leading_zeros((1u).xx); + uint2 res = (31u).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countLeadingZeros/70783f.wgsl.expected.glsl b/test/tint/builtins/gen/literal/countLeadingZeros/70783f.wgsl.expected.glsl index 09b8cfe3d0..93bbc080f5 100644 --- a/test/tint/builtins/gen/literal/countLeadingZeros/70783f.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/countLeadingZeros/70783f.wgsl.expected.glsl @@ -1,22 +1,7 @@ #version 310 es -uvec2 tint_count_leading_zeros(uvec2 v) { - uvec2 x = uvec2(v); - uvec2 b16 = mix(uvec2(0u), uvec2(16u), lessThanEqual(x, uvec2(65535u))); - x = (x << b16); - uvec2 b8 = mix(uvec2(0u), uvec2(8u), lessThanEqual(x, uvec2(16777215u))); - x = (x << b8); - uvec2 b4 = mix(uvec2(0u), uvec2(4u), lessThanEqual(x, uvec2(268435455u))); - x = (x << b4); - uvec2 b2 = mix(uvec2(0u), uvec2(2u), lessThanEqual(x, uvec2(1073741823u))); - x = (x << b2); - uvec2 b1 = mix(uvec2(0u), uvec2(1u), lessThanEqual(x, uvec2(2147483647u))); - uvec2 is_zero = mix(uvec2(0u), uvec2(1u), equal(x, uvec2(0u))); - return uvec2((((((b16 | b8) | b4) | b2) | b1) + is_zero)); -} - void countLeadingZeros_70783f() { - uvec2 res = tint_count_leading_zeros(uvec2(1u)); + uvec2 res = uvec2(31u); } vec4 vertex_main() { @@ -35,23 +20,8 @@ void main() { #version 310 es precision mediump float; -uvec2 tint_count_leading_zeros(uvec2 v) { - uvec2 x = uvec2(v); - uvec2 b16 = mix(uvec2(0u), uvec2(16u), lessThanEqual(x, uvec2(65535u))); - x = (x << b16); - uvec2 b8 = mix(uvec2(0u), uvec2(8u), lessThanEqual(x, uvec2(16777215u))); - x = (x << b8); - uvec2 b4 = mix(uvec2(0u), uvec2(4u), lessThanEqual(x, uvec2(268435455u))); - x = (x << b4); - uvec2 b2 = mix(uvec2(0u), uvec2(2u), lessThanEqual(x, uvec2(1073741823u))); - x = (x << b2); - uvec2 b1 = mix(uvec2(0u), uvec2(1u), lessThanEqual(x, uvec2(2147483647u))); - uvec2 is_zero = mix(uvec2(0u), uvec2(1u), equal(x, uvec2(0u))); - return uvec2((((((b16 | b8) | b4) | b2) | b1) + is_zero)); -} - void countLeadingZeros_70783f() { - uvec2 res = tint_count_leading_zeros(uvec2(1u)); + uvec2 res = uvec2(31u); } void fragment_main() { @@ -64,23 +34,8 @@ void main() { } #version 310 es -uvec2 tint_count_leading_zeros(uvec2 v) { - uvec2 x = uvec2(v); - uvec2 b16 = mix(uvec2(0u), uvec2(16u), lessThanEqual(x, uvec2(65535u))); - x = (x << b16); - uvec2 b8 = mix(uvec2(0u), uvec2(8u), lessThanEqual(x, uvec2(16777215u))); - x = (x << b8); - uvec2 b4 = mix(uvec2(0u), uvec2(4u), lessThanEqual(x, uvec2(268435455u))); - x = (x << b4); - uvec2 b2 = mix(uvec2(0u), uvec2(2u), lessThanEqual(x, uvec2(1073741823u))); - x = (x << b2); - uvec2 b1 = mix(uvec2(0u), uvec2(1u), lessThanEqual(x, uvec2(2147483647u))); - uvec2 is_zero = mix(uvec2(0u), uvec2(1u), equal(x, uvec2(0u))); - return uvec2((((((b16 | b8) | b4) | b2) | b1) + is_zero)); -} - void countLeadingZeros_70783f() { - uvec2 res = tint_count_leading_zeros(uvec2(1u)); + uvec2 res = uvec2(31u); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/countLeadingZeros/70783f.wgsl.expected.msl b/test/tint/builtins/gen/literal/countLeadingZeros/70783f.wgsl.expected.msl index 9758cd3383..959711d361 100644 --- a/test/tint/builtins/gen/literal/countLeadingZeros/70783f.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/countLeadingZeros/70783f.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void countLeadingZeros_70783f() { - uint2 res = clz(uint2(1u)); + uint2 res = uint2(31u); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countLeadingZeros/70783f.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/countLeadingZeros/70783f.wgsl.expected.spvasm index aa1288499b..86252e8288 100644 --- a/test/tint/builtins/gen/literal/countLeadingZeros/70783f.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/countLeadingZeros/70783f.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 93 +; Bound: 34 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -12,9 +12,6 @@ OpExecutionMode %compute_main LocalSize 1 1 1 OpName %value "value" OpName %vertex_point_size "vertex_point_size" - OpName %tint_count_leading_zeros "tint_count_leading_zeros" - OpName %v "v" - OpName %x "x" OpName %countLeadingZeros_70783f "countLeadingZeros_70783f" OpName %res "res" OpName %vertex_main_inner "vertex_main_inner" @@ -31,105 +28,41 @@ %_ptr_Output_float = OpTypePointer Output %float %8 = OpConstantNull %float %vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void %uint = OpTypeInt 32 0 %v2uint = OpTypeVector %uint 2 - %9 = OpTypeFunction %v2uint %v2uint + %uint_31 = OpConstant %uint 31 + %16 = OpConstantComposite %v2uint %uint_31 %uint_31 %_ptr_Function_v2uint = OpTypePointer Function %v2uint - %18 = OpConstantNull %v2uint - %uint_65535 = OpConstant %uint 65535 - %22 = OpConstantComposite %v2uint %uint_65535 %uint_65535 - %bool = OpTypeBool - %v2bool = OpTypeVector %bool 2 - %uint_16 = OpConstant %uint 16 - %27 = OpConstantComposite %v2uint %uint_16 %uint_16 -%uint_16777215 = OpConstant %uint 16777215 - %33 = OpConstantComposite %v2uint %uint_16777215 %uint_16777215 - %uint_8 = OpConstant %uint 8 - %36 = OpConstantComposite %v2uint %uint_8 %uint_8 -%uint_268435455 = OpConstant %uint 268435455 - %42 = OpConstantComposite %v2uint %uint_268435455 %uint_268435455 - %uint_4 = OpConstant %uint 4 - %45 = OpConstantComposite %v2uint %uint_4 %uint_4 -%uint_1073741823 = OpConstant %uint 1073741823 - %51 = OpConstantComposite %v2uint %uint_1073741823 %uint_1073741823 - %uint_2 = OpConstant %uint 2 - %54 = OpConstantComposite %v2uint %uint_2 %uint_2 -%uint_2147483647 = OpConstant %uint 2147483647 - %60 = OpConstantComposite %v2uint %uint_2147483647 %uint_2147483647 - %uint_1 = OpConstant %uint 1 - %63 = OpConstantComposite %v2uint %uint_1 %uint_1 - %void = OpTypeVoid - %73 = OpTypeFunction %void - %79 = OpTypeFunction %v4float + %19 = OpConstantNull %v2uint + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 -%tint_count_leading_zeros = OpFunction %v2uint None %9 - %v = OpFunctionParameter %v2uint - %14 = OpLabel - %x = OpVariable %_ptr_Function_v2uint Function %18 - OpStore %x %v - %20 = OpLoad %v2uint %x - %23 = OpULessThanEqual %v2bool %20 %22 - %19 = OpSelect %v2uint %23 %27 %18 - %28 = OpLoad %v2uint %x - %29 = OpShiftLeftLogical %v2uint %28 %19 - OpStore %x %29 - %31 = OpLoad %v2uint %x - %34 = OpULessThanEqual %v2bool %31 %33 - %30 = OpSelect %v2uint %34 %36 %18 - %37 = OpLoad %v2uint %x - %38 = OpShiftLeftLogical %v2uint %37 %30 - OpStore %x %38 - %40 = OpLoad %v2uint %x - %43 = OpULessThanEqual %v2bool %40 %42 - %39 = OpSelect %v2uint %43 %45 %18 - %46 = OpLoad %v2uint %x - %47 = OpShiftLeftLogical %v2uint %46 %39 - OpStore %x %47 - %49 = OpLoad %v2uint %x - %52 = OpULessThanEqual %v2bool %49 %51 - %48 = OpSelect %v2uint %52 %54 %18 - %55 = OpLoad %v2uint %x - %56 = OpShiftLeftLogical %v2uint %55 %48 - OpStore %x %56 - %58 = OpLoad %v2uint %x - %61 = OpULessThanEqual %v2bool %58 %60 - %57 = OpSelect %v2uint %61 %63 %18 - %65 = OpLoad %v2uint %x - %66 = OpIEqual %v2bool %65 %18 - %64 = OpSelect %v2uint %66 %63 %18 - %68 = OpBitwiseOr %v2uint %19 %30 - %69 = OpBitwiseOr %v2uint %68 %39 - %70 = OpBitwiseOr %v2uint %69 %48 - %71 = OpBitwiseOr %v2uint %70 %57 - %72 = OpIAdd %v2uint %71 %64 - OpReturnValue %72 - OpFunctionEnd -%countLeadingZeros_70783f = OpFunction %void None %73 - %76 = OpLabel - %res = OpVariable %_ptr_Function_v2uint Function %18 - %77 = OpFunctionCall %v2uint %tint_count_leading_zeros %63 - OpStore %res %77 +%countLeadingZeros_70783f = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v2uint Function %19 + OpStore %res %16 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %79 - %81 = OpLabel - %82 = OpFunctionCall %void %countLeadingZeros_70783f +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %countLeadingZeros_70783f OpReturnValue %5 OpFunctionEnd -%vertex_main = OpFunction %void None %73 - %84 = OpLabel - %85 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %85 +%vertex_main = OpFunction %void None %9 + %25 = OpLabel + %26 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %26 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd -%fragment_main = OpFunction %void None %73 - %88 = OpLabel - %89 = OpFunctionCall %void %countLeadingZeros_70783f +%fragment_main = OpFunction %void None %9 + %29 = OpLabel + %30 = OpFunctionCall %void %countLeadingZeros_70783f OpReturn OpFunctionEnd -%compute_main = OpFunction %void None %73 - %91 = OpLabel - %92 = OpFunctionCall %void %countLeadingZeros_70783f +%compute_main = OpFunction %void None %9 + %32 = OpLabel + %33 = OpFunctionCall %void %countLeadingZeros_70783f OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/countLeadingZeros/7c38a6.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/countLeadingZeros/7c38a6.wgsl.expected.dxc.hlsl index fbc0183ce7..44d17f8abd 100644 --- a/test/tint/builtins/gen/literal/countLeadingZeros/7c38a6.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/countLeadingZeros/7c38a6.wgsl.expected.dxc.hlsl @@ -1,20 +1,5 @@ -int3 tint_count_leading_zeros(int3 v) { - uint3 x = uint3(v); - const uint3 b16 = ((x <= (65535u).xxx) ? (16u).xxx : (0u).xxx); - x = (x << b16); - const uint3 b8 = ((x <= (16777215u).xxx) ? (8u).xxx : (0u).xxx); - x = (x << b8); - const uint3 b4 = ((x <= (268435455u).xxx) ? (4u).xxx : (0u).xxx); - x = (x << b4); - const uint3 b2 = ((x <= (1073741823u).xxx) ? (2u).xxx : (0u).xxx); - x = (x << b2); - const uint3 b1 = ((x <= (2147483647u).xxx) ? (1u).xxx : (0u).xxx); - const uint3 is_zero = ((x == (0u).xxx) ? (1u).xxx : (0u).xxx); - return int3((((((b16 | b8) | b4) | b2) | b1) + is_zero)); -} - void countLeadingZeros_7c38a6() { - int3 res = tint_count_leading_zeros((1).xxx); + int3 res = (31).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countLeadingZeros/7c38a6.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/countLeadingZeros/7c38a6.wgsl.expected.fxc.hlsl index fbc0183ce7..44d17f8abd 100644 --- a/test/tint/builtins/gen/literal/countLeadingZeros/7c38a6.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/countLeadingZeros/7c38a6.wgsl.expected.fxc.hlsl @@ -1,20 +1,5 @@ -int3 tint_count_leading_zeros(int3 v) { - uint3 x = uint3(v); - const uint3 b16 = ((x <= (65535u).xxx) ? (16u).xxx : (0u).xxx); - x = (x << b16); - const uint3 b8 = ((x <= (16777215u).xxx) ? (8u).xxx : (0u).xxx); - x = (x << b8); - const uint3 b4 = ((x <= (268435455u).xxx) ? (4u).xxx : (0u).xxx); - x = (x << b4); - const uint3 b2 = ((x <= (1073741823u).xxx) ? (2u).xxx : (0u).xxx); - x = (x << b2); - const uint3 b1 = ((x <= (2147483647u).xxx) ? (1u).xxx : (0u).xxx); - const uint3 is_zero = ((x == (0u).xxx) ? (1u).xxx : (0u).xxx); - return int3((((((b16 | b8) | b4) | b2) | b1) + is_zero)); -} - void countLeadingZeros_7c38a6() { - int3 res = tint_count_leading_zeros((1).xxx); + int3 res = (31).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countLeadingZeros/7c38a6.wgsl.expected.glsl b/test/tint/builtins/gen/literal/countLeadingZeros/7c38a6.wgsl.expected.glsl index daf451ff67..e1ec7fabe1 100644 --- a/test/tint/builtins/gen/literal/countLeadingZeros/7c38a6.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/countLeadingZeros/7c38a6.wgsl.expected.glsl @@ -1,22 +1,7 @@ #version 310 es -ivec3 tint_count_leading_zeros(ivec3 v) { - uvec3 x = uvec3(v); - uvec3 b16 = mix(uvec3(0u), uvec3(16u), lessThanEqual(x, uvec3(65535u))); - x = (x << b16); - uvec3 b8 = mix(uvec3(0u), uvec3(8u), lessThanEqual(x, uvec3(16777215u))); - x = (x << b8); - uvec3 b4 = mix(uvec3(0u), uvec3(4u), lessThanEqual(x, uvec3(268435455u))); - x = (x << b4); - uvec3 b2 = mix(uvec3(0u), uvec3(2u), lessThanEqual(x, uvec3(1073741823u))); - x = (x << b2); - uvec3 b1 = mix(uvec3(0u), uvec3(1u), lessThanEqual(x, uvec3(2147483647u))); - uvec3 is_zero = mix(uvec3(0u), uvec3(1u), equal(x, uvec3(0u))); - return ivec3((((((b16 | b8) | b4) | b2) | b1) + is_zero)); -} - void countLeadingZeros_7c38a6() { - ivec3 res = tint_count_leading_zeros(ivec3(1)); + ivec3 res = ivec3(31); } vec4 vertex_main() { @@ -35,23 +20,8 @@ void main() { #version 310 es precision mediump float; -ivec3 tint_count_leading_zeros(ivec3 v) { - uvec3 x = uvec3(v); - uvec3 b16 = mix(uvec3(0u), uvec3(16u), lessThanEqual(x, uvec3(65535u))); - x = (x << b16); - uvec3 b8 = mix(uvec3(0u), uvec3(8u), lessThanEqual(x, uvec3(16777215u))); - x = (x << b8); - uvec3 b4 = mix(uvec3(0u), uvec3(4u), lessThanEqual(x, uvec3(268435455u))); - x = (x << b4); - uvec3 b2 = mix(uvec3(0u), uvec3(2u), lessThanEqual(x, uvec3(1073741823u))); - x = (x << b2); - uvec3 b1 = mix(uvec3(0u), uvec3(1u), lessThanEqual(x, uvec3(2147483647u))); - uvec3 is_zero = mix(uvec3(0u), uvec3(1u), equal(x, uvec3(0u))); - return ivec3((((((b16 | b8) | b4) | b2) | b1) + is_zero)); -} - void countLeadingZeros_7c38a6() { - ivec3 res = tint_count_leading_zeros(ivec3(1)); + ivec3 res = ivec3(31); } void fragment_main() { @@ -64,23 +34,8 @@ void main() { } #version 310 es -ivec3 tint_count_leading_zeros(ivec3 v) { - uvec3 x = uvec3(v); - uvec3 b16 = mix(uvec3(0u), uvec3(16u), lessThanEqual(x, uvec3(65535u))); - x = (x << b16); - uvec3 b8 = mix(uvec3(0u), uvec3(8u), lessThanEqual(x, uvec3(16777215u))); - x = (x << b8); - uvec3 b4 = mix(uvec3(0u), uvec3(4u), lessThanEqual(x, uvec3(268435455u))); - x = (x << b4); - uvec3 b2 = mix(uvec3(0u), uvec3(2u), lessThanEqual(x, uvec3(1073741823u))); - x = (x << b2); - uvec3 b1 = mix(uvec3(0u), uvec3(1u), lessThanEqual(x, uvec3(2147483647u))); - uvec3 is_zero = mix(uvec3(0u), uvec3(1u), equal(x, uvec3(0u))); - return ivec3((((((b16 | b8) | b4) | b2) | b1) + is_zero)); -} - void countLeadingZeros_7c38a6() { - ivec3 res = tint_count_leading_zeros(ivec3(1)); + ivec3 res = ivec3(31); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/countLeadingZeros/7c38a6.wgsl.expected.msl b/test/tint/builtins/gen/literal/countLeadingZeros/7c38a6.wgsl.expected.msl index dcab0ad5dd..78f1f03726 100644 --- a/test/tint/builtins/gen/literal/countLeadingZeros/7c38a6.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/countLeadingZeros/7c38a6.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void countLeadingZeros_7c38a6() { - int3 res = clz(int3(1)); + int3 res = int3(31); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countLeadingZeros/7c38a6.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/countLeadingZeros/7c38a6.wgsl.expected.spvasm index b68f4a6f97..51e0fc1458 100644 --- a/test/tint/builtins/gen/literal/countLeadingZeros/7c38a6.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/countLeadingZeros/7c38a6.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 99 +; Bound: 34 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -12,9 +12,6 @@ OpExecutionMode %compute_main LocalSize 1 1 1 OpName %value "value" OpName %vertex_point_size "vertex_point_size" - OpName %tint_count_leading_zeros "tint_count_leading_zeros" - OpName %v "v" - OpName %x "x" OpName %countLeadingZeros_7c38a6 "countLeadingZeros_7c38a6" OpName %res "res" OpName %vertex_main_inner "vertex_main_inner" @@ -31,113 +28,41 @@ %_ptr_Output_float = OpTypePointer Output %float %8 = OpConstantNull %float %vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void %int = OpTypeInt 32 1 %v3int = OpTypeVector %int 3 - %9 = OpTypeFunction %v3int %v3int - %uint = OpTypeInt 32 0 - %v3uint = OpTypeVector %uint 3 -%_ptr_Function_v3uint = OpTypePointer Function %v3uint - %20 = OpConstantNull %v3uint - %uint_65535 = OpConstant %uint 65535 - %24 = OpConstantComposite %v3uint %uint_65535 %uint_65535 %uint_65535 - %bool = OpTypeBool - %v3bool = OpTypeVector %bool 3 - %uint_16 = OpConstant %uint 16 - %29 = OpConstantComposite %v3uint %uint_16 %uint_16 %uint_16 -%uint_16777215 = OpConstant %uint 16777215 - %35 = OpConstantComposite %v3uint %uint_16777215 %uint_16777215 %uint_16777215 - %uint_8 = OpConstant %uint 8 - %38 = OpConstantComposite %v3uint %uint_8 %uint_8 %uint_8 -%uint_268435455 = OpConstant %uint 268435455 - %44 = OpConstantComposite %v3uint %uint_268435455 %uint_268435455 %uint_268435455 - %uint_4 = OpConstant %uint 4 - %47 = OpConstantComposite %v3uint %uint_4 %uint_4 %uint_4 -%uint_1073741823 = OpConstant %uint 1073741823 - %53 = OpConstantComposite %v3uint %uint_1073741823 %uint_1073741823 %uint_1073741823 - %uint_2 = OpConstant %uint 2 - %56 = OpConstantComposite %v3uint %uint_2 %uint_2 %uint_2 -%uint_2147483647 = OpConstant %uint 2147483647 - %62 = OpConstantComposite %v3uint %uint_2147483647 %uint_2147483647 %uint_2147483647 - %uint_1 = OpConstant %uint 1 - %65 = OpConstantComposite %v3uint %uint_1 %uint_1 %uint_1 - %void = OpTypeVoid - %75 = OpTypeFunction %void - %int_1 = OpConstant %int 1 - %81 = OpConstantComposite %v3int %int_1 %int_1 %int_1 + %int_31 = OpConstant %int 31 + %16 = OpConstantComposite %v3int %int_31 %int_31 %int_31 %_ptr_Function_v3int = OpTypePointer Function %v3int - %84 = OpConstantNull %v3int - %85 = OpTypeFunction %v4float + %19 = OpConstantNull %v3int + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 -%tint_count_leading_zeros = OpFunction %v3int None %9 - %v = OpFunctionParameter %v3int - %14 = OpLabel - %x = OpVariable %_ptr_Function_v3uint Function %20 - %15 = OpBitcast %v3uint %v - OpStore %x %15 - %22 = OpLoad %v3uint %x - %25 = OpULessThanEqual %v3bool %22 %24 - %21 = OpSelect %v3uint %25 %29 %20 - %30 = OpLoad %v3uint %x - %31 = OpShiftLeftLogical %v3uint %30 %21 - OpStore %x %31 - %33 = OpLoad %v3uint %x - %36 = OpULessThanEqual %v3bool %33 %35 - %32 = OpSelect %v3uint %36 %38 %20 - %39 = OpLoad %v3uint %x - %40 = OpShiftLeftLogical %v3uint %39 %32 - OpStore %x %40 - %42 = OpLoad %v3uint %x - %45 = OpULessThanEqual %v3bool %42 %44 - %41 = OpSelect %v3uint %45 %47 %20 - %48 = OpLoad %v3uint %x - %49 = OpShiftLeftLogical %v3uint %48 %41 - OpStore %x %49 - %51 = OpLoad %v3uint %x - %54 = OpULessThanEqual %v3bool %51 %53 - %50 = OpSelect %v3uint %54 %56 %20 - %57 = OpLoad %v3uint %x - %58 = OpShiftLeftLogical %v3uint %57 %50 - OpStore %x %58 - %60 = OpLoad %v3uint %x - %63 = OpULessThanEqual %v3bool %60 %62 - %59 = OpSelect %v3uint %63 %65 %20 - %67 = OpLoad %v3uint %x - %68 = OpIEqual %v3bool %67 %20 - %66 = OpSelect %v3uint %68 %65 %20 - %70 = OpBitwiseOr %v3uint %21 %32 - %71 = OpBitwiseOr %v3uint %70 %41 - %72 = OpBitwiseOr %v3uint %71 %50 - %73 = OpBitwiseOr %v3uint %72 %59 - %74 = OpIAdd %v3uint %73 %66 - %69 = OpBitcast %v3int %74 - OpReturnValue %69 - OpFunctionEnd -%countLeadingZeros_7c38a6 = OpFunction %void None %75 - %78 = OpLabel - %res = OpVariable %_ptr_Function_v3int Function %84 - %79 = OpFunctionCall %v3int %tint_count_leading_zeros %81 - OpStore %res %79 +%countLeadingZeros_7c38a6 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v3int Function %19 + OpStore %res %16 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %85 - %87 = OpLabel - %88 = OpFunctionCall %void %countLeadingZeros_7c38a6 +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %countLeadingZeros_7c38a6 OpReturnValue %5 OpFunctionEnd -%vertex_main = OpFunction %void None %75 - %90 = OpLabel - %91 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %91 +%vertex_main = OpFunction %void None %9 + %25 = OpLabel + %26 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %26 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd -%fragment_main = OpFunction %void None %75 - %94 = OpLabel - %95 = OpFunctionCall %void %countLeadingZeros_7c38a6 +%fragment_main = OpFunction %void None %9 + %29 = OpLabel + %30 = OpFunctionCall %void %countLeadingZeros_7c38a6 OpReturn OpFunctionEnd -%compute_main = OpFunction %void None %75 - %97 = OpLabel - %98 = OpFunctionCall %void %countLeadingZeros_7c38a6 +%compute_main = OpFunction %void None %9 + %32 = OpLabel + %33 = OpFunctionCall %void %countLeadingZeros_7c38a6 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/countLeadingZeros/858d40.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/countLeadingZeros/858d40.wgsl.expected.dxc.hlsl index 0dbc22b034..25fe2827e4 100644 --- a/test/tint/builtins/gen/literal/countLeadingZeros/858d40.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/countLeadingZeros/858d40.wgsl.expected.dxc.hlsl @@ -1,20 +1,5 @@ -int2 tint_count_leading_zeros(int2 v) { - uint2 x = uint2(v); - const uint2 b16 = ((x <= (65535u).xx) ? (16u).xx : (0u).xx); - x = (x << b16); - const uint2 b8 = ((x <= (16777215u).xx) ? (8u).xx : (0u).xx); - x = (x << b8); - const uint2 b4 = ((x <= (268435455u).xx) ? (4u).xx : (0u).xx); - x = (x << b4); - const uint2 b2 = ((x <= (1073741823u).xx) ? (2u).xx : (0u).xx); - x = (x << b2); - const uint2 b1 = ((x <= (2147483647u).xx) ? (1u).xx : (0u).xx); - const uint2 is_zero = ((x == (0u).xx) ? (1u).xx : (0u).xx); - return int2((((((b16 | b8) | b4) | b2) | b1) + is_zero)); -} - void countLeadingZeros_858d40() { - int2 res = tint_count_leading_zeros((1).xx); + int2 res = (31).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countLeadingZeros/858d40.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/countLeadingZeros/858d40.wgsl.expected.fxc.hlsl index 0dbc22b034..25fe2827e4 100644 --- a/test/tint/builtins/gen/literal/countLeadingZeros/858d40.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/countLeadingZeros/858d40.wgsl.expected.fxc.hlsl @@ -1,20 +1,5 @@ -int2 tint_count_leading_zeros(int2 v) { - uint2 x = uint2(v); - const uint2 b16 = ((x <= (65535u).xx) ? (16u).xx : (0u).xx); - x = (x << b16); - const uint2 b8 = ((x <= (16777215u).xx) ? (8u).xx : (0u).xx); - x = (x << b8); - const uint2 b4 = ((x <= (268435455u).xx) ? (4u).xx : (0u).xx); - x = (x << b4); - const uint2 b2 = ((x <= (1073741823u).xx) ? (2u).xx : (0u).xx); - x = (x << b2); - const uint2 b1 = ((x <= (2147483647u).xx) ? (1u).xx : (0u).xx); - const uint2 is_zero = ((x == (0u).xx) ? (1u).xx : (0u).xx); - return int2((((((b16 | b8) | b4) | b2) | b1) + is_zero)); -} - void countLeadingZeros_858d40() { - int2 res = tint_count_leading_zeros((1).xx); + int2 res = (31).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countLeadingZeros/858d40.wgsl.expected.glsl b/test/tint/builtins/gen/literal/countLeadingZeros/858d40.wgsl.expected.glsl index 875e499f4f..edd459b2c3 100644 --- a/test/tint/builtins/gen/literal/countLeadingZeros/858d40.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/countLeadingZeros/858d40.wgsl.expected.glsl @@ -1,22 +1,7 @@ #version 310 es -ivec2 tint_count_leading_zeros(ivec2 v) { - uvec2 x = uvec2(v); - uvec2 b16 = mix(uvec2(0u), uvec2(16u), lessThanEqual(x, uvec2(65535u))); - x = (x << b16); - uvec2 b8 = mix(uvec2(0u), uvec2(8u), lessThanEqual(x, uvec2(16777215u))); - x = (x << b8); - uvec2 b4 = mix(uvec2(0u), uvec2(4u), lessThanEqual(x, uvec2(268435455u))); - x = (x << b4); - uvec2 b2 = mix(uvec2(0u), uvec2(2u), lessThanEqual(x, uvec2(1073741823u))); - x = (x << b2); - uvec2 b1 = mix(uvec2(0u), uvec2(1u), lessThanEqual(x, uvec2(2147483647u))); - uvec2 is_zero = mix(uvec2(0u), uvec2(1u), equal(x, uvec2(0u))); - return ivec2((((((b16 | b8) | b4) | b2) | b1) + is_zero)); -} - void countLeadingZeros_858d40() { - ivec2 res = tint_count_leading_zeros(ivec2(1)); + ivec2 res = ivec2(31); } vec4 vertex_main() { @@ -35,23 +20,8 @@ void main() { #version 310 es precision mediump float; -ivec2 tint_count_leading_zeros(ivec2 v) { - uvec2 x = uvec2(v); - uvec2 b16 = mix(uvec2(0u), uvec2(16u), lessThanEqual(x, uvec2(65535u))); - x = (x << b16); - uvec2 b8 = mix(uvec2(0u), uvec2(8u), lessThanEqual(x, uvec2(16777215u))); - x = (x << b8); - uvec2 b4 = mix(uvec2(0u), uvec2(4u), lessThanEqual(x, uvec2(268435455u))); - x = (x << b4); - uvec2 b2 = mix(uvec2(0u), uvec2(2u), lessThanEqual(x, uvec2(1073741823u))); - x = (x << b2); - uvec2 b1 = mix(uvec2(0u), uvec2(1u), lessThanEqual(x, uvec2(2147483647u))); - uvec2 is_zero = mix(uvec2(0u), uvec2(1u), equal(x, uvec2(0u))); - return ivec2((((((b16 | b8) | b4) | b2) | b1) + is_zero)); -} - void countLeadingZeros_858d40() { - ivec2 res = tint_count_leading_zeros(ivec2(1)); + ivec2 res = ivec2(31); } void fragment_main() { @@ -64,23 +34,8 @@ void main() { } #version 310 es -ivec2 tint_count_leading_zeros(ivec2 v) { - uvec2 x = uvec2(v); - uvec2 b16 = mix(uvec2(0u), uvec2(16u), lessThanEqual(x, uvec2(65535u))); - x = (x << b16); - uvec2 b8 = mix(uvec2(0u), uvec2(8u), lessThanEqual(x, uvec2(16777215u))); - x = (x << b8); - uvec2 b4 = mix(uvec2(0u), uvec2(4u), lessThanEqual(x, uvec2(268435455u))); - x = (x << b4); - uvec2 b2 = mix(uvec2(0u), uvec2(2u), lessThanEqual(x, uvec2(1073741823u))); - x = (x << b2); - uvec2 b1 = mix(uvec2(0u), uvec2(1u), lessThanEqual(x, uvec2(2147483647u))); - uvec2 is_zero = mix(uvec2(0u), uvec2(1u), equal(x, uvec2(0u))); - return ivec2((((((b16 | b8) | b4) | b2) | b1) + is_zero)); -} - void countLeadingZeros_858d40() { - ivec2 res = tint_count_leading_zeros(ivec2(1)); + ivec2 res = ivec2(31); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/countLeadingZeros/858d40.wgsl.expected.msl b/test/tint/builtins/gen/literal/countLeadingZeros/858d40.wgsl.expected.msl index aad89f72be..d0dd71f379 100644 --- a/test/tint/builtins/gen/literal/countLeadingZeros/858d40.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/countLeadingZeros/858d40.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void countLeadingZeros_858d40() { - int2 res = clz(int2(1)); + int2 res = int2(31); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countLeadingZeros/858d40.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/countLeadingZeros/858d40.wgsl.expected.spvasm index ab5c154fbb..be3c41db30 100644 --- a/test/tint/builtins/gen/literal/countLeadingZeros/858d40.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/countLeadingZeros/858d40.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 99 +; Bound: 34 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -12,9 +12,6 @@ OpExecutionMode %compute_main LocalSize 1 1 1 OpName %value "value" OpName %vertex_point_size "vertex_point_size" - OpName %tint_count_leading_zeros "tint_count_leading_zeros" - OpName %v "v" - OpName %x "x" OpName %countLeadingZeros_858d40 "countLeadingZeros_858d40" OpName %res "res" OpName %vertex_main_inner "vertex_main_inner" @@ -31,113 +28,41 @@ %_ptr_Output_float = OpTypePointer Output %float %8 = OpConstantNull %float %vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void %int = OpTypeInt 32 1 %v2int = OpTypeVector %int 2 - %9 = OpTypeFunction %v2int %v2int - %uint = OpTypeInt 32 0 - %v2uint = OpTypeVector %uint 2 -%_ptr_Function_v2uint = OpTypePointer Function %v2uint - %20 = OpConstantNull %v2uint - %uint_65535 = OpConstant %uint 65535 - %24 = OpConstantComposite %v2uint %uint_65535 %uint_65535 - %bool = OpTypeBool - %v2bool = OpTypeVector %bool 2 - %uint_16 = OpConstant %uint 16 - %29 = OpConstantComposite %v2uint %uint_16 %uint_16 -%uint_16777215 = OpConstant %uint 16777215 - %35 = OpConstantComposite %v2uint %uint_16777215 %uint_16777215 - %uint_8 = OpConstant %uint 8 - %38 = OpConstantComposite %v2uint %uint_8 %uint_8 -%uint_268435455 = OpConstant %uint 268435455 - %44 = OpConstantComposite %v2uint %uint_268435455 %uint_268435455 - %uint_4 = OpConstant %uint 4 - %47 = OpConstantComposite %v2uint %uint_4 %uint_4 -%uint_1073741823 = OpConstant %uint 1073741823 - %53 = OpConstantComposite %v2uint %uint_1073741823 %uint_1073741823 - %uint_2 = OpConstant %uint 2 - %56 = OpConstantComposite %v2uint %uint_2 %uint_2 -%uint_2147483647 = OpConstant %uint 2147483647 - %62 = OpConstantComposite %v2uint %uint_2147483647 %uint_2147483647 - %uint_1 = OpConstant %uint 1 - %65 = OpConstantComposite %v2uint %uint_1 %uint_1 - %void = OpTypeVoid - %75 = OpTypeFunction %void - %int_1 = OpConstant %int 1 - %81 = OpConstantComposite %v2int %int_1 %int_1 + %int_31 = OpConstant %int 31 + %16 = OpConstantComposite %v2int %int_31 %int_31 %_ptr_Function_v2int = OpTypePointer Function %v2int - %84 = OpConstantNull %v2int - %85 = OpTypeFunction %v4float + %19 = OpConstantNull %v2int + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 -%tint_count_leading_zeros = OpFunction %v2int None %9 - %v = OpFunctionParameter %v2int - %14 = OpLabel - %x = OpVariable %_ptr_Function_v2uint Function %20 - %15 = OpBitcast %v2uint %v - OpStore %x %15 - %22 = OpLoad %v2uint %x - %25 = OpULessThanEqual %v2bool %22 %24 - %21 = OpSelect %v2uint %25 %29 %20 - %30 = OpLoad %v2uint %x - %31 = OpShiftLeftLogical %v2uint %30 %21 - OpStore %x %31 - %33 = OpLoad %v2uint %x - %36 = OpULessThanEqual %v2bool %33 %35 - %32 = OpSelect %v2uint %36 %38 %20 - %39 = OpLoad %v2uint %x - %40 = OpShiftLeftLogical %v2uint %39 %32 - OpStore %x %40 - %42 = OpLoad %v2uint %x - %45 = OpULessThanEqual %v2bool %42 %44 - %41 = OpSelect %v2uint %45 %47 %20 - %48 = OpLoad %v2uint %x - %49 = OpShiftLeftLogical %v2uint %48 %41 - OpStore %x %49 - %51 = OpLoad %v2uint %x - %54 = OpULessThanEqual %v2bool %51 %53 - %50 = OpSelect %v2uint %54 %56 %20 - %57 = OpLoad %v2uint %x - %58 = OpShiftLeftLogical %v2uint %57 %50 - OpStore %x %58 - %60 = OpLoad %v2uint %x - %63 = OpULessThanEqual %v2bool %60 %62 - %59 = OpSelect %v2uint %63 %65 %20 - %67 = OpLoad %v2uint %x - %68 = OpIEqual %v2bool %67 %20 - %66 = OpSelect %v2uint %68 %65 %20 - %70 = OpBitwiseOr %v2uint %21 %32 - %71 = OpBitwiseOr %v2uint %70 %41 - %72 = OpBitwiseOr %v2uint %71 %50 - %73 = OpBitwiseOr %v2uint %72 %59 - %74 = OpIAdd %v2uint %73 %66 - %69 = OpBitcast %v2int %74 - OpReturnValue %69 - OpFunctionEnd -%countLeadingZeros_858d40 = OpFunction %void None %75 - %78 = OpLabel - %res = OpVariable %_ptr_Function_v2int Function %84 - %79 = OpFunctionCall %v2int %tint_count_leading_zeros %81 - OpStore %res %79 +%countLeadingZeros_858d40 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v2int Function %19 + OpStore %res %16 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %85 - %87 = OpLabel - %88 = OpFunctionCall %void %countLeadingZeros_858d40 +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %countLeadingZeros_858d40 OpReturnValue %5 OpFunctionEnd -%vertex_main = OpFunction %void None %75 - %90 = OpLabel - %91 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %91 +%vertex_main = OpFunction %void None %9 + %25 = OpLabel + %26 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %26 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd -%fragment_main = OpFunction %void None %75 - %94 = OpLabel - %95 = OpFunctionCall %void %countLeadingZeros_858d40 +%fragment_main = OpFunction %void None %9 + %29 = OpLabel + %30 = OpFunctionCall %void %countLeadingZeros_858d40 OpReturn OpFunctionEnd -%compute_main = OpFunction %void None %75 - %97 = OpLabel - %98 = OpFunctionCall %void %countLeadingZeros_858d40 +%compute_main = OpFunction %void None %9 + %32 = OpLabel + %33 = OpFunctionCall %void %countLeadingZeros_858d40 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/countLeadingZeros/ab6345.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/countLeadingZeros/ab6345.wgsl.expected.dxc.hlsl index 56e471a049..aca87cf6e9 100644 --- a/test/tint/builtins/gen/literal/countLeadingZeros/ab6345.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/countLeadingZeros/ab6345.wgsl.expected.dxc.hlsl @@ -1,20 +1,5 @@ -uint3 tint_count_leading_zeros(uint3 v) { - uint3 x = uint3(v); - const uint3 b16 = ((x <= (65535u).xxx) ? (16u).xxx : (0u).xxx); - x = (x << b16); - const uint3 b8 = ((x <= (16777215u).xxx) ? (8u).xxx : (0u).xxx); - x = (x << b8); - const uint3 b4 = ((x <= (268435455u).xxx) ? (4u).xxx : (0u).xxx); - x = (x << b4); - const uint3 b2 = ((x <= (1073741823u).xxx) ? (2u).xxx : (0u).xxx); - x = (x << b2); - const uint3 b1 = ((x <= (2147483647u).xxx) ? (1u).xxx : (0u).xxx); - const uint3 is_zero = ((x == (0u).xxx) ? (1u).xxx : (0u).xxx); - return uint3((((((b16 | b8) | b4) | b2) | b1) + is_zero)); -} - void countLeadingZeros_ab6345() { - uint3 res = tint_count_leading_zeros((1u).xxx); + uint3 res = (31u).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countLeadingZeros/ab6345.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/countLeadingZeros/ab6345.wgsl.expected.fxc.hlsl index 56e471a049..aca87cf6e9 100644 --- a/test/tint/builtins/gen/literal/countLeadingZeros/ab6345.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/countLeadingZeros/ab6345.wgsl.expected.fxc.hlsl @@ -1,20 +1,5 @@ -uint3 tint_count_leading_zeros(uint3 v) { - uint3 x = uint3(v); - const uint3 b16 = ((x <= (65535u).xxx) ? (16u).xxx : (0u).xxx); - x = (x << b16); - const uint3 b8 = ((x <= (16777215u).xxx) ? (8u).xxx : (0u).xxx); - x = (x << b8); - const uint3 b4 = ((x <= (268435455u).xxx) ? (4u).xxx : (0u).xxx); - x = (x << b4); - const uint3 b2 = ((x <= (1073741823u).xxx) ? (2u).xxx : (0u).xxx); - x = (x << b2); - const uint3 b1 = ((x <= (2147483647u).xxx) ? (1u).xxx : (0u).xxx); - const uint3 is_zero = ((x == (0u).xxx) ? (1u).xxx : (0u).xxx); - return uint3((((((b16 | b8) | b4) | b2) | b1) + is_zero)); -} - void countLeadingZeros_ab6345() { - uint3 res = tint_count_leading_zeros((1u).xxx); + uint3 res = (31u).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countLeadingZeros/ab6345.wgsl.expected.glsl b/test/tint/builtins/gen/literal/countLeadingZeros/ab6345.wgsl.expected.glsl index bc8be9cdb9..cbf475f342 100644 --- a/test/tint/builtins/gen/literal/countLeadingZeros/ab6345.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/countLeadingZeros/ab6345.wgsl.expected.glsl @@ -1,22 +1,7 @@ #version 310 es -uvec3 tint_count_leading_zeros(uvec3 v) { - uvec3 x = uvec3(v); - uvec3 b16 = mix(uvec3(0u), uvec3(16u), lessThanEqual(x, uvec3(65535u))); - x = (x << b16); - uvec3 b8 = mix(uvec3(0u), uvec3(8u), lessThanEqual(x, uvec3(16777215u))); - x = (x << b8); - uvec3 b4 = mix(uvec3(0u), uvec3(4u), lessThanEqual(x, uvec3(268435455u))); - x = (x << b4); - uvec3 b2 = mix(uvec3(0u), uvec3(2u), lessThanEqual(x, uvec3(1073741823u))); - x = (x << b2); - uvec3 b1 = mix(uvec3(0u), uvec3(1u), lessThanEqual(x, uvec3(2147483647u))); - uvec3 is_zero = mix(uvec3(0u), uvec3(1u), equal(x, uvec3(0u))); - return uvec3((((((b16 | b8) | b4) | b2) | b1) + is_zero)); -} - void countLeadingZeros_ab6345() { - uvec3 res = tint_count_leading_zeros(uvec3(1u)); + uvec3 res = uvec3(31u); } vec4 vertex_main() { @@ -35,23 +20,8 @@ void main() { #version 310 es precision mediump float; -uvec3 tint_count_leading_zeros(uvec3 v) { - uvec3 x = uvec3(v); - uvec3 b16 = mix(uvec3(0u), uvec3(16u), lessThanEqual(x, uvec3(65535u))); - x = (x << b16); - uvec3 b8 = mix(uvec3(0u), uvec3(8u), lessThanEqual(x, uvec3(16777215u))); - x = (x << b8); - uvec3 b4 = mix(uvec3(0u), uvec3(4u), lessThanEqual(x, uvec3(268435455u))); - x = (x << b4); - uvec3 b2 = mix(uvec3(0u), uvec3(2u), lessThanEqual(x, uvec3(1073741823u))); - x = (x << b2); - uvec3 b1 = mix(uvec3(0u), uvec3(1u), lessThanEqual(x, uvec3(2147483647u))); - uvec3 is_zero = mix(uvec3(0u), uvec3(1u), equal(x, uvec3(0u))); - return uvec3((((((b16 | b8) | b4) | b2) | b1) + is_zero)); -} - void countLeadingZeros_ab6345() { - uvec3 res = tint_count_leading_zeros(uvec3(1u)); + uvec3 res = uvec3(31u); } void fragment_main() { @@ -64,23 +34,8 @@ void main() { } #version 310 es -uvec3 tint_count_leading_zeros(uvec3 v) { - uvec3 x = uvec3(v); - uvec3 b16 = mix(uvec3(0u), uvec3(16u), lessThanEqual(x, uvec3(65535u))); - x = (x << b16); - uvec3 b8 = mix(uvec3(0u), uvec3(8u), lessThanEqual(x, uvec3(16777215u))); - x = (x << b8); - uvec3 b4 = mix(uvec3(0u), uvec3(4u), lessThanEqual(x, uvec3(268435455u))); - x = (x << b4); - uvec3 b2 = mix(uvec3(0u), uvec3(2u), lessThanEqual(x, uvec3(1073741823u))); - x = (x << b2); - uvec3 b1 = mix(uvec3(0u), uvec3(1u), lessThanEqual(x, uvec3(2147483647u))); - uvec3 is_zero = mix(uvec3(0u), uvec3(1u), equal(x, uvec3(0u))); - return uvec3((((((b16 | b8) | b4) | b2) | b1) + is_zero)); -} - void countLeadingZeros_ab6345() { - uvec3 res = tint_count_leading_zeros(uvec3(1u)); + uvec3 res = uvec3(31u); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/countLeadingZeros/ab6345.wgsl.expected.msl b/test/tint/builtins/gen/literal/countLeadingZeros/ab6345.wgsl.expected.msl index 85d4ca8c52..c7cbaab0f9 100644 --- a/test/tint/builtins/gen/literal/countLeadingZeros/ab6345.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/countLeadingZeros/ab6345.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void countLeadingZeros_ab6345() { - uint3 res = clz(uint3(1u)); + uint3 res = uint3(31u); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countLeadingZeros/ab6345.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/countLeadingZeros/ab6345.wgsl.expected.spvasm index 94f2f81e93..b648a7a6fa 100644 --- a/test/tint/builtins/gen/literal/countLeadingZeros/ab6345.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/countLeadingZeros/ab6345.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 93 +; Bound: 34 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -12,9 +12,6 @@ OpExecutionMode %compute_main LocalSize 1 1 1 OpName %value "value" OpName %vertex_point_size "vertex_point_size" - OpName %tint_count_leading_zeros "tint_count_leading_zeros" - OpName %v "v" - OpName %x "x" OpName %countLeadingZeros_ab6345 "countLeadingZeros_ab6345" OpName %res "res" OpName %vertex_main_inner "vertex_main_inner" @@ -31,105 +28,41 @@ %_ptr_Output_float = OpTypePointer Output %float %8 = OpConstantNull %float %vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void %uint = OpTypeInt 32 0 %v3uint = OpTypeVector %uint 3 - %9 = OpTypeFunction %v3uint %v3uint + %uint_31 = OpConstant %uint 31 + %16 = OpConstantComposite %v3uint %uint_31 %uint_31 %uint_31 %_ptr_Function_v3uint = OpTypePointer Function %v3uint - %18 = OpConstantNull %v3uint - %uint_65535 = OpConstant %uint 65535 - %22 = OpConstantComposite %v3uint %uint_65535 %uint_65535 %uint_65535 - %bool = OpTypeBool - %v3bool = OpTypeVector %bool 3 - %uint_16 = OpConstant %uint 16 - %27 = OpConstantComposite %v3uint %uint_16 %uint_16 %uint_16 -%uint_16777215 = OpConstant %uint 16777215 - %33 = OpConstantComposite %v3uint %uint_16777215 %uint_16777215 %uint_16777215 - %uint_8 = OpConstant %uint 8 - %36 = OpConstantComposite %v3uint %uint_8 %uint_8 %uint_8 -%uint_268435455 = OpConstant %uint 268435455 - %42 = OpConstantComposite %v3uint %uint_268435455 %uint_268435455 %uint_268435455 - %uint_4 = OpConstant %uint 4 - %45 = OpConstantComposite %v3uint %uint_4 %uint_4 %uint_4 -%uint_1073741823 = OpConstant %uint 1073741823 - %51 = OpConstantComposite %v3uint %uint_1073741823 %uint_1073741823 %uint_1073741823 - %uint_2 = OpConstant %uint 2 - %54 = OpConstantComposite %v3uint %uint_2 %uint_2 %uint_2 -%uint_2147483647 = OpConstant %uint 2147483647 - %60 = OpConstantComposite %v3uint %uint_2147483647 %uint_2147483647 %uint_2147483647 - %uint_1 = OpConstant %uint 1 - %63 = OpConstantComposite %v3uint %uint_1 %uint_1 %uint_1 - %void = OpTypeVoid - %73 = OpTypeFunction %void - %79 = OpTypeFunction %v4float + %19 = OpConstantNull %v3uint + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 -%tint_count_leading_zeros = OpFunction %v3uint None %9 - %v = OpFunctionParameter %v3uint - %14 = OpLabel - %x = OpVariable %_ptr_Function_v3uint Function %18 - OpStore %x %v - %20 = OpLoad %v3uint %x - %23 = OpULessThanEqual %v3bool %20 %22 - %19 = OpSelect %v3uint %23 %27 %18 - %28 = OpLoad %v3uint %x - %29 = OpShiftLeftLogical %v3uint %28 %19 - OpStore %x %29 - %31 = OpLoad %v3uint %x - %34 = OpULessThanEqual %v3bool %31 %33 - %30 = OpSelect %v3uint %34 %36 %18 - %37 = OpLoad %v3uint %x - %38 = OpShiftLeftLogical %v3uint %37 %30 - OpStore %x %38 - %40 = OpLoad %v3uint %x - %43 = OpULessThanEqual %v3bool %40 %42 - %39 = OpSelect %v3uint %43 %45 %18 - %46 = OpLoad %v3uint %x - %47 = OpShiftLeftLogical %v3uint %46 %39 - OpStore %x %47 - %49 = OpLoad %v3uint %x - %52 = OpULessThanEqual %v3bool %49 %51 - %48 = OpSelect %v3uint %52 %54 %18 - %55 = OpLoad %v3uint %x - %56 = OpShiftLeftLogical %v3uint %55 %48 - OpStore %x %56 - %58 = OpLoad %v3uint %x - %61 = OpULessThanEqual %v3bool %58 %60 - %57 = OpSelect %v3uint %61 %63 %18 - %65 = OpLoad %v3uint %x - %66 = OpIEqual %v3bool %65 %18 - %64 = OpSelect %v3uint %66 %63 %18 - %68 = OpBitwiseOr %v3uint %19 %30 - %69 = OpBitwiseOr %v3uint %68 %39 - %70 = OpBitwiseOr %v3uint %69 %48 - %71 = OpBitwiseOr %v3uint %70 %57 - %72 = OpIAdd %v3uint %71 %64 - OpReturnValue %72 - OpFunctionEnd -%countLeadingZeros_ab6345 = OpFunction %void None %73 - %76 = OpLabel - %res = OpVariable %_ptr_Function_v3uint Function %18 - %77 = OpFunctionCall %v3uint %tint_count_leading_zeros %63 - OpStore %res %77 +%countLeadingZeros_ab6345 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v3uint Function %19 + OpStore %res %16 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %79 - %81 = OpLabel - %82 = OpFunctionCall %void %countLeadingZeros_ab6345 +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %countLeadingZeros_ab6345 OpReturnValue %5 OpFunctionEnd -%vertex_main = OpFunction %void None %73 - %84 = OpLabel - %85 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %85 +%vertex_main = OpFunction %void None %9 + %25 = OpLabel + %26 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %26 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd -%fragment_main = OpFunction %void None %73 - %88 = OpLabel - %89 = OpFunctionCall %void %countLeadingZeros_ab6345 +%fragment_main = OpFunction %void None %9 + %29 = OpLabel + %30 = OpFunctionCall %void %countLeadingZeros_ab6345 OpReturn OpFunctionEnd -%compute_main = OpFunction %void None %73 - %91 = OpLabel - %92 = OpFunctionCall %void %countLeadingZeros_ab6345 +%compute_main = OpFunction %void None %9 + %32 = OpLabel + %33 = OpFunctionCall %void %countLeadingZeros_ab6345 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/countLeadingZeros/eab32b.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/countLeadingZeros/eab32b.wgsl.expected.dxc.hlsl index fdbeffdd05..20d59f5211 100644 --- a/test/tint/builtins/gen/literal/countLeadingZeros/eab32b.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/countLeadingZeros/eab32b.wgsl.expected.dxc.hlsl @@ -1,20 +1,5 @@ -int4 tint_count_leading_zeros(int4 v) { - uint4 x = uint4(v); - const uint4 b16 = ((x <= (65535u).xxxx) ? (16u).xxxx : (0u).xxxx); - x = (x << b16); - const uint4 b8 = ((x <= (16777215u).xxxx) ? (8u).xxxx : (0u).xxxx); - x = (x << b8); - const uint4 b4 = ((x <= (268435455u).xxxx) ? (4u).xxxx : (0u).xxxx); - x = (x << b4); - const uint4 b2 = ((x <= (1073741823u).xxxx) ? (2u).xxxx : (0u).xxxx); - x = (x << b2); - const uint4 b1 = ((x <= (2147483647u).xxxx) ? (1u).xxxx : (0u).xxxx); - const uint4 is_zero = ((x == (0u).xxxx) ? (1u).xxxx : (0u).xxxx); - return int4((((((b16 | b8) | b4) | b2) | b1) + is_zero)); -} - void countLeadingZeros_eab32b() { - int4 res = tint_count_leading_zeros((1).xxxx); + int4 res = (31).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countLeadingZeros/eab32b.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/countLeadingZeros/eab32b.wgsl.expected.fxc.hlsl index fdbeffdd05..20d59f5211 100644 --- a/test/tint/builtins/gen/literal/countLeadingZeros/eab32b.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/countLeadingZeros/eab32b.wgsl.expected.fxc.hlsl @@ -1,20 +1,5 @@ -int4 tint_count_leading_zeros(int4 v) { - uint4 x = uint4(v); - const uint4 b16 = ((x <= (65535u).xxxx) ? (16u).xxxx : (0u).xxxx); - x = (x << b16); - const uint4 b8 = ((x <= (16777215u).xxxx) ? (8u).xxxx : (0u).xxxx); - x = (x << b8); - const uint4 b4 = ((x <= (268435455u).xxxx) ? (4u).xxxx : (0u).xxxx); - x = (x << b4); - const uint4 b2 = ((x <= (1073741823u).xxxx) ? (2u).xxxx : (0u).xxxx); - x = (x << b2); - const uint4 b1 = ((x <= (2147483647u).xxxx) ? (1u).xxxx : (0u).xxxx); - const uint4 is_zero = ((x == (0u).xxxx) ? (1u).xxxx : (0u).xxxx); - return int4((((((b16 | b8) | b4) | b2) | b1) + is_zero)); -} - void countLeadingZeros_eab32b() { - int4 res = tint_count_leading_zeros((1).xxxx); + int4 res = (31).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countLeadingZeros/eab32b.wgsl.expected.glsl b/test/tint/builtins/gen/literal/countLeadingZeros/eab32b.wgsl.expected.glsl index ce67a9ecf7..d9cee38b41 100644 --- a/test/tint/builtins/gen/literal/countLeadingZeros/eab32b.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/countLeadingZeros/eab32b.wgsl.expected.glsl @@ -1,22 +1,7 @@ #version 310 es -ivec4 tint_count_leading_zeros(ivec4 v) { - uvec4 x = uvec4(v); - uvec4 b16 = mix(uvec4(0u), uvec4(16u), lessThanEqual(x, uvec4(65535u))); - x = (x << b16); - uvec4 b8 = mix(uvec4(0u), uvec4(8u), lessThanEqual(x, uvec4(16777215u))); - x = (x << b8); - uvec4 b4 = mix(uvec4(0u), uvec4(4u), lessThanEqual(x, uvec4(268435455u))); - x = (x << b4); - uvec4 b2 = mix(uvec4(0u), uvec4(2u), lessThanEqual(x, uvec4(1073741823u))); - x = (x << b2); - uvec4 b1 = mix(uvec4(0u), uvec4(1u), lessThanEqual(x, uvec4(2147483647u))); - uvec4 is_zero = mix(uvec4(0u), uvec4(1u), equal(x, uvec4(0u))); - return ivec4((((((b16 | b8) | b4) | b2) | b1) + is_zero)); -} - void countLeadingZeros_eab32b() { - ivec4 res = tint_count_leading_zeros(ivec4(1)); + ivec4 res = ivec4(31); } vec4 vertex_main() { @@ -35,23 +20,8 @@ void main() { #version 310 es precision mediump float; -ivec4 tint_count_leading_zeros(ivec4 v) { - uvec4 x = uvec4(v); - uvec4 b16 = mix(uvec4(0u), uvec4(16u), lessThanEqual(x, uvec4(65535u))); - x = (x << b16); - uvec4 b8 = mix(uvec4(0u), uvec4(8u), lessThanEqual(x, uvec4(16777215u))); - x = (x << b8); - uvec4 b4 = mix(uvec4(0u), uvec4(4u), lessThanEqual(x, uvec4(268435455u))); - x = (x << b4); - uvec4 b2 = mix(uvec4(0u), uvec4(2u), lessThanEqual(x, uvec4(1073741823u))); - x = (x << b2); - uvec4 b1 = mix(uvec4(0u), uvec4(1u), lessThanEqual(x, uvec4(2147483647u))); - uvec4 is_zero = mix(uvec4(0u), uvec4(1u), equal(x, uvec4(0u))); - return ivec4((((((b16 | b8) | b4) | b2) | b1) + is_zero)); -} - void countLeadingZeros_eab32b() { - ivec4 res = tint_count_leading_zeros(ivec4(1)); + ivec4 res = ivec4(31); } void fragment_main() { @@ -64,23 +34,8 @@ void main() { } #version 310 es -ivec4 tint_count_leading_zeros(ivec4 v) { - uvec4 x = uvec4(v); - uvec4 b16 = mix(uvec4(0u), uvec4(16u), lessThanEqual(x, uvec4(65535u))); - x = (x << b16); - uvec4 b8 = mix(uvec4(0u), uvec4(8u), lessThanEqual(x, uvec4(16777215u))); - x = (x << b8); - uvec4 b4 = mix(uvec4(0u), uvec4(4u), lessThanEqual(x, uvec4(268435455u))); - x = (x << b4); - uvec4 b2 = mix(uvec4(0u), uvec4(2u), lessThanEqual(x, uvec4(1073741823u))); - x = (x << b2); - uvec4 b1 = mix(uvec4(0u), uvec4(1u), lessThanEqual(x, uvec4(2147483647u))); - uvec4 is_zero = mix(uvec4(0u), uvec4(1u), equal(x, uvec4(0u))); - return ivec4((((((b16 | b8) | b4) | b2) | b1) + is_zero)); -} - void countLeadingZeros_eab32b() { - ivec4 res = tint_count_leading_zeros(ivec4(1)); + ivec4 res = ivec4(31); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/countLeadingZeros/eab32b.wgsl.expected.msl b/test/tint/builtins/gen/literal/countLeadingZeros/eab32b.wgsl.expected.msl index 2e2f4b629e..4544e07410 100644 --- a/test/tint/builtins/gen/literal/countLeadingZeros/eab32b.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/countLeadingZeros/eab32b.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void countLeadingZeros_eab32b() { - int4 res = clz(int4(1)); + int4 res = int4(31); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countLeadingZeros/eab32b.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/countLeadingZeros/eab32b.wgsl.expected.spvasm index c7f146d529..0bae17dedf 100644 --- a/test/tint/builtins/gen/literal/countLeadingZeros/eab32b.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/countLeadingZeros/eab32b.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 99 +; Bound: 34 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -12,9 +12,6 @@ OpExecutionMode %compute_main LocalSize 1 1 1 OpName %value "value" OpName %vertex_point_size "vertex_point_size" - OpName %tint_count_leading_zeros "tint_count_leading_zeros" - OpName %v "v" - OpName %x "x" OpName %countLeadingZeros_eab32b "countLeadingZeros_eab32b" OpName %res "res" OpName %vertex_main_inner "vertex_main_inner" @@ -31,113 +28,41 @@ %_ptr_Output_float = OpTypePointer Output %float %8 = OpConstantNull %float %vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void %int = OpTypeInt 32 1 %v4int = OpTypeVector %int 4 - %9 = OpTypeFunction %v4int %v4int - %uint = OpTypeInt 32 0 - %v4uint = OpTypeVector %uint 4 -%_ptr_Function_v4uint = OpTypePointer Function %v4uint - %20 = OpConstantNull %v4uint - %uint_65535 = OpConstant %uint 65535 - %24 = OpConstantComposite %v4uint %uint_65535 %uint_65535 %uint_65535 %uint_65535 - %bool = OpTypeBool - %v4bool = OpTypeVector %bool 4 - %uint_16 = OpConstant %uint 16 - %29 = OpConstantComposite %v4uint %uint_16 %uint_16 %uint_16 %uint_16 -%uint_16777215 = OpConstant %uint 16777215 - %35 = OpConstantComposite %v4uint %uint_16777215 %uint_16777215 %uint_16777215 %uint_16777215 - %uint_8 = OpConstant %uint 8 - %38 = OpConstantComposite %v4uint %uint_8 %uint_8 %uint_8 %uint_8 -%uint_268435455 = OpConstant %uint 268435455 - %44 = OpConstantComposite %v4uint %uint_268435455 %uint_268435455 %uint_268435455 %uint_268435455 - %uint_4 = OpConstant %uint 4 - %47 = OpConstantComposite %v4uint %uint_4 %uint_4 %uint_4 %uint_4 -%uint_1073741823 = OpConstant %uint 1073741823 - %53 = OpConstantComposite %v4uint %uint_1073741823 %uint_1073741823 %uint_1073741823 %uint_1073741823 - %uint_2 = OpConstant %uint 2 - %56 = OpConstantComposite %v4uint %uint_2 %uint_2 %uint_2 %uint_2 -%uint_2147483647 = OpConstant %uint 2147483647 - %62 = OpConstantComposite %v4uint %uint_2147483647 %uint_2147483647 %uint_2147483647 %uint_2147483647 - %uint_1 = OpConstant %uint 1 - %65 = OpConstantComposite %v4uint %uint_1 %uint_1 %uint_1 %uint_1 - %void = OpTypeVoid - %75 = OpTypeFunction %void - %int_1 = OpConstant %int 1 - %81 = OpConstantComposite %v4int %int_1 %int_1 %int_1 %int_1 + %int_31 = OpConstant %int 31 + %16 = OpConstantComposite %v4int %int_31 %int_31 %int_31 %int_31 %_ptr_Function_v4int = OpTypePointer Function %v4int - %84 = OpConstantNull %v4int - %85 = OpTypeFunction %v4float + %19 = OpConstantNull %v4int + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 -%tint_count_leading_zeros = OpFunction %v4int None %9 - %v = OpFunctionParameter %v4int - %14 = OpLabel - %x = OpVariable %_ptr_Function_v4uint Function %20 - %15 = OpBitcast %v4uint %v - OpStore %x %15 - %22 = OpLoad %v4uint %x - %25 = OpULessThanEqual %v4bool %22 %24 - %21 = OpSelect %v4uint %25 %29 %20 - %30 = OpLoad %v4uint %x - %31 = OpShiftLeftLogical %v4uint %30 %21 - OpStore %x %31 - %33 = OpLoad %v4uint %x - %36 = OpULessThanEqual %v4bool %33 %35 - %32 = OpSelect %v4uint %36 %38 %20 - %39 = OpLoad %v4uint %x - %40 = OpShiftLeftLogical %v4uint %39 %32 - OpStore %x %40 - %42 = OpLoad %v4uint %x - %45 = OpULessThanEqual %v4bool %42 %44 - %41 = OpSelect %v4uint %45 %47 %20 - %48 = OpLoad %v4uint %x - %49 = OpShiftLeftLogical %v4uint %48 %41 - OpStore %x %49 - %51 = OpLoad %v4uint %x - %54 = OpULessThanEqual %v4bool %51 %53 - %50 = OpSelect %v4uint %54 %56 %20 - %57 = OpLoad %v4uint %x - %58 = OpShiftLeftLogical %v4uint %57 %50 - OpStore %x %58 - %60 = OpLoad %v4uint %x - %63 = OpULessThanEqual %v4bool %60 %62 - %59 = OpSelect %v4uint %63 %65 %20 - %67 = OpLoad %v4uint %x - %68 = OpIEqual %v4bool %67 %20 - %66 = OpSelect %v4uint %68 %65 %20 - %70 = OpBitwiseOr %v4uint %21 %32 - %71 = OpBitwiseOr %v4uint %70 %41 - %72 = OpBitwiseOr %v4uint %71 %50 - %73 = OpBitwiseOr %v4uint %72 %59 - %74 = OpIAdd %v4uint %73 %66 - %69 = OpBitcast %v4int %74 - OpReturnValue %69 - OpFunctionEnd -%countLeadingZeros_eab32b = OpFunction %void None %75 - %78 = OpLabel - %res = OpVariable %_ptr_Function_v4int Function %84 - %79 = OpFunctionCall %v4int %tint_count_leading_zeros %81 - OpStore %res %79 +%countLeadingZeros_eab32b = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v4int Function %19 + OpStore %res %16 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %85 - %87 = OpLabel - %88 = OpFunctionCall %void %countLeadingZeros_eab32b +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %countLeadingZeros_eab32b OpReturnValue %5 OpFunctionEnd -%vertex_main = OpFunction %void None %75 - %90 = OpLabel - %91 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %91 +%vertex_main = OpFunction %void None %9 + %25 = OpLabel + %26 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %26 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd -%fragment_main = OpFunction %void None %75 - %94 = OpLabel - %95 = OpFunctionCall %void %countLeadingZeros_eab32b +%fragment_main = OpFunction %void None %9 + %29 = OpLabel + %30 = OpFunctionCall %void %countLeadingZeros_eab32b OpReturn OpFunctionEnd -%compute_main = OpFunction %void None %75 - %97 = OpLabel - %98 = OpFunctionCall %void %countLeadingZeros_eab32b +%compute_main = OpFunction %void None %9 + %32 = OpLabel + %33 = OpFunctionCall %void %countLeadingZeros_eab32b OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/countLeadingZeros/f70103.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/countLeadingZeros/f70103.wgsl.expected.dxc.hlsl index 8c9cbad028..e8fe65044b 100644 --- a/test/tint/builtins/gen/literal/countLeadingZeros/f70103.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/countLeadingZeros/f70103.wgsl.expected.dxc.hlsl @@ -1,20 +1,5 @@ -uint4 tint_count_leading_zeros(uint4 v) { - uint4 x = uint4(v); - const uint4 b16 = ((x <= (65535u).xxxx) ? (16u).xxxx : (0u).xxxx); - x = (x << b16); - const uint4 b8 = ((x <= (16777215u).xxxx) ? (8u).xxxx : (0u).xxxx); - x = (x << b8); - const uint4 b4 = ((x <= (268435455u).xxxx) ? (4u).xxxx : (0u).xxxx); - x = (x << b4); - const uint4 b2 = ((x <= (1073741823u).xxxx) ? (2u).xxxx : (0u).xxxx); - x = (x << b2); - const uint4 b1 = ((x <= (2147483647u).xxxx) ? (1u).xxxx : (0u).xxxx); - const uint4 is_zero = ((x == (0u).xxxx) ? (1u).xxxx : (0u).xxxx); - return uint4((((((b16 | b8) | b4) | b2) | b1) + is_zero)); -} - void countLeadingZeros_f70103() { - uint4 res = tint_count_leading_zeros((1u).xxxx); + uint4 res = (31u).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countLeadingZeros/f70103.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/countLeadingZeros/f70103.wgsl.expected.fxc.hlsl index 8c9cbad028..e8fe65044b 100644 --- a/test/tint/builtins/gen/literal/countLeadingZeros/f70103.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/countLeadingZeros/f70103.wgsl.expected.fxc.hlsl @@ -1,20 +1,5 @@ -uint4 tint_count_leading_zeros(uint4 v) { - uint4 x = uint4(v); - const uint4 b16 = ((x <= (65535u).xxxx) ? (16u).xxxx : (0u).xxxx); - x = (x << b16); - const uint4 b8 = ((x <= (16777215u).xxxx) ? (8u).xxxx : (0u).xxxx); - x = (x << b8); - const uint4 b4 = ((x <= (268435455u).xxxx) ? (4u).xxxx : (0u).xxxx); - x = (x << b4); - const uint4 b2 = ((x <= (1073741823u).xxxx) ? (2u).xxxx : (0u).xxxx); - x = (x << b2); - const uint4 b1 = ((x <= (2147483647u).xxxx) ? (1u).xxxx : (0u).xxxx); - const uint4 is_zero = ((x == (0u).xxxx) ? (1u).xxxx : (0u).xxxx); - return uint4((((((b16 | b8) | b4) | b2) | b1) + is_zero)); -} - void countLeadingZeros_f70103() { - uint4 res = tint_count_leading_zeros((1u).xxxx); + uint4 res = (31u).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countLeadingZeros/f70103.wgsl.expected.glsl b/test/tint/builtins/gen/literal/countLeadingZeros/f70103.wgsl.expected.glsl index b7e35486dc..4b663e735f 100644 --- a/test/tint/builtins/gen/literal/countLeadingZeros/f70103.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/countLeadingZeros/f70103.wgsl.expected.glsl @@ -1,22 +1,7 @@ #version 310 es -uvec4 tint_count_leading_zeros(uvec4 v) { - uvec4 x = uvec4(v); - uvec4 b16 = mix(uvec4(0u), uvec4(16u), lessThanEqual(x, uvec4(65535u))); - x = (x << b16); - uvec4 b8 = mix(uvec4(0u), uvec4(8u), lessThanEqual(x, uvec4(16777215u))); - x = (x << b8); - uvec4 b4 = mix(uvec4(0u), uvec4(4u), lessThanEqual(x, uvec4(268435455u))); - x = (x << b4); - uvec4 b2 = mix(uvec4(0u), uvec4(2u), lessThanEqual(x, uvec4(1073741823u))); - x = (x << b2); - uvec4 b1 = mix(uvec4(0u), uvec4(1u), lessThanEqual(x, uvec4(2147483647u))); - uvec4 is_zero = mix(uvec4(0u), uvec4(1u), equal(x, uvec4(0u))); - return uvec4((((((b16 | b8) | b4) | b2) | b1) + is_zero)); -} - void countLeadingZeros_f70103() { - uvec4 res = tint_count_leading_zeros(uvec4(1u)); + uvec4 res = uvec4(31u); } vec4 vertex_main() { @@ -35,23 +20,8 @@ void main() { #version 310 es precision mediump float; -uvec4 tint_count_leading_zeros(uvec4 v) { - uvec4 x = uvec4(v); - uvec4 b16 = mix(uvec4(0u), uvec4(16u), lessThanEqual(x, uvec4(65535u))); - x = (x << b16); - uvec4 b8 = mix(uvec4(0u), uvec4(8u), lessThanEqual(x, uvec4(16777215u))); - x = (x << b8); - uvec4 b4 = mix(uvec4(0u), uvec4(4u), lessThanEqual(x, uvec4(268435455u))); - x = (x << b4); - uvec4 b2 = mix(uvec4(0u), uvec4(2u), lessThanEqual(x, uvec4(1073741823u))); - x = (x << b2); - uvec4 b1 = mix(uvec4(0u), uvec4(1u), lessThanEqual(x, uvec4(2147483647u))); - uvec4 is_zero = mix(uvec4(0u), uvec4(1u), equal(x, uvec4(0u))); - return uvec4((((((b16 | b8) | b4) | b2) | b1) + is_zero)); -} - void countLeadingZeros_f70103() { - uvec4 res = tint_count_leading_zeros(uvec4(1u)); + uvec4 res = uvec4(31u); } void fragment_main() { @@ -64,23 +34,8 @@ void main() { } #version 310 es -uvec4 tint_count_leading_zeros(uvec4 v) { - uvec4 x = uvec4(v); - uvec4 b16 = mix(uvec4(0u), uvec4(16u), lessThanEqual(x, uvec4(65535u))); - x = (x << b16); - uvec4 b8 = mix(uvec4(0u), uvec4(8u), lessThanEqual(x, uvec4(16777215u))); - x = (x << b8); - uvec4 b4 = mix(uvec4(0u), uvec4(4u), lessThanEqual(x, uvec4(268435455u))); - x = (x << b4); - uvec4 b2 = mix(uvec4(0u), uvec4(2u), lessThanEqual(x, uvec4(1073741823u))); - x = (x << b2); - uvec4 b1 = mix(uvec4(0u), uvec4(1u), lessThanEqual(x, uvec4(2147483647u))); - uvec4 is_zero = mix(uvec4(0u), uvec4(1u), equal(x, uvec4(0u))); - return uvec4((((((b16 | b8) | b4) | b2) | b1) + is_zero)); -} - void countLeadingZeros_f70103() { - uvec4 res = tint_count_leading_zeros(uvec4(1u)); + uvec4 res = uvec4(31u); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/countLeadingZeros/f70103.wgsl.expected.msl b/test/tint/builtins/gen/literal/countLeadingZeros/f70103.wgsl.expected.msl index 04f050440b..1bd357f2ec 100644 --- a/test/tint/builtins/gen/literal/countLeadingZeros/f70103.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/countLeadingZeros/f70103.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void countLeadingZeros_f70103() { - uint4 res = clz(uint4(1u)); + uint4 res = uint4(31u); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countLeadingZeros/f70103.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/countLeadingZeros/f70103.wgsl.expected.spvasm index 86d8a21f96..477f6a736d 100644 --- a/test/tint/builtins/gen/literal/countLeadingZeros/f70103.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/countLeadingZeros/f70103.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 93 +; Bound: 34 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -12,9 +12,6 @@ OpExecutionMode %compute_main LocalSize 1 1 1 OpName %value "value" OpName %vertex_point_size "vertex_point_size" - OpName %tint_count_leading_zeros "tint_count_leading_zeros" - OpName %v "v" - OpName %x "x" OpName %countLeadingZeros_f70103 "countLeadingZeros_f70103" OpName %res "res" OpName %vertex_main_inner "vertex_main_inner" @@ -31,105 +28,41 @@ %_ptr_Output_float = OpTypePointer Output %float %8 = OpConstantNull %float %vertex_point_size = OpVariable %_ptr_Output_float Output %8 + %void = OpTypeVoid + %9 = OpTypeFunction %void %uint = OpTypeInt 32 0 %v4uint = OpTypeVector %uint 4 - %9 = OpTypeFunction %v4uint %v4uint + %uint_31 = OpConstant %uint 31 + %16 = OpConstantComposite %v4uint %uint_31 %uint_31 %uint_31 %uint_31 %_ptr_Function_v4uint = OpTypePointer Function %v4uint - %18 = OpConstantNull %v4uint - %uint_65535 = OpConstant %uint 65535 - %22 = OpConstantComposite %v4uint %uint_65535 %uint_65535 %uint_65535 %uint_65535 - %bool = OpTypeBool - %v4bool = OpTypeVector %bool 4 - %uint_16 = OpConstant %uint 16 - %27 = OpConstantComposite %v4uint %uint_16 %uint_16 %uint_16 %uint_16 -%uint_16777215 = OpConstant %uint 16777215 - %33 = OpConstantComposite %v4uint %uint_16777215 %uint_16777215 %uint_16777215 %uint_16777215 - %uint_8 = OpConstant %uint 8 - %36 = OpConstantComposite %v4uint %uint_8 %uint_8 %uint_8 %uint_8 -%uint_268435455 = OpConstant %uint 268435455 - %42 = OpConstantComposite %v4uint %uint_268435455 %uint_268435455 %uint_268435455 %uint_268435455 - %uint_4 = OpConstant %uint 4 - %45 = OpConstantComposite %v4uint %uint_4 %uint_4 %uint_4 %uint_4 -%uint_1073741823 = OpConstant %uint 1073741823 - %51 = OpConstantComposite %v4uint %uint_1073741823 %uint_1073741823 %uint_1073741823 %uint_1073741823 - %uint_2 = OpConstant %uint 2 - %54 = OpConstantComposite %v4uint %uint_2 %uint_2 %uint_2 %uint_2 -%uint_2147483647 = OpConstant %uint 2147483647 - %60 = OpConstantComposite %v4uint %uint_2147483647 %uint_2147483647 %uint_2147483647 %uint_2147483647 - %uint_1 = OpConstant %uint 1 - %63 = OpConstantComposite %v4uint %uint_1 %uint_1 %uint_1 %uint_1 - %void = OpTypeVoid - %73 = OpTypeFunction %void - %79 = OpTypeFunction %v4float + %19 = OpConstantNull %v4uint + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 -%tint_count_leading_zeros = OpFunction %v4uint None %9 - %v = OpFunctionParameter %v4uint - %14 = OpLabel - %x = OpVariable %_ptr_Function_v4uint Function %18 - OpStore %x %v - %20 = OpLoad %v4uint %x - %23 = OpULessThanEqual %v4bool %20 %22 - %19 = OpSelect %v4uint %23 %27 %18 - %28 = OpLoad %v4uint %x - %29 = OpShiftLeftLogical %v4uint %28 %19 - OpStore %x %29 - %31 = OpLoad %v4uint %x - %34 = OpULessThanEqual %v4bool %31 %33 - %30 = OpSelect %v4uint %34 %36 %18 - %37 = OpLoad %v4uint %x - %38 = OpShiftLeftLogical %v4uint %37 %30 - OpStore %x %38 - %40 = OpLoad %v4uint %x - %43 = OpULessThanEqual %v4bool %40 %42 - %39 = OpSelect %v4uint %43 %45 %18 - %46 = OpLoad %v4uint %x - %47 = OpShiftLeftLogical %v4uint %46 %39 - OpStore %x %47 - %49 = OpLoad %v4uint %x - %52 = OpULessThanEqual %v4bool %49 %51 - %48 = OpSelect %v4uint %52 %54 %18 - %55 = OpLoad %v4uint %x - %56 = OpShiftLeftLogical %v4uint %55 %48 - OpStore %x %56 - %58 = OpLoad %v4uint %x - %61 = OpULessThanEqual %v4bool %58 %60 - %57 = OpSelect %v4uint %61 %63 %18 - %65 = OpLoad %v4uint %x - %66 = OpIEqual %v4bool %65 %18 - %64 = OpSelect %v4uint %66 %63 %18 - %68 = OpBitwiseOr %v4uint %19 %30 - %69 = OpBitwiseOr %v4uint %68 %39 - %70 = OpBitwiseOr %v4uint %69 %48 - %71 = OpBitwiseOr %v4uint %70 %57 - %72 = OpIAdd %v4uint %71 %64 - OpReturnValue %72 - OpFunctionEnd -%countLeadingZeros_f70103 = OpFunction %void None %73 - %76 = OpLabel - %res = OpVariable %_ptr_Function_v4uint Function %18 - %77 = OpFunctionCall %v4uint %tint_count_leading_zeros %63 - OpStore %res %77 +%countLeadingZeros_f70103 = OpFunction %void None %9 + %12 = OpLabel + %res = OpVariable %_ptr_Function_v4uint Function %19 + OpStore %res %16 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %79 - %81 = OpLabel - %82 = OpFunctionCall %void %countLeadingZeros_f70103 +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %countLeadingZeros_f70103 OpReturnValue %5 OpFunctionEnd -%vertex_main = OpFunction %void None %73 - %84 = OpLabel - %85 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %85 +%vertex_main = OpFunction %void None %9 + %25 = OpLabel + %26 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %26 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd -%fragment_main = OpFunction %void None %73 - %88 = OpLabel - %89 = OpFunctionCall %void %countLeadingZeros_f70103 +%fragment_main = OpFunction %void None %9 + %29 = OpLabel + %30 = OpFunctionCall %void %countLeadingZeros_f70103 OpReturn OpFunctionEnd -%compute_main = OpFunction %void None %73 - %91 = OpLabel - %92 = OpFunctionCall %void %countLeadingZeros_f70103 +%compute_main = OpFunction %void None %9 + %32 = OpLabel + %33 = OpFunctionCall %void %countLeadingZeros_f70103 OpReturn OpFunctionEnd