diff --git a/src/tint/intrinsics.def b/src/tint/intrinsics.def index 14b00f87e8..f497405ee0 100644 --- a/src/tint/intrinsics.def +++ b/src/tint/intrinsics.def @@ -520,8 +520,8 @@ fn radians(T) -> T fn radians(vec) -> vec fn reflect(vec, vec) -> vec fn refract(vec, vec, T) -> vec -fn reverseBits(T) -> T -fn reverseBits(vec) -> vec +@const fn reverseBits(T) -> T +@const fn reverseBits(vec) -> vec fn round(T) -> T fn round(vec) -> vec @const fn saturate(@test_value(2) T) -> T diff --git a/src/tint/resolver/const_eval.cc b/src/tint/resolver/const_eval.cc index b8c4d5635a..2554dc8a90 100644 --- a/src/tint/resolver/const_eval.cc +++ b/src/tint/resolver/const_eval.cc @@ -1822,7 +1822,7 @@ ConstEval::Result ConstEval::extractBits(const sem::Type* ty, // Only need to set other bits if bit at c - 1 of result is 1 if ((r & (UT{1} << (c - UT{1}))) != UT{0}) { UT dst_mask = src_mask >> o; - r = r | (~UT{0} & ~dst_mask); + r |= (~UT{0} & ~dst_mask); } } @@ -1956,9 +1956,9 @@ ConstEval::Result ConstEval::insertBits(const sem::Type* ty, // newbits. Other bits of the result are copied from e. UT from = newbits << o; UT mask = ((UT{1} << c) - UT{1}) << UT{o}; - auto r = e; // Start with 'e' as the result - r = r & ~mask; // Zero the bits in 'e' we're overwriting - r = r | (from & mask); // Overwrite from 'newbits' (shifted into position) + auto r = e; // Start with 'e' as the result + r &= ~mask; // Zero the bits in 'e' we're overwriting + r |= (from & mask); // Overwrite from 'newbits' (shifted into position) result = NumberT{r}; } @@ -1969,6 +1969,33 @@ ConstEval::Result ConstEval::insertBits(const sem::Type* ty, return TransformElements(builder, ty, transform, args[0], args[1]); } +ConstEval::Result ConstEval::reverseBits(const sem::Type* ty, + utils::VectorRef args, + const Source&) { + auto transform = [&](const sem::Constant* c0) { + auto create = [&](auto in_e) -> ImplResult { + using NumberT = decltype(in_e); + using T = UnwrapNumber; + using UT = std::make_unsigned_t; + constexpr UT kNumBits = sizeof(UT) * 8; + + UT e = static_cast(in_e); + UT r = UT{0}; + for (size_t s = 0; s < kNumBits; ++s) { + // Write source 's' bit to destination 'd' bit if 1 + if (e & (UT{1} << s)) { + size_t d = kNumBits - s - 1; + r |= (UT{1} << d); + } + } + + return CreateElement(builder, c0->Type(), NumberT{r}); + }; + return Dispatch_iu32(create, c0); + }; + return TransformElements(builder, ty, transform, args[0]); +} + ConstEval::Result ConstEval::saturate(const sem::Type* ty, utils::VectorRef args, const Source&) { diff --git a/src/tint/resolver/const_eval.h b/src/tint/resolver/const_eval.h index a2a2dd15b0..f3091505a3 100644 --- a/src/tint/resolver/const_eval.h +++ b/src/tint/resolver/const_eval.h @@ -509,8 +509,8 @@ class ConstEval { /// @param source the source location of the conversion /// @return the result value, or null if the value cannot be calculated Result extractBits(const sem::Type* ty, - utils::VectorRef args, - const Source& source); + utils::VectorRef args, + const Source& source); /// firstLeadingBit builtin /// @param ty the expression type @@ -548,6 +548,15 @@ class ConstEval { utils::VectorRef args, const Source& source); + /// reverseBits 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 reverseBits(const sem::Type* ty, + utils::VectorRef args, + const Source& source); + /// saturate builtin /// @param ty the expression type /// @param args the input arguments diff --git a/src/tint/resolver/const_eval_builtin_test.cc b/src/tint/resolver/const_eval_builtin_test.cc index be01921eb6..74ac16f143 100644 --- a/src/tint/resolver/const_eval_builtin_test.cc +++ b/src/tint/resolver/const_eval_builtin_test.cc @@ -1106,6 +1106,52 @@ INSTANTIATE_TEST_SUITE_P(ExtractBits, std::make_tuple(1000, 1000), // std::make_tuple(u32::Highest(), u32::Highest()))); +template +std::vector ReverseBitsCases() { + using B = BitValues; + return { + C({T(0)}, T(0)), + + C({B::Lsh(1, 0)}, B::Lsh(1, 31)), // + C({B::Lsh(1, 1)}, B::Lsh(1, 30)), // + C({B::Lsh(1, 2)}, B::Lsh(1, 29)), // + C({B::Lsh(1, 3)}, B::Lsh(1, 28)), // + C({B::Lsh(1, 4)}, B::Lsh(1, 27)), // + //... + C({B::Lsh(1, 27)}, B::Lsh(1, 4)), // + C({B::Lsh(1, 28)}, B::Lsh(1, 3)), // + C({B::Lsh(1, 29)}, B::Lsh(1, 2)), // + C({B::Lsh(1, 30)}, B::Lsh(1, 1)), // + C({B::Lsh(1, 31)}, B::Lsh(1, 0)), // + + C({/**/ T(0b00010001000100010000000000000000)}, + /* */ T(0b00000000000000001000100010001000)), + + C({/**/ T(0b00011000000110000000000000000000)}, + /* */ T(0b00000000000000000001100000011000)), + + C({/**/ T(0b00000100000000001111111111111111)}, + /* */ T(0b11111111111111110000000000100000)), + + C({/**/ T(0b10010101111000110000011111101010)}, + /* */ T(0b01010111111000001100011110101001)), + + // Vector tests + C({/**/ Vec(T(0b00010001000100010000000000000000), // + T(0b00011000000110000000000000000000), // + T(0b00000000000000001111111111111111))}, + /* */ Vec(T(0b00000000000000001000100010001000), // + T(0b00000000000000000001100000011000), // + T(0b11111111111111110000000000000000))), + }; +} +INSTANTIATE_TEST_SUITE_P( // + ReverseBits, + ResolverConstEvalBuiltinTest, + testing::Combine(testing::Values(sem::BuiltinType::kReverseBits), + testing::ValuesIn(Concat(ReverseBitsCases(), // + ReverseBitsCases())))); + template std::vector SaturateCases() { return { diff --git a/src/tint/resolver/intrinsic_table.inl b/src/tint/resolver/intrinsic_table.inl index 307843cdac..ddce1ba7af 100644 --- a/src/tint/resolver/intrinsic_table.inl +++ b/src/tint/resolver/intrinsic_table.inl @@ -12398,7 +12398,7 @@ constexpr OverloadInfo kOverloads[] = { /* parameters */ &kParameters[869], /* return matcher indices */ &kMatcherIndices[1], /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), - /* const eval */ nullptr, + /* const eval */ &ConstEval::reverseBits, }, { /* [339] */ @@ -12410,7 +12410,7 @@ constexpr OverloadInfo kOverloads[] = { /* parameters */ &kParameters[868], /* return matcher indices */ &kMatcherIndices[30], /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline), - /* const eval */ nullptr, + /* const eval */ &ConstEval::reverseBits, }, { /* [340] */ diff --git a/test/tint/builtins/gen/literal/reverseBits/222177.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/reverseBits/222177.wgsl.expected.dxc.hlsl index 2ea66b6d08..e62cccb2ed 100644 --- a/test/tint/builtins/gen/literal/reverseBits/222177.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/reverseBits/222177.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void reverseBits_222177() { - int2 res = asint(reversebits(asuint((1).xx))); + int2 res = (-2147483648).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/reverseBits/222177.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/reverseBits/222177.wgsl.expected.fxc.hlsl index 2ea66b6d08..e62cccb2ed 100644 --- a/test/tint/builtins/gen/literal/reverseBits/222177.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/reverseBits/222177.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void reverseBits_222177() { - int2 res = asint(reversebits(asuint((1).xx))); + int2 res = (-2147483648).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/reverseBits/222177.wgsl.expected.glsl b/test/tint/builtins/gen/literal/reverseBits/222177.wgsl.expected.glsl index 599d35ac8e..317a798e32 100644 --- a/test/tint/builtins/gen/literal/reverseBits/222177.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/reverseBits/222177.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void reverseBits_222177() { - ivec2 res = bitfieldReverse(ivec2(1)); + ivec2 res = ivec2(-2147483648); } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void reverseBits_222177() { - ivec2 res = bitfieldReverse(ivec2(1)); + ivec2 res = ivec2(-2147483648); } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void reverseBits_222177() { - ivec2 res = bitfieldReverse(ivec2(1)); + ivec2 res = ivec2(-2147483648); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/reverseBits/222177.wgsl.expected.msl b/test/tint/builtins/gen/literal/reverseBits/222177.wgsl.expected.msl index a9283f6c7b..517d05b42d 100644 --- a/test/tint/builtins/gen/literal/reverseBits/222177.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/reverseBits/222177.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void reverseBits_222177() { - int2 res = reverse_bits(int2(1)); + int2 res = int2((-2147483647 - 1)); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/reverseBits/222177.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/reverseBits/222177.wgsl.expected.spvasm index 7fe7741e33..1428353a72 100644 --- a/test/tint/builtins/gen/literal/reverseBits/222177.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/reverseBits/222177.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 35 +; Bound: 34 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -32,38 +32,37 @@ %9 = OpTypeFunction %void %int = OpTypeInt 32 1 %v2int = OpTypeVector %int 2 - %int_1 = OpConstant %int 1 - %17 = OpConstantComposite %v2int %int_1 %int_1 +%int_n2147483648 = OpConstant %int -2147483648 + %16 = OpConstantComposite %v2int %int_n2147483648 %int_n2147483648 %_ptr_Function_v2int = OpTypePointer Function %v2int - %20 = OpConstantNull %v2int - %21 = OpTypeFunction %v4float + %19 = OpConstantNull %v2int + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %reverseBits_222177 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v2int Function %20 - %13 = OpBitReverse %v2int %17 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v2int Function %19 + OpStore %res %16 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %21 - %23 = OpLabel - %24 = OpFunctionCall %void %reverseBits_222177 +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %reverseBits_222177 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %27 + %25 = OpLabel + %26 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %26 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %30 = OpLabel - %31 = OpFunctionCall %void %reverseBits_222177 + %29 = OpLabel + %30 = OpFunctionCall %void %reverseBits_222177 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %33 = OpLabel - %34 = OpFunctionCall %void %reverseBits_222177 + %32 = OpLabel + %33 = OpFunctionCall %void %reverseBits_222177 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/reverseBits/35fea9.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/reverseBits/35fea9.wgsl.expected.dxc.hlsl index dab85fe998..ced6ec0e5f 100644 --- a/test/tint/builtins/gen/literal/reverseBits/35fea9.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/reverseBits/35fea9.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void reverseBits_35fea9() { - uint4 res = reversebits((1u).xxxx); + uint4 res = (2147483648u).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/reverseBits/35fea9.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/reverseBits/35fea9.wgsl.expected.fxc.hlsl index dab85fe998..ced6ec0e5f 100644 --- a/test/tint/builtins/gen/literal/reverseBits/35fea9.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/reverseBits/35fea9.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void reverseBits_35fea9() { - uint4 res = reversebits((1u).xxxx); + uint4 res = (2147483648u).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/reverseBits/35fea9.wgsl.expected.glsl b/test/tint/builtins/gen/literal/reverseBits/35fea9.wgsl.expected.glsl index cf80319482..ca78653fa6 100644 --- a/test/tint/builtins/gen/literal/reverseBits/35fea9.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/reverseBits/35fea9.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void reverseBits_35fea9() { - uvec4 res = bitfieldReverse(uvec4(1u)); + uvec4 res = uvec4(2147483648u); } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void reverseBits_35fea9() { - uvec4 res = bitfieldReverse(uvec4(1u)); + uvec4 res = uvec4(2147483648u); } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void reverseBits_35fea9() { - uvec4 res = bitfieldReverse(uvec4(1u)); + uvec4 res = uvec4(2147483648u); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/reverseBits/35fea9.wgsl.expected.msl b/test/tint/builtins/gen/literal/reverseBits/35fea9.wgsl.expected.msl index af6ec6cef2..f8b986a28c 100644 --- a/test/tint/builtins/gen/literal/reverseBits/35fea9.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/reverseBits/35fea9.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void reverseBits_35fea9() { - uint4 res = reverse_bits(uint4(1u)); + uint4 res = uint4(2147483648u); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/reverseBits/35fea9.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/reverseBits/35fea9.wgsl.expected.spvasm index 64647f436b..a9ef7e5b2e 100644 --- a/test/tint/builtins/gen/literal/reverseBits/35fea9.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/reverseBits/35fea9.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 35 +; Bound: 34 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -32,38 +32,37 @@ %9 = OpTypeFunction %void %uint = OpTypeInt 32 0 %v4uint = OpTypeVector %uint 4 - %uint_1 = OpConstant %uint 1 - %17 = OpConstantComposite %v4uint %uint_1 %uint_1 %uint_1 %uint_1 +%uint_2147483648 = OpConstant %uint 2147483648 + %16 = OpConstantComposite %v4uint %uint_2147483648 %uint_2147483648 %uint_2147483648 %uint_2147483648 %_ptr_Function_v4uint = OpTypePointer Function %v4uint - %20 = OpConstantNull %v4uint - %21 = OpTypeFunction %v4float + %19 = OpConstantNull %v4uint + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %reverseBits_35fea9 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v4uint Function %20 - %13 = OpBitReverse %v4uint %17 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v4uint Function %19 + OpStore %res %16 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %21 - %23 = OpLabel - %24 = OpFunctionCall %void %reverseBits_35fea9 +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %reverseBits_35fea9 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %27 + %25 = OpLabel + %26 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %26 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %30 = OpLabel - %31 = OpFunctionCall %void %reverseBits_35fea9 + %29 = OpLabel + %30 = OpFunctionCall %void %reverseBits_35fea9 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %33 = OpLabel - %34 = OpFunctionCall %void %reverseBits_35fea9 + %32 = OpLabel + %33 = OpFunctionCall %void %reverseBits_35fea9 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/reverseBits/4dbd6f.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/reverseBits/4dbd6f.wgsl.expected.dxc.hlsl index 73a433ba7a..aa81049725 100644 --- a/test/tint/builtins/gen/literal/reverseBits/4dbd6f.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/reverseBits/4dbd6f.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void reverseBits_4dbd6f() { - int4 res = asint(reversebits(asuint((1).xxxx))); + int4 res = (-2147483648).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/reverseBits/4dbd6f.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/reverseBits/4dbd6f.wgsl.expected.fxc.hlsl index 73a433ba7a..aa81049725 100644 --- a/test/tint/builtins/gen/literal/reverseBits/4dbd6f.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/reverseBits/4dbd6f.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void reverseBits_4dbd6f() { - int4 res = asint(reversebits(asuint((1).xxxx))); + int4 res = (-2147483648).xxxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/reverseBits/4dbd6f.wgsl.expected.glsl b/test/tint/builtins/gen/literal/reverseBits/4dbd6f.wgsl.expected.glsl index 0d096c5138..46772b009e 100644 --- a/test/tint/builtins/gen/literal/reverseBits/4dbd6f.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/reverseBits/4dbd6f.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void reverseBits_4dbd6f() { - ivec4 res = bitfieldReverse(ivec4(1)); + ivec4 res = ivec4(-2147483648); } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void reverseBits_4dbd6f() { - ivec4 res = bitfieldReverse(ivec4(1)); + ivec4 res = ivec4(-2147483648); } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void reverseBits_4dbd6f() { - ivec4 res = bitfieldReverse(ivec4(1)); + ivec4 res = ivec4(-2147483648); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/reverseBits/4dbd6f.wgsl.expected.msl b/test/tint/builtins/gen/literal/reverseBits/4dbd6f.wgsl.expected.msl index f148edcccf..5a5de8ba16 100644 --- a/test/tint/builtins/gen/literal/reverseBits/4dbd6f.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/reverseBits/4dbd6f.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void reverseBits_4dbd6f() { - int4 res = reverse_bits(int4(1)); + int4 res = int4((-2147483647 - 1)); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/reverseBits/4dbd6f.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/reverseBits/4dbd6f.wgsl.expected.spvasm index f8dfbb65ef..2e97a0bcf2 100644 --- a/test/tint/builtins/gen/literal/reverseBits/4dbd6f.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/reverseBits/4dbd6f.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 35 +; Bound: 34 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -32,38 +32,37 @@ %9 = OpTypeFunction %void %int = OpTypeInt 32 1 %v4int = OpTypeVector %int 4 - %int_1 = OpConstant %int 1 - %17 = OpConstantComposite %v4int %int_1 %int_1 %int_1 %int_1 +%int_n2147483648 = OpConstant %int -2147483648 + %16 = OpConstantComposite %v4int %int_n2147483648 %int_n2147483648 %int_n2147483648 %int_n2147483648 %_ptr_Function_v4int = OpTypePointer Function %v4int - %20 = OpConstantNull %v4int - %21 = OpTypeFunction %v4float + %19 = OpConstantNull %v4int + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %reverseBits_4dbd6f = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v4int Function %20 - %13 = OpBitReverse %v4int %17 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v4int Function %19 + OpStore %res %16 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %21 - %23 = OpLabel - %24 = OpFunctionCall %void %reverseBits_4dbd6f +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %reverseBits_4dbd6f OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %27 + %25 = OpLabel + %26 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %26 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %30 = OpLabel - %31 = OpFunctionCall %void %reverseBits_4dbd6f + %29 = OpLabel + %30 = OpFunctionCall %void %reverseBits_4dbd6f OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %33 = OpLabel - %34 = OpFunctionCall %void %reverseBits_4dbd6f + %32 = OpLabel + %33 = OpFunctionCall %void %reverseBits_4dbd6f OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/reverseBits/7c4269.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/reverseBits/7c4269.wgsl.expected.dxc.hlsl index b2796a2562..03c83560e8 100644 --- a/test/tint/builtins/gen/literal/reverseBits/7c4269.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/reverseBits/7c4269.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void reverseBits_7c4269() { - int res = asint(reversebits(asuint(1))); + int res = -2147483648; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/reverseBits/7c4269.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/reverseBits/7c4269.wgsl.expected.fxc.hlsl index b2796a2562..03c83560e8 100644 --- a/test/tint/builtins/gen/literal/reverseBits/7c4269.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/reverseBits/7c4269.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void reverseBits_7c4269() { - int res = asint(reversebits(asuint(1))); + int res = -2147483648; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/reverseBits/7c4269.wgsl.expected.glsl b/test/tint/builtins/gen/literal/reverseBits/7c4269.wgsl.expected.glsl index 390dad5a32..b49fd5d757 100644 --- a/test/tint/builtins/gen/literal/reverseBits/7c4269.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/reverseBits/7c4269.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void reverseBits_7c4269() { - int res = bitfieldReverse(1); + int res = -2147483648; } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void reverseBits_7c4269() { - int res = bitfieldReverse(1); + int res = -2147483648; } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void reverseBits_7c4269() { - int res = bitfieldReverse(1); + int res = -2147483648; } void compute_main() { diff --git a/test/tint/builtins/gen/literal/reverseBits/7c4269.wgsl.expected.msl b/test/tint/builtins/gen/literal/reverseBits/7c4269.wgsl.expected.msl index 90d843c897..d8667763b2 100644 --- a/test/tint/builtins/gen/literal/reverseBits/7c4269.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/reverseBits/7c4269.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void reverseBits_7c4269() { - int res = reverse_bits(1); + int res = (-2147483647 - 1); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/reverseBits/7c4269.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/reverseBits/7c4269.wgsl.expected.spvasm index 1811bbc9c7..099ac7e13a 100644 --- a/test/tint/builtins/gen/literal/reverseBits/7c4269.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/reverseBits/7c4269.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 33 +; Bound: 32 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -31,37 +31,36 @@ %void = OpTypeVoid %9 = OpTypeFunction %void %int = OpTypeInt 32 1 - %int_1 = OpConstant %int 1 +%int_n2147483648 = OpConstant %int -2147483648 %_ptr_Function_int = OpTypePointer Function %int - %18 = OpConstantNull %int - %19 = OpTypeFunction %v4float + %17 = OpConstantNull %int + %18 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %reverseBits_7c4269 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_int Function %18 - %13 = OpBitReverse %int %int_1 - OpStore %res %13 + %res = OpVariable %_ptr_Function_int Function %17 + OpStore %res %int_n2147483648 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %19 - %21 = OpLabel - %22 = OpFunctionCall %void %reverseBits_7c4269 +%vertex_main_inner = OpFunction %v4float None %18 + %20 = OpLabel + %21 = OpFunctionCall %void %reverseBits_7c4269 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %24 = OpLabel - %25 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %25 + %23 = OpLabel + %24 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %24 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %28 = OpLabel - %29 = OpFunctionCall %void %reverseBits_7c4269 + %27 = OpLabel + %28 = OpFunctionCall %void %reverseBits_7c4269 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %31 = OpLabel - %32 = OpFunctionCall %void %reverseBits_7c4269 + %30 = OpLabel + %31 = OpFunctionCall %void %reverseBits_7c4269 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/reverseBits/a6ccd4.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/reverseBits/a6ccd4.wgsl.expected.dxc.hlsl index 99e125afff..ae2987c23d 100644 --- a/test/tint/builtins/gen/literal/reverseBits/a6ccd4.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/reverseBits/a6ccd4.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void reverseBits_a6ccd4() { - uint3 res = reversebits((1u).xxx); + uint3 res = (2147483648u).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/reverseBits/a6ccd4.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/reverseBits/a6ccd4.wgsl.expected.fxc.hlsl index 99e125afff..ae2987c23d 100644 --- a/test/tint/builtins/gen/literal/reverseBits/a6ccd4.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/reverseBits/a6ccd4.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void reverseBits_a6ccd4() { - uint3 res = reversebits((1u).xxx); + uint3 res = (2147483648u).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/reverseBits/a6ccd4.wgsl.expected.glsl b/test/tint/builtins/gen/literal/reverseBits/a6ccd4.wgsl.expected.glsl index ae14fb671d..ff797a6984 100644 --- a/test/tint/builtins/gen/literal/reverseBits/a6ccd4.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/reverseBits/a6ccd4.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void reverseBits_a6ccd4() { - uvec3 res = bitfieldReverse(uvec3(1u)); + uvec3 res = uvec3(2147483648u); } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void reverseBits_a6ccd4() { - uvec3 res = bitfieldReverse(uvec3(1u)); + uvec3 res = uvec3(2147483648u); } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void reverseBits_a6ccd4() { - uvec3 res = bitfieldReverse(uvec3(1u)); + uvec3 res = uvec3(2147483648u); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/reverseBits/a6ccd4.wgsl.expected.msl b/test/tint/builtins/gen/literal/reverseBits/a6ccd4.wgsl.expected.msl index 1c8cfe712e..ebc5d6f4fa 100644 --- a/test/tint/builtins/gen/literal/reverseBits/a6ccd4.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/reverseBits/a6ccd4.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void reverseBits_a6ccd4() { - uint3 res = reverse_bits(uint3(1u)); + uint3 res = uint3(2147483648u); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/reverseBits/a6ccd4.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/reverseBits/a6ccd4.wgsl.expected.spvasm index cb42d67869..7be4545d6e 100644 --- a/test/tint/builtins/gen/literal/reverseBits/a6ccd4.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/reverseBits/a6ccd4.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 35 +; Bound: 34 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -32,38 +32,37 @@ %9 = OpTypeFunction %void %uint = OpTypeInt 32 0 %v3uint = OpTypeVector %uint 3 - %uint_1 = OpConstant %uint 1 - %17 = OpConstantComposite %v3uint %uint_1 %uint_1 %uint_1 +%uint_2147483648 = OpConstant %uint 2147483648 + %16 = OpConstantComposite %v3uint %uint_2147483648 %uint_2147483648 %uint_2147483648 %_ptr_Function_v3uint = OpTypePointer Function %v3uint - %20 = OpConstantNull %v3uint - %21 = OpTypeFunction %v4float + %19 = OpConstantNull %v3uint + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %reverseBits_a6ccd4 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v3uint Function %20 - %13 = OpBitReverse %v3uint %17 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v3uint Function %19 + OpStore %res %16 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %21 - %23 = OpLabel - %24 = OpFunctionCall %void %reverseBits_a6ccd4 +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %reverseBits_a6ccd4 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %27 + %25 = OpLabel + %26 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %26 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %30 = OpLabel - %31 = OpFunctionCall %void %reverseBits_a6ccd4 + %29 = OpLabel + %30 = OpFunctionCall %void %reverseBits_a6ccd4 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %33 = OpLabel - %34 = OpFunctionCall %void %reverseBits_a6ccd4 + %32 = OpLabel + %33 = OpFunctionCall %void %reverseBits_a6ccd4 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/reverseBits/c21bc1.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/reverseBits/c21bc1.wgsl.expected.dxc.hlsl index 5c31987567..f2aa08d0e6 100644 --- a/test/tint/builtins/gen/literal/reverseBits/c21bc1.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/reverseBits/c21bc1.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void reverseBits_c21bc1() { - int3 res = asint(reversebits(asuint((1).xxx))); + int3 res = (-2147483648).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/reverseBits/c21bc1.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/reverseBits/c21bc1.wgsl.expected.fxc.hlsl index 5c31987567..f2aa08d0e6 100644 --- a/test/tint/builtins/gen/literal/reverseBits/c21bc1.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/reverseBits/c21bc1.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void reverseBits_c21bc1() { - int3 res = asint(reversebits(asuint((1).xxx))); + int3 res = (-2147483648).xxx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/reverseBits/c21bc1.wgsl.expected.glsl b/test/tint/builtins/gen/literal/reverseBits/c21bc1.wgsl.expected.glsl index f71833dd88..631794a4b3 100644 --- a/test/tint/builtins/gen/literal/reverseBits/c21bc1.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/reverseBits/c21bc1.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void reverseBits_c21bc1() { - ivec3 res = bitfieldReverse(ivec3(1)); + ivec3 res = ivec3(-2147483648); } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void reverseBits_c21bc1() { - ivec3 res = bitfieldReverse(ivec3(1)); + ivec3 res = ivec3(-2147483648); } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void reverseBits_c21bc1() { - ivec3 res = bitfieldReverse(ivec3(1)); + ivec3 res = ivec3(-2147483648); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/reverseBits/c21bc1.wgsl.expected.msl b/test/tint/builtins/gen/literal/reverseBits/c21bc1.wgsl.expected.msl index fb2b4aacc7..0d687a9d77 100644 --- a/test/tint/builtins/gen/literal/reverseBits/c21bc1.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/reverseBits/c21bc1.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void reverseBits_c21bc1() { - int3 res = reverse_bits(int3(1)); + int3 res = int3((-2147483647 - 1)); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/reverseBits/c21bc1.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/reverseBits/c21bc1.wgsl.expected.spvasm index 74cbb29bb7..83d95fd091 100644 --- a/test/tint/builtins/gen/literal/reverseBits/c21bc1.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/reverseBits/c21bc1.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 35 +; Bound: 34 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -32,38 +32,37 @@ %9 = OpTypeFunction %void %int = OpTypeInt 32 1 %v3int = OpTypeVector %int 3 - %int_1 = OpConstant %int 1 - %17 = OpConstantComposite %v3int %int_1 %int_1 %int_1 +%int_n2147483648 = OpConstant %int -2147483648 + %16 = OpConstantComposite %v3int %int_n2147483648 %int_n2147483648 %int_n2147483648 %_ptr_Function_v3int = OpTypePointer Function %v3int - %20 = OpConstantNull %v3int - %21 = OpTypeFunction %v4float + %19 = OpConstantNull %v3int + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %reverseBits_c21bc1 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v3int Function %20 - %13 = OpBitReverse %v3int %17 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v3int Function %19 + OpStore %res %16 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %21 - %23 = OpLabel - %24 = OpFunctionCall %void %reverseBits_c21bc1 +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %reverseBits_c21bc1 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %27 + %25 = OpLabel + %26 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %26 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %30 = OpLabel - %31 = OpFunctionCall %void %reverseBits_c21bc1 + %29 = OpLabel + %30 = OpFunctionCall %void %reverseBits_c21bc1 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %33 = OpLabel - %34 = OpFunctionCall %void %reverseBits_c21bc1 + %32 = OpLabel + %33 = OpFunctionCall %void %reverseBits_c21bc1 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/reverseBits/e1f4c1.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/reverseBits/e1f4c1.wgsl.expected.dxc.hlsl index d159b1dc84..505d08fba5 100644 --- a/test/tint/builtins/gen/literal/reverseBits/e1f4c1.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/reverseBits/e1f4c1.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void reverseBits_e1f4c1() { - uint2 res = reversebits((1u).xx); + uint2 res = (2147483648u).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/reverseBits/e1f4c1.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/reverseBits/e1f4c1.wgsl.expected.fxc.hlsl index d159b1dc84..505d08fba5 100644 --- a/test/tint/builtins/gen/literal/reverseBits/e1f4c1.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/reverseBits/e1f4c1.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void reverseBits_e1f4c1() { - uint2 res = reversebits((1u).xx); + uint2 res = (2147483648u).xx; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/reverseBits/e1f4c1.wgsl.expected.glsl b/test/tint/builtins/gen/literal/reverseBits/e1f4c1.wgsl.expected.glsl index 123f32c429..7e40794cf1 100644 --- a/test/tint/builtins/gen/literal/reverseBits/e1f4c1.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/reverseBits/e1f4c1.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void reverseBits_e1f4c1() { - uvec2 res = bitfieldReverse(uvec2(1u)); + uvec2 res = uvec2(2147483648u); } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void reverseBits_e1f4c1() { - uvec2 res = bitfieldReverse(uvec2(1u)); + uvec2 res = uvec2(2147483648u); } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void reverseBits_e1f4c1() { - uvec2 res = bitfieldReverse(uvec2(1u)); + uvec2 res = uvec2(2147483648u); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/reverseBits/e1f4c1.wgsl.expected.msl b/test/tint/builtins/gen/literal/reverseBits/e1f4c1.wgsl.expected.msl index 0394724b98..7f28f03fc6 100644 --- a/test/tint/builtins/gen/literal/reverseBits/e1f4c1.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/reverseBits/e1f4c1.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void reverseBits_e1f4c1() { - uint2 res = reverse_bits(uint2(1u)); + uint2 res = uint2(2147483648u); } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/reverseBits/e1f4c1.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/reverseBits/e1f4c1.wgsl.expected.spvasm index 9643cf026a..11be15f55b 100644 --- a/test/tint/builtins/gen/literal/reverseBits/e1f4c1.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/reverseBits/e1f4c1.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 35 +; Bound: 34 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -32,38 +32,37 @@ %9 = OpTypeFunction %void %uint = OpTypeInt 32 0 %v2uint = OpTypeVector %uint 2 - %uint_1 = OpConstant %uint 1 - %17 = OpConstantComposite %v2uint %uint_1 %uint_1 +%uint_2147483648 = OpConstant %uint 2147483648 + %16 = OpConstantComposite %v2uint %uint_2147483648 %uint_2147483648 %_ptr_Function_v2uint = OpTypePointer Function %v2uint - %20 = OpConstantNull %v2uint - %21 = OpTypeFunction %v4float + %19 = OpConstantNull %v2uint + %20 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %reverseBits_e1f4c1 = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_v2uint Function %20 - %13 = OpBitReverse %v2uint %17 - OpStore %res %13 + %res = OpVariable %_ptr_Function_v2uint Function %19 + OpStore %res %16 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %21 - %23 = OpLabel - %24 = OpFunctionCall %void %reverseBits_e1f4c1 +%vertex_main_inner = OpFunction %v4float None %20 + %22 = OpLabel + %23 = OpFunctionCall %void %reverseBits_e1f4c1 OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %26 = OpLabel - %27 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %27 + %25 = OpLabel + %26 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %26 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %30 = OpLabel - %31 = OpFunctionCall %void %reverseBits_e1f4c1 + %29 = OpLabel + %30 = OpFunctionCall %void %reverseBits_e1f4c1 OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %33 = OpLabel - %34 = OpFunctionCall %void %reverseBits_e1f4c1 + %32 = OpLabel + %33 = OpFunctionCall %void %reverseBits_e1f4c1 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/reverseBits/e31adf.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/reverseBits/e31adf.wgsl.expected.dxc.hlsl index 823b7110cd..bc8374455a 100644 --- a/test/tint/builtins/gen/literal/reverseBits/e31adf.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/reverseBits/e31adf.wgsl.expected.dxc.hlsl @@ -1,5 +1,5 @@ void reverseBits_e31adf() { - uint res = reversebits(1u); + uint res = 2147483648u; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/reverseBits/e31adf.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/reverseBits/e31adf.wgsl.expected.fxc.hlsl index 823b7110cd..bc8374455a 100644 --- a/test/tint/builtins/gen/literal/reverseBits/e31adf.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/reverseBits/e31adf.wgsl.expected.fxc.hlsl @@ -1,5 +1,5 @@ void reverseBits_e31adf() { - uint res = reversebits(1u); + uint res = 2147483648u; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/reverseBits/e31adf.wgsl.expected.glsl b/test/tint/builtins/gen/literal/reverseBits/e31adf.wgsl.expected.glsl index 3ea30666ec..9702c7f537 100644 --- a/test/tint/builtins/gen/literal/reverseBits/e31adf.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/reverseBits/e31adf.wgsl.expected.glsl @@ -1,7 +1,7 @@ #version 310 es void reverseBits_e31adf() { - uint res = bitfieldReverse(1u); + uint res = 2147483648u; } vec4 vertex_main() { @@ -21,7 +21,7 @@ void main() { precision mediump float; void reverseBits_e31adf() { - uint res = bitfieldReverse(1u); + uint res = 2147483648u; } void fragment_main() { @@ -35,7 +35,7 @@ void main() { #version 310 es void reverseBits_e31adf() { - uint res = bitfieldReverse(1u); + uint res = 2147483648u; } void compute_main() { diff --git a/test/tint/builtins/gen/literal/reverseBits/e31adf.wgsl.expected.msl b/test/tint/builtins/gen/literal/reverseBits/e31adf.wgsl.expected.msl index c850796c2e..de5f9e3be8 100644 --- a/test/tint/builtins/gen/literal/reverseBits/e31adf.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/reverseBits/e31adf.wgsl.expected.msl @@ -2,7 +2,7 @@ using namespace metal; void reverseBits_e31adf() { - uint res = reverse_bits(1u); + uint res = 2147483648u; } struct tint_symbol { diff --git a/test/tint/builtins/gen/literal/reverseBits/e31adf.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/reverseBits/e31adf.wgsl.expected.spvasm index 9f44dbe9dd..55f8128631 100644 --- a/test/tint/builtins/gen/literal/reverseBits/e31adf.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/reverseBits/e31adf.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 33 +; Bound: 32 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -31,37 +31,36 @@ %void = OpTypeVoid %9 = OpTypeFunction %void %uint = OpTypeInt 32 0 - %uint_1 = OpConstant %uint 1 +%uint_2147483648 = OpConstant %uint 2147483648 %_ptr_Function_uint = OpTypePointer Function %uint - %18 = OpConstantNull %uint - %19 = OpTypeFunction %v4float + %17 = OpConstantNull %uint + %18 = OpTypeFunction %v4float %float_1 = OpConstant %float 1 %reverseBits_e31adf = OpFunction %void None %9 %12 = OpLabel - %res = OpVariable %_ptr_Function_uint Function %18 - %13 = OpBitReverse %uint %uint_1 - OpStore %res %13 + %res = OpVariable %_ptr_Function_uint Function %17 + OpStore %res %uint_2147483648 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %19 - %21 = OpLabel - %22 = OpFunctionCall %void %reverseBits_e31adf +%vertex_main_inner = OpFunction %v4float None %18 + %20 = OpLabel + %21 = OpFunctionCall %void %reverseBits_e31adf OpReturnValue %5 OpFunctionEnd %vertex_main = OpFunction %void None %9 - %24 = OpLabel - %25 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %25 + %23 = OpLabel + %24 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %24 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd %fragment_main = OpFunction %void None %9 - %28 = OpLabel - %29 = OpFunctionCall %void %reverseBits_e31adf + %27 = OpLabel + %28 = OpFunctionCall %void %reverseBits_e31adf OpReturn OpFunctionEnd %compute_main = OpFunction %void None %9 - %31 = OpLabel - %32 = OpFunctionCall %void %reverseBits_e31adf + %30 = OpLabel + %31 = OpFunctionCall %void %reverseBits_e31adf OpReturn OpFunctionEnd