diff --git a/src/tint/intrinsics.def b/src/tint/intrinsics.def index b513deb051..d3d01e681d 100644 --- a/src/tint/intrinsics.def +++ b/src/tint/intrinsics.def @@ -435,8 +435,8 @@ fn cosh(T) -> T fn cosh(vec) -> vec @const fn countLeadingZeros(T) -> T @const fn countLeadingZeros(vec) -> vec -fn countOneBits(T) -> T -fn countOneBits(vec) -> vec +@const fn countOneBits(T) -> T +@const fn countOneBits(vec) -> vec @const fn countTrailingZeros(T) -> T @const fn countTrailingZeros(vec) -> vec fn cross(vec3, vec3) -> vec3 diff --git a/src/tint/resolver/const_eval.cc b/src/tint/resolver/const_eval.cc index 86ce7605bd..83998c0c7d 100644 --- a/src/tint/resolver/const_eval.cc +++ b/src/tint/resolver/const_eval.cc @@ -1657,6 +1657,30 @@ ConstEval::Result ConstEval::countLeadingZeros(const sem::Type* ty, return TransformElements(builder, ty, transform, args[0]); } +ConstEval::Result ConstEval::countOneBits(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 kRightMost = UT{1}; + + auto count = UT{0}; + for (auto v = static_cast(e); v != UT{0}; v >>= 1) { + if ((v & kRightMost) == 1) { + ++count; + } + } + + return CreateElement(builder, c0->Type(), NumberT(count)); + }; + return Dispatch_iu32(create, c0); + }; + return TransformElements(builder, ty, transform, args[0]); +} + ConstEval::Result ConstEval::countTrailingZeros(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 1d6bb978c5..4e701f9e3b 100644 --- a/src/tint/resolver/const_eval.h +++ b/src/tint/resolver/const_eval.h @@ -449,14 +449,23 @@ class ConstEval { utils::VectorRef args, const Source& source); + /// countOneBits 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 countOneBits(const sem::Type* ty, + utils::VectorRef args, + const Source& source); + /// countTrailingZeros 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 countTrailingZeros(const sem::Type* ty, - utils::VectorRef args, - const Source& source); + utils::VectorRef args, + const Source& source); /// saturate builtin /// @param ty the expression type diff --git a/src/tint/resolver/const_eval_builtin_test.cc b/src/tint/resolver/const_eval_builtin_test.cc index 7b215160c0..71ec92ec07 100644 --- a/src/tint/resolver/const_eval_builtin_test.cc +++ b/src/tint/resolver/const_eval_builtin_test.cc @@ -581,6 +581,43 @@ INSTANTIATE_TEST_SUITE_P( // testing::ValuesIn(Concat(CountTrailingZerosCases(), // CountTrailingZerosCases())))); +template +std::vector CountOneBitsCases() { + using B = BitValues; + return { + C({T(0)}, T(0)), // + + C({B::Lsh(1, 31)}, T(1)), // + C({B::Lsh(1, 30)}, T(1)), // + C({B::Lsh(1, 29)}, T(1)), // + C({B::Lsh(1, 28)}, T(1)), + //... + C({B::Lsh(1, 3)}, T(1)), // + C({B::Lsh(1, 2)}, T(1)), // + C({B::Lsh(1, 1)}, T(1)), // + C({B::Lsh(1, 0)}, T(1)), + + C({T(0b1010'1010'1010'1010'1010'1010'1010'1010)}, T(16)), + C({T(0b0000'1111'0000'1111'0000'1111'0000'1111)}, T(16)), + C({T(0b0101'0000'0000'0000'0000'0000'0000'0101)}, T(4)), + + // Vector tests + C({Vec(B::Lsh(1, 31), B::Lsh(1, 30), B::Lsh(1, 29))}, Vec(T(1), T(1), T(1))), + C({Vec(B::Lsh(1, 2), B::Lsh(1, 1), B::Lsh(1, 0))}, Vec(T(1), T(1), T(1))), + + C({Vec(T(0b1010'1010'1010'1010'1010'1010'1010'1010), + T(0b0000'1111'0000'1111'0000'1111'0000'1111), + T(0b0101'0000'0000'0000'0000'0000'0000'0101))}, + Vec(T(16), T(16), T(4))), + }; +} +INSTANTIATE_TEST_SUITE_P( // + CountOneBits, + ResolverConstEvalBuiltinTest, + testing::Combine(testing::Values(sem::BuiltinType::kCountOneBits), + testing::ValuesIn(Concat(CountOneBitsCases(), // + CountOneBitsCases())))); + template std::vector SaturateCases() { return { diff --git a/src/tint/resolver/intrinsic_table.inl b/src/tint/resolver/intrinsic_table.inl index c25bd400f3..ae0ea8a830 100644 --- a/src/tint/resolver/intrinsic_table.inl +++ b/src/tint/resolver/intrinsic_table.inl @@ -12964,7 +12964,7 @@ constexpr OverloadInfo kOverloads[] = { /* parameters */ &kParameters[944], /* return matcher indices */ &kMatcherIndices[1], /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), - /* const eval */ nullptr, + /* const eval */ &ConstEval::countOneBits, }, { /* [387] */ @@ -12976,7 +12976,7 @@ constexpr OverloadInfo kOverloads[] = { /* parameters */ &kParameters[932], /* return matcher indices */ &kMatcherIndices[30], /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), - /* const eval */ nullptr, + /* const eval */ &ConstEval::countOneBits, }, { /* [388] */ diff --git a/test/tint/builtins/gen/literal/countOneBits/0d0e46.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/countOneBits/0d0e46.wgsl.expected.dxc.hlsl index 800331e426..ca49cf7ed7 100644 --- a/test/tint/builtins/gen/literal/countOneBits/0d0e46.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/countOneBits/0d0e46.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void countOneBits_0d0e46() { - uint4 res = countbits((1u).xxxx); + uint4 res = (1u).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countOneBits/0d0e46.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/countOneBits/0d0e46.wgsl.expected.fxc.hlsl index 800331e426..ca49cf7ed7 100644 --- a/test/tint/builtins/gen/literal/countOneBits/0d0e46.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/countOneBits/0d0e46.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void countOneBits_0d0e46() { - uint4 res = countbits((1u).xxxx); + uint4 res = (1u).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countOneBits/0d0e46.wgsl.expected.glsl b/test/tint/builtins/gen/literal/countOneBits/0d0e46.wgsl.expected.glsl index 85f302a948..0092329601 100644 --- a/test/tint/builtins/gen/literal/countOneBits/0d0e46.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/countOneBits/0d0e46.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void countOneBits_0d0e46() { - uvec4 res = uvec4(bitCount(uvec4(1u))); + uvec4 res = uvec4(1u); } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void countOneBits_0d0e46() { - uvec4 res = uvec4(bitCount(uvec4(1u))); + uvec4 res = uvec4(1u); } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void countOneBits_0d0e46() { - uvec4 res = uvec4(bitCount(uvec4(1u))); + uvec4 res = uvec4(1u); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/countOneBits/0d0e46.wgsl.expected.msl b/test/tint/builtins/gen/literal/countOneBits/0d0e46.wgsl.expected.msl index 05f5254685..5090ddc6c7 100644 --- a/test/tint/builtins/gen/literal/countOneBits/0d0e46.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/countOneBits/0d0e46.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void countOneBits_0d0e46() { - uint4 res = popcount(uint4(1u)); + uint4 res = uint4(1u); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countOneBits/0d0e46.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/countOneBits/0d0e46.wgsl.expected.spvasm index 09bb571913..c61cc2845f 100644 --- a/test/tint/builtins/gen/literal/countOneBits/0d0e46.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/countOneBits/0d0e46.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 35 +; Bound: 34 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -33,37 +33,36 @@ %uint = OpTypeInt 32 0 %v4uint = OpTypeVector %uint 4 %uint_1 = OpConstant %uint 1 - %17 = OpConstantComposite %v4uint %uint_1 %uint_1 %uint_1 %uint_1 + %16 = OpConstantComposite %v4uint %uint_1 %uint_1 %uint_1 %uint_1 %_ptr_Function_v4uint = OpTypePointer Function %v4uint - %20 = OpConstantNull %v4uint - %21 = OpTypeFunction %v4float + %19 = OpConstantNull %v4uint + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %countOneBits_0d0e46 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v4uint Function %20 - %13 = OpBitCount %v4uint %17 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v4uint Function %19 + OpStore %res %16 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %21 - %23 = OpLabel - %24 = OpFunctionCall %void %countOneBits_0d0e46 +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %countOneBits_0d0e46 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %27 + %25 = OpLabel + %26 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %26 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %30 = OpLabel - %31 = OpFunctionCall %void %countOneBits_0d0e46 + %29 = OpLabel + %30 = OpFunctionCall %void %countOneBits_0d0e46 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %33 = OpLabel - %34 = OpFunctionCall %void %countOneBits_0d0e46 + %32 = OpLabel + %33 = OpFunctionCall %void %countOneBits_0d0e46 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/countOneBits/0f7980.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/countOneBits/0f7980.wgsl.expected.dxc.hlsl index e66db7a2c4..73ce2e82c7 100644 --- a/test/tint/builtins/gen/literal/countOneBits/0f7980.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/countOneBits/0f7980.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void countOneBits_0f7980() { - int4 res = asint(countbits(asuint((1).xxxx))); + int4 res = (1).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countOneBits/0f7980.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/countOneBits/0f7980.wgsl.expected.fxc.hlsl index e66db7a2c4..73ce2e82c7 100644 --- a/test/tint/builtins/gen/literal/countOneBits/0f7980.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/countOneBits/0f7980.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void countOneBits_0f7980() { - int4 res = asint(countbits(asuint((1).xxxx))); + int4 res = (1).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countOneBits/0f7980.wgsl.expected.glsl b/test/tint/builtins/gen/literal/countOneBits/0f7980.wgsl.expected.glsl index 52a742ed1c..c6a79c0758 100644 --- a/test/tint/builtins/gen/literal/countOneBits/0f7980.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/countOneBits/0f7980.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void countOneBits_0f7980() { - ivec4 res = ivec4(bitCount(ivec4(1))); + ivec4 res = ivec4(1); } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void countOneBits_0f7980() { - ivec4 res = ivec4(bitCount(ivec4(1))); + ivec4 res = ivec4(1); } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void countOneBits_0f7980() { - ivec4 res = ivec4(bitCount(ivec4(1))); + ivec4 res = ivec4(1); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/countOneBits/0f7980.wgsl.expected.msl b/test/tint/builtins/gen/literal/countOneBits/0f7980.wgsl.expected.msl index aedf298941..14fefd6185 100644 --- a/test/tint/builtins/gen/literal/countOneBits/0f7980.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/countOneBits/0f7980.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void countOneBits_0f7980() { - int4 res = popcount(int4(1)); + int4 res = int4(1); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countOneBits/0f7980.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/countOneBits/0f7980.wgsl.expected.spvasm index a4617719a5..2402892b62 100644 --- a/test/tint/builtins/gen/literal/countOneBits/0f7980.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/countOneBits/0f7980.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 35 +; Bound: 34 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -33,37 +33,36 @@ %int = OpTypeInt 32 1 %v4int = OpTypeVector %int 4 %int_1 = OpConstant %int 1 - %17 = OpConstantComposite %v4int %int_1 %int_1 %int_1 %int_1 + %16 = OpConstantComposite %v4int %int_1 %int_1 %int_1 %int_1 %_ptr_Function_v4int = OpTypePointer Function %v4int - %20 = OpConstantNull %v4int - %21 = OpTypeFunction %v4float + %19 = OpConstantNull %v4int + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %countOneBits_0f7980 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v4int Function %20 - %13 = OpBitCount %v4int %17 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v4int Function %19 + OpStore %res %16 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %21 - %23 = OpLabel - %24 = OpFunctionCall %void %countOneBits_0f7980 +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %countOneBits_0f7980 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %27 + %25 = OpLabel + %26 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %26 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %30 = OpLabel - %31 = OpFunctionCall %void %countOneBits_0f7980 + %29 = OpLabel + %30 = OpFunctionCall %void %countOneBits_0f7980 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %33 = OpLabel - %34 = OpFunctionCall %void %countOneBits_0f7980 + %32 = OpLabel + %33 = OpFunctionCall %void %countOneBits_0f7980 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/countOneBits/65d2ae.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/countOneBits/65d2ae.wgsl.expected.dxc.hlsl index 790ebc70bc..ce3d74f7cd 100644 --- a/test/tint/builtins/gen/literal/countOneBits/65d2ae.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/countOneBits/65d2ae.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void countOneBits_65d2ae() { - int3 res = asint(countbits(asuint((1).xxx))); + int3 res = (1).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countOneBits/65d2ae.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/countOneBits/65d2ae.wgsl.expected.fxc.hlsl index 790ebc70bc..ce3d74f7cd 100644 --- a/test/tint/builtins/gen/literal/countOneBits/65d2ae.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/countOneBits/65d2ae.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void countOneBits_65d2ae() { - int3 res = asint(countbits(asuint((1).xxx))); + int3 res = (1).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countOneBits/65d2ae.wgsl.expected.glsl b/test/tint/builtins/gen/literal/countOneBits/65d2ae.wgsl.expected.glsl index 811ee03298..6e1363c001 100644 --- a/test/tint/builtins/gen/literal/countOneBits/65d2ae.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/countOneBits/65d2ae.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void countOneBits_65d2ae() { - ivec3 res = ivec3(bitCount(ivec3(1))); + ivec3 res = ivec3(1); } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void countOneBits_65d2ae() { - ivec3 res = ivec3(bitCount(ivec3(1))); + ivec3 res = ivec3(1); } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void countOneBits_65d2ae() { - ivec3 res = ivec3(bitCount(ivec3(1))); + ivec3 res = ivec3(1); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/countOneBits/65d2ae.wgsl.expected.msl b/test/tint/builtins/gen/literal/countOneBits/65d2ae.wgsl.expected.msl index c092cfc627..fd1928cdb2 100644 --- a/test/tint/builtins/gen/literal/countOneBits/65d2ae.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/countOneBits/65d2ae.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void countOneBits_65d2ae() { - int3 res = popcount(int3(1)); + int3 res = int3(1); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countOneBits/65d2ae.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/countOneBits/65d2ae.wgsl.expected.spvasm index 0ff478ecae..c210167d5a 100644 --- a/test/tint/builtins/gen/literal/countOneBits/65d2ae.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/countOneBits/65d2ae.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 35 +; Bound: 34 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -33,37 +33,36 @@ %int = OpTypeInt 32 1 %v3int = OpTypeVector %int 3 %int_1 = OpConstant %int 1 - %17 = OpConstantComposite %v3int %int_1 %int_1 %int_1 + %16 = OpConstantComposite %v3int %int_1 %int_1 %int_1 %_ptr_Function_v3int = OpTypePointer Function %v3int - %20 = OpConstantNull %v3int - %21 = OpTypeFunction %v4float + %19 = OpConstantNull %v3int + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %countOneBits_65d2ae = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v3int Function %20 - %13 = OpBitCount %v3int %17 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v3int Function %19 + OpStore %res %16 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %21 - %23 = OpLabel - %24 = OpFunctionCall %void %countOneBits_65d2ae +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %countOneBits_65d2ae OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %27 + %25 = OpLabel + %26 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %26 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %30 = OpLabel - %31 = OpFunctionCall %void %countOneBits_65d2ae + %29 = OpLabel + %30 = OpFunctionCall %void %countOneBits_65d2ae OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %33 = OpLabel - %34 = OpFunctionCall %void %countOneBits_65d2ae + %32 = OpLabel + %33 = OpFunctionCall %void %countOneBits_65d2ae OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/countOneBits/690cfc.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/countOneBits/690cfc.wgsl.expected.dxc.hlsl index 2b15a93cab..b5c737da25 100644 --- a/test/tint/builtins/gen/literal/countOneBits/690cfc.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/countOneBits/690cfc.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void countOneBits_690cfc() { - uint3 res = countbits((1u).xxx); + uint3 res = (1u).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countOneBits/690cfc.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/countOneBits/690cfc.wgsl.expected.fxc.hlsl index 2b15a93cab..b5c737da25 100644 --- a/test/tint/builtins/gen/literal/countOneBits/690cfc.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/countOneBits/690cfc.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void countOneBits_690cfc() { - uint3 res = countbits((1u).xxx); + uint3 res = (1u).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countOneBits/690cfc.wgsl.expected.glsl b/test/tint/builtins/gen/literal/countOneBits/690cfc.wgsl.expected.glsl index c3309dafa4..ab51c88647 100644 --- a/test/tint/builtins/gen/literal/countOneBits/690cfc.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/countOneBits/690cfc.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void countOneBits_690cfc() { - uvec3 res = uvec3(bitCount(uvec3(1u))); + uvec3 res = uvec3(1u); } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void countOneBits_690cfc() { - uvec3 res = uvec3(bitCount(uvec3(1u))); + uvec3 res = uvec3(1u); } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void countOneBits_690cfc() { - uvec3 res = uvec3(bitCount(uvec3(1u))); + uvec3 res = uvec3(1u); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/countOneBits/690cfc.wgsl.expected.msl b/test/tint/builtins/gen/literal/countOneBits/690cfc.wgsl.expected.msl index 32a6ebba7e..29f59d89e8 100644 --- a/test/tint/builtins/gen/literal/countOneBits/690cfc.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/countOneBits/690cfc.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void countOneBits_690cfc() { - uint3 res = popcount(uint3(1u)); + uint3 res = uint3(1u); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countOneBits/690cfc.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/countOneBits/690cfc.wgsl.expected.spvasm index 2fd3033ebb..514c316d46 100644 --- a/test/tint/builtins/gen/literal/countOneBits/690cfc.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/countOneBits/690cfc.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 35 +; Bound: 34 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -33,37 +33,36 @@ %uint = OpTypeInt 32 0 %v3uint = OpTypeVector %uint 3 %uint_1 = OpConstant %uint 1 - %17 = OpConstantComposite %v3uint %uint_1 %uint_1 %uint_1 + %16 = OpConstantComposite %v3uint %uint_1 %uint_1 %uint_1 %_ptr_Function_v3uint = OpTypePointer Function %v3uint - %20 = OpConstantNull %v3uint - %21 = OpTypeFunction %v4float + %19 = OpConstantNull %v3uint + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %countOneBits_690cfc = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v3uint Function %20 - %13 = OpBitCount %v3uint %17 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v3uint Function %19 + OpStore %res %16 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %21 - %23 = OpLabel - %24 = OpFunctionCall %void %countOneBits_690cfc +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %countOneBits_690cfc OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %27 + %25 = OpLabel + %26 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %26 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %30 = OpLabel - %31 = OpFunctionCall %void %countOneBits_690cfc + %29 = OpLabel + %30 = OpFunctionCall %void %countOneBits_690cfc OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %33 = OpLabel - %34 = OpFunctionCall %void %countOneBits_690cfc + %32 = OpLabel + %33 = OpFunctionCall %void %countOneBits_690cfc OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/countOneBits/94fd81.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/countOneBits/94fd81.wgsl.expected.dxc.hlsl index 218f0f8295..a92bb30f82 100644 --- a/test/tint/builtins/gen/literal/countOneBits/94fd81.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/countOneBits/94fd81.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void countOneBits_94fd81() { - uint2 res = countbits((1u).xx); + uint2 res = (1u).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countOneBits/94fd81.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/countOneBits/94fd81.wgsl.expected.fxc.hlsl index 218f0f8295..a92bb30f82 100644 --- a/test/tint/builtins/gen/literal/countOneBits/94fd81.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/countOneBits/94fd81.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void countOneBits_94fd81() { - uint2 res = countbits((1u).xx); + uint2 res = (1u).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countOneBits/94fd81.wgsl.expected.glsl b/test/tint/builtins/gen/literal/countOneBits/94fd81.wgsl.expected.glsl index ed00b85e42..c0e234f42a 100644 --- a/test/tint/builtins/gen/literal/countOneBits/94fd81.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/countOneBits/94fd81.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void countOneBits_94fd81() { - uvec2 res = uvec2(bitCount(uvec2(1u))); + uvec2 res = uvec2(1u); } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void countOneBits_94fd81() { - uvec2 res = uvec2(bitCount(uvec2(1u))); + uvec2 res = uvec2(1u); } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void countOneBits_94fd81() { - uvec2 res = uvec2(bitCount(uvec2(1u))); + uvec2 res = uvec2(1u); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/countOneBits/94fd81.wgsl.expected.msl b/test/tint/builtins/gen/literal/countOneBits/94fd81.wgsl.expected.msl index 15740da01f..68a63f85a6 100644 --- a/test/tint/builtins/gen/literal/countOneBits/94fd81.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/countOneBits/94fd81.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void countOneBits_94fd81() { - uint2 res = popcount(uint2(1u)); + uint2 res = uint2(1u); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countOneBits/94fd81.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/countOneBits/94fd81.wgsl.expected.spvasm index 7504893158..17bea2d83d 100644 --- a/test/tint/builtins/gen/literal/countOneBits/94fd81.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/countOneBits/94fd81.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 35 +; Bound: 34 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -33,37 +33,36 @@ %uint = OpTypeInt 32 0 %v2uint = OpTypeVector %uint 2 %uint_1 = OpConstant %uint 1 - %17 = OpConstantComposite %v2uint %uint_1 %uint_1 + %16 = OpConstantComposite %v2uint %uint_1 %uint_1 %_ptr_Function_v2uint = OpTypePointer Function %v2uint - %20 = OpConstantNull %v2uint - %21 = OpTypeFunction %v4float + %19 = OpConstantNull %v2uint + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %countOneBits_94fd81 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v2uint Function %20 - %13 = OpBitCount %v2uint %17 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v2uint Function %19 + OpStore %res %16 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %21 - %23 = OpLabel - %24 = OpFunctionCall %void %countOneBits_94fd81 +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %countOneBits_94fd81 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %27 + %25 = OpLabel + %26 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %26 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %30 = OpLabel - %31 = OpFunctionCall %void %countOneBits_94fd81 + %29 = OpLabel + %30 = OpFunctionCall %void %countOneBits_94fd81 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %33 = OpLabel - %34 = OpFunctionCall %void %countOneBits_94fd81 + %32 = OpLabel + %33 = OpFunctionCall %void %countOneBits_94fd81 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/countOneBits/ae44f9.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/countOneBits/ae44f9.wgsl.expected.dxc.hlsl index 6b51b87d6d..21626946eb 100644 --- a/test/tint/builtins/gen/literal/countOneBits/ae44f9.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/countOneBits/ae44f9.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void countOneBits_ae44f9() { - uint res = countbits(1u); + uint res = 1u; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countOneBits/ae44f9.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/countOneBits/ae44f9.wgsl.expected.fxc.hlsl index 6b51b87d6d..21626946eb 100644 --- a/test/tint/builtins/gen/literal/countOneBits/ae44f9.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/countOneBits/ae44f9.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void countOneBits_ae44f9() { - uint res = countbits(1u); + uint res = 1u; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countOneBits/ae44f9.wgsl.expected.glsl b/test/tint/builtins/gen/literal/countOneBits/ae44f9.wgsl.expected.glsl index 73089c988b..bb3693a4d4 100644 --- a/test/tint/builtins/gen/literal/countOneBits/ae44f9.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/countOneBits/ae44f9.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void countOneBits_ae44f9() { - uint res = uint(bitCount(1u)); + uint res = 1u; } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void countOneBits_ae44f9() { - uint res = uint(bitCount(1u)); + uint res = 1u; } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void countOneBits_ae44f9() { - uint res = uint(bitCount(1u)); + uint res = 1u; } void compute_main() { diff --git a/test/tint/builtins/gen/literal/countOneBits/ae44f9.wgsl.expected.msl b/test/tint/builtins/gen/literal/countOneBits/ae44f9.wgsl.expected.msl index 70e2b9f6f2..2f89485015 100644 --- a/test/tint/builtins/gen/literal/countOneBits/ae44f9.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/countOneBits/ae44f9.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void countOneBits_ae44f9() { - uint res = popcount(1u); + uint res = 1u; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countOneBits/ae44f9.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/countOneBits/ae44f9.wgsl.expected.spvasm index 7d098ff761..fe8c485e4e 100644 --- a/test/tint/builtins/gen/literal/countOneBits/ae44f9.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/countOneBits/ae44f9.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 33 +; Bound: 32 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -33,35 +33,34 @@ %uint = OpTypeInt 32 0 %uint_1 = OpConstant %uint 1 %_ptr_Function_uint = OpTypePointer Function %uint - %18 = OpConstantNull %uint - %19 = OpTypeFunction %v4float + %17 = OpConstantNull %uint + %18 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %countOneBits_ae44f9 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_uint Function %18 - %13 = OpBitCount %uint %uint_1 - OpStore %res %13 + %res = OpVariable %_ptr_Function_uint Function %17 + OpStore %res %uint_1 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %19 - %21 = OpLabel - %22 = OpFunctionCall %void %countOneBits_ae44f9 +%vertex_main_inner = OpFunction %v4float None %18 + %20 = OpLabel + %21 = OpFunctionCall %void %countOneBits_ae44f9 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %24 = OpLabel - %25 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %25 + %23 = OpLabel + %24 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %24 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %28 = OpLabel - %29 = OpFunctionCall %void %countOneBits_ae44f9 + %27 = OpLabel + %28 = OpFunctionCall %void %countOneBits_ae44f9 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %31 = OpLabel - %32 = OpFunctionCall %void %countOneBits_ae44f9 + %30 = OpLabel + %31 = OpFunctionCall %void %countOneBits_ae44f9 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/countOneBits/af90e2.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/countOneBits/af90e2.wgsl.expected.dxc.hlsl index 31d15d4e56..6a6a9b4db0 100644 --- a/test/tint/builtins/gen/literal/countOneBits/af90e2.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/countOneBits/af90e2.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void countOneBits_af90e2() { - int2 res = asint(countbits(asuint((1).xx))); + int2 res = (1).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countOneBits/af90e2.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/countOneBits/af90e2.wgsl.expected.fxc.hlsl index 31d15d4e56..6a6a9b4db0 100644 --- a/test/tint/builtins/gen/literal/countOneBits/af90e2.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/countOneBits/af90e2.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void countOneBits_af90e2() { - int2 res = asint(countbits(asuint((1).xx))); + int2 res = (1).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countOneBits/af90e2.wgsl.expected.glsl b/test/tint/builtins/gen/literal/countOneBits/af90e2.wgsl.expected.glsl index c1509a80a4..b8eceb6c9d 100644 --- a/test/tint/builtins/gen/literal/countOneBits/af90e2.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/countOneBits/af90e2.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void countOneBits_af90e2() { - ivec2 res = ivec2(bitCount(ivec2(1))); + ivec2 res = ivec2(1); } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void countOneBits_af90e2() { - ivec2 res = ivec2(bitCount(ivec2(1))); + ivec2 res = ivec2(1); } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void countOneBits_af90e2() { - ivec2 res = ivec2(bitCount(ivec2(1))); + ivec2 res = ivec2(1); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/countOneBits/af90e2.wgsl.expected.msl b/test/tint/builtins/gen/literal/countOneBits/af90e2.wgsl.expected.msl index d4f525d3fc..b87444c2a1 100644 --- a/test/tint/builtins/gen/literal/countOneBits/af90e2.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/countOneBits/af90e2.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void countOneBits_af90e2() { - int2 res = popcount(int2(1)); + int2 res = int2(1); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countOneBits/af90e2.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/countOneBits/af90e2.wgsl.expected.spvasm index 50566337db..154f2f4ebc 100644 --- a/test/tint/builtins/gen/literal/countOneBits/af90e2.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/countOneBits/af90e2.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 35 +; Bound: 34 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -33,37 +33,36 @@ %int = OpTypeInt 32 1 %v2int = OpTypeVector %int 2 %int_1 = OpConstant %int 1 - %17 = OpConstantComposite %v2int %int_1 %int_1 + %16 = OpConstantComposite %v2int %int_1 %int_1 %_ptr_Function_v2int = OpTypePointer Function %v2int - %20 = OpConstantNull %v2int - %21 = OpTypeFunction %v4float + %19 = OpConstantNull %v2int + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %countOneBits_af90e2 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v2int Function %20 - %13 = OpBitCount %v2int %17 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v2int Function %19 + OpStore %res %16 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %21 - %23 = OpLabel - %24 = OpFunctionCall %void %countOneBits_af90e2 +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %countOneBits_af90e2 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %27 + %25 = OpLabel + %26 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %26 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %30 = OpLabel - %31 = OpFunctionCall %void %countOneBits_af90e2 + %29 = OpLabel + %30 = OpFunctionCall %void %countOneBits_af90e2 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %33 = OpLabel - %34 = OpFunctionCall %void %countOneBits_af90e2 + %32 = OpLabel + %33 = OpFunctionCall %void %countOneBits_af90e2 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/countOneBits/fd88b2.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/countOneBits/fd88b2.wgsl.expected.dxc.hlsl index cc56ef3deb..71e3fc03c2 100644 --- a/test/tint/builtins/gen/literal/countOneBits/fd88b2.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/countOneBits/fd88b2.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void countOneBits_fd88b2() { - int res = asint(countbits(asuint(1))); + int res = 1; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countOneBits/fd88b2.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/countOneBits/fd88b2.wgsl.expected.fxc.hlsl index cc56ef3deb..71e3fc03c2 100644 --- a/test/tint/builtins/gen/literal/countOneBits/fd88b2.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/countOneBits/fd88b2.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void countOneBits_fd88b2() { - int res = asint(countbits(asuint(1))); + int res = 1; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countOneBits/fd88b2.wgsl.expected.glsl b/test/tint/builtins/gen/literal/countOneBits/fd88b2.wgsl.expected.glsl index 6f0d56cc38..da7d29e686 100644 --- a/test/tint/builtins/gen/literal/countOneBits/fd88b2.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/countOneBits/fd88b2.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void countOneBits_fd88b2() { - int res = int(bitCount(1)); + int res = 1; } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void countOneBits_fd88b2() { - int res = int(bitCount(1)); + int res = 1; } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void countOneBits_fd88b2() { - int res = int(bitCount(1)); + int res = 1; } void compute_main() { diff --git a/test/tint/builtins/gen/literal/countOneBits/fd88b2.wgsl.expected.msl b/test/tint/builtins/gen/literal/countOneBits/fd88b2.wgsl.expected.msl index 91cd762778..a596c93b1a 100644 --- a/test/tint/builtins/gen/literal/countOneBits/fd88b2.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/countOneBits/fd88b2.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void countOneBits_fd88b2() { - int res = popcount(1); + int res = 1; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/countOneBits/fd88b2.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/countOneBits/fd88b2.wgsl.expected.spvasm index 67c346a958..d8377c5075 100644 --- a/test/tint/builtins/gen/literal/countOneBits/fd88b2.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/countOneBits/fd88b2.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 33 +; Bound: 32 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -33,35 +33,34 @@ %int = OpTypeInt 32 1 %int_1 = OpConstant %int 1 %_ptr_Function_int = OpTypePointer Function %int - %18 = OpConstantNull %int - %19 = OpTypeFunction %v4float + %17 = OpConstantNull %int + %18 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %countOneBits_fd88b2 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_int Function %18 - %13 = OpBitCount %int %int_1 - OpStore %res %13 + %res = OpVariable %_ptr_Function_int Function %17 + OpStore %res %int_1 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %19 - %21 = OpLabel - %22 = OpFunctionCall %void %countOneBits_fd88b2 +%vertex_main_inner = OpFunction %v4float None %18 + %20 = OpLabel + %21 = OpFunctionCall %void %countOneBits_fd88b2 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %24 = OpLabel - %25 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %25 + %23 = OpLabel + %24 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %24 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %28 = OpLabel - %29 = OpFunctionCall %void %countOneBits_fd88b2 + %27 = OpLabel + %28 = OpFunctionCall %void %countOneBits_fd88b2 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %31 = OpLabel - %32 = OpFunctionCall %void %countOneBits_fd88b2 + %30 = OpLabel + %31 = OpFunctionCall %void %countOneBits_fd88b2 OpReturn OpFunctionEnd diff --git a/webgpu-cts/expectations.txt b/webgpu-cts/expectations.txt index 9043bb1543..7abcaafccd 100644 --- a/webgpu-cts/expectations.txt +++ b/webgpu-cts/expectations.txt @@ -466,14 +466,6 @@ crbug.com/tint/1613 webgpu:shader,execution,expression,call,builtin,countLeading crbug.com/tint/1613 webgpu:shader,execution,expression,call,builtin,countLeadingZeros:u32:inputSource="const";vectorize=2 [ Failure ] crbug.com/tint/1613 webgpu:shader,execution,expression,call,builtin,countLeadingZeros:u32:inputSource="const";vectorize=3 [ Failure ] crbug.com/tint/1613 webgpu:shader,execution,expression,call,builtin,countLeadingZeros:u32:inputSource="const";vectorize=4 [ Failure ] -crbug.com/tint/1613 webgpu:shader,execution,expression,call,builtin,countOneBits:i32:inputSource="const";vectorize="_undef_" [ Failure ] -crbug.com/tint/1613 webgpu:shader,execution,expression,call,builtin,countOneBits:i32:inputSource="const";vectorize=2 [ Failure ] -crbug.com/tint/1613 webgpu:shader,execution,expression,call,builtin,countOneBits:i32:inputSource="const";vectorize=3 [ Failure ] -crbug.com/tint/1613 webgpu:shader,execution,expression,call,builtin,countOneBits:i32:inputSource="const";vectorize=4 [ Failure ] -crbug.com/tint/1613 webgpu:shader,execution,expression,call,builtin,countOneBits:u32:inputSource="const";vectorize="_undef_" [ Failure ] -crbug.com/tint/1613 webgpu:shader,execution,expression,call,builtin,countOneBits:u32:inputSource="const";vectorize=2 [ Failure ] -crbug.com/tint/1613 webgpu:shader,execution,expression,call,builtin,countOneBits:u32:inputSource="const";vectorize=3 [ Failure ] -crbug.com/tint/1613 webgpu:shader,execution,expression,call,builtin,countOneBits:u32:inputSource="const";vectorize=4 [ Failure ] crbug.com/tint/1613 webgpu:shader,execution,expression,call,builtin,countTrailingZeros:i32:inputSource="const";vectorize="_undef_" [ Failure ] crbug.com/tint/1613 webgpu:shader,execution,expression,call,builtin,countTrailingZeros:i32:inputSource="const";vectorize=2 [ Failure ] crbug.com/tint/1613 webgpu:shader,execution,expression,call,builtin,countTrailingZeros:i32:inputSource="const";vectorize=3 [ Failure ]