Add const-eval for `sqrt`
This CL adds const-eval for `sqrt`.
Bug: tint:1581
Change-Id: I0d109e6439feaf07edb7db4d6a50274c1c4efcae
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110174
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
diff --git a/src/tint/intrinsics.def b/src/tint/intrinsics.def
index 5a088db..c368566 100644
--- a/src/tint/intrinsics.def
+++ b/src/tint/intrinsics.def
@@ -537,8 +537,8 @@
@const fn sinh<N: num, T: fa_f32_f16>(vec<N, T>) -> vec<N, T>
fn smoothstep<T: f32_f16>(T, T, T) -> T
fn smoothstep<N: num, T: f32_f16>(vec<N, T>, vec<N, T>, vec<N, T>) -> vec<N, T>
-fn sqrt<T: f32_f16>(T) -> T
-fn sqrt<N: num, T: f32_f16>(vec<N, T>) -> vec<N, T>
+@const fn sqrt<T: fa_f32_f16>(T) -> T
+@const fn sqrt<N: num, T: fa_f32_f16>(vec<N, T>) -> vec<N, T>
@const fn step<T: fa_f32_f16>(T, T) -> T
@const fn step<N: num, T: fa_f32_f16>(vec<N, T>, vec<N, T>) -> vec<N, T>
@stage("compute") fn storageBarrier()
diff --git a/src/tint/resolver/const_eval.cc b/src/tint/resolver/const_eval.cc
index 251690f..fa5506d 100644
--- a/src/tint/resolver/const_eval.cc
+++ b/src/tint/resolver/const_eval.cc
@@ -2375,6 +2375,24 @@
return TransformElements(builder, ty, transform, args[0], args[1]);
}
+ConstEval::Result ConstEval::sqrt(const sem::Type* ty,
+ 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, c0->Type(), NumberT(std::sqrt(i.value)));
+ };
+ return Dispatch_fa_f32_f16(create, c0);
+ };
+
+ return TransformElements(builder, ty, transform, args[0]);
+}
+
ConstEval::Result ConstEval::tan(const sem::Type* ty,
utils::VectorRef<const sem::Constant*> args,
const Source&) {
diff --git a/src/tint/resolver/const_eval.h b/src/tint/resolver/const_eval.h
index e64511b..269fc40 100644
--- a/src/tint/resolver/const_eval.h
+++ b/src/tint/resolver/const_eval.h
@@ -719,6 +719,15 @@
utils::VectorRef<const sem::Constant*> args,
const Source& source);
+ /// sqrt builtin
+ /// @param ty the expression type
+ /// @param args the input arguments
+ /// @param source the source location of the conversion
+ /// @return the result value, or null if the value cannot be calculated
+ Result sqrt(const sem::Type* ty,
+ utils::VectorRef<const sem::Constant*> args,
+ const Source& source);
+
/// tan builtin
/// @param ty the expression type
/// @param args the input arguments
diff --git a/src/tint/resolver/const_eval_builtin_test.cc b/src/tint/resolver/const_eval_builtin_test.cc
index b23cc0c..d3e3ca0 100644
--- a/src/tint/resolver/const_eval_builtin_test.cc
+++ b/src/tint/resolver/const_eval_builtin_test.cc
@@ -1651,6 +1651,28 @@
StepCases<f16>()))));
template <typename T>
+std::vector<Case> SqrtCases() {
+ std::vector<Case> cases = {
+ C({-T(0)}, -T(0)), //
+ C({T(0)}, T(0)), //
+ C({T(25)}, T(5)),
+
+ // Vector tests
+ C({Vec(T(25), T(100))}, Vec(T(5), T(10))),
+
+ E({-T(25)}, "12:34 error: sqrt must be called with a value >= 0"),
+ };
+ return cases;
+}
+INSTANTIATE_TEST_SUITE_P( //
+ Sqrt,
+ ResolverConstEvalBuiltinTest,
+ testing::Combine(testing::Values(sem::BuiltinType::kSqrt),
+ testing::ValuesIn(Concat(SqrtCases<AFloat>(), //
+ SqrtCases<f32>(),
+ SqrtCases<f16>()))));
+
+template <typename T>
std::vector<Case> TanCases() {
std::vector<Case> cases = {
C({-T(0)}, -T(0)),
diff --git a/src/tint/resolver/intrinsic_table.inl b/src/tint/resolver/intrinsic_table.inl
index 66bbf72..f820046 100644
--- a/src/tint/resolver/intrinsic_table.inl
+++ b/src/tint/resolver/intrinsic_table.inl
@@ -12585,24 +12585,24 @@
/* num parameters */ 1,
/* num template types */ 1,
/* num template numbers */ 0,
- /* template types */ &kTemplateTypes[25],
+ /* template types */ &kTemplateTypes[24],
/* template numbers */ &kTemplateNumbers[10],
/* parameters */ &kParameters[912],
/* return matcher indices */ &kMatcherIndices[1],
/* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
- /* const eval */ nullptr,
+ /* const eval */ &ConstEval::sqrt,
},
{
/* [355] */
/* num parameters */ 1,
/* num template types */ 1,
/* num template numbers */ 1,
- /* template types */ &kTemplateTypes[25],
+ /* template types */ &kTemplateTypes[24],
/* template numbers */ &kTemplateNumbers[5],
/* parameters */ &kParameters[913],
/* return matcher indices */ &kMatcherIndices[30],
/* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
- /* const eval */ nullptr,
+ /* const eval */ &ConstEval::sqrt,
},
{
/* [356] */
@@ -14511,8 +14511,8 @@
},
{
/* [73] */
- /* fn sqrt<T : f32_f16>(T) -> T */
- /* fn sqrt<N : num, T : f32_f16>(vec<N, T>) -> vec<N, T> */
+ /* fn sqrt<T : fa_f32_f16>(T) -> T */
+ /* fn sqrt<N : num, T : fa_f32_f16>(vec<N, T>) -> vec<N, T> */
/* num overloads */ 2,
/* overloads */ &kOverloads[354],
},
diff --git a/test/tint/builtins/gen/literal/sqrt/072192.wgsl b/test/tint/builtins/gen/literal/sqrt/072192.wgsl
new file mode 100644
index 0000000..7943f01
--- /dev/null
+++ b/test/tint/builtins/gen/literal/sqrt/072192.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 sqrt(vec<3, fa>) -> vec<3, fa>
+fn sqrt_072192() {
+ var res = sqrt(vec3(1.));
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ sqrt_072192();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ sqrt_072192();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ sqrt_072192();
+}
diff --git a/test/tint/builtins/gen/literal/sqrt/072192.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/sqrt/072192.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..eb05088
--- /dev/null
+++ b/test/tint/builtins/gen/literal/sqrt/072192.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void sqrt_072192() {
+ float3 res = (1.0f).xxx;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ sqrt_072192();
+ 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() {
+ sqrt_072192();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ sqrt_072192();
+ return;
+}
diff --git a/test/tint/builtins/gen/literal/sqrt/072192.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/sqrt/072192.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..eb05088
--- /dev/null
+++ b/test/tint/builtins/gen/literal/sqrt/072192.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void sqrt_072192() {
+ float3 res = (1.0f).xxx;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ sqrt_072192();
+ 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() {
+ sqrt_072192();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ sqrt_072192();
+ return;
+}
diff --git a/test/tint/builtins/gen/literal/sqrt/072192.wgsl.expected.glsl b/test/tint/builtins/gen/literal/sqrt/072192.wgsl.expected.glsl
new file mode 100644
index 0000000..910819a
--- /dev/null
+++ b/test/tint/builtins/gen/literal/sqrt/072192.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void sqrt_072192() {
+ vec3 res = vec3(1.0f);
+}
+
+vec4 vertex_main() {
+ sqrt_072192();
+ 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 sqrt_072192() {
+ vec3 res = vec3(1.0f);
+}
+
+void fragment_main() {
+ sqrt_072192();
+}
+
+void main() {
+ fragment_main();
+ return;
+}
+#version 310 es
+
+void sqrt_072192() {
+ vec3 res = vec3(1.0f);
+}
+
+void compute_main() {
+ sqrt_072192();
+}
+
+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/sqrt/072192.wgsl.expected.msl b/test/tint/builtins/gen/literal/sqrt/072192.wgsl.expected.msl
new file mode 100644
index 0000000..aa1da7b
--- /dev/null
+++ b/test/tint/builtins/gen/literal/sqrt/072192.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void sqrt_072192() {
+ float3 res = float3(1.0f);
+}
+
+struct tint_symbol {
+ float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+ sqrt_072192();
+ 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() {
+ sqrt_072192();
+ return;
+}
+
+kernel void compute_main() {
+ sqrt_072192();
+ return;
+}
+
diff --git a/test/tint/builtins/gen/literal/sqrt/072192.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/sqrt/072192.wgsl.expected.spvasm
new file mode 100644
index 0000000..a54c8a7
--- /dev/null
+++ b/test/tint/builtins/gen/literal/sqrt/072192.wgsl.expected.spvasm
@@ -0,0 +1,66 @@
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 0
+; Bound: 32
+; 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 %sqrt_072192 "sqrt_072192"
+ 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
+ %v3float = OpTypeVector %float 3
+ %float_1 = OpConstant %float 1
+ %15 = OpConstantComposite %v3float %float_1 %float_1 %float_1
+%_ptr_Function_v3float = OpTypePointer Function %v3float
+ %18 = OpConstantNull %v3float
+ %19 = OpTypeFunction %v4float
+%sqrt_072192 = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_v3float Function %18
+ OpStore %res %15
+ OpReturn
+ OpFunctionEnd
+%vertex_main_inner = OpFunction %v4float None %19
+ %21 = OpLabel
+ %22 = OpFunctionCall %void %sqrt_072192
+ OpReturnValue %5
+ OpFunctionEnd
+%vertex_main = OpFunction %void None %9
+ %24 = OpLabel
+ %25 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %25
+ OpStore %vertex_point_size %float_1
+ OpReturn
+ OpFunctionEnd
+%fragment_main = OpFunction %void None %9
+ %27 = OpLabel
+ %28 = OpFunctionCall %void %sqrt_072192
+ OpReturn
+ OpFunctionEnd
+%compute_main = OpFunction %void None %9
+ %30 = OpLabel
+ %31 = OpFunctionCall %void %sqrt_072192
+ OpReturn
+ OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/sqrt/072192.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/sqrt/072192.wgsl.expected.wgsl
new file mode 100644
index 0000000..6eeca72
--- /dev/null
+++ b/test/tint/builtins/gen/literal/sqrt/072192.wgsl.expected.wgsl
@@ -0,0 +1,19 @@
+fn sqrt_072192() {
+ var res = sqrt(vec3(1.0));
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ sqrt_072192();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ sqrt_072192();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ sqrt_072192();
+}
diff --git a/test/tint/builtins/gen/literal/sqrt/20c74e.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/sqrt/20c74e.wgsl.expected.dxc.hlsl
index a1f4acb..f50210d 100644
--- a/test/tint/builtins/gen/literal/sqrt/20c74e.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/sqrt/20c74e.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
void sqrt_20c74e() {
- float res = sqrt(1.0f);
+ float res = 1.0f;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/sqrt/20c74e.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/sqrt/20c74e.wgsl.expected.fxc.hlsl
index a1f4acb..f50210d 100644
--- a/test/tint/builtins/gen/literal/sqrt/20c74e.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/sqrt/20c74e.wgsl.expected.fxc.hlsl
@@ -1,5 +1,5 @@
void sqrt_20c74e() {
- float res = sqrt(1.0f);
+ float res = 1.0f;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/sqrt/20c74e.wgsl.expected.glsl b/test/tint/builtins/gen/literal/sqrt/20c74e.wgsl.expected.glsl
index 08f5000..2d9a577 100644
--- a/test/tint/builtins/gen/literal/sqrt/20c74e.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/sqrt/20c74e.wgsl.expected.glsl
@@ -1,7 +1,7 @@
#version 310 es
void sqrt_20c74e() {
- float res = sqrt(1.0f);
+ float res = 1.0f;
}
vec4 vertex_main() {
@@ -21,7 +21,7 @@
precision mediump float;
void sqrt_20c74e() {
- float res = sqrt(1.0f);
+ float res = 1.0f;
}
void fragment_main() {
@@ -35,7 +35,7 @@
#version 310 es
void sqrt_20c74e() {
- float res = sqrt(1.0f);
+ float res = 1.0f;
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/sqrt/20c74e.wgsl.expected.msl b/test/tint/builtins/gen/literal/sqrt/20c74e.wgsl.expected.msl
index 7f933af..02d8ac3 100644
--- a/test/tint/builtins/gen/literal/sqrt/20c74e.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/sqrt/20c74e.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void sqrt_20c74e() {
- float res = sqrt(1.0f);
+ float res = 1.0f;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/sqrt/20c74e.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/sqrt/20c74e.wgsl.expected.spvasm
index a9e5def..11cec2f 100644
--- a/test/tint/builtins/gen/literal/sqrt/20c74e.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/sqrt/20c74e.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"
@@ -33,33 +32,32 @@
%9 = OpTypeFunction %void
%float_1 = OpConstant %float 1
%_ptr_Function_float = OpTypePointer Function %float
- %18 = OpTypeFunction %v4float
+ %16 = OpTypeFunction %v4float
%sqrt_20c74e = OpFunction %void None %9
%12 = OpLabel
%res = OpVariable %_ptr_Function_float Function %8
- %13 = OpExtInst %float %14 Sqrt %float_1
- OpStore %res %13
+ OpStore %res %float_1
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %18
- %20 = OpLabel
- %21 = OpFunctionCall %void %sqrt_20c74e
+%vertex_main_inner = OpFunction %v4float None %16
+ %18 = OpLabel
+ %19 = OpFunctionCall %void %sqrt_20c74e
OpReturnValue %5
OpFunctionEnd
%vertex_main = OpFunction %void None %9
- %23 = OpLabel
- %24 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %24
+ %21 = OpLabel
+ %22 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %22
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
%fragment_main = OpFunction %void None %9
- %26 = OpLabel
- %27 = OpFunctionCall %void %sqrt_20c74e
+ %24 = OpLabel
+ %25 = OpFunctionCall %void %sqrt_20c74e
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %9
- %29 = OpLabel
- %30 = OpFunctionCall %void %sqrt_20c74e
+ %27 = OpLabel
+ %28 = OpFunctionCall %void %sqrt_20c74e
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/sqrt/4ac2c5.wgsl b/test/tint/builtins/gen/literal/sqrt/4ac2c5.wgsl
new file mode 100644
index 0000000..52b9585
--- /dev/null
+++ b/test/tint/builtins/gen/literal/sqrt/4ac2c5.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 sqrt(vec<4, fa>) -> vec<4, fa>
+fn sqrt_4ac2c5() {
+ var res = sqrt(vec4(1.));
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ sqrt_4ac2c5();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ sqrt_4ac2c5();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ sqrt_4ac2c5();
+}
diff --git a/test/tint/builtins/gen/literal/sqrt/4ac2c5.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/sqrt/4ac2c5.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..4e62875
--- /dev/null
+++ b/test/tint/builtins/gen/literal/sqrt/4ac2c5.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void sqrt_4ac2c5() {
+ float4 res = (1.0f).xxxx;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ sqrt_4ac2c5();
+ 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() {
+ sqrt_4ac2c5();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ sqrt_4ac2c5();
+ return;
+}
diff --git a/test/tint/builtins/gen/literal/sqrt/4ac2c5.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/sqrt/4ac2c5.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..4e62875
--- /dev/null
+++ b/test/tint/builtins/gen/literal/sqrt/4ac2c5.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void sqrt_4ac2c5() {
+ float4 res = (1.0f).xxxx;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ sqrt_4ac2c5();
+ 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() {
+ sqrt_4ac2c5();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ sqrt_4ac2c5();
+ return;
+}
diff --git a/test/tint/builtins/gen/literal/sqrt/4ac2c5.wgsl.expected.glsl b/test/tint/builtins/gen/literal/sqrt/4ac2c5.wgsl.expected.glsl
new file mode 100644
index 0000000..ee4417e
--- /dev/null
+++ b/test/tint/builtins/gen/literal/sqrt/4ac2c5.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void sqrt_4ac2c5() {
+ vec4 res = vec4(1.0f);
+}
+
+vec4 vertex_main() {
+ sqrt_4ac2c5();
+ 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 sqrt_4ac2c5() {
+ vec4 res = vec4(1.0f);
+}
+
+void fragment_main() {
+ sqrt_4ac2c5();
+}
+
+void main() {
+ fragment_main();
+ return;
+}
+#version 310 es
+
+void sqrt_4ac2c5() {
+ vec4 res = vec4(1.0f);
+}
+
+void compute_main() {
+ sqrt_4ac2c5();
+}
+
+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/sqrt/4ac2c5.wgsl.expected.msl b/test/tint/builtins/gen/literal/sqrt/4ac2c5.wgsl.expected.msl
new file mode 100644
index 0000000..5e02b2e
--- /dev/null
+++ b/test/tint/builtins/gen/literal/sqrt/4ac2c5.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void sqrt_4ac2c5() {
+ float4 res = float4(1.0f);
+}
+
+struct tint_symbol {
+ float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+ sqrt_4ac2c5();
+ 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() {
+ sqrt_4ac2c5();
+ return;
+}
+
+kernel void compute_main() {
+ sqrt_4ac2c5();
+ return;
+}
+
diff --git a/test/tint/builtins/gen/literal/sqrt/4ac2c5.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/sqrt/4ac2c5.wgsl.expected.spvasm
new file mode 100644
index 0000000..57ed3a3
--- /dev/null
+++ b/test/tint/builtins/gen/literal/sqrt/4ac2c5.wgsl.expected.spvasm
@@ -0,0 +1,64 @@
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 0
+; Bound: 30
+; 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 %sqrt_4ac2c5 "sqrt_4ac2c5"
+ 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
+ %float_1 = OpConstant %float 1
+ %14 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
+%_ptr_Function_v4float = OpTypePointer Function %v4float
+ %17 = OpTypeFunction %v4float
+%sqrt_4ac2c5 = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_v4float Function %5
+ OpStore %res %14
+ OpReturn
+ OpFunctionEnd
+%vertex_main_inner = OpFunction %v4float None %17
+ %19 = OpLabel
+ %20 = OpFunctionCall %void %sqrt_4ac2c5
+ OpReturnValue %5
+ OpFunctionEnd
+%vertex_main = OpFunction %void None %9
+ %22 = OpLabel
+ %23 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %23
+ OpStore %vertex_point_size %float_1
+ OpReturn
+ OpFunctionEnd
+%fragment_main = OpFunction %void None %9
+ %25 = OpLabel
+ %26 = OpFunctionCall %void %sqrt_4ac2c5
+ OpReturn
+ OpFunctionEnd
+%compute_main = OpFunction %void None %9
+ %28 = OpLabel
+ %29 = OpFunctionCall %void %sqrt_4ac2c5
+ OpReturn
+ OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/sqrt/4ac2c5.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/sqrt/4ac2c5.wgsl.expected.wgsl
new file mode 100644
index 0000000..331739a
--- /dev/null
+++ b/test/tint/builtins/gen/literal/sqrt/4ac2c5.wgsl.expected.wgsl
@@ -0,0 +1,19 @@
+fn sqrt_4ac2c5() {
+ var res = sqrt(vec4(1.0));
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ sqrt_4ac2c5();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ sqrt_4ac2c5();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ sqrt_4ac2c5();
+}
diff --git a/test/tint/builtins/gen/literal/sqrt/803d1c.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/sqrt/803d1c.wgsl.expected.dxc.hlsl
index 1f072d6..c046655 100644
--- a/test/tint/builtins/gen/literal/sqrt/803d1c.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/sqrt/803d1c.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
void sqrt_803d1c() {
- vector<float16_t, 4> res = sqrt((float16_t(1.0h)).xxxx);
+ vector<float16_t, 4> res = (float16_t(1.0h)).xxxx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/sqrt/803d1c.wgsl.expected.glsl b/test/tint/builtins/gen/literal/sqrt/803d1c.wgsl.expected.glsl
index 8282522..7b5ed1b 100644
--- a/test/tint/builtins/gen/literal/sqrt/803d1c.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/sqrt/803d1c.wgsl.expected.glsl
@@ -2,7 +2,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void sqrt_803d1c() {
- f16vec4 res = sqrt(f16vec4(1.0hf));
+ f16vec4 res = f16vec4(1.0hf);
}
vec4 vertex_main() {
@@ -23,7 +23,7 @@
precision mediump float;
void sqrt_803d1c() {
- f16vec4 res = sqrt(f16vec4(1.0hf));
+ f16vec4 res = f16vec4(1.0hf);
}
void fragment_main() {
@@ -38,7 +38,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void sqrt_803d1c() {
- f16vec4 res = sqrt(f16vec4(1.0hf));
+ f16vec4 res = f16vec4(1.0hf);
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/sqrt/803d1c.wgsl.expected.msl b/test/tint/builtins/gen/literal/sqrt/803d1c.wgsl.expected.msl
index f5ed424..c784c32 100644
--- a/test/tint/builtins/gen/literal/sqrt/803d1c.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/sqrt/803d1c.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void sqrt_803d1c() {
- half4 res = sqrt(half4(1.0h));
+ half4 res = half4(1.0h);
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/sqrt/803d1c.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/sqrt/803d1c.wgsl.expected.spvasm
index eb9d728..907832f 100644
--- a/test/tint/builtins/gen/literal/sqrt/803d1c.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/sqrt/803d1c.wgsl.expected.spvasm
@@ -1,14 +1,13 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 36
+; Bound: 34
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability UniformAndStorageBuffer16BitAccess
OpCapability StorageBuffer16BitAccess
OpCapability StorageInputOutput16
- %16 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -38,37 +37,36 @@
%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
+ %16 = OpConstantComposite %v4half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 %half_0x1p_0
%_ptr_Function_v4half = OpTypePointer Function %v4half
- %21 = OpConstantNull %v4half
- %22 = OpTypeFunction %v4float
+ %19 = OpConstantNull %v4half
+ %20 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
%sqrt_803d1c = OpFunction %void None %9
%12 = OpLabel
- %res = OpVariable %_ptr_Function_v4half Function %21
- %13 = OpExtInst %v4half %16 Sqrt %18
- OpStore %res %13
+ %res = OpVariable %_ptr_Function_v4half Function %19
+ OpStore %res %16
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %22
- %24 = OpLabel
- %25 = OpFunctionCall %void %sqrt_803d1c
+%vertex_main_inner = OpFunction %v4float None %20
+ %22 = OpLabel
+ %23 = OpFunctionCall %void %sqrt_803d1c
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
- %31 = OpLabel
- %32 = OpFunctionCall %void %sqrt_803d1c
+ %29 = OpLabel
+ %30 = OpFunctionCall %void %sqrt_803d1c
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %9
- %34 = OpLabel
- %35 = OpFunctionCall %void %sqrt_803d1c
+ %32 = OpLabel
+ %33 = OpFunctionCall %void %sqrt_803d1c
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/sqrt/895a0c.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/sqrt/895a0c.wgsl.expected.dxc.hlsl
index b3f2c26..aaaaa0b 100644
--- a/test/tint/builtins/gen/literal/sqrt/895a0c.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/sqrt/895a0c.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
void sqrt_895a0c() {
- vector<float16_t, 3> res = sqrt((float16_t(1.0h)).xxx);
+ vector<float16_t, 3> res = (float16_t(1.0h)).xxx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/sqrt/895a0c.wgsl.expected.glsl b/test/tint/builtins/gen/literal/sqrt/895a0c.wgsl.expected.glsl
index 4a89c94..aae6300 100644
--- a/test/tint/builtins/gen/literal/sqrt/895a0c.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/sqrt/895a0c.wgsl.expected.glsl
@@ -2,7 +2,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void sqrt_895a0c() {
- f16vec3 res = sqrt(f16vec3(1.0hf));
+ f16vec3 res = f16vec3(1.0hf);
}
vec4 vertex_main() {
@@ -23,7 +23,7 @@
precision mediump float;
void sqrt_895a0c() {
- f16vec3 res = sqrt(f16vec3(1.0hf));
+ f16vec3 res = f16vec3(1.0hf);
}
void fragment_main() {
@@ -38,7 +38,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void sqrt_895a0c() {
- f16vec3 res = sqrt(f16vec3(1.0hf));
+ f16vec3 res = f16vec3(1.0hf);
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/sqrt/895a0c.wgsl.expected.msl b/test/tint/builtins/gen/literal/sqrt/895a0c.wgsl.expected.msl
index e51d255..dce831f 100644
--- a/test/tint/builtins/gen/literal/sqrt/895a0c.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/sqrt/895a0c.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void sqrt_895a0c() {
- half3 res = sqrt(half3(1.0h));
+ half3 res = half3(1.0h);
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/sqrt/895a0c.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/sqrt/895a0c.wgsl.expected.spvasm
index 377745c..d525d58 100644
--- a/test/tint/builtins/gen/literal/sqrt/895a0c.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/sqrt/895a0c.wgsl.expected.spvasm
@@ -1,14 +1,13 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 36
+; Bound: 34
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability UniformAndStorageBuffer16BitAccess
OpCapability StorageBuffer16BitAccess
OpCapability StorageInputOutput16
- %16 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -38,37 +37,36 @@
%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
+ %16 = OpConstantComposite %v3half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0
%_ptr_Function_v3half = OpTypePointer Function %v3half
- %21 = OpConstantNull %v3half
- %22 = OpTypeFunction %v4float
+ %19 = OpConstantNull %v3half
+ %20 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
%sqrt_895a0c = OpFunction %void None %9
%12 = OpLabel
- %res = OpVariable %_ptr_Function_v3half Function %21
- %13 = OpExtInst %v3half %16 Sqrt %18
- OpStore %res %13
+ %res = OpVariable %_ptr_Function_v3half Function %19
+ OpStore %res %16
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %22
- %24 = OpLabel
- %25 = OpFunctionCall %void %sqrt_895a0c
+%vertex_main_inner = OpFunction %v4float None %20
+ %22 = OpLabel
+ %23 = OpFunctionCall %void %sqrt_895a0c
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
- %31 = OpLabel
- %32 = OpFunctionCall %void %sqrt_895a0c
+ %29 = OpLabel
+ %30 = OpFunctionCall %void %sqrt_895a0c
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %9
- %34 = OpLabel
- %35 = OpFunctionCall %void %sqrt_895a0c
+ %32 = OpLabel
+ %33 = OpFunctionCall %void %sqrt_895a0c
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/sqrt/8c7024.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/sqrt/8c7024.wgsl.expected.dxc.hlsl
index 0191d75..f7ee2ec 100644
--- a/test/tint/builtins/gen/literal/sqrt/8c7024.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/sqrt/8c7024.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
void sqrt_8c7024() {
- float2 res = sqrt((1.0f).xx);
+ float2 res = (1.0f).xx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/sqrt/8c7024.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/sqrt/8c7024.wgsl.expected.fxc.hlsl
index 0191d75..f7ee2ec 100644
--- a/test/tint/builtins/gen/literal/sqrt/8c7024.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/sqrt/8c7024.wgsl.expected.fxc.hlsl
@@ -1,5 +1,5 @@
void sqrt_8c7024() {
- float2 res = sqrt((1.0f).xx);
+ float2 res = (1.0f).xx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/sqrt/8c7024.wgsl.expected.glsl b/test/tint/builtins/gen/literal/sqrt/8c7024.wgsl.expected.glsl
index baa407b..e6cfb44 100644
--- a/test/tint/builtins/gen/literal/sqrt/8c7024.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/sqrt/8c7024.wgsl.expected.glsl
@@ -1,7 +1,7 @@
#version 310 es
void sqrt_8c7024() {
- vec2 res = sqrt(vec2(1.0f));
+ vec2 res = vec2(1.0f);
}
vec4 vertex_main() {
@@ -21,7 +21,7 @@
precision mediump float;
void sqrt_8c7024() {
- vec2 res = sqrt(vec2(1.0f));
+ vec2 res = vec2(1.0f);
}
void fragment_main() {
@@ -35,7 +35,7 @@
#version 310 es
void sqrt_8c7024() {
- vec2 res = sqrt(vec2(1.0f));
+ vec2 res = vec2(1.0f);
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/sqrt/8c7024.wgsl.expected.msl b/test/tint/builtins/gen/literal/sqrt/8c7024.wgsl.expected.msl
index b9dfbc4..16a4d33 100644
--- a/test/tint/builtins/gen/literal/sqrt/8c7024.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/sqrt/8c7024.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void sqrt_8c7024() {
- float2 res = sqrt(float2(1.0f));
+ float2 res = float2(1.0f);
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/sqrt/8c7024.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/sqrt/8c7024.wgsl.expected.spvasm
index ba7cdf4..5c1c9fa 100644
--- a/test/tint/builtins/gen/literal/sqrt/8c7024.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/sqrt/8c7024.wgsl.expected.spvasm
@@ -1,10 +1,9 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 34
+; Bound: 32
; Schema: 0
OpCapability Shader
- %15 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -33,36 +32,35 @@
%9 = OpTypeFunction %void
%v2float = OpTypeVector %float 2
%float_1 = OpConstant %float 1
- %17 = OpConstantComposite %v2float %float_1 %float_1
+ %15 = OpConstantComposite %v2float %float_1 %float_1
%_ptr_Function_v2float = OpTypePointer Function %v2float
- %20 = OpConstantNull %v2float
- %21 = OpTypeFunction %v4float
+ %18 = OpConstantNull %v2float
+ %19 = OpTypeFunction %v4float
%sqrt_8c7024 = OpFunction %void None %9
%12 = OpLabel
- %res = OpVariable %_ptr_Function_v2float Function %20
- %13 = OpExtInst %v2float %15 Sqrt %17
- OpStore %res %13
+ %res = OpVariable %_ptr_Function_v2float Function %18
+ OpStore %res %15
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %21
- %23 = OpLabel
- %24 = OpFunctionCall %void %sqrt_8c7024
+%vertex_main_inner = OpFunction %v4float None %19
+ %21 = OpLabel
+ %22 = OpFunctionCall %void %sqrt_8c7024
OpReturnValue %5
OpFunctionEnd
%vertex_main = OpFunction %void None %9
- %26 = OpLabel
- %27 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %27
+ %24 = OpLabel
+ %25 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %25
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
%fragment_main = OpFunction %void None %9
- %29 = OpLabel
- %30 = OpFunctionCall %void %sqrt_8c7024
+ %27 = OpLabel
+ %28 = OpFunctionCall %void %sqrt_8c7024
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %9
- %32 = OpLabel
- %33 = OpFunctionCall %void %sqrt_8c7024
+ %30 = OpLabel
+ %31 = OpFunctionCall %void %sqrt_8c7024
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/sqrt/8da177.wgsl b/test/tint/builtins/gen/literal/sqrt/8da177.wgsl
new file mode 100644
index 0000000..857eae5
--- /dev/null
+++ b/test/tint/builtins/gen/literal/sqrt/8da177.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 sqrt(fa) -> fa
+fn sqrt_8da177() {
+ var res = sqrt(1.);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ sqrt_8da177();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ sqrt_8da177();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ sqrt_8da177();
+}
diff --git a/test/tint/builtins/gen/literal/sqrt/8da177.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/sqrt/8da177.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..f9435c9
--- /dev/null
+++ b/test/tint/builtins/gen/literal/sqrt/8da177.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void sqrt_8da177() {
+ float res = 1.0f;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ sqrt_8da177();
+ 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() {
+ sqrt_8da177();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ sqrt_8da177();
+ return;
+}
diff --git a/test/tint/builtins/gen/literal/sqrt/8da177.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/sqrt/8da177.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..f9435c9
--- /dev/null
+++ b/test/tint/builtins/gen/literal/sqrt/8da177.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void sqrt_8da177() {
+ float res = 1.0f;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ sqrt_8da177();
+ 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() {
+ sqrt_8da177();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ sqrt_8da177();
+ return;
+}
diff --git a/test/tint/builtins/gen/literal/sqrt/8da177.wgsl.expected.glsl b/test/tint/builtins/gen/literal/sqrt/8da177.wgsl.expected.glsl
new file mode 100644
index 0000000..feec5e8
--- /dev/null
+++ b/test/tint/builtins/gen/literal/sqrt/8da177.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void sqrt_8da177() {
+ float res = 1.0f;
+}
+
+vec4 vertex_main() {
+ sqrt_8da177();
+ 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 sqrt_8da177() {
+ float res = 1.0f;
+}
+
+void fragment_main() {
+ sqrt_8da177();
+}
+
+void main() {
+ fragment_main();
+ return;
+}
+#version 310 es
+
+void sqrt_8da177() {
+ float res = 1.0f;
+}
+
+void compute_main() {
+ sqrt_8da177();
+}
+
+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/sqrt/8da177.wgsl.expected.msl b/test/tint/builtins/gen/literal/sqrt/8da177.wgsl.expected.msl
new file mode 100644
index 0000000..313093b
--- /dev/null
+++ b/test/tint/builtins/gen/literal/sqrt/8da177.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void sqrt_8da177() {
+ float res = 1.0f;
+}
+
+struct tint_symbol {
+ float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+ sqrt_8da177();
+ 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() {
+ sqrt_8da177();
+ return;
+}
+
+kernel void compute_main() {
+ sqrt_8da177();
+ return;
+}
+
diff --git a/test/tint/builtins/gen/literal/sqrt/8da177.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/sqrt/8da177.wgsl.expected.spvasm
new file mode 100644
index 0000000..3e52e33
--- /dev/null
+++ b/test/tint/builtins/gen/literal/sqrt/8da177.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 %sqrt_8da177 "sqrt_8da177"
+ 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
+ %float_1 = OpConstant %float 1
+%_ptr_Function_float = OpTypePointer Function %float
+ %16 = OpTypeFunction %v4float
+%sqrt_8da177 = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_float Function %8
+ OpStore %res %float_1
+ OpReturn
+ OpFunctionEnd
+%vertex_main_inner = OpFunction %v4float None %16
+ %18 = OpLabel
+ %19 = OpFunctionCall %void %sqrt_8da177
+ OpReturnValue %5
+ OpFunctionEnd
+%vertex_main = OpFunction %void None %9
+ %21 = OpLabel
+ %22 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %22
+ OpStore %vertex_point_size %float_1
+ OpReturn
+ OpFunctionEnd
+%fragment_main = OpFunction %void None %9
+ %24 = OpLabel
+ %25 = OpFunctionCall %void %sqrt_8da177
+ OpReturn
+ OpFunctionEnd
+%compute_main = OpFunction %void None %9
+ %27 = OpLabel
+ %28 = OpFunctionCall %void %sqrt_8da177
+ OpReturn
+ OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/sqrt/8da177.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/sqrt/8da177.wgsl.expected.wgsl
new file mode 100644
index 0000000..8a0d070
--- /dev/null
+++ b/test/tint/builtins/gen/literal/sqrt/8da177.wgsl.expected.wgsl
@@ -0,0 +1,19 @@
+fn sqrt_8da177() {
+ var res = sqrt(1.0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ sqrt_8da177();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ sqrt_8da177();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ sqrt_8da177();
+}
diff --git a/test/tint/builtins/gen/literal/sqrt/9c5cbe.wgsl b/test/tint/builtins/gen/literal/sqrt/9c5cbe.wgsl
new file mode 100644
index 0000000..c45b389
--- /dev/null
+++ b/test/tint/builtins/gen/literal/sqrt/9c5cbe.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 sqrt(vec<2, fa>) -> vec<2, fa>
+fn sqrt_9c5cbe() {
+ var res = sqrt(vec2(1.));
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ sqrt_9c5cbe();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ sqrt_9c5cbe();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ sqrt_9c5cbe();
+}
diff --git a/test/tint/builtins/gen/literal/sqrt/9c5cbe.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/sqrt/9c5cbe.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..c0053e0
--- /dev/null
+++ b/test/tint/builtins/gen/literal/sqrt/9c5cbe.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void sqrt_9c5cbe() {
+ float2 res = (1.0f).xx;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ sqrt_9c5cbe();
+ 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() {
+ sqrt_9c5cbe();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ sqrt_9c5cbe();
+ return;
+}
diff --git a/test/tint/builtins/gen/literal/sqrt/9c5cbe.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/sqrt/9c5cbe.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..c0053e0
--- /dev/null
+++ b/test/tint/builtins/gen/literal/sqrt/9c5cbe.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void sqrt_9c5cbe() {
+ float2 res = (1.0f).xx;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ sqrt_9c5cbe();
+ 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() {
+ sqrt_9c5cbe();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ sqrt_9c5cbe();
+ return;
+}
diff --git a/test/tint/builtins/gen/literal/sqrt/9c5cbe.wgsl.expected.glsl b/test/tint/builtins/gen/literal/sqrt/9c5cbe.wgsl.expected.glsl
new file mode 100644
index 0000000..c6f1427
--- /dev/null
+++ b/test/tint/builtins/gen/literal/sqrt/9c5cbe.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void sqrt_9c5cbe() {
+ vec2 res = vec2(1.0f);
+}
+
+vec4 vertex_main() {
+ sqrt_9c5cbe();
+ 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 sqrt_9c5cbe() {
+ vec2 res = vec2(1.0f);
+}
+
+void fragment_main() {
+ sqrt_9c5cbe();
+}
+
+void main() {
+ fragment_main();
+ return;
+}
+#version 310 es
+
+void sqrt_9c5cbe() {
+ vec2 res = vec2(1.0f);
+}
+
+void compute_main() {
+ sqrt_9c5cbe();
+}
+
+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/sqrt/9c5cbe.wgsl.expected.msl b/test/tint/builtins/gen/literal/sqrt/9c5cbe.wgsl.expected.msl
new file mode 100644
index 0000000..c1866c8
--- /dev/null
+++ b/test/tint/builtins/gen/literal/sqrt/9c5cbe.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void sqrt_9c5cbe() {
+ float2 res = float2(1.0f);
+}
+
+struct tint_symbol {
+ float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+ sqrt_9c5cbe();
+ 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() {
+ sqrt_9c5cbe();
+ return;
+}
+
+kernel void compute_main() {
+ sqrt_9c5cbe();
+ return;
+}
+
diff --git a/test/tint/builtins/gen/literal/sqrt/9c5cbe.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/sqrt/9c5cbe.wgsl.expected.spvasm
new file mode 100644
index 0000000..feffb50
--- /dev/null
+++ b/test/tint/builtins/gen/literal/sqrt/9c5cbe.wgsl.expected.spvasm
@@ -0,0 +1,66 @@
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 0
+; Bound: 32
+; 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 %sqrt_9c5cbe "sqrt_9c5cbe"
+ 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
+ %v2float = OpTypeVector %float 2
+ %float_1 = OpConstant %float 1
+ %15 = OpConstantComposite %v2float %float_1 %float_1
+%_ptr_Function_v2float = OpTypePointer Function %v2float
+ %18 = OpConstantNull %v2float
+ %19 = OpTypeFunction %v4float
+%sqrt_9c5cbe = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_v2float Function %18
+ OpStore %res %15
+ OpReturn
+ OpFunctionEnd
+%vertex_main_inner = OpFunction %v4float None %19
+ %21 = OpLabel
+ %22 = OpFunctionCall %void %sqrt_9c5cbe
+ OpReturnValue %5
+ OpFunctionEnd
+%vertex_main = OpFunction %void None %9
+ %24 = OpLabel
+ %25 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %25
+ OpStore %vertex_point_size %float_1
+ OpReturn
+ OpFunctionEnd
+%fragment_main = OpFunction %void None %9
+ %27 = OpLabel
+ %28 = OpFunctionCall %void %sqrt_9c5cbe
+ OpReturn
+ OpFunctionEnd
+%compute_main = OpFunction %void None %9
+ %30 = OpLabel
+ %31 = OpFunctionCall %void %sqrt_9c5cbe
+ OpReturn
+ OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/sqrt/9c5cbe.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/sqrt/9c5cbe.wgsl.expected.wgsl
new file mode 100644
index 0000000..26ca006
--- /dev/null
+++ b/test/tint/builtins/gen/literal/sqrt/9c5cbe.wgsl.expected.wgsl
@@ -0,0 +1,19 @@
+fn sqrt_9c5cbe() {
+ var res = sqrt(vec2(1.0));
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ sqrt_9c5cbe();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ sqrt_9c5cbe();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ sqrt_9c5cbe();
+}
diff --git a/test/tint/builtins/gen/literal/sqrt/aa0d7a.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/sqrt/aa0d7a.wgsl.expected.dxc.hlsl
index 776d0d4..e4d8702 100644
--- a/test/tint/builtins/gen/literal/sqrt/aa0d7a.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/sqrt/aa0d7a.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
void sqrt_aa0d7a() {
- float4 res = sqrt((1.0f).xxxx);
+ float4 res = (1.0f).xxxx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/sqrt/aa0d7a.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/sqrt/aa0d7a.wgsl.expected.fxc.hlsl
index 776d0d4..e4d8702 100644
--- a/test/tint/builtins/gen/literal/sqrt/aa0d7a.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/sqrt/aa0d7a.wgsl.expected.fxc.hlsl
@@ -1,5 +1,5 @@
void sqrt_aa0d7a() {
- float4 res = sqrt((1.0f).xxxx);
+ float4 res = (1.0f).xxxx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/sqrt/aa0d7a.wgsl.expected.glsl b/test/tint/builtins/gen/literal/sqrt/aa0d7a.wgsl.expected.glsl
index d96dc6c..dad6999 100644
--- a/test/tint/builtins/gen/literal/sqrt/aa0d7a.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/sqrt/aa0d7a.wgsl.expected.glsl
@@ -1,7 +1,7 @@
#version 310 es
void sqrt_aa0d7a() {
- vec4 res = sqrt(vec4(1.0f));
+ vec4 res = vec4(1.0f);
}
vec4 vertex_main() {
@@ -21,7 +21,7 @@
precision mediump float;
void sqrt_aa0d7a() {
- vec4 res = sqrt(vec4(1.0f));
+ vec4 res = vec4(1.0f);
}
void fragment_main() {
@@ -35,7 +35,7 @@
#version 310 es
void sqrt_aa0d7a() {
- vec4 res = sqrt(vec4(1.0f));
+ vec4 res = vec4(1.0f);
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/sqrt/aa0d7a.wgsl.expected.msl b/test/tint/builtins/gen/literal/sqrt/aa0d7a.wgsl.expected.msl
index 13a62e1..da314c5 100644
--- a/test/tint/builtins/gen/literal/sqrt/aa0d7a.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/sqrt/aa0d7a.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void sqrt_aa0d7a() {
- float4 res = sqrt(float4(1.0f));
+ float4 res = float4(1.0f);
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/sqrt/aa0d7a.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/sqrt/aa0d7a.wgsl.expected.spvasm
index da8c047..bb14df4 100644
--- a/test/tint/builtins/gen/literal/sqrt/aa0d7a.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/sqrt/aa0d7a.wgsl.expected.spvasm
@@ -1,10 +1,9 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 32
+; Bound: 30
; 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"
@@ -32,35 +31,34 @@
%void = OpTypeVoid
%9 = OpTypeFunction %void
%float_1 = OpConstant %float 1
- %16 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
+ %14 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
%_ptr_Function_v4float = OpTypePointer Function %v4float
- %19 = OpTypeFunction %v4float
+ %17 = OpTypeFunction %v4float
%sqrt_aa0d7a = OpFunction %void None %9
%12 = OpLabel
%res = OpVariable %_ptr_Function_v4float Function %5
- %13 = OpExtInst %v4float %14 Sqrt %16
- OpStore %res %13
+ OpStore %res %14
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %19
- %21 = OpLabel
- %22 = OpFunctionCall %void %sqrt_aa0d7a
+%vertex_main_inner = OpFunction %v4float None %17
+ %19 = OpLabel
+ %20 = OpFunctionCall %void %sqrt_aa0d7a
OpReturnValue %5
OpFunctionEnd
%vertex_main = OpFunction %void None %9
- %24 = OpLabel
- %25 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %25
+ %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
- %27 = OpLabel
- %28 = OpFunctionCall %void %sqrt_aa0d7a
+ %25 = OpLabel
+ %26 = OpFunctionCall %void %sqrt_aa0d7a
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %9
- %30 = OpLabel
- %31 = OpFunctionCall %void %sqrt_aa0d7a
+ %28 = OpLabel
+ %29 = OpFunctionCall %void %sqrt_aa0d7a
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/sqrt/d9ab4d.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/sqrt/d9ab4d.wgsl.expected.dxc.hlsl
index a31a43c..c1609d5 100644
--- a/test/tint/builtins/gen/literal/sqrt/d9ab4d.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/sqrt/d9ab4d.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
void sqrt_d9ab4d() {
- vector<float16_t, 2> res = sqrt((float16_t(1.0h)).xx);
+ vector<float16_t, 2> res = (float16_t(1.0h)).xx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/sqrt/d9ab4d.wgsl.expected.glsl b/test/tint/builtins/gen/literal/sqrt/d9ab4d.wgsl.expected.glsl
index d31df4c..963379e 100644
--- a/test/tint/builtins/gen/literal/sqrt/d9ab4d.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/sqrt/d9ab4d.wgsl.expected.glsl
@@ -2,7 +2,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void sqrt_d9ab4d() {
- f16vec2 res = sqrt(f16vec2(1.0hf));
+ f16vec2 res = f16vec2(1.0hf);
}
vec4 vertex_main() {
@@ -23,7 +23,7 @@
precision mediump float;
void sqrt_d9ab4d() {
- f16vec2 res = sqrt(f16vec2(1.0hf));
+ f16vec2 res = f16vec2(1.0hf);
}
void fragment_main() {
@@ -38,7 +38,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void sqrt_d9ab4d() {
- f16vec2 res = sqrt(f16vec2(1.0hf));
+ f16vec2 res = f16vec2(1.0hf);
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/sqrt/d9ab4d.wgsl.expected.msl b/test/tint/builtins/gen/literal/sqrt/d9ab4d.wgsl.expected.msl
index acc30f2..4e15166 100644
--- a/test/tint/builtins/gen/literal/sqrt/d9ab4d.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/sqrt/d9ab4d.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void sqrt_d9ab4d() {
- half2 res = sqrt(half2(1.0h));
+ half2 res = half2(1.0h);
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/sqrt/d9ab4d.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/sqrt/d9ab4d.wgsl.expected.spvasm
index f186c13..ff075ce 100644
--- a/test/tint/builtins/gen/literal/sqrt/d9ab4d.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/sqrt/d9ab4d.wgsl.expected.spvasm
@@ -1,14 +1,13 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 36
+; Bound: 34
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability UniformAndStorageBuffer16BitAccess
OpCapability StorageBuffer16BitAccess
OpCapability StorageInputOutput16
- %16 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -38,37 +37,36 @@
%half = OpTypeFloat 16
%v2half = OpTypeVector %half 2
%half_0x1p_0 = OpConstant %half 0x1p+0
- %18 = OpConstantComposite %v2half %half_0x1p_0 %half_0x1p_0
+ %16 = OpConstantComposite %v2half %half_0x1p_0 %half_0x1p_0
%_ptr_Function_v2half = OpTypePointer Function %v2half
- %21 = OpConstantNull %v2half
- %22 = OpTypeFunction %v4float
+ %19 = OpConstantNull %v2half
+ %20 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
%sqrt_d9ab4d = OpFunction %void None %9
%12 = OpLabel
- %res = OpVariable %_ptr_Function_v2half Function %21
- %13 = OpExtInst %v2half %16 Sqrt %18
- OpStore %res %13
+ %res = OpVariable %_ptr_Function_v2half Function %19
+ OpStore %res %16
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %22
- %24 = OpLabel
- %25 = OpFunctionCall %void %sqrt_d9ab4d
+%vertex_main_inner = OpFunction %v4float None %20
+ %22 = OpLabel
+ %23 = OpFunctionCall %void %sqrt_d9ab4d
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
- %31 = OpLabel
- %32 = OpFunctionCall %void %sqrt_d9ab4d
+ %29 = OpLabel
+ %30 = OpFunctionCall %void %sqrt_d9ab4d
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %9
- %34 = OpLabel
- %35 = OpFunctionCall %void %sqrt_d9ab4d
+ %32 = OpLabel
+ %33 = OpFunctionCall %void %sqrt_d9ab4d
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/sqrt/ec33e9.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/sqrt/ec33e9.wgsl.expected.dxc.hlsl
index bc3797b..23939d5 100644
--- a/test/tint/builtins/gen/literal/sqrt/ec33e9.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/sqrt/ec33e9.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
void sqrt_ec33e9() {
- float16_t res = sqrt(float16_t(1.0h));
+ float16_t res = float16_t(1.0h);
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/sqrt/ec33e9.wgsl.expected.glsl b/test/tint/builtins/gen/literal/sqrt/ec33e9.wgsl.expected.glsl
index d08c0af..4245551 100644
--- a/test/tint/builtins/gen/literal/sqrt/ec33e9.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/sqrt/ec33e9.wgsl.expected.glsl
@@ -2,7 +2,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void sqrt_ec33e9() {
- float16_t res = sqrt(1.0hf);
+ float16_t res = 1.0hf;
}
vec4 vertex_main() {
@@ -23,7 +23,7 @@
precision mediump float;
void sqrt_ec33e9() {
- float16_t res = sqrt(1.0hf);
+ float16_t res = 1.0hf;
}
void fragment_main() {
@@ -38,7 +38,7 @@
#extension GL_AMD_gpu_shader_half_float : require
void sqrt_ec33e9() {
- float16_t res = sqrt(1.0hf);
+ float16_t res = 1.0hf;
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/sqrt/ec33e9.wgsl.expected.msl b/test/tint/builtins/gen/literal/sqrt/ec33e9.wgsl.expected.msl
index cdf9675..a3d8e32 100644
--- a/test/tint/builtins/gen/literal/sqrt/ec33e9.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/sqrt/ec33e9.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void sqrt_ec33e9() {
- half res = sqrt(1.0h);
+ half res = 1.0h;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/sqrt/ec33e9.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/sqrt/ec33e9.wgsl.expected.spvasm
index 06634a2..9bf7a91 100644
--- a/test/tint/builtins/gen/literal/sqrt/ec33e9.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/sqrt/ec33e9.wgsl.expected.spvasm
@@ -1,14 +1,13 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 34
+; Bound: 32
; 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"
@@ -38,35 +37,34 @@
%half = OpTypeFloat 16
%half_0x1p_0 = OpConstant %half 0x1p+0
%_ptr_Function_half = OpTypePointer Function %half
- %19 = OpConstantNull %half
- %20 = OpTypeFunction %v4float
+ %17 = OpConstantNull %half
+ %18 = OpTypeFunction %v4float
%float_1 = OpConstant %float 1
%sqrt_ec33e9 = OpFunction %void None %9
%12 = OpLabel
- %res = OpVariable %_ptr_Function_half Function %19
- %13 = OpExtInst %half %15 Sqrt %half_0x1p_0
- OpStore %res %13
+ %res = OpVariable %_ptr_Function_half Function %17
+ OpStore %res %half_0x1p_0
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %20
- %22 = OpLabel
- %23 = OpFunctionCall %void %sqrt_ec33e9
+%vertex_main_inner = OpFunction %v4float None %18
+ %20 = OpLabel
+ %21 = OpFunctionCall %void %sqrt_ec33e9
OpReturnValue %5
OpFunctionEnd
%vertex_main = OpFunction %void None %9
- %25 = OpLabel
- %26 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %26
+ %23 = OpLabel
+ %24 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %24
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
%fragment_main = OpFunction %void None %9
- %29 = OpLabel
- %30 = OpFunctionCall %void %sqrt_ec33e9
+ %27 = OpLabel
+ %28 = OpFunctionCall %void %sqrt_ec33e9
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %9
- %32 = OpLabel
- %33 = OpFunctionCall %void %sqrt_ec33e9
+ %30 = OpLabel
+ %31 = OpFunctionCall %void %sqrt_ec33e9
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/sqrt/f8c59a.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/sqrt/f8c59a.wgsl.expected.dxc.hlsl
index e0c1921..a572ca5 100644
--- a/test/tint/builtins/gen/literal/sqrt/f8c59a.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/sqrt/f8c59a.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
void sqrt_f8c59a() {
- float3 res = sqrt((1.0f).xxx);
+ float3 res = (1.0f).xxx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/sqrt/f8c59a.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/sqrt/f8c59a.wgsl.expected.fxc.hlsl
index e0c1921..a572ca5 100644
--- a/test/tint/builtins/gen/literal/sqrt/f8c59a.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/sqrt/f8c59a.wgsl.expected.fxc.hlsl
@@ -1,5 +1,5 @@
void sqrt_f8c59a() {
- float3 res = sqrt((1.0f).xxx);
+ float3 res = (1.0f).xxx;
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/sqrt/f8c59a.wgsl.expected.glsl b/test/tint/builtins/gen/literal/sqrt/f8c59a.wgsl.expected.glsl
index 9d05843..fa397f3 100644
--- a/test/tint/builtins/gen/literal/sqrt/f8c59a.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/sqrt/f8c59a.wgsl.expected.glsl
@@ -1,7 +1,7 @@
#version 310 es
void sqrt_f8c59a() {
- vec3 res = sqrt(vec3(1.0f));
+ vec3 res = vec3(1.0f);
}
vec4 vertex_main() {
@@ -21,7 +21,7 @@
precision mediump float;
void sqrt_f8c59a() {
- vec3 res = sqrt(vec3(1.0f));
+ vec3 res = vec3(1.0f);
}
void fragment_main() {
@@ -35,7 +35,7 @@
#version 310 es
void sqrt_f8c59a() {
- vec3 res = sqrt(vec3(1.0f));
+ vec3 res = vec3(1.0f);
}
void compute_main() {
diff --git a/test/tint/builtins/gen/literal/sqrt/f8c59a.wgsl.expected.msl b/test/tint/builtins/gen/literal/sqrt/f8c59a.wgsl.expected.msl
index d79e601..1e77ab0 100644
--- a/test/tint/builtins/gen/literal/sqrt/f8c59a.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/sqrt/f8c59a.wgsl.expected.msl
@@ -2,7 +2,7 @@
using namespace metal;
void sqrt_f8c59a() {
- float3 res = sqrt(float3(1.0f));
+ float3 res = float3(1.0f);
}
struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/sqrt/f8c59a.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/sqrt/f8c59a.wgsl.expected.spvasm
index fdc4f9a..448b3f6 100644
--- a/test/tint/builtins/gen/literal/sqrt/f8c59a.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/sqrt/f8c59a.wgsl.expected.spvasm
@@ -1,10 +1,9 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 34
+; Bound: 32
; Schema: 0
OpCapability Shader
- %15 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -33,36 +32,35 @@
%9 = OpTypeFunction %void
%v3float = OpTypeVector %float 3
%float_1 = OpConstant %float 1
- %17 = OpConstantComposite %v3float %float_1 %float_1 %float_1
+ %15 = OpConstantComposite %v3float %float_1 %float_1 %float_1
%_ptr_Function_v3float = OpTypePointer Function %v3float
- %20 = OpConstantNull %v3float
- %21 = OpTypeFunction %v4float
+ %18 = OpConstantNull %v3float
+ %19 = OpTypeFunction %v4float
%sqrt_f8c59a = OpFunction %void None %9
%12 = OpLabel
- %res = OpVariable %_ptr_Function_v3float Function %20
- %13 = OpExtInst %v3float %15 Sqrt %17
- OpStore %res %13
+ %res = OpVariable %_ptr_Function_v3float Function %18
+ OpStore %res %15
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %21
- %23 = OpLabel
- %24 = OpFunctionCall %void %sqrt_f8c59a
+%vertex_main_inner = OpFunction %v4float None %19
+ %21 = OpLabel
+ %22 = OpFunctionCall %void %sqrt_f8c59a
OpReturnValue %5
OpFunctionEnd
%vertex_main = OpFunction %void None %9
- %26 = OpLabel
- %27 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %27
+ %24 = OpLabel
+ %25 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %25
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
%fragment_main = OpFunction %void None %9
- %29 = OpLabel
- %30 = OpFunctionCall %void %sqrt_f8c59a
+ %27 = OpLabel
+ %28 = OpFunctionCall %void %sqrt_f8c59a
OpReturn
OpFunctionEnd
%compute_main = OpFunction %void None %9
- %32 = OpLabel
- %33 = OpFunctionCall %void %sqrt_f8c59a
+ %30 = OpLabel
+ %31 = OpFunctionCall %void %sqrt_f8c59a
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/sqrt/072192.wgsl b/test/tint/builtins/gen/var/sqrt/072192.wgsl
new file mode 100644
index 0000000..9eeed91
--- /dev/null
+++ b/test/tint/builtins/gen/var/sqrt/072192.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 sqrt(vec<3, fa>) -> vec<3, fa>
+fn sqrt_072192() {
+ const arg_0 = vec3(1.);
+ var res = sqrt(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ sqrt_072192();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ sqrt_072192();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ sqrt_072192();
+}
diff --git a/test/tint/builtins/gen/var/sqrt/072192.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/sqrt/072192.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..eb05088
--- /dev/null
+++ b/test/tint/builtins/gen/var/sqrt/072192.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void sqrt_072192() {
+ float3 res = (1.0f).xxx;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ sqrt_072192();
+ 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() {
+ sqrt_072192();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ sqrt_072192();
+ return;
+}
diff --git a/test/tint/builtins/gen/var/sqrt/072192.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/sqrt/072192.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..eb05088
--- /dev/null
+++ b/test/tint/builtins/gen/var/sqrt/072192.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void sqrt_072192() {
+ float3 res = (1.0f).xxx;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ sqrt_072192();
+ 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() {
+ sqrt_072192();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ sqrt_072192();
+ return;
+}
diff --git a/test/tint/builtins/gen/var/sqrt/072192.wgsl.expected.glsl b/test/tint/builtins/gen/var/sqrt/072192.wgsl.expected.glsl
new file mode 100644
index 0000000..910819a
--- /dev/null
+++ b/test/tint/builtins/gen/var/sqrt/072192.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void sqrt_072192() {
+ vec3 res = vec3(1.0f);
+}
+
+vec4 vertex_main() {
+ sqrt_072192();
+ 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 sqrt_072192() {
+ vec3 res = vec3(1.0f);
+}
+
+void fragment_main() {
+ sqrt_072192();
+}
+
+void main() {
+ fragment_main();
+ return;
+}
+#version 310 es
+
+void sqrt_072192() {
+ vec3 res = vec3(1.0f);
+}
+
+void compute_main() {
+ sqrt_072192();
+}
+
+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/sqrt/072192.wgsl.expected.msl b/test/tint/builtins/gen/var/sqrt/072192.wgsl.expected.msl
new file mode 100644
index 0000000..aa1da7b
--- /dev/null
+++ b/test/tint/builtins/gen/var/sqrt/072192.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void sqrt_072192() {
+ float3 res = float3(1.0f);
+}
+
+struct tint_symbol {
+ float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+ sqrt_072192();
+ 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() {
+ sqrt_072192();
+ return;
+}
+
+kernel void compute_main() {
+ sqrt_072192();
+ return;
+}
+
diff --git a/test/tint/builtins/gen/var/sqrt/072192.wgsl.expected.spvasm b/test/tint/builtins/gen/var/sqrt/072192.wgsl.expected.spvasm
new file mode 100644
index 0000000..a54c8a7
--- /dev/null
+++ b/test/tint/builtins/gen/var/sqrt/072192.wgsl.expected.spvasm
@@ -0,0 +1,66 @@
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 0
+; Bound: 32
+; 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 %sqrt_072192 "sqrt_072192"
+ 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
+ %v3float = OpTypeVector %float 3
+ %float_1 = OpConstant %float 1
+ %15 = OpConstantComposite %v3float %float_1 %float_1 %float_1
+%_ptr_Function_v3float = OpTypePointer Function %v3float
+ %18 = OpConstantNull %v3float
+ %19 = OpTypeFunction %v4float
+%sqrt_072192 = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_v3float Function %18
+ OpStore %res %15
+ OpReturn
+ OpFunctionEnd
+%vertex_main_inner = OpFunction %v4float None %19
+ %21 = OpLabel
+ %22 = OpFunctionCall %void %sqrt_072192
+ OpReturnValue %5
+ OpFunctionEnd
+%vertex_main = OpFunction %void None %9
+ %24 = OpLabel
+ %25 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %25
+ OpStore %vertex_point_size %float_1
+ OpReturn
+ OpFunctionEnd
+%fragment_main = OpFunction %void None %9
+ %27 = OpLabel
+ %28 = OpFunctionCall %void %sqrt_072192
+ OpReturn
+ OpFunctionEnd
+%compute_main = OpFunction %void None %9
+ %30 = OpLabel
+ %31 = OpFunctionCall %void %sqrt_072192
+ OpReturn
+ OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/sqrt/072192.wgsl.expected.wgsl b/test/tint/builtins/gen/var/sqrt/072192.wgsl.expected.wgsl
new file mode 100644
index 0000000..19b63e7
--- /dev/null
+++ b/test/tint/builtins/gen/var/sqrt/072192.wgsl.expected.wgsl
@@ -0,0 +1,20 @@
+fn sqrt_072192() {
+ const arg_0 = vec3(1.0);
+ var res = sqrt(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ sqrt_072192();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ sqrt_072192();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ sqrt_072192();
+}
diff --git a/test/tint/builtins/gen/var/sqrt/4ac2c5.wgsl b/test/tint/builtins/gen/var/sqrt/4ac2c5.wgsl
new file mode 100644
index 0000000..8f13124
--- /dev/null
+++ b/test/tint/builtins/gen/var/sqrt/4ac2c5.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 sqrt(vec<4, fa>) -> vec<4, fa>
+fn sqrt_4ac2c5() {
+ const arg_0 = vec4(1.);
+ var res = sqrt(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ sqrt_4ac2c5();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ sqrt_4ac2c5();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ sqrt_4ac2c5();
+}
diff --git a/test/tint/builtins/gen/var/sqrt/4ac2c5.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/sqrt/4ac2c5.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..4e62875
--- /dev/null
+++ b/test/tint/builtins/gen/var/sqrt/4ac2c5.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void sqrt_4ac2c5() {
+ float4 res = (1.0f).xxxx;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ sqrt_4ac2c5();
+ 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() {
+ sqrt_4ac2c5();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ sqrt_4ac2c5();
+ return;
+}
diff --git a/test/tint/builtins/gen/var/sqrt/4ac2c5.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/sqrt/4ac2c5.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..4e62875
--- /dev/null
+++ b/test/tint/builtins/gen/var/sqrt/4ac2c5.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void sqrt_4ac2c5() {
+ float4 res = (1.0f).xxxx;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ sqrt_4ac2c5();
+ 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() {
+ sqrt_4ac2c5();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ sqrt_4ac2c5();
+ return;
+}
diff --git a/test/tint/builtins/gen/var/sqrt/4ac2c5.wgsl.expected.glsl b/test/tint/builtins/gen/var/sqrt/4ac2c5.wgsl.expected.glsl
new file mode 100644
index 0000000..ee4417e
--- /dev/null
+++ b/test/tint/builtins/gen/var/sqrt/4ac2c5.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void sqrt_4ac2c5() {
+ vec4 res = vec4(1.0f);
+}
+
+vec4 vertex_main() {
+ sqrt_4ac2c5();
+ 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 sqrt_4ac2c5() {
+ vec4 res = vec4(1.0f);
+}
+
+void fragment_main() {
+ sqrt_4ac2c5();
+}
+
+void main() {
+ fragment_main();
+ return;
+}
+#version 310 es
+
+void sqrt_4ac2c5() {
+ vec4 res = vec4(1.0f);
+}
+
+void compute_main() {
+ sqrt_4ac2c5();
+}
+
+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/sqrt/4ac2c5.wgsl.expected.msl b/test/tint/builtins/gen/var/sqrt/4ac2c5.wgsl.expected.msl
new file mode 100644
index 0000000..5e02b2e
--- /dev/null
+++ b/test/tint/builtins/gen/var/sqrt/4ac2c5.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void sqrt_4ac2c5() {
+ float4 res = float4(1.0f);
+}
+
+struct tint_symbol {
+ float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+ sqrt_4ac2c5();
+ 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() {
+ sqrt_4ac2c5();
+ return;
+}
+
+kernel void compute_main() {
+ sqrt_4ac2c5();
+ return;
+}
+
diff --git a/test/tint/builtins/gen/var/sqrt/4ac2c5.wgsl.expected.spvasm b/test/tint/builtins/gen/var/sqrt/4ac2c5.wgsl.expected.spvasm
new file mode 100644
index 0000000..57ed3a3
--- /dev/null
+++ b/test/tint/builtins/gen/var/sqrt/4ac2c5.wgsl.expected.spvasm
@@ -0,0 +1,64 @@
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 0
+; Bound: 30
+; 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 %sqrt_4ac2c5 "sqrt_4ac2c5"
+ 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
+ %float_1 = OpConstant %float 1
+ %14 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
+%_ptr_Function_v4float = OpTypePointer Function %v4float
+ %17 = OpTypeFunction %v4float
+%sqrt_4ac2c5 = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_v4float Function %5
+ OpStore %res %14
+ OpReturn
+ OpFunctionEnd
+%vertex_main_inner = OpFunction %v4float None %17
+ %19 = OpLabel
+ %20 = OpFunctionCall %void %sqrt_4ac2c5
+ OpReturnValue %5
+ OpFunctionEnd
+%vertex_main = OpFunction %void None %9
+ %22 = OpLabel
+ %23 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %23
+ OpStore %vertex_point_size %float_1
+ OpReturn
+ OpFunctionEnd
+%fragment_main = OpFunction %void None %9
+ %25 = OpLabel
+ %26 = OpFunctionCall %void %sqrt_4ac2c5
+ OpReturn
+ OpFunctionEnd
+%compute_main = OpFunction %void None %9
+ %28 = OpLabel
+ %29 = OpFunctionCall %void %sqrt_4ac2c5
+ OpReturn
+ OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/sqrt/4ac2c5.wgsl.expected.wgsl b/test/tint/builtins/gen/var/sqrt/4ac2c5.wgsl.expected.wgsl
new file mode 100644
index 0000000..ce2d5d5
--- /dev/null
+++ b/test/tint/builtins/gen/var/sqrt/4ac2c5.wgsl.expected.wgsl
@@ -0,0 +1,20 @@
+fn sqrt_4ac2c5() {
+ const arg_0 = vec4(1.0);
+ var res = sqrt(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ sqrt_4ac2c5();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ sqrt_4ac2c5();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ sqrt_4ac2c5();
+}
diff --git a/test/tint/builtins/gen/var/sqrt/8da177.wgsl b/test/tint/builtins/gen/var/sqrt/8da177.wgsl
new file mode 100644
index 0000000..57219bb
--- /dev/null
+++ b/test/tint/builtins/gen/var/sqrt/8da177.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 sqrt(fa) -> fa
+fn sqrt_8da177() {
+ const arg_0 = 1.;
+ var res = sqrt(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ sqrt_8da177();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ sqrt_8da177();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ sqrt_8da177();
+}
diff --git a/test/tint/builtins/gen/var/sqrt/8da177.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/sqrt/8da177.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..f9435c9
--- /dev/null
+++ b/test/tint/builtins/gen/var/sqrt/8da177.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void sqrt_8da177() {
+ float res = 1.0f;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ sqrt_8da177();
+ 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() {
+ sqrt_8da177();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ sqrt_8da177();
+ return;
+}
diff --git a/test/tint/builtins/gen/var/sqrt/8da177.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/sqrt/8da177.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..f9435c9
--- /dev/null
+++ b/test/tint/builtins/gen/var/sqrt/8da177.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void sqrt_8da177() {
+ float res = 1.0f;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ sqrt_8da177();
+ 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() {
+ sqrt_8da177();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ sqrt_8da177();
+ return;
+}
diff --git a/test/tint/builtins/gen/var/sqrt/8da177.wgsl.expected.glsl b/test/tint/builtins/gen/var/sqrt/8da177.wgsl.expected.glsl
new file mode 100644
index 0000000..feec5e8
--- /dev/null
+++ b/test/tint/builtins/gen/var/sqrt/8da177.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void sqrt_8da177() {
+ float res = 1.0f;
+}
+
+vec4 vertex_main() {
+ sqrt_8da177();
+ 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 sqrt_8da177() {
+ float res = 1.0f;
+}
+
+void fragment_main() {
+ sqrt_8da177();
+}
+
+void main() {
+ fragment_main();
+ return;
+}
+#version 310 es
+
+void sqrt_8da177() {
+ float res = 1.0f;
+}
+
+void compute_main() {
+ sqrt_8da177();
+}
+
+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/sqrt/8da177.wgsl.expected.msl b/test/tint/builtins/gen/var/sqrt/8da177.wgsl.expected.msl
new file mode 100644
index 0000000..313093b
--- /dev/null
+++ b/test/tint/builtins/gen/var/sqrt/8da177.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void sqrt_8da177() {
+ float res = 1.0f;
+}
+
+struct tint_symbol {
+ float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+ sqrt_8da177();
+ 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() {
+ sqrt_8da177();
+ return;
+}
+
+kernel void compute_main() {
+ sqrt_8da177();
+ return;
+}
+
diff --git a/test/tint/builtins/gen/var/sqrt/8da177.wgsl.expected.spvasm b/test/tint/builtins/gen/var/sqrt/8da177.wgsl.expected.spvasm
new file mode 100644
index 0000000..3e52e33
--- /dev/null
+++ b/test/tint/builtins/gen/var/sqrt/8da177.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 %sqrt_8da177 "sqrt_8da177"
+ 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
+ %float_1 = OpConstant %float 1
+%_ptr_Function_float = OpTypePointer Function %float
+ %16 = OpTypeFunction %v4float
+%sqrt_8da177 = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_float Function %8
+ OpStore %res %float_1
+ OpReturn
+ OpFunctionEnd
+%vertex_main_inner = OpFunction %v4float None %16
+ %18 = OpLabel
+ %19 = OpFunctionCall %void %sqrt_8da177
+ OpReturnValue %5
+ OpFunctionEnd
+%vertex_main = OpFunction %void None %9
+ %21 = OpLabel
+ %22 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %22
+ OpStore %vertex_point_size %float_1
+ OpReturn
+ OpFunctionEnd
+%fragment_main = OpFunction %void None %9
+ %24 = OpLabel
+ %25 = OpFunctionCall %void %sqrt_8da177
+ OpReturn
+ OpFunctionEnd
+%compute_main = OpFunction %void None %9
+ %27 = OpLabel
+ %28 = OpFunctionCall %void %sqrt_8da177
+ OpReturn
+ OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/sqrt/8da177.wgsl.expected.wgsl b/test/tint/builtins/gen/var/sqrt/8da177.wgsl.expected.wgsl
new file mode 100644
index 0000000..efab11d
--- /dev/null
+++ b/test/tint/builtins/gen/var/sqrt/8da177.wgsl.expected.wgsl
@@ -0,0 +1,20 @@
+fn sqrt_8da177() {
+ const arg_0 = 1.0;
+ var res = sqrt(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ sqrt_8da177();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ sqrt_8da177();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ sqrt_8da177();
+}
diff --git a/test/tint/builtins/gen/var/sqrt/9c5cbe.wgsl b/test/tint/builtins/gen/var/sqrt/9c5cbe.wgsl
new file mode 100644
index 0000000..fd7b08c
--- /dev/null
+++ b/test/tint/builtins/gen/var/sqrt/9c5cbe.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 sqrt(vec<2, fa>) -> vec<2, fa>
+fn sqrt_9c5cbe() {
+ const arg_0 = vec2(1.);
+ var res = sqrt(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ sqrt_9c5cbe();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ sqrt_9c5cbe();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ sqrt_9c5cbe();
+}
diff --git a/test/tint/builtins/gen/var/sqrt/9c5cbe.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/sqrt/9c5cbe.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..c0053e0
--- /dev/null
+++ b/test/tint/builtins/gen/var/sqrt/9c5cbe.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void sqrt_9c5cbe() {
+ float2 res = (1.0f).xx;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ sqrt_9c5cbe();
+ 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() {
+ sqrt_9c5cbe();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ sqrt_9c5cbe();
+ return;
+}
diff --git a/test/tint/builtins/gen/var/sqrt/9c5cbe.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/sqrt/9c5cbe.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..c0053e0
--- /dev/null
+++ b/test/tint/builtins/gen/var/sqrt/9c5cbe.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void sqrt_9c5cbe() {
+ float2 res = (1.0f).xx;
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ sqrt_9c5cbe();
+ 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() {
+ sqrt_9c5cbe();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ sqrt_9c5cbe();
+ return;
+}
diff --git a/test/tint/builtins/gen/var/sqrt/9c5cbe.wgsl.expected.glsl b/test/tint/builtins/gen/var/sqrt/9c5cbe.wgsl.expected.glsl
new file mode 100644
index 0000000..c6f1427
--- /dev/null
+++ b/test/tint/builtins/gen/var/sqrt/9c5cbe.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void sqrt_9c5cbe() {
+ vec2 res = vec2(1.0f);
+}
+
+vec4 vertex_main() {
+ sqrt_9c5cbe();
+ 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 sqrt_9c5cbe() {
+ vec2 res = vec2(1.0f);
+}
+
+void fragment_main() {
+ sqrt_9c5cbe();
+}
+
+void main() {
+ fragment_main();
+ return;
+}
+#version 310 es
+
+void sqrt_9c5cbe() {
+ vec2 res = vec2(1.0f);
+}
+
+void compute_main() {
+ sqrt_9c5cbe();
+}
+
+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/sqrt/9c5cbe.wgsl.expected.msl b/test/tint/builtins/gen/var/sqrt/9c5cbe.wgsl.expected.msl
new file mode 100644
index 0000000..c1866c8
--- /dev/null
+++ b/test/tint/builtins/gen/var/sqrt/9c5cbe.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void sqrt_9c5cbe() {
+ float2 res = float2(1.0f);
+}
+
+struct tint_symbol {
+ float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+ sqrt_9c5cbe();
+ 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() {
+ sqrt_9c5cbe();
+ return;
+}
+
+kernel void compute_main() {
+ sqrt_9c5cbe();
+ return;
+}
+
diff --git a/test/tint/builtins/gen/var/sqrt/9c5cbe.wgsl.expected.spvasm b/test/tint/builtins/gen/var/sqrt/9c5cbe.wgsl.expected.spvasm
new file mode 100644
index 0000000..feffb50
--- /dev/null
+++ b/test/tint/builtins/gen/var/sqrt/9c5cbe.wgsl.expected.spvasm
@@ -0,0 +1,66 @@
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 0
+; Bound: 32
+; 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 %sqrt_9c5cbe "sqrt_9c5cbe"
+ 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
+ %v2float = OpTypeVector %float 2
+ %float_1 = OpConstant %float 1
+ %15 = OpConstantComposite %v2float %float_1 %float_1
+%_ptr_Function_v2float = OpTypePointer Function %v2float
+ %18 = OpConstantNull %v2float
+ %19 = OpTypeFunction %v4float
+%sqrt_9c5cbe = OpFunction %void None %9
+ %12 = OpLabel
+ %res = OpVariable %_ptr_Function_v2float Function %18
+ OpStore %res %15
+ OpReturn
+ OpFunctionEnd
+%vertex_main_inner = OpFunction %v4float None %19
+ %21 = OpLabel
+ %22 = OpFunctionCall %void %sqrt_9c5cbe
+ OpReturnValue %5
+ OpFunctionEnd
+%vertex_main = OpFunction %void None %9
+ %24 = OpLabel
+ %25 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %25
+ OpStore %vertex_point_size %float_1
+ OpReturn
+ OpFunctionEnd
+%fragment_main = OpFunction %void None %9
+ %27 = OpLabel
+ %28 = OpFunctionCall %void %sqrt_9c5cbe
+ OpReturn
+ OpFunctionEnd
+%compute_main = OpFunction %void None %9
+ %30 = OpLabel
+ %31 = OpFunctionCall %void %sqrt_9c5cbe
+ OpReturn
+ OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/sqrt/9c5cbe.wgsl.expected.wgsl b/test/tint/builtins/gen/var/sqrt/9c5cbe.wgsl.expected.wgsl
new file mode 100644
index 0000000..73193fa
--- /dev/null
+++ b/test/tint/builtins/gen/var/sqrt/9c5cbe.wgsl.expected.wgsl
@@ -0,0 +1,20 @@
+fn sqrt_9c5cbe() {
+ const arg_0 = vec2(1.0);
+ var res = sqrt(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ sqrt_9c5cbe();
+ return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+ sqrt_9c5cbe();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+ sqrt_9c5cbe();
+}