tint: const eval of countLeadingZeros

Bug: tint:1581
Change-Id: Ib7ae9f36dad64c1eed3ce223af47e92aa0a663f1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107661
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
Antonio Maiorano 2022-10-29 14:02:38 +00:00
parent eb465f312c
commit 2be5167e3e
46 changed files with 333 additions and 1387 deletions

View File

@ -433,8 +433,8 @@ fn cos<T: f32_f16>(T) -> T
fn cos<N: num, T: f32_f16>(vec<N, T>) -> vec<N, T> fn cos<N: num, T: f32_f16>(vec<N, T>) -> vec<N, T>
fn cosh<T: f32_f16>(T) -> T fn cosh<T: f32_f16>(T) -> T
fn cosh<N: num, T: f32_f16>(vec<N, T>) -> vec<N, T> fn cosh<N: num, T: f32_f16>(vec<N, T>) -> vec<N, T>
fn countLeadingZeros<T: iu32>(T) -> T @const fn countLeadingZeros<T: iu32>(T) -> T
fn countLeadingZeros<N: num, T: iu32>(vec<N, T>) -> vec<N, T> @const fn countLeadingZeros<N: num, T: iu32>(vec<N, T>) -> vec<N, T>
fn countOneBits<T: iu32>(T) -> T fn countOneBits<T: iu32>(T) -> T
fn countOneBits<N: num, T: iu32>(vec<N, T>) -> vec<N, T> fn countOneBits<N: num, T: iu32>(vec<N, T>) -> vec<N, T>
fn countTrailingZeros<T: iu32>(T) -> T fn countTrailingZeros<T: iu32>(T) -> T

View File

@ -53,6 +53,16 @@ T First(T&& first, ...) {
return std::forward<T>(first); return std::forward<T>(first);
} }
/// Helper that calls `f` passing in the value of all `cs`.
/// Calls `f` with all constants cast to the type of the first `cs` argument.
template <typename F, typename... CONSTANTS>
auto Dispatch_iu32(F&& f, CONSTANTS&&... cs) {
return Switch(
First(cs...)->Type(), //
[&](const sem::I32*) { return f(cs->template As<i32>()...); },
[&](const sem::U32*) { return f(cs->template As<u32>()...); });
}
/// Helper that calls `f` passing in the value of all `cs`. /// Helper that calls `f` passing in the value of all `cs`.
/// Calls `f` with all constants cast to the type of the first `cs` argument. /// Calls `f` with all constants cast to the type of the first `cs` argument.
template <typename F, typename... CONSTANTS> template <typename F, typename... CONSTANTS>
@ -1616,6 +1626,31 @@ ConstEval::Result ConstEval::clamp(const sem::Type* ty,
return TransformElements(builder, ty, transform, args[0], args[1], args[2]); return TransformElements(builder, ty, transform, args[0], args[1], args[2]);
} }
ConstEval::Result ConstEval::countLeadingZeros(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 kLeftMost = UT{1} << (kNumBits - 1);
auto v = static_cast<UT>(e);
auto count = UT{0};
while ((count < kNumBits) && ((v & kLeftMost) == 0)) {
++count;
v <<= 1;
}
return CreateElement(builder, c0->Type(), NumberT(count));
};
return Dispatch_iu32(create, c0);
};
return TransformElements(builder, ty, transform, args[0]);
}
ConstEval::Result ConstEval::saturate(const sem::Type* ty, ConstEval::Result ConstEval::saturate(const sem::Type* ty,
utils::VectorRef<const sem::Constant*> args, utils::VectorRef<const sem::Constant*> args,
const Source&) { const Source&) {

View File

@ -431,6 +431,15 @@ class ConstEval {
utils::VectorRef<const sem::Constant*> args, utils::VectorRef<const sem::Constant*> args,
const Source& source); const Source& source);
/// countLeadingZeros builtin
/// @param ty the expression type
/// @param args the input arguments
/// @param source the source location of the conversion
/// @return the result value, or null if the value cannot be calculated
Result countLeadingZeros(const sem::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source);
/// saturate builtin /// saturate builtin
/// @param ty the expression type /// @param ty the expression type
/// @param args the input arguments /// @param args the input arguments

View File

@ -460,6 +460,52 @@ INSTANTIATE_TEST_SUITE_P( //
ClampCases<f32>(), ClampCases<f32>(),
ClampCases<f16>())))); ClampCases<f16>()))));
template <typename T>
std::vector<Case> CountLeadingZerosCases() {
using B = BitValues<T>;
return {
C({B::Lsh(1, 31)}, T(0)), //
C({B::Lsh(1, 30)}, T(1)), //
C({B::Lsh(1, 29)}, T(2)), //
C({B::Lsh(1, 28)}, T(3)),
//...
C({B::Lsh(1, 3)}, T(28)), //
C({B::Lsh(1, 2)}, T(29)), //
C({B::Lsh(1, 1)}, T(30)), //
C({B::Lsh(1, 0)}, T(31)),
C({T(0b1111'0000'1111'0000'1111'0000'1111'0000)}, T(0)),
C({T(0b0111'1000'0111'1000'0111'1000'0111'1000)}, T(1)),
C({T(0b0011'1100'0011'1100'0011'1100'0011'1100)}, T(2)),
C({T(0b0001'1110'0001'1110'0001'1110'0001'1110)}, T(3)),
//...
C({T(0b0000'0000'0000'0000'0000'0000'0000'0111)}, T(29)),
C({T(0b0000'0000'0000'0000'0000'0000'0000'0011)}, T(30)),
C({T(0b0000'0000'0000'0000'0000'0000'0000'0001)}, T(31)),
C({T(0b0000'0000'0000'0000'0000'0000'0000'0000)}, T(32)),
// Same as above, but remove leading 0
C({T(0b1111'1000'0111'1000'0111'1000'0111'1000)}, T(0)),
C({T(0b1011'1100'0011'1100'0011'1100'0011'1100)}, T(0)),
C({T(0b1001'1110'0001'1110'0001'1110'0001'1110)}, T(0)),
//...
C({T(0b1000'0000'0000'0000'0000'0000'0000'0111)}, T(0)),
C({T(0b1000'0000'0000'0000'0000'0000'0000'0011)}, T(0)),
C({T(0b1000'0000'0000'0000'0000'0000'0000'0001)}, T(0)),
C({T(0b1000'0000'0000'0000'0000'0000'0000'0000)}, T(0)),
// Vector tests
C({Vec(B::Lsh(1, 31), B::Lsh(1, 30), B::Lsh(1, 29))}, Vec(T(0), T(1), T(2))),
C({Vec(B::Lsh(1, 2), B::Lsh(1, 1), B::Lsh(1, 0))}, Vec(T(29), T(30), T(31))),
};
}
INSTANTIATE_TEST_SUITE_P( //
CountLeadingZeros,
ResolverConstEvalBuiltinTest,
testing::Combine(testing::Values(sem::BuiltinType::kCountLeadingZeros),
testing::ValuesIn(Concat(CountLeadingZerosCases<i32>(), //
CountLeadingZerosCases<u32>()))));
template <typename T> template <typename T>
std::vector<Case> SaturateCases() { std::vector<Case> SaturateCases() {
return { return {

View File

@ -236,6 +236,8 @@ template <typename NumberT>
struct BitValues { struct BitValues {
/// The unwrapped number type /// The unwrapped number type
using T = UnwrapNumber<NumberT>; using T = UnwrapNumber<NumberT>;
/// The unsigned unwrapped number type
using UT = std::make_unsigned_t<T>;
/// Details /// Details
struct detail { struct detail {
/// Unsigned type of `T` /// Unsigned type of `T`
@ -281,7 +283,7 @@ struct BitValues {
/// @returns the shifted value /// @returns the shifted value
template <typename U, typename V> template <typename U, typename V>
static constexpr NumberT Lsh(U val, V shiftBy) { static constexpr NumberT Lsh(U val, V shiftBy) {
return NumberT{static_cast<T>(val) << static_cast<T>(shiftBy)}; return NumberT{static_cast<T>(static_cast<UT>(val) << static_cast<UT>(shiftBy))};
} }
}; };

View File

@ -13012,7 +13012,7 @@ constexpr OverloadInfo kOverloads[] = {
/* parameters */ &kParameters[950], /* parameters */ &kParameters[950],
/* return matcher indices */ &kMatcherIndices[1], /* return matcher indices */ &kMatcherIndices[1],
/* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
/* const eval */ nullptr, /* const eval */ &ConstEval::countLeadingZeros,
}, },
{ {
/* [391] */ /* [391] */
@ -13024,7 +13024,7 @@ constexpr OverloadInfo kOverloads[] = {
/* parameters */ &kParameters[947], /* parameters */ &kParameters[947],
/* return matcher indices */ &kMatcherIndices[30], /* return matcher indices */ &kMatcherIndices[30],
/* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
/* const eval */ nullptr, /* const eval */ &ConstEval::countLeadingZeros,
}, },
{ {
/* [392] */ /* [392] */

View File

@ -1,20 +1,5 @@
uint tint_count_leading_zeros(uint v) {
uint x = uint(v);
const uint b16 = ((x <= 65535u) ? 16u : 0u);
x = (x << b16);
const uint b8 = ((x <= 16777215u) ? 8u : 0u);
x = (x << b8);
const uint b4 = ((x <= 268435455u) ? 4u : 0u);
x = (x << b4);
const uint b2 = ((x <= 1073741823u) ? 2u : 0u);
x = (x << b2);
const uint b1 = ((x <= 2147483647u) ? 1u : 0u);
const uint is_zero = ((x == 0u) ? 1u : 0u);
return uint((((((b16 | b8) | b4) | b2) | b1) + is_zero));
}
void countLeadingZeros_208d46() { void countLeadingZeros_208d46() {
uint res = tint_count_leading_zeros(1u); uint res = 31u;
} }
struct tint_symbol { struct tint_symbol {

View File

@ -1,20 +1,5 @@
uint tint_count_leading_zeros(uint v) {
uint x = uint(v);
const uint b16 = ((x <= 65535u) ? 16u : 0u);
x = (x << b16);
const uint b8 = ((x <= 16777215u) ? 8u : 0u);
x = (x << b8);
const uint b4 = ((x <= 268435455u) ? 4u : 0u);
x = (x << b4);
const uint b2 = ((x <= 1073741823u) ? 2u : 0u);
x = (x << b2);
const uint b1 = ((x <= 2147483647u) ? 1u : 0u);
const uint is_zero = ((x == 0u) ? 1u : 0u);
return uint((((((b16 | b8) | b4) | b2) | b1) + is_zero));
}
void countLeadingZeros_208d46() { void countLeadingZeros_208d46() {
uint res = tint_count_leading_zeros(1u); uint res = 31u;
} }
struct tint_symbol { struct tint_symbol {

View File

@ -1,22 +1,7 @@
#version 310 es #version 310 es
uint tint_count_leading_zeros(uint v) {
uint x = uint(v);
uint b16 = ((x <= 65535u) ? 16u : 0u);
x = (x << b16);
uint b8 = ((x <= 16777215u) ? 8u : 0u);
x = (x << b8);
uint b4 = ((x <= 268435455u) ? 4u : 0u);
x = (x << b4);
uint b2 = ((x <= 1073741823u) ? 2u : 0u);
x = (x << b2);
uint b1 = ((x <= 2147483647u) ? 1u : 0u);
uint is_zero = ((x == 0u) ? 1u : 0u);
return uint((((((b16 | b8) | b4) | b2) | b1) + is_zero));
}
void countLeadingZeros_208d46() { void countLeadingZeros_208d46() {
uint res = tint_count_leading_zeros(1u); uint res = 31u;
} }
vec4 vertex_main() { vec4 vertex_main() {
@ -35,23 +20,8 @@ void main() {
#version 310 es #version 310 es
precision mediump float; precision mediump float;
uint tint_count_leading_zeros(uint v) {
uint x = uint(v);
uint b16 = ((x <= 65535u) ? 16u : 0u);
x = (x << b16);
uint b8 = ((x <= 16777215u) ? 8u : 0u);
x = (x << b8);
uint b4 = ((x <= 268435455u) ? 4u : 0u);
x = (x << b4);
uint b2 = ((x <= 1073741823u) ? 2u : 0u);
x = (x << b2);
uint b1 = ((x <= 2147483647u) ? 1u : 0u);
uint is_zero = ((x == 0u) ? 1u : 0u);
return uint((((((b16 | b8) | b4) | b2) | b1) + is_zero));
}
void countLeadingZeros_208d46() { void countLeadingZeros_208d46() {
uint res = tint_count_leading_zeros(1u); uint res = 31u;
} }
void fragment_main() { void fragment_main() {
@ -64,23 +34,8 @@ void main() {
} }
#version 310 es #version 310 es
uint tint_count_leading_zeros(uint v) {
uint x = uint(v);
uint b16 = ((x <= 65535u) ? 16u : 0u);
x = (x << b16);
uint b8 = ((x <= 16777215u) ? 8u : 0u);
x = (x << b8);
uint b4 = ((x <= 268435455u) ? 4u : 0u);
x = (x << b4);
uint b2 = ((x <= 1073741823u) ? 2u : 0u);
x = (x << b2);
uint b1 = ((x <= 2147483647u) ? 1u : 0u);
uint is_zero = ((x == 0u) ? 1u : 0u);
return uint((((((b16 | b8) | b4) | b2) | b1) + is_zero));
}
void countLeadingZeros_208d46() { void countLeadingZeros_208d46() {
uint res = tint_count_leading_zeros(1u); uint res = 31u;
} }
void compute_main() { void compute_main() {

View File

@ -2,7 +2,7 @@
using namespace metal; using namespace metal;
void countLeadingZeros_208d46() { void countLeadingZeros_208d46() {
uint res = clz(1u); uint res = 31u;
} }
struct tint_symbol { struct tint_symbol {

View File

@ -1,7 +1,7 @@
; SPIR-V ; SPIR-V
; Version: 1.3 ; Version: 1.3
; Generator: Google Tint Compiler; 0 ; Generator: Google Tint Compiler; 0
; Bound: 81 ; Bound: 32
; Schema: 0 ; Schema: 0
OpCapability Shader OpCapability Shader
OpMemoryModel Logical GLSL450 OpMemoryModel Logical GLSL450
@ -12,9 +12,6 @@
OpExecutionMode %compute_main LocalSize 1 1 1 OpExecutionMode %compute_main LocalSize 1 1 1
OpName %value "value" OpName %value "value"
OpName %vertex_point_size "vertex_point_size" OpName %vertex_point_size "vertex_point_size"
OpName %tint_count_leading_zeros "tint_count_leading_zeros"
OpName %v "v"
OpName %x "x"
OpName %countLeadingZeros_208d46 "countLeadingZeros_208d46" OpName %countLeadingZeros_208d46 "countLeadingZeros_208d46"
OpName %res "res" OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner" OpName %vertex_main_inner "vertex_main_inner"
@ -31,93 +28,39 @@
%_ptr_Output_float = OpTypePointer Output %float %_ptr_Output_float = OpTypePointer Output %float
%8 = OpConstantNull %float %8 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %8 %vertex_point_size = OpVariable %_ptr_Output_float Output %8
%void = OpTypeVoid
%9 = OpTypeFunction %void
%uint = OpTypeInt 32 0 %uint = OpTypeInt 32 0
%9 = OpTypeFunction %uint %uint %uint_31 = OpConstant %uint 31
%_ptr_Function_uint = OpTypePointer Function %uint %_ptr_Function_uint = OpTypePointer Function %uint
%17 = OpConstantNull %uint %17 = OpConstantNull %uint
%uint_65535 = OpConstant %uint 65535 %18 = OpTypeFunction %v4float
%bool = OpTypeBool
%uint_16 = OpConstant %uint 16
%uint_16777215 = OpConstant %uint 16777215
%uint_8 = OpConstant %uint 8
%uint_268435455 = OpConstant %uint 268435455
%uint_4 = OpConstant %uint 4
%uint_1073741823 = OpConstant %uint 1073741823
%uint_2 = OpConstant %uint 2
%uint_2147483647 = OpConstant %uint 2147483647
%uint_1 = OpConstant %uint 1
%void = OpTypeVoid
%61 = OpTypeFunction %void
%67 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1 %float_1 = OpConstant %float 1
%tint_count_leading_zeros = OpFunction %uint None %9 %countLeadingZeros_208d46 = OpFunction %void None %9
%v = OpFunctionParameter %uint %12 = OpLabel
%13 = OpLabel
%x = OpVariable %_ptr_Function_uint Function %17
OpStore %x %v
%19 = OpLoad %uint %x
%21 = OpULessThanEqual %bool %19 %uint_65535
%18 = OpSelect %uint %21 %uint_16 %17
%24 = OpLoad %uint %x
%25 = OpShiftLeftLogical %uint %24 %18
OpStore %x %25
%27 = OpLoad %uint %x
%29 = OpULessThanEqual %bool %27 %uint_16777215
%26 = OpSelect %uint %29 %uint_8 %17
%31 = OpLoad %uint %x
%32 = OpShiftLeftLogical %uint %31 %26
OpStore %x %32
%34 = OpLoad %uint %x
%36 = OpULessThanEqual %bool %34 %uint_268435455
%33 = OpSelect %uint %36 %uint_4 %17
%38 = OpLoad %uint %x
%39 = OpShiftLeftLogical %uint %38 %33
OpStore %x %39
%41 = OpLoad %uint %x
%43 = OpULessThanEqual %bool %41 %uint_1073741823
%40 = OpSelect %uint %43 %uint_2 %17
%45 = OpLoad %uint %x
%46 = OpShiftLeftLogical %uint %45 %40
OpStore %x %46
%48 = OpLoad %uint %x
%50 = OpULessThanEqual %bool %48 %uint_2147483647
%47 = OpSelect %uint %50 %uint_1 %17
%53 = OpLoad %uint %x
%54 = OpIEqual %bool %53 %17
%52 = OpSelect %uint %54 %uint_1 %17
%56 = OpBitwiseOr %uint %18 %26
%57 = OpBitwiseOr %uint %56 %33
%58 = OpBitwiseOr %uint %57 %40
%59 = OpBitwiseOr %uint %58 %47
%60 = OpIAdd %uint %59 %52
OpReturnValue %60
OpFunctionEnd
%countLeadingZeros_208d46 = OpFunction %void None %61
%64 = OpLabel
%res = OpVariable %_ptr_Function_uint Function %17 %res = OpVariable %_ptr_Function_uint Function %17
%65 = OpFunctionCall %uint %tint_count_leading_zeros %uint_1 OpStore %res %uint_31
OpStore %res %65
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%vertex_main_inner = OpFunction %v4float None %67 %vertex_main_inner = OpFunction %v4float None %18
%69 = OpLabel %20 = OpLabel
%70 = OpFunctionCall %void %countLeadingZeros_208d46 %21 = OpFunctionCall %void %countLeadingZeros_208d46
OpReturnValue %5 OpReturnValue %5
OpFunctionEnd OpFunctionEnd
%vertex_main = OpFunction %void None %61 %vertex_main = OpFunction %void None %9
%72 = OpLabel %23 = OpLabel
%73 = OpFunctionCall %v4float %vertex_main_inner %24 = OpFunctionCall %v4float %vertex_main_inner
OpStore %value %73 OpStore %value %24
OpStore %vertex_point_size %float_1 OpStore %vertex_point_size %float_1
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%fragment_main = OpFunction %void None %61 %fragment_main = OpFunction %void None %9
%76 = OpLabel %27 = OpLabel
%77 = OpFunctionCall %void %countLeadingZeros_208d46 %28 = OpFunctionCall %void %countLeadingZeros_208d46
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%compute_main = OpFunction %void None %61 %compute_main = OpFunction %void None %9
%79 = OpLabel %30 = OpLabel
%80 = OpFunctionCall %void %countLeadingZeros_208d46 %31 = OpFunctionCall %void %countLeadingZeros_208d46
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd

View File

@ -1,20 +1,5 @@
int tint_count_leading_zeros(int v) {
uint x = uint(v);
const uint b16 = ((x <= 65535u) ? 16u : 0u);
x = (x << b16);
const uint b8 = ((x <= 16777215u) ? 8u : 0u);
x = (x << b8);
const uint b4 = ((x <= 268435455u) ? 4u : 0u);
x = (x << b4);
const uint b2 = ((x <= 1073741823u) ? 2u : 0u);
x = (x << b2);
const uint b1 = ((x <= 2147483647u) ? 1u : 0u);
const uint is_zero = ((x == 0u) ? 1u : 0u);
return int((((((b16 | b8) | b4) | b2) | b1) + is_zero));
}
void countLeadingZeros_6d4656() { void countLeadingZeros_6d4656() {
int res = tint_count_leading_zeros(1); int res = 31;
} }
struct tint_symbol { struct tint_symbol {

View File

@ -1,20 +1,5 @@
int tint_count_leading_zeros(int v) {
uint x = uint(v);
const uint b16 = ((x <= 65535u) ? 16u : 0u);
x = (x << b16);
const uint b8 = ((x <= 16777215u) ? 8u : 0u);
x = (x << b8);
const uint b4 = ((x <= 268435455u) ? 4u : 0u);
x = (x << b4);
const uint b2 = ((x <= 1073741823u) ? 2u : 0u);
x = (x << b2);
const uint b1 = ((x <= 2147483647u) ? 1u : 0u);
const uint is_zero = ((x == 0u) ? 1u : 0u);
return int((((((b16 | b8) | b4) | b2) | b1) + is_zero));
}
void countLeadingZeros_6d4656() { void countLeadingZeros_6d4656() {
int res = tint_count_leading_zeros(1); int res = 31;
} }
struct tint_symbol { struct tint_symbol {

View File

@ -1,22 +1,7 @@
#version 310 es #version 310 es
int tint_count_leading_zeros(int v) {
uint x = uint(v);
uint b16 = ((x <= 65535u) ? 16u : 0u);
x = (x << b16);
uint b8 = ((x <= 16777215u) ? 8u : 0u);
x = (x << b8);
uint b4 = ((x <= 268435455u) ? 4u : 0u);
x = (x << b4);
uint b2 = ((x <= 1073741823u) ? 2u : 0u);
x = (x << b2);
uint b1 = ((x <= 2147483647u) ? 1u : 0u);
uint is_zero = ((x == 0u) ? 1u : 0u);
return int((((((b16 | b8) | b4) | b2) | b1) + is_zero));
}
void countLeadingZeros_6d4656() { void countLeadingZeros_6d4656() {
int res = tint_count_leading_zeros(1); int res = 31;
} }
vec4 vertex_main() { vec4 vertex_main() {
@ -35,23 +20,8 @@ void main() {
#version 310 es #version 310 es
precision mediump float; precision mediump float;
int tint_count_leading_zeros(int v) {
uint x = uint(v);
uint b16 = ((x <= 65535u) ? 16u : 0u);
x = (x << b16);
uint b8 = ((x <= 16777215u) ? 8u : 0u);
x = (x << b8);
uint b4 = ((x <= 268435455u) ? 4u : 0u);
x = (x << b4);
uint b2 = ((x <= 1073741823u) ? 2u : 0u);
x = (x << b2);
uint b1 = ((x <= 2147483647u) ? 1u : 0u);
uint is_zero = ((x == 0u) ? 1u : 0u);
return int((((((b16 | b8) | b4) | b2) | b1) + is_zero));
}
void countLeadingZeros_6d4656() { void countLeadingZeros_6d4656() {
int res = tint_count_leading_zeros(1); int res = 31;
} }
void fragment_main() { void fragment_main() {
@ -64,23 +34,8 @@ void main() {
} }
#version 310 es #version 310 es
int tint_count_leading_zeros(int v) {
uint x = uint(v);
uint b16 = ((x <= 65535u) ? 16u : 0u);
x = (x << b16);
uint b8 = ((x <= 16777215u) ? 8u : 0u);
x = (x << b8);
uint b4 = ((x <= 268435455u) ? 4u : 0u);
x = (x << b4);
uint b2 = ((x <= 1073741823u) ? 2u : 0u);
x = (x << b2);
uint b1 = ((x <= 2147483647u) ? 1u : 0u);
uint is_zero = ((x == 0u) ? 1u : 0u);
return int((((((b16 | b8) | b4) | b2) | b1) + is_zero));
}
void countLeadingZeros_6d4656() { void countLeadingZeros_6d4656() {
int res = tint_count_leading_zeros(1); int res = 31;
} }
void compute_main() { void compute_main() {

View File

@ -2,7 +2,7 @@
using namespace metal; using namespace metal;
void countLeadingZeros_6d4656() { void countLeadingZeros_6d4656() {
int res = clz(1); int res = 31;
} }
struct tint_symbol { struct tint_symbol {

View File

@ -1,7 +1,7 @@
; SPIR-V ; SPIR-V
; Version: 1.3 ; Version: 1.3
; Generator: Google Tint Compiler; 0 ; Generator: Google Tint Compiler; 0
; Bound: 85 ; Bound: 32
; Schema: 0 ; Schema: 0
OpCapability Shader OpCapability Shader
OpMemoryModel Logical GLSL450 OpMemoryModel Logical GLSL450
@ -12,9 +12,6 @@
OpExecutionMode %compute_main LocalSize 1 1 1 OpExecutionMode %compute_main LocalSize 1 1 1
OpName %value "value" OpName %value "value"
OpName %vertex_point_size "vertex_point_size" OpName %vertex_point_size "vertex_point_size"
OpName %tint_count_leading_zeros "tint_count_leading_zeros"
OpName %v "v"
OpName %x "x"
OpName %countLeadingZeros_6d4656 "countLeadingZeros_6d4656" OpName %countLeadingZeros_6d4656 "countLeadingZeros_6d4656"
OpName %res "res" OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner" OpName %vertex_main_inner "vertex_main_inner"
@ -31,99 +28,39 @@
%_ptr_Output_float = OpTypePointer Output %float %_ptr_Output_float = OpTypePointer Output %float
%8 = OpConstantNull %float %8 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %8 %vertex_point_size = OpVariable %_ptr_Output_float Output %8
%int = OpTypeInt 32 1
%9 = OpTypeFunction %int %int
%uint = OpTypeInt 32 0
%_ptr_Function_uint = OpTypePointer Function %uint
%18 = OpConstantNull %uint
%uint_65535 = OpConstant %uint 65535
%bool = OpTypeBool
%uint_16 = OpConstant %uint 16
%uint_16777215 = OpConstant %uint 16777215
%uint_8 = OpConstant %uint 8
%uint_268435455 = OpConstant %uint 268435455
%uint_4 = OpConstant %uint 4
%uint_1073741823 = OpConstant %uint 1073741823
%uint_2 = OpConstant %uint 2
%uint_2147483647 = OpConstant %uint 2147483647
%uint_1 = OpConstant %uint 1
%void = OpTypeVoid %void = OpTypeVoid
%62 = OpTypeFunction %void %9 = OpTypeFunction %void
%int_1 = OpConstant %int 1 %int = OpTypeInt 32 1
%int_31 = OpConstant %int 31
%_ptr_Function_int = OpTypePointer Function %int %_ptr_Function_int = OpTypePointer Function %int
%70 = OpConstantNull %int %17 = OpConstantNull %int
%71 = OpTypeFunction %v4float %18 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1 %float_1 = OpConstant %float 1
%tint_count_leading_zeros = OpFunction %int None %9 %countLeadingZeros_6d4656 = OpFunction %void None %9
%v = OpFunctionParameter %int %12 = OpLabel
%13 = OpLabel %res = OpVariable %_ptr_Function_int Function %17
%x = OpVariable %_ptr_Function_uint Function %18 OpStore %res %int_31
%14 = OpBitcast %uint %v
OpStore %x %14
%20 = OpLoad %uint %x
%22 = OpULessThanEqual %bool %20 %uint_65535
%19 = OpSelect %uint %22 %uint_16 %18
%25 = OpLoad %uint %x
%26 = OpShiftLeftLogical %uint %25 %19
OpStore %x %26
%28 = OpLoad %uint %x
%30 = OpULessThanEqual %bool %28 %uint_16777215
%27 = OpSelect %uint %30 %uint_8 %18
%32 = OpLoad %uint %x
%33 = OpShiftLeftLogical %uint %32 %27
OpStore %x %33
%35 = OpLoad %uint %x
%37 = OpULessThanEqual %bool %35 %uint_268435455
%34 = OpSelect %uint %37 %uint_4 %18
%39 = OpLoad %uint %x
%40 = OpShiftLeftLogical %uint %39 %34
OpStore %x %40
%42 = OpLoad %uint %x
%44 = OpULessThanEqual %bool %42 %uint_1073741823
%41 = OpSelect %uint %44 %uint_2 %18
%46 = OpLoad %uint %x
%47 = OpShiftLeftLogical %uint %46 %41
OpStore %x %47
%49 = OpLoad %uint %x
%51 = OpULessThanEqual %bool %49 %uint_2147483647
%48 = OpSelect %uint %51 %uint_1 %18
%54 = OpLoad %uint %x
%55 = OpIEqual %bool %54 %18
%53 = OpSelect %uint %55 %uint_1 %18
%57 = OpBitwiseOr %uint %19 %27
%58 = OpBitwiseOr %uint %57 %34
%59 = OpBitwiseOr %uint %58 %41
%60 = OpBitwiseOr %uint %59 %48
%61 = OpIAdd %uint %60 %53
%56 = OpBitcast %int %61
OpReturnValue %56
OpFunctionEnd
%countLeadingZeros_6d4656 = OpFunction %void None %62
%65 = OpLabel
%res = OpVariable %_ptr_Function_int Function %70
%66 = OpFunctionCall %int %tint_count_leading_zeros %int_1
OpStore %res %66
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%vertex_main_inner = OpFunction %v4float None %71 %vertex_main_inner = OpFunction %v4float None %18
%73 = OpLabel %20 = OpLabel
%74 = OpFunctionCall %void %countLeadingZeros_6d4656 %21 = OpFunctionCall %void %countLeadingZeros_6d4656
OpReturnValue %5 OpReturnValue %5
OpFunctionEnd OpFunctionEnd
%vertex_main = OpFunction %void None %62 %vertex_main = OpFunction %void None %9
%76 = OpLabel %23 = OpLabel
%77 = OpFunctionCall %v4float %vertex_main_inner %24 = OpFunctionCall %v4float %vertex_main_inner
OpStore %value %77 OpStore %value %24
OpStore %vertex_point_size %float_1 OpStore %vertex_point_size %float_1
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%fragment_main = OpFunction %void None %62 %fragment_main = OpFunction %void None %9
%80 = OpLabel %27 = OpLabel
%81 = OpFunctionCall %void %countLeadingZeros_6d4656 %28 = OpFunctionCall %void %countLeadingZeros_6d4656
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%compute_main = OpFunction %void None %62 %compute_main = OpFunction %void None %9
%83 = OpLabel %30 = OpLabel
%84 = OpFunctionCall %void %countLeadingZeros_6d4656 %31 = OpFunctionCall %void %countLeadingZeros_6d4656
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd

View File

@ -1,20 +1,5 @@
uint2 tint_count_leading_zeros(uint2 v) {
uint2 x = uint2(v);
const uint2 b16 = ((x <= (65535u).xx) ? (16u).xx : (0u).xx);
x = (x << b16);
const uint2 b8 = ((x <= (16777215u).xx) ? (8u).xx : (0u).xx);
x = (x << b8);
const uint2 b4 = ((x <= (268435455u).xx) ? (4u).xx : (0u).xx);
x = (x << b4);
const uint2 b2 = ((x <= (1073741823u).xx) ? (2u).xx : (0u).xx);
x = (x << b2);
const uint2 b1 = ((x <= (2147483647u).xx) ? (1u).xx : (0u).xx);
const uint2 is_zero = ((x == (0u).xx) ? (1u).xx : (0u).xx);
return uint2((((((b16 | b8) | b4) | b2) | b1) + is_zero));
}
void countLeadingZeros_70783f() { void countLeadingZeros_70783f() {
uint2 res = tint_count_leading_zeros((1u).xx); uint2 res = (31u).xx;
} }
struct tint_symbol { struct tint_symbol {

View File

@ -1,20 +1,5 @@
uint2 tint_count_leading_zeros(uint2 v) {
uint2 x = uint2(v);
const uint2 b16 = ((x <= (65535u).xx) ? (16u).xx : (0u).xx);
x = (x << b16);
const uint2 b8 = ((x <= (16777215u).xx) ? (8u).xx : (0u).xx);
x = (x << b8);
const uint2 b4 = ((x <= (268435455u).xx) ? (4u).xx : (0u).xx);
x = (x << b4);
const uint2 b2 = ((x <= (1073741823u).xx) ? (2u).xx : (0u).xx);
x = (x << b2);
const uint2 b1 = ((x <= (2147483647u).xx) ? (1u).xx : (0u).xx);
const uint2 is_zero = ((x == (0u).xx) ? (1u).xx : (0u).xx);
return uint2((((((b16 | b8) | b4) | b2) | b1) + is_zero));
}
void countLeadingZeros_70783f() { void countLeadingZeros_70783f() {
uint2 res = tint_count_leading_zeros((1u).xx); uint2 res = (31u).xx;
} }
struct tint_symbol { struct tint_symbol {

View File

@ -1,22 +1,7 @@
#version 310 es #version 310 es
uvec2 tint_count_leading_zeros(uvec2 v) {
uvec2 x = uvec2(v);
uvec2 b16 = mix(uvec2(0u), uvec2(16u), lessThanEqual(x, uvec2(65535u)));
x = (x << b16);
uvec2 b8 = mix(uvec2(0u), uvec2(8u), lessThanEqual(x, uvec2(16777215u)));
x = (x << b8);
uvec2 b4 = mix(uvec2(0u), uvec2(4u), lessThanEqual(x, uvec2(268435455u)));
x = (x << b4);
uvec2 b2 = mix(uvec2(0u), uvec2(2u), lessThanEqual(x, uvec2(1073741823u)));
x = (x << b2);
uvec2 b1 = mix(uvec2(0u), uvec2(1u), lessThanEqual(x, uvec2(2147483647u)));
uvec2 is_zero = mix(uvec2(0u), uvec2(1u), equal(x, uvec2(0u)));
return uvec2((((((b16 | b8) | b4) | b2) | b1) + is_zero));
}
void countLeadingZeros_70783f() { void countLeadingZeros_70783f() {
uvec2 res = tint_count_leading_zeros(uvec2(1u)); uvec2 res = uvec2(31u);
} }
vec4 vertex_main() { vec4 vertex_main() {
@ -35,23 +20,8 @@ void main() {
#version 310 es #version 310 es
precision mediump float; precision mediump float;
uvec2 tint_count_leading_zeros(uvec2 v) {
uvec2 x = uvec2(v);
uvec2 b16 = mix(uvec2(0u), uvec2(16u), lessThanEqual(x, uvec2(65535u)));
x = (x << b16);
uvec2 b8 = mix(uvec2(0u), uvec2(8u), lessThanEqual(x, uvec2(16777215u)));
x = (x << b8);
uvec2 b4 = mix(uvec2(0u), uvec2(4u), lessThanEqual(x, uvec2(268435455u)));
x = (x << b4);
uvec2 b2 = mix(uvec2(0u), uvec2(2u), lessThanEqual(x, uvec2(1073741823u)));
x = (x << b2);
uvec2 b1 = mix(uvec2(0u), uvec2(1u), lessThanEqual(x, uvec2(2147483647u)));
uvec2 is_zero = mix(uvec2(0u), uvec2(1u), equal(x, uvec2(0u)));
return uvec2((((((b16 | b8) | b4) | b2) | b1) + is_zero));
}
void countLeadingZeros_70783f() { void countLeadingZeros_70783f() {
uvec2 res = tint_count_leading_zeros(uvec2(1u)); uvec2 res = uvec2(31u);
} }
void fragment_main() { void fragment_main() {
@ -64,23 +34,8 @@ void main() {
} }
#version 310 es #version 310 es
uvec2 tint_count_leading_zeros(uvec2 v) {
uvec2 x = uvec2(v);
uvec2 b16 = mix(uvec2(0u), uvec2(16u), lessThanEqual(x, uvec2(65535u)));
x = (x << b16);
uvec2 b8 = mix(uvec2(0u), uvec2(8u), lessThanEqual(x, uvec2(16777215u)));
x = (x << b8);
uvec2 b4 = mix(uvec2(0u), uvec2(4u), lessThanEqual(x, uvec2(268435455u)));
x = (x << b4);
uvec2 b2 = mix(uvec2(0u), uvec2(2u), lessThanEqual(x, uvec2(1073741823u)));
x = (x << b2);
uvec2 b1 = mix(uvec2(0u), uvec2(1u), lessThanEqual(x, uvec2(2147483647u)));
uvec2 is_zero = mix(uvec2(0u), uvec2(1u), equal(x, uvec2(0u)));
return uvec2((((((b16 | b8) | b4) | b2) | b1) + is_zero));
}
void countLeadingZeros_70783f() { void countLeadingZeros_70783f() {
uvec2 res = tint_count_leading_zeros(uvec2(1u)); uvec2 res = uvec2(31u);
} }
void compute_main() { void compute_main() {

View File

@ -2,7 +2,7 @@
using namespace metal; using namespace metal;
void countLeadingZeros_70783f() { void countLeadingZeros_70783f() {
uint2 res = clz(uint2(1u)); uint2 res = uint2(31u);
} }
struct tint_symbol { struct tint_symbol {

View File

@ -1,7 +1,7 @@
; SPIR-V ; SPIR-V
; Version: 1.3 ; Version: 1.3
; Generator: Google Tint Compiler; 0 ; Generator: Google Tint Compiler; 0
; Bound: 93 ; Bound: 34
; Schema: 0 ; Schema: 0
OpCapability Shader OpCapability Shader
OpMemoryModel Logical GLSL450 OpMemoryModel Logical GLSL450
@ -12,9 +12,6 @@
OpExecutionMode %compute_main LocalSize 1 1 1 OpExecutionMode %compute_main LocalSize 1 1 1
OpName %value "value" OpName %value "value"
OpName %vertex_point_size "vertex_point_size" OpName %vertex_point_size "vertex_point_size"
OpName %tint_count_leading_zeros "tint_count_leading_zeros"
OpName %v "v"
OpName %x "x"
OpName %countLeadingZeros_70783f "countLeadingZeros_70783f" OpName %countLeadingZeros_70783f "countLeadingZeros_70783f"
OpName %res "res" OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner" OpName %vertex_main_inner "vertex_main_inner"
@ -31,105 +28,41 @@
%_ptr_Output_float = OpTypePointer Output %float %_ptr_Output_float = OpTypePointer Output %float
%8 = OpConstantNull %float %8 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %8 %vertex_point_size = OpVariable %_ptr_Output_float Output %8
%void = OpTypeVoid
%9 = OpTypeFunction %void
%uint = OpTypeInt 32 0 %uint = OpTypeInt 32 0
%v2uint = OpTypeVector %uint 2 %v2uint = OpTypeVector %uint 2
%9 = OpTypeFunction %v2uint %v2uint %uint_31 = OpConstant %uint 31
%16 = OpConstantComposite %v2uint %uint_31 %uint_31
%_ptr_Function_v2uint = OpTypePointer Function %v2uint %_ptr_Function_v2uint = OpTypePointer Function %v2uint
%18 = OpConstantNull %v2uint %19 = OpConstantNull %v2uint
%uint_65535 = OpConstant %uint 65535 %20 = OpTypeFunction %v4float
%22 = OpConstantComposite %v2uint %uint_65535 %uint_65535
%bool = OpTypeBool
%v2bool = OpTypeVector %bool 2
%uint_16 = OpConstant %uint 16
%27 = OpConstantComposite %v2uint %uint_16 %uint_16
%uint_16777215 = OpConstant %uint 16777215
%33 = OpConstantComposite %v2uint %uint_16777215 %uint_16777215
%uint_8 = OpConstant %uint 8
%36 = OpConstantComposite %v2uint %uint_8 %uint_8
%uint_268435455 = OpConstant %uint 268435455
%42 = OpConstantComposite %v2uint %uint_268435455 %uint_268435455
%uint_4 = OpConstant %uint 4
%45 = OpConstantComposite %v2uint %uint_4 %uint_4
%uint_1073741823 = OpConstant %uint 1073741823
%51 = OpConstantComposite %v2uint %uint_1073741823 %uint_1073741823
%uint_2 = OpConstant %uint 2
%54 = OpConstantComposite %v2uint %uint_2 %uint_2
%uint_2147483647 = OpConstant %uint 2147483647
%60 = OpConstantComposite %v2uint %uint_2147483647 %uint_2147483647
%uint_1 = OpConstant %uint 1
%63 = OpConstantComposite %v2uint %uint_1 %uint_1
%void = OpTypeVoid
%73 = OpTypeFunction %void
%79 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1 %float_1 = OpConstant %float 1
%tint_count_leading_zeros = OpFunction %v2uint None %9 %countLeadingZeros_70783f = OpFunction %void None %9
%v = OpFunctionParameter %v2uint %12 = OpLabel
%14 = OpLabel %res = OpVariable %_ptr_Function_v2uint Function %19
%x = OpVariable %_ptr_Function_v2uint Function %18 OpStore %res %16
OpStore %x %v
%20 = OpLoad %v2uint %x
%23 = OpULessThanEqual %v2bool %20 %22
%19 = OpSelect %v2uint %23 %27 %18
%28 = OpLoad %v2uint %x
%29 = OpShiftLeftLogical %v2uint %28 %19
OpStore %x %29
%31 = OpLoad %v2uint %x
%34 = OpULessThanEqual %v2bool %31 %33
%30 = OpSelect %v2uint %34 %36 %18
%37 = OpLoad %v2uint %x
%38 = OpShiftLeftLogical %v2uint %37 %30
OpStore %x %38
%40 = OpLoad %v2uint %x
%43 = OpULessThanEqual %v2bool %40 %42
%39 = OpSelect %v2uint %43 %45 %18
%46 = OpLoad %v2uint %x
%47 = OpShiftLeftLogical %v2uint %46 %39
OpStore %x %47
%49 = OpLoad %v2uint %x
%52 = OpULessThanEqual %v2bool %49 %51
%48 = OpSelect %v2uint %52 %54 %18
%55 = OpLoad %v2uint %x
%56 = OpShiftLeftLogical %v2uint %55 %48
OpStore %x %56
%58 = OpLoad %v2uint %x
%61 = OpULessThanEqual %v2bool %58 %60
%57 = OpSelect %v2uint %61 %63 %18
%65 = OpLoad %v2uint %x
%66 = OpIEqual %v2bool %65 %18
%64 = OpSelect %v2uint %66 %63 %18
%68 = OpBitwiseOr %v2uint %19 %30
%69 = OpBitwiseOr %v2uint %68 %39
%70 = OpBitwiseOr %v2uint %69 %48
%71 = OpBitwiseOr %v2uint %70 %57
%72 = OpIAdd %v2uint %71 %64
OpReturnValue %72
OpFunctionEnd
%countLeadingZeros_70783f = OpFunction %void None %73
%76 = OpLabel
%res = OpVariable %_ptr_Function_v2uint Function %18
%77 = OpFunctionCall %v2uint %tint_count_leading_zeros %63
OpStore %res %77
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%vertex_main_inner = OpFunction %v4float None %79 %vertex_main_inner = OpFunction %v4float None %20
%81 = OpLabel %22 = OpLabel
%82 = OpFunctionCall %void %countLeadingZeros_70783f %23 = OpFunctionCall %void %countLeadingZeros_70783f
OpReturnValue %5 OpReturnValue %5
OpFunctionEnd OpFunctionEnd
%vertex_main = OpFunction %void None %73 %vertex_main = OpFunction %void None %9
%84 = OpLabel %25 = OpLabel
%85 = OpFunctionCall %v4float %vertex_main_inner %26 = OpFunctionCall %v4float %vertex_main_inner
OpStore %value %85 OpStore %value %26
OpStore %vertex_point_size %float_1 OpStore %vertex_point_size %float_1
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%fragment_main = OpFunction %void None %73 %fragment_main = OpFunction %void None %9
%88 = OpLabel %29 = OpLabel
%89 = OpFunctionCall %void %countLeadingZeros_70783f %30 = OpFunctionCall %void %countLeadingZeros_70783f
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%compute_main = OpFunction %void None %73 %compute_main = OpFunction %void None %9
%91 = OpLabel %32 = OpLabel
%92 = OpFunctionCall %void %countLeadingZeros_70783f %33 = OpFunctionCall %void %countLeadingZeros_70783f
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd

View File

@ -1,20 +1,5 @@
int3 tint_count_leading_zeros(int3 v) {
uint3 x = uint3(v);
const uint3 b16 = ((x <= (65535u).xxx) ? (16u).xxx : (0u).xxx);
x = (x << b16);
const uint3 b8 = ((x <= (16777215u).xxx) ? (8u).xxx : (0u).xxx);
x = (x << b8);
const uint3 b4 = ((x <= (268435455u).xxx) ? (4u).xxx : (0u).xxx);
x = (x << b4);
const uint3 b2 = ((x <= (1073741823u).xxx) ? (2u).xxx : (0u).xxx);
x = (x << b2);
const uint3 b1 = ((x <= (2147483647u).xxx) ? (1u).xxx : (0u).xxx);
const uint3 is_zero = ((x == (0u).xxx) ? (1u).xxx : (0u).xxx);
return int3((((((b16 | b8) | b4) | b2) | b1) + is_zero));
}
void countLeadingZeros_7c38a6() { void countLeadingZeros_7c38a6() {
int3 res = tint_count_leading_zeros((1).xxx); int3 res = (31).xxx;
} }
struct tint_symbol { struct tint_symbol {

View File

@ -1,20 +1,5 @@
int3 tint_count_leading_zeros(int3 v) {
uint3 x = uint3(v);
const uint3 b16 = ((x <= (65535u).xxx) ? (16u).xxx : (0u).xxx);
x = (x << b16);
const uint3 b8 = ((x <= (16777215u).xxx) ? (8u).xxx : (0u).xxx);
x = (x << b8);
const uint3 b4 = ((x <= (268435455u).xxx) ? (4u).xxx : (0u).xxx);
x = (x << b4);
const uint3 b2 = ((x <= (1073741823u).xxx) ? (2u).xxx : (0u).xxx);
x = (x << b2);
const uint3 b1 = ((x <= (2147483647u).xxx) ? (1u).xxx : (0u).xxx);
const uint3 is_zero = ((x == (0u).xxx) ? (1u).xxx : (0u).xxx);
return int3((((((b16 | b8) | b4) | b2) | b1) + is_zero));
}
void countLeadingZeros_7c38a6() { void countLeadingZeros_7c38a6() {
int3 res = tint_count_leading_zeros((1).xxx); int3 res = (31).xxx;
} }
struct tint_symbol { struct tint_symbol {

View File

@ -1,22 +1,7 @@
#version 310 es #version 310 es
ivec3 tint_count_leading_zeros(ivec3 v) {
uvec3 x = uvec3(v);
uvec3 b16 = mix(uvec3(0u), uvec3(16u), lessThanEqual(x, uvec3(65535u)));
x = (x << b16);
uvec3 b8 = mix(uvec3(0u), uvec3(8u), lessThanEqual(x, uvec3(16777215u)));
x = (x << b8);
uvec3 b4 = mix(uvec3(0u), uvec3(4u), lessThanEqual(x, uvec3(268435455u)));
x = (x << b4);
uvec3 b2 = mix(uvec3(0u), uvec3(2u), lessThanEqual(x, uvec3(1073741823u)));
x = (x << b2);
uvec3 b1 = mix(uvec3(0u), uvec3(1u), lessThanEqual(x, uvec3(2147483647u)));
uvec3 is_zero = mix(uvec3(0u), uvec3(1u), equal(x, uvec3(0u)));
return ivec3((((((b16 | b8) | b4) | b2) | b1) + is_zero));
}
void countLeadingZeros_7c38a6() { void countLeadingZeros_7c38a6() {
ivec3 res = tint_count_leading_zeros(ivec3(1)); ivec3 res = ivec3(31);
} }
vec4 vertex_main() { vec4 vertex_main() {
@ -35,23 +20,8 @@ void main() {
#version 310 es #version 310 es
precision mediump float; precision mediump float;
ivec3 tint_count_leading_zeros(ivec3 v) {
uvec3 x = uvec3(v);
uvec3 b16 = mix(uvec3(0u), uvec3(16u), lessThanEqual(x, uvec3(65535u)));
x = (x << b16);
uvec3 b8 = mix(uvec3(0u), uvec3(8u), lessThanEqual(x, uvec3(16777215u)));
x = (x << b8);
uvec3 b4 = mix(uvec3(0u), uvec3(4u), lessThanEqual(x, uvec3(268435455u)));
x = (x << b4);
uvec3 b2 = mix(uvec3(0u), uvec3(2u), lessThanEqual(x, uvec3(1073741823u)));
x = (x << b2);
uvec3 b1 = mix(uvec3(0u), uvec3(1u), lessThanEqual(x, uvec3(2147483647u)));
uvec3 is_zero = mix(uvec3(0u), uvec3(1u), equal(x, uvec3(0u)));
return ivec3((((((b16 | b8) | b4) | b2) | b1) + is_zero));
}
void countLeadingZeros_7c38a6() { void countLeadingZeros_7c38a6() {
ivec3 res = tint_count_leading_zeros(ivec3(1)); ivec3 res = ivec3(31);
} }
void fragment_main() { void fragment_main() {
@ -64,23 +34,8 @@ void main() {
} }
#version 310 es #version 310 es
ivec3 tint_count_leading_zeros(ivec3 v) {
uvec3 x = uvec3(v);
uvec3 b16 = mix(uvec3(0u), uvec3(16u), lessThanEqual(x, uvec3(65535u)));
x = (x << b16);
uvec3 b8 = mix(uvec3(0u), uvec3(8u), lessThanEqual(x, uvec3(16777215u)));
x = (x << b8);
uvec3 b4 = mix(uvec3(0u), uvec3(4u), lessThanEqual(x, uvec3(268435455u)));
x = (x << b4);
uvec3 b2 = mix(uvec3(0u), uvec3(2u), lessThanEqual(x, uvec3(1073741823u)));
x = (x << b2);
uvec3 b1 = mix(uvec3(0u), uvec3(1u), lessThanEqual(x, uvec3(2147483647u)));
uvec3 is_zero = mix(uvec3(0u), uvec3(1u), equal(x, uvec3(0u)));
return ivec3((((((b16 | b8) | b4) | b2) | b1) + is_zero));
}
void countLeadingZeros_7c38a6() { void countLeadingZeros_7c38a6() {
ivec3 res = tint_count_leading_zeros(ivec3(1)); ivec3 res = ivec3(31);
} }
void compute_main() { void compute_main() {

View File

@ -2,7 +2,7 @@
using namespace metal; using namespace metal;
void countLeadingZeros_7c38a6() { void countLeadingZeros_7c38a6() {
int3 res = clz(int3(1)); int3 res = int3(31);
} }
struct tint_symbol { struct tint_symbol {

View File

@ -1,7 +1,7 @@
; SPIR-V ; SPIR-V
; Version: 1.3 ; Version: 1.3
; Generator: Google Tint Compiler; 0 ; Generator: Google Tint Compiler; 0
; Bound: 99 ; Bound: 34
; Schema: 0 ; Schema: 0
OpCapability Shader OpCapability Shader
OpMemoryModel Logical GLSL450 OpMemoryModel Logical GLSL450
@ -12,9 +12,6 @@
OpExecutionMode %compute_main LocalSize 1 1 1 OpExecutionMode %compute_main LocalSize 1 1 1
OpName %value "value" OpName %value "value"
OpName %vertex_point_size "vertex_point_size" OpName %vertex_point_size "vertex_point_size"
OpName %tint_count_leading_zeros "tint_count_leading_zeros"
OpName %v "v"
OpName %x "x"
OpName %countLeadingZeros_7c38a6 "countLeadingZeros_7c38a6" OpName %countLeadingZeros_7c38a6 "countLeadingZeros_7c38a6"
OpName %res "res" OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner" OpName %vertex_main_inner "vertex_main_inner"
@ -31,113 +28,41 @@
%_ptr_Output_float = OpTypePointer Output %float %_ptr_Output_float = OpTypePointer Output %float
%8 = OpConstantNull %float %8 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %8 %vertex_point_size = OpVariable %_ptr_Output_float Output %8
%void = OpTypeVoid
%9 = OpTypeFunction %void
%int = OpTypeInt 32 1 %int = OpTypeInt 32 1
%v3int = OpTypeVector %int 3 %v3int = OpTypeVector %int 3
%9 = OpTypeFunction %v3int %v3int %int_31 = OpConstant %int 31
%uint = OpTypeInt 32 0 %16 = OpConstantComposite %v3int %int_31 %int_31 %int_31
%v3uint = OpTypeVector %uint 3
%_ptr_Function_v3uint = OpTypePointer Function %v3uint
%20 = OpConstantNull %v3uint
%uint_65535 = OpConstant %uint 65535
%24 = OpConstantComposite %v3uint %uint_65535 %uint_65535 %uint_65535
%bool = OpTypeBool
%v3bool = OpTypeVector %bool 3
%uint_16 = OpConstant %uint 16
%29 = OpConstantComposite %v3uint %uint_16 %uint_16 %uint_16
%uint_16777215 = OpConstant %uint 16777215
%35 = OpConstantComposite %v3uint %uint_16777215 %uint_16777215 %uint_16777215
%uint_8 = OpConstant %uint 8
%38 = OpConstantComposite %v3uint %uint_8 %uint_8 %uint_8
%uint_268435455 = OpConstant %uint 268435455
%44 = OpConstantComposite %v3uint %uint_268435455 %uint_268435455 %uint_268435455
%uint_4 = OpConstant %uint 4
%47 = OpConstantComposite %v3uint %uint_4 %uint_4 %uint_4
%uint_1073741823 = OpConstant %uint 1073741823
%53 = OpConstantComposite %v3uint %uint_1073741823 %uint_1073741823 %uint_1073741823
%uint_2 = OpConstant %uint 2
%56 = OpConstantComposite %v3uint %uint_2 %uint_2 %uint_2
%uint_2147483647 = OpConstant %uint 2147483647
%62 = OpConstantComposite %v3uint %uint_2147483647 %uint_2147483647 %uint_2147483647
%uint_1 = OpConstant %uint 1
%65 = OpConstantComposite %v3uint %uint_1 %uint_1 %uint_1
%void = OpTypeVoid
%75 = OpTypeFunction %void
%int_1 = OpConstant %int 1
%81 = OpConstantComposite %v3int %int_1 %int_1 %int_1
%_ptr_Function_v3int = OpTypePointer Function %v3int %_ptr_Function_v3int = OpTypePointer Function %v3int
%84 = OpConstantNull %v3int %19 = OpConstantNull %v3int
%85 = OpTypeFunction %v4float %20 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1 %float_1 = OpConstant %float 1
%tint_count_leading_zeros = OpFunction %v3int None %9 %countLeadingZeros_7c38a6 = OpFunction %void None %9
%v = OpFunctionParameter %v3int %12 = OpLabel
%14 = OpLabel %res = OpVariable %_ptr_Function_v3int Function %19
%x = OpVariable %_ptr_Function_v3uint Function %20 OpStore %res %16
%15 = OpBitcast %v3uint %v
OpStore %x %15
%22 = OpLoad %v3uint %x
%25 = OpULessThanEqual %v3bool %22 %24
%21 = OpSelect %v3uint %25 %29 %20
%30 = OpLoad %v3uint %x
%31 = OpShiftLeftLogical %v3uint %30 %21
OpStore %x %31
%33 = OpLoad %v3uint %x
%36 = OpULessThanEqual %v3bool %33 %35
%32 = OpSelect %v3uint %36 %38 %20
%39 = OpLoad %v3uint %x
%40 = OpShiftLeftLogical %v3uint %39 %32
OpStore %x %40
%42 = OpLoad %v3uint %x
%45 = OpULessThanEqual %v3bool %42 %44
%41 = OpSelect %v3uint %45 %47 %20
%48 = OpLoad %v3uint %x
%49 = OpShiftLeftLogical %v3uint %48 %41
OpStore %x %49
%51 = OpLoad %v3uint %x
%54 = OpULessThanEqual %v3bool %51 %53
%50 = OpSelect %v3uint %54 %56 %20
%57 = OpLoad %v3uint %x
%58 = OpShiftLeftLogical %v3uint %57 %50
OpStore %x %58
%60 = OpLoad %v3uint %x
%63 = OpULessThanEqual %v3bool %60 %62
%59 = OpSelect %v3uint %63 %65 %20
%67 = OpLoad %v3uint %x
%68 = OpIEqual %v3bool %67 %20
%66 = OpSelect %v3uint %68 %65 %20
%70 = OpBitwiseOr %v3uint %21 %32
%71 = OpBitwiseOr %v3uint %70 %41
%72 = OpBitwiseOr %v3uint %71 %50
%73 = OpBitwiseOr %v3uint %72 %59
%74 = OpIAdd %v3uint %73 %66
%69 = OpBitcast %v3int %74
OpReturnValue %69
OpFunctionEnd
%countLeadingZeros_7c38a6 = OpFunction %void None %75
%78 = OpLabel
%res = OpVariable %_ptr_Function_v3int Function %84
%79 = OpFunctionCall %v3int %tint_count_leading_zeros %81
OpStore %res %79
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%vertex_main_inner = OpFunction %v4float None %85 %vertex_main_inner = OpFunction %v4float None %20
%87 = OpLabel %22 = OpLabel
%88 = OpFunctionCall %void %countLeadingZeros_7c38a6 %23 = OpFunctionCall %void %countLeadingZeros_7c38a6
OpReturnValue %5 OpReturnValue %5
OpFunctionEnd OpFunctionEnd
%vertex_main = OpFunction %void None %75 %vertex_main = OpFunction %void None %9
%90 = OpLabel %25 = OpLabel
%91 = OpFunctionCall %v4float %vertex_main_inner %26 = OpFunctionCall %v4float %vertex_main_inner
OpStore %value %91 OpStore %value %26
OpStore %vertex_point_size %float_1 OpStore %vertex_point_size %float_1
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%fragment_main = OpFunction %void None %75 %fragment_main = OpFunction %void None %9
%94 = OpLabel %29 = OpLabel
%95 = OpFunctionCall %void %countLeadingZeros_7c38a6 %30 = OpFunctionCall %void %countLeadingZeros_7c38a6
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%compute_main = OpFunction %void None %75 %compute_main = OpFunction %void None %9
%97 = OpLabel %32 = OpLabel
%98 = OpFunctionCall %void %countLeadingZeros_7c38a6 %33 = OpFunctionCall %void %countLeadingZeros_7c38a6
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd

View File

@ -1,20 +1,5 @@
int2 tint_count_leading_zeros(int2 v) {
uint2 x = uint2(v);
const uint2 b16 = ((x <= (65535u).xx) ? (16u).xx : (0u).xx);
x = (x << b16);
const uint2 b8 = ((x <= (16777215u).xx) ? (8u).xx : (0u).xx);
x = (x << b8);
const uint2 b4 = ((x <= (268435455u).xx) ? (4u).xx : (0u).xx);
x = (x << b4);
const uint2 b2 = ((x <= (1073741823u).xx) ? (2u).xx : (0u).xx);
x = (x << b2);
const uint2 b1 = ((x <= (2147483647u).xx) ? (1u).xx : (0u).xx);
const uint2 is_zero = ((x == (0u).xx) ? (1u).xx : (0u).xx);
return int2((((((b16 | b8) | b4) | b2) | b1) + is_zero));
}
void countLeadingZeros_858d40() { void countLeadingZeros_858d40() {
int2 res = tint_count_leading_zeros((1).xx); int2 res = (31).xx;
} }
struct tint_symbol { struct tint_symbol {

View File

@ -1,20 +1,5 @@
int2 tint_count_leading_zeros(int2 v) {
uint2 x = uint2(v);
const uint2 b16 = ((x <= (65535u).xx) ? (16u).xx : (0u).xx);
x = (x << b16);
const uint2 b8 = ((x <= (16777215u).xx) ? (8u).xx : (0u).xx);
x = (x << b8);
const uint2 b4 = ((x <= (268435455u).xx) ? (4u).xx : (0u).xx);
x = (x << b4);
const uint2 b2 = ((x <= (1073741823u).xx) ? (2u).xx : (0u).xx);
x = (x << b2);
const uint2 b1 = ((x <= (2147483647u).xx) ? (1u).xx : (0u).xx);
const uint2 is_zero = ((x == (0u).xx) ? (1u).xx : (0u).xx);
return int2((((((b16 | b8) | b4) | b2) | b1) + is_zero));
}
void countLeadingZeros_858d40() { void countLeadingZeros_858d40() {
int2 res = tint_count_leading_zeros((1).xx); int2 res = (31).xx;
} }
struct tint_symbol { struct tint_symbol {

View File

@ -1,22 +1,7 @@
#version 310 es #version 310 es
ivec2 tint_count_leading_zeros(ivec2 v) {
uvec2 x = uvec2(v);
uvec2 b16 = mix(uvec2(0u), uvec2(16u), lessThanEqual(x, uvec2(65535u)));
x = (x << b16);
uvec2 b8 = mix(uvec2(0u), uvec2(8u), lessThanEqual(x, uvec2(16777215u)));
x = (x << b8);
uvec2 b4 = mix(uvec2(0u), uvec2(4u), lessThanEqual(x, uvec2(268435455u)));
x = (x << b4);
uvec2 b2 = mix(uvec2(0u), uvec2(2u), lessThanEqual(x, uvec2(1073741823u)));
x = (x << b2);
uvec2 b1 = mix(uvec2(0u), uvec2(1u), lessThanEqual(x, uvec2(2147483647u)));
uvec2 is_zero = mix(uvec2(0u), uvec2(1u), equal(x, uvec2(0u)));
return ivec2((((((b16 | b8) | b4) | b2) | b1) + is_zero));
}
void countLeadingZeros_858d40() { void countLeadingZeros_858d40() {
ivec2 res = tint_count_leading_zeros(ivec2(1)); ivec2 res = ivec2(31);
} }
vec4 vertex_main() { vec4 vertex_main() {
@ -35,23 +20,8 @@ void main() {
#version 310 es #version 310 es
precision mediump float; precision mediump float;
ivec2 tint_count_leading_zeros(ivec2 v) {
uvec2 x = uvec2(v);
uvec2 b16 = mix(uvec2(0u), uvec2(16u), lessThanEqual(x, uvec2(65535u)));
x = (x << b16);
uvec2 b8 = mix(uvec2(0u), uvec2(8u), lessThanEqual(x, uvec2(16777215u)));
x = (x << b8);
uvec2 b4 = mix(uvec2(0u), uvec2(4u), lessThanEqual(x, uvec2(268435455u)));
x = (x << b4);
uvec2 b2 = mix(uvec2(0u), uvec2(2u), lessThanEqual(x, uvec2(1073741823u)));
x = (x << b2);
uvec2 b1 = mix(uvec2(0u), uvec2(1u), lessThanEqual(x, uvec2(2147483647u)));
uvec2 is_zero = mix(uvec2(0u), uvec2(1u), equal(x, uvec2(0u)));
return ivec2((((((b16 | b8) | b4) | b2) | b1) + is_zero));
}
void countLeadingZeros_858d40() { void countLeadingZeros_858d40() {
ivec2 res = tint_count_leading_zeros(ivec2(1)); ivec2 res = ivec2(31);
} }
void fragment_main() { void fragment_main() {
@ -64,23 +34,8 @@ void main() {
} }
#version 310 es #version 310 es
ivec2 tint_count_leading_zeros(ivec2 v) {
uvec2 x = uvec2(v);
uvec2 b16 = mix(uvec2(0u), uvec2(16u), lessThanEqual(x, uvec2(65535u)));
x = (x << b16);
uvec2 b8 = mix(uvec2(0u), uvec2(8u), lessThanEqual(x, uvec2(16777215u)));
x = (x << b8);
uvec2 b4 = mix(uvec2(0u), uvec2(4u), lessThanEqual(x, uvec2(268435455u)));
x = (x << b4);
uvec2 b2 = mix(uvec2(0u), uvec2(2u), lessThanEqual(x, uvec2(1073741823u)));
x = (x << b2);
uvec2 b1 = mix(uvec2(0u), uvec2(1u), lessThanEqual(x, uvec2(2147483647u)));
uvec2 is_zero = mix(uvec2(0u), uvec2(1u), equal(x, uvec2(0u)));
return ivec2((((((b16 | b8) | b4) | b2) | b1) + is_zero));
}
void countLeadingZeros_858d40() { void countLeadingZeros_858d40() {
ivec2 res = tint_count_leading_zeros(ivec2(1)); ivec2 res = ivec2(31);
} }
void compute_main() { void compute_main() {

View File

@ -2,7 +2,7 @@
using namespace metal; using namespace metal;
void countLeadingZeros_858d40() { void countLeadingZeros_858d40() {
int2 res = clz(int2(1)); int2 res = int2(31);
} }
struct tint_symbol { struct tint_symbol {

View File

@ -1,7 +1,7 @@
; SPIR-V ; SPIR-V
; Version: 1.3 ; Version: 1.3
; Generator: Google Tint Compiler; 0 ; Generator: Google Tint Compiler; 0
; Bound: 99 ; Bound: 34
; Schema: 0 ; Schema: 0
OpCapability Shader OpCapability Shader
OpMemoryModel Logical GLSL450 OpMemoryModel Logical GLSL450
@ -12,9 +12,6 @@
OpExecutionMode %compute_main LocalSize 1 1 1 OpExecutionMode %compute_main LocalSize 1 1 1
OpName %value "value" OpName %value "value"
OpName %vertex_point_size "vertex_point_size" OpName %vertex_point_size "vertex_point_size"
OpName %tint_count_leading_zeros "tint_count_leading_zeros"
OpName %v "v"
OpName %x "x"
OpName %countLeadingZeros_858d40 "countLeadingZeros_858d40" OpName %countLeadingZeros_858d40 "countLeadingZeros_858d40"
OpName %res "res" OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner" OpName %vertex_main_inner "vertex_main_inner"
@ -31,113 +28,41 @@
%_ptr_Output_float = OpTypePointer Output %float %_ptr_Output_float = OpTypePointer Output %float
%8 = OpConstantNull %float %8 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %8 %vertex_point_size = OpVariable %_ptr_Output_float Output %8
%void = OpTypeVoid
%9 = OpTypeFunction %void
%int = OpTypeInt 32 1 %int = OpTypeInt 32 1
%v2int = OpTypeVector %int 2 %v2int = OpTypeVector %int 2
%9 = OpTypeFunction %v2int %v2int %int_31 = OpConstant %int 31
%uint = OpTypeInt 32 0 %16 = OpConstantComposite %v2int %int_31 %int_31
%v2uint = OpTypeVector %uint 2
%_ptr_Function_v2uint = OpTypePointer Function %v2uint
%20 = OpConstantNull %v2uint
%uint_65535 = OpConstant %uint 65535
%24 = OpConstantComposite %v2uint %uint_65535 %uint_65535
%bool = OpTypeBool
%v2bool = OpTypeVector %bool 2
%uint_16 = OpConstant %uint 16
%29 = OpConstantComposite %v2uint %uint_16 %uint_16
%uint_16777215 = OpConstant %uint 16777215
%35 = OpConstantComposite %v2uint %uint_16777215 %uint_16777215
%uint_8 = OpConstant %uint 8
%38 = OpConstantComposite %v2uint %uint_8 %uint_8
%uint_268435455 = OpConstant %uint 268435455
%44 = OpConstantComposite %v2uint %uint_268435455 %uint_268435455
%uint_4 = OpConstant %uint 4
%47 = OpConstantComposite %v2uint %uint_4 %uint_4
%uint_1073741823 = OpConstant %uint 1073741823
%53 = OpConstantComposite %v2uint %uint_1073741823 %uint_1073741823
%uint_2 = OpConstant %uint 2
%56 = OpConstantComposite %v2uint %uint_2 %uint_2
%uint_2147483647 = OpConstant %uint 2147483647
%62 = OpConstantComposite %v2uint %uint_2147483647 %uint_2147483647
%uint_1 = OpConstant %uint 1
%65 = OpConstantComposite %v2uint %uint_1 %uint_1
%void = OpTypeVoid
%75 = OpTypeFunction %void
%int_1 = OpConstant %int 1
%81 = OpConstantComposite %v2int %int_1 %int_1
%_ptr_Function_v2int = OpTypePointer Function %v2int %_ptr_Function_v2int = OpTypePointer Function %v2int
%84 = OpConstantNull %v2int %19 = OpConstantNull %v2int
%85 = OpTypeFunction %v4float %20 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1 %float_1 = OpConstant %float 1
%tint_count_leading_zeros = OpFunction %v2int None %9 %countLeadingZeros_858d40 = OpFunction %void None %9
%v = OpFunctionParameter %v2int %12 = OpLabel
%14 = OpLabel %res = OpVariable %_ptr_Function_v2int Function %19
%x = OpVariable %_ptr_Function_v2uint Function %20 OpStore %res %16
%15 = OpBitcast %v2uint %v
OpStore %x %15
%22 = OpLoad %v2uint %x
%25 = OpULessThanEqual %v2bool %22 %24
%21 = OpSelect %v2uint %25 %29 %20
%30 = OpLoad %v2uint %x
%31 = OpShiftLeftLogical %v2uint %30 %21
OpStore %x %31
%33 = OpLoad %v2uint %x
%36 = OpULessThanEqual %v2bool %33 %35
%32 = OpSelect %v2uint %36 %38 %20
%39 = OpLoad %v2uint %x
%40 = OpShiftLeftLogical %v2uint %39 %32
OpStore %x %40
%42 = OpLoad %v2uint %x
%45 = OpULessThanEqual %v2bool %42 %44
%41 = OpSelect %v2uint %45 %47 %20
%48 = OpLoad %v2uint %x
%49 = OpShiftLeftLogical %v2uint %48 %41
OpStore %x %49
%51 = OpLoad %v2uint %x
%54 = OpULessThanEqual %v2bool %51 %53
%50 = OpSelect %v2uint %54 %56 %20
%57 = OpLoad %v2uint %x
%58 = OpShiftLeftLogical %v2uint %57 %50
OpStore %x %58
%60 = OpLoad %v2uint %x
%63 = OpULessThanEqual %v2bool %60 %62
%59 = OpSelect %v2uint %63 %65 %20
%67 = OpLoad %v2uint %x
%68 = OpIEqual %v2bool %67 %20
%66 = OpSelect %v2uint %68 %65 %20
%70 = OpBitwiseOr %v2uint %21 %32
%71 = OpBitwiseOr %v2uint %70 %41
%72 = OpBitwiseOr %v2uint %71 %50
%73 = OpBitwiseOr %v2uint %72 %59
%74 = OpIAdd %v2uint %73 %66
%69 = OpBitcast %v2int %74
OpReturnValue %69
OpFunctionEnd
%countLeadingZeros_858d40 = OpFunction %void None %75
%78 = OpLabel
%res = OpVariable %_ptr_Function_v2int Function %84
%79 = OpFunctionCall %v2int %tint_count_leading_zeros %81
OpStore %res %79
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%vertex_main_inner = OpFunction %v4float None %85 %vertex_main_inner = OpFunction %v4float None %20
%87 = OpLabel %22 = OpLabel
%88 = OpFunctionCall %void %countLeadingZeros_858d40 %23 = OpFunctionCall %void %countLeadingZeros_858d40
OpReturnValue %5 OpReturnValue %5
OpFunctionEnd OpFunctionEnd
%vertex_main = OpFunction %void None %75 %vertex_main = OpFunction %void None %9
%90 = OpLabel %25 = OpLabel
%91 = OpFunctionCall %v4float %vertex_main_inner %26 = OpFunctionCall %v4float %vertex_main_inner
OpStore %value %91 OpStore %value %26
OpStore %vertex_point_size %float_1 OpStore %vertex_point_size %float_1
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%fragment_main = OpFunction %void None %75 %fragment_main = OpFunction %void None %9
%94 = OpLabel %29 = OpLabel
%95 = OpFunctionCall %void %countLeadingZeros_858d40 %30 = OpFunctionCall %void %countLeadingZeros_858d40
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%compute_main = OpFunction %void None %75 %compute_main = OpFunction %void None %9
%97 = OpLabel %32 = OpLabel
%98 = OpFunctionCall %void %countLeadingZeros_858d40 %33 = OpFunctionCall %void %countLeadingZeros_858d40
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd

View File

@ -1,20 +1,5 @@
uint3 tint_count_leading_zeros(uint3 v) {
uint3 x = uint3(v);
const uint3 b16 = ((x <= (65535u).xxx) ? (16u).xxx : (0u).xxx);
x = (x << b16);
const uint3 b8 = ((x <= (16777215u).xxx) ? (8u).xxx : (0u).xxx);
x = (x << b8);
const uint3 b4 = ((x <= (268435455u).xxx) ? (4u).xxx : (0u).xxx);
x = (x << b4);
const uint3 b2 = ((x <= (1073741823u).xxx) ? (2u).xxx : (0u).xxx);
x = (x << b2);
const uint3 b1 = ((x <= (2147483647u).xxx) ? (1u).xxx : (0u).xxx);
const uint3 is_zero = ((x == (0u).xxx) ? (1u).xxx : (0u).xxx);
return uint3((((((b16 | b8) | b4) | b2) | b1) + is_zero));
}
void countLeadingZeros_ab6345() { void countLeadingZeros_ab6345() {
uint3 res = tint_count_leading_zeros((1u).xxx); uint3 res = (31u).xxx;
} }
struct tint_symbol { struct tint_symbol {

View File

@ -1,20 +1,5 @@
uint3 tint_count_leading_zeros(uint3 v) {
uint3 x = uint3(v);
const uint3 b16 = ((x <= (65535u).xxx) ? (16u).xxx : (0u).xxx);
x = (x << b16);
const uint3 b8 = ((x <= (16777215u).xxx) ? (8u).xxx : (0u).xxx);
x = (x << b8);
const uint3 b4 = ((x <= (268435455u).xxx) ? (4u).xxx : (0u).xxx);
x = (x << b4);
const uint3 b2 = ((x <= (1073741823u).xxx) ? (2u).xxx : (0u).xxx);
x = (x << b2);
const uint3 b1 = ((x <= (2147483647u).xxx) ? (1u).xxx : (0u).xxx);
const uint3 is_zero = ((x == (0u).xxx) ? (1u).xxx : (0u).xxx);
return uint3((((((b16 | b8) | b4) | b2) | b1) + is_zero));
}
void countLeadingZeros_ab6345() { void countLeadingZeros_ab6345() {
uint3 res = tint_count_leading_zeros((1u).xxx); uint3 res = (31u).xxx;
} }
struct tint_symbol { struct tint_symbol {

View File

@ -1,22 +1,7 @@
#version 310 es #version 310 es
uvec3 tint_count_leading_zeros(uvec3 v) {
uvec3 x = uvec3(v);
uvec3 b16 = mix(uvec3(0u), uvec3(16u), lessThanEqual(x, uvec3(65535u)));
x = (x << b16);
uvec3 b8 = mix(uvec3(0u), uvec3(8u), lessThanEqual(x, uvec3(16777215u)));
x = (x << b8);
uvec3 b4 = mix(uvec3(0u), uvec3(4u), lessThanEqual(x, uvec3(268435455u)));
x = (x << b4);
uvec3 b2 = mix(uvec3(0u), uvec3(2u), lessThanEqual(x, uvec3(1073741823u)));
x = (x << b2);
uvec3 b1 = mix(uvec3(0u), uvec3(1u), lessThanEqual(x, uvec3(2147483647u)));
uvec3 is_zero = mix(uvec3(0u), uvec3(1u), equal(x, uvec3(0u)));
return uvec3((((((b16 | b8) | b4) | b2) | b1) + is_zero));
}
void countLeadingZeros_ab6345() { void countLeadingZeros_ab6345() {
uvec3 res = tint_count_leading_zeros(uvec3(1u)); uvec3 res = uvec3(31u);
} }
vec4 vertex_main() { vec4 vertex_main() {
@ -35,23 +20,8 @@ void main() {
#version 310 es #version 310 es
precision mediump float; precision mediump float;
uvec3 tint_count_leading_zeros(uvec3 v) {
uvec3 x = uvec3(v);
uvec3 b16 = mix(uvec3(0u), uvec3(16u), lessThanEqual(x, uvec3(65535u)));
x = (x << b16);
uvec3 b8 = mix(uvec3(0u), uvec3(8u), lessThanEqual(x, uvec3(16777215u)));
x = (x << b8);
uvec3 b4 = mix(uvec3(0u), uvec3(4u), lessThanEqual(x, uvec3(268435455u)));
x = (x << b4);
uvec3 b2 = mix(uvec3(0u), uvec3(2u), lessThanEqual(x, uvec3(1073741823u)));
x = (x << b2);
uvec3 b1 = mix(uvec3(0u), uvec3(1u), lessThanEqual(x, uvec3(2147483647u)));
uvec3 is_zero = mix(uvec3(0u), uvec3(1u), equal(x, uvec3(0u)));
return uvec3((((((b16 | b8) | b4) | b2) | b1) + is_zero));
}
void countLeadingZeros_ab6345() { void countLeadingZeros_ab6345() {
uvec3 res = tint_count_leading_zeros(uvec3(1u)); uvec3 res = uvec3(31u);
} }
void fragment_main() { void fragment_main() {
@ -64,23 +34,8 @@ void main() {
} }
#version 310 es #version 310 es
uvec3 tint_count_leading_zeros(uvec3 v) {
uvec3 x = uvec3(v);
uvec3 b16 = mix(uvec3(0u), uvec3(16u), lessThanEqual(x, uvec3(65535u)));
x = (x << b16);
uvec3 b8 = mix(uvec3(0u), uvec3(8u), lessThanEqual(x, uvec3(16777215u)));
x = (x << b8);
uvec3 b4 = mix(uvec3(0u), uvec3(4u), lessThanEqual(x, uvec3(268435455u)));
x = (x << b4);
uvec3 b2 = mix(uvec3(0u), uvec3(2u), lessThanEqual(x, uvec3(1073741823u)));
x = (x << b2);
uvec3 b1 = mix(uvec3(0u), uvec3(1u), lessThanEqual(x, uvec3(2147483647u)));
uvec3 is_zero = mix(uvec3(0u), uvec3(1u), equal(x, uvec3(0u)));
return uvec3((((((b16 | b8) | b4) | b2) | b1) + is_zero));
}
void countLeadingZeros_ab6345() { void countLeadingZeros_ab6345() {
uvec3 res = tint_count_leading_zeros(uvec3(1u)); uvec3 res = uvec3(31u);
} }
void compute_main() { void compute_main() {

View File

@ -2,7 +2,7 @@
using namespace metal; using namespace metal;
void countLeadingZeros_ab6345() { void countLeadingZeros_ab6345() {
uint3 res = clz(uint3(1u)); uint3 res = uint3(31u);
} }
struct tint_symbol { struct tint_symbol {

View File

@ -1,7 +1,7 @@
; SPIR-V ; SPIR-V
; Version: 1.3 ; Version: 1.3
; Generator: Google Tint Compiler; 0 ; Generator: Google Tint Compiler; 0
; Bound: 93 ; Bound: 34
; Schema: 0 ; Schema: 0
OpCapability Shader OpCapability Shader
OpMemoryModel Logical GLSL450 OpMemoryModel Logical GLSL450
@ -12,9 +12,6 @@
OpExecutionMode %compute_main LocalSize 1 1 1 OpExecutionMode %compute_main LocalSize 1 1 1
OpName %value "value" OpName %value "value"
OpName %vertex_point_size "vertex_point_size" OpName %vertex_point_size "vertex_point_size"
OpName %tint_count_leading_zeros "tint_count_leading_zeros"
OpName %v "v"
OpName %x "x"
OpName %countLeadingZeros_ab6345 "countLeadingZeros_ab6345" OpName %countLeadingZeros_ab6345 "countLeadingZeros_ab6345"
OpName %res "res" OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner" OpName %vertex_main_inner "vertex_main_inner"
@ -31,105 +28,41 @@
%_ptr_Output_float = OpTypePointer Output %float %_ptr_Output_float = OpTypePointer Output %float
%8 = OpConstantNull %float %8 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %8 %vertex_point_size = OpVariable %_ptr_Output_float Output %8
%void = OpTypeVoid
%9 = OpTypeFunction %void
%uint = OpTypeInt 32 0 %uint = OpTypeInt 32 0
%v3uint = OpTypeVector %uint 3 %v3uint = OpTypeVector %uint 3
%9 = OpTypeFunction %v3uint %v3uint %uint_31 = OpConstant %uint 31
%16 = OpConstantComposite %v3uint %uint_31 %uint_31 %uint_31
%_ptr_Function_v3uint = OpTypePointer Function %v3uint %_ptr_Function_v3uint = OpTypePointer Function %v3uint
%18 = OpConstantNull %v3uint %19 = OpConstantNull %v3uint
%uint_65535 = OpConstant %uint 65535 %20 = OpTypeFunction %v4float
%22 = OpConstantComposite %v3uint %uint_65535 %uint_65535 %uint_65535
%bool = OpTypeBool
%v3bool = OpTypeVector %bool 3
%uint_16 = OpConstant %uint 16
%27 = OpConstantComposite %v3uint %uint_16 %uint_16 %uint_16
%uint_16777215 = OpConstant %uint 16777215
%33 = OpConstantComposite %v3uint %uint_16777215 %uint_16777215 %uint_16777215
%uint_8 = OpConstant %uint 8
%36 = OpConstantComposite %v3uint %uint_8 %uint_8 %uint_8
%uint_268435455 = OpConstant %uint 268435455
%42 = OpConstantComposite %v3uint %uint_268435455 %uint_268435455 %uint_268435455
%uint_4 = OpConstant %uint 4
%45 = OpConstantComposite %v3uint %uint_4 %uint_4 %uint_4
%uint_1073741823 = OpConstant %uint 1073741823
%51 = OpConstantComposite %v3uint %uint_1073741823 %uint_1073741823 %uint_1073741823
%uint_2 = OpConstant %uint 2
%54 = OpConstantComposite %v3uint %uint_2 %uint_2 %uint_2
%uint_2147483647 = OpConstant %uint 2147483647
%60 = OpConstantComposite %v3uint %uint_2147483647 %uint_2147483647 %uint_2147483647
%uint_1 = OpConstant %uint 1
%63 = OpConstantComposite %v3uint %uint_1 %uint_1 %uint_1
%void = OpTypeVoid
%73 = OpTypeFunction %void
%79 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1 %float_1 = OpConstant %float 1
%tint_count_leading_zeros = OpFunction %v3uint None %9 %countLeadingZeros_ab6345 = OpFunction %void None %9
%v = OpFunctionParameter %v3uint %12 = OpLabel
%14 = OpLabel %res = OpVariable %_ptr_Function_v3uint Function %19
%x = OpVariable %_ptr_Function_v3uint Function %18 OpStore %res %16
OpStore %x %v
%20 = OpLoad %v3uint %x
%23 = OpULessThanEqual %v3bool %20 %22
%19 = OpSelect %v3uint %23 %27 %18
%28 = OpLoad %v3uint %x
%29 = OpShiftLeftLogical %v3uint %28 %19
OpStore %x %29
%31 = OpLoad %v3uint %x
%34 = OpULessThanEqual %v3bool %31 %33
%30 = OpSelect %v3uint %34 %36 %18
%37 = OpLoad %v3uint %x
%38 = OpShiftLeftLogical %v3uint %37 %30
OpStore %x %38
%40 = OpLoad %v3uint %x
%43 = OpULessThanEqual %v3bool %40 %42
%39 = OpSelect %v3uint %43 %45 %18
%46 = OpLoad %v3uint %x
%47 = OpShiftLeftLogical %v3uint %46 %39
OpStore %x %47
%49 = OpLoad %v3uint %x
%52 = OpULessThanEqual %v3bool %49 %51
%48 = OpSelect %v3uint %52 %54 %18
%55 = OpLoad %v3uint %x
%56 = OpShiftLeftLogical %v3uint %55 %48
OpStore %x %56
%58 = OpLoad %v3uint %x
%61 = OpULessThanEqual %v3bool %58 %60
%57 = OpSelect %v3uint %61 %63 %18
%65 = OpLoad %v3uint %x
%66 = OpIEqual %v3bool %65 %18
%64 = OpSelect %v3uint %66 %63 %18
%68 = OpBitwiseOr %v3uint %19 %30
%69 = OpBitwiseOr %v3uint %68 %39
%70 = OpBitwiseOr %v3uint %69 %48
%71 = OpBitwiseOr %v3uint %70 %57
%72 = OpIAdd %v3uint %71 %64
OpReturnValue %72
OpFunctionEnd
%countLeadingZeros_ab6345 = OpFunction %void None %73
%76 = OpLabel
%res = OpVariable %_ptr_Function_v3uint Function %18
%77 = OpFunctionCall %v3uint %tint_count_leading_zeros %63
OpStore %res %77
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%vertex_main_inner = OpFunction %v4float None %79 %vertex_main_inner = OpFunction %v4float None %20
%81 = OpLabel %22 = OpLabel
%82 = OpFunctionCall %void %countLeadingZeros_ab6345 %23 = OpFunctionCall %void %countLeadingZeros_ab6345
OpReturnValue %5 OpReturnValue %5
OpFunctionEnd OpFunctionEnd
%vertex_main = OpFunction %void None %73 %vertex_main = OpFunction %void None %9
%84 = OpLabel %25 = OpLabel
%85 = OpFunctionCall %v4float %vertex_main_inner %26 = OpFunctionCall %v4float %vertex_main_inner
OpStore %value %85 OpStore %value %26
OpStore %vertex_point_size %float_1 OpStore %vertex_point_size %float_1
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%fragment_main = OpFunction %void None %73 %fragment_main = OpFunction %void None %9
%88 = OpLabel %29 = OpLabel
%89 = OpFunctionCall %void %countLeadingZeros_ab6345 %30 = OpFunctionCall %void %countLeadingZeros_ab6345
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%compute_main = OpFunction %void None %73 %compute_main = OpFunction %void None %9
%91 = OpLabel %32 = OpLabel
%92 = OpFunctionCall %void %countLeadingZeros_ab6345 %33 = OpFunctionCall %void %countLeadingZeros_ab6345
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd

View File

@ -1,20 +1,5 @@
int4 tint_count_leading_zeros(int4 v) {
uint4 x = uint4(v);
const uint4 b16 = ((x <= (65535u).xxxx) ? (16u).xxxx : (0u).xxxx);
x = (x << b16);
const uint4 b8 = ((x <= (16777215u).xxxx) ? (8u).xxxx : (0u).xxxx);
x = (x << b8);
const uint4 b4 = ((x <= (268435455u).xxxx) ? (4u).xxxx : (0u).xxxx);
x = (x << b4);
const uint4 b2 = ((x <= (1073741823u).xxxx) ? (2u).xxxx : (0u).xxxx);
x = (x << b2);
const uint4 b1 = ((x <= (2147483647u).xxxx) ? (1u).xxxx : (0u).xxxx);
const uint4 is_zero = ((x == (0u).xxxx) ? (1u).xxxx : (0u).xxxx);
return int4((((((b16 | b8) | b4) | b2) | b1) + is_zero));
}
void countLeadingZeros_eab32b() { void countLeadingZeros_eab32b() {
int4 res = tint_count_leading_zeros((1).xxxx); int4 res = (31).xxxx;
} }
struct tint_symbol { struct tint_symbol {

View File

@ -1,20 +1,5 @@
int4 tint_count_leading_zeros(int4 v) {
uint4 x = uint4(v);
const uint4 b16 = ((x <= (65535u).xxxx) ? (16u).xxxx : (0u).xxxx);
x = (x << b16);
const uint4 b8 = ((x <= (16777215u).xxxx) ? (8u).xxxx : (0u).xxxx);
x = (x << b8);
const uint4 b4 = ((x <= (268435455u).xxxx) ? (4u).xxxx : (0u).xxxx);
x = (x << b4);
const uint4 b2 = ((x <= (1073741823u).xxxx) ? (2u).xxxx : (0u).xxxx);
x = (x << b2);
const uint4 b1 = ((x <= (2147483647u).xxxx) ? (1u).xxxx : (0u).xxxx);
const uint4 is_zero = ((x == (0u).xxxx) ? (1u).xxxx : (0u).xxxx);
return int4((((((b16 | b8) | b4) | b2) | b1) + is_zero));
}
void countLeadingZeros_eab32b() { void countLeadingZeros_eab32b() {
int4 res = tint_count_leading_zeros((1).xxxx); int4 res = (31).xxxx;
} }
struct tint_symbol { struct tint_symbol {

View File

@ -1,22 +1,7 @@
#version 310 es #version 310 es
ivec4 tint_count_leading_zeros(ivec4 v) {
uvec4 x = uvec4(v);
uvec4 b16 = mix(uvec4(0u), uvec4(16u), lessThanEqual(x, uvec4(65535u)));
x = (x << b16);
uvec4 b8 = mix(uvec4(0u), uvec4(8u), lessThanEqual(x, uvec4(16777215u)));
x = (x << b8);
uvec4 b4 = mix(uvec4(0u), uvec4(4u), lessThanEqual(x, uvec4(268435455u)));
x = (x << b4);
uvec4 b2 = mix(uvec4(0u), uvec4(2u), lessThanEqual(x, uvec4(1073741823u)));
x = (x << b2);
uvec4 b1 = mix(uvec4(0u), uvec4(1u), lessThanEqual(x, uvec4(2147483647u)));
uvec4 is_zero = mix(uvec4(0u), uvec4(1u), equal(x, uvec4(0u)));
return ivec4((((((b16 | b8) | b4) | b2) | b1) + is_zero));
}
void countLeadingZeros_eab32b() { void countLeadingZeros_eab32b() {
ivec4 res = tint_count_leading_zeros(ivec4(1)); ivec4 res = ivec4(31);
} }
vec4 vertex_main() { vec4 vertex_main() {
@ -35,23 +20,8 @@ void main() {
#version 310 es #version 310 es
precision mediump float; precision mediump float;
ivec4 tint_count_leading_zeros(ivec4 v) {
uvec4 x = uvec4(v);
uvec4 b16 = mix(uvec4(0u), uvec4(16u), lessThanEqual(x, uvec4(65535u)));
x = (x << b16);
uvec4 b8 = mix(uvec4(0u), uvec4(8u), lessThanEqual(x, uvec4(16777215u)));
x = (x << b8);
uvec4 b4 = mix(uvec4(0u), uvec4(4u), lessThanEqual(x, uvec4(268435455u)));
x = (x << b4);
uvec4 b2 = mix(uvec4(0u), uvec4(2u), lessThanEqual(x, uvec4(1073741823u)));
x = (x << b2);
uvec4 b1 = mix(uvec4(0u), uvec4(1u), lessThanEqual(x, uvec4(2147483647u)));
uvec4 is_zero = mix(uvec4(0u), uvec4(1u), equal(x, uvec4(0u)));
return ivec4((((((b16 | b8) | b4) | b2) | b1) + is_zero));
}
void countLeadingZeros_eab32b() { void countLeadingZeros_eab32b() {
ivec4 res = tint_count_leading_zeros(ivec4(1)); ivec4 res = ivec4(31);
} }
void fragment_main() { void fragment_main() {
@ -64,23 +34,8 @@ void main() {
} }
#version 310 es #version 310 es
ivec4 tint_count_leading_zeros(ivec4 v) {
uvec4 x = uvec4(v);
uvec4 b16 = mix(uvec4(0u), uvec4(16u), lessThanEqual(x, uvec4(65535u)));
x = (x << b16);
uvec4 b8 = mix(uvec4(0u), uvec4(8u), lessThanEqual(x, uvec4(16777215u)));
x = (x << b8);
uvec4 b4 = mix(uvec4(0u), uvec4(4u), lessThanEqual(x, uvec4(268435455u)));
x = (x << b4);
uvec4 b2 = mix(uvec4(0u), uvec4(2u), lessThanEqual(x, uvec4(1073741823u)));
x = (x << b2);
uvec4 b1 = mix(uvec4(0u), uvec4(1u), lessThanEqual(x, uvec4(2147483647u)));
uvec4 is_zero = mix(uvec4(0u), uvec4(1u), equal(x, uvec4(0u)));
return ivec4((((((b16 | b8) | b4) | b2) | b1) + is_zero));
}
void countLeadingZeros_eab32b() { void countLeadingZeros_eab32b() {
ivec4 res = tint_count_leading_zeros(ivec4(1)); ivec4 res = ivec4(31);
} }
void compute_main() { void compute_main() {

View File

@ -2,7 +2,7 @@
using namespace metal; using namespace metal;
void countLeadingZeros_eab32b() { void countLeadingZeros_eab32b() {
int4 res = clz(int4(1)); int4 res = int4(31);
} }
struct tint_symbol { struct tint_symbol {

View File

@ -1,7 +1,7 @@
; SPIR-V ; SPIR-V
; Version: 1.3 ; Version: 1.3
; Generator: Google Tint Compiler; 0 ; Generator: Google Tint Compiler; 0
; Bound: 99 ; Bound: 34
; Schema: 0 ; Schema: 0
OpCapability Shader OpCapability Shader
OpMemoryModel Logical GLSL450 OpMemoryModel Logical GLSL450
@ -12,9 +12,6 @@
OpExecutionMode %compute_main LocalSize 1 1 1 OpExecutionMode %compute_main LocalSize 1 1 1
OpName %value "value" OpName %value "value"
OpName %vertex_point_size "vertex_point_size" OpName %vertex_point_size "vertex_point_size"
OpName %tint_count_leading_zeros "tint_count_leading_zeros"
OpName %v "v"
OpName %x "x"
OpName %countLeadingZeros_eab32b "countLeadingZeros_eab32b" OpName %countLeadingZeros_eab32b "countLeadingZeros_eab32b"
OpName %res "res" OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner" OpName %vertex_main_inner "vertex_main_inner"
@ -31,113 +28,41 @@
%_ptr_Output_float = OpTypePointer Output %float %_ptr_Output_float = OpTypePointer Output %float
%8 = OpConstantNull %float %8 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %8 %vertex_point_size = OpVariable %_ptr_Output_float Output %8
%void = OpTypeVoid
%9 = OpTypeFunction %void
%int = OpTypeInt 32 1 %int = OpTypeInt 32 1
%v4int = OpTypeVector %int 4 %v4int = OpTypeVector %int 4
%9 = OpTypeFunction %v4int %v4int %int_31 = OpConstant %int 31
%uint = OpTypeInt 32 0 %16 = OpConstantComposite %v4int %int_31 %int_31 %int_31 %int_31
%v4uint = OpTypeVector %uint 4
%_ptr_Function_v4uint = OpTypePointer Function %v4uint
%20 = OpConstantNull %v4uint
%uint_65535 = OpConstant %uint 65535
%24 = OpConstantComposite %v4uint %uint_65535 %uint_65535 %uint_65535 %uint_65535
%bool = OpTypeBool
%v4bool = OpTypeVector %bool 4
%uint_16 = OpConstant %uint 16
%29 = OpConstantComposite %v4uint %uint_16 %uint_16 %uint_16 %uint_16
%uint_16777215 = OpConstant %uint 16777215
%35 = OpConstantComposite %v4uint %uint_16777215 %uint_16777215 %uint_16777215 %uint_16777215
%uint_8 = OpConstant %uint 8
%38 = OpConstantComposite %v4uint %uint_8 %uint_8 %uint_8 %uint_8
%uint_268435455 = OpConstant %uint 268435455
%44 = OpConstantComposite %v4uint %uint_268435455 %uint_268435455 %uint_268435455 %uint_268435455
%uint_4 = OpConstant %uint 4
%47 = OpConstantComposite %v4uint %uint_4 %uint_4 %uint_4 %uint_4
%uint_1073741823 = OpConstant %uint 1073741823
%53 = OpConstantComposite %v4uint %uint_1073741823 %uint_1073741823 %uint_1073741823 %uint_1073741823
%uint_2 = OpConstant %uint 2
%56 = OpConstantComposite %v4uint %uint_2 %uint_2 %uint_2 %uint_2
%uint_2147483647 = OpConstant %uint 2147483647
%62 = OpConstantComposite %v4uint %uint_2147483647 %uint_2147483647 %uint_2147483647 %uint_2147483647
%uint_1 = OpConstant %uint 1
%65 = OpConstantComposite %v4uint %uint_1 %uint_1 %uint_1 %uint_1
%void = OpTypeVoid
%75 = OpTypeFunction %void
%int_1 = OpConstant %int 1
%81 = OpConstantComposite %v4int %int_1 %int_1 %int_1 %int_1
%_ptr_Function_v4int = OpTypePointer Function %v4int %_ptr_Function_v4int = OpTypePointer Function %v4int
%84 = OpConstantNull %v4int %19 = OpConstantNull %v4int
%85 = OpTypeFunction %v4float %20 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1 %float_1 = OpConstant %float 1
%tint_count_leading_zeros = OpFunction %v4int None %9 %countLeadingZeros_eab32b = OpFunction %void None %9
%v = OpFunctionParameter %v4int %12 = OpLabel
%14 = OpLabel %res = OpVariable %_ptr_Function_v4int Function %19
%x = OpVariable %_ptr_Function_v4uint Function %20 OpStore %res %16
%15 = OpBitcast %v4uint %v
OpStore %x %15
%22 = OpLoad %v4uint %x
%25 = OpULessThanEqual %v4bool %22 %24
%21 = OpSelect %v4uint %25 %29 %20
%30 = OpLoad %v4uint %x
%31 = OpShiftLeftLogical %v4uint %30 %21
OpStore %x %31
%33 = OpLoad %v4uint %x
%36 = OpULessThanEqual %v4bool %33 %35
%32 = OpSelect %v4uint %36 %38 %20
%39 = OpLoad %v4uint %x
%40 = OpShiftLeftLogical %v4uint %39 %32
OpStore %x %40
%42 = OpLoad %v4uint %x
%45 = OpULessThanEqual %v4bool %42 %44
%41 = OpSelect %v4uint %45 %47 %20
%48 = OpLoad %v4uint %x
%49 = OpShiftLeftLogical %v4uint %48 %41
OpStore %x %49
%51 = OpLoad %v4uint %x
%54 = OpULessThanEqual %v4bool %51 %53
%50 = OpSelect %v4uint %54 %56 %20
%57 = OpLoad %v4uint %x
%58 = OpShiftLeftLogical %v4uint %57 %50
OpStore %x %58
%60 = OpLoad %v4uint %x
%63 = OpULessThanEqual %v4bool %60 %62
%59 = OpSelect %v4uint %63 %65 %20
%67 = OpLoad %v4uint %x
%68 = OpIEqual %v4bool %67 %20
%66 = OpSelect %v4uint %68 %65 %20
%70 = OpBitwiseOr %v4uint %21 %32
%71 = OpBitwiseOr %v4uint %70 %41
%72 = OpBitwiseOr %v4uint %71 %50
%73 = OpBitwiseOr %v4uint %72 %59
%74 = OpIAdd %v4uint %73 %66
%69 = OpBitcast %v4int %74
OpReturnValue %69
OpFunctionEnd
%countLeadingZeros_eab32b = OpFunction %void None %75
%78 = OpLabel
%res = OpVariable %_ptr_Function_v4int Function %84
%79 = OpFunctionCall %v4int %tint_count_leading_zeros %81
OpStore %res %79
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%vertex_main_inner = OpFunction %v4float None %85 %vertex_main_inner = OpFunction %v4float None %20
%87 = OpLabel %22 = OpLabel
%88 = OpFunctionCall %void %countLeadingZeros_eab32b %23 = OpFunctionCall %void %countLeadingZeros_eab32b
OpReturnValue %5 OpReturnValue %5
OpFunctionEnd OpFunctionEnd
%vertex_main = OpFunction %void None %75 %vertex_main = OpFunction %void None %9
%90 = OpLabel %25 = OpLabel
%91 = OpFunctionCall %v4float %vertex_main_inner %26 = OpFunctionCall %v4float %vertex_main_inner
OpStore %value %91 OpStore %value %26
OpStore %vertex_point_size %float_1 OpStore %vertex_point_size %float_1
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%fragment_main = OpFunction %void None %75 %fragment_main = OpFunction %void None %9
%94 = OpLabel %29 = OpLabel
%95 = OpFunctionCall %void %countLeadingZeros_eab32b %30 = OpFunctionCall %void %countLeadingZeros_eab32b
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%compute_main = OpFunction %void None %75 %compute_main = OpFunction %void None %9
%97 = OpLabel %32 = OpLabel
%98 = OpFunctionCall %void %countLeadingZeros_eab32b %33 = OpFunctionCall %void %countLeadingZeros_eab32b
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd

View File

@ -1,20 +1,5 @@
uint4 tint_count_leading_zeros(uint4 v) {
uint4 x = uint4(v);
const uint4 b16 = ((x <= (65535u).xxxx) ? (16u).xxxx : (0u).xxxx);
x = (x << b16);
const uint4 b8 = ((x <= (16777215u).xxxx) ? (8u).xxxx : (0u).xxxx);
x = (x << b8);
const uint4 b4 = ((x <= (268435455u).xxxx) ? (4u).xxxx : (0u).xxxx);
x = (x << b4);
const uint4 b2 = ((x <= (1073741823u).xxxx) ? (2u).xxxx : (0u).xxxx);
x = (x << b2);
const uint4 b1 = ((x <= (2147483647u).xxxx) ? (1u).xxxx : (0u).xxxx);
const uint4 is_zero = ((x == (0u).xxxx) ? (1u).xxxx : (0u).xxxx);
return uint4((((((b16 | b8) | b4) | b2) | b1) + is_zero));
}
void countLeadingZeros_f70103() { void countLeadingZeros_f70103() {
uint4 res = tint_count_leading_zeros((1u).xxxx); uint4 res = (31u).xxxx;
} }
struct tint_symbol { struct tint_symbol {

View File

@ -1,20 +1,5 @@
uint4 tint_count_leading_zeros(uint4 v) {
uint4 x = uint4(v);
const uint4 b16 = ((x <= (65535u).xxxx) ? (16u).xxxx : (0u).xxxx);
x = (x << b16);
const uint4 b8 = ((x <= (16777215u).xxxx) ? (8u).xxxx : (0u).xxxx);
x = (x << b8);
const uint4 b4 = ((x <= (268435455u).xxxx) ? (4u).xxxx : (0u).xxxx);
x = (x << b4);
const uint4 b2 = ((x <= (1073741823u).xxxx) ? (2u).xxxx : (0u).xxxx);
x = (x << b2);
const uint4 b1 = ((x <= (2147483647u).xxxx) ? (1u).xxxx : (0u).xxxx);
const uint4 is_zero = ((x == (0u).xxxx) ? (1u).xxxx : (0u).xxxx);
return uint4((((((b16 | b8) | b4) | b2) | b1) + is_zero));
}
void countLeadingZeros_f70103() { void countLeadingZeros_f70103() {
uint4 res = tint_count_leading_zeros((1u).xxxx); uint4 res = (31u).xxxx;
} }
struct tint_symbol { struct tint_symbol {

View File

@ -1,22 +1,7 @@
#version 310 es #version 310 es
uvec4 tint_count_leading_zeros(uvec4 v) {
uvec4 x = uvec4(v);
uvec4 b16 = mix(uvec4(0u), uvec4(16u), lessThanEqual(x, uvec4(65535u)));
x = (x << b16);
uvec4 b8 = mix(uvec4(0u), uvec4(8u), lessThanEqual(x, uvec4(16777215u)));
x = (x << b8);
uvec4 b4 = mix(uvec4(0u), uvec4(4u), lessThanEqual(x, uvec4(268435455u)));
x = (x << b4);
uvec4 b2 = mix(uvec4(0u), uvec4(2u), lessThanEqual(x, uvec4(1073741823u)));
x = (x << b2);
uvec4 b1 = mix(uvec4(0u), uvec4(1u), lessThanEqual(x, uvec4(2147483647u)));
uvec4 is_zero = mix(uvec4(0u), uvec4(1u), equal(x, uvec4(0u)));
return uvec4((((((b16 | b8) | b4) | b2) | b1) + is_zero));
}
void countLeadingZeros_f70103() { void countLeadingZeros_f70103() {
uvec4 res = tint_count_leading_zeros(uvec4(1u)); uvec4 res = uvec4(31u);
} }
vec4 vertex_main() { vec4 vertex_main() {
@ -35,23 +20,8 @@ void main() {
#version 310 es #version 310 es
precision mediump float; precision mediump float;
uvec4 tint_count_leading_zeros(uvec4 v) {
uvec4 x = uvec4(v);
uvec4 b16 = mix(uvec4(0u), uvec4(16u), lessThanEqual(x, uvec4(65535u)));
x = (x << b16);
uvec4 b8 = mix(uvec4(0u), uvec4(8u), lessThanEqual(x, uvec4(16777215u)));
x = (x << b8);
uvec4 b4 = mix(uvec4(0u), uvec4(4u), lessThanEqual(x, uvec4(268435455u)));
x = (x << b4);
uvec4 b2 = mix(uvec4(0u), uvec4(2u), lessThanEqual(x, uvec4(1073741823u)));
x = (x << b2);
uvec4 b1 = mix(uvec4(0u), uvec4(1u), lessThanEqual(x, uvec4(2147483647u)));
uvec4 is_zero = mix(uvec4(0u), uvec4(1u), equal(x, uvec4(0u)));
return uvec4((((((b16 | b8) | b4) | b2) | b1) + is_zero));
}
void countLeadingZeros_f70103() { void countLeadingZeros_f70103() {
uvec4 res = tint_count_leading_zeros(uvec4(1u)); uvec4 res = uvec4(31u);
} }
void fragment_main() { void fragment_main() {
@ -64,23 +34,8 @@ void main() {
} }
#version 310 es #version 310 es
uvec4 tint_count_leading_zeros(uvec4 v) {
uvec4 x = uvec4(v);
uvec4 b16 = mix(uvec4(0u), uvec4(16u), lessThanEqual(x, uvec4(65535u)));
x = (x << b16);
uvec4 b8 = mix(uvec4(0u), uvec4(8u), lessThanEqual(x, uvec4(16777215u)));
x = (x << b8);
uvec4 b4 = mix(uvec4(0u), uvec4(4u), lessThanEqual(x, uvec4(268435455u)));
x = (x << b4);
uvec4 b2 = mix(uvec4(0u), uvec4(2u), lessThanEqual(x, uvec4(1073741823u)));
x = (x << b2);
uvec4 b1 = mix(uvec4(0u), uvec4(1u), lessThanEqual(x, uvec4(2147483647u)));
uvec4 is_zero = mix(uvec4(0u), uvec4(1u), equal(x, uvec4(0u)));
return uvec4((((((b16 | b8) | b4) | b2) | b1) + is_zero));
}
void countLeadingZeros_f70103() { void countLeadingZeros_f70103() {
uvec4 res = tint_count_leading_zeros(uvec4(1u)); uvec4 res = uvec4(31u);
} }
void compute_main() { void compute_main() {

View File

@ -2,7 +2,7 @@
using namespace metal; using namespace metal;
void countLeadingZeros_f70103() { void countLeadingZeros_f70103() {
uint4 res = clz(uint4(1u)); uint4 res = uint4(31u);
} }
struct tint_symbol { struct tint_symbol {

View File

@ -1,7 +1,7 @@
; SPIR-V ; SPIR-V
; Version: 1.3 ; Version: 1.3
; Generator: Google Tint Compiler; 0 ; Generator: Google Tint Compiler; 0
; Bound: 93 ; Bound: 34
; Schema: 0 ; Schema: 0
OpCapability Shader OpCapability Shader
OpMemoryModel Logical GLSL450 OpMemoryModel Logical GLSL450
@ -12,9 +12,6 @@
OpExecutionMode %compute_main LocalSize 1 1 1 OpExecutionMode %compute_main LocalSize 1 1 1
OpName %value "value" OpName %value "value"
OpName %vertex_point_size "vertex_point_size" OpName %vertex_point_size "vertex_point_size"
OpName %tint_count_leading_zeros "tint_count_leading_zeros"
OpName %v "v"
OpName %x "x"
OpName %countLeadingZeros_f70103 "countLeadingZeros_f70103" OpName %countLeadingZeros_f70103 "countLeadingZeros_f70103"
OpName %res "res" OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner" OpName %vertex_main_inner "vertex_main_inner"
@ -31,105 +28,41 @@
%_ptr_Output_float = OpTypePointer Output %float %_ptr_Output_float = OpTypePointer Output %float
%8 = OpConstantNull %float %8 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %8 %vertex_point_size = OpVariable %_ptr_Output_float Output %8
%void = OpTypeVoid
%9 = OpTypeFunction %void
%uint = OpTypeInt 32 0 %uint = OpTypeInt 32 0
%v4uint = OpTypeVector %uint 4 %v4uint = OpTypeVector %uint 4
%9 = OpTypeFunction %v4uint %v4uint %uint_31 = OpConstant %uint 31
%16 = OpConstantComposite %v4uint %uint_31 %uint_31 %uint_31 %uint_31
%_ptr_Function_v4uint = OpTypePointer Function %v4uint %_ptr_Function_v4uint = OpTypePointer Function %v4uint
%18 = OpConstantNull %v4uint %19 = OpConstantNull %v4uint
%uint_65535 = OpConstant %uint 65535 %20 = OpTypeFunction %v4float
%22 = OpConstantComposite %v4uint %uint_65535 %uint_65535 %uint_65535 %uint_65535
%bool = OpTypeBool
%v4bool = OpTypeVector %bool 4
%uint_16 = OpConstant %uint 16
%27 = OpConstantComposite %v4uint %uint_16 %uint_16 %uint_16 %uint_16
%uint_16777215 = OpConstant %uint 16777215
%33 = OpConstantComposite %v4uint %uint_16777215 %uint_16777215 %uint_16777215 %uint_16777215
%uint_8 = OpConstant %uint 8
%36 = OpConstantComposite %v4uint %uint_8 %uint_8 %uint_8 %uint_8
%uint_268435455 = OpConstant %uint 268435455
%42 = OpConstantComposite %v4uint %uint_268435455 %uint_268435455 %uint_268435455 %uint_268435455
%uint_4 = OpConstant %uint 4
%45 = OpConstantComposite %v4uint %uint_4 %uint_4 %uint_4 %uint_4
%uint_1073741823 = OpConstant %uint 1073741823
%51 = OpConstantComposite %v4uint %uint_1073741823 %uint_1073741823 %uint_1073741823 %uint_1073741823
%uint_2 = OpConstant %uint 2
%54 = OpConstantComposite %v4uint %uint_2 %uint_2 %uint_2 %uint_2
%uint_2147483647 = OpConstant %uint 2147483647
%60 = OpConstantComposite %v4uint %uint_2147483647 %uint_2147483647 %uint_2147483647 %uint_2147483647
%uint_1 = OpConstant %uint 1
%63 = OpConstantComposite %v4uint %uint_1 %uint_1 %uint_1 %uint_1
%void = OpTypeVoid
%73 = OpTypeFunction %void
%79 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1 %float_1 = OpConstant %float 1
%tint_count_leading_zeros = OpFunction %v4uint None %9 %countLeadingZeros_f70103 = OpFunction %void None %9
%v = OpFunctionParameter %v4uint %12 = OpLabel
%14 = OpLabel %res = OpVariable %_ptr_Function_v4uint Function %19
%x = OpVariable %_ptr_Function_v4uint Function %18 OpStore %res %16
OpStore %x %v
%20 = OpLoad %v4uint %x
%23 = OpULessThanEqual %v4bool %20 %22
%19 = OpSelect %v4uint %23 %27 %18
%28 = OpLoad %v4uint %x
%29 = OpShiftLeftLogical %v4uint %28 %19
OpStore %x %29
%31 = OpLoad %v4uint %x
%34 = OpULessThanEqual %v4bool %31 %33
%30 = OpSelect %v4uint %34 %36 %18
%37 = OpLoad %v4uint %x
%38 = OpShiftLeftLogical %v4uint %37 %30
OpStore %x %38
%40 = OpLoad %v4uint %x
%43 = OpULessThanEqual %v4bool %40 %42
%39 = OpSelect %v4uint %43 %45 %18
%46 = OpLoad %v4uint %x
%47 = OpShiftLeftLogical %v4uint %46 %39
OpStore %x %47
%49 = OpLoad %v4uint %x
%52 = OpULessThanEqual %v4bool %49 %51
%48 = OpSelect %v4uint %52 %54 %18
%55 = OpLoad %v4uint %x
%56 = OpShiftLeftLogical %v4uint %55 %48
OpStore %x %56
%58 = OpLoad %v4uint %x
%61 = OpULessThanEqual %v4bool %58 %60
%57 = OpSelect %v4uint %61 %63 %18
%65 = OpLoad %v4uint %x
%66 = OpIEqual %v4bool %65 %18
%64 = OpSelect %v4uint %66 %63 %18
%68 = OpBitwiseOr %v4uint %19 %30
%69 = OpBitwiseOr %v4uint %68 %39
%70 = OpBitwiseOr %v4uint %69 %48
%71 = OpBitwiseOr %v4uint %70 %57
%72 = OpIAdd %v4uint %71 %64
OpReturnValue %72
OpFunctionEnd
%countLeadingZeros_f70103 = OpFunction %void None %73
%76 = OpLabel
%res = OpVariable %_ptr_Function_v4uint Function %18
%77 = OpFunctionCall %v4uint %tint_count_leading_zeros %63
OpStore %res %77
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%vertex_main_inner = OpFunction %v4float None %79 %vertex_main_inner = OpFunction %v4float None %20
%81 = OpLabel %22 = OpLabel
%82 = OpFunctionCall %void %countLeadingZeros_f70103 %23 = OpFunctionCall %void %countLeadingZeros_f70103
OpReturnValue %5 OpReturnValue %5
OpFunctionEnd OpFunctionEnd
%vertex_main = OpFunction %void None %73 %vertex_main = OpFunction %void None %9
%84 = OpLabel %25 = OpLabel
%85 = OpFunctionCall %v4float %vertex_main_inner %26 = OpFunctionCall %v4float %vertex_main_inner
OpStore %value %85 OpStore %value %26
OpStore %vertex_point_size %float_1 OpStore %vertex_point_size %float_1
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%fragment_main = OpFunction %void None %73 %fragment_main = OpFunction %void None %9
%88 = OpLabel %29 = OpLabel
%89 = OpFunctionCall %void %countLeadingZeros_f70103 %30 = OpFunctionCall %void %countLeadingZeros_f70103
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd
%compute_main = OpFunction %void None %73 %compute_main = OpFunction %void None %9
%91 = OpLabel %32 = OpLabel
%92 = OpFunctionCall %void %countLeadingZeros_f70103 %33 = OpFunctionCall %void %countLeadingZeros_f70103
OpReturn OpReturn
OpFunctionEnd OpFunctionEnd