tint: const eval of insertBits
Bug: tint:1581
Change-Id: Id89530eb90d3c75bd1f99dd67a78cad1c923c6f0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107924
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
diff --git a/src/tint/intrinsics.def b/src/tint/intrinsics.def
index 3146aa8..b72426e 100644
--- a/src/tint/intrinsics.def
+++ b/src/tint/intrinsics.def
@@ -485,8 +485,8 @@
@stage("fragment") fn fwidthCoarse<N: num>(vec<N, f32>) -> vec<N, f32>
@stage("fragment") fn fwidthFine(f32) -> f32
@stage("fragment") fn fwidthFine<N: num>(vec<N, f32>) -> vec<N, f32>
-fn insertBits<T: iu32>(T, T, u32, u32) -> T
-fn insertBits<N: num, T: iu32>(vec<N, T>, vec<N, T>, u32, u32) -> vec<N, T>
+@const fn insertBits<T: iu32>(T, T, u32, u32) -> T
+@const fn insertBits<N: num, T: iu32>(vec<N, T>, vec<N, T>, u32, u32) -> vec<N, T>
fn inverseSqrt<T: f32_f16>(T) -> T
fn inverseSqrt<N: num, T: f32_f16>(vec<N, T>) -> vec<N, T>
fn ldexp<T: f32_f16>(T, i32) -> T
diff --git a/src/tint/resolver/const_eval.cc b/src/tint/resolver/const_eval.cc
index 0331f46..5d94e1c 100644
--- a/src/tint/resolver/const_eval.cc
+++ b/src/tint/resolver/const_eval.cc
@@ -1790,6 +1790,58 @@
return TransformElements(builder, ty, transform, args[0]);
}
+ConstEval::Result ConstEval::insertBits(const sem::Type* ty,
+ utils::VectorRef<const sem::Constant*> args,
+ const Source& source) {
+ auto transform = [&](const sem::Constant* c0, const sem::Constant* c1) {
+ auto create = [&](auto in_e, auto in_newbits) -> ImplResult {
+ using NumberT = decltype(in_e);
+ using T = UnwrapNumber<NumberT>;
+ using UT = std::make_unsigned_t<T>;
+ using NumberUT = Number<UT>;
+
+ // Read args that are always scalar
+ NumberUT in_offset = args[2]->As<NumberUT>();
+ NumberUT in_count = args[3]->As<NumberUT>();
+
+ constexpr UT w = sizeof(UT) * 8;
+ if ((in_offset + in_count) > w) {
+ AddError("'offset + 'count' must be less than or equal to the bit width of 'e'",
+ source);
+ return utils::Failure;
+ }
+
+ // Cast all to unsigned
+ UT e = static_cast<UT>(in_e);
+ UT newbits = static_cast<UT>(in_newbits);
+ UT o = static_cast<UT>(in_offset);
+ UT c = static_cast<UT>(in_count);
+
+ NumberT result;
+ if (c == UT{0}) {
+ // The result is e if c is 0
+ result = NumberT{e};
+ } else if (c == w) {
+ // The result is newbits if c is w
+ result = NumberT{newbits};
+ } else {
+ // Otherwise, bits o..o + c - 1 of the result are copied from bits 0..c - 1 of
+ // 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)
+ result = NumberT{r};
+ }
+
+ return CreateElement(builder, c0->Type(), result);
+ };
+ return Dispatch_iu32(create, c0, c1);
+ };
+ return TransformElements(builder, ty, transform, args[0], args[1]);
+}
+
ConstEval::Result ConstEval::saturate(const sem::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source&) {
diff --git a/src/tint/resolver/const_eval.h b/src/tint/resolver/const_eval.h
index 07ce7e7..9aacec5 100644
--- a/src/tint/resolver/const_eval.h
+++ b/src/tint/resolver/const_eval.h
@@ -485,6 +485,15 @@
utils::VectorRef<const sem::Constant*> args,
const Source& source);
+ /// insertBits 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 insertBits(const sem::Type* ty,
+ utils::VectorRef<const sem::Constant*> args,
+ const Source& source);
+
/// saturate builtin
/// @param ty the expression type
/// @param args the input arguments
diff --git a/src/tint/resolver/const_eval_builtin_test.cc b/src/tint/resolver/const_eval_builtin_test.cc
index daa5a72..7b78035 100644
--- a/src/tint/resolver/const_eval_builtin_test.cc
+++ b/src/tint/resolver/const_eval_builtin_test.cc
@@ -714,6 +714,94 @@
FirstTrailingBitCases<u32>()))));
template <typename T>
+std::vector<Case> InsertBitsCases() {
+ using UT = Number<std::make_unsigned_t<UnwrapNumber<T>>>;
+
+ auto e = /* */ T(0b0101'1100'0011'1010'0101'1100'0011'1010);
+ auto newbits = T{0b1010'0011'1100'0101'1010'0011'1100'0101};
+
+ auto r = std::vector<Case>{
+ // args: e, newbits, offset, count
+
+ // If count is 0, result is e
+ C({e, newbits, UT(0), UT(0)}, e), //
+ C({e, newbits, UT(1), UT(0)}, e), //
+ C({e, newbits, UT(2), UT(0)}, e), //
+ C({e, newbits, UT(3), UT(0)}, e), //
+ // ...
+ C({e, newbits, UT(29), UT(0)}, e), //
+ C({e, newbits, UT(30), UT(0)}, e), //
+ C({e, newbits, UT(31), UT(0)}, e),
+
+ // Copy 1 to 32 bits of newbits to e at offset 0
+ C({e, newbits, UT(0), UT(1)}, T(0b0101'1100'0011'1010'0101'1100'0011'1011)),
+ C({e, newbits, UT(0), UT(2)}, T(0b0101'1100'0011'1010'0101'1100'0011'1001)),
+ C({e, newbits, UT(0), UT(3)}, T(0b0101'1100'0011'1010'0101'1100'0011'1101)),
+ C({e, newbits, UT(0), UT(4)}, T(0b0101'1100'0011'1010'0101'1100'0011'0101)),
+ C({e, newbits, UT(0), UT(5)}, T(0b0101'1100'0011'1010'0101'1100'0010'0101)),
+ C({e, newbits, UT(0), UT(6)}, T(0b0101'1100'0011'1010'0101'1100'0000'0101)),
+ // ...
+ C({e, newbits, UT(0), UT(29)}, T(0b0100'0011'1100'0101'1010'0011'1100'0101)),
+ C({e, newbits, UT(0), UT(30)}, T(0b0110'0011'1100'0101'1010'0011'1100'0101)),
+ C({e, newbits, UT(0), UT(31)}, T(0b0010'0011'1100'0101'1010'0011'1100'0101)),
+ C({e, newbits, UT(0), UT(32)}, T(0b1010'0011'1100'0101'1010'0011'1100'0101)),
+
+ // Copy at varying offsets and counts
+ C({e, newbits, UT(3), UT(8)}, T(0b0101'1100'0011'1010'0101'1110'0010'1010)),
+ C({e, newbits, UT(8), UT(8)}, T(0b0101'1100'0011'1010'1100'0101'0011'1010)),
+ C({e, newbits, UT(15), UT(1)}, T(0b0101'1100'0011'1010'1101'1100'0011'1010)),
+ C({e, newbits, UT(16), UT(16)}, T(0b1010'0011'1100'0101'0101'1100'0011'1010)),
+
+ // Vector tests
+ C({Vec(T(0b1111'0000'1111'0000'1111'0000'1111'0000), //
+ T(0b0000'1111'0000'1111'0000'1111'0000'1111), //
+ T(0b1010'0101'1010'0101'1010'0101'1010'0101)),
+ Vec(T(0b1111'1111'1111'1111'1111'1111'1111'1111), //
+ T(0b1111'1111'1111'1111'1111'1111'1111'1111), //
+ T(0b1111'1111'1111'1111'1111'1111'1111'1111)),
+ Val(UT(3)), Val(UT(8))},
+ Vec(T(0b1111'0000'1111'0000'1111'0111'1111'1000), //
+ T(0b0000'1111'0000'1111'0000'1111'1111'1111), //
+ T(0b1010'0101'1010'0101'1010'0111'1111'1101))),
+ };
+
+ return r;
+}
+INSTANTIATE_TEST_SUITE_P( //
+ InsertBits,
+ ResolverConstEvalBuiltinTest,
+ testing::Combine(testing::Values(sem::BuiltinType::kInsertBits),
+ testing::ValuesIn(Concat(InsertBitsCases<i32>(), //
+ InsertBitsCases<u32>()))));
+
+using ResolverConstEvalBuiltinTest_InsertBits_InvalidOffsetAndCount =
+ ResolverTestWithParam<std::tuple<size_t, size_t>>;
+TEST_P(ResolverConstEvalBuiltinTest_InsertBits_InvalidOffsetAndCount, Test) {
+ auto& p = GetParam();
+ auto* expr = Call(Source{{12, 24}}, sem::str(sem::BuiltinType::kInsertBits), Expr(1_u),
+ Expr(1_u), Expr(u32(std::get<0>(p))), Expr(u32(std::get<1>(p))));
+ GlobalConst("C", expr);
+ EXPECT_FALSE(r()->Resolve());
+ EXPECT_EQ(r()->error(),
+ "12:24 error: 'offset + 'count' must be less than or equal to the bit width of 'e'");
+}
+INSTANTIATE_TEST_SUITE_P(InsertBits,
+ ResolverConstEvalBuiltinTest_InsertBits_InvalidOffsetAndCount,
+ testing::Values( //
+ std::make_tuple(33, 0), //
+ std::make_tuple(34, 0), //
+ std::make_tuple(1000, 0), //
+ std::make_tuple(u32::Highest(), 0), //
+ std::make_tuple(0, 33), //
+ std::make_tuple(0, 34), //
+ std::make_tuple(0, 1000), //
+ std::make_tuple(0, u32::Highest()), //
+ std::make_tuple(33, 33), //
+ std::make_tuple(34, 34), //
+ std::make_tuple(1000, 1000), //
+ std::make_tuple(u32::Highest(), u32::Highest())));
+
+template <typename T>
std::vector<Case> SaturateCases() {
return {
C({T(0)}, T(0)),
diff --git a/src/tint/resolver/intrinsic_table.inl b/src/tint/resolver/intrinsic_table.inl
index ea7ad98..dde2982 100644
--- a/src/tint/resolver/intrinsic_table.inl
+++ b/src/tint/resolver/intrinsic_table.inl
@@ -11894,7 +11894,7 @@
/* parameters */ &kParameters[423],
/* return matcher indices */ &kMatcherIndices[1],
/* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
- /* const eval */ nullptr,
+ /* const eval */ &ConstEval::insertBits,
},
{
/* [297] */
@@ -11906,7 +11906,7 @@
/* parameters */ &kParameters[427],
/* return matcher indices */ &kMatcherIndices[30],
/* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
- /* const eval */ nullptr,
+ /* const eval */ &ConstEval::insertBits,
},
{
/* [298] */
diff --git a/test/tint/builtins/gen/literal/insertBits/3c7ba5.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/insertBits/3c7ba5.wgsl.expected.dxc.hlsl
index 01e391d..afc5773 100644
--- a/test/tint/builtins/gen/literal/insertBits/3c7ba5.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/insertBits/3c7ba5.wgsl.expected.dxc.hlsl
@@ -1,12 +1,5 @@
-uint2 tint_insert_bits(uint2 v, uint2 n, uint offset, uint count) {
- const uint s = min(offset, 32u);
- const uint e = min(32u, (s + count));
- const uint mask = (((1u << s) - 1u) ^ ((1u << e) - 1u));
- return (((n << uint2((s).xx)) & uint2((mask).xx)) | (v & uint2((~(mask)).xx)));
-}
-
void insertBits_3c7ba5() {
- uint2 res = tint_insert_bits((1u).xx, (1u).xx, 1u, 1u);
+ uint2 res = (3u).xx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/insertBits/3c7ba5.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/insertBits/3c7ba5.wgsl.expected.fxc.hlsl
index 01e391d..afc5773 100644
--- a/test/tint/builtins/gen/literal/insertBits/3c7ba5.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/insertBits/3c7ba5.wgsl.expected.fxc.hlsl
@@ -1,12 +1,5 @@
-uint2 tint_insert_bits(uint2 v, uint2 n, uint offset, uint count) {
- const uint s = min(offset, 32u);
- const uint e = min(32u, (s + count));
- const uint mask = (((1u << s) - 1u) ^ ((1u << e) - 1u));
- return (((n << uint2((s).xx)) & uint2((mask).xx)) | (v & uint2((~(mask)).xx)));
-}
-
void insertBits_3c7ba5() {
- uint2 res = tint_insert_bits((1u).xx, (1u).xx, 1u, 1u);
+ uint2 res = (3u).xx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/insertBits/3c7ba5.wgsl.expected.glsl b/test/tint/builtins/gen/literal/insertBits/3c7ba5.wgsl.expected.glsl
index 3cbe76e..f664ffc 100644
--- a/test/tint/builtins/gen/literal/insertBits/3c7ba5.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/insertBits/3c7ba5.wgsl.expected.glsl
@@ -1,13 +1,7 @@
#version 310 es
-uvec2 tint_insert_bits(uvec2 v, uvec2 n, uint offset, uint count) {
- uint s = min(offset, 32u);
- uint e = min(32u, (s + count));
- return bitfieldInsert(v, n, int(s), int((e - s)));
-}
-
void insertBits_3c7ba5() {
- uvec2 res = tint_insert_bits(uvec2(1u), uvec2(1u), 1u, 1u);
+ uvec2 res = uvec2(3u);
}
vec4 vertex_main() {
@@ -26,14 +20,8 @@
#version 310 es
precision mediump float;
-uvec2 tint_insert_bits(uvec2 v, uvec2 n, uint offset, uint count) {
- uint s = min(offset, 32u);
- uint e = min(32u, (s + count));
- return bitfieldInsert(v, n, int(s), int((e - s)));
-}
-
void insertBits_3c7ba5() {
- uvec2 res = tint_insert_bits(uvec2(1u), uvec2(1u), 1u, 1u);
+ uvec2 res = uvec2(3u);
}
void fragment_main() {
@@ -46,14 +34,8 @@
}
#version 310 es
-uvec2 tint_insert_bits(uvec2 v, uvec2 n, uint offset, uint count) {
- uint s = min(offset, 32u);
- uint e = min(32u, (s + count));
- return bitfieldInsert(v, n, int(s), int((e - s)));
-}
-
void insertBits_3c7ba5() {
- uvec2 res = tint_insert_bits(uvec2(1u), uvec2(1u), 1u, 1u);
+ uvec2 res = uvec2(3u);
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/insertBits/3c7ba5.wgsl.expected.msl b/test/tint/builtins/gen/literal/insertBits/3c7ba5.wgsl.expected.msl
index eea8550..a412b68 100644
--- a/test/tint/builtins/gen/literal/insertBits/3c7ba5.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/insertBits/3c7ba5.wgsl.expected.msl
@@ -1,14 +1,8 @@
#include <metal_stdlib>
using namespace metal;
-uint2 tint_insert_bits(uint2 v, uint2 n, uint offset, uint count) {
- uint const s = min(offset, 32u);
- uint const e = min(32u, (s + count));
- return insert_bits(v, n, s, (e - s));
-}
-
void insertBits_3c7ba5() {
- uint2 res = tint_insert_bits(uint2(1u), uint2(1u), 1u, 1u);
+ uint2 res = uint2(3u);
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/insertBits/3c7ba5.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/insertBits/3c7ba5.wgsl.expected.spvasm
index 96b9209..cef27ea 100644
--- a/test/tint/builtins/gen/literal/insertBits/3c7ba5.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/insertBits/3c7ba5.wgsl.expected.spvasm
@@ -1,10 +1,9 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 49
+; Bound: 34
; Schema: 0
OpCapability Shader
- %19 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -13,11 +12,6 @@
OpExecutionMode %compute_main LocalSize 1 1 1
OpName %value "value"
OpName %vertex_point_size "vertex_point_size"
- OpName %tint_insert_bits "tint_insert_bits"
- OpName %v "v"
- OpName %n "n"
- OpName %offset "offset"
- OpName %count "count"
OpName %insertBits_3c7ba5 "insertBits_3c7ba5"
OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner"
@@ -34,57 +28,41 @@
%_ptr_Output_float = OpTypePointer Output %float
%8 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
+ %void = OpTypeVoid
+ %9 = OpTypeFunction %void
%uint = OpTypeInt 32 0
%v2uint = OpTypeVector %uint 2
- %9 = OpTypeFunction %v2uint %v2uint %v2uint %uint %uint
- %uint_32 = OpConstant %uint 32
- %void = OpTypeVoid
- %25 = OpTypeFunction %void
- %uint_1 = OpConstant %uint 1
- %31 = OpConstantComposite %v2uint %uint_1 %uint_1
+ %uint_3 = OpConstant %uint 3
+ %16 = OpConstantComposite %v2uint %uint_3 %uint_3
%_ptr_Function_v2uint = OpTypePointer Function %v2uint
- %34 = OpConstantNull %v2uint
- %35 = OpTypeFunction %v4float
+ %19 = OpConstantNull %v2uint
+ %20 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
-%tint_insert_bits = OpFunction %v2uint None %9
- %v = OpFunctionParameter %v2uint
- %n = OpFunctionParameter %v2uint
- %offset = OpFunctionParameter %uint
- %count = OpFunctionParameter %uint
- %17 = OpLabel
- %18 = OpExtInst %uint %19 UMin %offset %uint_32
- %22 = OpIAdd %uint %18 %count
- %21 = OpExtInst %uint %19 UMin %uint_32 %22
- %24 = OpISub %uint %21 %18
- %23 = OpBitFieldInsert %v2uint %v %n %18 %24
- OpReturnValue %23
- OpFunctionEnd
-%insertBits_3c7ba5 = OpFunction %void None %25
- %28 = OpLabel
- %res = OpVariable %_ptr_Function_v2uint Function %34
- %29 = OpFunctionCall %v2uint %tint_insert_bits %31 %31 %uint_1 %uint_1
- OpStore %res %29
+%insertBits_3c7ba5 = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_v2uint Function %19
+ OpStore %res %16
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %35
- %37 = OpLabel
- %38 = OpFunctionCall %void %insertBits_3c7ba5
+%vertex_main_inner = OpFunction %v4float None %20
+ %22 = OpLabel
+ %23 = OpFunctionCall %void %insertBits_3c7ba5
OpReturnValue %5
OpFunctionEnd
-%vertex_main = OpFunction %void None %25
- %40 = OpLabel
- %41 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %41
+%vertex_main = OpFunction %void None %9
+ %25 = OpLabel
+ %26 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %26
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
-%fragment_main = OpFunction %void None %25
- %44 = OpLabel
- %45 = OpFunctionCall %void %insertBits_3c7ba5
+%fragment_main = OpFunction %void None %9
+ %29 = OpLabel
+ %30 = OpFunctionCall %void %insertBits_3c7ba5
OpReturn
OpFunctionEnd
-%compute_main = OpFunction %void None %25
- %47 = OpLabel
- %48 = OpFunctionCall %void %insertBits_3c7ba5
+%compute_main = OpFunction %void None %9
+ %32 = OpLabel
+ %33 = OpFunctionCall %void %insertBits_3c7ba5
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/insertBits/428b0b.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/insertBits/428b0b.wgsl.expected.dxc.hlsl
index fcc8e12..04df023 100644
--- a/test/tint/builtins/gen/literal/insertBits/428b0b.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/insertBits/428b0b.wgsl.expected.dxc.hlsl
@@ -1,12 +1,5 @@
-int3 tint_insert_bits(int3 v, int3 n, uint offset, uint count) {
- const uint s = min(offset, 32u);
- const uint e = min(32u, (s + count));
- const uint mask = (((1u << s) - 1u) ^ ((1u << e) - 1u));
- return (((n << uint3((s).xxx)) & int3((int(mask)).xxx)) | (v & int3((int(~(mask))).xxx)));
-}
-
void insertBits_428b0b() {
- int3 res = tint_insert_bits((1).xxx, (1).xxx, 1u, 1u);
+ int3 res = (3).xxx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/insertBits/428b0b.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/insertBits/428b0b.wgsl.expected.fxc.hlsl
index fcc8e12..04df023 100644
--- a/test/tint/builtins/gen/literal/insertBits/428b0b.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/insertBits/428b0b.wgsl.expected.fxc.hlsl
@@ -1,12 +1,5 @@
-int3 tint_insert_bits(int3 v, int3 n, uint offset, uint count) {
- const uint s = min(offset, 32u);
- const uint e = min(32u, (s + count));
- const uint mask = (((1u << s) - 1u) ^ ((1u << e) - 1u));
- return (((n << uint3((s).xxx)) & int3((int(mask)).xxx)) | (v & int3((int(~(mask))).xxx)));
-}
-
void insertBits_428b0b() {
- int3 res = tint_insert_bits((1).xxx, (1).xxx, 1u, 1u);
+ int3 res = (3).xxx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/insertBits/428b0b.wgsl.expected.glsl b/test/tint/builtins/gen/literal/insertBits/428b0b.wgsl.expected.glsl
index 38eb5cb..67a44a2 100644
--- a/test/tint/builtins/gen/literal/insertBits/428b0b.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/insertBits/428b0b.wgsl.expected.glsl
@@ -1,13 +1,7 @@
#version 310 es
-ivec3 tint_insert_bits(ivec3 v, ivec3 n, uint offset, uint count) {
- uint s = min(offset, 32u);
- uint e = min(32u, (s + count));
- return bitfieldInsert(v, n, int(s), int((e - s)));
-}
-
void insertBits_428b0b() {
- ivec3 res = tint_insert_bits(ivec3(1), ivec3(1), 1u, 1u);
+ ivec3 res = ivec3(3);
}
vec4 vertex_main() {
@@ -26,14 +20,8 @@
#version 310 es
precision mediump float;
-ivec3 tint_insert_bits(ivec3 v, ivec3 n, uint offset, uint count) {
- uint s = min(offset, 32u);
- uint e = min(32u, (s + count));
- return bitfieldInsert(v, n, int(s), int((e - s)));
-}
-
void insertBits_428b0b() {
- ivec3 res = tint_insert_bits(ivec3(1), ivec3(1), 1u, 1u);
+ ivec3 res = ivec3(3);
}
void fragment_main() {
@@ -46,14 +34,8 @@
}
#version 310 es
-ivec3 tint_insert_bits(ivec3 v, ivec3 n, uint offset, uint count) {
- uint s = min(offset, 32u);
- uint e = min(32u, (s + count));
- return bitfieldInsert(v, n, int(s), int((e - s)));
-}
-
void insertBits_428b0b() {
- ivec3 res = tint_insert_bits(ivec3(1), ivec3(1), 1u, 1u);
+ ivec3 res = ivec3(3);
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/insertBits/428b0b.wgsl.expected.msl b/test/tint/builtins/gen/literal/insertBits/428b0b.wgsl.expected.msl
index 026c7a4..8774770 100644
--- a/test/tint/builtins/gen/literal/insertBits/428b0b.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/insertBits/428b0b.wgsl.expected.msl
@@ -1,14 +1,8 @@
#include <metal_stdlib>
using namespace metal;
-int3 tint_insert_bits(int3 v, int3 n, uint offset, uint count) {
- uint const s = min(offset, 32u);
- uint const e = min(32u, (s + count));
- return insert_bits(v, n, s, (e - s));
-}
-
void insertBits_428b0b() {
- int3 res = tint_insert_bits(int3(1), int3(1), 1u, 1u);
+ int3 res = int3(3);
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/insertBits/428b0b.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/insertBits/428b0b.wgsl.expected.spvasm
index 923dcfd..4aa5619 100644
--- a/test/tint/builtins/gen/literal/insertBits/428b0b.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/insertBits/428b0b.wgsl.expected.spvasm
@@ -1,10 +1,9 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 51
+; Bound: 34
; Schema: 0
OpCapability Shader
- %20 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -13,11 +12,6 @@
OpExecutionMode %compute_main LocalSize 1 1 1
OpName %value "value"
OpName %vertex_point_size "vertex_point_size"
- OpName %tint_insert_bits "tint_insert_bits"
- OpName %v "v"
- OpName %n "n"
- OpName %offset "offset"
- OpName %count "count"
OpName %insertBits_428b0b "insertBits_428b0b"
OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner"
@@ -34,59 +28,41 @@
%_ptr_Output_float = OpTypePointer Output %float
%8 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
+ %void = OpTypeVoid
+ %9 = OpTypeFunction %void
%int = OpTypeInt 32 1
%v3int = OpTypeVector %int 3
- %uint = OpTypeInt 32 0
- %9 = OpTypeFunction %v3int %v3int %v3int %uint %uint
- %uint_32 = OpConstant %uint 32
- %void = OpTypeVoid
- %26 = OpTypeFunction %void
- %int_1 = OpConstant %int 1
- %32 = OpConstantComposite %v3int %int_1 %int_1 %int_1
- %uint_1 = OpConstant %uint 1
+ %int_3 = OpConstant %int 3
+ %16 = OpConstantComposite %v3int %int_3 %int_3 %int_3
%_ptr_Function_v3int = OpTypePointer Function %v3int
- %36 = OpConstantNull %v3int
- %37 = OpTypeFunction %v4float
+ %19 = OpConstantNull %v3int
+ %20 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
-%tint_insert_bits = OpFunction %v3int None %9
- %v = OpFunctionParameter %v3int
- %n = OpFunctionParameter %v3int
- %offset = OpFunctionParameter %uint
- %count = OpFunctionParameter %uint
- %18 = OpLabel
- %19 = OpExtInst %uint %20 UMin %offset %uint_32
- %23 = OpIAdd %uint %19 %count
- %22 = OpExtInst %uint %20 UMin %uint_32 %23
- %25 = OpISub %uint %22 %19
- %24 = OpBitFieldInsert %v3int %v %n %19 %25
- OpReturnValue %24
- OpFunctionEnd
-%insertBits_428b0b = OpFunction %void None %26
- %29 = OpLabel
- %res = OpVariable %_ptr_Function_v3int Function %36
- %30 = OpFunctionCall %v3int %tint_insert_bits %32 %32 %uint_1 %uint_1
- OpStore %res %30
+%insertBits_428b0b = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_v3int Function %19
+ OpStore %res %16
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %37
- %39 = OpLabel
- %40 = OpFunctionCall %void %insertBits_428b0b
+%vertex_main_inner = OpFunction %v4float None %20
+ %22 = OpLabel
+ %23 = OpFunctionCall %void %insertBits_428b0b
OpReturnValue %5
OpFunctionEnd
-%vertex_main = OpFunction %void None %26
- %42 = OpLabel
- %43 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %43
+%vertex_main = OpFunction %void None %9
+ %25 = OpLabel
+ %26 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %26
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
-%fragment_main = OpFunction %void None %26
- %46 = OpLabel
- %47 = OpFunctionCall %void %insertBits_428b0b
+%fragment_main = OpFunction %void None %9
+ %29 = OpLabel
+ %30 = OpFunctionCall %void %insertBits_428b0b
OpReturn
OpFunctionEnd
-%compute_main = OpFunction %void None %26
- %49 = OpLabel
- %50 = OpFunctionCall %void %insertBits_428b0b
+%compute_main = OpFunction %void None %9
+ %32 = OpLabel
+ %33 = OpFunctionCall %void %insertBits_428b0b
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/insertBits/51ede1.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/insertBits/51ede1.wgsl.expected.dxc.hlsl
index 25671aa..3e2e173 100644
--- a/test/tint/builtins/gen/literal/insertBits/51ede1.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/insertBits/51ede1.wgsl.expected.dxc.hlsl
@@ -1,12 +1,5 @@
-uint4 tint_insert_bits(uint4 v, uint4 n, uint offset, uint count) {
- const uint s = min(offset, 32u);
- const uint e = min(32u, (s + count));
- const uint mask = (((1u << s) - 1u) ^ ((1u << e) - 1u));
- return (((n << uint4((s).xxxx)) & uint4((mask).xxxx)) | (v & uint4((~(mask)).xxxx)));
-}
-
void insertBits_51ede1() {
- uint4 res = tint_insert_bits((1u).xxxx, (1u).xxxx, 1u, 1u);
+ uint4 res = (3u).xxxx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/insertBits/51ede1.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/insertBits/51ede1.wgsl.expected.fxc.hlsl
index 25671aa..3e2e173 100644
--- a/test/tint/builtins/gen/literal/insertBits/51ede1.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/insertBits/51ede1.wgsl.expected.fxc.hlsl
@@ -1,12 +1,5 @@
-uint4 tint_insert_bits(uint4 v, uint4 n, uint offset, uint count) {
- const uint s = min(offset, 32u);
- const uint e = min(32u, (s + count));
- const uint mask = (((1u << s) - 1u) ^ ((1u << e) - 1u));
- return (((n << uint4((s).xxxx)) & uint4((mask).xxxx)) | (v & uint4((~(mask)).xxxx)));
-}
-
void insertBits_51ede1() {
- uint4 res = tint_insert_bits((1u).xxxx, (1u).xxxx, 1u, 1u);
+ uint4 res = (3u).xxxx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/insertBits/51ede1.wgsl.expected.glsl b/test/tint/builtins/gen/literal/insertBits/51ede1.wgsl.expected.glsl
index 4996ffb..9d67c29 100644
--- a/test/tint/builtins/gen/literal/insertBits/51ede1.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/insertBits/51ede1.wgsl.expected.glsl
@@ -1,13 +1,7 @@
#version 310 es
-uvec4 tint_insert_bits(uvec4 v, uvec4 n, uint offset, uint count) {
- uint s = min(offset, 32u);
- uint e = min(32u, (s + count));
- return bitfieldInsert(v, n, int(s), int((e - s)));
-}
-
void insertBits_51ede1() {
- uvec4 res = tint_insert_bits(uvec4(1u), uvec4(1u), 1u, 1u);
+ uvec4 res = uvec4(3u);
}
vec4 vertex_main() {
@@ -26,14 +20,8 @@
#version 310 es
precision mediump float;
-uvec4 tint_insert_bits(uvec4 v, uvec4 n, uint offset, uint count) {
- uint s = min(offset, 32u);
- uint e = min(32u, (s + count));
- return bitfieldInsert(v, n, int(s), int((e - s)));
-}
-
void insertBits_51ede1() {
- uvec4 res = tint_insert_bits(uvec4(1u), uvec4(1u), 1u, 1u);
+ uvec4 res = uvec4(3u);
}
void fragment_main() {
@@ -46,14 +34,8 @@
}
#version 310 es
-uvec4 tint_insert_bits(uvec4 v, uvec4 n, uint offset, uint count) {
- uint s = min(offset, 32u);
- uint e = min(32u, (s + count));
- return bitfieldInsert(v, n, int(s), int((e - s)));
-}
-
void insertBits_51ede1() {
- uvec4 res = tint_insert_bits(uvec4(1u), uvec4(1u), 1u, 1u);
+ uvec4 res = uvec4(3u);
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/insertBits/51ede1.wgsl.expected.msl b/test/tint/builtins/gen/literal/insertBits/51ede1.wgsl.expected.msl
index bd1ebb3..7f0158c 100644
--- a/test/tint/builtins/gen/literal/insertBits/51ede1.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/insertBits/51ede1.wgsl.expected.msl
@@ -1,14 +1,8 @@
#include <metal_stdlib>
using namespace metal;
-uint4 tint_insert_bits(uint4 v, uint4 n, uint offset, uint count) {
- uint const s = min(offset, 32u);
- uint const e = min(32u, (s + count));
- return insert_bits(v, n, s, (e - s));
-}
-
void insertBits_51ede1() {
- uint4 res = tint_insert_bits(uint4(1u), uint4(1u), 1u, 1u);
+ uint4 res = uint4(3u);
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/insertBits/51ede1.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/insertBits/51ede1.wgsl.expected.spvasm
index 0aa6178..37a228e 100644
--- a/test/tint/builtins/gen/literal/insertBits/51ede1.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/insertBits/51ede1.wgsl.expected.spvasm
@@ -1,10 +1,9 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 49
+; Bound: 34
; Schema: 0
OpCapability Shader
- %19 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -13,11 +12,6 @@
OpExecutionMode %compute_main LocalSize 1 1 1
OpName %value "value"
OpName %vertex_point_size "vertex_point_size"
- OpName %tint_insert_bits "tint_insert_bits"
- OpName %v "v"
- OpName %n "n"
- OpName %offset "offset"
- OpName %count "count"
OpName %insertBits_51ede1 "insertBits_51ede1"
OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner"
@@ -34,57 +28,41 @@
%_ptr_Output_float = OpTypePointer Output %float
%8 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
+ %void = OpTypeVoid
+ %9 = OpTypeFunction %void
%uint = OpTypeInt 32 0
%v4uint = OpTypeVector %uint 4
- %9 = OpTypeFunction %v4uint %v4uint %v4uint %uint %uint
- %uint_32 = OpConstant %uint 32
- %void = OpTypeVoid
- %25 = OpTypeFunction %void
- %uint_1 = OpConstant %uint 1
- %31 = OpConstantComposite %v4uint %uint_1 %uint_1 %uint_1 %uint_1
+ %uint_3 = OpConstant %uint 3
+ %16 = OpConstantComposite %v4uint %uint_3 %uint_3 %uint_3 %uint_3
%_ptr_Function_v4uint = OpTypePointer Function %v4uint
- %34 = OpConstantNull %v4uint
- %35 = OpTypeFunction %v4float
+ %19 = OpConstantNull %v4uint
+ %20 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
-%tint_insert_bits = OpFunction %v4uint None %9
- %v = OpFunctionParameter %v4uint
- %n = OpFunctionParameter %v4uint
- %offset = OpFunctionParameter %uint
- %count = OpFunctionParameter %uint
- %17 = OpLabel
- %18 = OpExtInst %uint %19 UMin %offset %uint_32
- %22 = OpIAdd %uint %18 %count
- %21 = OpExtInst %uint %19 UMin %uint_32 %22
- %24 = OpISub %uint %21 %18
- %23 = OpBitFieldInsert %v4uint %v %n %18 %24
- OpReturnValue %23
- OpFunctionEnd
-%insertBits_51ede1 = OpFunction %void None %25
- %28 = OpLabel
- %res = OpVariable %_ptr_Function_v4uint Function %34
- %29 = OpFunctionCall %v4uint %tint_insert_bits %31 %31 %uint_1 %uint_1
- OpStore %res %29
+%insertBits_51ede1 = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_v4uint Function %19
+ OpStore %res %16
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %35
- %37 = OpLabel
- %38 = OpFunctionCall %void %insertBits_51ede1
+%vertex_main_inner = OpFunction %v4float None %20
+ %22 = OpLabel
+ %23 = OpFunctionCall %void %insertBits_51ede1
OpReturnValue %5
OpFunctionEnd
-%vertex_main = OpFunction %void None %25
- %40 = OpLabel
- %41 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %41
+%vertex_main = OpFunction %void None %9
+ %25 = OpLabel
+ %26 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %26
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
-%fragment_main = OpFunction %void None %25
- %44 = OpLabel
- %45 = OpFunctionCall %void %insertBits_51ede1
+%fragment_main = OpFunction %void None %9
+ %29 = OpLabel
+ %30 = OpFunctionCall %void %insertBits_51ede1
OpReturn
OpFunctionEnd
-%compute_main = OpFunction %void None %25
- %47 = OpLabel
- %48 = OpFunctionCall %void %insertBits_51ede1
+%compute_main = OpFunction %void None %9
+ %32 = OpLabel
+ %33 = OpFunctionCall %void %insertBits_51ede1
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/insertBits/65468b.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/insertBits/65468b.wgsl.expected.dxc.hlsl
index 57a24ad..9482530 100644
--- a/test/tint/builtins/gen/literal/insertBits/65468b.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/insertBits/65468b.wgsl.expected.dxc.hlsl
@@ -1,12 +1,5 @@
-int tint_insert_bits(int v, int n, uint offset, uint count) {
- const uint s = min(offset, 32u);
- const uint e = min(32u, (s + count));
- const uint mask = (((1u << s) - 1u) ^ ((1u << e) - 1u));
- return (((n << s) & int(mask)) | (v & int(~(mask))));
-}
-
void insertBits_65468b() {
- int res = tint_insert_bits(1, 1, 1u, 1u);
+ int res = 3;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/insertBits/65468b.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/insertBits/65468b.wgsl.expected.fxc.hlsl
index 57a24ad..9482530 100644
--- a/test/tint/builtins/gen/literal/insertBits/65468b.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/insertBits/65468b.wgsl.expected.fxc.hlsl
@@ -1,12 +1,5 @@
-int tint_insert_bits(int v, int n, uint offset, uint count) {
- const uint s = min(offset, 32u);
- const uint e = min(32u, (s + count));
- const uint mask = (((1u << s) - 1u) ^ ((1u << e) - 1u));
- return (((n << s) & int(mask)) | (v & int(~(mask))));
-}
-
void insertBits_65468b() {
- int res = tint_insert_bits(1, 1, 1u, 1u);
+ int res = 3;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/insertBits/65468b.wgsl.expected.glsl b/test/tint/builtins/gen/literal/insertBits/65468b.wgsl.expected.glsl
index 88dfff2..3d7ce5c 100644
--- a/test/tint/builtins/gen/literal/insertBits/65468b.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/insertBits/65468b.wgsl.expected.glsl
@@ -1,13 +1,7 @@
#version 310 es
-int tint_insert_bits(int v, int n, uint offset, uint count) {
- uint s = min(offset, 32u);
- uint e = min(32u, (s + count));
- return bitfieldInsert(v, n, int(s), int((e - s)));
-}
-
void insertBits_65468b() {
- int res = tint_insert_bits(1, 1, 1u, 1u);
+ int res = 3;
}
vec4 vertex_main() {
@@ -26,14 +20,8 @@
#version 310 es
precision mediump float;
-int tint_insert_bits(int v, int n, uint offset, uint count) {
- uint s = min(offset, 32u);
- uint e = min(32u, (s + count));
- return bitfieldInsert(v, n, int(s), int((e - s)));
-}
-
void insertBits_65468b() {
- int res = tint_insert_bits(1, 1, 1u, 1u);
+ int res = 3;
}
void fragment_main() {
@@ -46,14 +34,8 @@
}
#version 310 es
-int tint_insert_bits(int v, int n, uint offset, uint count) {
- uint s = min(offset, 32u);
- uint e = min(32u, (s + count));
- return bitfieldInsert(v, n, int(s), int((e - s)));
-}
-
void insertBits_65468b() {
- int res = tint_insert_bits(1, 1, 1u, 1u);
+ int res = 3;
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/insertBits/65468b.wgsl.expected.msl b/test/tint/builtins/gen/literal/insertBits/65468b.wgsl.expected.msl
index dcee063..959af5c 100644
--- a/test/tint/builtins/gen/literal/insertBits/65468b.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/insertBits/65468b.wgsl.expected.msl
@@ -1,14 +1,8 @@
#include <metal_stdlib>
using namespace metal;
-int tint_insert_bits(int v, int n, uint offset, uint count) {
- uint const s = min(offset, 32u);
- uint const e = min(32u, (s + count));
- return insert_bits(v, n, s, (e - s));
-}
-
void insertBits_65468b() {
- int res = tint_insert_bits(1, 1, 1u, 1u);
+ int res = 3;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/insertBits/65468b.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/insertBits/65468b.wgsl.expected.spvasm
index 411e289..e51f4a2 100644
--- a/test/tint/builtins/gen/literal/insertBits/65468b.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/insertBits/65468b.wgsl.expected.spvasm
@@ -1,10 +1,9 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 49
+; Bound: 32
; Schema: 0
OpCapability Shader
- %19 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -13,11 +12,6 @@
OpExecutionMode %compute_main LocalSize 1 1 1
OpName %value "value"
OpName %vertex_point_size "vertex_point_size"
- OpName %tint_insert_bits "tint_insert_bits"
- OpName %v "v"
- OpName %n "n"
- OpName %offset "offset"
- OpName %count "count"
OpName %insertBits_65468b "insertBits_65468b"
OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner"
@@ -34,57 +28,39 @@
%_ptr_Output_float = OpTypePointer Output %float
%8 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
- %int = OpTypeInt 32 1
- %uint = OpTypeInt 32 0
- %9 = OpTypeFunction %int %int %int %uint %uint
- %uint_32 = OpConstant %uint 32
%void = OpTypeVoid
- %25 = OpTypeFunction %void
- %int_1 = OpConstant %int 1
- %uint_1 = OpConstant %uint 1
+ %9 = OpTypeFunction %void
+ %int = OpTypeInt 32 1
+ %int_3 = OpConstant %int 3
%_ptr_Function_int = OpTypePointer Function %int
- %34 = OpConstantNull %int
- %35 = OpTypeFunction %v4float
+ %17 = OpConstantNull %int
+ %18 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
-%tint_insert_bits = OpFunction %int None %9
- %v = OpFunctionParameter %int
- %n = OpFunctionParameter %int
- %offset = OpFunctionParameter %uint
- %count = OpFunctionParameter %uint
- %17 = OpLabel
- %18 = OpExtInst %uint %19 UMin %offset %uint_32
- %22 = OpIAdd %uint %18 %count
- %21 = OpExtInst %uint %19 UMin %uint_32 %22
- %24 = OpISub %uint %21 %18
- %23 = OpBitFieldInsert %int %v %n %18 %24
- OpReturnValue %23
- OpFunctionEnd
-%insertBits_65468b = OpFunction %void None %25
- %28 = OpLabel
- %res = OpVariable %_ptr_Function_int Function %34
- %29 = OpFunctionCall %int %tint_insert_bits %int_1 %int_1 %uint_1 %uint_1
- OpStore %res %29
+%insertBits_65468b = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_int Function %17
+ OpStore %res %int_3
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %35
- %37 = OpLabel
- %38 = OpFunctionCall %void %insertBits_65468b
+%vertex_main_inner = OpFunction %v4float None %18
+ %20 = OpLabel
+ %21 = OpFunctionCall %void %insertBits_65468b
OpReturnValue %5
OpFunctionEnd
-%vertex_main = OpFunction %void None %25
- %40 = OpLabel
- %41 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %41
+%vertex_main = OpFunction %void None %9
+ %23 = OpLabel
+ %24 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %24
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
-%fragment_main = OpFunction %void None %25
- %44 = OpLabel
- %45 = OpFunctionCall %void %insertBits_65468b
+%fragment_main = OpFunction %void None %9
+ %27 = OpLabel
+ %28 = OpFunctionCall %void %insertBits_65468b
OpReturn
OpFunctionEnd
-%compute_main = OpFunction %void None %25
- %47 = OpLabel
- %48 = OpFunctionCall %void %insertBits_65468b
+%compute_main = OpFunction %void None %9
+ %30 = OpLabel
+ %31 = OpFunctionCall %void %insertBits_65468b
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/insertBits/87826b.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/insertBits/87826b.wgsl.expected.dxc.hlsl
index e0c5147..1c1f0ca 100644
--- a/test/tint/builtins/gen/literal/insertBits/87826b.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/insertBits/87826b.wgsl.expected.dxc.hlsl
@@ -1,12 +1,5 @@
-uint3 tint_insert_bits(uint3 v, uint3 n, uint offset, uint count) {
- const uint s = min(offset, 32u);
- const uint e = min(32u, (s + count));
- const uint mask = (((1u << s) - 1u) ^ ((1u << e) - 1u));
- return (((n << uint3((s).xxx)) & uint3((mask).xxx)) | (v & uint3((~(mask)).xxx)));
-}
-
void insertBits_87826b() {
- uint3 res = tint_insert_bits((1u).xxx, (1u).xxx, 1u, 1u);
+ uint3 res = (3u).xxx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/insertBits/87826b.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/insertBits/87826b.wgsl.expected.fxc.hlsl
index e0c5147..1c1f0ca 100644
--- a/test/tint/builtins/gen/literal/insertBits/87826b.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/insertBits/87826b.wgsl.expected.fxc.hlsl
@@ -1,12 +1,5 @@
-uint3 tint_insert_bits(uint3 v, uint3 n, uint offset, uint count) {
- const uint s = min(offset, 32u);
- const uint e = min(32u, (s + count));
- const uint mask = (((1u << s) - 1u) ^ ((1u << e) - 1u));
- return (((n << uint3((s).xxx)) & uint3((mask).xxx)) | (v & uint3((~(mask)).xxx)));
-}
-
void insertBits_87826b() {
- uint3 res = tint_insert_bits((1u).xxx, (1u).xxx, 1u, 1u);
+ uint3 res = (3u).xxx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/insertBits/87826b.wgsl.expected.glsl b/test/tint/builtins/gen/literal/insertBits/87826b.wgsl.expected.glsl
index e0e8d8e..12710a5 100644
--- a/test/tint/builtins/gen/literal/insertBits/87826b.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/insertBits/87826b.wgsl.expected.glsl
@@ -1,13 +1,7 @@
#version 310 es
-uvec3 tint_insert_bits(uvec3 v, uvec3 n, uint offset, uint count) {
- uint s = min(offset, 32u);
- uint e = min(32u, (s + count));
- return bitfieldInsert(v, n, int(s), int((e - s)));
-}
-
void insertBits_87826b() {
- uvec3 res = tint_insert_bits(uvec3(1u), uvec3(1u), 1u, 1u);
+ uvec3 res = uvec3(3u);
}
vec4 vertex_main() {
@@ -26,14 +20,8 @@
#version 310 es
precision mediump float;
-uvec3 tint_insert_bits(uvec3 v, uvec3 n, uint offset, uint count) {
- uint s = min(offset, 32u);
- uint e = min(32u, (s + count));
- return bitfieldInsert(v, n, int(s), int((e - s)));
-}
-
void insertBits_87826b() {
- uvec3 res = tint_insert_bits(uvec3(1u), uvec3(1u), 1u, 1u);
+ uvec3 res = uvec3(3u);
}
void fragment_main() {
@@ -46,14 +34,8 @@
}
#version 310 es
-uvec3 tint_insert_bits(uvec3 v, uvec3 n, uint offset, uint count) {
- uint s = min(offset, 32u);
- uint e = min(32u, (s + count));
- return bitfieldInsert(v, n, int(s), int((e - s)));
-}
-
void insertBits_87826b() {
- uvec3 res = tint_insert_bits(uvec3(1u), uvec3(1u), 1u, 1u);
+ uvec3 res = uvec3(3u);
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/insertBits/87826b.wgsl.expected.msl b/test/tint/builtins/gen/literal/insertBits/87826b.wgsl.expected.msl
index c8ea865..776b271 100644
--- a/test/tint/builtins/gen/literal/insertBits/87826b.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/insertBits/87826b.wgsl.expected.msl
@@ -1,14 +1,8 @@
#include <metal_stdlib>
using namespace metal;
-uint3 tint_insert_bits(uint3 v, uint3 n, uint offset, uint count) {
- uint const s = min(offset, 32u);
- uint const e = min(32u, (s + count));
- return insert_bits(v, n, s, (e - s));
-}
-
void insertBits_87826b() {
- uint3 res = tint_insert_bits(uint3(1u), uint3(1u), 1u, 1u);
+ uint3 res = uint3(3u);
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/insertBits/87826b.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/insertBits/87826b.wgsl.expected.spvasm
index e361250..76b42f1 100644
--- a/test/tint/builtins/gen/literal/insertBits/87826b.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/insertBits/87826b.wgsl.expected.spvasm
@@ -1,10 +1,9 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 49
+; Bound: 34
; Schema: 0
OpCapability Shader
- %19 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -13,11 +12,6 @@
OpExecutionMode %compute_main LocalSize 1 1 1
OpName %value "value"
OpName %vertex_point_size "vertex_point_size"
- OpName %tint_insert_bits "tint_insert_bits"
- OpName %v "v"
- OpName %n "n"
- OpName %offset "offset"
- OpName %count "count"
OpName %insertBits_87826b "insertBits_87826b"
OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner"
@@ -34,57 +28,41 @@
%_ptr_Output_float = OpTypePointer Output %float
%8 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
+ %void = OpTypeVoid
+ %9 = OpTypeFunction %void
%uint = OpTypeInt 32 0
%v3uint = OpTypeVector %uint 3
- %9 = OpTypeFunction %v3uint %v3uint %v3uint %uint %uint
- %uint_32 = OpConstant %uint 32
- %void = OpTypeVoid
- %25 = OpTypeFunction %void
- %uint_1 = OpConstant %uint 1
- %31 = OpConstantComposite %v3uint %uint_1 %uint_1 %uint_1
+ %uint_3 = OpConstant %uint 3
+ %16 = OpConstantComposite %v3uint %uint_3 %uint_3 %uint_3
%_ptr_Function_v3uint = OpTypePointer Function %v3uint
- %34 = OpConstantNull %v3uint
- %35 = OpTypeFunction %v4float
+ %19 = OpConstantNull %v3uint
+ %20 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
-%tint_insert_bits = OpFunction %v3uint None %9
- %v = OpFunctionParameter %v3uint
- %n = OpFunctionParameter %v3uint
- %offset = OpFunctionParameter %uint
- %count = OpFunctionParameter %uint
- %17 = OpLabel
- %18 = OpExtInst %uint %19 UMin %offset %uint_32
- %22 = OpIAdd %uint %18 %count
- %21 = OpExtInst %uint %19 UMin %uint_32 %22
- %24 = OpISub %uint %21 %18
- %23 = OpBitFieldInsert %v3uint %v %n %18 %24
- OpReturnValue %23
- OpFunctionEnd
-%insertBits_87826b = OpFunction %void None %25
- %28 = OpLabel
- %res = OpVariable %_ptr_Function_v3uint Function %34
- %29 = OpFunctionCall %v3uint %tint_insert_bits %31 %31 %uint_1 %uint_1
- OpStore %res %29
+%insertBits_87826b = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_v3uint Function %19
+ OpStore %res %16
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %35
- %37 = OpLabel
- %38 = OpFunctionCall %void %insertBits_87826b
+%vertex_main_inner = OpFunction %v4float None %20
+ %22 = OpLabel
+ %23 = OpFunctionCall %void %insertBits_87826b
OpReturnValue %5
OpFunctionEnd
-%vertex_main = OpFunction %void None %25
- %40 = OpLabel
- %41 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %41
+%vertex_main = OpFunction %void None %9
+ %25 = OpLabel
+ %26 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %26
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
-%fragment_main = OpFunction %void None %25
- %44 = OpLabel
- %45 = OpFunctionCall %void %insertBits_87826b
+%fragment_main = OpFunction %void None %9
+ %29 = OpLabel
+ %30 = OpFunctionCall %void %insertBits_87826b
OpReturn
OpFunctionEnd
-%compute_main = OpFunction %void None %25
- %47 = OpLabel
- %48 = OpFunctionCall %void %insertBits_87826b
+%compute_main = OpFunction %void None %9
+ %32 = OpLabel
+ %33 = OpFunctionCall %void %insertBits_87826b
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/insertBits/d86978.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/insertBits/d86978.wgsl.expected.dxc.hlsl
index 11333ba..106b71a 100644
--- a/test/tint/builtins/gen/literal/insertBits/d86978.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/insertBits/d86978.wgsl.expected.dxc.hlsl
@@ -1,12 +1,5 @@
-int4 tint_insert_bits(int4 v, int4 n, uint offset, uint count) {
- const uint s = min(offset, 32u);
- const uint e = min(32u, (s + count));
- const uint mask = (((1u << s) - 1u) ^ ((1u << e) - 1u));
- return (((n << uint4((s).xxxx)) & int4((int(mask)).xxxx)) | (v & int4((int(~(mask))).xxxx)));
-}
-
void insertBits_d86978() {
- int4 res = tint_insert_bits((1).xxxx, (1).xxxx, 1u, 1u);
+ int4 res = (3).xxxx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/insertBits/d86978.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/insertBits/d86978.wgsl.expected.fxc.hlsl
index 11333ba..106b71a 100644
--- a/test/tint/builtins/gen/literal/insertBits/d86978.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/insertBits/d86978.wgsl.expected.fxc.hlsl
@@ -1,12 +1,5 @@
-int4 tint_insert_bits(int4 v, int4 n, uint offset, uint count) {
- const uint s = min(offset, 32u);
- const uint e = min(32u, (s + count));
- const uint mask = (((1u << s) - 1u) ^ ((1u << e) - 1u));
- return (((n << uint4((s).xxxx)) & int4((int(mask)).xxxx)) | (v & int4((int(~(mask))).xxxx)));
-}
-
void insertBits_d86978() {
- int4 res = tint_insert_bits((1).xxxx, (1).xxxx, 1u, 1u);
+ int4 res = (3).xxxx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/insertBits/d86978.wgsl.expected.glsl b/test/tint/builtins/gen/literal/insertBits/d86978.wgsl.expected.glsl
index fc0aa6f..53b7d9e 100644
--- a/test/tint/builtins/gen/literal/insertBits/d86978.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/insertBits/d86978.wgsl.expected.glsl
@@ -1,13 +1,7 @@
#version 310 es
-ivec4 tint_insert_bits(ivec4 v, ivec4 n, uint offset, uint count) {
- uint s = min(offset, 32u);
- uint e = min(32u, (s + count));
- return bitfieldInsert(v, n, int(s), int((e - s)));
-}
-
void insertBits_d86978() {
- ivec4 res = tint_insert_bits(ivec4(1), ivec4(1), 1u, 1u);
+ ivec4 res = ivec4(3);
}
vec4 vertex_main() {
@@ -26,14 +20,8 @@
#version 310 es
precision mediump float;
-ivec4 tint_insert_bits(ivec4 v, ivec4 n, uint offset, uint count) {
- uint s = min(offset, 32u);
- uint e = min(32u, (s + count));
- return bitfieldInsert(v, n, int(s), int((e - s)));
-}
-
void insertBits_d86978() {
- ivec4 res = tint_insert_bits(ivec4(1), ivec4(1), 1u, 1u);
+ ivec4 res = ivec4(3);
}
void fragment_main() {
@@ -46,14 +34,8 @@
}
#version 310 es
-ivec4 tint_insert_bits(ivec4 v, ivec4 n, uint offset, uint count) {
- uint s = min(offset, 32u);
- uint e = min(32u, (s + count));
- return bitfieldInsert(v, n, int(s), int((e - s)));
-}
-
void insertBits_d86978() {
- ivec4 res = tint_insert_bits(ivec4(1), ivec4(1), 1u, 1u);
+ ivec4 res = ivec4(3);
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/insertBits/d86978.wgsl.expected.msl b/test/tint/builtins/gen/literal/insertBits/d86978.wgsl.expected.msl
index b7929fe..7e4d1bd 100644
--- a/test/tint/builtins/gen/literal/insertBits/d86978.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/insertBits/d86978.wgsl.expected.msl
@@ -1,14 +1,8 @@
#include <metal_stdlib>
using namespace metal;
-int4 tint_insert_bits(int4 v, int4 n, uint offset, uint count) {
- uint const s = min(offset, 32u);
- uint const e = min(32u, (s + count));
- return insert_bits(v, n, s, (e - s));
-}
-
void insertBits_d86978() {
- int4 res = tint_insert_bits(int4(1), int4(1), 1u, 1u);
+ int4 res = int4(3);
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/insertBits/d86978.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/insertBits/d86978.wgsl.expected.spvasm
index 639baf3..bdf19b8 100644
--- a/test/tint/builtins/gen/literal/insertBits/d86978.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/insertBits/d86978.wgsl.expected.spvasm
@@ -1,10 +1,9 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 51
+; Bound: 34
; Schema: 0
OpCapability Shader
- %20 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -13,11 +12,6 @@
OpExecutionMode %compute_main LocalSize 1 1 1
OpName %value "value"
OpName %vertex_point_size "vertex_point_size"
- OpName %tint_insert_bits "tint_insert_bits"
- OpName %v "v"
- OpName %n "n"
- OpName %offset "offset"
- OpName %count "count"
OpName %insertBits_d86978 "insertBits_d86978"
OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner"
@@ -34,59 +28,41 @@
%_ptr_Output_float = OpTypePointer Output %float
%8 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
+ %void = OpTypeVoid
+ %9 = OpTypeFunction %void
%int = OpTypeInt 32 1
%v4int = OpTypeVector %int 4
- %uint = OpTypeInt 32 0
- %9 = OpTypeFunction %v4int %v4int %v4int %uint %uint
- %uint_32 = OpConstant %uint 32
- %void = OpTypeVoid
- %26 = OpTypeFunction %void
- %int_1 = OpConstant %int 1
- %32 = OpConstantComposite %v4int %int_1 %int_1 %int_1 %int_1
- %uint_1 = OpConstant %uint 1
+ %int_3 = OpConstant %int 3
+ %16 = OpConstantComposite %v4int %int_3 %int_3 %int_3 %int_3
%_ptr_Function_v4int = OpTypePointer Function %v4int
- %36 = OpConstantNull %v4int
- %37 = OpTypeFunction %v4float
+ %19 = OpConstantNull %v4int
+ %20 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
-%tint_insert_bits = OpFunction %v4int None %9
- %v = OpFunctionParameter %v4int
- %n = OpFunctionParameter %v4int
- %offset = OpFunctionParameter %uint
- %count = OpFunctionParameter %uint
- %18 = OpLabel
- %19 = OpExtInst %uint %20 UMin %offset %uint_32
- %23 = OpIAdd %uint %19 %count
- %22 = OpExtInst %uint %20 UMin %uint_32 %23
- %25 = OpISub %uint %22 %19
- %24 = OpBitFieldInsert %v4int %v %n %19 %25
- OpReturnValue %24
- OpFunctionEnd
-%insertBits_d86978 = OpFunction %void None %26
- %29 = OpLabel
- %res = OpVariable %_ptr_Function_v4int Function %36
- %30 = OpFunctionCall %v4int %tint_insert_bits %32 %32 %uint_1 %uint_1
- OpStore %res %30
+%insertBits_d86978 = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_v4int Function %19
+ OpStore %res %16
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %37
- %39 = OpLabel
- %40 = OpFunctionCall %void %insertBits_d86978
+%vertex_main_inner = OpFunction %v4float None %20
+ %22 = OpLabel
+ %23 = OpFunctionCall %void %insertBits_d86978
OpReturnValue %5
OpFunctionEnd
-%vertex_main = OpFunction %void None %26
- %42 = OpLabel
- %43 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %43
+%vertex_main = OpFunction %void None %9
+ %25 = OpLabel
+ %26 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %26
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
-%fragment_main = OpFunction %void None %26
- %46 = OpLabel
- %47 = OpFunctionCall %void %insertBits_d86978
+%fragment_main = OpFunction %void None %9
+ %29 = OpLabel
+ %30 = OpFunctionCall %void %insertBits_d86978
OpReturn
OpFunctionEnd
-%compute_main = OpFunction %void None %26
- %49 = OpLabel
- %50 = OpFunctionCall %void %insertBits_d86978
+%compute_main = OpFunction %void None %9
+ %32 = OpLabel
+ %33 = OpFunctionCall %void %insertBits_d86978
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/insertBits/e3e3a2.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/insertBits/e3e3a2.wgsl.expected.dxc.hlsl
index 014ba4a..a5f4bf4 100644
--- a/test/tint/builtins/gen/literal/insertBits/e3e3a2.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/insertBits/e3e3a2.wgsl.expected.dxc.hlsl
@@ -1,12 +1,5 @@
-uint tint_insert_bits(uint v, uint n, uint offset, uint count) {
- const uint s = min(offset, 32u);
- const uint e = min(32u, (s + count));
- const uint mask = (((1u << s) - 1u) ^ ((1u << e) - 1u));
- return (((n << s) & mask) | (v & ~(mask)));
-}
-
void insertBits_e3e3a2() {
- uint res = tint_insert_bits(1u, 1u, 1u, 1u);
+ uint res = 3u;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/insertBits/e3e3a2.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/insertBits/e3e3a2.wgsl.expected.fxc.hlsl
index 014ba4a..a5f4bf4 100644
--- a/test/tint/builtins/gen/literal/insertBits/e3e3a2.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/insertBits/e3e3a2.wgsl.expected.fxc.hlsl
@@ -1,12 +1,5 @@
-uint tint_insert_bits(uint v, uint n, uint offset, uint count) {
- const uint s = min(offset, 32u);
- const uint e = min(32u, (s + count));
- const uint mask = (((1u << s) - 1u) ^ ((1u << e) - 1u));
- return (((n << s) & mask) | (v & ~(mask)));
-}
-
void insertBits_e3e3a2() {
- uint res = tint_insert_bits(1u, 1u, 1u, 1u);
+ uint res = 3u;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/insertBits/e3e3a2.wgsl.expected.glsl b/test/tint/builtins/gen/literal/insertBits/e3e3a2.wgsl.expected.glsl
index 2da5c2a..4b430e6 100644
--- a/test/tint/builtins/gen/literal/insertBits/e3e3a2.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/insertBits/e3e3a2.wgsl.expected.glsl
@@ -1,13 +1,7 @@
#version 310 es
-uint tint_insert_bits(uint v, uint n, uint offset, uint count) {
- uint s = min(offset, 32u);
- uint e = min(32u, (s + count));
- return bitfieldInsert(v, n, int(s), int((e - s)));
-}
-
void insertBits_e3e3a2() {
- uint res = tint_insert_bits(1u, 1u, 1u, 1u);
+ uint res = 3u;
}
vec4 vertex_main() {
@@ -26,14 +20,8 @@
#version 310 es
precision mediump float;
-uint tint_insert_bits(uint v, uint n, uint offset, uint count) {
- uint s = min(offset, 32u);
- uint e = min(32u, (s + count));
- return bitfieldInsert(v, n, int(s), int((e - s)));
-}
-
void insertBits_e3e3a2() {
- uint res = tint_insert_bits(1u, 1u, 1u, 1u);
+ uint res = 3u;
}
void fragment_main() {
@@ -46,14 +34,8 @@
}
#version 310 es
-uint tint_insert_bits(uint v, uint n, uint offset, uint count) {
- uint s = min(offset, 32u);
- uint e = min(32u, (s + count));
- return bitfieldInsert(v, n, int(s), int((e - s)));
-}
-
void insertBits_e3e3a2() {
- uint res = tint_insert_bits(1u, 1u, 1u, 1u);
+ uint res = 3u;
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/insertBits/e3e3a2.wgsl.expected.msl b/test/tint/builtins/gen/literal/insertBits/e3e3a2.wgsl.expected.msl
index 7edeb0c..e4b988c 100644
--- a/test/tint/builtins/gen/literal/insertBits/e3e3a2.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/insertBits/e3e3a2.wgsl.expected.msl
@@ -1,14 +1,8 @@
#include <metal_stdlib>
using namespace metal;
-uint tint_insert_bits(uint v, uint n, uint offset, uint count) {
- uint const s = min(offset, 32u);
- uint const e = min(32u, (s + count));
- return insert_bits(v, n, s, (e - s));
-}
-
void insertBits_e3e3a2() {
- uint res = tint_insert_bits(1u, 1u, 1u, 1u);
+ uint res = 3u;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/insertBits/e3e3a2.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/insertBits/e3e3a2.wgsl.expected.spvasm
index bde4e39..e347759 100644
--- a/test/tint/builtins/gen/literal/insertBits/e3e3a2.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/insertBits/e3e3a2.wgsl.expected.spvasm
@@ -1,10 +1,9 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 47
+; Bound: 32
; Schema: 0
OpCapability Shader
- %18 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -13,11 +12,6 @@
OpExecutionMode %compute_main LocalSize 1 1 1
OpName %value "value"
OpName %vertex_point_size "vertex_point_size"
- OpName %tint_insert_bits "tint_insert_bits"
- OpName %v "v"
- OpName %n "n"
- OpName %offset "offset"
- OpName %count "count"
OpName %insertBits_e3e3a2 "insertBits_e3e3a2"
OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner"
@@ -34,55 +28,39 @@
%_ptr_Output_float = OpTypePointer Output %float
%8 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
- %uint = OpTypeInt 32 0
- %9 = OpTypeFunction %uint %uint %uint %uint %uint
- %uint_32 = OpConstant %uint 32
%void = OpTypeVoid
- %24 = OpTypeFunction %void
- %uint_1 = OpConstant %uint 1
+ %9 = OpTypeFunction %void
+ %uint = OpTypeInt 32 0
+ %uint_3 = OpConstant %uint 3
%_ptr_Function_uint = OpTypePointer Function %uint
- %32 = OpConstantNull %uint
- %33 = OpTypeFunction %v4float
+ %17 = OpConstantNull %uint
+ %18 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
-%tint_insert_bits = OpFunction %uint None %9
- %v = OpFunctionParameter %uint
- %n = OpFunctionParameter %uint
- %offset = OpFunctionParameter %uint
- %count = OpFunctionParameter %uint
- %16 = OpLabel
- %17 = OpExtInst %uint %18 UMin %offset %uint_32
- %21 = OpIAdd %uint %17 %count
- %20 = OpExtInst %uint %18 UMin %uint_32 %21
- %23 = OpISub %uint %20 %17
- %22 = OpBitFieldInsert %uint %v %n %17 %23
- OpReturnValue %22
- OpFunctionEnd
-%insertBits_e3e3a2 = OpFunction %void None %24
- %27 = OpLabel
- %res = OpVariable %_ptr_Function_uint Function %32
- %28 = OpFunctionCall %uint %tint_insert_bits %uint_1 %uint_1 %uint_1 %uint_1
- OpStore %res %28
+%insertBits_e3e3a2 = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_uint Function %17
+ OpStore %res %uint_3
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %33
- %35 = OpLabel
- %36 = OpFunctionCall %void %insertBits_e3e3a2
+%vertex_main_inner = OpFunction %v4float None %18
+ %20 = OpLabel
+ %21 = OpFunctionCall %void %insertBits_e3e3a2
OpReturnValue %5
OpFunctionEnd
-%vertex_main = OpFunction %void None %24
- %38 = OpLabel
- %39 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %39
+%vertex_main = OpFunction %void None %9
+ %23 = OpLabel
+ %24 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %24
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
-%fragment_main = OpFunction %void None %24
- %42 = OpLabel
- %43 = OpFunctionCall %void %insertBits_e3e3a2
+%fragment_main = OpFunction %void None %9
+ %27 = OpLabel
+ %28 = OpFunctionCall %void %insertBits_e3e3a2
OpReturn
OpFunctionEnd
-%compute_main = OpFunction %void None %24
- %45 = OpLabel
- %46 = OpFunctionCall %void %insertBits_e3e3a2
+%compute_main = OpFunction %void None %9
+ %30 = OpLabel
+ %31 = OpFunctionCall %void %insertBits_e3e3a2
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/insertBits/fe6ba6.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/insertBits/fe6ba6.wgsl.expected.dxc.hlsl
index 6861d6e..7e1fa26 100644
--- a/test/tint/builtins/gen/literal/insertBits/fe6ba6.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/insertBits/fe6ba6.wgsl.expected.dxc.hlsl
@@ -1,12 +1,5 @@
-int2 tint_insert_bits(int2 v, int2 n, uint offset, uint count) {
- const uint s = min(offset, 32u);
- const uint e = min(32u, (s + count));
- const uint mask = (((1u << s) - 1u) ^ ((1u << e) - 1u));
- return (((n << uint2((s).xx)) & int2((int(mask)).xx)) | (v & int2((int(~(mask))).xx)));
-}
-
void insertBits_fe6ba6() {
- int2 res = tint_insert_bits((1).xx, (1).xx, 1u, 1u);
+ int2 res = (3).xx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/insertBits/fe6ba6.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/insertBits/fe6ba6.wgsl.expected.fxc.hlsl
index 6861d6e..7e1fa26 100644
--- a/test/tint/builtins/gen/literal/insertBits/fe6ba6.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/insertBits/fe6ba6.wgsl.expected.fxc.hlsl
@@ -1,12 +1,5 @@
-int2 tint_insert_bits(int2 v, int2 n, uint offset, uint count) {
- const uint s = min(offset, 32u);
- const uint e = min(32u, (s + count));
- const uint mask = (((1u << s) - 1u) ^ ((1u << e) - 1u));
- return (((n << uint2((s).xx)) & int2((int(mask)).xx)) | (v & int2((int(~(mask))).xx)));
-}
-
void insertBits_fe6ba6() {
- int2 res = tint_insert_bits((1).xx, (1).xx, 1u, 1u);
+ int2 res = (3).xx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/insertBits/fe6ba6.wgsl.expected.glsl b/test/tint/builtins/gen/literal/insertBits/fe6ba6.wgsl.expected.glsl
index 3a65590..1a48f38 100644
--- a/test/tint/builtins/gen/literal/insertBits/fe6ba6.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/insertBits/fe6ba6.wgsl.expected.glsl
@@ -1,13 +1,7 @@
#version 310 es
-ivec2 tint_insert_bits(ivec2 v, ivec2 n, uint offset, uint count) {
- uint s = min(offset, 32u);
- uint e = min(32u, (s + count));
- return bitfieldInsert(v, n, int(s), int((e - s)));
-}
-
void insertBits_fe6ba6() {
- ivec2 res = tint_insert_bits(ivec2(1), ivec2(1), 1u, 1u);
+ ivec2 res = ivec2(3);
}
vec4 vertex_main() {
@@ -26,14 +20,8 @@
#version 310 es
precision mediump float;
-ivec2 tint_insert_bits(ivec2 v, ivec2 n, uint offset, uint count) {
- uint s = min(offset, 32u);
- uint e = min(32u, (s + count));
- return bitfieldInsert(v, n, int(s), int((e - s)));
-}
-
void insertBits_fe6ba6() {
- ivec2 res = tint_insert_bits(ivec2(1), ivec2(1), 1u, 1u);
+ ivec2 res = ivec2(3);
}
void fragment_main() {
@@ -46,14 +34,8 @@
}
#version 310 es
-ivec2 tint_insert_bits(ivec2 v, ivec2 n, uint offset, uint count) {
- uint s = min(offset, 32u);
- uint e = min(32u, (s + count));
- return bitfieldInsert(v, n, int(s), int((e - s)));
-}
-
void insertBits_fe6ba6() {
- ivec2 res = tint_insert_bits(ivec2(1), ivec2(1), 1u, 1u);
+ ivec2 res = ivec2(3);
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/insertBits/fe6ba6.wgsl.expected.msl b/test/tint/builtins/gen/literal/insertBits/fe6ba6.wgsl.expected.msl
index 8b053ad..9198fa1 100644
--- a/test/tint/builtins/gen/literal/insertBits/fe6ba6.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/insertBits/fe6ba6.wgsl.expected.msl
@@ -1,14 +1,8 @@
#include <metal_stdlib>
using namespace metal;
-int2 tint_insert_bits(int2 v, int2 n, uint offset, uint count) {
- uint const s = min(offset, 32u);
- uint const e = min(32u, (s + count));
- return insert_bits(v, n, s, (e - s));
-}
-
void insertBits_fe6ba6() {
- int2 res = tint_insert_bits(int2(1), int2(1), 1u, 1u);
+ int2 res = int2(3);
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/insertBits/fe6ba6.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/insertBits/fe6ba6.wgsl.expected.spvasm
index 18cbaaf..1b4a987 100644
--- a/test/tint/builtins/gen/literal/insertBits/fe6ba6.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/insertBits/fe6ba6.wgsl.expected.spvasm
@@ -1,10 +1,9 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 51
+; Bound: 34
; Schema: 0
OpCapability Shader
- %20 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -13,11 +12,6 @@
OpExecutionMode %compute_main LocalSize 1 1 1
OpName %value "value"
OpName %vertex_point_size "vertex_point_size"
- OpName %tint_insert_bits "tint_insert_bits"
- OpName %v "v"
- OpName %n "n"
- OpName %offset "offset"
- OpName %count "count"
OpName %insertBits_fe6ba6 "insertBits_fe6ba6"
OpName %res "res"
OpName %vertex_main_inner "vertex_main_inner"
@@ -34,59 +28,41 @@
%_ptr_Output_float = OpTypePointer Output %float
%8 = OpConstantNull %float
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
+ %void = OpTypeVoid
+ %9 = OpTypeFunction %void
%int = OpTypeInt 32 1
%v2int = OpTypeVector %int 2
- %uint = OpTypeInt 32 0
- %9 = OpTypeFunction %v2int %v2int %v2int %uint %uint
- %uint_32 = OpConstant %uint 32
- %void = OpTypeVoid
- %26 = OpTypeFunction %void
- %int_1 = OpConstant %int 1
- %32 = OpConstantComposite %v2int %int_1 %int_1
- %uint_1 = OpConstant %uint 1
+ %int_3 = OpConstant %int 3
+ %16 = OpConstantComposite %v2int %int_3 %int_3
%_ptr_Function_v2int = OpTypePointer Function %v2int
- %36 = OpConstantNull %v2int
- %37 = OpTypeFunction %v4float
+ %19 = OpConstantNull %v2int
+ %20 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
-%tint_insert_bits = OpFunction %v2int None %9
- %v = OpFunctionParameter %v2int
- %n = OpFunctionParameter %v2int
- %offset = OpFunctionParameter %uint
- %count = OpFunctionParameter %uint
- %18 = OpLabel
- %19 = OpExtInst %uint %20 UMin %offset %uint_32
- %23 = OpIAdd %uint %19 %count
- %22 = OpExtInst %uint %20 UMin %uint_32 %23
- %25 = OpISub %uint %22 %19
- %24 = OpBitFieldInsert %v2int %v %n %19 %25
- OpReturnValue %24
- OpFunctionEnd
-%insertBits_fe6ba6 = OpFunction %void None %26
- %29 = OpLabel
- %res = OpVariable %_ptr_Function_v2int Function %36
- %30 = OpFunctionCall %v2int %tint_insert_bits %32 %32 %uint_1 %uint_1
- OpStore %res %30
+%insertBits_fe6ba6 = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_v2int Function %19
+ OpStore %res %16
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %37
- %39 = OpLabel
- %40 = OpFunctionCall %void %insertBits_fe6ba6
+%vertex_main_inner = OpFunction %v4float None %20
+ %22 = OpLabel
+ %23 = OpFunctionCall %void %insertBits_fe6ba6
OpReturnValue %5
OpFunctionEnd
-%vertex_main = OpFunction %void None %26
- %42 = OpLabel
- %43 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %43
+%vertex_main = OpFunction %void None %9
+ %25 = OpLabel
+ %26 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %26
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
-%fragment_main = OpFunction %void None %26
- %46 = OpLabel
- %47 = OpFunctionCall %void %insertBits_fe6ba6
+%fragment_main = OpFunction %void None %9
+ %29 = OpLabel
+ %30 = OpFunctionCall %void %insertBits_fe6ba6
OpReturn
OpFunctionEnd
-%compute_main = OpFunction %void None %26
- %49 = OpLabel
- %50 = OpFunctionCall %void %insertBits_fe6ba6
+%compute_main = OpFunction %void None %9
+ %32 = OpLabel
+ %33 = OpFunctionCall %void %insertBits_fe6ba6
OpReturn
OpFunctionEnd
diff --git a/webgpu-cts/expectations.txt b/webgpu-cts/expectations.txt
index 38de05e..34d2e53 100644
--- a/webgpu-cts/expectations.txt
+++ b/webgpu-cts/expectations.txt
@@ -455,14 +455,6 @@
crbug.com/tint/1613 webgpu:shader,execution,expression,call,builtin,fract:f32:inputSource="const";vectorize=2 [ Failure ]
crbug.com/tint/1613 webgpu:shader,execution,expression,call,builtin,fract:f32:inputSource="const";vectorize=3 [ Failure ]
crbug.com/tint/1613 webgpu:shader,execution,expression,call,builtin,fract:f32:inputSource="const";vectorize=4 [ Failure ]
-crbug.com/tint/1613 webgpu:shader,execution,expression,call,builtin,insertBits:integer:inputSource="const";signed=false;width=1 [ Failure ]
-crbug.com/tint/1613 webgpu:shader,execution,expression,call,builtin,insertBits:integer:inputSource="const";signed=false;width=2 [ Failure ]
-crbug.com/tint/1613 webgpu:shader,execution,expression,call,builtin,insertBits:integer:inputSource="const";signed=false;width=3 [ Failure ]
-crbug.com/tint/1613 webgpu:shader,execution,expression,call,builtin,insertBits:integer:inputSource="const";signed=false;width=4 [ Failure ]
-crbug.com/tint/1613 webgpu:shader,execution,expression,call,builtin,insertBits:integer:inputSource="const";signed=true;width=1 [ Failure ]
-crbug.com/tint/1613 webgpu:shader,execution,expression,call,builtin,insertBits:integer:inputSource="const";signed=true;width=2 [ Failure ]
-crbug.com/tint/1613 webgpu:shader,execution,expression,call,builtin,insertBits:integer:inputSource="const";signed=true;width=3 [ Failure ]
-crbug.com/tint/1613 webgpu:shader,execution,expression,call,builtin,insertBits:integer:inputSource="const";signed=true;width=4 [ Failure ]
crbug.com/tint/1613 webgpu:shader,execution,expression,call,builtin,inversesqrt:f32:inputSource="const";vectorize="_undef_" [ Failure ]
crbug.com/tint/1613 webgpu:shader,execution,expression,call,builtin,inversesqrt:f32:inputSource="const";vectorize=2 [ Failure ]
crbug.com/tint/1613 webgpu:shader,execution,expression,call,builtin,inversesqrt:f32:inputSource="const";vectorize=3 [ Failure ]