tint: const eval of countTrailingZeros
Bug: tint:1581
Change-Id: I2967ea1d6f3f297c03795bddd0e26abcccd57184
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107700
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/src/tint/intrinsics.def b/src/tint/intrinsics.def
index 9b3206b..b55a9cc 100644
--- a/src/tint/intrinsics.def
+++ b/src/tint/intrinsics.def
@@ -437,8 +437,8 @@
@const fn countLeadingZeros<N: num, T: iu32>(vec<N, T>) -> vec<N, T>
fn countOneBits<T: iu32>(T) -> T
fn countOneBits<N: num, T: iu32>(vec<N, T>) -> vec<N, T>
-fn countTrailingZeros<T: iu32>(T) -> T
-fn countTrailingZeros<N: num, T: iu32>(vec<N, T>) -> vec<N, T>
+@const fn countTrailingZeros<T: iu32>(T) -> T
+@const fn countTrailingZeros<N: num, T: iu32>(vec<N, T>) -> vec<N, T>
fn cross<T: f32_f16>(vec3<T>, vec3<T>) -> vec3<T>
fn degrees<T: f32_f16>(T) -> T
fn degrees<N: num, T: f32_f16>(vec<N, T>) -> vec<N, T>
diff --git a/src/tint/resolver/const_eval.cc b/src/tint/resolver/const_eval.cc
index 31b3796..285e936 100644
--- a/src/tint/resolver/const_eval.cc
+++ b/src/tint/resolver/const_eval.cc
@@ -1651,6 +1651,31 @@
return TransformElements(builder, ty, transform, args[0]);
}
+ConstEval::Result ConstEval::countTrailingZeros(const sem::Type* ty,
+ utils::VectorRef<const sem::Constant*> args,
+ const Source&) {
+ auto transform = [&](const sem::Constant* c0) {
+ auto create = [&](auto e) {
+ using NumberT = decltype(e);
+ using T = UnwrapNumber<NumberT>;
+ using UT = std::make_unsigned_t<T>;
+ constexpr UT kNumBits = sizeof(UT) * 8;
+ constexpr UT kRightMost = UT{1};
+
+ auto v = static_cast<UT>(e);
+ auto count = UT{0};
+ while ((count < kNumBits) && ((v & kRightMost) == 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<const sem::Constant*> args,
const Source&) {
diff --git a/src/tint/resolver/const_eval.h b/src/tint/resolver/const_eval.h
index 980a310..91a59f3 100644
--- a/src/tint/resolver/const_eval.h
+++ b/src/tint/resolver/const_eval.h
@@ -440,6 +440,15 @@
utils::VectorRef<const sem::Constant*> 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<const sem::Constant*> 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 6378230..5af7561 100644
--- a/src/tint/resolver/const_eval_builtin_test.cc
+++ b/src/tint/resolver/const_eval_builtin_test.cc
@@ -507,6 +507,52 @@
CountLeadingZerosCases<u32>()))));
template <typename T>
+std::vector<Case> CountTrailingZerosCases() {
+ using B = BitValues<T>;
+ return {
+ C({B::Lsh(1, 31)}, T(31)), //
+ C({B::Lsh(1, 30)}, T(30)), //
+ C({B::Lsh(1, 29)}, T(29)), //
+ C({B::Lsh(1, 28)}, T(28)),
+ //...
+ C({B::Lsh(1, 3)}, T(3)), //
+ C({B::Lsh(1, 2)}, T(2)), //
+ C({B::Lsh(1, 1)}, T(1)), //
+ C({B::Lsh(1, 0)}, T(0)),
+
+ C({T(0b0000'1111'0000'1111'0000'1111'0000'1111)}, T(0)),
+ C({T(0b0001'1110'0001'1110'0001'1110'0001'1110)}, T(1)),
+ C({T(0b0011'1100'0011'1100'0011'1100'0011'1100)}, T(2)),
+ C({T(0b0111'1000'0111'1000'0111'1000'0111'1000)}, T(3)),
+ //...
+ C({T(0b1110'0000'0000'0000'0000'0000'0000'0000)}, T(29)),
+ C({T(0b1100'0000'0000'0000'0000'0000'0000'0000)}, T(30)),
+ C({T(0b1000'0000'0000'0000'0000'0000'0000'0000)}, T(31)),
+ C({T(0b0000'0000'0000'0000'0000'0000'0000'0000)}, T(32)),
+
+ //// Same as above, but remove trailing 0
+ C({T(0b0001'1110'0001'1110'0001'1110'0001'1111)}, T(0)),
+ C({T(0b0011'1100'0011'1100'0011'1100'0011'1101)}, T(0)),
+ C({T(0b0111'1000'0111'1000'0111'1000'0111'1001)}, T(0)),
+ //...
+ C({T(0b1110'0000'0000'0000'0000'0000'0000'0001)}, T(0)),
+ C({T(0b1100'0000'0000'0000'0000'0000'0000'0001)}, T(0)),
+ C({T(0b1000'0000'0000'0000'0000'0000'0000'0001)}, T(0)),
+ C({T(0b0000'0000'0000'0000'0000'0000'0000'0001)}, T(0)),
+
+ // Vector tests
+ C({Vec(B::Lsh(1, 31), B::Lsh(1, 30), B::Lsh(1, 29))}, Vec(T(31), T(30), T(29))),
+ C({Vec(B::Lsh(1, 2), B::Lsh(1, 1), B::Lsh(1, 0))}, Vec(T(2), T(1), T(0))),
+ };
+}
+INSTANTIATE_TEST_SUITE_P( //
+ CountTrailingZeros,
+ ResolverConstEvalBuiltinTest,
+ testing::Combine(testing::Values(sem::BuiltinType::kCountTrailingZeros),
+ testing::ValuesIn(Concat(CountTrailingZerosCases<i32>(), //
+ CountTrailingZerosCases<u32>()))));
+
+template <typename T>
std::vector<Case> SaturateCases() {
return {
C({T(0)}, T(0)),
diff --git a/src/tint/resolver/intrinsic_table.inl b/src/tint/resolver/intrinsic_table.inl
index 38bba68..587333c 100644
--- a/src/tint/resolver/intrinsic_table.inl
+++ b/src/tint/resolver/intrinsic_table.inl
@@ -12940,7 +12940,7 @@
/* parameters */ &kParameters[931],
/* return matcher indices */ &kMatcherIndices[1],
/* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
- /* const eval */ nullptr,
+ /* const eval */ &ConstEval::countTrailingZeros,
},
{
/* [385] */
@@ -12952,7 +12952,7 @@
/* parameters */ &kParameters[930],
/* return matcher indices */ &kMatcherIndices[30],
/* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
- /* const eval */ nullptr,
+ /* const eval */ &ConstEval::countTrailingZeros,
},
{
/* [386] */
diff --git a/test/tint/builtins/gen/literal/countTrailingZeros/1ad138.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/countTrailingZeros/1ad138.wgsl.expected.dxc.hlsl
index a61337c..53ca8f4 100644
--- a/test/tint/builtins/gen/literal/countTrailingZeros/1ad138.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/countTrailingZeros/1ad138.wgsl.expected.dxc.hlsl
@@ -1,20 +1,5 @@
-uint2 tint_count_trailing_zeros(uint2 v) {
- uint2 x = uint2(v);
- const uint2 b16 = (bool2((x & (65535u).xx)) ? (0u).xx : (16u).xx);
- x = (x >> b16);
- const uint2 b8 = (bool2((x & (255u).xx)) ? (0u).xx : (8u).xx);
- x = (x >> b8);
- const uint2 b4 = (bool2((x & (15u).xx)) ? (0u).xx : (4u).xx);
- x = (x >> b4);
- const uint2 b2 = (bool2((x & (3u).xx)) ? (0u).xx : (2u).xx);
- x = (x >> b2);
- const uint2 b1 = (bool2((x & (1u).xx)) ? (0u).xx : (1u).xx);
- const uint2 is_zero = ((x == (0u).xx) ? (1u).xx : (0u).xx);
- return uint2((((((b16 | b8) | b4) | b2) | b1) + is_zero));
-}
-
void countTrailingZeros_1ad138() {
- uint2 res = tint_count_trailing_zeros((1u).xx);
+ uint2 res = (0u).xx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/countTrailingZeros/1ad138.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/countTrailingZeros/1ad138.wgsl.expected.fxc.hlsl
index a61337c..53ca8f4 100644
--- a/test/tint/builtins/gen/literal/countTrailingZeros/1ad138.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/countTrailingZeros/1ad138.wgsl.expected.fxc.hlsl
@@ -1,20 +1,5 @@
-uint2 tint_count_trailing_zeros(uint2 v) {
- uint2 x = uint2(v);
- const uint2 b16 = (bool2((x & (65535u).xx)) ? (0u).xx : (16u).xx);
- x = (x >> b16);
- const uint2 b8 = (bool2((x & (255u).xx)) ? (0u).xx : (8u).xx);
- x = (x >> b8);
- const uint2 b4 = (bool2((x & (15u).xx)) ? (0u).xx : (4u).xx);
- x = (x >> b4);
- const uint2 b2 = (bool2((x & (3u).xx)) ? (0u).xx : (2u).xx);
- x = (x >> b2);
- const uint2 b1 = (bool2((x & (1u).xx)) ? (0u).xx : (1u).xx);
- const uint2 is_zero = ((x == (0u).xx) ? (1u).xx : (0u).xx);
- return uint2((((((b16 | b8) | b4) | b2) | b1) + is_zero));
-}
-
void countTrailingZeros_1ad138() {
- uint2 res = tint_count_trailing_zeros((1u).xx);
+ uint2 res = (0u).xx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/countTrailingZeros/1ad138.wgsl.expected.glsl b/test/tint/builtins/gen/literal/countTrailingZeros/1ad138.wgsl.expected.glsl
index c6bd3d4..7587a61 100644
--- a/test/tint/builtins/gen/literal/countTrailingZeros/1ad138.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/countTrailingZeros/1ad138.wgsl.expected.glsl
@@ -1,22 +1,7 @@
#version 310 es
-uvec2 tint_count_trailing_zeros(uvec2 v) {
- uvec2 x = uvec2(v);
- uvec2 b16 = mix(uvec2(16u), uvec2(0u), bvec2((x & uvec2(65535u))));
- x = (x >> b16);
- uvec2 b8 = mix(uvec2(8u), uvec2(0u), bvec2((x & uvec2(255u))));
- x = (x >> b8);
- uvec2 b4 = mix(uvec2(4u), uvec2(0u), bvec2((x & uvec2(15u))));
- x = (x >> b4);
- uvec2 b2 = mix(uvec2(2u), uvec2(0u), bvec2((x & uvec2(3u))));
- x = (x >> b2);
- uvec2 b1 = mix(uvec2(1u), uvec2(0u), bvec2((x & uvec2(1u))));
- uvec2 is_zero = mix(uvec2(0u), uvec2(1u), equal(x, uvec2(0u)));
- return uvec2((((((b16 | b8) | b4) | b2) | b1) + is_zero));
-}
-
void countTrailingZeros_1ad138() {
- uvec2 res = tint_count_trailing_zeros(uvec2(1u));
+ uvec2 res = uvec2(0u);
}
vec4 vertex_main() {
@@ -35,23 +20,8 @@
#version 310 es
precision mediump float;
-uvec2 tint_count_trailing_zeros(uvec2 v) {
- uvec2 x = uvec2(v);
- uvec2 b16 = mix(uvec2(16u), uvec2(0u), bvec2((x & uvec2(65535u))));
- x = (x >> b16);
- uvec2 b8 = mix(uvec2(8u), uvec2(0u), bvec2((x & uvec2(255u))));
- x = (x >> b8);
- uvec2 b4 = mix(uvec2(4u), uvec2(0u), bvec2((x & uvec2(15u))));
- x = (x >> b4);
- uvec2 b2 = mix(uvec2(2u), uvec2(0u), bvec2((x & uvec2(3u))));
- x = (x >> b2);
- uvec2 b1 = mix(uvec2(1u), uvec2(0u), bvec2((x & uvec2(1u))));
- uvec2 is_zero = mix(uvec2(0u), uvec2(1u), equal(x, uvec2(0u)));
- return uvec2((((((b16 | b8) | b4) | b2) | b1) + is_zero));
-}
-
void countTrailingZeros_1ad138() {
- uvec2 res = tint_count_trailing_zeros(uvec2(1u));
+ uvec2 res = uvec2(0u);
}
void fragment_main() {
@@ -64,23 +34,8 @@
}
#version 310 es
-uvec2 tint_count_trailing_zeros(uvec2 v) {
- uvec2 x = uvec2(v);
- uvec2 b16 = mix(uvec2(16u), uvec2(0u), bvec2((x & uvec2(65535u))));
- x = (x >> b16);
- uvec2 b8 = mix(uvec2(8u), uvec2(0u), bvec2((x & uvec2(255u))));
- x = (x >> b8);
- uvec2 b4 = mix(uvec2(4u), uvec2(0u), bvec2((x & uvec2(15u))));
- x = (x >> b4);
- uvec2 b2 = mix(uvec2(2u), uvec2(0u), bvec2((x & uvec2(3u))));
- x = (x >> b2);
- uvec2 b1 = mix(uvec2(1u), uvec2(0u), bvec2((x & uvec2(1u))));
- uvec2 is_zero = mix(uvec2(0u), uvec2(1u), equal(x, uvec2(0u)));
- return uvec2((((((b16 | b8) | b4) | b2) | b1) + is_zero));
-}
-
void countTrailingZeros_1ad138() {
- uvec2 res = tint_count_trailing_zeros(uvec2(1u));
+ uvec2 res = uvec2(0u);
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/countTrailingZeros/1ad138.wgsl.expected.msl b/test/tint/builtins/gen/literal/countTrailingZeros/1ad138.wgsl.expected.msl
index 527fe90..e0f33eb 100644
--- a/test/tint/builtins/gen/literal/countTrailingZeros/1ad138.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/countTrailingZeros/1ad138.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void countTrailingZeros_1ad138() {
- uint2 res = ctz(uint2(1u));
+ uint2 res = uint2(0u);
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/countTrailingZeros/1ad138.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/countTrailingZeros/1ad138.wgsl.expected.spvasm
index d2ea81d..9bb2548 100644
--- a/test/tint/builtins/gen/literal/countTrailingZeros/1ad138.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/countTrailingZeros/1ad138.wgsl.expected.spvasm
@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 96
+; 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_trailing_zeros "tint_count_trailing_zeros"
- OpName %v "v"
- OpName %x "x"
OpName %countTrailingZeros_1ad138 "countTrailingZeros_1ad138"
OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner"
@@ -31,108 +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
%v2uint = OpTypeVector %uint 2
- %9 = OpTypeFunction %v2uint %v2uint
+ %15 = OpConstantNull %v2uint
%_ptr_Function_v2uint = OpTypePointer Function %v2uint
- %18 = OpConstantNull %v2uint
- %bool = OpTypeBool
- %v2bool = OpTypeVector %bool 2
- %uint_65535 = OpConstant %uint 65535
- %25 = OpConstantComposite %v2uint %uint_65535 %uint_65535
- %uint_16 = OpConstant %uint 16
- %28 = OpConstantComposite %v2uint %uint_16 %uint_16
- %uint_255 = OpConstant %uint 255
- %35 = OpConstantComposite %v2uint %uint_255 %uint_255
- %uint_8 = OpConstant %uint 8
- %38 = OpConstantComposite %v2uint %uint_8 %uint_8
- %uint_15 = OpConstant %uint 15
- %45 = OpConstantComposite %v2uint %uint_15 %uint_15
- %uint_4 = OpConstant %uint 4
- %48 = OpConstantComposite %v2uint %uint_4 %uint_4
- %uint_3 = OpConstant %uint 3
- %55 = OpConstantComposite %v2uint %uint_3 %uint_3
- %uint_2 = OpConstant %uint 2
- %58 = OpConstantComposite %v2uint %uint_2 %uint_2
- %uint_1 = OpConstant %uint 1
- %65 = OpConstantComposite %v2uint %uint_1 %uint_1
- %void = OpTypeVoid
- %76 = OpTypeFunction %void
- %82 = OpTypeFunction %v4float
+ %18 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
-%tint_count_trailing_zeros = OpFunction %v2uint None %9
- %v = OpFunctionParameter %v2uint
- %14 = OpLabel
- %x = OpVariable %_ptr_Function_v2uint Function %18
- OpStore %x %v
- %23 = OpLoad %v2uint %x
- %26 = OpBitwiseAnd %v2uint %23 %25
- %20 = OpINotEqual %v2bool %26 %18
- %19 = OpSelect %v2uint %20 %18 %28
- %29 = OpLoad %v2uint %x
- %30 = OpShiftRightLogical %v2uint %29 %19
- OpStore %x %30
- %33 = OpLoad %v2uint %x
- %36 = OpBitwiseAnd %v2uint %33 %35
- %32 = OpINotEqual %v2bool %36 %18
- %31 = OpSelect %v2uint %32 %18 %38
- %39 = OpLoad %v2uint %x
- %40 = OpShiftRightLogical %v2uint %39 %31
- OpStore %x %40
- %43 = OpLoad %v2uint %x
- %46 = OpBitwiseAnd %v2uint %43 %45
- %42 = OpINotEqual %v2bool %46 %18
- %41 = OpSelect %v2uint %42 %18 %48
- %49 = OpLoad %v2uint %x
- %50 = OpShiftRightLogical %v2uint %49 %41
- OpStore %x %50
- %53 = OpLoad %v2uint %x
- %56 = OpBitwiseAnd %v2uint %53 %55
- %52 = OpINotEqual %v2bool %56 %18
- %51 = OpSelect %v2uint %52 %18 %58
- %59 = OpLoad %v2uint %x
- %60 = OpShiftRightLogical %v2uint %59 %51
- OpStore %x %60
- %63 = OpLoad %v2uint %x
- %66 = OpBitwiseAnd %v2uint %63 %65
- %62 = OpINotEqual %v2bool %66 %18
- %61 = OpSelect %v2uint %62 %18 %65
- %68 = OpLoad %v2uint %x
- %69 = OpIEqual %v2bool %68 %18
- %67 = OpSelect %v2uint %69 %65 %18
- %71 = OpBitwiseOr %v2uint %19 %31
- %72 = OpBitwiseOr %v2uint %71 %41
- %73 = OpBitwiseOr %v2uint %72 %51
- %74 = OpBitwiseOr %v2uint %73 %61
- %75 = OpIAdd %v2uint %74 %67
- OpReturnValue %75
- OpFunctionEnd
-%countTrailingZeros_1ad138 = OpFunction %void None %76
- %79 = OpLabel
- %res = OpVariable %_ptr_Function_v2uint Function %18
- %80 = OpFunctionCall %v2uint %tint_count_trailing_zeros %65
- OpStore %res %80
+%countTrailingZeros_1ad138 = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_v2uint Function %15
+ OpStore %res %15
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %82
- %84 = OpLabel
- %85 = OpFunctionCall %void %countTrailingZeros_1ad138
+%vertex_main_inner = OpFunction %v4float None %18
+ %20 = OpLabel
+ %21 = OpFunctionCall %void %countTrailingZeros_1ad138
OpReturnValue %5
OpFunctionEnd
-%vertex_main = OpFunction %void None %76
- %87 = OpLabel
- %88 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %88
+%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 %76
- %91 = OpLabel
- %92 = OpFunctionCall %void %countTrailingZeros_1ad138
+%fragment_main = OpFunction %void None %9
+ %27 = OpLabel
+ %28 = OpFunctionCall %void %countTrailingZeros_1ad138
OpReturn
OpFunctionEnd
-%compute_main = OpFunction %void None %76
- %94 = OpLabel
- %95 = OpFunctionCall %void %countTrailingZeros_1ad138
+%compute_main = OpFunction %void None %9
+ %30 = OpLabel
+ %31 = OpFunctionCall %void %countTrailingZeros_1ad138
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/countTrailingZeros/1dc84a.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/countTrailingZeros/1dc84a.wgsl.expected.dxc.hlsl
index 2855d6d..327fef3 100644
--- a/test/tint/builtins/gen/literal/countTrailingZeros/1dc84a.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/countTrailingZeros/1dc84a.wgsl.expected.dxc.hlsl
@@ -1,20 +1,5 @@
-int4 tint_count_trailing_zeros(int4 v) {
- uint4 x = uint4(v);
- const uint4 b16 = (bool4((x & (65535u).xxxx)) ? (0u).xxxx : (16u).xxxx);
- x = (x >> b16);
- const uint4 b8 = (bool4((x & (255u).xxxx)) ? (0u).xxxx : (8u).xxxx);
- x = (x >> b8);
- const uint4 b4 = (bool4((x & (15u).xxxx)) ? (0u).xxxx : (4u).xxxx);
- x = (x >> b4);
- const uint4 b2 = (bool4((x & (3u).xxxx)) ? (0u).xxxx : (2u).xxxx);
- x = (x >> b2);
- const uint4 b1 = (bool4((x & (1u).xxxx)) ? (0u).xxxx : (1u).xxxx);
- const uint4 is_zero = ((x == (0u).xxxx) ? (1u).xxxx : (0u).xxxx);
- return int4((((((b16 | b8) | b4) | b2) | b1) + is_zero));
-}
-
void countTrailingZeros_1dc84a() {
- int4 res = tint_count_trailing_zeros((1).xxxx);
+ int4 res = (0).xxxx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/countTrailingZeros/1dc84a.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/countTrailingZeros/1dc84a.wgsl.expected.fxc.hlsl
index 2855d6d..327fef3 100644
--- a/test/tint/builtins/gen/literal/countTrailingZeros/1dc84a.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/countTrailingZeros/1dc84a.wgsl.expected.fxc.hlsl
@@ -1,20 +1,5 @@
-int4 tint_count_trailing_zeros(int4 v) {
- uint4 x = uint4(v);
- const uint4 b16 = (bool4((x & (65535u).xxxx)) ? (0u).xxxx : (16u).xxxx);
- x = (x >> b16);
- const uint4 b8 = (bool4((x & (255u).xxxx)) ? (0u).xxxx : (8u).xxxx);
- x = (x >> b8);
- const uint4 b4 = (bool4((x & (15u).xxxx)) ? (0u).xxxx : (4u).xxxx);
- x = (x >> b4);
- const uint4 b2 = (bool4((x & (3u).xxxx)) ? (0u).xxxx : (2u).xxxx);
- x = (x >> b2);
- const uint4 b1 = (bool4((x & (1u).xxxx)) ? (0u).xxxx : (1u).xxxx);
- const uint4 is_zero = ((x == (0u).xxxx) ? (1u).xxxx : (0u).xxxx);
- return int4((((((b16 | b8) | b4) | b2) | b1) + is_zero));
-}
-
void countTrailingZeros_1dc84a() {
- int4 res = tint_count_trailing_zeros((1).xxxx);
+ int4 res = (0).xxxx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/countTrailingZeros/1dc84a.wgsl.expected.glsl b/test/tint/builtins/gen/literal/countTrailingZeros/1dc84a.wgsl.expected.glsl
index 004dfe3..f29e7c4 100644
--- a/test/tint/builtins/gen/literal/countTrailingZeros/1dc84a.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/countTrailingZeros/1dc84a.wgsl.expected.glsl
@@ -1,22 +1,7 @@
#version 310 es
-ivec4 tint_count_trailing_zeros(ivec4 v) {
- uvec4 x = uvec4(v);
- uvec4 b16 = mix(uvec4(16u), uvec4(0u), bvec4((x & uvec4(65535u))));
- x = (x >> b16);
- uvec4 b8 = mix(uvec4(8u), uvec4(0u), bvec4((x & uvec4(255u))));
- x = (x >> b8);
- uvec4 b4 = mix(uvec4(4u), uvec4(0u), bvec4((x & uvec4(15u))));
- x = (x >> b4);
- uvec4 b2 = mix(uvec4(2u), uvec4(0u), bvec4((x & uvec4(3u))));
- x = (x >> b2);
- uvec4 b1 = mix(uvec4(1u), uvec4(0u), bvec4((x & uvec4(1u))));
- uvec4 is_zero = mix(uvec4(0u), uvec4(1u), equal(x, uvec4(0u)));
- return ivec4((((((b16 | b8) | b4) | b2) | b1) + is_zero));
-}
-
void countTrailingZeros_1dc84a() {
- ivec4 res = tint_count_trailing_zeros(ivec4(1));
+ ivec4 res = ivec4(0);
}
vec4 vertex_main() {
@@ -35,23 +20,8 @@
#version 310 es
precision mediump float;
-ivec4 tint_count_trailing_zeros(ivec4 v) {
- uvec4 x = uvec4(v);
- uvec4 b16 = mix(uvec4(16u), uvec4(0u), bvec4((x & uvec4(65535u))));
- x = (x >> b16);
- uvec4 b8 = mix(uvec4(8u), uvec4(0u), bvec4((x & uvec4(255u))));
- x = (x >> b8);
- uvec4 b4 = mix(uvec4(4u), uvec4(0u), bvec4((x & uvec4(15u))));
- x = (x >> b4);
- uvec4 b2 = mix(uvec4(2u), uvec4(0u), bvec4((x & uvec4(3u))));
- x = (x >> b2);
- uvec4 b1 = mix(uvec4(1u), uvec4(0u), bvec4((x & uvec4(1u))));
- uvec4 is_zero = mix(uvec4(0u), uvec4(1u), equal(x, uvec4(0u)));
- return ivec4((((((b16 | b8) | b4) | b2) | b1) + is_zero));
-}
-
void countTrailingZeros_1dc84a() {
- ivec4 res = tint_count_trailing_zeros(ivec4(1));
+ ivec4 res = ivec4(0);
}
void fragment_main() {
@@ -64,23 +34,8 @@
}
#version 310 es
-ivec4 tint_count_trailing_zeros(ivec4 v) {
- uvec4 x = uvec4(v);
- uvec4 b16 = mix(uvec4(16u), uvec4(0u), bvec4((x & uvec4(65535u))));
- x = (x >> b16);
- uvec4 b8 = mix(uvec4(8u), uvec4(0u), bvec4((x & uvec4(255u))));
- x = (x >> b8);
- uvec4 b4 = mix(uvec4(4u), uvec4(0u), bvec4((x & uvec4(15u))));
- x = (x >> b4);
- uvec4 b2 = mix(uvec4(2u), uvec4(0u), bvec4((x & uvec4(3u))));
- x = (x >> b2);
- uvec4 b1 = mix(uvec4(1u), uvec4(0u), bvec4((x & uvec4(1u))));
- uvec4 is_zero = mix(uvec4(0u), uvec4(1u), equal(x, uvec4(0u)));
- return ivec4((((((b16 | b8) | b4) | b2) | b1) + is_zero));
-}
-
void countTrailingZeros_1dc84a() {
- ivec4 res = tint_count_trailing_zeros(ivec4(1));
+ ivec4 res = ivec4(0);
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/countTrailingZeros/1dc84a.wgsl.expected.msl b/test/tint/builtins/gen/literal/countTrailingZeros/1dc84a.wgsl.expected.msl
index 216718b..dcf6b8a 100644
--- a/test/tint/builtins/gen/literal/countTrailingZeros/1dc84a.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/countTrailingZeros/1dc84a.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void countTrailingZeros_1dc84a() {
- int4 res = ctz(int4(1));
+ int4 res = int4(0);
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/countTrailingZeros/1dc84a.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/countTrailingZeros/1dc84a.wgsl.expected.spvasm
index 85d0c58..f20dbd4 100644
--- a/test/tint/builtins/gen/literal/countTrailingZeros/1dc84a.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/countTrailingZeros/1dc84a.wgsl.expected.spvasm
@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 102
+; 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_trailing_zeros "tint_count_trailing_zeros"
- OpName %v "v"
- OpName %x "x"
OpName %countTrailingZeros_1dc84a "countTrailingZeros_1dc84a"
OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner"
@@ -31,116 +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
%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
- %bool = OpTypeBool
- %v4bool = OpTypeVector %bool 4
- %uint_65535 = OpConstant %uint 65535
- %27 = OpConstantComposite %v4uint %uint_65535 %uint_65535 %uint_65535 %uint_65535
- %uint_16 = OpConstant %uint 16
- %30 = OpConstantComposite %v4uint %uint_16 %uint_16 %uint_16 %uint_16
- %uint_255 = OpConstant %uint 255
- %37 = OpConstantComposite %v4uint %uint_255 %uint_255 %uint_255 %uint_255
- %uint_8 = OpConstant %uint 8
- %40 = OpConstantComposite %v4uint %uint_8 %uint_8 %uint_8 %uint_8
- %uint_15 = OpConstant %uint 15
- %47 = OpConstantComposite %v4uint %uint_15 %uint_15 %uint_15 %uint_15
- %uint_4 = OpConstant %uint 4
- %50 = OpConstantComposite %v4uint %uint_4 %uint_4 %uint_4 %uint_4
- %uint_3 = OpConstant %uint 3
- %57 = OpConstantComposite %v4uint %uint_3 %uint_3 %uint_3 %uint_3
- %uint_2 = OpConstant %uint 2
- %60 = OpConstantComposite %v4uint %uint_2 %uint_2 %uint_2 %uint_2
- %uint_1 = OpConstant %uint 1
- %67 = OpConstantComposite %v4uint %uint_1 %uint_1 %uint_1 %uint_1
- %void = OpTypeVoid
- %78 = OpTypeFunction %void
- %int_1 = OpConstant %int 1
- %84 = OpConstantComposite %v4int %int_1 %int_1 %int_1 %int_1
+ %15 = OpConstantNull %v4int
%_ptr_Function_v4int = OpTypePointer Function %v4int
- %87 = OpConstantNull %v4int
- %88 = OpTypeFunction %v4float
+ %18 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
-%tint_count_trailing_zeros = OpFunction %v4int None %9
- %v = OpFunctionParameter %v4int
- %14 = OpLabel
- %x = OpVariable %_ptr_Function_v4uint Function %20
- %15 = OpBitcast %v4uint %v
- OpStore %x %15
- %25 = OpLoad %v4uint %x
- %28 = OpBitwiseAnd %v4uint %25 %27
- %22 = OpINotEqual %v4bool %28 %20
- %21 = OpSelect %v4uint %22 %20 %30
- %31 = OpLoad %v4uint %x
- %32 = OpShiftRightLogical %v4uint %31 %21
- OpStore %x %32
- %35 = OpLoad %v4uint %x
- %38 = OpBitwiseAnd %v4uint %35 %37
- %34 = OpINotEqual %v4bool %38 %20
- %33 = OpSelect %v4uint %34 %20 %40
- %41 = OpLoad %v4uint %x
- %42 = OpShiftRightLogical %v4uint %41 %33
- OpStore %x %42
- %45 = OpLoad %v4uint %x
- %48 = OpBitwiseAnd %v4uint %45 %47
- %44 = OpINotEqual %v4bool %48 %20
- %43 = OpSelect %v4uint %44 %20 %50
- %51 = OpLoad %v4uint %x
- %52 = OpShiftRightLogical %v4uint %51 %43
- OpStore %x %52
- %55 = OpLoad %v4uint %x
- %58 = OpBitwiseAnd %v4uint %55 %57
- %54 = OpINotEqual %v4bool %58 %20
- %53 = OpSelect %v4uint %54 %20 %60
- %61 = OpLoad %v4uint %x
- %62 = OpShiftRightLogical %v4uint %61 %53
- OpStore %x %62
- %65 = OpLoad %v4uint %x
- %68 = OpBitwiseAnd %v4uint %65 %67
- %64 = OpINotEqual %v4bool %68 %20
- %63 = OpSelect %v4uint %64 %20 %67
- %70 = OpLoad %v4uint %x
- %71 = OpIEqual %v4bool %70 %20
- %69 = OpSelect %v4uint %71 %67 %20
- %73 = OpBitwiseOr %v4uint %21 %33
- %74 = OpBitwiseOr %v4uint %73 %43
- %75 = OpBitwiseOr %v4uint %74 %53
- %76 = OpBitwiseOr %v4uint %75 %63
- %77 = OpIAdd %v4uint %76 %69
- %72 = OpBitcast %v4int %77
- OpReturnValue %72
- OpFunctionEnd
-%countTrailingZeros_1dc84a = OpFunction %void None %78
- %81 = OpLabel
- %res = OpVariable %_ptr_Function_v4int Function %87
- %82 = OpFunctionCall %v4int %tint_count_trailing_zeros %84
- OpStore %res %82
+%countTrailingZeros_1dc84a = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_v4int Function %15
+ OpStore %res %15
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %88
- %90 = OpLabel
- %91 = OpFunctionCall %void %countTrailingZeros_1dc84a
+%vertex_main_inner = OpFunction %v4float None %18
+ %20 = OpLabel
+ %21 = OpFunctionCall %void %countTrailingZeros_1dc84a
OpReturnValue %5
OpFunctionEnd
-%vertex_main = OpFunction %void None %78
- %93 = OpLabel
- %94 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %94
+%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 %78
- %97 = OpLabel
- %98 = OpFunctionCall %void %countTrailingZeros_1dc84a
+%fragment_main = OpFunction %void None %9
+ %27 = OpLabel
+ %28 = OpFunctionCall %void %countTrailingZeros_1dc84a
OpReturn
OpFunctionEnd
-%compute_main = OpFunction %void None %78
- %100 = OpLabel
- %101 = OpFunctionCall %void %countTrailingZeros_1dc84a
+%compute_main = OpFunction %void None %9
+ %30 = OpLabel
+ %31 = OpFunctionCall %void %countTrailingZeros_1dc84a
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/countTrailingZeros/21e394.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/countTrailingZeros/21e394.wgsl.expected.dxc.hlsl
index edace49..2399db9 100644
--- a/test/tint/builtins/gen/literal/countTrailingZeros/21e394.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/countTrailingZeros/21e394.wgsl.expected.dxc.hlsl
@@ -1,20 +1,5 @@
-uint tint_count_trailing_zeros(uint v) {
- uint x = uint(v);
- const uint b16 = (bool((x & 65535u)) ? 0u : 16u);
- x = (x >> b16);
- const uint b8 = (bool((x & 255u)) ? 0u : 8u);
- x = (x >> b8);
- const uint b4 = (bool((x & 15u)) ? 0u : 4u);
- x = (x >> b4);
- const uint b2 = (bool((x & 3u)) ? 0u : 2u);
- x = (x >> b2);
- const uint b1 = (bool((x & 1u)) ? 0u : 1u);
- const uint is_zero = ((x == 0u) ? 1u : 0u);
- return uint((((((b16 | b8) | b4) | b2) | b1) + is_zero));
-}
-
void countTrailingZeros_21e394() {
- uint res = tint_count_trailing_zeros(1u);
+ uint res = 0u;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/countTrailingZeros/21e394.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/countTrailingZeros/21e394.wgsl.expected.fxc.hlsl
index edace49..2399db9 100644
--- a/test/tint/builtins/gen/literal/countTrailingZeros/21e394.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/countTrailingZeros/21e394.wgsl.expected.fxc.hlsl
@@ -1,20 +1,5 @@
-uint tint_count_trailing_zeros(uint v) {
- uint x = uint(v);
- const uint b16 = (bool((x & 65535u)) ? 0u : 16u);
- x = (x >> b16);
- const uint b8 = (bool((x & 255u)) ? 0u : 8u);
- x = (x >> b8);
- const uint b4 = (bool((x & 15u)) ? 0u : 4u);
- x = (x >> b4);
- const uint b2 = (bool((x & 3u)) ? 0u : 2u);
- x = (x >> b2);
- const uint b1 = (bool((x & 1u)) ? 0u : 1u);
- const uint is_zero = ((x == 0u) ? 1u : 0u);
- return uint((((((b16 | b8) | b4) | b2) | b1) + is_zero));
-}
-
void countTrailingZeros_21e394() {
- uint res = tint_count_trailing_zeros(1u);
+ uint res = 0u;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/countTrailingZeros/21e394.wgsl.expected.glsl b/test/tint/builtins/gen/literal/countTrailingZeros/21e394.wgsl.expected.glsl
index 48ead3c..4d74fa0 100644
--- a/test/tint/builtins/gen/literal/countTrailingZeros/21e394.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/countTrailingZeros/21e394.wgsl.expected.glsl
@@ -1,22 +1,7 @@
#version 310 es
-uint tint_count_trailing_zeros(uint v) {
- uint x = uint(v);
- uint b16 = (bool((x & 65535u)) ? 0u : 16u);
- x = (x >> b16);
- uint b8 = (bool((x & 255u)) ? 0u : 8u);
- x = (x >> b8);
- uint b4 = (bool((x & 15u)) ? 0u : 4u);
- x = (x >> b4);
- uint b2 = (bool((x & 3u)) ? 0u : 2u);
- x = (x >> b2);
- uint b1 = (bool((x & 1u)) ? 0u : 1u);
- uint is_zero = ((x == 0u) ? 1u : 0u);
- return uint((((((b16 | b8) | b4) | b2) | b1) + is_zero));
-}
-
void countTrailingZeros_21e394() {
- uint res = tint_count_trailing_zeros(1u);
+ uint res = 0u;
}
vec4 vertex_main() {
@@ -35,23 +20,8 @@
#version 310 es
precision mediump float;
-uint tint_count_trailing_zeros(uint v) {
- uint x = uint(v);
- uint b16 = (bool((x & 65535u)) ? 0u : 16u);
- x = (x >> b16);
- uint b8 = (bool((x & 255u)) ? 0u : 8u);
- x = (x >> b8);
- uint b4 = (bool((x & 15u)) ? 0u : 4u);
- x = (x >> b4);
- uint b2 = (bool((x & 3u)) ? 0u : 2u);
- x = (x >> b2);
- uint b1 = (bool((x & 1u)) ? 0u : 1u);
- uint is_zero = ((x == 0u) ? 1u : 0u);
- return uint((((((b16 | b8) | b4) | b2) | b1) + is_zero));
-}
-
void countTrailingZeros_21e394() {
- uint res = tint_count_trailing_zeros(1u);
+ uint res = 0u;
}
void fragment_main() {
@@ -64,23 +34,8 @@
}
#version 310 es
-uint tint_count_trailing_zeros(uint v) {
- uint x = uint(v);
- uint b16 = (bool((x & 65535u)) ? 0u : 16u);
- x = (x >> b16);
- uint b8 = (bool((x & 255u)) ? 0u : 8u);
- x = (x >> b8);
- uint b4 = (bool((x & 15u)) ? 0u : 4u);
- x = (x >> b4);
- uint b2 = (bool((x & 3u)) ? 0u : 2u);
- x = (x >> b2);
- uint b1 = (bool((x & 1u)) ? 0u : 1u);
- uint is_zero = ((x == 0u) ? 1u : 0u);
- return uint((((((b16 | b8) | b4) | b2) | b1) + is_zero));
-}
-
void countTrailingZeros_21e394() {
- uint res = tint_count_trailing_zeros(1u);
+ uint res = 0u;
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/countTrailingZeros/21e394.wgsl.expected.msl b/test/tint/builtins/gen/literal/countTrailingZeros/21e394.wgsl.expected.msl
index e403208..d3eb2a9 100644
--- a/test/tint/builtins/gen/literal/countTrailingZeros/21e394.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/countTrailingZeros/21e394.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void countTrailingZeros_21e394() {
- uint res = ctz(1u);
+ uint res = 0u;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/countTrailingZeros/21e394.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/countTrailingZeros/21e394.wgsl.expected.spvasm
index 4d07aef..f3035a2 100644
--- a/test/tint/builtins/gen/literal/countTrailingZeros/21e394.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/countTrailingZeros/21e394.wgsl.expected.spvasm
@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 85
+; Bound: 31
; 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_trailing_zeros "tint_count_trailing_zeros"
- OpName %v "v"
- OpName %x "x"
OpName %countTrailingZeros_21e394 "countTrailingZeros_21e394"
OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner"
@@ -31,97 +28,38 @@
%_ptr_Output_float = OpTypePointer Output %float
%8 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
- %uint = OpTypeInt 32 0
- %9 = OpTypeFunction %uint %uint
-%_ptr_Function_uint = OpTypePointer Function %uint
- %17 = OpConstantNull %uint
- %bool = OpTypeBool
- %uint_65535 = OpConstant %uint 65535
- %uint_16 = OpConstant %uint 16
- %uint_255 = OpConstant %uint 255
- %uint_8 = OpConstant %uint 8
- %uint_15 = OpConstant %uint 15
- %uint_4 = OpConstant %uint 4
- %uint_3 = OpConstant %uint 3
- %uint_2 = OpConstant %uint 2
- %uint_1 = OpConstant %uint 1
%void = OpTypeVoid
- %65 = OpTypeFunction %void
- %71 = OpTypeFunction %v4float
+ %9 = OpTypeFunction %void
+ %uint = OpTypeInt 32 0
+ %14 = OpConstantNull %uint
+%_ptr_Function_uint = OpTypePointer Function %uint
+ %17 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
-%tint_count_trailing_zeros = OpFunction %uint None %9
- %v = OpFunctionParameter %uint
- %13 = OpLabel
- %x = OpVariable %_ptr_Function_uint Function %17
- OpStore %x %v
- %21 = OpLoad %uint %x
- %23 = OpBitwiseAnd %uint %21 %uint_65535
- %19 = OpINotEqual %bool %23 %17
- %18 = OpSelect %uint %19 %17 %uint_16
- %25 = OpLoad %uint %x
- %26 = OpShiftRightLogical %uint %25 %18
- OpStore %x %26
- %29 = OpLoad %uint %x
- %31 = OpBitwiseAnd %uint %29 %uint_255
- %28 = OpINotEqual %bool %31 %17
- %27 = OpSelect %uint %28 %17 %uint_8
- %33 = OpLoad %uint %x
- %34 = OpShiftRightLogical %uint %33 %27
- OpStore %x %34
- %37 = OpLoad %uint %x
- %39 = OpBitwiseAnd %uint %37 %uint_15
- %36 = OpINotEqual %bool %39 %17
- %35 = OpSelect %uint %36 %17 %uint_4
- %41 = OpLoad %uint %x
- %42 = OpShiftRightLogical %uint %41 %35
- OpStore %x %42
- %45 = OpLoad %uint %x
- %47 = OpBitwiseAnd %uint %45 %uint_3
- %44 = OpINotEqual %bool %47 %17
- %43 = OpSelect %uint %44 %17 %uint_2
- %49 = OpLoad %uint %x
- %50 = OpShiftRightLogical %uint %49 %43
- OpStore %x %50
- %53 = OpLoad %uint %x
- %55 = OpBitwiseAnd %uint %53 %uint_1
- %52 = OpINotEqual %bool %55 %17
- %51 = OpSelect %uint %52 %17 %uint_1
- %57 = OpLoad %uint %x
- %58 = OpIEqual %bool %57 %17
- %56 = OpSelect %uint %58 %uint_1 %17
- %60 = OpBitwiseOr %uint %18 %27
- %61 = OpBitwiseOr %uint %60 %35
- %62 = OpBitwiseOr %uint %61 %43
- %63 = OpBitwiseOr %uint %62 %51
- %64 = OpIAdd %uint %63 %56
- OpReturnValue %64
- OpFunctionEnd
-%countTrailingZeros_21e394 = OpFunction %void None %65
- %68 = OpLabel
- %res = OpVariable %_ptr_Function_uint Function %17
- %69 = OpFunctionCall %uint %tint_count_trailing_zeros %uint_1
- OpStore %res %69
+%countTrailingZeros_21e394 = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_uint Function %14
+ OpStore %res %14
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %71
- %73 = OpLabel
- %74 = OpFunctionCall %void %countTrailingZeros_21e394
+%vertex_main_inner = OpFunction %v4float None %17
+ %19 = OpLabel
+ %20 = OpFunctionCall %void %countTrailingZeros_21e394
OpReturnValue %5
OpFunctionEnd
-%vertex_main = OpFunction %void None %65
- %76 = OpLabel
- %77 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %77
+%vertex_main = OpFunction %void None %9
+ %22 = OpLabel
+ %23 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %23
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
-%fragment_main = OpFunction %void None %65
- %80 = OpLabel
- %81 = OpFunctionCall %void %countTrailingZeros_21e394
+%fragment_main = OpFunction %void None %9
+ %26 = OpLabel
+ %27 = OpFunctionCall %void %countTrailingZeros_21e394
OpReturn
OpFunctionEnd
-%compute_main = OpFunction %void None %65
- %83 = OpLabel
- %84 = OpFunctionCall %void %countTrailingZeros_21e394
+%compute_main = OpFunction %void None %9
+ %29 = OpLabel
+ %30 = OpFunctionCall %void %countTrailingZeros_21e394
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/countTrailingZeros/327c37.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/countTrailingZeros/327c37.wgsl.expected.dxc.hlsl
index a63a846..c42b308 100644
--- a/test/tint/builtins/gen/literal/countTrailingZeros/327c37.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/countTrailingZeros/327c37.wgsl.expected.dxc.hlsl
@@ -1,20 +1,5 @@
-int2 tint_count_trailing_zeros(int2 v) {
- uint2 x = uint2(v);
- const uint2 b16 = (bool2((x & (65535u).xx)) ? (0u).xx : (16u).xx);
- x = (x >> b16);
- const uint2 b8 = (bool2((x & (255u).xx)) ? (0u).xx : (8u).xx);
- x = (x >> b8);
- const uint2 b4 = (bool2((x & (15u).xx)) ? (0u).xx : (4u).xx);
- x = (x >> b4);
- const uint2 b2 = (bool2((x & (3u).xx)) ? (0u).xx : (2u).xx);
- x = (x >> b2);
- const uint2 b1 = (bool2((x & (1u).xx)) ? (0u).xx : (1u).xx);
- const uint2 is_zero = ((x == (0u).xx) ? (1u).xx : (0u).xx);
- return int2((((((b16 | b8) | b4) | b2) | b1) + is_zero));
-}
-
void countTrailingZeros_327c37() {
- int2 res = tint_count_trailing_zeros((1).xx);
+ int2 res = (0).xx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/countTrailingZeros/327c37.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/countTrailingZeros/327c37.wgsl.expected.fxc.hlsl
index a63a846..c42b308 100644
--- a/test/tint/builtins/gen/literal/countTrailingZeros/327c37.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/countTrailingZeros/327c37.wgsl.expected.fxc.hlsl
@@ -1,20 +1,5 @@
-int2 tint_count_trailing_zeros(int2 v) {
- uint2 x = uint2(v);
- const uint2 b16 = (bool2((x & (65535u).xx)) ? (0u).xx : (16u).xx);
- x = (x >> b16);
- const uint2 b8 = (bool2((x & (255u).xx)) ? (0u).xx : (8u).xx);
- x = (x >> b8);
- const uint2 b4 = (bool2((x & (15u).xx)) ? (0u).xx : (4u).xx);
- x = (x >> b4);
- const uint2 b2 = (bool2((x & (3u).xx)) ? (0u).xx : (2u).xx);
- x = (x >> b2);
- const uint2 b1 = (bool2((x & (1u).xx)) ? (0u).xx : (1u).xx);
- const uint2 is_zero = ((x == (0u).xx) ? (1u).xx : (0u).xx);
- return int2((((((b16 | b8) | b4) | b2) | b1) + is_zero));
-}
-
void countTrailingZeros_327c37() {
- int2 res = tint_count_trailing_zeros((1).xx);
+ int2 res = (0).xx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/countTrailingZeros/327c37.wgsl.expected.glsl b/test/tint/builtins/gen/literal/countTrailingZeros/327c37.wgsl.expected.glsl
index b321de8..0a5c509 100644
--- a/test/tint/builtins/gen/literal/countTrailingZeros/327c37.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/countTrailingZeros/327c37.wgsl.expected.glsl
@@ -1,22 +1,7 @@
#version 310 es
-ivec2 tint_count_trailing_zeros(ivec2 v) {
- uvec2 x = uvec2(v);
- uvec2 b16 = mix(uvec2(16u), uvec2(0u), bvec2((x & uvec2(65535u))));
- x = (x >> b16);
- uvec2 b8 = mix(uvec2(8u), uvec2(0u), bvec2((x & uvec2(255u))));
- x = (x >> b8);
- uvec2 b4 = mix(uvec2(4u), uvec2(0u), bvec2((x & uvec2(15u))));
- x = (x >> b4);
- uvec2 b2 = mix(uvec2(2u), uvec2(0u), bvec2((x & uvec2(3u))));
- x = (x >> b2);
- uvec2 b1 = mix(uvec2(1u), uvec2(0u), bvec2((x & uvec2(1u))));
- uvec2 is_zero = mix(uvec2(0u), uvec2(1u), equal(x, uvec2(0u)));
- return ivec2((((((b16 | b8) | b4) | b2) | b1) + is_zero));
-}
-
void countTrailingZeros_327c37() {
- ivec2 res = tint_count_trailing_zeros(ivec2(1));
+ ivec2 res = ivec2(0);
}
vec4 vertex_main() {
@@ -35,23 +20,8 @@
#version 310 es
precision mediump float;
-ivec2 tint_count_trailing_zeros(ivec2 v) {
- uvec2 x = uvec2(v);
- uvec2 b16 = mix(uvec2(16u), uvec2(0u), bvec2((x & uvec2(65535u))));
- x = (x >> b16);
- uvec2 b8 = mix(uvec2(8u), uvec2(0u), bvec2((x & uvec2(255u))));
- x = (x >> b8);
- uvec2 b4 = mix(uvec2(4u), uvec2(0u), bvec2((x & uvec2(15u))));
- x = (x >> b4);
- uvec2 b2 = mix(uvec2(2u), uvec2(0u), bvec2((x & uvec2(3u))));
- x = (x >> b2);
- uvec2 b1 = mix(uvec2(1u), uvec2(0u), bvec2((x & uvec2(1u))));
- uvec2 is_zero = mix(uvec2(0u), uvec2(1u), equal(x, uvec2(0u)));
- return ivec2((((((b16 | b8) | b4) | b2) | b1) + is_zero));
-}
-
void countTrailingZeros_327c37() {
- ivec2 res = tint_count_trailing_zeros(ivec2(1));
+ ivec2 res = ivec2(0);
}
void fragment_main() {
@@ -64,23 +34,8 @@
}
#version 310 es
-ivec2 tint_count_trailing_zeros(ivec2 v) {
- uvec2 x = uvec2(v);
- uvec2 b16 = mix(uvec2(16u), uvec2(0u), bvec2((x & uvec2(65535u))));
- x = (x >> b16);
- uvec2 b8 = mix(uvec2(8u), uvec2(0u), bvec2((x & uvec2(255u))));
- x = (x >> b8);
- uvec2 b4 = mix(uvec2(4u), uvec2(0u), bvec2((x & uvec2(15u))));
- x = (x >> b4);
- uvec2 b2 = mix(uvec2(2u), uvec2(0u), bvec2((x & uvec2(3u))));
- x = (x >> b2);
- uvec2 b1 = mix(uvec2(1u), uvec2(0u), bvec2((x & uvec2(1u))));
- uvec2 is_zero = mix(uvec2(0u), uvec2(1u), equal(x, uvec2(0u)));
- return ivec2((((((b16 | b8) | b4) | b2) | b1) + is_zero));
-}
-
void countTrailingZeros_327c37() {
- ivec2 res = tint_count_trailing_zeros(ivec2(1));
+ ivec2 res = ivec2(0);
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/countTrailingZeros/327c37.wgsl.expected.msl b/test/tint/builtins/gen/literal/countTrailingZeros/327c37.wgsl.expected.msl
index c0e1ed6..b4039fb 100644
--- a/test/tint/builtins/gen/literal/countTrailingZeros/327c37.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/countTrailingZeros/327c37.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void countTrailingZeros_327c37() {
- int2 res = ctz(int2(1));
+ int2 res = int2(0);
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/countTrailingZeros/327c37.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/countTrailingZeros/327c37.wgsl.expected.spvasm
index 456ba27..24a157c 100644
--- a/test/tint/builtins/gen/literal/countTrailingZeros/327c37.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/countTrailingZeros/327c37.wgsl.expected.spvasm
@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 102
+; 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_trailing_zeros "tint_count_trailing_zeros"
- OpName %v "v"
- OpName %x "x"
OpName %countTrailingZeros_327c37 "countTrailingZeros_327c37"
OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner"
@@ -31,116 +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
%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
- %bool = OpTypeBool
- %v2bool = OpTypeVector %bool 2
- %uint_65535 = OpConstant %uint 65535
- %27 = OpConstantComposite %v2uint %uint_65535 %uint_65535
- %uint_16 = OpConstant %uint 16
- %30 = OpConstantComposite %v2uint %uint_16 %uint_16
- %uint_255 = OpConstant %uint 255
- %37 = OpConstantComposite %v2uint %uint_255 %uint_255
- %uint_8 = OpConstant %uint 8
- %40 = OpConstantComposite %v2uint %uint_8 %uint_8
- %uint_15 = OpConstant %uint 15
- %47 = OpConstantComposite %v2uint %uint_15 %uint_15
- %uint_4 = OpConstant %uint 4
- %50 = OpConstantComposite %v2uint %uint_4 %uint_4
- %uint_3 = OpConstant %uint 3
- %57 = OpConstantComposite %v2uint %uint_3 %uint_3
- %uint_2 = OpConstant %uint 2
- %60 = OpConstantComposite %v2uint %uint_2 %uint_2
- %uint_1 = OpConstant %uint 1
- %67 = OpConstantComposite %v2uint %uint_1 %uint_1
- %void = OpTypeVoid
- %78 = OpTypeFunction %void
- %int_1 = OpConstant %int 1
- %84 = OpConstantComposite %v2int %int_1 %int_1
+ %15 = OpConstantNull %v2int
%_ptr_Function_v2int = OpTypePointer Function %v2int
- %87 = OpConstantNull %v2int
- %88 = OpTypeFunction %v4float
+ %18 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
-%tint_count_trailing_zeros = OpFunction %v2int None %9
- %v = OpFunctionParameter %v2int
- %14 = OpLabel
- %x = OpVariable %_ptr_Function_v2uint Function %20
- %15 = OpBitcast %v2uint %v
- OpStore %x %15
- %25 = OpLoad %v2uint %x
- %28 = OpBitwiseAnd %v2uint %25 %27
- %22 = OpINotEqual %v2bool %28 %20
- %21 = OpSelect %v2uint %22 %20 %30
- %31 = OpLoad %v2uint %x
- %32 = OpShiftRightLogical %v2uint %31 %21
- OpStore %x %32
- %35 = OpLoad %v2uint %x
- %38 = OpBitwiseAnd %v2uint %35 %37
- %34 = OpINotEqual %v2bool %38 %20
- %33 = OpSelect %v2uint %34 %20 %40
- %41 = OpLoad %v2uint %x
- %42 = OpShiftRightLogical %v2uint %41 %33
- OpStore %x %42
- %45 = OpLoad %v2uint %x
- %48 = OpBitwiseAnd %v2uint %45 %47
- %44 = OpINotEqual %v2bool %48 %20
- %43 = OpSelect %v2uint %44 %20 %50
- %51 = OpLoad %v2uint %x
- %52 = OpShiftRightLogical %v2uint %51 %43
- OpStore %x %52
- %55 = OpLoad %v2uint %x
- %58 = OpBitwiseAnd %v2uint %55 %57
- %54 = OpINotEqual %v2bool %58 %20
- %53 = OpSelect %v2uint %54 %20 %60
- %61 = OpLoad %v2uint %x
- %62 = OpShiftRightLogical %v2uint %61 %53
- OpStore %x %62
- %65 = OpLoad %v2uint %x
- %68 = OpBitwiseAnd %v2uint %65 %67
- %64 = OpINotEqual %v2bool %68 %20
- %63 = OpSelect %v2uint %64 %20 %67
- %70 = OpLoad %v2uint %x
- %71 = OpIEqual %v2bool %70 %20
- %69 = OpSelect %v2uint %71 %67 %20
- %73 = OpBitwiseOr %v2uint %21 %33
- %74 = OpBitwiseOr %v2uint %73 %43
- %75 = OpBitwiseOr %v2uint %74 %53
- %76 = OpBitwiseOr %v2uint %75 %63
- %77 = OpIAdd %v2uint %76 %69
- %72 = OpBitcast %v2int %77
- OpReturnValue %72
- OpFunctionEnd
-%countTrailingZeros_327c37 = OpFunction %void None %78
- %81 = OpLabel
- %res = OpVariable %_ptr_Function_v2int Function %87
- %82 = OpFunctionCall %v2int %tint_count_trailing_zeros %84
- OpStore %res %82
+%countTrailingZeros_327c37 = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_v2int Function %15
+ OpStore %res %15
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %88
- %90 = OpLabel
- %91 = OpFunctionCall %void %countTrailingZeros_327c37
+%vertex_main_inner = OpFunction %v4float None %18
+ %20 = OpLabel
+ %21 = OpFunctionCall %void %countTrailingZeros_327c37
OpReturnValue %5
OpFunctionEnd
-%vertex_main = OpFunction %void None %78
- %93 = OpLabel
- %94 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %94
+%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 %78
- %97 = OpLabel
- %98 = OpFunctionCall %void %countTrailingZeros_327c37
+%fragment_main = OpFunction %void None %9
+ %27 = OpLabel
+ %28 = OpFunctionCall %void %countTrailingZeros_327c37
OpReturn
OpFunctionEnd
-%compute_main = OpFunction %void None %78
- %100 = OpLabel
- %101 = OpFunctionCall %void %countTrailingZeros_327c37
+%compute_main = OpFunction %void None %9
+ %30 = OpLabel
+ %31 = OpFunctionCall %void %countTrailingZeros_327c37
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/countTrailingZeros/42fed6.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/countTrailingZeros/42fed6.wgsl.expected.dxc.hlsl
index b5eacaa..795a698 100644
--- a/test/tint/builtins/gen/literal/countTrailingZeros/42fed6.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/countTrailingZeros/42fed6.wgsl.expected.dxc.hlsl
@@ -1,20 +1,5 @@
-int tint_count_trailing_zeros(int v) {
- uint x = uint(v);
- const uint b16 = (bool((x & 65535u)) ? 0u : 16u);
- x = (x >> b16);
- const uint b8 = (bool((x & 255u)) ? 0u : 8u);
- x = (x >> b8);
- const uint b4 = (bool((x & 15u)) ? 0u : 4u);
- x = (x >> b4);
- const uint b2 = (bool((x & 3u)) ? 0u : 2u);
- x = (x >> b2);
- const uint b1 = (bool((x & 1u)) ? 0u : 1u);
- const uint is_zero = ((x == 0u) ? 1u : 0u);
- return int((((((b16 | b8) | b4) | b2) | b1) + is_zero));
-}
-
void countTrailingZeros_42fed6() {
- int res = tint_count_trailing_zeros(1);
+ int res = 0;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/countTrailingZeros/42fed6.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/countTrailingZeros/42fed6.wgsl.expected.fxc.hlsl
index b5eacaa..795a698 100644
--- a/test/tint/builtins/gen/literal/countTrailingZeros/42fed6.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/countTrailingZeros/42fed6.wgsl.expected.fxc.hlsl
@@ -1,20 +1,5 @@
-int tint_count_trailing_zeros(int v) {
- uint x = uint(v);
- const uint b16 = (bool((x & 65535u)) ? 0u : 16u);
- x = (x >> b16);
- const uint b8 = (bool((x & 255u)) ? 0u : 8u);
- x = (x >> b8);
- const uint b4 = (bool((x & 15u)) ? 0u : 4u);
- x = (x >> b4);
- const uint b2 = (bool((x & 3u)) ? 0u : 2u);
- x = (x >> b2);
- const uint b1 = (bool((x & 1u)) ? 0u : 1u);
- const uint is_zero = ((x == 0u) ? 1u : 0u);
- return int((((((b16 | b8) | b4) | b2) | b1) + is_zero));
-}
-
void countTrailingZeros_42fed6() {
- int res = tint_count_trailing_zeros(1);
+ int res = 0;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/countTrailingZeros/42fed6.wgsl.expected.glsl b/test/tint/builtins/gen/literal/countTrailingZeros/42fed6.wgsl.expected.glsl
index 79ef865..38fc48c 100644
--- a/test/tint/builtins/gen/literal/countTrailingZeros/42fed6.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/countTrailingZeros/42fed6.wgsl.expected.glsl
@@ -1,22 +1,7 @@
#version 310 es
-int tint_count_trailing_zeros(int v) {
- uint x = uint(v);
- uint b16 = (bool((x & 65535u)) ? 0u : 16u);
- x = (x >> b16);
- uint b8 = (bool((x & 255u)) ? 0u : 8u);
- x = (x >> b8);
- uint b4 = (bool((x & 15u)) ? 0u : 4u);
- x = (x >> b4);
- uint b2 = (bool((x & 3u)) ? 0u : 2u);
- x = (x >> b2);
- uint b1 = (bool((x & 1u)) ? 0u : 1u);
- uint is_zero = ((x == 0u) ? 1u : 0u);
- return int((((((b16 | b8) | b4) | b2) | b1) + is_zero));
-}
-
void countTrailingZeros_42fed6() {
- int res = tint_count_trailing_zeros(1);
+ int res = 0;
}
vec4 vertex_main() {
@@ -35,23 +20,8 @@
#version 310 es
precision mediump float;
-int tint_count_trailing_zeros(int v) {
- uint x = uint(v);
- uint b16 = (bool((x & 65535u)) ? 0u : 16u);
- x = (x >> b16);
- uint b8 = (bool((x & 255u)) ? 0u : 8u);
- x = (x >> b8);
- uint b4 = (bool((x & 15u)) ? 0u : 4u);
- x = (x >> b4);
- uint b2 = (bool((x & 3u)) ? 0u : 2u);
- x = (x >> b2);
- uint b1 = (bool((x & 1u)) ? 0u : 1u);
- uint is_zero = ((x == 0u) ? 1u : 0u);
- return int((((((b16 | b8) | b4) | b2) | b1) + is_zero));
-}
-
void countTrailingZeros_42fed6() {
- int res = tint_count_trailing_zeros(1);
+ int res = 0;
}
void fragment_main() {
@@ -64,23 +34,8 @@
}
#version 310 es
-int tint_count_trailing_zeros(int v) {
- uint x = uint(v);
- uint b16 = (bool((x & 65535u)) ? 0u : 16u);
- x = (x >> b16);
- uint b8 = (bool((x & 255u)) ? 0u : 8u);
- x = (x >> b8);
- uint b4 = (bool((x & 15u)) ? 0u : 4u);
- x = (x >> b4);
- uint b2 = (bool((x & 3u)) ? 0u : 2u);
- x = (x >> b2);
- uint b1 = (bool((x & 1u)) ? 0u : 1u);
- uint is_zero = ((x == 0u) ? 1u : 0u);
- return int((((((b16 | b8) | b4) | b2) | b1) + is_zero));
-}
-
void countTrailingZeros_42fed6() {
- int res = tint_count_trailing_zeros(1);
+ int res = 0;
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/countTrailingZeros/42fed6.wgsl.expected.msl b/test/tint/builtins/gen/literal/countTrailingZeros/42fed6.wgsl.expected.msl
index 7d73b00..662a1a4 100644
--- a/test/tint/builtins/gen/literal/countTrailingZeros/42fed6.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/countTrailingZeros/42fed6.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void countTrailingZeros_42fed6() {
- int res = ctz(1);
+ int res = 0;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/countTrailingZeros/42fed6.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/countTrailingZeros/42fed6.wgsl.expected.spvasm
index 5603d88..2096349 100644
--- a/test/tint/builtins/gen/literal/countTrailingZeros/42fed6.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/countTrailingZeros/42fed6.wgsl.expected.spvasm
@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 89
+; Bound: 31
; 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_trailing_zeros "tint_count_trailing_zeros"
- OpName %v "v"
- OpName %x "x"
OpName %countTrailingZeros_42fed6 "countTrailingZeros_42fed6"
OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner"
@@ -31,103 +28,38 @@
%_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
- %bool = OpTypeBool
- %uint_65535 = OpConstant %uint 65535
- %uint_16 = OpConstant %uint 16
- %uint_255 = OpConstant %uint 255
- %uint_8 = OpConstant %uint 8
- %uint_15 = OpConstant %uint 15
- %uint_4 = OpConstant %uint 4
- %uint_3 = OpConstant %uint 3
- %uint_2 = OpConstant %uint 2
- %uint_1 = OpConstant %uint 1
%void = OpTypeVoid
- %66 = OpTypeFunction %void
- %int_1 = OpConstant %int 1
+ %9 = OpTypeFunction %void
+ %int = OpTypeInt 32 1
+ %14 = OpConstantNull %int
%_ptr_Function_int = OpTypePointer Function %int
- %74 = OpConstantNull %int
- %75 = OpTypeFunction %v4float
+ %17 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
-%tint_count_trailing_zeros = OpFunction %int None %9
- %v = OpFunctionParameter %int
- %13 = OpLabel
- %x = OpVariable %_ptr_Function_uint Function %18
- %14 = OpBitcast %uint %v
- OpStore %x %14
- %22 = OpLoad %uint %x
- %24 = OpBitwiseAnd %uint %22 %uint_65535
- %20 = OpINotEqual %bool %24 %18
- %19 = OpSelect %uint %20 %18 %uint_16
- %26 = OpLoad %uint %x
- %27 = OpShiftRightLogical %uint %26 %19
- OpStore %x %27
- %30 = OpLoad %uint %x
- %32 = OpBitwiseAnd %uint %30 %uint_255
- %29 = OpINotEqual %bool %32 %18
- %28 = OpSelect %uint %29 %18 %uint_8
- %34 = OpLoad %uint %x
- %35 = OpShiftRightLogical %uint %34 %28
- OpStore %x %35
- %38 = OpLoad %uint %x
- %40 = OpBitwiseAnd %uint %38 %uint_15
- %37 = OpINotEqual %bool %40 %18
- %36 = OpSelect %uint %37 %18 %uint_4
- %42 = OpLoad %uint %x
- %43 = OpShiftRightLogical %uint %42 %36
- OpStore %x %43
- %46 = OpLoad %uint %x
- %48 = OpBitwiseAnd %uint %46 %uint_3
- %45 = OpINotEqual %bool %48 %18
- %44 = OpSelect %uint %45 %18 %uint_2
- %50 = OpLoad %uint %x
- %51 = OpShiftRightLogical %uint %50 %44
- OpStore %x %51
- %54 = OpLoad %uint %x
- %56 = OpBitwiseAnd %uint %54 %uint_1
- %53 = OpINotEqual %bool %56 %18
- %52 = OpSelect %uint %53 %18 %uint_1
- %58 = OpLoad %uint %x
- %59 = OpIEqual %bool %58 %18
- %57 = OpSelect %uint %59 %uint_1 %18
- %61 = OpBitwiseOr %uint %19 %28
- %62 = OpBitwiseOr %uint %61 %36
- %63 = OpBitwiseOr %uint %62 %44
- %64 = OpBitwiseOr %uint %63 %52
- %65 = OpIAdd %uint %64 %57
- %60 = OpBitcast %int %65
- OpReturnValue %60
- OpFunctionEnd
-%countTrailingZeros_42fed6 = OpFunction %void None %66
- %69 = OpLabel
- %res = OpVariable %_ptr_Function_int Function %74
- %70 = OpFunctionCall %int %tint_count_trailing_zeros %int_1
- OpStore %res %70
+%countTrailingZeros_42fed6 = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_int Function %14
+ OpStore %res %14
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %75
- %77 = OpLabel
- %78 = OpFunctionCall %void %countTrailingZeros_42fed6
+%vertex_main_inner = OpFunction %v4float None %17
+ %19 = OpLabel
+ %20 = OpFunctionCall %void %countTrailingZeros_42fed6
OpReturnValue %5
OpFunctionEnd
-%vertex_main = OpFunction %void None %66
- %80 = OpLabel
- %81 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %81
+%vertex_main = OpFunction %void None %9
+ %22 = OpLabel
+ %23 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %23
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
-%fragment_main = OpFunction %void None %66
- %84 = OpLabel
- %85 = OpFunctionCall %void %countTrailingZeros_42fed6
+%fragment_main = OpFunction %void None %9
+ %26 = OpLabel
+ %27 = OpFunctionCall %void %countTrailingZeros_42fed6
OpReturn
OpFunctionEnd
-%compute_main = OpFunction %void None %66
- %87 = OpLabel
- %88 = OpFunctionCall %void %countTrailingZeros_42fed6
+%compute_main = OpFunction %void None %9
+ %29 = OpLabel
+ %30 = OpFunctionCall %void %countTrailingZeros_42fed6
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/countTrailingZeros/8ed26f.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/countTrailingZeros/8ed26f.wgsl.expected.dxc.hlsl
index 39dbf0a..89e2360 100644
--- a/test/tint/builtins/gen/literal/countTrailingZeros/8ed26f.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/countTrailingZeros/8ed26f.wgsl.expected.dxc.hlsl
@@ -1,20 +1,5 @@
-uint3 tint_count_trailing_zeros(uint3 v) {
- uint3 x = uint3(v);
- const uint3 b16 = (bool3((x & (65535u).xxx)) ? (0u).xxx : (16u).xxx);
- x = (x >> b16);
- const uint3 b8 = (bool3((x & (255u).xxx)) ? (0u).xxx : (8u).xxx);
- x = (x >> b8);
- const uint3 b4 = (bool3((x & (15u).xxx)) ? (0u).xxx : (4u).xxx);
- x = (x >> b4);
- const uint3 b2 = (bool3((x & (3u).xxx)) ? (0u).xxx : (2u).xxx);
- x = (x >> b2);
- const uint3 b1 = (bool3((x & (1u).xxx)) ? (0u).xxx : (1u).xxx);
- const uint3 is_zero = ((x == (0u).xxx) ? (1u).xxx : (0u).xxx);
- return uint3((((((b16 | b8) | b4) | b2) | b1) + is_zero));
-}
-
void countTrailingZeros_8ed26f() {
- uint3 res = tint_count_trailing_zeros((1u).xxx);
+ uint3 res = (0u).xxx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/countTrailingZeros/8ed26f.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/countTrailingZeros/8ed26f.wgsl.expected.fxc.hlsl
index 39dbf0a..89e2360 100644
--- a/test/tint/builtins/gen/literal/countTrailingZeros/8ed26f.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/countTrailingZeros/8ed26f.wgsl.expected.fxc.hlsl
@@ -1,20 +1,5 @@
-uint3 tint_count_trailing_zeros(uint3 v) {
- uint3 x = uint3(v);
- const uint3 b16 = (bool3((x & (65535u).xxx)) ? (0u).xxx : (16u).xxx);
- x = (x >> b16);
- const uint3 b8 = (bool3((x & (255u).xxx)) ? (0u).xxx : (8u).xxx);
- x = (x >> b8);
- const uint3 b4 = (bool3((x & (15u).xxx)) ? (0u).xxx : (4u).xxx);
- x = (x >> b4);
- const uint3 b2 = (bool3((x & (3u).xxx)) ? (0u).xxx : (2u).xxx);
- x = (x >> b2);
- const uint3 b1 = (bool3((x & (1u).xxx)) ? (0u).xxx : (1u).xxx);
- const uint3 is_zero = ((x == (0u).xxx) ? (1u).xxx : (0u).xxx);
- return uint3((((((b16 | b8) | b4) | b2) | b1) + is_zero));
-}
-
void countTrailingZeros_8ed26f() {
- uint3 res = tint_count_trailing_zeros((1u).xxx);
+ uint3 res = (0u).xxx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/countTrailingZeros/8ed26f.wgsl.expected.glsl b/test/tint/builtins/gen/literal/countTrailingZeros/8ed26f.wgsl.expected.glsl
index 083c857..9bb8dbb 100644
--- a/test/tint/builtins/gen/literal/countTrailingZeros/8ed26f.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/countTrailingZeros/8ed26f.wgsl.expected.glsl
@@ -1,22 +1,7 @@
#version 310 es
-uvec3 tint_count_trailing_zeros(uvec3 v) {
- uvec3 x = uvec3(v);
- uvec3 b16 = mix(uvec3(16u), uvec3(0u), bvec3((x & uvec3(65535u))));
- x = (x >> b16);
- uvec3 b8 = mix(uvec3(8u), uvec3(0u), bvec3((x & uvec3(255u))));
- x = (x >> b8);
- uvec3 b4 = mix(uvec3(4u), uvec3(0u), bvec3((x & uvec3(15u))));
- x = (x >> b4);
- uvec3 b2 = mix(uvec3(2u), uvec3(0u), bvec3((x & uvec3(3u))));
- x = (x >> b2);
- uvec3 b1 = mix(uvec3(1u), uvec3(0u), bvec3((x & uvec3(1u))));
- uvec3 is_zero = mix(uvec3(0u), uvec3(1u), equal(x, uvec3(0u)));
- return uvec3((((((b16 | b8) | b4) | b2) | b1) + is_zero));
-}
-
void countTrailingZeros_8ed26f() {
- uvec3 res = tint_count_trailing_zeros(uvec3(1u));
+ uvec3 res = uvec3(0u);
}
vec4 vertex_main() {
@@ -35,23 +20,8 @@
#version 310 es
precision mediump float;
-uvec3 tint_count_trailing_zeros(uvec3 v) {
- uvec3 x = uvec3(v);
- uvec3 b16 = mix(uvec3(16u), uvec3(0u), bvec3((x & uvec3(65535u))));
- x = (x >> b16);
- uvec3 b8 = mix(uvec3(8u), uvec3(0u), bvec3((x & uvec3(255u))));
- x = (x >> b8);
- uvec3 b4 = mix(uvec3(4u), uvec3(0u), bvec3((x & uvec3(15u))));
- x = (x >> b4);
- uvec3 b2 = mix(uvec3(2u), uvec3(0u), bvec3((x & uvec3(3u))));
- x = (x >> b2);
- uvec3 b1 = mix(uvec3(1u), uvec3(0u), bvec3((x & uvec3(1u))));
- uvec3 is_zero = mix(uvec3(0u), uvec3(1u), equal(x, uvec3(0u)));
- return uvec3((((((b16 | b8) | b4) | b2) | b1) + is_zero));
-}
-
void countTrailingZeros_8ed26f() {
- uvec3 res = tint_count_trailing_zeros(uvec3(1u));
+ uvec3 res = uvec3(0u);
}
void fragment_main() {
@@ -64,23 +34,8 @@
}
#version 310 es
-uvec3 tint_count_trailing_zeros(uvec3 v) {
- uvec3 x = uvec3(v);
- uvec3 b16 = mix(uvec3(16u), uvec3(0u), bvec3((x & uvec3(65535u))));
- x = (x >> b16);
- uvec3 b8 = mix(uvec3(8u), uvec3(0u), bvec3((x & uvec3(255u))));
- x = (x >> b8);
- uvec3 b4 = mix(uvec3(4u), uvec3(0u), bvec3((x & uvec3(15u))));
- x = (x >> b4);
- uvec3 b2 = mix(uvec3(2u), uvec3(0u), bvec3((x & uvec3(3u))));
- x = (x >> b2);
- uvec3 b1 = mix(uvec3(1u), uvec3(0u), bvec3((x & uvec3(1u))));
- uvec3 is_zero = mix(uvec3(0u), uvec3(1u), equal(x, uvec3(0u)));
- return uvec3((((((b16 | b8) | b4) | b2) | b1) + is_zero));
-}
-
void countTrailingZeros_8ed26f() {
- uvec3 res = tint_count_trailing_zeros(uvec3(1u));
+ uvec3 res = uvec3(0u);
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/countTrailingZeros/8ed26f.wgsl.expected.msl b/test/tint/builtins/gen/literal/countTrailingZeros/8ed26f.wgsl.expected.msl
index 4b8e6a8..78f48b6 100644
--- a/test/tint/builtins/gen/literal/countTrailingZeros/8ed26f.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/countTrailingZeros/8ed26f.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void countTrailingZeros_8ed26f() {
- uint3 res = ctz(uint3(1u));
+ uint3 res = uint3(0u);
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/countTrailingZeros/8ed26f.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/countTrailingZeros/8ed26f.wgsl.expected.spvasm
index 55a38aa..4a78169 100644
--- a/test/tint/builtins/gen/literal/countTrailingZeros/8ed26f.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/countTrailingZeros/8ed26f.wgsl.expected.spvasm
@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 96
+; 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_trailing_zeros "tint_count_trailing_zeros"
- OpName %v "v"
- OpName %x "x"
OpName %countTrailingZeros_8ed26f "countTrailingZeros_8ed26f"
OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner"
@@ -31,108 +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
%v3uint = OpTypeVector %uint 3
- %9 = OpTypeFunction %v3uint %v3uint
+ %15 = OpConstantNull %v3uint
%_ptr_Function_v3uint = OpTypePointer Function %v3uint
- %18 = OpConstantNull %v3uint
- %bool = OpTypeBool
- %v3bool = OpTypeVector %bool 3
- %uint_65535 = OpConstant %uint 65535
- %25 = OpConstantComposite %v3uint %uint_65535 %uint_65535 %uint_65535
- %uint_16 = OpConstant %uint 16
- %28 = OpConstantComposite %v3uint %uint_16 %uint_16 %uint_16
- %uint_255 = OpConstant %uint 255
- %35 = OpConstantComposite %v3uint %uint_255 %uint_255 %uint_255
- %uint_8 = OpConstant %uint 8
- %38 = OpConstantComposite %v3uint %uint_8 %uint_8 %uint_8
- %uint_15 = OpConstant %uint 15
- %45 = OpConstantComposite %v3uint %uint_15 %uint_15 %uint_15
- %uint_4 = OpConstant %uint 4
- %48 = OpConstantComposite %v3uint %uint_4 %uint_4 %uint_4
- %uint_3 = OpConstant %uint 3
- %55 = OpConstantComposite %v3uint %uint_3 %uint_3 %uint_3
- %uint_2 = OpConstant %uint 2
- %58 = OpConstantComposite %v3uint %uint_2 %uint_2 %uint_2
- %uint_1 = OpConstant %uint 1
- %65 = OpConstantComposite %v3uint %uint_1 %uint_1 %uint_1
- %void = OpTypeVoid
- %76 = OpTypeFunction %void
- %82 = OpTypeFunction %v4float
+ %18 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
-%tint_count_trailing_zeros = OpFunction %v3uint None %9
- %v = OpFunctionParameter %v3uint
- %14 = OpLabel
- %x = OpVariable %_ptr_Function_v3uint Function %18
- OpStore %x %v
- %23 = OpLoad %v3uint %x
- %26 = OpBitwiseAnd %v3uint %23 %25
- %20 = OpINotEqual %v3bool %26 %18
- %19 = OpSelect %v3uint %20 %18 %28
- %29 = OpLoad %v3uint %x
- %30 = OpShiftRightLogical %v3uint %29 %19
- OpStore %x %30
- %33 = OpLoad %v3uint %x
- %36 = OpBitwiseAnd %v3uint %33 %35
- %32 = OpINotEqual %v3bool %36 %18
- %31 = OpSelect %v3uint %32 %18 %38
- %39 = OpLoad %v3uint %x
- %40 = OpShiftRightLogical %v3uint %39 %31
- OpStore %x %40
- %43 = OpLoad %v3uint %x
- %46 = OpBitwiseAnd %v3uint %43 %45
- %42 = OpINotEqual %v3bool %46 %18
- %41 = OpSelect %v3uint %42 %18 %48
- %49 = OpLoad %v3uint %x
- %50 = OpShiftRightLogical %v3uint %49 %41
- OpStore %x %50
- %53 = OpLoad %v3uint %x
- %56 = OpBitwiseAnd %v3uint %53 %55
- %52 = OpINotEqual %v3bool %56 %18
- %51 = OpSelect %v3uint %52 %18 %58
- %59 = OpLoad %v3uint %x
- %60 = OpShiftRightLogical %v3uint %59 %51
- OpStore %x %60
- %63 = OpLoad %v3uint %x
- %66 = OpBitwiseAnd %v3uint %63 %65
- %62 = OpINotEqual %v3bool %66 %18
- %61 = OpSelect %v3uint %62 %18 %65
- %68 = OpLoad %v3uint %x
- %69 = OpIEqual %v3bool %68 %18
- %67 = OpSelect %v3uint %69 %65 %18
- %71 = OpBitwiseOr %v3uint %19 %31
- %72 = OpBitwiseOr %v3uint %71 %41
- %73 = OpBitwiseOr %v3uint %72 %51
- %74 = OpBitwiseOr %v3uint %73 %61
- %75 = OpIAdd %v3uint %74 %67
- OpReturnValue %75
- OpFunctionEnd
-%countTrailingZeros_8ed26f = OpFunction %void None %76
- %79 = OpLabel
- %res = OpVariable %_ptr_Function_v3uint Function %18
- %80 = OpFunctionCall %v3uint %tint_count_trailing_zeros %65
- OpStore %res %80
+%countTrailingZeros_8ed26f = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_v3uint Function %15
+ OpStore %res %15
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %82
- %84 = OpLabel
- %85 = OpFunctionCall %void %countTrailingZeros_8ed26f
+%vertex_main_inner = OpFunction %v4float None %18
+ %20 = OpLabel
+ %21 = OpFunctionCall %void %countTrailingZeros_8ed26f
OpReturnValue %5
OpFunctionEnd
-%vertex_main = OpFunction %void None %76
- %87 = OpLabel
- %88 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %88
+%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 %76
- %91 = OpLabel
- %92 = OpFunctionCall %void %countTrailingZeros_8ed26f
+%fragment_main = OpFunction %void None %9
+ %27 = OpLabel
+ %28 = OpFunctionCall %void %countTrailingZeros_8ed26f
OpReturn
OpFunctionEnd
-%compute_main = OpFunction %void None %76
- %94 = OpLabel
- %95 = OpFunctionCall %void %countTrailingZeros_8ed26f
+%compute_main = OpFunction %void None %9
+ %30 = OpLabel
+ %31 = OpFunctionCall %void %countTrailingZeros_8ed26f
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/countTrailingZeros/acfacb.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/countTrailingZeros/acfacb.wgsl.expected.dxc.hlsl
index 6cf84fe..9f0d446 100644
--- a/test/tint/builtins/gen/literal/countTrailingZeros/acfacb.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/countTrailingZeros/acfacb.wgsl.expected.dxc.hlsl
@@ -1,20 +1,5 @@
-int3 tint_count_trailing_zeros(int3 v) {
- uint3 x = uint3(v);
- const uint3 b16 = (bool3((x & (65535u).xxx)) ? (0u).xxx : (16u).xxx);
- x = (x >> b16);
- const uint3 b8 = (bool3((x & (255u).xxx)) ? (0u).xxx : (8u).xxx);
- x = (x >> b8);
- const uint3 b4 = (bool3((x & (15u).xxx)) ? (0u).xxx : (4u).xxx);
- x = (x >> b4);
- const uint3 b2 = (bool3((x & (3u).xxx)) ? (0u).xxx : (2u).xxx);
- x = (x >> b2);
- const uint3 b1 = (bool3((x & (1u).xxx)) ? (0u).xxx : (1u).xxx);
- const uint3 is_zero = ((x == (0u).xxx) ? (1u).xxx : (0u).xxx);
- return int3((((((b16 | b8) | b4) | b2) | b1) + is_zero));
-}
-
void countTrailingZeros_acfacb() {
- int3 res = tint_count_trailing_zeros((1).xxx);
+ int3 res = (0).xxx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/countTrailingZeros/acfacb.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/countTrailingZeros/acfacb.wgsl.expected.fxc.hlsl
index 6cf84fe..9f0d446 100644
--- a/test/tint/builtins/gen/literal/countTrailingZeros/acfacb.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/countTrailingZeros/acfacb.wgsl.expected.fxc.hlsl
@@ -1,20 +1,5 @@
-int3 tint_count_trailing_zeros(int3 v) {
- uint3 x = uint3(v);
- const uint3 b16 = (bool3((x & (65535u).xxx)) ? (0u).xxx : (16u).xxx);
- x = (x >> b16);
- const uint3 b8 = (bool3((x & (255u).xxx)) ? (0u).xxx : (8u).xxx);
- x = (x >> b8);
- const uint3 b4 = (bool3((x & (15u).xxx)) ? (0u).xxx : (4u).xxx);
- x = (x >> b4);
- const uint3 b2 = (bool3((x & (3u).xxx)) ? (0u).xxx : (2u).xxx);
- x = (x >> b2);
- const uint3 b1 = (bool3((x & (1u).xxx)) ? (0u).xxx : (1u).xxx);
- const uint3 is_zero = ((x == (0u).xxx) ? (1u).xxx : (0u).xxx);
- return int3((((((b16 | b8) | b4) | b2) | b1) + is_zero));
-}
-
void countTrailingZeros_acfacb() {
- int3 res = tint_count_trailing_zeros((1).xxx);
+ int3 res = (0).xxx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/countTrailingZeros/acfacb.wgsl.expected.glsl b/test/tint/builtins/gen/literal/countTrailingZeros/acfacb.wgsl.expected.glsl
index 6a70198..44fcde0 100644
--- a/test/tint/builtins/gen/literal/countTrailingZeros/acfacb.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/countTrailingZeros/acfacb.wgsl.expected.glsl
@@ -1,22 +1,7 @@
#version 310 es
-ivec3 tint_count_trailing_zeros(ivec3 v) {
- uvec3 x = uvec3(v);
- uvec3 b16 = mix(uvec3(16u), uvec3(0u), bvec3((x & uvec3(65535u))));
- x = (x >> b16);
- uvec3 b8 = mix(uvec3(8u), uvec3(0u), bvec3((x & uvec3(255u))));
- x = (x >> b8);
- uvec3 b4 = mix(uvec3(4u), uvec3(0u), bvec3((x & uvec3(15u))));
- x = (x >> b4);
- uvec3 b2 = mix(uvec3(2u), uvec3(0u), bvec3((x & uvec3(3u))));
- x = (x >> b2);
- uvec3 b1 = mix(uvec3(1u), uvec3(0u), bvec3((x & uvec3(1u))));
- uvec3 is_zero = mix(uvec3(0u), uvec3(1u), equal(x, uvec3(0u)));
- return ivec3((((((b16 | b8) | b4) | b2) | b1) + is_zero));
-}
-
void countTrailingZeros_acfacb() {
- ivec3 res = tint_count_trailing_zeros(ivec3(1));
+ ivec3 res = ivec3(0);
}
vec4 vertex_main() {
@@ -35,23 +20,8 @@
#version 310 es
precision mediump float;
-ivec3 tint_count_trailing_zeros(ivec3 v) {
- uvec3 x = uvec3(v);
- uvec3 b16 = mix(uvec3(16u), uvec3(0u), bvec3((x & uvec3(65535u))));
- x = (x >> b16);
- uvec3 b8 = mix(uvec3(8u), uvec3(0u), bvec3((x & uvec3(255u))));
- x = (x >> b8);
- uvec3 b4 = mix(uvec3(4u), uvec3(0u), bvec3((x & uvec3(15u))));
- x = (x >> b4);
- uvec3 b2 = mix(uvec3(2u), uvec3(0u), bvec3((x & uvec3(3u))));
- x = (x >> b2);
- uvec3 b1 = mix(uvec3(1u), uvec3(0u), bvec3((x & uvec3(1u))));
- uvec3 is_zero = mix(uvec3(0u), uvec3(1u), equal(x, uvec3(0u)));
- return ivec3((((((b16 | b8) | b4) | b2) | b1) + is_zero));
-}
-
void countTrailingZeros_acfacb() {
- ivec3 res = tint_count_trailing_zeros(ivec3(1));
+ ivec3 res = ivec3(0);
}
void fragment_main() {
@@ -64,23 +34,8 @@
}
#version 310 es
-ivec3 tint_count_trailing_zeros(ivec3 v) {
- uvec3 x = uvec3(v);
- uvec3 b16 = mix(uvec3(16u), uvec3(0u), bvec3((x & uvec3(65535u))));
- x = (x >> b16);
- uvec3 b8 = mix(uvec3(8u), uvec3(0u), bvec3((x & uvec3(255u))));
- x = (x >> b8);
- uvec3 b4 = mix(uvec3(4u), uvec3(0u), bvec3((x & uvec3(15u))));
- x = (x >> b4);
- uvec3 b2 = mix(uvec3(2u), uvec3(0u), bvec3((x & uvec3(3u))));
- x = (x >> b2);
- uvec3 b1 = mix(uvec3(1u), uvec3(0u), bvec3((x & uvec3(1u))));
- uvec3 is_zero = mix(uvec3(0u), uvec3(1u), equal(x, uvec3(0u)));
- return ivec3((((((b16 | b8) | b4) | b2) | b1) + is_zero));
-}
-
void countTrailingZeros_acfacb() {
- ivec3 res = tint_count_trailing_zeros(ivec3(1));
+ ivec3 res = ivec3(0);
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/countTrailingZeros/acfacb.wgsl.expected.msl b/test/tint/builtins/gen/literal/countTrailingZeros/acfacb.wgsl.expected.msl
index 9b8028b..b218911 100644
--- a/test/tint/builtins/gen/literal/countTrailingZeros/acfacb.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/countTrailingZeros/acfacb.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void countTrailingZeros_acfacb() {
- int3 res = ctz(int3(1));
+ int3 res = int3(0);
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/countTrailingZeros/acfacb.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/countTrailingZeros/acfacb.wgsl.expected.spvasm
index 32f7b95..795e4e0 100644
--- a/test/tint/builtins/gen/literal/countTrailingZeros/acfacb.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/countTrailingZeros/acfacb.wgsl.expected.spvasm
@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 102
+; 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_trailing_zeros "tint_count_trailing_zeros"
- OpName %v "v"
- OpName %x "x"
OpName %countTrailingZeros_acfacb "countTrailingZeros_acfacb"
OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner"
@@ -31,116 +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
%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
- %bool = OpTypeBool
- %v3bool = OpTypeVector %bool 3
- %uint_65535 = OpConstant %uint 65535
- %27 = OpConstantComposite %v3uint %uint_65535 %uint_65535 %uint_65535
- %uint_16 = OpConstant %uint 16
- %30 = OpConstantComposite %v3uint %uint_16 %uint_16 %uint_16
- %uint_255 = OpConstant %uint 255
- %37 = OpConstantComposite %v3uint %uint_255 %uint_255 %uint_255
- %uint_8 = OpConstant %uint 8
- %40 = OpConstantComposite %v3uint %uint_8 %uint_8 %uint_8
- %uint_15 = OpConstant %uint 15
- %47 = OpConstantComposite %v3uint %uint_15 %uint_15 %uint_15
- %uint_4 = OpConstant %uint 4
- %50 = OpConstantComposite %v3uint %uint_4 %uint_4 %uint_4
- %uint_3 = OpConstant %uint 3
- %57 = OpConstantComposite %v3uint %uint_3 %uint_3 %uint_3
- %uint_2 = OpConstant %uint 2
- %60 = OpConstantComposite %v3uint %uint_2 %uint_2 %uint_2
- %uint_1 = OpConstant %uint 1
- %67 = OpConstantComposite %v3uint %uint_1 %uint_1 %uint_1
- %void = OpTypeVoid
- %78 = OpTypeFunction %void
- %int_1 = OpConstant %int 1
- %84 = OpConstantComposite %v3int %int_1 %int_1 %int_1
+ %15 = OpConstantNull %v3int
%_ptr_Function_v3int = OpTypePointer Function %v3int
- %87 = OpConstantNull %v3int
- %88 = OpTypeFunction %v4float
+ %18 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
-%tint_count_trailing_zeros = OpFunction %v3int None %9
- %v = OpFunctionParameter %v3int
- %14 = OpLabel
- %x = OpVariable %_ptr_Function_v3uint Function %20
- %15 = OpBitcast %v3uint %v
- OpStore %x %15
- %25 = OpLoad %v3uint %x
- %28 = OpBitwiseAnd %v3uint %25 %27
- %22 = OpINotEqual %v3bool %28 %20
- %21 = OpSelect %v3uint %22 %20 %30
- %31 = OpLoad %v3uint %x
- %32 = OpShiftRightLogical %v3uint %31 %21
- OpStore %x %32
- %35 = OpLoad %v3uint %x
- %38 = OpBitwiseAnd %v3uint %35 %37
- %34 = OpINotEqual %v3bool %38 %20
- %33 = OpSelect %v3uint %34 %20 %40
- %41 = OpLoad %v3uint %x
- %42 = OpShiftRightLogical %v3uint %41 %33
- OpStore %x %42
- %45 = OpLoad %v3uint %x
- %48 = OpBitwiseAnd %v3uint %45 %47
- %44 = OpINotEqual %v3bool %48 %20
- %43 = OpSelect %v3uint %44 %20 %50
- %51 = OpLoad %v3uint %x
- %52 = OpShiftRightLogical %v3uint %51 %43
- OpStore %x %52
- %55 = OpLoad %v3uint %x
- %58 = OpBitwiseAnd %v3uint %55 %57
- %54 = OpINotEqual %v3bool %58 %20
- %53 = OpSelect %v3uint %54 %20 %60
- %61 = OpLoad %v3uint %x
- %62 = OpShiftRightLogical %v3uint %61 %53
- OpStore %x %62
- %65 = OpLoad %v3uint %x
- %68 = OpBitwiseAnd %v3uint %65 %67
- %64 = OpINotEqual %v3bool %68 %20
- %63 = OpSelect %v3uint %64 %20 %67
- %70 = OpLoad %v3uint %x
- %71 = OpIEqual %v3bool %70 %20
- %69 = OpSelect %v3uint %71 %67 %20
- %73 = OpBitwiseOr %v3uint %21 %33
- %74 = OpBitwiseOr %v3uint %73 %43
- %75 = OpBitwiseOr %v3uint %74 %53
- %76 = OpBitwiseOr %v3uint %75 %63
- %77 = OpIAdd %v3uint %76 %69
- %72 = OpBitcast %v3int %77
- OpReturnValue %72
- OpFunctionEnd
-%countTrailingZeros_acfacb = OpFunction %void None %78
- %81 = OpLabel
- %res = OpVariable %_ptr_Function_v3int Function %87
- %82 = OpFunctionCall %v3int %tint_count_trailing_zeros %84
- OpStore %res %82
+%countTrailingZeros_acfacb = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_v3int Function %15
+ OpStore %res %15
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %88
- %90 = OpLabel
- %91 = OpFunctionCall %void %countTrailingZeros_acfacb
+%vertex_main_inner = OpFunction %v4float None %18
+ %20 = OpLabel
+ %21 = OpFunctionCall %void %countTrailingZeros_acfacb
OpReturnValue %5
OpFunctionEnd
-%vertex_main = OpFunction %void None %78
- %93 = OpLabel
- %94 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %94
+%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 %78
- %97 = OpLabel
- %98 = OpFunctionCall %void %countTrailingZeros_acfacb
+%fragment_main = OpFunction %void None %9
+ %27 = OpLabel
+ %28 = OpFunctionCall %void %countTrailingZeros_acfacb
OpReturn
OpFunctionEnd
-%compute_main = OpFunction %void None %78
- %100 = OpLabel
- %101 = OpFunctionCall %void %countTrailingZeros_acfacb
+%compute_main = OpFunction %void None %9
+ %30 = OpLabel
+ %31 = OpFunctionCall %void %countTrailingZeros_acfacb
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/countTrailingZeros/d2b4a0.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/countTrailingZeros/d2b4a0.wgsl.expected.dxc.hlsl
index 8504bb8..4d36b60 100644
--- a/test/tint/builtins/gen/literal/countTrailingZeros/d2b4a0.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/countTrailingZeros/d2b4a0.wgsl.expected.dxc.hlsl
@@ -1,20 +1,5 @@
-uint4 tint_count_trailing_zeros(uint4 v) {
- uint4 x = uint4(v);
- const uint4 b16 = (bool4((x & (65535u).xxxx)) ? (0u).xxxx : (16u).xxxx);
- x = (x >> b16);
- const uint4 b8 = (bool4((x & (255u).xxxx)) ? (0u).xxxx : (8u).xxxx);
- x = (x >> b8);
- const uint4 b4 = (bool4((x & (15u).xxxx)) ? (0u).xxxx : (4u).xxxx);
- x = (x >> b4);
- const uint4 b2 = (bool4((x & (3u).xxxx)) ? (0u).xxxx : (2u).xxxx);
- x = (x >> b2);
- const uint4 b1 = (bool4((x & (1u).xxxx)) ? (0u).xxxx : (1u).xxxx);
- const uint4 is_zero = ((x == (0u).xxxx) ? (1u).xxxx : (0u).xxxx);
- return uint4((((((b16 | b8) | b4) | b2) | b1) + is_zero));
-}
-
void countTrailingZeros_d2b4a0() {
- uint4 res = tint_count_trailing_zeros((1u).xxxx);
+ uint4 res = (0u).xxxx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/countTrailingZeros/d2b4a0.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/countTrailingZeros/d2b4a0.wgsl.expected.fxc.hlsl
index 8504bb8..4d36b60 100644
--- a/test/tint/builtins/gen/literal/countTrailingZeros/d2b4a0.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/countTrailingZeros/d2b4a0.wgsl.expected.fxc.hlsl
@@ -1,20 +1,5 @@
-uint4 tint_count_trailing_zeros(uint4 v) {
- uint4 x = uint4(v);
- const uint4 b16 = (bool4((x & (65535u).xxxx)) ? (0u).xxxx : (16u).xxxx);
- x = (x >> b16);
- const uint4 b8 = (bool4((x & (255u).xxxx)) ? (0u).xxxx : (8u).xxxx);
- x = (x >> b8);
- const uint4 b4 = (bool4((x & (15u).xxxx)) ? (0u).xxxx : (4u).xxxx);
- x = (x >> b4);
- const uint4 b2 = (bool4((x & (3u).xxxx)) ? (0u).xxxx : (2u).xxxx);
- x = (x >> b2);
- const uint4 b1 = (bool4((x & (1u).xxxx)) ? (0u).xxxx : (1u).xxxx);
- const uint4 is_zero = ((x == (0u).xxxx) ? (1u).xxxx : (0u).xxxx);
- return uint4((((((b16 | b8) | b4) | b2) | b1) + is_zero));
-}
-
void countTrailingZeros_d2b4a0() {
- uint4 res = tint_count_trailing_zeros((1u).xxxx);
+ uint4 res = (0u).xxxx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/countTrailingZeros/d2b4a0.wgsl.expected.glsl b/test/tint/builtins/gen/literal/countTrailingZeros/d2b4a0.wgsl.expected.glsl
index 12fcaa3..721e11e 100644
--- a/test/tint/builtins/gen/literal/countTrailingZeros/d2b4a0.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/countTrailingZeros/d2b4a0.wgsl.expected.glsl
@@ -1,22 +1,7 @@
#version 310 es
-uvec4 tint_count_trailing_zeros(uvec4 v) {
- uvec4 x = uvec4(v);
- uvec4 b16 = mix(uvec4(16u), uvec4(0u), bvec4((x & uvec4(65535u))));
- x = (x >> b16);
- uvec4 b8 = mix(uvec4(8u), uvec4(0u), bvec4((x & uvec4(255u))));
- x = (x >> b8);
- uvec4 b4 = mix(uvec4(4u), uvec4(0u), bvec4((x & uvec4(15u))));
- x = (x >> b4);
- uvec4 b2 = mix(uvec4(2u), uvec4(0u), bvec4((x & uvec4(3u))));
- x = (x >> b2);
- uvec4 b1 = mix(uvec4(1u), uvec4(0u), bvec4((x & uvec4(1u))));
- uvec4 is_zero = mix(uvec4(0u), uvec4(1u), equal(x, uvec4(0u)));
- return uvec4((((((b16 | b8) | b4) | b2) | b1) + is_zero));
-}
-
void countTrailingZeros_d2b4a0() {
- uvec4 res = tint_count_trailing_zeros(uvec4(1u));
+ uvec4 res = uvec4(0u);
}
vec4 vertex_main() {
@@ -35,23 +20,8 @@
#version 310 es
precision mediump float;
-uvec4 tint_count_trailing_zeros(uvec4 v) {
- uvec4 x = uvec4(v);
- uvec4 b16 = mix(uvec4(16u), uvec4(0u), bvec4((x & uvec4(65535u))));
- x = (x >> b16);
- uvec4 b8 = mix(uvec4(8u), uvec4(0u), bvec4((x & uvec4(255u))));
- x = (x >> b8);
- uvec4 b4 = mix(uvec4(4u), uvec4(0u), bvec4((x & uvec4(15u))));
- x = (x >> b4);
- uvec4 b2 = mix(uvec4(2u), uvec4(0u), bvec4((x & uvec4(3u))));
- x = (x >> b2);
- uvec4 b1 = mix(uvec4(1u), uvec4(0u), bvec4((x & uvec4(1u))));
- uvec4 is_zero = mix(uvec4(0u), uvec4(1u), equal(x, uvec4(0u)));
- return uvec4((((((b16 | b8) | b4) | b2) | b1) + is_zero));
-}
-
void countTrailingZeros_d2b4a0() {
- uvec4 res = tint_count_trailing_zeros(uvec4(1u));
+ uvec4 res = uvec4(0u);
}
void fragment_main() {
@@ -64,23 +34,8 @@
}
#version 310 es
-uvec4 tint_count_trailing_zeros(uvec4 v) {
- uvec4 x = uvec4(v);
- uvec4 b16 = mix(uvec4(16u), uvec4(0u), bvec4((x & uvec4(65535u))));
- x = (x >> b16);
- uvec4 b8 = mix(uvec4(8u), uvec4(0u), bvec4((x & uvec4(255u))));
- x = (x >> b8);
- uvec4 b4 = mix(uvec4(4u), uvec4(0u), bvec4((x & uvec4(15u))));
- x = (x >> b4);
- uvec4 b2 = mix(uvec4(2u), uvec4(0u), bvec4((x & uvec4(3u))));
- x = (x >> b2);
- uvec4 b1 = mix(uvec4(1u), uvec4(0u), bvec4((x & uvec4(1u))));
- uvec4 is_zero = mix(uvec4(0u), uvec4(1u), equal(x, uvec4(0u)));
- return uvec4((((((b16 | b8) | b4) | b2) | b1) + is_zero));
-}
-
void countTrailingZeros_d2b4a0() {
- uvec4 res = tint_count_trailing_zeros(uvec4(1u));
+ uvec4 res = uvec4(0u);
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/countTrailingZeros/d2b4a0.wgsl.expected.msl b/test/tint/builtins/gen/literal/countTrailingZeros/d2b4a0.wgsl.expected.msl
index 79d1f25..ee9e6a8 100644
--- a/test/tint/builtins/gen/literal/countTrailingZeros/d2b4a0.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/countTrailingZeros/d2b4a0.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void countTrailingZeros_d2b4a0() {
- uint4 res = ctz(uint4(1u));
+ uint4 res = uint4(0u);
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/countTrailingZeros/d2b4a0.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/countTrailingZeros/d2b4a0.wgsl.expected.spvasm
index 74bcb41..20a5725 100644
--- a/test/tint/builtins/gen/literal/countTrailingZeros/d2b4a0.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/countTrailingZeros/d2b4a0.wgsl.expected.spvasm
@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 96
+; 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_trailing_zeros "tint_count_trailing_zeros"
- OpName %v "v"
- OpName %x "x"
OpName %countTrailingZeros_d2b4a0 "countTrailingZeros_d2b4a0"
OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner"
@@ -31,108 +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
%v4uint = OpTypeVector %uint 4
- %9 = OpTypeFunction %v4uint %v4uint
+ %15 = OpConstantNull %v4uint
%_ptr_Function_v4uint = OpTypePointer Function %v4uint
- %18 = OpConstantNull %v4uint
- %bool = OpTypeBool
- %v4bool = OpTypeVector %bool 4
- %uint_65535 = OpConstant %uint 65535
- %25 = OpConstantComposite %v4uint %uint_65535 %uint_65535 %uint_65535 %uint_65535
- %uint_16 = OpConstant %uint 16
- %28 = OpConstantComposite %v4uint %uint_16 %uint_16 %uint_16 %uint_16
- %uint_255 = OpConstant %uint 255
- %35 = OpConstantComposite %v4uint %uint_255 %uint_255 %uint_255 %uint_255
- %uint_8 = OpConstant %uint 8
- %38 = OpConstantComposite %v4uint %uint_8 %uint_8 %uint_8 %uint_8
- %uint_15 = OpConstant %uint 15
- %45 = OpConstantComposite %v4uint %uint_15 %uint_15 %uint_15 %uint_15
- %uint_4 = OpConstant %uint 4
- %48 = OpConstantComposite %v4uint %uint_4 %uint_4 %uint_4 %uint_4
- %uint_3 = OpConstant %uint 3
- %55 = OpConstantComposite %v4uint %uint_3 %uint_3 %uint_3 %uint_3
- %uint_2 = OpConstant %uint 2
- %58 = OpConstantComposite %v4uint %uint_2 %uint_2 %uint_2 %uint_2
- %uint_1 = OpConstant %uint 1
- %65 = OpConstantComposite %v4uint %uint_1 %uint_1 %uint_1 %uint_1
- %void = OpTypeVoid
- %76 = OpTypeFunction %void
- %82 = OpTypeFunction %v4float
+ %18 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
-%tint_count_trailing_zeros = OpFunction %v4uint None %9
- %v = OpFunctionParameter %v4uint
- %14 = OpLabel
- %x = OpVariable %_ptr_Function_v4uint Function %18
- OpStore %x %v
- %23 = OpLoad %v4uint %x
- %26 = OpBitwiseAnd %v4uint %23 %25
- %20 = OpINotEqual %v4bool %26 %18
- %19 = OpSelect %v4uint %20 %18 %28
- %29 = OpLoad %v4uint %x
- %30 = OpShiftRightLogical %v4uint %29 %19
- OpStore %x %30
- %33 = OpLoad %v4uint %x
- %36 = OpBitwiseAnd %v4uint %33 %35
- %32 = OpINotEqual %v4bool %36 %18
- %31 = OpSelect %v4uint %32 %18 %38
- %39 = OpLoad %v4uint %x
- %40 = OpShiftRightLogical %v4uint %39 %31
- OpStore %x %40
- %43 = OpLoad %v4uint %x
- %46 = OpBitwiseAnd %v4uint %43 %45
- %42 = OpINotEqual %v4bool %46 %18
- %41 = OpSelect %v4uint %42 %18 %48
- %49 = OpLoad %v4uint %x
- %50 = OpShiftRightLogical %v4uint %49 %41
- OpStore %x %50
- %53 = OpLoad %v4uint %x
- %56 = OpBitwiseAnd %v4uint %53 %55
- %52 = OpINotEqual %v4bool %56 %18
- %51 = OpSelect %v4uint %52 %18 %58
- %59 = OpLoad %v4uint %x
- %60 = OpShiftRightLogical %v4uint %59 %51
- OpStore %x %60
- %63 = OpLoad %v4uint %x
- %66 = OpBitwiseAnd %v4uint %63 %65
- %62 = OpINotEqual %v4bool %66 %18
- %61 = OpSelect %v4uint %62 %18 %65
- %68 = OpLoad %v4uint %x
- %69 = OpIEqual %v4bool %68 %18
- %67 = OpSelect %v4uint %69 %65 %18
- %71 = OpBitwiseOr %v4uint %19 %31
- %72 = OpBitwiseOr %v4uint %71 %41
- %73 = OpBitwiseOr %v4uint %72 %51
- %74 = OpBitwiseOr %v4uint %73 %61
- %75 = OpIAdd %v4uint %74 %67
- OpReturnValue %75
- OpFunctionEnd
-%countTrailingZeros_d2b4a0 = OpFunction %void None %76
- %79 = OpLabel
- %res = OpVariable %_ptr_Function_v4uint Function %18
- %80 = OpFunctionCall %v4uint %tint_count_trailing_zeros %65
- OpStore %res %80
+%countTrailingZeros_d2b4a0 = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_v4uint Function %15
+ OpStore %res %15
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %82
- %84 = OpLabel
- %85 = OpFunctionCall %void %countTrailingZeros_d2b4a0
+%vertex_main_inner = OpFunction %v4float None %18
+ %20 = OpLabel
+ %21 = OpFunctionCall %void %countTrailingZeros_d2b4a0
OpReturnValue %5
OpFunctionEnd
-%vertex_main = OpFunction %void None %76
- %87 = OpLabel
- %88 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %88
+%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 %76
- %91 = OpLabel
- %92 = OpFunctionCall %void %countTrailingZeros_d2b4a0
+%fragment_main = OpFunction %void None %9
+ %27 = OpLabel
+ %28 = OpFunctionCall %void %countTrailingZeros_d2b4a0
OpReturn
OpFunctionEnd
-%compute_main = OpFunction %void None %76
- %94 = OpLabel
- %95 = OpFunctionCall %void %countTrailingZeros_d2b4a0
+%compute_main = OpFunction %void None %9
+ %30 = OpLabel
+ %31 = OpFunctionCall %void %countTrailingZeros_d2b4a0
OpReturn
OpFunctionEnd