tint: const eval of length builtin
Bug: tint:1581
Change-Id: Ie6dc9da6b48c606af03da023c835ec36a99dd362
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110981
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
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 f2b4d7e..4bb101e 100644
--- a/src/tint/intrinsics.def
+++ b/src/tint/intrinsics.def
@@ -491,8 +491,8 @@
fn inverseSqrt<N: num, T: f32_f16>(vec<N, T>) -> vec<N, T>
fn ldexp<T: f32_f16>(T, i32) -> T
fn ldexp<N: num, T: f32_f16>(vec<N, T>, vec<N, i32>) -> vec<N, T>
-fn length<T: f32_f16>(T) -> T
-fn length<N: num, T: f32_f16>(vec<N, T>) -> T
+@const fn length<T: fa_f32_f16>(@test_value(0.0) T) -> T
+@const fn length<N: num, T: fa_f32_f16>(@test_value(0.0) vec<N, T>) -> T
fn log<T: f32_f16>(T) -> T
fn log<N: num, T: f32_f16>(vec<N, T>) -> vec<N, T>
fn log2<T: f32_f16>(T) -> T
diff --git a/src/tint/resolver/builtin_test.cc b/src/tint/resolver/builtin_test.cc
index 9fc6090..c6ca1f4 100644
--- a/src/tint/resolver/builtin_test.cc
+++ b/src/tint/resolver/builtin_test.cc
@@ -1184,8 +1184,8 @@
EXPECT_EQ(r()->error(), R"(error: no matching call to length()
2 candidate functions:
- length(T) -> T where: T is f32 or f16
- length(vecN<T>) -> T where: T is f32 or f16
+ length(T) -> T where: T is abstract-float, f32 or f16
+ length(vecN<T>) -> T where: T is abstract-float, f32 or f16
)");
}
@@ -1198,8 +1198,8 @@
EXPECT_EQ(r()->error(), R"(error: no matching call to length(f32, f32)
2 candidate functions:
- length(T) -> T where: T is f32 or f16
- length(vecN<T>) -> T where: T is f32 or f16
+ length(T) -> T where: T is abstract-float, f32 or f16
+ length(vecN<T>) -> T where: T is abstract-float, f32 or f16
)");
}
diff --git a/src/tint/resolver/const_eval.cc b/src/tint/resolver/const_eval.cc
index 28e100e..6cdf8f4 100644
--- a/src/tint/resolver/const_eval.cc
+++ b/src/tint/resolver/const_eval.cc
@@ -891,6 +891,24 @@
}
template <typename NumberT>
+utils::Result<NumberT> ConstEval::Sqrt(const Source& source, NumberT v) {
+ if (v < NumberT(0)) {
+ AddError("sqrt must be called with a value >= 0", source);
+ return utils::Failure;
+ }
+ return NumberT{std::sqrt(v)};
+}
+
+auto ConstEval::SqrtFunc(const Source& source, const sem::Type* elem_ty) {
+ return [=](auto v) -> ImplResult {
+ if (auto r = Sqrt(source, v)) {
+ return CreateElement(builder, source, elem_ty, r.Get());
+ }
+ return utils::Failure;
+ };
+}
+
+template <typename NumberT>
utils::Result<NumberT> ConstEval::Clamp(const Source&, NumberT e, NumberT low, NumberT high) {
return NumberT{std::min(std::max(e, low), high)};
}
@@ -968,6 +986,33 @@
};
}
+ConstEval::Result ConstEval::Dot(const Source& source,
+ const sem::Constant* v1,
+ const sem::Constant* v2) {
+ auto* vec_ty = v1->Type()->As<sem::Vector>();
+ TINT_ASSERT(Resolver, vec_ty);
+ auto* elem_ty = vec_ty->type();
+ switch (vec_ty->Width()) {
+ case 2:
+ return Dispatch_fia_fiu32_f16( //
+ Dot2Func(source, elem_ty), //
+ v1->Index(0), v1->Index(1), //
+ v2->Index(0), v2->Index(1));
+ case 3:
+ return Dispatch_fia_fiu32_f16( //
+ Dot3Func(source, elem_ty), //
+ v1->Index(0), v1->Index(1), v1->Index(2), //
+ v2->Index(0), v2->Index(1), v2->Index(2));
+ case 4:
+ return Dispatch_fia_fiu32_f16( //
+ Dot4Func(source, elem_ty), //
+ v1->Index(0), v1->Index(1), v1->Index(2), v1->Index(3), //
+ v2->Index(0), v2->Index(1), v2->Index(2), v2->Index(3));
+ }
+ TINT_ICE(Resolver, builder.Diagnostics()) << "Expected vector";
+ return utils::Failure;
+}
+
auto ConstEval::Det2Func(const Source& source, const sem::Type* elem_ty) {
return [=](auto a, auto b, auto c, auto d) -> ImplResult {
if (auto r = Det2(source, a, b, c, d)) {
@@ -1969,30 +2014,10 @@
return TransformElements(builder, ty, transform, args[0]);
}
-ConstEval::Result ConstEval::dot(const sem::Type* ty,
+ConstEval::Result ConstEval::dot(const sem::Type*,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
- auto calculate = [&]() -> ImplResult {
- auto* v1 = args[0];
- auto* v2 = args[1];
- auto* vec_ty = v1->Type()->As<sem::Vector>();
- switch (vec_ty->Width()) {
- case 2:
- return Dispatch_fia_fiu32_f16(Dot2Func(source, ty), v1->Index(0), v1->Index(1),
- v2->Index(0), v2->Index(1));
- case 3:
- return Dispatch_fia_fiu32_f16(Dot3Func(source, ty), v1->Index(0), v1->Index(1),
- v1->Index(2), v2->Index(0), v2->Index(1),
- v2->Index(2));
- case 4:
- return Dispatch_fia_fiu32_f16(Dot4Func(source, ty), v1->Index(0), v1->Index(1),
- v1->Index(2), v1->Index(3), v2->Index(0),
- v2->Index(1), v2->Index(2), v2->Index(3));
- }
- TINT_ICE(Resolver, builder.Diagnostics()) << "Expected scalar or vector";
- return utils::Failure;
- };
- auto r = calculate();
+ auto r = Dot(source, args[0], args[1]);
if (!r) {
AddNote("when calculating dot", source);
}
@@ -2188,6 +2213,35 @@
return TransformElements(builder, ty, transform, args[0], args[1]);
}
+ConstEval::Result ConstEval::length(const sem::Type* ty,
+ utils::VectorRef<const sem::Constant*> args,
+ const Source& source) {
+ auto calculate = [&]() -> ImplResult {
+ auto* vec_ty = args[0]->Type()->As<sem::Vector>();
+
+ // Evaluates to the absolute value of e if T is scalar.
+ if (vec_ty == nullptr) {
+ auto create = [&](auto e) {
+ using NumberT = decltype(e);
+ return CreateElement(builder, source, ty, NumberT{std::abs(e)});
+ };
+ return Dispatch_fa_f32_f16(create, args[0]);
+ }
+
+ // Evaluates to sqrt(e[0]^2 + e[1]^2 + ...) if T is a vector type.
+ auto d = Dot(source, args[0], args[0]);
+ if (!d) {
+ return utils::Failure;
+ }
+ return Dispatch_fa_f32_f16(SqrtFunc(source, ty), d.Get());
+ };
+ auto r = calculate();
+ if (!r) {
+ AddNote("when calculating length", source);
+ }
+ return r;
+}
+
ConstEval::Result ConstEval::max(const sem::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
@@ -2561,15 +2615,7 @@
utils::VectorRef<const sem::Constant*> args,
const Source& source) {
auto transform = [&](const sem::Constant* c0) {
- auto create = [&](auto i) -> ImplResult {
- using NumberT = decltype(i);
- if (i < NumberT(0)) {
- AddError("sqrt must be called with a value >= 0", source);
- return utils::Failure;
- }
- return CreateElement(builder, source, c0->Type(), NumberT(std::sqrt(i.value)));
- };
- return Dispatch_fa_f32_f16(create, c0);
+ return Dispatch_fa_f32_f16(SqrtFunc(source, c0->Type()), c0);
};
return TransformElements(builder, ty, transform, args[0]);
diff --git a/src/tint/resolver/const_eval.h b/src/tint/resolver/const_eval.h
index cb1babd..496e138 100644
--- a/src/tint/resolver/const_eval.h
+++ b/src/tint/resolver/const_eval.h
@@ -601,6 +601,15 @@
utils::VectorRef<const sem::Constant*> args,
const Source& source);
+ /// length builtin
+ /// @param ty the expression type
+ /// @param args the input arguments
+ /// @param source the source location
+ /// @return the result value, or null if the value cannot be calculated
+ Result length(const sem::Type* ty,
+ utils::VectorRef<const sem::Constant*> args,
+ const Source& source);
+
/// max builtin
/// @param ty the expression type
/// @param args the input arguments
@@ -962,6 +971,9 @@
NumberT b1,
NumberT b2);
+ template <typename NumberT>
+ utils::Result<NumberT> Sqrt(const Source& source, NumberT v);
+
/// Clamps e between low and high
/// @param source the source location
/// @param e the number to clamp
@@ -1034,6 +1046,20 @@
/// @returns the callable function
auto ClampFunc(const Source& source, const sem::Type* elem_ty);
+ /// Returns a callable that calls SqrtFunc, and creates a Constant with its
+ /// result of type `elem_ty` if successful, or returns Failure otherwise.
+ /// @param source the source location
+ /// @param elem_ty the element type of the Constant to create on success
+ /// @returns the callable function
+ auto SqrtFunc(const Source& source, const sem::Type* elem_ty);
+
+ /// Returns the dot product of v1 and v2.
+ /// @param source the source location
+ /// @param v1 the first vector
+ /// @param v2 the second vector
+ /// @returns the dot product
+ Result Dot(const Source& source, const sem::Constant* v1, const sem::Constant* v2);
+
ProgramBuilder& builder;
};
diff --git a/src/tint/resolver/const_eval_builtin_test.cc b/src/tint/resolver/const_eval_builtin_test.cc
index 6c6d193..13bbac5 100644
--- a/src/tint/resolver/const_eval_builtin_test.cc
+++ b/src/tint/resolver/const_eval_builtin_test.cc
@@ -41,10 +41,12 @@
return *this;
}
- /// Expected value should be compared using FLOAT_EQ instead of EQ
- Case& FloatComp() {
+ /// Expected value should be compared using EXPECT_FLOAT_EQ instead of EXPECT_EQ.
+ /// If optional epsilon is passed in, will be compared using EXPECT_NEAR with that epsilon.
+ Case& FloatComp(std::optional<double> epsilon = {}) {
Success s = expected.Get();
s.flags.float_compare = true;
+ s.flags.float_compare_epsilon = epsilon;
expected = s;
return *this;
}
@@ -1177,6 +1179,65 @@
ExtractBitsCases<u32>()))));
template <typename T>
+std::vector<Case> LengthCases() {
+ const auto kSqrtOfHighest = T(std::sqrt(T::Highest()));
+ const auto kSqrtOfHighestSquared = T(kSqrtOfHighest * kSqrtOfHighest);
+
+ auto error_msg = [](auto a, const char* op, auto b) {
+ return "12:34 error: " + OverflowErrorMessage(a, op, b) + R"(
+12:34 note: when calculating length)";
+ };
+ return {
+ C({T(0)}, T(0)),
+ C({Vec(T(0), T(0))}, Val(T(0))),
+ C({Vec(T(0), T(0), T(0))}, Val(T(0))),
+ C({Vec(T(0), T(0), T(0), T(0))}, Val(T(0))),
+
+ C({T(1)}, T(1)),
+ C({Vec(T(1), T(1))}, Val(T(std::sqrt(2)))),
+ C({Vec(T(1), T(1), T(1))}, Val(T(std::sqrt(3)))),
+ C({Vec(T(1), T(1), T(1), T(1))}, Val(T(std::sqrt(4)))),
+
+ C({T(2)}, T(2)),
+ C({Vec(T(2), T(2))}, Val(T(std::sqrt(8)))),
+ C({Vec(T(2), T(2), T(2))}, Val(T(std::sqrt(12)))),
+ C({Vec(T(2), T(2), T(2), T(2))}, Val(T(std::sqrt(16)))),
+
+ C({Vec(T(2), T(3))}, Val(T(std::sqrt(13)))),
+ C({Vec(T(2), T(3), T(4))}, Val(T(std::sqrt(29)))),
+ C({Vec(T(2), T(3), T(4), T(5))}, Val(T(std::sqrt(54)))),
+
+ C({T(-5)}, T(5)),
+ C({T::Highest()}, T::Highest()),
+ C({T::Lowest()}, T::Highest()),
+
+ C({Vec(T(-2), T(-3), T(-4), T(-5))}, Val(T(std::sqrt(54)))),
+ C({Vec(T(2), T(-3), T(4), T(-5))}, Val(T(std::sqrt(54)))),
+ C({Vec(T(-2), T(3), T(-4), T(5))}, Val(T(std::sqrt(54)))),
+
+ C({Vec(kSqrtOfHighest, T(0))}, Val(kSqrtOfHighest)).FloatComp(0.2),
+ C({Vec(T(0), kSqrtOfHighest)}, Val(kSqrtOfHighest)).FloatComp(0.2),
+
+ C({Vec(-kSqrtOfHighest, T(0))}, Val(kSqrtOfHighest)).FloatComp(0.2),
+ C({Vec(T(0), -kSqrtOfHighest)}, Val(kSqrtOfHighest)).FloatComp(0.2),
+
+ // Overflow when squaring a term
+ E({Vec(T::Highest(), T(0))}, error_msg(T::Highest(), "*", T::Highest())),
+ E({Vec(T(0), T::Highest())}, error_msg(T::Highest(), "*", T::Highest())),
+ // Overflow when adding squared terms
+ E({Vec(kSqrtOfHighest, kSqrtOfHighest)},
+ error_msg(kSqrtOfHighestSquared, "+", kSqrtOfHighestSquared)),
+ };
+}
+INSTANTIATE_TEST_SUITE_P( //
+ Length,
+ ResolverConstEvalBuiltinTest,
+ testing::Combine(testing::Values(sem::BuiltinType::kLength),
+ testing::ValuesIn(Concat(LengthCases<AFloat>(), //
+ LengthCases<f32>(),
+ LengthCases<f16>()))));
+
+template <typename T>
std::vector<Case> MaxCases() {
return {
C({T(0), T(0)}, T(0)),
diff --git a/src/tint/resolver/const_eval_test.h b/src/tint/resolver/const_eval_test.h
index 908d7e2..bc85542 100644
--- a/src/tint/resolver/const_eval_test.h
+++ b/src/tint/resolver/const_eval_test.h
@@ -16,6 +16,7 @@
#define SRC_TINT_RESOLVER_CONST_EVAL_TEST_H_
#include <limits>
+#include <optional>
#include <string>
#include <utility>
@@ -74,8 +75,11 @@
struct CheckConstantFlags {
/// Expected value may be positive or negative
bool pos_or_neg = false;
- /// Expected value should be compared using FLOAT_EQ instead of EQ
+ /// Expected value should be compared using EXPECT_FLOAT_EQ instead of EQ, or EXPECT_NEAR if
+ /// float_compare_epsilon is set.
bool float_compare = false;
+ /// Expected value should be compared using EXPECT_NEAR if float_compare is set.
+ std::optional<double> float_compare_epsilon;
};
/// CheckConstant checks that @p got_constant, the result value of
@@ -106,18 +110,16 @@
EXPECT_TRUE(std::isnan(got));
} else {
if (flags.pos_or_neg) {
- auto got_abs = Abs(got);
- if (flags.float_compare) {
- EXPECT_FLOAT_EQ(got_abs, expected);
+ got = Abs(got);
+ }
+ if (flags.float_compare) {
+ if (flags.float_compare_epsilon) {
+ EXPECT_NEAR(got, expected, *flags.float_compare_epsilon);
} else {
- EXPECT_EQ(got_abs, expected);
+ EXPECT_FLOAT_EQ(got, expected);
}
} else {
- if (flags.float_compare) {
- EXPECT_FLOAT_EQ(got, expected);
- } else {
- EXPECT_EQ(got, expected);
- }
+ EXPECT_EQ(got, expected);
}
}
} else {
diff --git a/src/tint/resolver/intrinsic_table.inl b/src/tint/resolver/intrinsic_table.inl
index 91ff68c..7744960 100644
--- a/src/tint/resolver/intrinsic_table.inl
+++ b/src/tint/resolver/intrinsic_table.inl
@@ -12726,24 +12726,24 @@
/* num parameters */ 1,
/* num template types */ 1,
/* num template numbers */ 0,
- /* template types */ &kTemplateTypes[26],
+ /* template types */ &kTemplateTypes[23],
/* template numbers */ &kTemplateNumbers[10],
/* parameters */ &kParameters[872],
/* return matcher indices */ &kMatcherIndices[3],
/* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
- /* const eval */ nullptr,
+ /* const eval */ &ConstEval::length,
},
{
/* [368] */
/* num parameters */ 1,
/* num template types */ 1,
/* num template numbers */ 1,
- /* template types */ &kTemplateTypes[26],
+ /* template types */ &kTemplateTypes[23],
/* template numbers */ &kTemplateNumbers[4],
/* parameters */ &kParameters[873],
/* return matcher indices */ &kMatcherIndices[3],
/* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
- /* const eval */ nullptr,
+ /* const eval */ &ConstEval::length,
},
{
/* [369] */
@@ -14308,8 +14308,8 @@
},
{
/* [47] */
- /* fn length<T : f32_f16>(T) -> T */
- /* fn length<N : num, T : f32_f16>(vec<N, T>) -> T */
+ /* fn length<T : fa_f32_f16>(@test_value(0) T) -> T */
+ /* fn length<N : num, T : fa_f32_f16>(@test_value(0) vec<N, T>) -> T */
/* num overloads */ 2,
/* overloads */ &kOverloads[367],
},
diff --git a/test/tint/builtins/gen/literal/length/056071.wgsl b/test/tint/builtins/gen/literal/length/056071.wgsl
index 8fc39ba..e8d182c 100644
--- a/test/tint/builtins/gen/literal/length/056071.wgsl
+++ b/test/tint/builtins/gen/literal/length/056071.wgsl
@@ -23,7 +23,7 @@
// fn length(vec<3, f32>) -> f32
fn length_056071() {
- var res: f32 = length(vec3<f32>(1.f));
+ var res: f32 = length(vec3<f32>(0.f));
}
@vertex
diff --git a/test/tint/builtins/gen/literal/length/056071.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/length/056071.wgsl.expected.dxc.hlsl
index 059bd52..5866d13 100644
--- a/test/tint/builtins/gen/literal/length/056071.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/length/056071.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
void length_056071() {
- float res = length((1.0f).xxx);
+ float res = 0.0f;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/length/056071.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/length/056071.wgsl.expected.fxc.hlsl
index 059bd52..5866d13 100644
--- a/test/tint/builtins/gen/literal/length/056071.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/length/056071.wgsl.expected.fxc.hlsl
@@ -1,5 +1,5 @@
void length_056071() {
- float res = length((1.0f).xxx);
+ float res = 0.0f;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/length/056071.wgsl.expected.glsl b/test/tint/builtins/gen/literal/length/056071.wgsl.expected.glsl
index 13c4890..d70b411 100644
--- a/test/tint/builtins/gen/literal/length/056071.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/length/056071.wgsl.expected.glsl
@@ -1,7 +1,7 @@
#version 310 es
void length_056071() {
- float res = length(vec3(1.0f));
+ float res = 0.0f;
}
vec4 vertex_main() {
@@ -21,7 +21,7 @@
precision mediump float;
void length_056071() {
- float res = length(vec3(1.0f));
+ float res = 0.0f;
}
void fragment_main() {
@@ -35,7 +35,7 @@
#version 310 es
void length_056071() {
- float res = length(vec3(1.0f));
+ float res = 0.0f;
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/length/056071.wgsl.expected.msl b/test/tint/builtins/gen/literal/length/056071.wgsl.expected.msl
index 387e06d..7ccfb33 100644
--- a/test/tint/builtins/gen/literal/length/056071.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/length/056071.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void length_056071() {
- float res = length(float3(1.0f));
+ float res = 0.0f;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/length/056071.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/length/056071.wgsl.expected.spvasm
index 9f13f37..0a8134b 100644
--- a/test/tint/builtins/gen/literal/length/056071.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/length/056071.wgsl.expected.spvasm
@@ -1,10 +1,9 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 33
+; Bound: 29
; Schema: 0
OpCapability Shader
- %14 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -31,37 +30,34 @@
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
%void = OpTypeVoid
%9 = OpTypeFunction %void
- %v3float = OpTypeVector %float 3
- %float_1 = OpConstant %float 1
- %17 = OpConstantComposite %v3float %float_1 %float_1 %float_1
%_ptr_Function_float = OpTypePointer Function %float
- %20 = OpTypeFunction %v4float
+ %15 = OpTypeFunction %v4float
+ %float_1 = OpConstant %float 1
%length_056071 = OpFunction %void None %9
%12 = OpLabel
%res = OpVariable %_ptr_Function_float Function %8
- %13 = OpExtInst %float %14 Length %17
- OpStore %res %13
+ OpStore %res %8
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %20
- %22 = OpLabel
- %23 = OpFunctionCall %void %length_056071
+%vertex_main_inner = OpFunction %v4float None %15
+ %17 = OpLabel
+ %18 = OpFunctionCall %void %length_056071
OpReturnValue %5
OpFunctionEnd
%vertex_main = OpFunction %void None %9
- %25 = OpLabel
- %26 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %26
+ %20 = OpLabel
+ %21 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %21
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
%fragment_main = OpFunction %void None %9
- %28 = OpLabel
- %29 = OpFunctionCall %void %length_056071
+ %24 = OpLabel
+ %25 = OpFunctionCall %void %length_056071
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %9
- %31 = OpLabel
- %32 = OpFunctionCall %void %length_056071
+ %27 = OpLabel
+ %28 = OpFunctionCall %void %length_056071
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/length/056071.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/length/056071.wgsl.expected.wgsl
index d83825d8..34f59eb 100644
--- a/test/tint/builtins/gen/literal/length/056071.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/literal/length/056071.wgsl.expected.wgsl
@@ -1,5 +1,5 @@
fn length_056071() {
- var res : f32 = length(vec3<f32>(1.0f));
+ var res : f32 = length(vec3<f32>(0.0f));
}
@vertex
diff --git a/test/tint/builtins/gen/literal/length/3f0e13.wgsl b/test/tint/builtins/gen/literal/length/3f0e13.wgsl
index 61b3d2b..44fc5bf 100644
--- a/test/tint/builtins/gen/literal/length/3f0e13.wgsl
+++ b/test/tint/builtins/gen/literal/length/3f0e13.wgsl
@@ -25,7 +25,7 @@
// fn length(vec<2, f16>) -> f16
fn length_3f0e13() {
- var res: f16 = length(vec2<f16>(1.h));
+ var res: f16 = length(vec2<f16>(0.h));
}
@vertex
diff --git a/test/tint/builtins/gen/literal/length/3f0e13.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/length/3f0e13.wgsl.expected.dxc.hlsl
index aeb2c63..25a71d7 100644
--- a/test/tint/builtins/gen/literal/length/3f0e13.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/length/3f0e13.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
void length_3f0e13() {
- float16_t res = length((float16_t(1.0h)).xx);
+ float16_t res = float16_t(0.0h);
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/length/3f0e13.wgsl.expected.glsl b/test/tint/builtins/gen/literal/length/3f0e13.wgsl.expected.glsl
index d1738a3..aa45582 100644
--- a/test/tint/builtins/gen/literal/length/3f0e13.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/length/3f0e13.wgsl.expected.glsl
@@ -2,7 +2,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void length_3f0e13() {
- float16_t res = length(f16vec2(1.0hf));
+ float16_t res = 0.0hf;
}
vec4 vertex_main() {
@@ -23,7 +23,7 @@
precision mediump float;
void length_3f0e13() {
- float16_t res = length(f16vec2(1.0hf));
+ float16_t res = 0.0hf;
}
void fragment_main() {
@@ -38,7 +38,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void length_3f0e13() {
- float16_t res = length(f16vec2(1.0hf));
+ float16_t res = 0.0hf;
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/length/3f0e13.wgsl.expected.msl b/test/tint/builtins/gen/literal/length/3f0e13.wgsl.expected.msl
index 82464e6..4709c0d 100644
--- a/test/tint/builtins/gen/literal/length/3f0e13.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/length/3f0e13.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void length_3f0e13() {
- half res = length(half2(1.0h));
+ half res = 0.0h;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/length/3f0e13.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/length/3f0e13.wgsl.expected.spvasm
index c026dd5..8e47cf3 100644
--- a/test/tint/builtins/gen/literal/length/3f0e13.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/length/3f0e13.wgsl.expected.spvasm
@@ -1,14 +1,13 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 36
+; Bound: 31
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability UniformAndStorageBuffer16BitAccess
OpCapability StorageBuffer16BitAccess
OpCapability StorageInputOutput16
- %15 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -36,39 +35,35 @@
%void = OpTypeVoid
%9 = OpTypeFunction %void
%half = OpTypeFloat 16
- %v2half = OpTypeVector %half 2
-%half_0x1p_0 = OpConstant %half 0x1p+0
- %18 = OpConstantComposite %v2half %half_0x1p_0 %half_0x1p_0
+ %14 = OpConstantNull %half
%_ptr_Function_half = OpTypePointer Function %half
- %21 = OpConstantNull %half
- %22 = OpTypeFunction %v4float
+ %17 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
%length_3f0e13 = OpFunction %void None %9
%12 = OpLabel
- %res = OpVariable %_ptr_Function_half Function %21
- %13 = OpExtInst %half %15 Length %18
- OpStore %res %13
+ %res = OpVariable %_ptr_Function_half Function %14
+ OpStore %res %14
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %22
- %24 = OpLabel
- %25 = OpFunctionCall %void %length_3f0e13
+%vertex_main_inner = OpFunction %v4float None %17
+ %19 = OpLabel
+ %20 = OpFunctionCall %void %length_3f0e13
OpReturnValue %5
OpFunctionEnd
%vertex_main = OpFunction %void None %9
- %27 = OpLabel
- %28 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %28
+ %22 = OpLabel
+ %23 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %23
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
%fragment_main = OpFunction %void None %9
- %31 = OpLabel
- %32 = OpFunctionCall %void %length_3f0e13
+ %26 = OpLabel
+ %27 = OpFunctionCall %void %length_3f0e13
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %9
- %34 = OpLabel
- %35 = OpFunctionCall %void %length_3f0e13
+ %29 = OpLabel
+ %30 = OpFunctionCall %void %length_3f0e13
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/length/3f0e13.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/length/3f0e13.wgsl.expected.wgsl
index 295b05e..920ea1a 100644
--- a/test/tint/builtins/gen/literal/length/3f0e13.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/literal/length/3f0e13.wgsl.expected.wgsl
@@ -1,7 +1,7 @@
enable f16;
fn length_3f0e13() {
- var res : f16 = length(vec2<f16>(1.0h));
+ var res : f16 = length(vec2<f16>(0.0h));
}
@vertex
diff --git a/test/tint/builtins/gen/literal/length/555aba.wgsl b/test/tint/builtins/gen/literal/length/555aba.wgsl
new file mode 100644
index 0000000..595bb1b
--- /dev/null
+++ b/test/tint/builtins/gen/literal/length/555aba.wgsl
@@ -0,0 +1,43 @@
+// Copyright 2022 The Tint Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+////////////////////////////////////////////////////////////////////////////////
+// File generated by tools/src/cmd/gen
+// using the template:
+// test/tint/builtins/gen/gen.wgsl.tmpl
+//
+// Do not modify this file directly
+////////////////////////////////////////////////////////////////////////////////
+
+
+// fn length(vec<3, fa>) -> fa
+fn length_555aba() {
+ var res = length(vec3(0.));
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ length_555aba();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ length_555aba();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ length_555aba();
+}
diff --git a/test/tint/builtins/gen/literal/length/555aba.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/length/555aba.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..ae75f2e
--- /dev/null
+++ b/test/tint/builtins/gen/literal/length/555aba.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void length_555aba() {
+ float res = 0.0f;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ length_555aba();
+ return (0.0f).xxxx;
+}
+
+tint_symbol vertex_main() {
+ const float4 inner_result = vertex_main_inner();
+ tint_symbol wrapper_result = (tint_symbol)0;
+ wrapper_result.value = inner_result;
+ return wrapper_result;
+}
+
+void fragment_main() {
+ length_555aba();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ length_555aba();
+ return;
+}
diff --git a/test/tint/builtins/gen/literal/length/555aba.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/length/555aba.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..ae75f2e
--- /dev/null
+++ b/test/tint/builtins/gen/literal/length/555aba.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void length_555aba() {
+ float res = 0.0f;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ length_555aba();
+ return (0.0f).xxxx;
+}
+
+tint_symbol vertex_main() {
+ const float4 inner_result = vertex_main_inner();
+ tint_symbol wrapper_result = (tint_symbol)0;
+ wrapper_result.value = inner_result;
+ return wrapper_result;
+}
+
+void fragment_main() {
+ length_555aba();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ length_555aba();
+ return;
+}
diff --git a/test/tint/builtins/gen/literal/length/555aba.wgsl.expected.glsl b/test/tint/builtins/gen/literal/length/555aba.wgsl.expected.glsl
new file mode 100644
index 0000000..fb815a6
--- /dev/null
+++ b/test/tint/builtins/gen/literal/length/555aba.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void length_555aba() {
+ float res = 0.0f;
+}
+
+vec4 vertex_main() {
+ length_555aba();
+ return vec4(0.0f);
+}
+
+void main() {
+ gl_PointSize = 1.0;
+ vec4 inner_result = vertex_main();
+ gl_Position = inner_result;
+ gl_Position.y = -(gl_Position.y);
+ gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
+ return;
+}
+#version 310 es
+precision mediump float;
+
+void length_555aba() {
+ float res = 0.0f;
+}
+
+void fragment_main() {
+ length_555aba();
+}
+
+void main() {
+ fragment_main();
+ return;
+}
+#version 310 es
+
+void length_555aba() {
+ float res = 0.0f;
+}
+
+void compute_main() {
+ length_555aba();
+}
+
+layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
+void main() {
+ compute_main();
+ return;
+}
diff --git a/test/tint/builtins/gen/literal/length/555aba.wgsl.expected.msl b/test/tint/builtins/gen/literal/length/555aba.wgsl.expected.msl
new file mode 100644
index 0000000..c59618c
--- /dev/null
+++ b/test/tint/builtins/gen/literal/length/555aba.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void length_555aba() {
+ float res = 0.0f;
+}
+
+struct tint_symbol {
+ float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+ length_555aba();
+ return float4(0.0f);
+}
+
+vertex tint_symbol vertex_main() {
+ float4 const inner_result = vertex_main_inner();
+ tint_symbol wrapper_result = {};
+ wrapper_result.value = inner_result;
+ return wrapper_result;
+}
+
+fragment void fragment_main() {
+ length_555aba();
+ return;
+}
+
+kernel void compute_main() {
+ length_555aba();
+ return;
+}
+
diff --git a/test/tint/builtins/gen/literal/length/555aba.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/length/555aba.wgsl.expected.spvasm
new file mode 100644
index 0000000..d8d7c41
--- /dev/null
+++ b/test/tint/builtins/gen/literal/length/555aba.wgsl.expected.spvasm
@@ -0,0 +1,63 @@
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 0
+; Bound: 29
+; Schema: 0
+ OpCapability Shader
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
+ OpEntryPoint Fragment %fragment_main "fragment_main"
+ OpEntryPoint GLCompute %compute_main "compute_main"
+ OpExecutionMode %fragment_main OriginUpperLeft
+ OpExecutionMode %compute_main LocalSize 1 1 1
+ OpName %value "value"
+ OpName %vertex_point_size "vertex_point_size"
+ OpName %length_555aba "length_555aba"
+ OpName %res "res"
+ OpName %vertex_main_inner "vertex_main_inner"
+ OpName %vertex_main "vertex_main"
+ OpName %fragment_main "fragment_main"
+ OpName %compute_main "compute_main"
+ OpDecorate %value BuiltIn Position
+ OpDecorate %vertex_point_size BuiltIn PointSize
+ %float = OpTypeFloat 32
+ %v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+ %5 = OpConstantNull %v4float
+ %value = OpVariable %_ptr_Output_v4float Output %5
+%_ptr_Output_float = OpTypePointer Output %float
+ %8 = OpConstantNull %float
+%vertex_point_size = OpVariable %_ptr_Output_float Output %8
+ %void = OpTypeVoid
+ %9 = OpTypeFunction %void
+%_ptr_Function_float = OpTypePointer Function %float
+ %15 = OpTypeFunction %v4float
+ %float_1 = OpConstant %float 1
+%length_555aba = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_float Function %8
+ OpStore %res %8
+ OpReturn
+ OpFunctionEnd
+%vertex_main_inner = OpFunction %v4float None %15
+ %17 = OpLabel
+ %18 = OpFunctionCall %void %length_555aba
+ OpReturnValue %5
+ OpFunctionEnd
+%vertex_main = OpFunction %void None %9
+ %20 = OpLabel
+ %21 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %21
+ OpStore %vertex_point_size %float_1
+ OpReturn
+ OpFunctionEnd
+%fragment_main = OpFunction %void None %9
+ %24 = OpLabel
+ %25 = OpFunctionCall %void %length_555aba
+ OpReturn
+ OpFunctionEnd
+%compute_main = OpFunction %void None %9
+ %27 = OpLabel
+ %28 = OpFunctionCall %void %length_555aba
+ OpReturn
+ OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/length/555aba.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/length/555aba.wgsl.expected.wgsl
new file mode 100644
index 0000000..ebae2ef
--- /dev/null
+++ b/test/tint/builtins/gen/literal/length/555aba.wgsl.expected.wgsl
@@ -0,0 +1,19 @@
+fn length_555aba() {
+ var res = length(vec3(0.0));
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ length_555aba();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ length_555aba();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ length_555aba();
+}
diff --git a/test/tint/builtins/gen/literal/length/5b1a9b.wgsl b/test/tint/builtins/gen/literal/length/5b1a9b.wgsl
index 50a2ef1..a15a013 100644
--- a/test/tint/builtins/gen/literal/length/5b1a9b.wgsl
+++ b/test/tint/builtins/gen/literal/length/5b1a9b.wgsl
@@ -25,7 +25,7 @@
// fn length(vec<4, f16>) -> f16
fn length_5b1a9b() {
- var res: f16 = length(vec4<f16>(1.h));
+ var res: f16 = length(vec4<f16>(0.h));
}
@vertex
diff --git a/test/tint/builtins/gen/literal/length/5b1a9b.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/length/5b1a9b.wgsl.expected.dxc.hlsl
index df13890..1e64383 100644
--- a/test/tint/builtins/gen/literal/length/5b1a9b.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/length/5b1a9b.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
void length_5b1a9b() {
- float16_t res = length((float16_t(1.0h)).xxxx);
+ float16_t res = float16_t(0.0h);
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/length/5b1a9b.wgsl.expected.glsl b/test/tint/builtins/gen/literal/length/5b1a9b.wgsl.expected.glsl
index faca950..27c14fd 100644
--- a/test/tint/builtins/gen/literal/length/5b1a9b.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/length/5b1a9b.wgsl.expected.glsl
@@ -2,7 +2,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void length_5b1a9b() {
- float16_t res = length(f16vec4(1.0hf));
+ float16_t res = 0.0hf;
}
vec4 vertex_main() {
@@ -23,7 +23,7 @@
precision mediump float;
void length_5b1a9b() {
- float16_t res = length(f16vec4(1.0hf));
+ float16_t res = 0.0hf;
}
void fragment_main() {
@@ -38,7 +38,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void length_5b1a9b() {
- float16_t res = length(f16vec4(1.0hf));
+ float16_t res = 0.0hf;
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/length/5b1a9b.wgsl.expected.msl b/test/tint/builtins/gen/literal/length/5b1a9b.wgsl.expected.msl
index dff63ba..5fd0861 100644
--- a/test/tint/builtins/gen/literal/length/5b1a9b.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/length/5b1a9b.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void length_5b1a9b() {
- half res = length(half4(1.0h));
+ half res = 0.0h;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/length/5b1a9b.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/length/5b1a9b.wgsl.expected.spvasm
index bdc9042..3d31fb3 100644
--- a/test/tint/builtins/gen/literal/length/5b1a9b.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/length/5b1a9b.wgsl.expected.spvasm
@@ -1,14 +1,13 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 36
+; Bound: 31
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability UniformAndStorageBuffer16BitAccess
OpCapability StorageBuffer16BitAccess
OpCapability StorageInputOutput16
- %15 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -36,39 +35,35 @@
%void = OpTypeVoid
%9 = OpTypeFunction %void
%half = OpTypeFloat 16
- %v4half = OpTypeVector %half 4
-%half_0x1p_0 = OpConstant %half 0x1p+0
- %18 = OpConstantComposite %v4half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 %half_0x1p_0
+ %14 = OpConstantNull %half
%_ptr_Function_half = OpTypePointer Function %half
- %21 = OpConstantNull %half
- %22 = OpTypeFunction %v4float
+ %17 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
%length_5b1a9b = OpFunction %void None %9
%12 = OpLabel
- %res = OpVariable %_ptr_Function_half Function %21
- %13 = OpExtInst %half %15 Length %18
- OpStore %res %13
+ %res = OpVariable %_ptr_Function_half Function %14
+ OpStore %res %14
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %22
- %24 = OpLabel
- %25 = OpFunctionCall %void %length_5b1a9b
+%vertex_main_inner = OpFunction %v4float None %17
+ %19 = OpLabel
+ %20 = OpFunctionCall %void %length_5b1a9b
OpReturnValue %5
OpFunctionEnd
%vertex_main = OpFunction %void None %9
- %27 = OpLabel
- %28 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %28
+ %22 = OpLabel
+ %23 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %23
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
%fragment_main = OpFunction %void None %9
- %31 = OpLabel
- %32 = OpFunctionCall %void %length_5b1a9b
+ %26 = OpLabel
+ %27 = OpFunctionCall %void %length_5b1a9b
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %9
- %34 = OpLabel
- %35 = OpFunctionCall %void %length_5b1a9b
+ %29 = OpLabel
+ %30 = OpFunctionCall %void %length_5b1a9b
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/length/5b1a9b.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/length/5b1a9b.wgsl.expected.wgsl
index e94fb3f..c218c4a 100644
--- a/test/tint/builtins/gen/literal/length/5b1a9b.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/literal/length/5b1a9b.wgsl.expected.wgsl
@@ -1,7 +1,7 @@
enable f16;
fn length_5b1a9b() {
- var res : f16 = length(vec4<f16>(1.0h));
+ var res : f16 = length(vec4<f16>(0.0h));
}
@vertex
diff --git a/test/tint/builtins/gen/literal/length/602a17.wgsl b/test/tint/builtins/gen/literal/length/602a17.wgsl
index a9d4624..491582f 100644
--- a/test/tint/builtins/gen/literal/length/602a17.wgsl
+++ b/test/tint/builtins/gen/literal/length/602a17.wgsl
@@ -23,7 +23,7 @@
// fn length(f32) -> f32
fn length_602a17() {
- var res: f32 = length(1.f);
+ var res: f32 = length(0.f);
}
@vertex
diff --git a/test/tint/builtins/gen/literal/length/602a17.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/length/602a17.wgsl.expected.dxc.hlsl
index 0c0ce39..68960df 100644
--- a/test/tint/builtins/gen/literal/length/602a17.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/length/602a17.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
void length_602a17() {
- float res = length(1.0f);
+ float res = 0.0f;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/length/602a17.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/length/602a17.wgsl.expected.fxc.hlsl
index 0c0ce39..68960df 100644
--- a/test/tint/builtins/gen/literal/length/602a17.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/length/602a17.wgsl.expected.fxc.hlsl
@@ -1,5 +1,5 @@
void length_602a17() {
- float res = length(1.0f);
+ float res = 0.0f;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/length/602a17.wgsl.expected.glsl b/test/tint/builtins/gen/literal/length/602a17.wgsl.expected.glsl
index d6cce45..579e675 100644
--- a/test/tint/builtins/gen/literal/length/602a17.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/length/602a17.wgsl.expected.glsl
@@ -1,7 +1,7 @@
#version 310 es
void length_602a17() {
- float res = length(1.0f);
+ float res = 0.0f;
}
vec4 vertex_main() {
@@ -21,7 +21,7 @@
precision mediump float;
void length_602a17() {
- float res = length(1.0f);
+ float res = 0.0f;
}
void fragment_main() {
@@ -35,7 +35,7 @@
#version 310 es
void length_602a17() {
- float res = length(1.0f);
+ float res = 0.0f;
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/length/602a17.wgsl.expected.msl b/test/tint/builtins/gen/literal/length/602a17.wgsl.expected.msl
index 86bfa31..ee0c167 100644
--- a/test/tint/builtins/gen/literal/length/602a17.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/length/602a17.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void length_602a17() {
- float res = fabs(1.0f);
+ float res = 0.0f;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/length/602a17.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/length/602a17.wgsl.expected.spvasm
index f42a9a5..d0aedc4 100644
--- a/test/tint/builtins/gen/literal/length/602a17.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/length/602a17.wgsl.expected.spvasm
@@ -1,10 +1,9 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 31
+; Bound: 29
; Schema: 0
OpCapability Shader
- %14 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -31,35 +30,34 @@
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
%void = OpTypeVoid
%9 = OpTypeFunction %void
- %float_1 = OpConstant %float 1
%_ptr_Function_float = OpTypePointer Function %float
- %18 = OpTypeFunction %v4float
+ %15 = OpTypeFunction %v4float
+ %float_1 = OpConstant %float 1
%length_602a17 = OpFunction %void None %9
%12 = OpLabel
%res = OpVariable %_ptr_Function_float Function %8
- %13 = OpExtInst %float %14 Length %float_1
- OpStore %res %13
+ OpStore %res %8
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %18
- %20 = OpLabel
- %21 = OpFunctionCall %void %length_602a17
+%vertex_main_inner = OpFunction %v4float None %15
+ %17 = OpLabel
+ %18 = OpFunctionCall %void %length_602a17
OpReturnValue %5
OpFunctionEnd
%vertex_main = OpFunction %void None %9
- %23 = OpLabel
- %24 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %24
+ %20 = OpLabel
+ %21 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %21
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
%fragment_main = OpFunction %void None %9
- %26 = OpLabel
- %27 = OpFunctionCall %void %length_602a17
+ %24 = OpLabel
+ %25 = OpFunctionCall %void %length_602a17
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %9
- %29 = OpLabel
- %30 = OpFunctionCall %void %length_602a17
+ %27 = OpLabel
+ %28 = OpFunctionCall %void %length_602a17
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/length/602a17.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/length/602a17.wgsl.expected.wgsl
index 9209e3f..e1220e5 100644
--- a/test/tint/builtins/gen/literal/length/602a17.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/literal/length/602a17.wgsl.expected.wgsl
@@ -1,5 +1,5 @@
fn length_602a17() {
- var res : f32 = length(1.0f);
+ var res : f32 = length(0.0f);
}
@vertex
diff --git a/test/tint/builtins/gen/literal/length/7b4741.wgsl b/test/tint/builtins/gen/literal/length/7b4741.wgsl
new file mode 100644
index 0000000..359f2a0
--- /dev/null
+++ b/test/tint/builtins/gen/literal/length/7b4741.wgsl
@@ -0,0 +1,43 @@
+// Copyright 2022 The Tint Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+////////////////////////////////////////////////////////////////////////////////
+// File generated by tools/src/cmd/gen
+// using the template:
+// test/tint/builtins/gen/gen.wgsl.tmpl
+//
+// Do not modify this file directly
+////////////////////////////////////////////////////////////////////////////////
+
+
+// fn length(vec<2, fa>) -> fa
+fn length_7b4741() {
+ var res = length(vec2(0.));
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ length_7b4741();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ length_7b4741();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ length_7b4741();
+}
diff --git a/test/tint/builtins/gen/literal/length/7b4741.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/length/7b4741.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..08e83f5
--- /dev/null
+++ b/test/tint/builtins/gen/literal/length/7b4741.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void length_7b4741() {
+ float res = 0.0f;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ length_7b4741();
+ return (0.0f).xxxx;
+}
+
+tint_symbol vertex_main() {
+ const float4 inner_result = vertex_main_inner();
+ tint_symbol wrapper_result = (tint_symbol)0;
+ wrapper_result.value = inner_result;
+ return wrapper_result;
+}
+
+void fragment_main() {
+ length_7b4741();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ length_7b4741();
+ return;
+}
diff --git a/test/tint/builtins/gen/literal/length/7b4741.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/length/7b4741.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..08e83f5
--- /dev/null
+++ b/test/tint/builtins/gen/literal/length/7b4741.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void length_7b4741() {
+ float res = 0.0f;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ length_7b4741();
+ return (0.0f).xxxx;
+}
+
+tint_symbol vertex_main() {
+ const float4 inner_result = vertex_main_inner();
+ tint_symbol wrapper_result = (tint_symbol)0;
+ wrapper_result.value = inner_result;
+ return wrapper_result;
+}
+
+void fragment_main() {
+ length_7b4741();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ length_7b4741();
+ return;
+}
diff --git a/test/tint/builtins/gen/literal/length/7b4741.wgsl.expected.glsl b/test/tint/builtins/gen/literal/length/7b4741.wgsl.expected.glsl
new file mode 100644
index 0000000..16c9226
--- /dev/null
+++ b/test/tint/builtins/gen/literal/length/7b4741.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void length_7b4741() {
+ float res = 0.0f;
+}
+
+vec4 vertex_main() {
+ length_7b4741();
+ return vec4(0.0f);
+}
+
+void main() {
+ gl_PointSize = 1.0;
+ vec4 inner_result = vertex_main();
+ gl_Position = inner_result;
+ gl_Position.y = -(gl_Position.y);
+ gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
+ return;
+}
+#version 310 es
+precision mediump float;
+
+void length_7b4741() {
+ float res = 0.0f;
+}
+
+void fragment_main() {
+ length_7b4741();
+}
+
+void main() {
+ fragment_main();
+ return;
+}
+#version 310 es
+
+void length_7b4741() {
+ float res = 0.0f;
+}
+
+void compute_main() {
+ length_7b4741();
+}
+
+layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
+void main() {
+ compute_main();
+ return;
+}
diff --git a/test/tint/builtins/gen/literal/length/7b4741.wgsl.expected.msl b/test/tint/builtins/gen/literal/length/7b4741.wgsl.expected.msl
new file mode 100644
index 0000000..7c9de19
--- /dev/null
+++ b/test/tint/builtins/gen/literal/length/7b4741.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void length_7b4741() {
+ float res = 0.0f;
+}
+
+struct tint_symbol {
+ float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+ length_7b4741();
+ return float4(0.0f);
+}
+
+vertex tint_symbol vertex_main() {
+ float4 const inner_result = vertex_main_inner();
+ tint_symbol wrapper_result = {};
+ wrapper_result.value = inner_result;
+ return wrapper_result;
+}
+
+fragment void fragment_main() {
+ length_7b4741();
+ return;
+}
+
+kernel void compute_main() {
+ length_7b4741();
+ return;
+}
+
diff --git a/test/tint/builtins/gen/literal/length/7b4741.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/length/7b4741.wgsl.expected.spvasm
new file mode 100644
index 0000000..c85d9f2
--- /dev/null
+++ b/test/tint/builtins/gen/literal/length/7b4741.wgsl.expected.spvasm
@@ -0,0 +1,63 @@
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 0
+; Bound: 29
+; Schema: 0
+ OpCapability Shader
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
+ OpEntryPoint Fragment %fragment_main "fragment_main"
+ OpEntryPoint GLCompute %compute_main "compute_main"
+ OpExecutionMode %fragment_main OriginUpperLeft
+ OpExecutionMode %compute_main LocalSize 1 1 1
+ OpName %value "value"
+ OpName %vertex_point_size "vertex_point_size"
+ OpName %length_7b4741 "length_7b4741"
+ OpName %res "res"
+ OpName %vertex_main_inner "vertex_main_inner"
+ OpName %vertex_main "vertex_main"
+ OpName %fragment_main "fragment_main"
+ OpName %compute_main "compute_main"
+ OpDecorate %value BuiltIn Position
+ OpDecorate %vertex_point_size BuiltIn PointSize
+ %float = OpTypeFloat 32
+ %v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+ %5 = OpConstantNull %v4float
+ %value = OpVariable %_ptr_Output_v4float Output %5
+%_ptr_Output_float = OpTypePointer Output %float
+ %8 = OpConstantNull %float
+%vertex_point_size = OpVariable %_ptr_Output_float Output %8
+ %void = OpTypeVoid
+ %9 = OpTypeFunction %void
+%_ptr_Function_float = OpTypePointer Function %float
+ %15 = OpTypeFunction %v4float
+ %float_1 = OpConstant %float 1
+%length_7b4741 = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_float Function %8
+ OpStore %res %8
+ OpReturn
+ OpFunctionEnd
+%vertex_main_inner = OpFunction %v4float None %15
+ %17 = OpLabel
+ %18 = OpFunctionCall %void %length_7b4741
+ OpReturnValue %5
+ OpFunctionEnd
+%vertex_main = OpFunction %void None %9
+ %20 = OpLabel
+ %21 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %21
+ OpStore %vertex_point_size %float_1
+ OpReturn
+ OpFunctionEnd
+%fragment_main = OpFunction %void None %9
+ %24 = OpLabel
+ %25 = OpFunctionCall %void %length_7b4741
+ OpReturn
+ OpFunctionEnd
+%compute_main = OpFunction %void None %9
+ %27 = OpLabel
+ %28 = OpFunctionCall %void %length_7b4741
+ OpReturn
+ OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/length/7b4741.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/length/7b4741.wgsl.expected.wgsl
new file mode 100644
index 0000000..d38ad2a
--- /dev/null
+++ b/test/tint/builtins/gen/literal/length/7b4741.wgsl.expected.wgsl
@@ -0,0 +1,19 @@
+fn length_7b4741() {
+ var res = length(vec2(0.0));
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ length_7b4741();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ length_7b4741();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ length_7b4741();
+}
diff --git a/test/tint/builtins/gen/literal/length/936ad5.wgsl b/test/tint/builtins/gen/literal/length/936ad5.wgsl
new file mode 100644
index 0000000..1a5ea92
--- /dev/null
+++ b/test/tint/builtins/gen/literal/length/936ad5.wgsl
@@ -0,0 +1,43 @@
+// Copyright 2022 The Tint Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+////////////////////////////////////////////////////////////////////////////////
+// File generated by tools/src/cmd/gen
+// using the template:
+// test/tint/builtins/gen/gen.wgsl.tmpl
+//
+// Do not modify this file directly
+////////////////////////////////////////////////////////////////////////////////
+
+
+// fn length(fa) -> fa
+fn length_936ad5() {
+ var res = length(0.);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ length_936ad5();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ length_936ad5();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ length_936ad5();
+}
diff --git a/test/tint/builtins/gen/literal/length/936ad5.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/length/936ad5.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..cf6a772
--- /dev/null
+++ b/test/tint/builtins/gen/literal/length/936ad5.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void length_936ad5() {
+ float res = 0.0f;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ length_936ad5();
+ return (0.0f).xxxx;
+}
+
+tint_symbol vertex_main() {
+ const float4 inner_result = vertex_main_inner();
+ tint_symbol wrapper_result = (tint_symbol)0;
+ wrapper_result.value = inner_result;
+ return wrapper_result;
+}
+
+void fragment_main() {
+ length_936ad5();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ length_936ad5();
+ return;
+}
diff --git a/test/tint/builtins/gen/literal/length/936ad5.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/length/936ad5.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..cf6a772
--- /dev/null
+++ b/test/tint/builtins/gen/literal/length/936ad5.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void length_936ad5() {
+ float res = 0.0f;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ length_936ad5();
+ return (0.0f).xxxx;
+}
+
+tint_symbol vertex_main() {
+ const float4 inner_result = vertex_main_inner();
+ tint_symbol wrapper_result = (tint_symbol)0;
+ wrapper_result.value = inner_result;
+ return wrapper_result;
+}
+
+void fragment_main() {
+ length_936ad5();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ length_936ad5();
+ return;
+}
diff --git a/test/tint/builtins/gen/literal/length/936ad5.wgsl.expected.glsl b/test/tint/builtins/gen/literal/length/936ad5.wgsl.expected.glsl
new file mode 100644
index 0000000..cfb1b8c
--- /dev/null
+++ b/test/tint/builtins/gen/literal/length/936ad5.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void length_936ad5() {
+ float res = 0.0f;
+}
+
+vec4 vertex_main() {
+ length_936ad5();
+ return vec4(0.0f);
+}
+
+void main() {
+ gl_PointSize = 1.0;
+ vec4 inner_result = vertex_main();
+ gl_Position = inner_result;
+ gl_Position.y = -(gl_Position.y);
+ gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
+ return;
+}
+#version 310 es
+precision mediump float;
+
+void length_936ad5() {
+ float res = 0.0f;
+}
+
+void fragment_main() {
+ length_936ad5();
+}
+
+void main() {
+ fragment_main();
+ return;
+}
+#version 310 es
+
+void length_936ad5() {
+ float res = 0.0f;
+}
+
+void compute_main() {
+ length_936ad5();
+}
+
+layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
+void main() {
+ compute_main();
+ return;
+}
diff --git a/test/tint/builtins/gen/literal/length/936ad5.wgsl.expected.msl b/test/tint/builtins/gen/literal/length/936ad5.wgsl.expected.msl
new file mode 100644
index 0000000..6a2e0a7
--- /dev/null
+++ b/test/tint/builtins/gen/literal/length/936ad5.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void length_936ad5() {
+ float res = 0.0f;
+}
+
+struct tint_symbol {
+ float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+ length_936ad5();
+ return float4(0.0f);
+}
+
+vertex tint_symbol vertex_main() {
+ float4 const inner_result = vertex_main_inner();
+ tint_symbol wrapper_result = {};
+ wrapper_result.value = inner_result;
+ return wrapper_result;
+}
+
+fragment void fragment_main() {
+ length_936ad5();
+ return;
+}
+
+kernel void compute_main() {
+ length_936ad5();
+ return;
+}
+
diff --git a/test/tint/builtins/gen/literal/length/936ad5.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/length/936ad5.wgsl.expected.spvasm
new file mode 100644
index 0000000..a28538d
--- /dev/null
+++ b/test/tint/builtins/gen/literal/length/936ad5.wgsl.expected.spvasm
@@ -0,0 +1,63 @@
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 0
+; Bound: 29
+; Schema: 0
+ OpCapability Shader
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
+ OpEntryPoint Fragment %fragment_main "fragment_main"
+ OpEntryPoint GLCompute %compute_main "compute_main"
+ OpExecutionMode %fragment_main OriginUpperLeft
+ OpExecutionMode %compute_main LocalSize 1 1 1
+ OpName %value "value"
+ OpName %vertex_point_size "vertex_point_size"
+ OpName %length_936ad5 "length_936ad5"
+ OpName %res "res"
+ OpName %vertex_main_inner "vertex_main_inner"
+ OpName %vertex_main "vertex_main"
+ OpName %fragment_main "fragment_main"
+ OpName %compute_main "compute_main"
+ OpDecorate %value BuiltIn Position
+ OpDecorate %vertex_point_size BuiltIn PointSize
+ %float = OpTypeFloat 32
+ %v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+ %5 = OpConstantNull %v4float
+ %value = OpVariable %_ptr_Output_v4float Output %5
+%_ptr_Output_float = OpTypePointer Output %float
+ %8 = OpConstantNull %float
+%vertex_point_size = OpVariable %_ptr_Output_float Output %8
+ %void = OpTypeVoid
+ %9 = OpTypeFunction %void
+%_ptr_Function_float = OpTypePointer Function %float
+ %15 = OpTypeFunction %v4float
+ %float_1 = OpConstant %float 1
+%length_936ad5 = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_float Function %8
+ OpStore %res %8
+ OpReturn
+ OpFunctionEnd
+%vertex_main_inner = OpFunction %v4float None %15
+ %17 = OpLabel
+ %18 = OpFunctionCall %void %length_936ad5
+ OpReturnValue %5
+ OpFunctionEnd
+%vertex_main = OpFunction %void None %9
+ %20 = OpLabel
+ %21 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %21
+ OpStore %vertex_point_size %float_1
+ OpReturn
+ OpFunctionEnd
+%fragment_main = OpFunction %void None %9
+ %24 = OpLabel
+ %25 = OpFunctionCall %void %length_936ad5
+ OpReturn
+ OpFunctionEnd
+%compute_main = OpFunction %void None %9
+ %27 = OpLabel
+ %28 = OpFunctionCall %void %length_936ad5
+ OpReturn
+ OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/length/936ad5.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/length/936ad5.wgsl.expected.wgsl
new file mode 100644
index 0000000..2e9ee0d
--- /dev/null
+++ b/test/tint/builtins/gen/literal/length/936ad5.wgsl.expected.wgsl
@@ -0,0 +1,19 @@
+fn length_936ad5() {
+ var res = length(0.0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ length_936ad5();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ length_936ad5();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ length_936ad5();
+}
diff --git a/test/tint/builtins/gen/literal/length/afde8b.wgsl b/test/tint/builtins/gen/literal/length/afde8b.wgsl
index 4d0092b..722e73f 100644
--- a/test/tint/builtins/gen/literal/length/afde8b.wgsl
+++ b/test/tint/builtins/gen/literal/length/afde8b.wgsl
@@ -23,7 +23,7 @@
// fn length(vec<2, f32>) -> f32
fn length_afde8b() {
- var res: f32 = length(vec2<f32>(1.f));
+ var res: f32 = length(vec2<f32>(0.f));
}
@vertex
diff --git a/test/tint/builtins/gen/literal/length/afde8b.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/length/afde8b.wgsl.expected.dxc.hlsl
index fedf5b1..42456bf 100644
--- a/test/tint/builtins/gen/literal/length/afde8b.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/length/afde8b.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
void length_afde8b() {
- float res = length((1.0f).xx);
+ float res = 0.0f;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/length/afde8b.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/length/afde8b.wgsl.expected.fxc.hlsl
index fedf5b1..42456bf 100644
--- a/test/tint/builtins/gen/literal/length/afde8b.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/length/afde8b.wgsl.expected.fxc.hlsl
@@ -1,5 +1,5 @@
void length_afde8b() {
- float res = length((1.0f).xx);
+ float res = 0.0f;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/length/afde8b.wgsl.expected.glsl b/test/tint/builtins/gen/literal/length/afde8b.wgsl.expected.glsl
index c81bf7b..769f7f0 100644
--- a/test/tint/builtins/gen/literal/length/afde8b.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/length/afde8b.wgsl.expected.glsl
@@ -1,7 +1,7 @@
#version 310 es
void length_afde8b() {
- float res = length(vec2(1.0f));
+ float res = 0.0f;
}
vec4 vertex_main() {
@@ -21,7 +21,7 @@
precision mediump float;
void length_afde8b() {
- float res = length(vec2(1.0f));
+ float res = 0.0f;
}
void fragment_main() {
@@ -35,7 +35,7 @@
#version 310 es
void length_afde8b() {
- float res = length(vec2(1.0f));
+ float res = 0.0f;
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/length/afde8b.wgsl.expected.msl b/test/tint/builtins/gen/literal/length/afde8b.wgsl.expected.msl
index 74668c5..5fed668 100644
--- a/test/tint/builtins/gen/literal/length/afde8b.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/length/afde8b.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void length_afde8b() {
- float res = length(float2(1.0f));
+ float res = 0.0f;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/length/afde8b.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/length/afde8b.wgsl.expected.spvasm
index d82d662..e17edea 100644
--- a/test/tint/builtins/gen/literal/length/afde8b.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/length/afde8b.wgsl.expected.spvasm
@@ -1,10 +1,9 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 33
+; Bound: 29
; Schema: 0
OpCapability Shader
- %14 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -31,37 +30,34 @@
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
%void = OpTypeVoid
%9 = OpTypeFunction %void
- %v2float = OpTypeVector %float 2
- %float_1 = OpConstant %float 1
- %17 = OpConstantComposite %v2float %float_1 %float_1
%_ptr_Function_float = OpTypePointer Function %float
- %20 = OpTypeFunction %v4float
+ %15 = OpTypeFunction %v4float
+ %float_1 = OpConstant %float 1
%length_afde8b = OpFunction %void None %9
%12 = OpLabel
%res = OpVariable %_ptr_Function_float Function %8
- %13 = OpExtInst %float %14 Length %17
- OpStore %res %13
+ OpStore %res %8
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %20
- %22 = OpLabel
- %23 = OpFunctionCall %void %length_afde8b
+%vertex_main_inner = OpFunction %v4float None %15
+ %17 = OpLabel
+ %18 = OpFunctionCall %void %length_afde8b
OpReturnValue %5
OpFunctionEnd
%vertex_main = OpFunction %void None %9
- %25 = OpLabel
- %26 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %26
+ %20 = OpLabel
+ %21 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %21
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
%fragment_main = OpFunction %void None %9
- %28 = OpLabel
- %29 = OpFunctionCall %void %length_afde8b
+ %24 = OpLabel
+ %25 = OpFunctionCall %void %length_afde8b
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %9
- %31 = OpLabel
- %32 = OpFunctionCall %void %length_afde8b
+ %27 = OpLabel
+ %28 = OpFunctionCall %void %length_afde8b
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/length/afde8b.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/length/afde8b.wgsl.expected.wgsl
index 77a600c..06b7d27 100644
--- a/test/tint/builtins/gen/literal/length/afde8b.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/literal/length/afde8b.wgsl.expected.wgsl
@@ -1,5 +1,5 @@
fn length_afde8b() {
- var res : f32 = length(vec2<f32>(1.0f));
+ var res : f32 = length(vec2<f32>(0.0f));
}
@vertex
diff --git a/test/tint/builtins/gen/literal/length/ba16d6.wgsl b/test/tint/builtins/gen/literal/length/ba16d6.wgsl
index cca9b19..1319ded 100644
--- a/test/tint/builtins/gen/literal/length/ba16d6.wgsl
+++ b/test/tint/builtins/gen/literal/length/ba16d6.wgsl
@@ -25,7 +25,7 @@
// fn length(vec<3, f16>) -> f16
fn length_ba16d6() {
- var res: f16 = length(vec3<f16>(1.h));
+ var res: f16 = length(vec3<f16>(0.h));
}
@vertex
diff --git a/test/tint/builtins/gen/literal/length/ba16d6.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/length/ba16d6.wgsl.expected.dxc.hlsl
index 9cb7003..6439c99 100644
--- a/test/tint/builtins/gen/literal/length/ba16d6.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/length/ba16d6.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
void length_ba16d6() {
- float16_t res = length((float16_t(1.0h)).xxx);
+ float16_t res = float16_t(0.0h);
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/length/ba16d6.wgsl.expected.glsl b/test/tint/builtins/gen/literal/length/ba16d6.wgsl.expected.glsl
index 676602a..11ed9cc 100644
--- a/test/tint/builtins/gen/literal/length/ba16d6.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/length/ba16d6.wgsl.expected.glsl
@@ -2,7 +2,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void length_ba16d6() {
- float16_t res = length(f16vec3(1.0hf));
+ float16_t res = 0.0hf;
}
vec4 vertex_main() {
@@ -23,7 +23,7 @@
precision mediump float;
void length_ba16d6() {
- float16_t res = length(f16vec3(1.0hf));
+ float16_t res = 0.0hf;
}
void fragment_main() {
@@ -38,7 +38,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void length_ba16d6() {
- float16_t res = length(f16vec3(1.0hf));
+ float16_t res = 0.0hf;
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/length/ba16d6.wgsl.expected.msl b/test/tint/builtins/gen/literal/length/ba16d6.wgsl.expected.msl
index 02c8d79..f0ac6aa 100644
--- a/test/tint/builtins/gen/literal/length/ba16d6.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/length/ba16d6.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void length_ba16d6() {
- half res = length(half3(1.0h));
+ half res = 0.0h;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/length/ba16d6.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/length/ba16d6.wgsl.expected.spvasm
index bb6cac0..4dc8dc4 100644
--- a/test/tint/builtins/gen/literal/length/ba16d6.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/length/ba16d6.wgsl.expected.spvasm
@@ -1,14 +1,13 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 36
+; Bound: 31
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability UniformAndStorageBuffer16BitAccess
OpCapability StorageBuffer16BitAccess
OpCapability StorageInputOutput16
- %15 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -36,39 +35,35 @@
%void = OpTypeVoid
%9 = OpTypeFunction %void
%half = OpTypeFloat 16
- %v3half = OpTypeVector %half 3
-%half_0x1p_0 = OpConstant %half 0x1p+0
- %18 = OpConstantComposite %v3half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0
+ %14 = OpConstantNull %half
%_ptr_Function_half = OpTypePointer Function %half
- %21 = OpConstantNull %half
- %22 = OpTypeFunction %v4float
+ %17 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
%length_ba16d6 = OpFunction %void None %9
%12 = OpLabel
- %res = OpVariable %_ptr_Function_half Function %21
- %13 = OpExtInst %half %15 Length %18
- OpStore %res %13
+ %res = OpVariable %_ptr_Function_half Function %14
+ OpStore %res %14
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %22
- %24 = OpLabel
- %25 = OpFunctionCall %void %length_ba16d6
+%vertex_main_inner = OpFunction %v4float None %17
+ %19 = OpLabel
+ %20 = OpFunctionCall %void %length_ba16d6
OpReturnValue %5
OpFunctionEnd
%vertex_main = OpFunction %void None %9
- %27 = OpLabel
- %28 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %28
+ %22 = OpLabel
+ %23 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %23
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
%fragment_main = OpFunction %void None %9
- %31 = OpLabel
- %32 = OpFunctionCall %void %length_ba16d6
+ %26 = OpLabel
+ %27 = OpFunctionCall %void %length_ba16d6
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %9
- %34 = OpLabel
- %35 = OpFunctionCall %void %length_ba16d6
+ %29 = OpLabel
+ %30 = OpFunctionCall %void %length_ba16d6
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/length/ba16d6.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/length/ba16d6.wgsl.expected.wgsl
index 7c54ecb..16aee35 100644
--- a/test/tint/builtins/gen/literal/length/ba16d6.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/literal/length/ba16d6.wgsl.expected.wgsl
@@ -1,7 +1,7 @@
enable f16;
fn length_ba16d6() {
- var res : f16 = length(vec3<f16>(1.0h));
+ var res : f16 = length(vec3<f16>(0.0h));
}
@vertex
diff --git a/test/tint/builtins/gen/literal/length/becebf.wgsl b/test/tint/builtins/gen/literal/length/becebf.wgsl
index 7429e61..55981c8 100644
--- a/test/tint/builtins/gen/literal/length/becebf.wgsl
+++ b/test/tint/builtins/gen/literal/length/becebf.wgsl
@@ -23,7 +23,7 @@
// fn length(vec<4, f32>) -> f32
fn length_becebf() {
- var res: f32 = length(vec4<f32>(1.f));
+ var res: f32 = length(vec4<f32>(0.f));
}
@vertex
diff --git a/test/tint/builtins/gen/literal/length/becebf.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/length/becebf.wgsl.expected.dxc.hlsl
index 2d55ef8..340a531 100644
--- a/test/tint/builtins/gen/literal/length/becebf.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/length/becebf.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
void length_becebf() {
- float res = length((1.0f).xxxx);
+ float res = 0.0f;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/length/becebf.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/length/becebf.wgsl.expected.fxc.hlsl
index 2d55ef8..340a531 100644
--- a/test/tint/builtins/gen/literal/length/becebf.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/length/becebf.wgsl.expected.fxc.hlsl
@@ -1,5 +1,5 @@
void length_becebf() {
- float res = length((1.0f).xxxx);
+ float res = 0.0f;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/length/becebf.wgsl.expected.glsl b/test/tint/builtins/gen/literal/length/becebf.wgsl.expected.glsl
index b836746..1f7b1da 100644
--- a/test/tint/builtins/gen/literal/length/becebf.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/length/becebf.wgsl.expected.glsl
@@ -1,7 +1,7 @@
#version 310 es
void length_becebf() {
- float res = length(vec4(1.0f));
+ float res = 0.0f;
}
vec4 vertex_main() {
@@ -21,7 +21,7 @@
precision mediump float;
void length_becebf() {
- float res = length(vec4(1.0f));
+ float res = 0.0f;
}
void fragment_main() {
@@ -35,7 +35,7 @@
#version 310 es
void length_becebf() {
- float res = length(vec4(1.0f));
+ float res = 0.0f;
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/length/becebf.wgsl.expected.msl b/test/tint/builtins/gen/literal/length/becebf.wgsl.expected.msl
index fdc96aa..5ddf5a6 100644
--- a/test/tint/builtins/gen/literal/length/becebf.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/length/becebf.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void length_becebf() {
- float res = length(float4(1.0f));
+ float res = 0.0f;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/length/becebf.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/length/becebf.wgsl.expected.spvasm
index 5ca602f..a5cc92d 100644
--- a/test/tint/builtins/gen/literal/length/becebf.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/length/becebf.wgsl.expected.spvasm
@@ -1,10 +1,9 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 32
+; Bound: 29
; Schema: 0
OpCapability Shader
- %14 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -31,36 +30,34 @@
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
%void = OpTypeVoid
%9 = OpTypeFunction %void
- %float_1 = OpConstant %float 1
- %16 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
%_ptr_Function_float = OpTypePointer Function %float
- %19 = OpTypeFunction %v4float
+ %15 = OpTypeFunction %v4float
+ %float_1 = OpConstant %float 1
%length_becebf = OpFunction %void None %9
%12 = OpLabel
%res = OpVariable %_ptr_Function_float Function %8
- %13 = OpExtInst %float %14 Length %16
- OpStore %res %13
+ OpStore %res %8
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %19
- %21 = OpLabel
- %22 = OpFunctionCall %void %length_becebf
+%vertex_main_inner = OpFunction %v4float None %15
+ %17 = OpLabel
+ %18 = OpFunctionCall %void %length_becebf
OpReturnValue %5
OpFunctionEnd
%vertex_main = OpFunction %void None %9
- %24 = OpLabel
- %25 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %25
+ %20 = OpLabel
+ %21 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %21
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
%fragment_main = OpFunction %void None %9
- %27 = OpLabel
- %28 = OpFunctionCall %void %length_becebf
+ %24 = OpLabel
+ %25 = OpFunctionCall %void %length_becebf
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %9
- %30 = OpLabel
- %31 = OpFunctionCall %void %length_becebf
+ %27 = OpLabel
+ %28 = OpFunctionCall %void %length_becebf
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/length/becebf.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/length/becebf.wgsl.expected.wgsl
index e6e3b71..4433e77 100644
--- a/test/tint/builtins/gen/literal/length/becebf.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/literal/length/becebf.wgsl.expected.wgsl
@@ -1,5 +1,5 @@
fn length_becebf() {
- var res : f32 = length(vec4<f32>(1.0f));
+ var res : f32 = length(vec4<f32>(0.0f));
}
@vertex
diff --git a/test/tint/builtins/gen/literal/length/c158da.wgsl b/test/tint/builtins/gen/literal/length/c158da.wgsl
index cde0e0c..9733c9e 100644
--- a/test/tint/builtins/gen/literal/length/c158da.wgsl
+++ b/test/tint/builtins/gen/literal/length/c158da.wgsl
@@ -25,7 +25,7 @@
// fn length(f16) -> f16
fn length_c158da() {
- var res: f16 = length(1.h);
+ var res: f16 = length(0.h);
}
@vertex
diff --git a/test/tint/builtins/gen/literal/length/c158da.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/length/c158da.wgsl.expected.dxc.hlsl
index 05771c2..26407dc 100644
--- a/test/tint/builtins/gen/literal/length/c158da.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/length/c158da.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
void length_c158da() {
- float16_t res = length(float16_t(1.0h));
+ float16_t res = float16_t(0.0h);
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/length/c158da.wgsl.expected.glsl b/test/tint/builtins/gen/literal/length/c158da.wgsl.expected.glsl
index d60a08b..b276e06 100644
--- a/test/tint/builtins/gen/literal/length/c158da.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/length/c158da.wgsl.expected.glsl
@@ -2,7 +2,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void length_c158da() {
- float16_t res = length(1.0hf);
+ float16_t res = 0.0hf;
}
vec4 vertex_main() {
@@ -23,7 +23,7 @@
precision mediump float;
void length_c158da() {
- float16_t res = length(1.0hf);
+ float16_t res = 0.0hf;
}
void fragment_main() {
@@ -38,7 +38,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void length_c158da() {
- float16_t res = length(1.0hf);
+ float16_t res = 0.0hf;
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/length/c158da.wgsl.expected.msl b/test/tint/builtins/gen/literal/length/c158da.wgsl.expected.msl
index b1858e1..432f101 100644
--- a/test/tint/builtins/gen/literal/length/c158da.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/length/c158da.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void length_c158da() {
- half res = fabs(1.0h);
+ half res = 0.0h;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/length/c158da.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/length/c158da.wgsl.expected.spvasm
index ec976a1..f822ca5 100644
--- a/test/tint/builtins/gen/literal/length/c158da.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/length/c158da.wgsl.expected.spvasm
@@ -1,14 +1,13 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 34
+; Bound: 31
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability UniformAndStorageBuffer16BitAccess
OpCapability StorageBuffer16BitAccess
OpCapability StorageInputOutput16
- %15 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -36,37 +35,35 @@
%void = OpTypeVoid
%9 = OpTypeFunction %void
%half = OpTypeFloat 16
-%half_0x1p_0 = OpConstant %half 0x1p+0
+ %14 = OpConstantNull %half
%_ptr_Function_half = OpTypePointer Function %half
- %19 = OpConstantNull %half
- %20 = OpTypeFunction %v4float
+ %17 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
%length_c158da = OpFunction %void None %9
%12 = OpLabel
- %res = OpVariable %_ptr_Function_half Function %19
- %13 = OpExtInst %half %15 Length %half_0x1p_0
- OpStore %res %13
+ %res = OpVariable %_ptr_Function_half Function %14
+ OpStore %res %14
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %20
- %22 = OpLabel
- %23 = OpFunctionCall %void %length_c158da
+%vertex_main_inner = OpFunction %v4float None %17
+ %19 = OpLabel
+ %20 = OpFunctionCall %void %length_c158da
OpReturnValue %5
OpFunctionEnd
%vertex_main = OpFunction %void None %9
- %25 = OpLabel
- %26 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %26
+ %22 = OpLabel
+ %23 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %23
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
%fragment_main = OpFunction %void None %9
- %29 = OpLabel
- %30 = OpFunctionCall %void %length_c158da
+ %26 = OpLabel
+ %27 = OpFunctionCall %void %length_c158da
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %9
- %32 = OpLabel
- %33 = OpFunctionCall %void %length_c158da
+ %29 = OpLabel
+ %30 = OpFunctionCall %void %length_c158da
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/length/c158da.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/length/c158da.wgsl.expected.wgsl
index 66e82b1..46edf49 100644
--- a/test/tint/builtins/gen/literal/length/c158da.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/literal/length/c158da.wgsl.expected.wgsl
@@ -1,7 +1,7 @@
enable f16;
fn length_c158da() {
- var res : f16 = length(1.0h);
+ var res : f16 = length(0.0h);
}
@vertex
diff --git a/test/tint/builtins/gen/literal/length/c2c544.wgsl b/test/tint/builtins/gen/literal/length/c2c544.wgsl
new file mode 100644
index 0000000..516c67f
--- /dev/null
+++ b/test/tint/builtins/gen/literal/length/c2c544.wgsl
@@ -0,0 +1,43 @@
+// Copyright 2022 The Tint Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+////////////////////////////////////////////////////////////////////////////////
+// File generated by tools/src/cmd/gen
+// using the template:
+// test/tint/builtins/gen/gen.wgsl.tmpl
+//
+// Do not modify this file directly
+////////////////////////////////////////////////////////////////////////////////
+
+
+// fn length(vec<4, fa>) -> fa
+fn length_c2c544() {
+ var res = length(vec4(0.));
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ length_c2c544();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ length_c2c544();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ length_c2c544();
+}
diff --git a/test/tint/builtins/gen/literal/length/c2c544.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/length/c2c544.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..3182250
--- /dev/null
+++ b/test/tint/builtins/gen/literal/length/c2c544.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void length_c2c544() {
+ float res = 0.0f;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ length_c2c544();
+ return (0.0f).xxxx;
+}
+
+tint_symbol vertex_main() {
+ const float4 inner_result = vertex_main_inner();
+ tint_symbol wrapper_result = (tint_symbol)0;
+ wrapper_result.value = inner_result;
+ return wrapper_result;
+}
+
+void fragment_main() {
+ length_c2c544();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ length_c2c544();
+ return;
+}
diff --git a/test/tint/builtins/gen/literal/length/c2c544.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/length/c2c544.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..3182250
--- /dev/null
+++ b/test/tint/builtins/gen/literal/length/c2c544.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void length_c2c544() {
+ float res = 0.0f;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ length_c2c544();
+ return (0.0f).xxxx;
+}
+
+tint_symbol vertex_main() {
+ const float4 inner_result = vertex_main_inner();
+ tint_symbol wrapper_result = (tint_symbol)0;
+ wrapper_result.value = inner_result;
+ return wrapper_result;
+}
+
+void fragment_main() {
+ length_c2c544();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ length_c2c544();
+ return;
+}
diff --git a/test/tint/builtins/gen/literal/length/c2c544.wgsl.expected.glsl b/test/tint/builtins/gen/literal/length/c2c544.wgsl.expected.glsl
new file mode 100644
index 0000000..6c6a328
--- /dev/null
+++ b/test/tint/builtins/gen/literal/length/c2c544.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void length_c2c544() {
+ float res = 0.0f;
+}
+
+vec4 vertex_main() {
+ length_c2c544();
+ return vec4(0.0f);
+}
+
+void main() {
+ gl_PointSize = 1.0;
+ vec4 inner_result = vertex_main();
+ gl_Position = inner_result;
+ gl_Position.y = -(gl_Position.y);
+ gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
+ return;
+}
+#version 310 es
+precision mediump float;
+
+void length_c2c544() {
+ float res = 0.0f;
+}
+
+void fragment_main() {
+ length_c2c544();
+}
+
+void main() {
+ fragment_main();
+ return;
+}
+#version 310 es
+
+void length_c2c544() {
+ float res = 0.0f;
+}
+
+void compute_main() {
+ length_c2c544();
+}
+
+layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
+void main() {
+ compute_main();
+ return;
+}
diff --git a/test/tint/builtins/gen/literal/length/c2c544.wgsl.expected.msl b/test/tint/builtins/gen/literal/length/c2c544.wgsl.expected.msl
new file mode 100644
index 0000000..e4d987c
--- /dev/null
+++ b/test/tint/builtins/gen/literal/length/c2c544.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void length_c2c544() {
+ float res = 0.0f;
+}
+
+struct tint_symbol {
+ float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+ length_c2c544();
+ return float4(0.0f);
+}
+
+vertex tint_symbol vertex_main() {
+ float4 const inner_result = vertex_main_inner();
+ tint_symbol wrapper_result = {};
+ wrapper_result.value = inner_result;
+ return wrapper_result;
+}
+
+fragment void fragment_main() {
+ length_c2c544();
+ return;
+}
+
+kernel void compute_main() {
+ length_c2c544();
+ return;
+}
+
diff --git a/test/tint/builtins/gen/literal/length/c2c544.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/length/c2c544.wgsl.expected.spvasm
new file mode 100644
index 0000000..c3a38b8
--- /dev/null
+++ b/test/tint/builtins/gen/literal/length/c2c544.wgsl.expected.spvasm
@@ -0,0 +1,63 @@
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 0
+; Bound: 29
+; Schema: 0
+ OpCapability Shader
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
+ OpEntryPoint Fragment %fragment_main "fragment_main"
+ OpEntryPoint GLCompute %compute_main "compute_main"
+ OpExecutionMode %fragment_main OriginUpperLeft
+ OpExecutionMode %compute_main LocalSize 1 1 1
+ OpName %value "value"
+ OpName %vertex_point_size "vertex_point_size"
+ OpName %length_c2c544 "length_c2c544"
+ OpName %res "res"
+ OpName %vertex_main_inner "vertex_main_inner"
+ OpName %vertex_main "vertex_main"
+ OpName %fragment_main "fragment_main"
+ OpName %compute_main "compute_main"
+ OpDecorate %value BuiltIn Position
+ OpDecorate %vertex_point_size BuiltIn PointSize
+ %float = OpTypeFloat 32
+ %v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+ %5 = OpConstantNull %v4float
+ %value = OpVariable %_ptr_Output_v4float Output %5
+%_ptr_Output_float = OpTypePointer Output %float
+ %8 = OpConstantNull %float
+%vertex_point_size = OpVariable %_ptr_Output_float Output %8
+ %void = OpTypeVoid
+ %9 = OpTypeFunction %void
+%_ptr_Function_float = OpTypePointer Function %float
+ %15 = OpTypeFunction %v4float
+ %float_1 = OpConstant %float 1
+%length_c2c544 = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_float Function %8
+ OpStore %res %8
+ OpReturn
+ OpFunctionEnd
+%vertex_main_inner = OpFunction %v4float None %15
+ %17 = OpLabel
+ %18 = OpFunctionCall %void %length_c2c544
+ OpReturnValue %5
+ OpFunctionEnd
+%vertex_main = OpFunction %void None %9
+ %20 = OpLabel
+ %21 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %21
+ OpStore %vertex_point_size %float_1
+ OpReturn
+ OpFunctionEnd
+%fragment_main = OpFunction %void None %9
+ %24 = OpLabel
+ %25 = OpFunctionCall %void %length_c2c544
+ OpReturn
+ OpFunctionEnd
+%compute_main = OpFunction %void None %9
+ %27 = OpLabel
+ %28 = OpFunctionCall %void %length_c2c544
+ OpReturn
+ OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/length/c2c544.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/length/c2c544.wgsl.expected.wgsl
new file mode 100644
index 0000000..b16a1750
--- /dev/null
+++ b/test/tint/builtins/gen/literal/length/c2c544.wgsl.expected.wgsl
@@ -0,0 +1,19 @@
+fn length_c2c544() {
+ var res = length(vec4(0.0));
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ length_c2c544();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ length_c2c544();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ length_c2c544();
+}
diff --git a/test/tint/builtins/gen/var/length/056071.wgsl b/test/tint/builtins/gen/var/length/056071.wgsl
index 2755232..f353299 100644
--- a/test/tint/builtins/gen/var/length/056071.wgsl
+++ b/test/tint/builtins/gen/var/length/056071.wgsl
@@ -23,7 +23,7 @@
// fn length(vec<3, f32>) -> f32
fn length_056071() {
- var arg_0 = vec3<f32>(1.f);
+ var arg_0 = vec3<f32>(0.f);
var res: f32 = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/056071.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/length/056071.wgsl.expected.dxc.hlsl
index 563246c..bd540fb 100644
--- a/test/tint/builtins/gen/var/length/056071.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/var/length/056071.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
void length_056071() {
- float3 arg_0 = (1.0f).xxx;
+ float3 arg_0 = (0.0f).xxx;
float res = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/056071.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/length/056071.wgsl.expected.fxc.hlsl
index 563246c..bd540fb 100644
--- a/test/tint/builtins/gen/var/length/056071.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/var/length/056071.wgsl.expected.fxc.hlsl
@@ -1,5 +1,5 @@
void length_056071() {
- float3 arg_0 = (1.0f).xxx;
+ float3 arg_0 = (0.0f).xxx;
float res = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/056071.wgsl.expected.glsl b/test/tint/builtins/gen/var/length/056071.wgsl.expected.glsl
index c7442a6..f4f3920 100644
--- a/test/tint/builtins/gen/var/length/056071.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/var/length/056071.wgsl.expected.glsl
@@ -1,7 +1,7 @@
#version 310 es
void length_056071() {
- vec3 arg_0 = vec3(1.0f);
+ vec3 arg_0 = vec3(0.0f);
float res = length(arg_0);
}
@@ -22,7 +22,7 @@
precision mediump float;
void length_056071() {
- vec3 arg_0 = vec3(1.0f);
+ vec3 arg_0 = vec3(0.0f);
float res = length(arg_0);
}
@@ -37,7 +37,7 @@
#version 310 es
void length_056071() {
- vec3 arg_0 = vec3(1.0f);
+ vec3 arg_0 = vec3(0.0f);
float res = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/056071.wgsl.expected.msl b/test/tint/builtins/gen/var/length/056071.wgsl.expected.msl
index f2ba3c3..1727b62 100644
--- a/test/tint/builtins/gen/var/length/056071.wgsl.expected.msl
+++ b/test/tint/builtins/gen/var/length/056071.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void length_056071() {
- float3 arg_0 = float3(1.0f);
+ float3 arg_0 = float3(0.0f);
float res = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/056071.wgsl.expected.spvasm b/test/tint/builtins/gen/var/length/056071.wgsl.expected.spvasm
index 45c6997..fb485c7 100644
--- a/test/tint/builtins/gen/var/length/056071.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/var/length/056071.wgsl.expected.spvasm
@@ -1,10 +1,10 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 37
+; Bound: 36
; Schema: 0
OpCapability Shader
- %20 = OpExtInstImport "GLSL.std.450"
+ %18 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -33,41 +33,40 @@
%void = OpTypeVoid
%9 = OpTypeFunction %void
%v3float = OpTypeVector %float 3
- %float_1 = OpConstant %float 1
- %15 = OpConstantComposite %v3float %float_1 %float_1 %float_1
+ %14 = OpConstantNull %v3float
%_ptr_Function_v3float = OpTypePointer Function %v3float
- %18 = OpConstantNull %v3float
%_ptr_Function_float = OpTypePointer Function %float
- %24 = OpTypeFunction %v4float
+ %22 = OpTypeFunction %v4float
+ %float_1 = OpConstant %float 1
%length_056071 = OpFunction %void None %9
%12 = OpLabel
- %arg_0 = OpVariable %_ptr_Function_v3float Function %18
+ %arg_0 = OpVariable %_ptr_Function_v3float Function %14
%res = OpVariable %_ptr_Function_float Function %8
- OpStore %arg_0 %15
- %21 = OpLoad %v3float %arg_0
- %19 = OpExtInst %float %20 Length %21
- OpStore %res %19
+ OpStore %arg_0 %14
+ %19 = OpLoad %v3float %arg_0
+ %17 = OpExtInst %float %18 Length %19
+ OpStore %res %17
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %24
- %26 = OpLabel
- %27 = OpFunctionCall %void %length_056071
+%vertex_main_inner = OpFunction %v4float None %22
+ %24 = OpLabel
+ %25 = OpFunctionCall %void %length_056071
OpReturnValue %5
OpFunctionEnd
%vertex_main = OpFunction %void None %9
- %29 = OpLabel
- %30 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %30
+ %27 = OpLabel
+ %28 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %28
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
%fragment_main = OpFunction %void None %9
- %32 = OpLabel
- %33 = OpFunctionCall %void %length_056071
+ %31 = OpLabel
+ %32 = OpFunctionCall %void %length_056071
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %9
- %35 = OpLabel
- %36 = OpFunctionCall %void %length_056071
+ %34 = OpLabel
+ %35 = OpFunctionCall %void %length_056071
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/length/056071.wgsl.expected.wgsl b/test/tint/builtins/gen/var/length/056071.wgsl.expected.wgsl
index b5ddeb0..ff5c0f2 100644
--- a/test/tint/builtins/gen/var/length/056071.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/length/056071.wgsl.expected.wgsl
@@ -1,5 +1,5 @@
fn length_056071() {
- var arg_0 = vec3<f32>(1.0f);
+ var arg_0 = vec3<f32>(0.0f);
var res : f32 = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/3f0e13.wgsl b/test/tint/builtins/gen/var/length/3f0e13.wgsl
index cc5f92f..053f8b7 100644
--- a/test/tint/builtins/gen/var/length/3f0e13.wgsl
+++ b/test/tint/builtins/gen/var/length/3f0e13.wgsl
@@ -25,7 +25,7 @@
// fn length(vec<2, f16>) -> f16
fn length_3f0e13() {
- var arg_0 = vec2<f16>(1.h);
+ var arg_0 = vec2<f16>(0.h);
var res: f16 = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/3f0e13.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/length/3f0e13.wgsl.expected.dxc.hlsl
index 59d9493..ef03b06 100644
--- a/test/tint/builtins/gen/var/length/3f0e13.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/var/length/3f0e13.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
void length_3f0e13() {
- vector<float16_t, 2> arg_0 = (float16_t(1.0h)).xx;
+ vector<float16_t, 2> arg_0 = (float16_t(0.0h)).xx;
float16_t res = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/3f0e13.wgsl.expected.glsl b/test/tint/builtins/gen/var/length/3f0e13.wgsl.expected.glsl
index 30425e5..a5f2471 100644
--- a/test/tint/builtins/gen/var/length/3f0e13.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/var/length/3f0e13.wgsl.expected.glsl
@@ -2,7 +2,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void length_3f0e13() {
- f16vec2 arg_0 = f16vec2(1.0hf);
+ f16vec2 arg_0 = f16vec2(0.0hf);
float16_t res = length(arg_0);
}
@@ -24,7 +24,7 @@
precision mediump float;
void length_3f0e13() {
- f16vec2 arg_0 = f16vec2(1.0hf);
+ f16vec2 arg_0 = f16vec2(0.0hf);
float16_t res = length(arg_0);
}
@@ -40,7 +40,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void length_3f0e13() {
- f16vec2 arg_0 = f16vec2(1.0hf);
+ f16vec2 arg_0 = f16vec2(0.0hf);
float16_t res = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/3f0e13.wgsl.expected.msl b/test/tint/builtins/gen/var/length/3f0e13.wgsl.expected.msl
index 403f079..797b6fb 100644
--- a/test/tint/builtins/gen/var/length/3f0e13.wgsl.expected.msl
+++ b/test/tint/builtins/gen/var/length/3f0e13.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void length_3f0e13() {
- half2 arg_0 = half2(1.0h);
+ half2 arg_0 = half2(0.0h);
half res = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/3f0e13.wgsl.expected.spvasm b/test/tint/builtins/gen/var/length/3f0e13.wgsl.expected.spvasm
index bcc5e638..a92c3f1 100644
--- a/test/tint/builtins/gen/var/length/3f0e13.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/var/length/3f0e13.wgsl.expected.spvasm
@@ -1,14 +1,14 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 40
+; Bound: 38
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability UniformAndStorageBuffer16BitAccess
OpCapability StorageBuffer16BitAccess
OpCapability StorageInputOutput16
- %21 = OpExtInstImport "GLSL.std.450"
+ %19 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -38,43 +38,41 @@
%9 = OpTypeFunction %void
%half = OpTypeFloat 16
%v2half = OpTypeVector %half 2
-%half_0x1p_0 = OpConstant %half 0x1p+0
- %16 = OpConstantComposite %v2half %half_0x1p_0 %half_0x1p_0
+ %15 = OpConstantNull %v2half
%_ptr_Function_v2half = OpTypePointer Function %v2half
- %19 = OpConstantNull %v2half
%_ptr_Function_half = OpTypePointer Function %half
- %25 = OpConstantNull %half
- %26 = OpTypeFunction %v4float
+ %23 = OpConstantNull %half
+ %24 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
%length_3f0e13 = OpFunction %void None %9
%12 = OpLabel
- %arg_0 = OpVariable %_ptr_Function_v2half Function %19
- %res = OpVariable %_ptr_Function_half Function %25
- OpStore %arg_0 %16
- %22 = OpLoad %v2half %arg_0
- %20 = OpExtInst %half %21 Length %22
- OpStore %res %20
+ %arg_0 = OpVariable %_ptr_Function_v2half Function %15
+ %res = OpVariable %_ptr_Function_half Function %23
+ OpStore %arg_0 %15
+ %20 = OpLoad %v2half %arg_0
+ %18 = OpExtInst %half %19 Length %20
+ OpStore %res %18
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %26
- %28 = OpLabel
- %29 = OpFunctionCall %void %length_3f0e13
+%vertex_main_inner = OpFunction %v4float None %24
+ %26 = OpLabel
+ %27 = OpFunctionCall %void %length_3f0e13
OpReturnValue %5
OpFunctionEnd
%vertex_main = OpFunction %void None %9
- %31 = OpLabel
- %32 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %32
+ %29 = OpLabel
+ %30 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %30
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
%fragment_main = OpFunction %void None %9
- %35 = OpLabel
- %36 = OpFunctionCall %void %length_3f0e13
+ %33 = OpLabel
+ %34 = OpFunctionCall %void %length_3f0e13
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %9
- %38 = OpLabel
- %39 = OpFunctionCall %void %length_3f0e13
+ %36 = OpLabel
+ %37 = OpFunctionCall %void %length_3f0e13
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/length/3f0e13.wgsl.expected.wgsl b/test/tint/builtins/gen/var/length/3f0e13.wgsl.expected.wgsl
index aa47114..1f69181 100644
--- a/test/tint/builtins/gen/var/length/3f0e13.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/length/3f0e13.wgsl.expected.wgsl
@@ -1,7 +1,7 @@
enable f16;
fn length_3f0e13() {
- var arg_0 = vec2<f16>(1.0h);
+ var arg_0 = vec2<f16>(0.0h);
var res : f16 = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/555aba.wgsl b/test/tint/builtins/gen/var/length/555aba.wgsl
new file mode 100644
index 0000000..c16c099
--- /dev/null
+++ b/test/tint/builtins/gen/var/length/555aba.wgsl
@@ -0,0 +1,44 @@
+// Copyright 2022 The Tint Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+////////////////////////////////////////////////////////////////////////////////
+// File generated by tools/src/cmd/gen
+// using the template:
+// test/tint/builtins/gen/gen.wgsl.tmpl
+//
+// Do not modify this file directly
+////////////////////////////////////////////////////////////////////////////////
+
+
+// fn length(vec<3, fa>) -> fa
+fn length_555aba() {
+ const arg_0 = vec3(0.);
+ var res = length(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ length_555aba();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ length_555aba();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ length_555aba();
+}
diff --git a/test/tint/builtins/gen/var/length/555aba.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/length/555aba.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..ae75f2e
--- /dev/null
+++ b/test/tint/builtins/gen/var/length/555aba.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void length_555aba() {
+ float res = 0.0f;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ length_555aba();
+ return (0.0f).xxxx;
+}
+
+tint_symbol vertex_main() {
+ const float4 inner_result = vertex_main_inner();
+ tint_symbol wrapper_result = (tint_symbol)0;
+ wrapper_result.value = inner_result;
+ return wrapper_result;
+}
+
+void fragment_main() {
+ length_555aba();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ length_555aba();
+ return;
+}
diff --git a/test/tint/builtins/gen/var/length/555aba.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/length/555aba.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..ae75f2e
--- /dev/null
+++ b/test/tint/builtins/gen/var/length/555aba.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void length_555aba() {
+ float res = 0.0f;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ length_555aba();
+ return (0.0f).xxxx;
+}
+
+tint_symbol vertex_main() {
+ const float4 inner_result = vertex_main_inner();
+ tint_symbol wrapper_result = (tint_symbol)0;
+ wrapper_result.value = inner_result;
+ return wrapper_result;
+}
+
+void fragment_main() {
+ length_555aba();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ length_555aba();
+ return;
+}
diff --git a/test/tint/builtins/gen/var/length/555aba.wgsl.expected.glsl b/test/tint/builtins/gen/var/length/555aba.wgsl.expected.glsl
new file mode 100644
index 0000000..fb815a6
--- /dev/null
+++ b/test/tint/builtins/gen/var/length/555aba.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void length_555aba() {
+ float res = 0.0f;
+}
+
+vec4 vertex_main() {
+ length_555aba();
+ return vec4(0.0f);
+}
+
+void main() {
+ gl_PointSize = 1.0;
+ vec4 inner_result = vertex_main();
+ gl_Position = inner_result;
+ gl_Position.y = -(gl_Position.y);
+ gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
+ return;
+}
+#version 310 es
+precision mediump float;
+
+void length_555aba() {
+ float res = 0.0f;
+}
+
+void fragment_main() {
+ length_555aba();
+}
+
+void main() {
+ fragment_main();
+ return;
+}
+#version 310 es
+
+void length_555aba() {
+ float res = 0.0f;
+}
+
+void compute_main() {
+ length_555aba();
+}
+
+layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
+void main() {
+ compute_main();
+ return;
+}
diff --git a/test/tint/builtins/gen/var/length/555aba.wgsl.expected.msl b/test/tint/builtins/gen/var/length/555aba.wgsl.expected.msl
new file mode 100644
index 0000000..c59618c
--- /dev/null
+++ b/test/tint/builtins/gen/var/length/555aba.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void length_555aba() {
+ float res = 0.0f;
+}
+
+struct tint_symbol {
+ float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+ length_555aba();
+ return float4(0.0f);
+}
+
+vertex tint_symbol vertex_main() {
+ float4 const inner_result = vertex_main_inner();
+ tint_symbol wrapper_result = {};
+ wrapper_result.value = inner_result;
+ return wrapper_result;
+}
+
+fragment void fragment_main() {
+ length_555aba();
+ return;
+}
+
+kernel void compute_main() {
+ length_555aba();
+ return;
+}
+
diff --git a/test/tint/builtins/gen/var/length/555aba.wgsl.expected.spvasm b/test/tint/builtins/gen/var/length/555aba.wgsl.expected.spvasm
new file mode 100644
index 0000000..d8d7c41
--- /dev/null
+++ b/test/tint/builtins/gen/var/length/555aba.wgsl.expected.spvasm
@@ -0,0 +1,63 @@
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 0
+; Bound: 29
+; Schema: 0
+ OpCapability Shader
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
+ OpEntryPoint Fragment %fragment_main "fragment_main"
+ OpEntryPoint GLCompute %compute_main "compute_main"
+ OpExecutionMode %fragment_main OriginUpperLeft
+ OpExecutionMode %compute_main LocalSize 1 1 1
+ OpName %value "value"
+ OpName %vertex_point_size "vertex_point_size"
+ OpName %length_555aba "length_555aba"
+ OpName %res "res"
+ OpName %vertex_main_inner "vertex_main_inner"
+ OpName %vertex_main "vertex_main"
+ OpName %fragment_main "fragment_main"
+ OpName %compute_main "compute_main"
+ OpDecorate %value BuiltIn Position
+ OpDecorate %vertex_point_size BuiltIn PointSize
+ %float = OpTypeFloat 32
+ %v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+ %5 = OpConstantNull %v4float
+ %value = OpVariable %_ptr_Output_v4float Output %5
+%_ptr_Output_float = OpTypePointer Output %float
+ %8 = OpConstantNull %float
+%vertex_point_size = OpVariable %_ptr_Output_float Output %8
+ %void = OpTypeVoid
+ %9 = OpTypeFunction %void
+%_ptr_Function_float = OpTypePointer Function %float
+ %15 = OpTypeFunction %v4float
+ %float_1 = OpConstant %float 1
+%length_555aba = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_float Function %8
+ OpStore %res %8
+ OpReturn
+ OpFunctionEnd
+%vertex_main_inner = OpFunction %v4float None %15
+ %17 = OpLabel
+ %18 = OpFunctionCall %void %length_555aba
+ OpReturnValue %5
+ OpFunctionEnd
+%vertex_main = OpFunction %void None %9
+ %20 = OpLabel
+ %21 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %21
+ OpStore %vertex_point_size %float_1
+ OpReturn
+ OpFunctionEnd
+%fragment_main = OpFunction %void None %9
+ %24 = OpLabel
+ %25 = OpFunctionCall %void %length_555aba
+ OpReturn
+ OpFunctionEnd
+%compute_main = OpFunction %void None %9
+ %27 = OpLabel
+ %28 = OpFunctionCall %void %length_555aba
+ OpReturn
+ OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/length/555aba.wgsl.expected.wgsl b/test/tint/builtins/gen/var/length/555aba.wgsl.expected.wgsl
new file mode 100644
index 0000000..5fa0c1b
--- /dev/null
+++ b/test/tint/builtins/gen/var/length/555aba.wgsl.expected.wgsl
@@ -0,0 +1,20 @@
+fn length_555aba() {
+ const arg_0 = vec3(0.0);
+ var res = length(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ length_555aba();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ length_555aba();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ length_555aba();
+}
diff --git a/test/tint/builtins/gen/var/length/5b1a9b.wgsl b/test/tint/builtins/gen/var/length/5b1a9b.wgsl
index 629e9ce..cef2978 100644
--- a/test/tint/builtins/gen/var/length/5b1a9b.wgsl
+++ b/test/tint/builtins/gen/var/length/5b1a9b.wgsl
@@ -25,7 +25,7 @@
// fn length(vec<4, f16>) -> f16
fn length_5b1a9b() {
- var arg_0 = vec4<f16>(1.h);
+ var arg_0 = vec4<f16>(0.h);
var res: f16 = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/5b1a9b.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/length/5b1a9b.wgsl.expected.dxc.hlsl
index ff848f8..4865222 100644
--- a/test/tint/builtins/gen/var/length/5b1a9b.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/var/length/5b1a9b.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
void length_5b1a9b() {
- vector<float16_t, 4> arg_0 = (float16_t(1.0h)).xxxx;
+ vector<float16_t, 4> arg_0 = (float16_t(0.0h)).xxxx;
float16_t res = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/5b1a9b.wgsl.expected.glsl b/test/tint/builtins/gen/var/length/5b1a9b.wgsl.expected.glsl
index 0d54625..75b0701 100644
--- a/test/tint/builtins/gen/var/length/5b1a9b.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/var/length/5b1a9b.wgsl.expected.glsl
@@ -2,7 +2,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void length_5b1a9b() {
- f16vec4 arg_0 = f16vec4(1.0hf);
+ f16vec4 arg_0 = f16vec4(0.0hf);
float16_t res = length(arg_0);
}
@@ -24,7 +24,7 @@
precision mediump float;
void length_5b1a9b() {
- f16vec4 arg_0 = f16vec4(1.0hf);
+ f16vec4 arg_0 = f16vec4(0.0hf);
float16_t res = length(arg_0);
}
@@ -40,7 +40,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void length_5b1a9b() {
- f16vec4 arg_0 = f16vec4(1.0hf);
+ f16vec4 arg_0 = f16vec4(0.0hf);
float16_t res = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/5b1a9b.wgsl.expected.msl b/test/tint/builtins/gen/var/length/5b1a9b.wgsl.expected.msl
index 2b9aa9f..885dd66 100644
--- a/test/tint/builtins/gen/var/length/5b1a9b.wgsl.expected.msl
+++ b/test/tint/builtins/gen/var/length/5b1a9b.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void length_5b1a9b() {
- half4 arg_0 = half4(1.0h);
+ half4 arg_0 = half4(0.0h);
half res = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/5b1a9b.wgsl.expected.spvasm b/test/tint/builtins/gen/var/length/5b1a9b.wgsl.expected.spvasm
index b880106..0d97afe 100644
--- a/test/tint/builtins/gen/var/length/5b1a9b.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/var/length/5b1a9b.wgsl.expected.spvasm
@@ -1,14 +1,14 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 40
+; Bound: 38
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability UniformAndStorageBuffer16BitAccess
OpCapability StorageBuffer16BitAccess
OpCapability StorageInputOutput16
- %21 = OpExtInstImport "GLSL.std.450"
+ %19 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -38,43 +38,41 @@
%9 = OpTypeFunction %void
%half = OpTypeFloat 16
%v4half = OpTypeVector %half 4
-%half_0x1p_0 = OpConstant %half 0x1p+0
- %16 = OpConstantComposite %v4half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 %half_0x1p_0
+ %15 = OpConstantNull %v4half
%_ptr_Function_v4half = OpTypePointer Function %v4half
- %19 = OpConstantNull %v4half
%_ptr_Function_half = OpTypePointer Function %half
- %25 = OpConstantNull %half
- %26 = OpTypeFunction %v4float
+ %23 = OpConstantNull %half
+ %24 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
%length_5b1a9b = OpFunction %void None %9
%12 = OpLabel
- %arg_0 = OpVariable %_ptr_Function_v4half Function %19
- %res = OpVariable %_ptr_Function_half Function %25
- OpStore %arg_0 %16
- %22 = OpLoad %v4half %arg_0
- %20 = OpExtInst %half %21 Length %22
- OpStore %res %20
+ %arg_0 = OpVariable %_ptr_Function_v4half Function %15
+ %res = OpVariable %_ptr_Function_half Function %23
+ OpStore %arg_0 %15
+ %20 = OpLoad %v4half %arg_0
+ %18 = OpExtInst %half %19 Length %20
+ OpStore %res %18
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %26
- %28 = OpLabel
- %29 = OpFunctionCall %void %length_5b1a9b
+%vertex_main_inner = OpFunction %v4float None %24
+ %26 = OpLabel
+ %27 = OpFunctionCall %void %length_5b1a9b
OpReturnValue %5
OpFunctionEnd
%vertex_main = OpFunction %void None %9
- %31 = OpLabel
- %32 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %32
+ %29 = OpLabel
+ %30 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %30
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
%fragment_main = OpFunction %void None %9
- %35 = OpLabel
- %36 = OpFunctionCall %void %length_5b1a9b
+ %33 = OpLabel
+ %34 = OpFunctionCall %void %length_5b1a9b
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %9
- %38 = OpLabel
- %39 = OpFunctionCall %void %length_5b1a9b
+ %36 = OpLabel
+ %37 = OpFunctionCall %void %length_5b1a9b
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/length/5b1a9b.wgsl.expected.wgsl b/test/tint/builtins/gen/var/length/5b1a9b.wgsl.expected.wgsl
index c008e07..5a4657d 100644
--- a/test/tint/builtins/gen/var/length/5b1a9b.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/length/5b1a9b.wgsl.expected.wgsl
@@ -1,7 +1,7 @@
enable f16;
fn length_5b1a9b() {
- var arg_0 = vec4<f16>(1.0h);
+ var arg_0 = vec4<f16>(0.0h);
var res : f16 = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/602a17.wgsl b/test/tint/builtins/gen/var/length/602a17.wgsl
index 407ab65..e96d9d3 100644
--- a/test/tint/builtins/gen/var/length/602a17.wgsl
+++ b/test/tint/builtins/gen/var/length/602a17.wgsl
@@ -23,7 +23,7 @@
// fn length(f32) -> f32
fn length_602a17() {
- var arg_0 = 1.f;
+ var arg_0 = 0.f;
var res: f32 = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/602a17.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/length/602a17.wgsl.expected.dxc.hlsl
index 5f4310e..a887d00 100644
--- a/test/tint/builtins/gen/var/length/602a17.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/var/length/602a17.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
void length_602a17() {
- float arg_0 = 1.0f;
+ float arg_0 = 0.0f;
float res = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/602a17.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/length/602a17.wgsl.expected.fxc.hlsl
index 5f4310e..a887d00 100644
--- a/test/tint/builtins/gen/var/length/602a17.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/var/length/602a17.wgsl.expected.fxc.hlsl
@@ -1,5 +1,5 @@
void length_602a17() {
- float arg_0 = 1.0f;
+ float arg_0 = 0.0f;
float res = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/602a17.wgsl.expected.glsl b/test/tint/builtins/gen/var/length/602a17.wgsl.expected.glsl
index 41ad408..2fb5467 100644
--- a/test/tint/builtins/gen/var/length/602a17.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/var/length/602a17.wgsl.expected.glsl
@@ -1,7 +1,7 @@
#version 310 es
void length_602a17() {
- float arg_0 = 1.0f;
+ float arg_0 = 0.0f;
float res = length(arg_0);
}
@@ -22,7 +22,7 @@
precision mediump float;
void length_602a17() {
- float arg_0 = 1.0f;
+ float arg_0 = 0.0f;
float res = length(arg_0);
}
@@ -37,7 +37,7 @@
#version 310 es
void length_602a17() {
- float arg_0 = 1.0f;
+ float arg_0 = 0.0f;
float res = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/602a17.wgsl.expected.msl b/test/tint/builtins/gen/var/length/602a17.wgsl.expected.msl
index a88e9ed..b7bbcd9 100644
--- a/test/tint/builtins/gen/var/length/602a17.wgsl.expected.msl
+++ b/test/tint/builtins/gen/var/length/602a17.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void length_602a17() {
- float arg_0 = 1.0f;
+ float arg_0 = 0.0f;
float res = fabs(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/602a17.wgsl.expected.spvasm b/test/tint/builtins/gen/var/length/602a17.wgsl.expected.spvasm
index 7d99bcc..087b034 100644
--- a/test/tint/builtins/gen/var/length/602a17.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/var/length/602a17.wgsl.expected.spvasm
@@ -4,7 +4,7 @@
; Bound: 33
; Schema: 0
OpCapability Shader
- %17 = OpExtInstImport "GLSL.std.450"
+ %16 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -32,28 +32,28 @@
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
%void = OpTypeVoid
%9 = OpTypeFunction %void
- %float_1 = OpConstant %float 1
%_ptr_Function_float = OpTypePointer Function %float
- %20 = OpTypeFunction %v4float
+ %19 = OpTypeFunction %v4float
+ %float_1 = OpConstant %float 1
%length_602a17 = OpFunction %void None %9
%12 = OpLabel
%arg_0 = OpVariable %_ptr_Function_float Function %8
%res = OpVariable %_ptr_Function_float Function %8
- OpStore %arg_0 %float_1
- %18 = OpLoad %float %arg_0
- %16 = OpExtInst %float %17 Length %18
- OpStore %res %16
+ OpStore %arg_0 %8
+ %17 = OpLoad %float %arg_0
+ %15 = OpExtInst %float %16 Length %17
+ OpStore %res %15
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %20
- %22 = OpLabel
- %23 = OpFunctionCall %void %length_602a17
+%vertex_main_inner = OpFunction %v4float None %19
+ %21 = OpLabel
+ %22 = OpFunctionCall %void %length_602a17
OpReturnValue %5
OpFunctionEnd
%vertex_main = OpFunction %void None %9
- %25 = OpLabel
- %26 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %26
+ %24 = OpLabel
+ %25 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %25
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/length/602a17.wgsl.expected.wgsl b/test/tint/builtins/gen/var/length/602a17.wgsl.expected.wgsl
index 7d1a3db..aaeb9ed 100644
--- a/test/tint/builtins/gen/var/length/602a17.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/length/602a17.wgsl.expected.wgsl
@@ -1,5 +1,5 @@
fn length_602a17() {
- var arg_0 = 1.0f;
+ var arg_0 = 0.0f;
var res : f32 = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/7b4741.wgsl b/test/tint/builtins/gen/var/length/7b4741.wgsl
new file mode 100644
index 0000000..ef76630
--- /dev/null
+++ b/test/tint/builtins/gen/var/length/7b4741.wgsl
@@ -0,0 +1,44 @@
+// Copyright 2022 The Tint Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+////////////////////////////////////////////////////////////////////////////////
+// File generated by tools/src/cmd/gen
+// using the template:
+// test/tint/builtins/gen/gen.wgsl.tmpl
+//
+// Do not modify this file directly
+////////////////////////////////////////////////////////////////////////////////
+
+
+// fn length(vec<2, fa>) -> fa
+fn length_7b4741() {
+ const arg_0 = vec2(0.);
+ var res = length(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ length_7b4741();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ length_7b4741();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ length_7b4741();
+}
diff --git a/test/tint/builtins/gen/var/length/7b4741.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/length/7b4741.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..08e83f5
--- /dev/null
+++ b/test/tint/builtins/gen/var/length/7b4741.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void length_7b4741() {
+ float res = 0.0f;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ length_7b4741();
+ return (0.0f).xxxx;
+}
+
+tint_symbol vertex_main() {
+ const float4 inner_result = vertex_main_inner();
+ tint_symbol wrapper_result = (tint_symbol)0;
+ wrapper_result.value = inner_result;
+ return wrapper_result;
+}
+
+void fragment_main() {
+ length_7b4741();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ length_7b4741();
+ return;
+}
diff --git a/test/tint/builtins/gen/var/length/7b4741.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/length/7b4741.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..08e83f5
--- /dev/null
+++ b/test/tint/builtins/gen/var/length/7b4741.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void length_7b4741() {
+ float res = 0.0f;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ length_7b4741();
+ return (0.0f).xxxx;
+}
+
+tint_symbol vertex_main() {
+ const float4 inner_result = vertex_main_inner();
+ tint_symbol wrapper_result = (tint_symbol)0;
+ wrapper_result.value = inner_result;
+ return wrapper_result;
+}
+
+void fragment_main() {
+ length_7b4741();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ length_7b4741();
+ return;
+}
diff --git a/test/tint/builtins/gen/var/length/7b4741.wgsl.expected.glsl b/test/tint/builtins/gen/var/length/7b4741.wgsl.expected.glsl
new file mode 100644
index 0000000..16c9226
--- /dev/null
+++ b/test/tint/builtins/gen/var/length/7b4741.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void length_7b4741() {
+ float res = 0.0f;
+}
+
+vec4 vertex_main() {
+ length_7b4741();
+ return vec4(0.0f);
+}
+
+void main() {
+ gl_PointSize = 1.0;
+ vec4 inner_result = vertex_main();
+ gl_Position = inner_result;
+ gl_Position.y = -(gl_Position.y);
+ gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
+ return;
+}
+#version 310 es
+precision mediump float;
+
+void length_7b4741() {
+ float res = 0.0f;
+}
+
+void fragment_main() {
+ length_7b4741();
+}
+
+void main() {
+ fragment_main();
+ return;
+}
+#version 310 es
+
+void length_7b4741() {
+ float res = 0.0f;
+}
+
+void compute_main() {
+ length_7b4741();
+}
+
+layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
+void main() {
+ compute_main();
+ return;
+}
diff --git a/test/tint/builtins/gen/var/length/7b4741.wgsl.expected.msl b/test/tint/builtins/gen/var/length/7b4741.wgsl.expected.msl
new file mode 100644
index 0000000..7c9de19
--- /dev/null
+++ b/test/tint/builtins/gen/var/length/7b4741.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void length_7b4741() {
+ float res = 0.0f;
+}
+
+struct tint_symbol {
+ float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+ length_7b4741();
+ return float4(0.0f);
+}
+
+vertex tint_symbol vertex_main() {
+ float4 const inner_result = vertex_main_inner();
+ tint_symbol wrapper_result = {};
+ wrapper_result.value = inner_result;
+ return wrapper_result;
+}
+
+fragment void fragment_main() {
+ length_7b4741();
+ return;
+}
+
+kernel void compute_main() {
+ length_7b4741();
+ return;
+}
+
diff --git a/test/tint/builtins/gen/var/length/7b4741.wgsl.expected.spvasm b/test/tint/builtins/gen/var/length/7b4741.wgsl.expected.spvasm
new file mode 100644
index 0000000..c85d9f2
--- /dev/null
+++ b/test/tint/builtins/gen/var/length/7b4741.wgsl.expected.spvasm
@@ -0,0 +1,63 @@
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 0
+; Bound: 29
+; Schema: 0
+ OpCapability Shader
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
+ OpEntryPoint Fragment %fragment_main "fragment_main"
+ OpEntryPoint GLCompute %compute_main "compute_main"
+ OpExecutionMode %fragment_main OriginUpperLeft
+ OpExecutionMode %compute_main LocalSize 1 1 1
+ OpName %value "value"
+ OpName %vertex_point_size "vertex_point_size"
+ OpName %length_7b4741 "length_7b4741"
+ OpName %res "res"
+ OpName %vertex_main_inner "vertex_main_inner"
+ OpName %vertex_main "vertex_main"
+ OpName %fragment_main "fragment_main"
+ OpName %compute_main "compute_main"
+ OpDecorate %value BuiltIn Position
+ OpDecorate %vertex_point_size BuiltIn PointSize
+ %float = OpTypeFloat 32
+ %v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+ %5 = OpConstantNull %v4float
+ %value = OpVariable %_ptr_Output_v4float Output %5
+%_ptr_Output_float = OpTypePointer Output %float
+ %8 = OpConstantNull %float
+%vertex_point_size = OpVariable %_ptr_Output_float Output %8
+ %void = OpTypeVoid
+ %9 = OpTypeFunction %void
+%_ptr_Function_float = OpTypePointer Function %float
+ %15 = OpTypeFunction %v4float
+ %float_1 = OpConstant %float 1
+%length_7b4741 = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_float Function %8
+ OpStore %res %8
+ OpReturn
+ OpFunctionEnd
+%vertex_main_inner = OpFunction %v4float None %15
+ %17 = OpLabel
+ %18 = OpFunctionCall %void %length_7b4741
+ OpReturnValue %5
+ OpFunctionEnd
+%vertex_main = OpFunction %void None %9
+ %20 = OpLabel
+ %21 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %21
+ OpStore %vertex_point_size %float_1
+ OpReturn
+ OpFunctionEnd
+%fragment_main = OpFunction %void None %9
+ %24 = OpLabel
+ %25 = OpFunctionCall %void %length_7b4741
+ OpReturn
+ OpFunctionEnd
+%compute_main = OpFunction %void None %9
+ %27 = OpLabel
+ %28 = OpFunctionCall %void %length_7b4741
+ OpReturn
+ OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/length/7b4741.wgsl.expected.wgsl b/test/tint/builtins/gen/var/length/7b4741.wgsl.expected.wgsl
new file mode 100644
index 0000000..96518d9
--- /dev/null
+++ b/test/tint/builtins/gen/var/length/7b4741.wgsl.expected.wgsl
@@ -0,0 +1,20 @@
+fn length_7b4741() {
+ const arg_0 = vec2(0.0);
+ var res = length(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ length_7b4741();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ length_7b4741();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ length_7b4741();
+}
diff --git a/test/tint/builtins/gen/var/length/936ad5.wgsl b/test/tint/builtins/gen/var/length/936ad5.wgsl
new file mode 100644
index 0000000..ffaf899
--- /dev/null
+++ b/test/tint/builtins/gen/var/length/936ad5.wgsl
@@ -0,0 +1,44 @@
+// Copyright 2022 The Tint Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+////////////////////////////////////////////////////////////////////////////////
+// File generated by tools/src/cmd/gen
+// using the template:
+// test/tint/builtins/gen/gen.wgsl.tmpl
+//
+// Do not modify this file directly
+////////////////////////////////////////////////////////////////////////////////
+
+
+// fn length(fa) -> fa
+fn length_936ad5() {
+ const arg_0 = 0.;
+ var res = length(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ length_936ad5();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ length_936ad5();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ length_936ad5();
+}
diff --git a/test/tint/builtins/gen/var/length/936ad5.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/length/936ad5.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..cf6a772
--- /dev/null
+++ b/test/tint/builtins/gen/var/length/936ad5.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void length_936ad5() {
+ float res = 0.0f;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ length_936ad5();
+ return (0.0f).xxxx;
+}
+
+tint_symbol vertex_main() {
+ const float4 inner_result = vertex_main_inner();
+ tint_symbol wrapper_result = (tint_symbol)0;
+ wrapper_result.value = inner_result;
+ return wrapper_result;
+}
+
+void fragment_main() {
+ length_936ad5();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ length_936ad5();
+ return;
+}
diff --git a/test/tint/builtins/gen/var/length/936ad5.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/length/936ad5.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..cf6a772
--- /dev/null
+++ b/test/tint/builtins/gen/var/length/936ad5.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void length_936ad5() {
+ float res = 0.0f;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ length_936ad5();
+ return (0.0f).xxxx;
+}
+
+tint_symbol vertex_main() {
+ const float4 inner_result = vertex_main_inner();
+ tint_symbol wrapper_result = (tint_symbol)0;
+ wrapper_result.value = inner_result;
+ return wrapper_result;
+}
+
+void fragment_main() {
+ length_936ad5();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ length_936ad5();
+ return;
+}
diff --git a/test/tint/builtins/gen/var/length/936ad5.wgsl.expected.glsl b/test/tint/builtins/gen/var/length/936ad5.wgsl.expected.glsl
new file mode 100644
index 0000000..cfb1b8c
--- /dev/null
+++ b/test/tint/builtins/gen/var/length/936ad5.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void length_936ad5() {
+ float res = 0.0f;
+}
+
+vec4 vertex_main() {
+ length_936ad5();
+ return vec4(0.0f);
+}
+
+void main() {
+ gl_PointSize = 1.0;
+ vec4 inner_result = vertex_main();
+ gl_Position = inner_result;
+ gl_Position.y = -(gl_Position.y);
+ gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
+ return;
+}
+#version 310 es
+precision mediump float;
+
+void length_936ad5() {
+ float res = 0.0f;
+}
+
+void fragment_main() {
+ length_936ad5();
+}
+
+void main() {
+ fragment_main();
+ return;
+}
+#version 310 es
+
+void length_936ad5() {
+ float res = 0.0f;
+}
+
+void compute_main() {
+ length_936ad5();
+}
+
+layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
+void main() {
+ compute_main();
+ return;
+}
diff --git a/test/tint/builtins/gen/var/length/936ad5.wgsl.expected.msl b/test/tint/builtins/gen/var/length/936ad5.wgsl.expected.msl
new file mode 100644
index 0000000..6a2e0a7
--- /dev/null
+++ b/test/tint/builtins/gen/var/length/936ad5.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void length_936ad5() {
+ float res = 0.0f;
+}
+
+struct tint_symbol {
+ float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+ length_936ad5();
+ return float4(0.0f);
+}
+
+vertex tint_symbol vertex_main() {
+ float4 const inner_result = vertex_main_inner();
+ tint_symbol wrapper_result = {};
+ wrapper_result.value = inner_result;
+ return wrapper_result;
+}
+
+fragment void fragment_main() {
+ length_936ad5();
+ return;
+}
+
+kernel void compute_main() {
+ length_936ad5();
+ return;
+}
+
diff --git a/test/tint/builtins/gen/var/length/936ad5.wgsl.expected.spvasm b/test/tint/builtins/gen/var/length/936ad5.wgsl.expected.spvasm
new file mode 100644
index 0000000..a28538d
--- /dev/null
+++ b/test/tint/builtins/gen/var/length/936ad5.wgsl.expected.spvasm
@@ -0,0 +1,63 @@
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 0
+; Bound: 29
+; Schema: 0
+ OpCapability Shader
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
+ OpEntryPoint Fragment %fragment_main "fragment_main"
+ OpEntryPoint GLCompute %compute_main "compute_main"
+ OpExecutionMode %fragment_main OriginUpperLeft
+ OpExecutionMode %compute_main LocalSize 1 1 1
+ OpName %value "value"
+ OpName %vertex_point_size "vertex_point_size"
+ OpName %length_936ad5 "length_936ad5"
+ OpName %res "res"
+ OpName %vertex_main_inner "vertex_main_inner"
+ OpName %vertex_main "vertex_main"
+ OpName %fragment_main "fragment_main"
+ OpName %compute_main "compute_main"
+ OpDecorate %value BuiltIn Position
+ OpDecorate %vertex_point_size BuiltIn PointSize
+ %float = OpTypeFloat 32
+ %v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+ %5 = OpConstantNull %v4float
+ %value = OpVariable %_ptr_Output_v4float Output %5
+%_ptr_Output_float = OpTypePointer Output %float
+ %8 = OpConstantNull %float
+%vertex_point_size = OpVariable %_ptr_Output_float Output %8
+ %void = OpTypeVoid
+ %9 = OpTypeFunction %void
+%_ptr_Function_float = OpTypePointer Function %float
+ %15 = OpTypeFunction %v4float
+ %float_1 = OpConstant %float 1
+%length_936ad5 = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_float Function %8
+ OpStore %res %8
+ OpReturn
+ OpFunctionEnd
+%vertex_main_inner = OpFunction %v4float None %15
+ %17 = OpLabel
+ %18 = OpFunctionCall %void %length_936ad5
+ OpReturnValue %5
+ OpFunctionEnd
+%vertex_main = OpFunction %void None %9
+ %20 = OpLabel
+ %21 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %21
+ OpStore %vertex_point_size %float_1
+ OpReturn
+ OpFunctionEnd
+%fragment_main = OpFunction %void None %9
+ %24 = OpLabel
+ %25 = OpFunctionCall %void %length_936ad5
+ OpReturn
+ OpFunctionEnd
+%compute_main = OpFunction %void None %9
+ %27 = OpLabel
+ %28 = OpFunctionCall %void %length_936ad5
+ OpReturn
+ OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/length/936ad5.wgsl.expected.wgsl b/test/tint/builtins/gen/var/length/936ad5.wgsl.expected.wgsl
new file mode 100644
index 0000000..5075b6d
--- /dev/null
+++ b/test/tint/builtins/gen/var/length/936ad5.wgsl.expected.wgsl
@@ -0,0 +1,20 @@
+fn length_936ad5() {
+ const arg_0 = 0.0;
+ var res = length(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ length_936ad5();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ length_936ad5();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ length_936ad5();
+}
diff --git a/test/tint/builtins/gen/var/length/afde8b.wgsl b/test/tint/builtins/gen/var/length/afde8b.wgsl
index d24ca0b..20d6230 100644
--- a/test/tint/builtins/gen/var/length/afde8b.wgsl
+++ b/test/tint/builtins/gen/var/length/afde8b.wgsl
@@ -23,7 +23,7 @@
// fn length(vec<2, f32>) -> f32
fn length_afde8b() {
- var arg_0 = vec2<f32>(1.f);
+ var arg_0 = vec2<f32>(0.f);
var res: f32 = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/afde8b.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/length/afde8b.wgsl.expected.dxc.hlsl
index 3652276..f1ca92a 100644
--- a/test/tint/builtins/gen/var/length/afde8b.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/var/length/afde8b.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
void length_afde8b() {
- float2 arg_0 = (1.0f).xx;
+ float2 arg_0 = (0.0f).xx;
float res = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/afde8b.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/length/afde8b.wgsl.expected.fxc.hlsl
index 3652276..f1ca92a 100644
--- a/test/tint/builtins/gen/var/length/afde8b.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/var/length/afde8b.wgsl.expected.fxc.hlsl
@@ -1,5 +1,5 @@
void length_afde8b() {
- float2 arg_0 = (1.0f).xx;
+ float2 arg_0 = (0.0f).xx;
float res = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/afde8b.wgsl.expected.glsl b/test/tint/builtins/gen/var/length/afde8b.wgsl.expected.glsl
index 95b2f85..bee8807 100644
--- a/test/tint/builtins/gen/var/length/afde8b.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/var/length/afde8b.wgsl.expected.glsl
@@ -1,7 +1,7 @@
#version 310 es
void length_afde8b() {
- vec2 arg_0 = vec2(1.0f);
+ vec2 arg_0 = vec2(0.0f);
float res = length(arg_0);
}
@@ -22,7 +22,7 @@
precision mediump float;
void length_afde8b() {
- vec2 arg_0 = vec2(1.0f);
+ vec2 arg_0 = vec2(0.0f);
float res = length(arg_0);
}
@@ -37,7 +37,7 @@
#version 310 es
void length_afde8b() {
- vec2 arg_0 = vec2(1.0f);
+ vec2 arg_0 = vec2(0.0f);
float res = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/afde8b.wgsl.expected.msl b/test/tint/builtins/gen/var/length/afde8b.wgsl.expected.msl
index b283afe..ebda0cb 100644
--- a/test/tint/builtins/gen/var/length/afde8b.wgsl.expected.msl
+++ b/test/tint/builtins/gen/var/length/afde8b.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void length_afde8b() {
- float2 arg_0 = float2(1.0f);
+ float2 arg_0 = float2(0.0f);
float res = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/afde8b.wgsl.expected.spvasm b/test/tint/builtins/gen/var/length/afde8b.wgsl.expected.spvasm
index 603a9b0..975439c 100644
--- a/test/tint/builtins/gen/var/length/afde8b.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/var/length/afde8b.wgsl.expected.spvasm
@@ -1,10 +1,10 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 37
+; Bound: 36
; Schema: 0
OpCapability Shader
- %20 = OpExtInstImport "GLSL.std.450"
+ %18 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -33,41 +33,40 @@
%void = OpTypeVoid
%9 = OpTypeFunction %void
%v2float = OpTypeVector %float 2
- %float_1 = OpConstant %float 1
- %15 = OpConstantComposite %v2float %float_1 %float_1
+ %14 = OpConstantNull %v2float
%_ptr_Function_v2float = OpTypePointer Function %v2float
- %18 = OpConstantNull %v2float
%_ptr_Function_float = OpTypePointer Function %float
- %24 = OpTypeFunction %v4float
+ %22 = OpTypeFunction %v4float
+ %float_1 = OpConstant %float 1
%length_afde8b = OpFunction %void None %9
%12 = OpLabel
- %arg_0 = OpVariable %_ptr_Function_v2float Function %18
+ %arg_0 = OpVariable %_ptr_Function_v2float Function %14
%res = OpVariable %_ptr_Function_float Function %8
- OpStore %arg_0 %15
- %21 = OpLoad %v2float %arg_0
- %19 = OpExtInst %float %20 Length %21
- OpStore %res %19
+ OpStore %arg_0 %14
+ %19 = OpLoad %v2float %arg_0
+ %17 = OpExtInst %float %18 Length %19
+ OpStore %res %17
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %24
- %26 = OpLabel
- %27 = OpFunctionCall %void %length_afde8b
+%vertex_main_inner = OpFunction %v4float None %22
+ %24 = OpLabel
+ %25 = OpFunctionCall %void %length_afde8b
OpReturnValue %5
OpFunctionEnd
%vertex_main = OpFunction %void None %9
- %29 = OpLabel
- %30 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %30
+ %27 = OpLabel
+ %28 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %28
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
%fragment_main = OpFunction %void None %9
- %32 = OpLabel
- %33 = OpFunctionCall %void %length_afde8b
+ %31 = OpLabel
+ %32 = OpFunctionCall %void %length_afde8b
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %9
- %35 = OpLabel
- %36 = OpFunctionCall %void %length_afde8b
+ %34 = OpLabel
+ %35 = OpFunctionCall %void %length_afde8b
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/length/afde8b.wgsl.expected.wgsl b/test/tint/builtins/gen/var/length/afde8b.wgsl.expected.wgsl
index 17ad733..8fad0c3 100644
--- a/test/tint/builtins/gen/var/length/afde8b.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/length/afde8b.wgsl.expected.wgsl
@@ -1,5 +1,5 @@
fn length_afde8b() {
- var arg_0 = vec2<f32>(1.0f);
+ var arg_0 = vec2<f32>(0.0f);
var res : f32 = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/ba16d6.wgsl b/test/tint/builtins/gen/var/length/ba16d6.wgsl
index 7c69210..c838fd5 100644
--- a/test/tint/builtins/gen/var/length/ba16d6.wgsl
+++ b/test/tint/builtins/gen/var/length/ba16d6.wgsl
@@ -25,7 +25,7 @@
// fn length(vec<3, f16>) -> f16
fn length_ba16d6() {
- var arg_0 = vec3<f16>(1.h);
+ var arg_0 = vec3<f16>(0.h);
var res: f16 = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/ba16d6.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/length/ba16d6.wgsl.expected.dxc.hlsl
index a69b529..7480de0 100644
--- a/test/tint/builtins/gen/var/length/ba16d6.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/var/length/ba16d6.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
void length_ba16d6() {
- vector<float16_t, 3> arg_0 = (float16_t(1.0h)).xxx;
+ vector<float16_t, 3> arg_0 = (float16_t(0.0h)).xxx;
float16_t res = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/ba16d6.wgsl.expected.glsl b/test/tint/builtins/gen/var/length/ba16d6.wgsl.expected.glsl
index f73d680..ea04f30 100644
--- a/test/tint/builtins/gen/var/length/ba16d6.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/var/length/ba16d6.wgsl.expected.glsl
@@ -2,7 +2,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void length_ba16d6() {
- f16vec3 arg_0 = f16vec3(1.0hf);
+ f16vec3 arg_0 = f16vec3(0.0hf);
float16_t res = length(arg_0);
}
@@ -24,7 +24,7 @@
precision mediump float;
void length_ba16d6() {
- f16vec3 arg_0 = f16vec3(1.0hf);
+ f16vec3 arg_0 = f16vec3(0.0hf);
float16_t res = length(arg_0);
}
@@ -40,7 +40,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void length_ba16d6() {
- f16vec3 arg_0 = f16vec3(1.0hf);
+ f16vec3 arg_0 = f16vec3(0.0hf);
float16_t res = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/ba16d6.wgsl.expected.msl b/test/tint/builtins/gen/var/length/ba16d6.wgsl.expected.msl
index bb585a0..54123fc 100644
--- a/test/tint/builtins/gen/var/length/ba16d6.wgsl.expected.msl
+++ b/test/tint/builtins/gen/var/length/ba16d6.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void length_ba16d6() {
- half3 arg_0 = half3(1.0h);
+ half3 arg_0 = half3(0.0h);
half res = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/ba16d6.wgsl.expected.spvasm b/test/tint/builtins/gen/var/length/ba16d6.wgsl.expected.spvasm
index 60a8f8b..4ec76a0 100644
--- a/test/tint/builtins/gen/var/length/ba16d6.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/var/length/ba16d6.wgsl.expected.spvasm
@@ -1,14 +1,14 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 40
+; Bound: 38
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability UniformAndStorageBuffer16BitAccess
OpCapability StorageBuffer16BitAccess
OpCapability StorageInputOutput16
- %21 = OpExtInstImport "GLSL.std.450"
+ %19 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -38,43 +38,41 @@
%9 = OpTypeFunction %void
%half = OpTypeFloat 16
%v3half = OpTypeVector %half 3
-%half_0x1p_0 = OpConstant %half 0x1p+0
- %16 = OpConstantComposite %v3half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0
+ %15 = OpConstantNull %v3half
%_ptr_Function_v3half = OpTypePointer Function %v3half
- %19 = OpConstantNull %v3half
%_ptr_Function_half = OpTypePointer Function %half
- %25 = OpConstantNull %half
- %26 = OpTypeFunction %v4float
+ %23 = OpConstantNull %half
+ %24 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
%length_ba16d6 = OpFunction %void None %9
%12 = OpLabel
- %arg_0 = OpVariable %_ptr_Function_v3half Function %19
- %res = OpVariable %_ptr_Function_half Function %25
- OpStore %arg_0 %16
- %22 = OpLoad %v3half %arg_0
- %20 = OpExtInst %half %21 Length %22
- OpStore %res %20
+ %arg_0 = OpVariable %_ptr_Function_v3half Function %15
+ %res = OpVariable %_ptr_Function_half Function %23
+ OpStore %arg_0 %15
+ %20 = OpLoad %v3half %arg_0
+ %18 = OpExtInst %half %19 Length %20
+ OpStore %res %18
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %26
- %28 = OpLabel
- %29 = OpFunctionCall %void %length_ba16d6
+%vertex_main_inner = OpFunction %v4float None %24
+ %26 = OpLabel
+ %27 = OpFunctionCall %void %length_ba16d6
OpReturnValue %5
OpFunctionEnd
%vertex_main = OpFunction %void None %9
- %31 = OpLabel
- %32 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %32
+ %29 = OpLabel
+ %30 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %30
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
%fragment_main = OpFunction %void None %9
- %35 = OpLabel
- %36 = OpFunctionCall %void %length_ba16d6
+ %33 = OpLabel
+ %34 = OpFunctionCall %void %length_ba16d6
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %9
- %38 = OpLabel
- %39 = OpFunctionCall %void %length_ba16d6
+ %36 = OpLabel
+ %37 = OpFunctionCall %void %length_ba16d6
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/length/ba16d6.wgsl.expected.wgsl b/test/tint/builtins/gen/var/length/ba16d6.wgsl.expected.wgsl
index a3dcd56..2319558 100644
--- a/test/tint/builtins/gen/var/length/ba16d6.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/length/ba16d6.wgsl.expected.wgsl
@@ -1,7 +1,7 @@
enable f16;
fn length_ba16d6() {
- var arg_0 = vec3<f16>(1.0h);
+ var arg_0 = vec3<f16>(0.0h);
var res : f16 = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/becebf.wgsl b/test/tint/builtins/gen/var/length/becebf.wgsl
index ef00979..32cdab7 100644
--- a/test/tint/builtins/gen/var/length/becebf.wgsl
+++ b/test/tint/builtins/gen/var/length/becebf.wgsl
@@ -23,7 +23,7 @@
// fn length(vec<4, f32>) -> f32
fn length_becebf() {
- var arg_0 = vec4<f32>(1.f);
+ var arg_0 = vec4<f32>(0.f);
var res: f32 = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/becebf.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/length/becebf.wgsl.expected.dxc.hlsl
index 12594bc..e7760dd8 100644
--- a/test/tint/builtins/gen/var/length/becebf.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/var/length/becebf.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
void length_becebf() {
- float4 arg_0 = (1.0f).xxxx;
+ float4 arg_0 = (0.0f).xxxx;
float res = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/becebf.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/length/becebf.wgsl.expected.fxc.hlsl
index 12594bc..e7760dd8 100644
--- a/test/tint/builtins/gen/var/length/becebf.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/var/length/becebf.wgsl.expected.fxc.hlsl
@@ -1,5 +1,5 @@
void length_becebf() {
- float4 arg_0 = (1.0f).xxxx;
+ float4 arg_0 = (0.0f).xxxx;
float res = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/becebf.wgsl.expected.glsl b/test/tint/builtins/gen/var/length/becebf.wgsl.expected.glsl
index abe433f..a87cbf7 100644
--- a/test/tint/builtins/gen/var/length/becebf.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/var/length/becebf.wgsl.expected.glsl
@@ -1,7 +1,7 @@
#version 310 es
void length_becebf() {
- vec4 arg_0 = vec4(1.0f);
+ vec4 arg_0 = vec4(0.0f);
float res = length(arg_0);
}
@@ -22,7 +22,7 @@
precision mediump float;
void length_becebf() {
- vec4 arg_0 = vec4(1.0f);
+ vec4 arg_0 = vec4(0.0f);
float res = length(arg_0);
}
@@ -37,7 +37,7 @@
#version 310 es
void length_becebf() {
- vec4 arg_0 = vec4(1.0f);
+ vec4 arg_0 = vec4(0.0f);
float res = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/becebf.wgsl.expected.msl b/test/tint/builtins/gen/var/length/becebf.wgsl.expected.msl
index 27c3e89..6909b06 100644
--- a/test/tint/builtins/gen/var/length/becebf.wgsl.expected.msl
+++ b/test/tint/builtins/gen/var/length/becebf.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void length_becebf() {
- float4 arg_0 = float4(1.0f);
+ float4 arg_0 = float4(0.0f);
float res = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/becebf.wgsl.expected.spvasm b/test/tint/builtins/gen/var/length/becebf.wgsl.expected.spvasm
index 7b2a58a..4162c69 100644
--- a/test/tint/builtins/gen/var/length/becebf.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/var/length/becebf.wgsl.expected.spvasm
@@ -1,10 +1,10 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 35
+; Bound: 34
; Schema: 0
OpCapability Shader
- %18 = OpExtInstImport "GLSL.std.450"
+ %16 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -32,40 +32,39 @@
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
%void = OpTypeVoid
%9 = OpTypeFunction %void
- %float_1 = OpConstant %float 1
- %14 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
%_ptr_Function_v4float = OpTypePointer Function %v4float
%_ptr_Function_float = OpTypePointer Function %float
- %22 = OpTypeFunction %v4float
+ %20 = OpTypeFunction %v4float
+ %float_1 = OpConstant %float 1
%length_becebf = OpFunction %void None %9
%12 = OpLabel
%arg_0 = OpVariable %_ptr_Function_v4float Function %5
%res = OpVariable %_ptr_Function_float Function %8
- OpStore %arg_0 %14
- %19 = OpLoad %v4float %arg_0
- %17 = OpExtInst %float %18 Length %19
- OpStore %res %17
+ OpStore %arg_0 %5
+ %17 = OpLoad %v4float %arg_0
+ %15 = OpExtInst %float %16 Length %17
+ OpStore %res %15
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %22
- %24 = OpLabel
- %25 = OpFunctionCall %void %length_becebf
+%vertex_main_inner = OpFunction %v4float None %20
+ %22 = OpLabel
+ %23 = OpFunctionCall %void %length_becebf
OpReturnValue %5
OpFunctionEnd
%vertex_main = OpFunction %void None %9
- %27 = OpLabel
- %28 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %28
+ %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 %length_becebf
+ %29 = OpLabel
+ %30 = OpFunctionCall %void %length_becebf
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %9
- %33 = OpLabel
- %34 = OpFunctionCall %void %length_becebf
+ %32 = OpLabel
+ %33 = OpFunctionCall %void %length_becebf
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/length/becebf.wgsl.expected.wgsl b/test/tint/builtins/gen/var/length/becebf.wgsl.expected.wgsl
index 9f7791a..2d1b76d 100644
--- a/test/tint/builtins/gen/var/length/becebf.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/length/becebf.wgsl.expected.wgsl
@@ -1,5 +1,5 @@
fn length_becebf() {
- var arg_0 = vec4<f32>(1.0f);
+ var arg_0 = vec4<f32>(0.0f);
var res : f32 = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/c158da.wgsl b/test/tint/builtins/gen/var/length/c158da.wgsl
index 9c175dc..8205577 100644
--- a/test/tint/builtins/gen/var/length/c158da.wgsl
+++ b/test/tint/builtins/gen/var/length/c158da.wgsl
@@ -25,7 +25,7 @@
// fn length(f16) -> f16
fn length_c158da() {
- var arg_0 = 1.h;
+ var arg_0 = 0.h;
var res: f16 = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/c158da.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/length/c158da.wgsl.expected.dxc.hlsl
index b3b16c3..e8ad9f7 100644
--- a/test/tint/builtins/gen/var/length/c158da.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/var/length/c158da.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
void length_c158da() {
- float16_t arg_0 = float16_t(1.0h);
+ float16_t arg_0 = float16_t(0.0h);
float16_t res = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/c158da.wgsl.expected.glsl b/test/tint/builtins/gen/var/length/c158da.wgsl.expected.glsl
index 64a00e1..023690c 100644
--- a/test/tint/builtins/gen/var/length/c158da.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/var/length/c158da.wgsl.expected.glsl
@@ -2,7 +2,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void length_c158da() {
- float16_t arg_0 = 1.0hf;
+ float16_t arg_0 = 0.0hf;
float16_t res = length(arg_0);
}
@@ -24,7 +24,7 @@
precision mediump float;
void length_c158da() {
- float16_t arg_0 = 1.0hf;
+ float16_t arg_0 = 0.0hf;
float16_t res = length(arg_0);
}
@@ -40,7 +40,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void length_c158da() {
- float16_t arg_0 = 1.0hf;
+ float16_t arg_0 = 0.0hf;
float16_t res = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/c158da.wgsl.expected.msl b/test/tint/builtins/gen/var/length/c158da.wgsl.expected.msl
index 9854ae1..ea75d99 100644
--- a/test/tint/builtins/gen/var/length/c158da.wgsl.expected.msl
+++ b/test/tint/builtins/gen/var/length/c158da.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void length_c158da() {
- half arg_0 = 1.0h;
+ half arg_0 = 0.0h;
half res = fabs(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/c158da.wgsl.expected.spvasm b/test/tint/builtins/gen/var/length/c158da.wgsl.expected.spvasm
index 5c55dc8..5b14574 100644
--- a/test/tint/builtins/gen/var/length/c158da.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/var/length/c158da.wgsl.expected.spvasm
@@ -1,14 +1,14 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 36
+; Bound: 35
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability UniformAndStorageBuffer16BitAccess
OpCapability StorageBuffer16BitAccess
OpCapability StorageInputOutput16
- %19 = OpExtInstImport "GLSL.std.450"
+ %18 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -37,40 +37,39 @@
%void = OpTypeVoid
%9 = OpTypeFunction %void
%half = OpTypeFloat 16
-%half_0x1p_0 = OpConstant %half 0x1p+0
+ %14 = OpConstantNull %half
%_ptr_Function_half = OpTypePointer Function %half
- %17 = OpConstantNull %half
- %22 = OpTypeFunction %v4float
+ %21 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
%length_c158da = OpFunction %void None %9
%12 = OpLabel
- %arg_0 = OpVariable %_ptr_Function_half Function %17
- %res = OpVariable %_ptr_Function_half Function %17
- OpStore %arg_0 %half_0x1p_0
- %20 = OpLoad %half %arg_0
- %18 = OpExtInst %half %19 Length %20
- OpStore %res %18
+ %arg_0 = OpVariable %_ptr_Function_half Function %14
+ %res = OpVariable %_ptr_Function_half Function %14
+ OpStore %arg_0 %14
+ %19 = OpLoad %half %arg_0
+ %17 = OpExtInst %half %18 Length %19
+ OpStore %res %17
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %22
- %24 = OpLabel
- %25 = OpFunctionCall %void %length_c158da
+%vertex_main_inner = OpFunction %v4float None %21
+ %23 = OpLabel
+ %24 = OpFunctionCall %void %length_c158da
OpReturnValue %5
OpFunctionEnd
%vertex_main = OpFunction %void None %9
- %27 = OpLabel
- %28 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %28
+ %26 = OpLabel
+ %27 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %27
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
%fragment_main = OpFunction %void None %9
- %31 = OpLabel
- %32 = OpFunctionCall %void %length_c158da
+ %30 = OpLabel
+ %31 = OpFunctionCall %void %length_c158da
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %9
- %34 = OpLabel
- %35 = OpFunctionCall %void %length_c158da
+ %33 = OpLabel
+ %34 = OpFunctionCall %void %length_c158da
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/length/c158da.wgsl.expected.wgsl b/test/tint/builtins/gen/var/length/c158da.wgsl.expected.wgsl
index 2017cde..dc07d4b 100644
--- a/test/tint/builtins/gen/var/length/c158da.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/length/c158da.wgsl.expected.wgsl
@@ -1,7 +1,7 @@
enable f16;
fn length_c158da() {
- var arg_0 = 1.0h;
+ var arg_0 = 0.0h;
var res : f16 = length(arg_0);
}
diff --git a/test/tint/builtins/gen/var/length/c2c544.wgsl b/test/tint/builtins/gen/var/length/c2c544.wgsl
new file mode 100644
index 0000000..5e145ff
--- /dev/null
+++ b/test/tint/builtins/gen/var/length/c2c544.wgsl
@@ -0,0 +1,44 @@
+// Copyright 2022 The Tint Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+////////////////////////////////////////////////////////////////////////////////
+// File generated by tools/src/cmd/gen
+// using the template:
+// test/tint/builtins/gen/gen.wgsl.tmpl
+//
+// Do not modify this file directly
+////////////////////////////////////////////////////////////////////////////////
+
+
+// fn length(vec<4, fa>) -> fa
+fn length_c2c544() {
+ const arg_0 = vec4(0.);
+ var res = length(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ length_c2c544();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ length_c2c544();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ length_c2c544();
+}
diff --git a/test/tint/builtins/gen/var/length/c2c544.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/length/c2c544.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..3182250
--- /dev/null
+++ b/test/tint/builtins/gen/var/length/c2c544.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void length_c2c544() {
+ float res = 0.0f;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ length_c2c544();
+ return (0.0f).xxxx;
+}
+
+tint_symbol vertex_main() {
+ const float4 inner_result = vertex_main_inner();
+ tint_symbol wrapper_result = (tint_symbol)0;
+ wrapper_result.value = inner_result;
+ return wrapper_result;
+}
+
+void fragment_main() {
+ length_c2c544();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ length_c2c544();
+ return;
+}
diff --git a/test/tint/builtins/gen/var/length/c2c544.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/length/c2c544.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..3182250
--- /dev/null
+++ b/test/tint/builtins/gen/var/length/c2c544.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void length_c2c544() {
+ float res = 0.0f;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ length_c2c544();
+ return (0.0f).xxxx;
+}
+
+tint_symbol vertex_main() {
+ const float4 inner_result = vertex_main_inner();
+ tint_symbol wrapper_result = (tint_symbol)0;
+ wrapper_result.value = inner_result;
+ return wrapper_result;
+}
+
+void fragment_main() {
+ length_c2c544();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ length_c2c544();
+ return;
+}
diff --git a/test/tint/builtins/gen/var/length/c2c544.wgsl.expected.glsl b/test/tint/builtins/gen/var/length/c2c544.wgsl.expected.glsl
new file mode 100644
index 0000000..6c6a328
--- /dev/null
+++ b/test/tint/builtins/gen/var/length/c2c544.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void length_c2c544() {
+ float res = 0.0f;
+}
+
+vec4 vertex_main() {
+ length_c2c544();
+ return vec4(0.0f);
+}
+
+void main() {
+ gl_PointSize = 1.0;
+ vec4 inner_result = vertex_main();
+ gl_Position = inner_result;
+ gl_Position.y = -(gl_Position.y);
+ gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
+ return;
+}
+#version 310 es
+precision mediump float;
+
+void length_c2c544() {
+ float res = 0.0f;
+}
+
+void fragment_main() {
+ length_c2c544();
+}
+
+void main() {
+ fragment_main();
+ return;
+}
+#version 310 es
+
+void length_c2c544() {
+ float res = 0.0f;
+}
+
+void compute_main() {
+ length_c2c544();
+}
+
+layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
+void main() {
+ compute_main();
+ return;
+}
diff --git a/test/tint/builtins/gen/var/length/c2c544.wgsl.expected.msl b/test/tint/builtins/gen/var/length/c2c544.wgsl.expected.msl
new file mode 100644
index 0000000..e4d987c
--- /dev/null
+++ b/test/tint/builtins/gen/var/length/c2c544.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void length_c2c544() {
+ float res = 0.0f;
+}
+
+struct tint_symbol {
+ float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+ length_c2c544();
+ return float4(0.0f);
+}
+
+vertex tint_symbol vertex_main() {
+ float4 const inner_result = vertex_main_inner();
+ tint_symbol wrapper_result = {};
+ wrapper_result.value = inner_result;
+ return wrapper_result;
+}
+
+fragment void fragment_main() {
+ length_c2c544();
+ return;
+}
+
+kernel void compute_main() {
+ length_c2c544();
+ return;
+}
+
diff --git a/test/tint/builtins/gen/var/length/c2c544.wgsl.expected.spvasm b/test/tint/builtins/gen/var/length/c2c544.wgsl.expected.spvasm
new file mode 100644
index 0000000..c3a38b8
--- /dev/null
+++ b/test/tint/builtins/gen/var/length/c2c544.wgsl.expected.spvasm
@@ -0,0 +1,63 @@
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 0
+; Bound: 29
+; Schema: 0
+ OpCapability Shader
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
+ OpEntryPoint Fragment %fragment_main "fragment_main"
+ OpEntryPoint GLCompute %compute_main "compute_main"
+ OpExecutionMode %fragment_main OriginUpperLeft
+ OpExecutionMode %compute_main LocalSize 1 1 1
+ OpName %value "value"
+ OpName %vertex_point_size "vertex_point_size"
+ OpName %length_c2c544 "length_c2c544"
+ OpName %res "res"
+ OpName %vertex_main_inner "vertex_main_inner"
+ OpName %vertex_main "vertex_main"
+ OpName %fragment_main "fragment_main"
+ OpName %compute_main "compute_main"
+ OpDecorate %value BuiltIn Position
+ OpDecorate %vertex_point_size BuiltIn PointSize
+ %float = OpTypeFloat 32
+ %v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+ %5 = OpConstantNull %v4float
+ %value = OpVariable %_ptr_Output_v4float Output %5
+%_ptr_Output_float = OpTypePointer Output %float
+ %8 = OpConstantNull %float
+%vertex_point_size = OpVariable %_ptr_Output_float Output %8
+ %void = OpTypeVoid
+ %9 = OpTypeFunction %void
+%_ptr_Function_float = OpTypePointer Function %float
+ %15 = OpTypeFunction %v4float
+ %float_1 = OpConstant %float 1
+%length_c2c544 = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_float Function %8
+ OpStore %res %8
+ OpReturn
+ OpFunctionEnd
+%vertex_main_inner = OpFunction %v4float None %15
+ %17 = OpLabel
+ %18 = OpFunctionCall %void %length_c2c544
+ OpReturnValue %5
+ OpFunctionEnd
+%vertex_main = OpFunction %void None %9
+ %20 = OpLabel
+ %21 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %21
+ OpStore %vertex_point_size %float_1
+ OpReturn
+ OpFunctionEnd
+%fragment_main = OpFunction %void None %9
+ %24 = OpLabel
+ %25 = OpFunctionCall %void %length_c2c544
+ OpReturn
+ OpFunctionEnd
+%compute_main = OpFunction %void None %9
+ %27 = OpLabel
+ %28 = OpFunctionCall %void %length_c2c544
+ OpReturn
+ OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/length/c2c544.wgsl.expected.wgsl b/test/tint/builtins/gen/var/length/c2c544.wgsl.expected.wgsl
new file mode 100644
index 0000000..b7f0ae8
--- /dev/null
+++ b/test/tint/builtins/gen/var/length/c2c544.wgsl.expected.wgsl
@@ -0,0 +1,20 @@
+fn length_c2c544() {
+ const arg_0 = vec4(0.0);
+ var res = length(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ length_c2c544();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ length_c2c544();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ length_c2c544();
+}