Add const-eval for `saturate`.

This CL adds const-eval for the `saturate` builtin.

Bug: tint:1581
Change-Id: I3729ea5b381b04b73bbe1bc8e03e5ce65c27e082
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107362
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
diff --git a/src/tint/intrinsics.def b/src/tint/intrinsics.def
index 01dd501..90766cc 100644
--- a/src/tint/intrinsics.def
+++ b/src/tint/intrinsics.def
@@ -522,8 +522,8 @@
 fn reverseBits<N: num, T: iu32>(vec<N, T>) -> vec<N, T>
 fn round<T: f32_f16>(T) -> T
 fn round<N: num, T: f32_f16>(vec<N, T>) -> vec<N, T>
-fn saturate<T: f32_f16>(T) -> T
-fn saturate<T: f32_f16, N: num>(vec<N, T>) -> vec<N, T>
+@const fn saturate<T: fa_f32_f16>(@test_value(2) T) -> T
+@const fn saturate<T: fa_f32_f16, N: num>(@test_value(2) vec<N, T>) -> vec<N, T>
 @const("select_bool") fn select<T: scalar>(T, T, bool) -> T
 @const("select_bool") fn select<T: scalar, N: num>(vec<N, T>, vec<N, T>, bool) -> vec<N, T>
 @const("select_boolvec") fn select<N: num, T: scalar>(vec<N, T>, vec<N, T>, vec<N, bool>) -> vec<N, T>
diff --git a/src/tint/resolver/const_eval.cc b/src/tint/resolver/const_eval.cc
index 1d0d333..de29bc3 100644
--- a/src/tint/resolver/const_eval.cc
+++ b/src/tint/resolver/const_eval.cc
@@ -1616,6 +1616,20 @@
     return TransformElements(builder, ty, transform, args[0], args[1], args[2]);
 }
 
+ConstEval::Result ConstEval::saturate(const sem::Type* ty,
+                                      utils::VectorRef<const sem::Constant*> args,
+                                      const Source&) {
+    auto transform = [&](const sem::Constant* c0) {
+        auto create = [&](auto e) {
+            using NumberT = decltype(e);
+            return CreateElement(builder, c0->Type(),
+                                 NumberT(std::min(std::max(e, NumberT(0.0)), NumberT(1.0))));
+        };
+        return Dispatch_fia_fiu32_f16(create, c0);
+    };
+    return TransformElements(builder, ty, transform, args[0]);
+}
+
 ConstEval::Result ConstEval::select_bool(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 425b524..cffdcca 100644
--- a/src/tint/resolver/const_eval.h
+++ b/src/tint/resolver/const_eval.h
@@ -431,6 +431,15 @@
                  utils::VectorRef<const sem::Constant*> args,
                  const Source& source);
 
+    /// saturate 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 saturate(const sem::Type* ty,
+                    utils::VectorRef<const sem::Constant*> args,
+                    const Source& source);
+
     /// select builtin with single bool third arg
     /// @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 c35099e..09e73da 100644
--- a/src/tint/resolver/const_eval_builtin_test.cc
+++ b/src/tint/resolver/const_eval_builtin_test.cc
@@ -461,6 +461,31 @@
                                               ClampCases<f16>()))));
 
 template <typename T>
+std::vector<Case> SaturateCases() {
+    return {
+        C({T(0)}, T(0)),
+        C({T(1)}, T(1)),
+        C({T::Lowest()}, T(0)),
+        C({T::Highest()}, T(1)),
+
+        // Vector tests
+        C({Vec(T(0), T(0))},                       //
+          Vec(T(0), T(0))),                        //
+        C({Vec(T(1), T(1))},                       //
+          Vec(T(1), T(1))),                        //
+        C({Vec(T::Lowest(), T(0), T::Highest())},  //
+          Vec(T(0), T(0), T(1))),
+    };
+}
+INSTANTIATE_TEST_SUITE_P(  //
+    Saturate,
+    ResolverConstEvalBuiltinTest,
+    testing::Combine(testing::Values(sem::BuiltinType::kSaturate),
+                     testing::ValuesIn(Concat(SaturateCases<AFloat>(),  //
+                                              SaturateCases<f32>(),
+                                              SaturateCases<f16>()))));
+
+template <typename T>
 std::vector<Case> SelectCases() {
     return {
         C({Val(T{1}), Val(T{2}), Val(false)}, Val(T{1})),
diff --git a/src/tint/resolver/intrinsic_table.inl b/src/tint/resolver/intrinsic_table.inl
index 785cce1..826307d 100644
--- a/src/tint/resolver/intrinsic_table.inl
+++ b/src/tint/resolver/intrinsic_table.inl
@@ -12407,24 +12407,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[902],
     /* return matcher indices */ &kMatcherIndices[1],
     /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
-    /* const eval */ nullptr,
+    /* const eval */ &ConstEval::saturate,
   },
   {
     /* [341] */
     /* 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[903],
     /* return matcher indices */ &kMatcherIndices[30],
     /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
-    /* const eval */ nullptr,
+    /* const eval */ &ConstEval::saturate,
   },
   {
     /* [342] */
@@ -14427,8 +14427,8 @@
   },
   {
     /* [66] */
-    /* fn saturate<T : f32_f16>(T) -> T */
-    /* fn saturate<T : f32_f16, N : num>(vec<N, T>) -> vec<N, T> */
+    /* fn saturate<T : fa_f32_f16>(@test_value(2) T) -> T */
+    /* fn saturate<T : fa_f32_f16, N : num>(@test_value(2) vec<N, T>) -> vec<N, T> */
     /* num overloads */ 2,
     /* overloads */ &kOverloads[340],
   },
diff --git a/src/tint/transform/builtin_polyfill_test.cc b/src/tint/transform/builtin_polyfill_test.cc
index 40059ca..dc76eb0 100644
--- a/src/tint/transform/builtin_polyfill_test.cc
+++ b/src/tint/transform/builtin_polyfill_test.cc
@@ -1435,28 +1435,6 @@
     EXPECT_EQ(expect, str(got));
 }
 
-TEST_F(BuiltinPolyfillTest, Saturate_f32_from_abstract_float) {
-    auto* src = R"(
-fn f() {
-  let r : f32 = saturate(0.5);
-}
-)";
-
-    auto* expect = R"(
-fn tint_saturate(v : f32) -> f32 {
-  return clamp(v, f32(0), f32(1));
-}
-
-fn f() {
-  let r : f32 = tint_saturate(0.5);
-}
-)";
-
-    auto got = Run<BuiltinPolyfill>(src, polyfillSaturate());
-
-    EXPECT_EQ(expect, str(got));
-}
-
 TEST_F(BuiltinPolyfillTest, Saturate_f16) {
     auto* src = R"(
 enable f16;
@@ -1505,28 +1483,6 @@
     EXPECT_EQ(expect, str(got));
 }
 
-TEST_F(BuiltinPolyfillTest, Saturate_vec3_f32_from_abstract_float) {
-    auto* src = R"(
-fn f() {
-  let r : vec3<f32> = saturate(vec3(0.5));
-}
-)";
-
-    auto* expect = R"(
-fn tint_saturate(v : vec3<f32>) -> vec3<f32> {
-  return clamp(v, vec3<f32>(0), vec3<f32>(1));
-}
-
-fn f() {
-  let r : vec3<f32> = tint_saturate(vec3(0.5));
-}
-)";
-
-    auto got = Run<BuiltinPolyfill>(src, polyfillSaturate());
-
-    EXPECT_EQ(expect, str(got));
-}
-
 TEST_F(BuiltinPolyfillTest, Saturate_vec3_f16) {
     auto* src = R"(
 enable f16;
diff --git a/test/tint/builtins/gen/literal/saturate/270da5.wgsl b/test/tint/builtins/gen/literal/saturate/270da5.wgsl
index 2ec5cec..263c53d 100644
--- a/test/tint/builtins/gen/literal/saturate/270da5.wgsl
+++ b/test/tint/builtins/gen/literal/saturate/270da5.wgsl
@@ -23,7 +23,7 @@
 
 // fn saturate(f32) -> f32
 fn saturate_270da5() {
-  var res: f32 = saturate(1.f);
+  var res: f32 = saturate(2.f);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.dxc.hlsl
index 6d8db4c..ea2aa83 100644
--- a/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
 void saturate_270da5() {
-  float res = saturate(1.0f);
+  float res = 1.0f;
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.fxc.hlsl
index 6d8db4c..ea2aa83 100644
--- a/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.fxc.hlsl
@@ -1,5 +1,5 @@
 void saturate_270da5() {
-  float res = saturate(1.0f);
+  float res = 1.0f;
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.glsl b/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.glsl
index f9313c7..99d917d 100644
--- a/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.glsl
@@ -5,7 +5,7 @@
 }
 
 void saturate_270da5() {
-  float res = tint_saturate(1.0f);
+  float res = tint_saturate(2.0f);
 }
 
 vec4 vertex_main() {
@@ -29,7 +29,7 @@
 }
 
 void saturate_270da5() {
-  float res = tint_saturate(1.0f);
+  float res = tint_saturate(2.0f);
 }
 
 void fragment_main() {
@@ -47,7 +47,7 @@
 }
 
 void saturate_270da5() {
-  float res = tint_saturate(1.0f);
+  float res = tint_saturate(2.0f);
 }
 
 void compute_main() {
diff --git a/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.msl b/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.msl
index 1b6a3dc..5d05acc 100644
--- a/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void saturate_270da5() {
-  float res = saturate(1.0f);
+  float res = 1.0f;
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.spvasm
index 4eea101..47550a2 100644
--- a/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.spvasm
@@ -1,7 +1,7 @@
 ; SPIR-V
 ; Version: 1.3
 ; Generator: Google Tint Compiler; 0
-; Bound: 36
+; Bound: 37
 ; Schema: 0
                OpCapability Shader
          %14 = OpExtInstImport "GLSL.std.450"
@@ -35,8 +35,9 @@
     %float_1 = OpConstant %float 1
        %void = OpTypeVoid
          %16 = OpTypeFunction %void
+    %float_2 = OpConstant %float 2
 %_ptr_Function_float = OpTypePointer Function %float
-         %23 = OpTypeFunction %v4float
+         %24 = OpTypeFunction %v4float
 %tint_saturate = OpFunction %float None %9
           %v = OpFunctionParameter %float
          %12 = OpLabel
@@ -46,29 +47,29 @@
 %saturate_270da5 = OpFunction %void None %16
          %19 = OpLabel
         %res = OpVariable %_ptr_Function_float Function %8
-         %20 = OpFunctionCall %float %tint_saturate %float_1
+         %20 = OpFunctionCall %float %tint_saturate %float_2
                OpStore %res %20
                OpReturn
                OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %23
-         %25 = OpLabel
-         %26 = OpFunctionCall %void %saturate_270da5
+%vertex_main_inner = OpFunction %v4float None %24
+         %26 = OpLabel
+         %27 = OpFunctionCall %void %saturate_270da5
                OpReturnValue %5
                OpFunctionEnd
 %vertex_main = OpFunction %void None %16
-         %28 = OpLabel
-         %29 = OpFunctionCall %v4float %vertex_main_inner
-               OpStore %value %29
+         %29 = OpLabel
+         %30 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %30
                OpStore %vertex_point_size %float_1
                OpReturn
                OpFunctionEnd
 %fragment_main = OpFunction %void None %16
-         %31 = OpLabel
-         %32 = OpFunctionCall %void %saturate_270da5
+         %32 = OpLabel
+         %33 = OpFunctionCall %void %saturate_270da5
                OpReturn
                OpFunctionEnd
 %compute_main = OpFunction %void None %16
-         %34 = OpLabel
-         %35 = OpFunctionCall %void %saturate_270da5
+         %35 = OpLabel
+         %36 = OpFunctionCall %void %saturate_270da5
                OpReturn
                OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.wgsl
index dc2a36a..006c871 100644
--- a/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/literal/saturate/270da5.wgsl.expected.wgsl
@@ -1,5 +1,5 @@
 fn saturate_270da5() {
-  var res : f32 = saturate(1.0f);
+  var res : f32 = saturate(2.0f);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/literal/saturate/462535.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/saturate/462535.wgsl.expected.dxc.hlsl
index cd2602f..23800c3 100644
--- a/test/tint/builtins/gen/literal/saturate/462535.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/saturate/462535.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
 void saturate_462535() {
-  vector<float16_t, 3> res = saturate((float16_t(0.0h)).xxx);
+  vector<float16_t, 3> res = (float16_t(0.0h)).xxx;
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/saturate/462535.wgsl.expected.msl b/test/tint/builtins/gen/literal/saturate/462535.wgsl.expected.msl
index 52dd6d5..35014be 100644
--- a/test/tint/builtins/gen/literal/saturate/462535.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/saturate/462535.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void saturate_462535() {
-  half3 res = saturate(half3(0.0h));
+  half3 res = half3(0.0h);
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl b/test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl
new file mode 100644
index 0000000..d730ec4d
--- /dev/null
+++ b/test/tint/builtins/gen/literal/saturate/4ed8d7.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 saturate(vec<4, fa>) -> vec<4, fa>
+fn saturate_4ed8d7() {
+  var res = saturate(vec4(2));
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  saturate_4ed8d7();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  saturate_4ed8d7();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  saturate_4ed8d7();
+}
diff --git a/test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..6bafa64
--- /dev/null
+++ b/test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void saturate_4ed8d7() {
+  float4 res = (1.0f).xxxx;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  saturate_4ed8d7();
+  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() {
+  saturate_4ed8d7();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  saturate_4ed8d7();
+  return;
+}
diff --git a/test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..6bafa64
--- /dev/null
+++ b/test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void saturate_4ed8d7() {
+  float4 res = (1.0f).xxxx;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  saturate_4ed8d7();
+  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() {
+  saturate_4ed8d7();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  saturate_4ed8d7();
+  return;
+}
diff --git a/test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl.expected.glsl b/test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl.expected.glsl
new file mode 100644
index 0000000..e6bfa97
--- /dev/null
+++ b/test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void saturate_4ed8d7() {
+  vec4 res = vec4(1.0f);
+}
+
+vec4 vertex_main() {
+  saturate_4ed8d7();
+  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 saturate_4ed8d7() {
+  vec4 res = vec4(1.0f);
+}
+
+void fragment_main() {
+  saturate_4ed8d7();
+}
+
+void main() {
+  fragment_main();
+  return;
+}
+#version 310 es
+
+void saturate_4ed8d7() {
+  vec4 res = vec4(1.0f);
+}
+
+void compute_main() {
+  saturate_4ed8d7();
+}
+
+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/saturate/4ed8d7.wgsl.expected.msl b/test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl.expected.msl
new file mode 100644
index 0000000..f6dfde6
--- /dev/null
+++ b/test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void saturate_4ed8d7() {
+  float4 res = float4(1.0f);
+}
+
+struct tint_symbol {
+  float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+  saturate_4ed8d7();
+  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() {
+  saturate_4ed8d7();
+  return;
+}
+
+kernel void compute_main() {
+  saturate_4ed8d7();
+  return;
+}
+
diff --git a/test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl.expected.spvasm
new file mode 100644
index 0000000..91bfee1
--- /dev/null
+++ b/test/tint/builtins/gen/literal/saturate/4ed8d7.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 %saturate_4ed8d7 "saturate_4ed8d7"
+               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
+%saturate_4ed8d7 = 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 %saturate_4ed8d7
+               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 %saturate_4ed8d7
+               OpReturn
+               OpFunctionEnd
+%compute_main = OpFunction %void None %9
+         %28 = OpLabel
+         %29 = OpFunctionCall %void %saturate_4ed8d7
+               OpReturn
+               OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl.expected.wgsl
new file mode 100644
index 0000000..4ef9207
--- /dev/null
+++ b/test/tint/builtins/gen/literal/saturate/4ed8d7.wgsl.expected.wgsl
@@ -0,0 +1,19 @@
+fn saturate_4ed8d7() {
+  var res = saturate(vec4(2));
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  saturate_4ed8d7();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  saturate_4ed8d7();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  saturate_4ed8d7();
+}
diff --git a/test/tint/builtins/gen/literal/saturate/51567f.wgsl b/test/tint/builtins/gen/literal/saturate/51567f.wgsl
index 3cfebef..23daad5 100644
--- a/test/tint/builtins/gen/literal/saturate/51567f.wgsl
+++ b/test/tint/builtins/gen/literal/saturate/51567f.wgsl
@@ -23,7 +23,7 @@
 
 // fn saturate(vec<2, f32>) -> vec<2, f32>
 fn saturate_51567f() {
-  var res: vec2<f32> = saturate(vec2<f32>(1.f));
+  var res: vec2<f32> = saturate(vec2<f32>(2.f));
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.dxc.hlsl
index 4110251..8d8a7de 100644
--- a/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
 void saturate_51567f() {
-  float2 res = saturate((1.0f).xx);
+  float2 res = (1.0f).xx;
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.fxc.hlsl
index 4110251..8d8a7de 100644
--- a/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.fxc.hlsl
@@ -1,5 +1,5 @@
 void saturate_51567f() {
-  float2 res = saturate((1.0f).xx);
+  float2 res = (1.0f).xx;
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.glsl b/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.glsl
index 2646c1f..8b4840e 100644
--- a/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.glsl
@@ -5,7 +5,7 @@
 }
 
 void saturate_51567f() {
-  vec2 res = tint_saturate(vec2(1.0f));
+  vec2 res = tint_saturate(vec2(2.0f));
 }
 
 vec4 vertex_main() {
@@ -29,7 +29,7 @@
 }
 
 void saturate_51567f() {
-  vec2 res = tint_saturate(vec2(1.0f));
+  vec2 res = tint_saturate(vec2(2.0f));
 }
 
 void fragment_main() {
@@ -47,7 +47,7 @@
 }
 
 void saturate_51567f() {
-  vec2 res = tint_saturate(vec2(1.0f));
+  vec2 res = tint_saturate(vec2(2.0f));
 }
 
 void compute_main() {
diff --git a/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.msl b/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.msl
index d3d4e00..aa4854a 100644
--- a/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void saturate_51567f() {
-  float2 res = saturate(float2(1.0f));
+  float2 res = float2(1.0f);
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.spvasm
index 46f1ae9..563368c 100644
--- a/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.spvasm
@@ -1,7 +1,7 @@
 ; SPIR-V
 ; Version: 1.3
 ; Generator: Google Tint Compiler; 0
-; Bound: 39
+; Bound: 41
 ; Schema: 0
                OpCapability Shader
          %15 = OpExtInstImport "GLSL.std.450"
@@ -38,8 +38,10 @@
          %18 = OpConstantComposite %v2float %float_1 %float_1
        %void = OpTypeVoid
          %19 = OpTypeFunction %void
+    %float_2 = OpConstant %float 2
+         %25 = OpConstantComposite %v2float %float_2 %float_2
 %_ptr_Function_v2float = OpTypePointer Function %v2float
-         %26 = OpTypeFunction %v4float
+         %28 = OpTypeFunction %v4float
 %tint_saturate = OpFunction %v2float None %9
           %v = OpFunctionParameter %v2float
          %13 = OpLabel
@@ -49,29 +51,29 @@
 %saturate_51567f = OpFunction %void None %19
          %22 = OpLabel
         %res = OpVariable %_ptr_Function_v2float Function %16
-         %23 = OpFunctionCall %v2float %tint_saturate %18
+         %23 = OpFunctionCall %v2float %tint_saturate %25
                OpStore %res %23
                OpReturn
                OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %26
-         %28 = OpLabel
-         %29 = OpFunctionCall %void %saturate_51567f
+%vertex_main_inner = OpFunction %v4float None %28
+         %30 = OpLabel
+         %31 = OpFunctionCall %void %saturate_51567f
                OpReturnValue %5
                OpFunctionEnd
 %vertex_main = OpFunction %void None %19
-         %31 = OpLabel
-         %32 = OpFunctionCall %v4float %vertex_main_inner
-               OpStore %value %32
+         %33 = OpLabel
+         %34 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %34
                OpStore %vertex_point_size %float_1
                OpReturn
                OpFunctionEnd
 %fragment_main = OpFunction %void None %19
-         %34 = OpLabel
-         %35 = OpFunctionCall %void %saturate_51567f
+         %36 = OpLabel
+         %37 = OpFunctionCall %void %saturate_51567f
                OpReturn
                OpFunctionEnd
 %compute_main = OpFunction %void None %19
-         %37 = OpLabel
-         %38 = OpFunctionCall %void %saturate_51567f
+         %39 = OpLabel
+         %40 = OpFunctionCall %void %saturate_51567f
                OpReturn
                OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.wgsl
index e22d067..f81f727 100644
--- a/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/literal/saturate/51567f.wgsl.expected.wgsl
@@ -1,5 +1,5 @@
 fn saturate_51567f() {
-  var res : vec2<f32> = saturate(vec2<f32>(1.0f));
+  var res : vec2<f32> = saturate(vec2<f32>(2.0f));
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl b/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl
index 0c3e1f8..da4ce4b 100644
--- a/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl
+++ b/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl
@@ -23,7 +23,7 @@
 
 // fn saturate(vec<3, f32>) -> vec<3, f32>
 fn saturate_6bcddf() {
-  var res: vec3<f32> = saturate(vec3<f32>(1.f));
+  var res: vec3<f32> = saturate(vec3<f32>(2.f));
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.dxc.hlsl
index ada840b..444b45a 100644
--- a/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
 void saturate_6bcddf() {
-  float3 res = saturate((1.0f).xxx);
+  float3 res = (1.0f).xxx;
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.fxc.hlsl
index ada840b..444b45a 100644
--- a/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.fxc.hlsl
@@ -1,5 +1,5 @@
 void saturate_6bcddf() {
-  float3 res = saturate((1.0f).xxx);
+  float3 res = (1.0f).xxx;
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.glsl b/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.glsl
index 301fd1c..c5ca265 100644
--- a/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.glsl
@@ -5,7 +5,7 @@
 }
 
 void saturate_6bcddf() {
-  vec3 res = tint_saturate(vec3(1.0f));
+  vec3 res = tint_saturate(vec3(2.0f));
 }
 
 vec4 vertex_main() {
@@ -29,7 +29,7 @@
 }
 
 void saturate_6bcddf() {
-  vec3 res = tint_saturate(vec3(1.0f));
+  vec3 res = tint_saturate(vec3(2.0f));
 }
 
 void fragment_main() {
@@ -47,7 +47,7 @@
 }
 
 void saturate_6bcddf() {
-  vec3 res = tint_saturate(vec3(1.0f));
+  vec3 res = tint_saturate(vec3(2.0f));
 }
 
 void compute_main() {
diff --git a/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.msl b/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.msl
index 1a54ff0..0cf7e3f 100644
--- a/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void saturate_6bcddf() {
-  float3 res = saturate(float3(1.0f));
+  float3 res = float3(1.0f);
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.spvasm
index bd381f1..5559bd2 100644
--- a/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.spvasm
@@ -1,7 +1,7 @@
 ; SPIR-V
 ; Version: 1.3
 ; Generator: Google Tint Compiler; 0
-; Bound: 39
+; Bound: 41
 ; Schema: 0
                OpCapability Shader
          %15 = OpExtInstImport "GLSL.std.450"
@@ -38,8 +38,10 @@
          %18 = OpConstantComposite %v3float %float_1 %float_1 %float_1
        %void = OpTypeVoid
          %19 = OpTypeFunction %void
+    %float_2 = OpConstant %float 2
+         %25 = OpConstantComposite %v3float %float_2 %float_2 %float_2
 %_ptr_Function_v3float = OpTypePointer Function %v3float
-         %26 = OpTypeFunction %v4float
+         %28 = OpTypeFunction %v4float
 %tint_saturate = OpFunction %v3float None %9
           %v = OpFunctionParameter %v3float
          %13 = OpLabel
@@ -49,29 +51,29 @@
 %saturate_6bcddf = OpFunction %void None %19
          %22 = OpLabel
         %res = OpVariable %_ptr_Function_v3float Function %16
-         %23 = OpFunctionCall %v3float %tint_saturate %18
+         %23 = OpFunctionCall %v3float %tint_saturate %25
                OpStore %res %23
                OpReturn
                OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %26
-         %28 = OpLabel
-         %29 = OpFunctionCall %void %saturate_6bcddf
+%vertex_main_inner = OpFunction %v4float None %28
+         %30 = OpLabel
+         %31 = OpFunctionCall %void %saturate_6bcddf
                OpReturnValue %5
                OpFunctionEnd
 %vertex_main = OpFunction %void None %19
-         %31 = OpLabel
-         %32 = OpFunctionCall %v4float %vertex_main_inner
-               OpStore %value %32
+         %33 = OpLabel
+         %34 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %34
                OpStore %vertex_point_size %float_1
                OpReturn
                OpFunctionEnd
 %fragment_main = OpFunction %void None %19
-         %34 = OpLabel
-         %35 = OpFunctionCall %void %saturate_6bcddf
+         %36 = OpLabel
+         %37 = OpFunctionCall %void %saturate_6bcddf
                OpReturn
                OpFunctionEnd
 %compute_main = OpFunction %void None %19
-         %37 = OpLabel
-         %38 = OpFunctionCall %void %saturate_6bcddf
+         %39 = OpLabel
+         %40 = OpFunctionCall %void %saturate_6bcddf
                OpReturn
                OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.wgsl
index b85b66e..c4c3a61 100644
--- a/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/literal/saturate/6bcddf.wgsl.expected.wgsl
@@ -1,5 +1,5 @@
 fn saturate_6bcddf() {
-  var res : vec3<f32> = saturate(vec3<f32>(1.0f));
+  var res : vec3<f32> = saturate(vec3<f32>(2.0f));
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/literal/saturate/78b37c.wgsl b/test/tint/builtins/gen/literal/saturate/78b37c.wgsl
new file mode 100644
index 0000000..4ac82c1
--- /dev/null
+++ b/test/tint/builtins/gen/literal/saturate/78b37c.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 saturate(fa) -> fa
+fn saturate_78b37c() {
+  var res = saturate(2);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  saturate_78b37c();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  saturate_78b37c();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  saturate_78b37c();
+}
diff --git a/test/tint/builtins/gen/literal/saturate/78b37c.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/saturate/78b37c.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..68051b6
--- /dev/null
+++ b/test/tint/builtins/gen/literal/saturate/78b37c.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void saturate_78b37c() {
+  float res = 1.0f;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  saturate_78b37c();
+  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() {
+  saturate_78b37c();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  saturate_78b37c();
+  return;
+}
diff --git a/test/tint/builtins/gen/literal/saturate/78b37c.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/saturate/78b37c.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..68051b6
--- /dev/null
+++ b/test/tint/builtins/gen/literal/saturate/78b37c.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void saturate_78b37c() {
+  float res = 1.0f;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  saturate_78b37c();
+  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() {
+  saturate_78b37c();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  saturate_78b37c();
+  return;
+}
diff --git a/test/tint/builtins/gen/literal/saturate/78b37c.wgsl.expected.glsl b/test/tint/builtins/gen/literal/saturate/78b37c.wgsl.expected.glsl
new file mode 100644
index 0000000..e660571
--- /dev/null
+++ b/test/tint/builtins/gen/literal/saturate/78b37c.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void saturate_78b37c() {
+  float res = 1.0f;
+}
+
+vec4 vertex_main() {
+  saturate_78b37c();
+  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 saturate_78b37c() {
+  float res = 1.0f;
+}
+
+void fragment_main() {
+  saturate_78b37c();
+}
+
+void main() {
+  fragment_main();
+  return;
+}
+#version 310 es
+
+void saturate_78b37c() {
+  float res = 1.0f;
+}
+
+void compute_main() {
+  saturate_78b37c();
+}
+
+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/saturate/78b37c.wgsl.expected.msl b/test/tint/builtins/gen/literal/saturate/78b37c.wgsl.expected.msl
new file mode 100644
index 0000000..4619ba0
--- /dev/null
+++ b/test/tint/builtins/gen/literal/saturate/78b37c.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void saturate_78b37c() {
+  float res = 1.0f;
+}
+
+struct tint_symbol {
+  float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+  saturate_78b37c();
+  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() {
+  saturate_78b37c();
+  return;
+}
+
+kernel void compute_main() {
+  saturate_78b37c();
+  return;
+}
+
diff --git a/test/tint/builtins/gen/literal/saturate/78b37c.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/saturate/78b37c.wgsl.expected.spvasm
new file mode 100644
index 0000000..5b55286
--- /dev/null
+++ b/test/tint/builtins/gen/literal/saturate/78b37c.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 %saturate_78b37c "saturate_78b37c"
+               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
+%saturate_78b37c = 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 %saturate_78b37c
+               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 %saturate_78b37c
+               OpReturn
+               OpFunctionEnd
+%compute_main = OpFunction %void None %9
+         %27 = OpLabel
+         %28 = OpFunctionCall %void %saturate_78b37c
+               OpReturn
+               OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/saturate/78b37c.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/saturate/78b37c.wgsl.expected.wgsl
new file mode 100644
index 0000000..43b22f6
--- /dev/null
+++ b/test/tint/builtins/gen/literal/saturate/78b37c.wgsl.expected.wgsl
@@ -0,0 +1,19 @@
+fn saturate_78b37c() {
+  var res = saturate(2);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  saturate_78b37c();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  saturate_78b37c();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  saturate_78b37c();
+}
diff --git a/test/tint/builtins/gen/literal/saturate/a5b571.wgsl b/test/tint/builtins/gen/literal/saturate/a5b571.wgsl
index 57683f2..984d4cb 100644
--- a/test/tint/builtins/gen/literal/saturate/a5b571.wgsl
+++ b/test/tint/builtins/gen/literal/saturate/a5b571.wgsl
@@ -23,7 +23,7 @@
 
 // fn saturate(vec<4, f32>) -> vec<4, f32>
 fn saturate_a5b571() {
-  var res: vec4<f32> = saturate(vec4<f32>(1.f));
+  var res: vec4<f32> = saturate(vec4<f32>(2.f));
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.dxc.hlsl
index 2f85096..66b0b04 100644
--- a/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
 void saturate_a5b571() {
-  float4 res = saturate((1.0f).xxxx);
+  float4 res = (1.0f).xxxx;
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.fxc.hlsl
index 2f85096..66b0b04 100644
--- a/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.fxc.hlsl
@@ -1,5 +1,5 @@
 void saturate_a5b571() {
-  float4 res = saturate((1.0f).xxxx);
+  float4 res = (1.0f).xxxx;
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.glsl b/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.glsl
index 6d2ba76..5ef994c 100644
--- a/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.glsl
@@ -5,7 +5,7 @@
 }
 
 void saturate_a5b571() {
-  vec4 res = tint_saturate(vec4(1.0f));
+  vec4 res = tint_saturate(vec4(2.0f));
 }
 
 vec4 vertex_main() {
@@ -29,7 +29,7 @@
 }
 
 void saturate_a5b571() {
-  vec4 res = tint_saturate(vec4(1.0f));
+  vec4 res = tint_saturate(vec4(2.0f));
 }
 
 void fragment_main() {
@@ -47,7 +47,7 @@
 }
 
 void saturate_a5b571() {
-  vec4 res = tint_saturate(vec4(1.0f));
+  vec4 res = tint_saturate(vec4(2.0f));
 }
 
 void compute_main() {
diff --git a/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.msl b/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.msl
index 6f1af61..48e0fda 100644
--- a/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void saturate_a5b571() {
-  float4 res = saturate(float4(1.0f));
+  float4 res = float4(1.0f);
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.spvasm
index 741b845..cc9e8d8 100644
--- a/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.spvasm
@@ -1,7 +1,7 @@
 ; SPIR-V
 ; Version: 1.3
 ; Generator: Google Tint Compiler; 0
-; Bound: 37
+; Bound: 39
 ; Schema: 0
                OpCapability Shader
          %14 = OpExtInstImport "GLSL.std.450"
@@ -36,8 +36,10 @@
          %16 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
        %void = OpTypeVoid
          %17 = OpTypeFunction %void
+    %float_2 = OpConstant %float 2
+         %23 = OpConstantComposite %v4float %float_2 %float_2 %float_2 %float_2
 %_ptr_Function_v4float = OpTypePointer Function %v4float
-         %24 = OpTypeFunction %v4float
+         %26 = OpTypeFunction %v4float
 %tint_saturate = OpFunction %v4float None %9
           %v = OpFunctionParameter %v4float
          %12 = OpLabel
@@ -47,29 +49,29 @@
 %saturate_a5b571 = OpFunction %void None %17
          %20 = OpLabel
         %res = OpVariable %_ptr_Function_v4float Function %5
-         %21 = OpFunctionCall %v4float %tint_saturate %16
+         %21 = OpFunctionCall %v4float %tint_saturate %23
                OpStore %res %21
                OpReturn
                OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %24
-         %26 = OpLabel
-         %27 = OpFunctionCall %void %saturate_a5b571
+%vertex_main_inner = OpFunction %v4float None %26
+         %28 = OpLabel
+         %29 = OpFunctionCall %void %saturate_a5b571
                OpReturnValue %5
                OpFunctionEnd
 %vertex_main = OpFunction %void None %17
-         %29 = OpLabel
-         %30 = OpFunctionCall %v4float %vertex_main_inner
-               OpStore %value %30
+         %31 = OpLabel
+         %32 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %32
                OpStore %vertex_point_size %float_1
                OpReturn
                OpFunctionEnd
 %fragment_main = OpFunction %void None %17
-         %32 = OpLabel
-         %33 = OpFunctionCall %void %saturate_a5b571
+         %34 = OpLabel
+         %35 = OpFunctionCall %void %saturate_a5b571
                OpReturn
                OpFunctionEnd
 %compute_main = OpFunction %void None %17
-         %35 = OpLabel
-         %36 = OpFunctionCall %void %saturate_a5b571
+         %37 = OpLabel
+         %38 = OpFunctionCall %void %saturate_a5b571
                OpReturn
                OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.wgsl
index afba14c..79a7572 100644
--- a/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/literal/saturate/a5b571.wgsl.expected.wgsl
@@ -1,5 +1,5 @@
 fn saturate_a5b571() {
-  var res : vec4<f32> = saturate(vec4<f32>(1.0f));
+  var res : vec4<f32> = saturate(vec4<f32>(2.0f));
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/literal/saturate/cd2028.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/saturate/cd2028.wgsl.expected.dxc.hlsl
index 6f7e98f..97f10e9 100644
--- a/test/tint/builtins/gen/literal/saturate/cd2028.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/saturate/cd2028.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
 void saturate_cd2028() {
-  vector<float16_t, 2> res = saturate((float16_t(0.0h)).xx);
+  vector<float16_t, 2> res = (float16_t(0.0h)).xx;
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/saturate/cd2028.wgsl.expected.msl b/test/tint/builtins/gen/literal/saturate/cd2028.wgsl.expected.msl
index 9f9ad52..0f23c02 100644
--- a/test/tint/builtins/gen/literal/saturate/cd2028.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/saturate/cd2028.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void saturate_cd2028() {
-  half2 res = saturate(half2(0.0h));
+  half2 res = half2(0.0h);
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/saturate/d55822.wgsl b/test/tint/builtins/gen/literal/saturate/d55822.wgsl
new file mode 100644
index 0000000..4ed8e48
--- /dev/null
+++ b/test/tint/builtins/gen/literal/saturate/d55822.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 saturate(vec<3, fa>) -> vec<3, fa>
+fn saturate_d55822() {
+  var res = saturate(vec3(2));
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  saturate_d55822();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  saturate_d55822();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  saturate_d55822();
+}
diff --git a/test/tint/builtins/gen/literal/saturate/d55822.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/saturate/d55822.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..8121744
--- /dev/null
+++ b/test/tint/builtins/gen/literal/saturate/d55822.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void saturate_d55822() {
+  float3 res = (1.0f).xxx;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  saturate_d55822();
+  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() {
+  saturate_d55822();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  saturate_d55822();
+  return;
+}
diff --git a/test/tint/builtins/gen/literal/saturate/d55822.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/saturate/d55822.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..8121744
--- /dev/null
+++ b/test/tint/builtins/gen/literal/saturate/d55822.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void saturate_d55822() {
+  float3 res = (1.0f).xxx;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  saturate_d55822();
+  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() {
+  saturate_d55822();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  saturate_d55822();
+  return;
+}
diff --git a/test/tint/builtins/gen/literal/saturate/d55822.wgsl.expected.glsl b/test/tint/builtins/gen/literal/saturate/d55822.wgsl.expected.glsl
new file mode 100644
index 0000000..499d488
--- /dev/null
+++ b/test/tint/builtins/gen/literal/saturate/d55822.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void saturate_d55822() {
+  vec3 res = vec3(1.0f);
+}
+
+vec4 vertex_main() {
+  saturate_d55822();
+  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 saturate_d55822() {
+  vec3 res = vec3(1.0f);
+}
+
+void fragment_main() {
+  saturate_d55822();
+}
+
+void main() {
+  fragment_main();
+  return;
+}
+#version 310 es
+
+void saturate_d55822() {
+  vec3 res = vec3(1.0f);
+}
+
+void compute_main() {
+  saturate_d55822();
+}
+
+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/saturate/d55822.wgsl.expected.msl b/test/tint/builtins/gen/literal/saturate/d55822.wgsl.expected.msl
new file mode 100644
index 0000000..40857e4
--- /dev/null
+++ b/test/tint/builtins/gen/literal/saturate/d55822.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void saturate_d55822() {
+  float3 res = float3(1.0f);
+}
+
+struct tint_symbol {
+  float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+  saturate_d55822();
+  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() {
+  saturate_d55822();
+  return;
+}
+
+kernel void compute_main() {
+  saturate_d55822();
+  return;
+}
+
diff --git a/test/tint/builtins/gen/literal/saturate/d55822.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/saturate/d55822.wgsl.expected.spvasm
new file mode 100644
index 0000000..575588d
--- /dev/null
+++ b/test/tint/builtins/gen/literal/saturate/d55822.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 %saturate_d55822 "saturate_d55822"
+               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
+%saturate_d55822 = 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 %saturate_d55822
+               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 %saturate_d55822
+               OpReturn
+               OpFunctionEnd
+%compute_main = OpFunction %void None %9
+         %30 = OpLabel
+         %31 = OpFunctionCall %void %saturate_d55822
+               OpReturn
+               OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/saturate/d55822.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/saturate/d55822.wgsl.expected.wgsl
new file mode 100644
index 0000000..98847cc
--- /dev/null
+++ b/test/tint/builtins/gen/literal/saturate/d55822.wgsl.expected.wgsl
@@ -0,0 +1,19 @@
+fn saturate_d55822() {
+  var res = saturate(vec3(2));
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  saturate_d55822();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  saturate_d55822();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  saturate_d55822();
+}
diff --git a/test/tint/builtins/gen/literal/saturate/dcde71.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/saturate/dcde71.wgsl.expected.dxc.hlsl
index 2520f59..23cb232 100644
--- a/test/tint/builtins/gen/literal/saturate/dcde71.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/saturate/dcde71.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
 void saturate_dcde71() {
-  vector<float16_t, 4> res = saturate((float16_t(0.0h)).xxxx);
+  vector<float16_t, 4> res = (float16_t(0.0h)).xxxx;
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/saturate/dcde71.wgsl.expected.msl b/test/tint/builtins/gen/literal/saturate/dcde71.wgsl.expected.msl
index 6bc8bf1..3dc2267 100644
--- a/test/tint/builtins/gen/literal/saturate/dcde71.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/saturate/dcde71.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void saturate_dcde71() {
-  half4 res = saturate(half4(0.0h));
+  half4 res = half4(0.0h);
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/saturate/e40fb6.wgsl b/test/tint/builtins/gen/literal/saturate/e40fb6.wgsl
new file mode 100644
index 0000000..f1e6275
--- /dev/null
+++ b/test/tint/builtins/gen/literal/saturate/e40fb6.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 saturate(vec<2, fa>) -> vec<2, fa>
+fn saturate_e40fb6() {
+  var res = saturate(vec2(2));
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  saturate_e40fb6();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  saturate_e40fb6();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  saturate_e40fb6();
+}
diff --git a/test/tint/builtins/gen/literal/saturate/e40fb6.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/saturate/e40fb6.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..1c81096
--- /dev/null
+++ b/test/tint/builtins/gen/literal/saturate/e40fb6.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void saturate_e40fb6() {
+  float2 res = (1.0f).xx;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  saturate_e40fb6();
+  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() {
+  saturate_e40fb6();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  saturate_e40fb6();
+  return;
+}
diff --git a/test/tint/builtins/gen/literal/saturate/e40fb6.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/saturate/e40fb6.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..1c81096
--- /dev/null
+++ b/test/tint/builtins/gen/literal/saturate/e40fb6.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void saturate_e40fb6() {
+  float2 res = (1.0f).xx;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  saturate_e40fb6();
+  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() {
+  saturate_e40fb6();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  saturate_e40fb6();
+  return;
+}
diff --git a/test/tint/builtins/gen/literal/saturate/e40fb6.wgsl.expected.glsl b/test/tint/builtins/gen/literal/saturate/e40fb6.wgsl.expected.glsl
new file mode 100644
index 0000000..950837f
--- /dev/null
+++ b/test/tint/builtins/gen/literal/saturate/e40fb6.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void saturate_e40fb6() {
+  vec2 res = vec2(1.0f);
+}
+
+vec4 vertex_main() {
+  saturate_e40fb6();
+  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 saturate_e40fb6() {
+  vec2 res = vec2(1.0f);
+}
+
+void fragment_main() {
+  saturate_e40fb6();
+}
+
+void main() {
+  fragment_main();
+  return;
+}
+#version 310 es
+
+void saturate_e40fb6() {
+  vec2 res = vec2(1.0f);
+}
+
+void compute_main() {
+  saturate_e40fb6();
+}
+
+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/saturate/e40fb6.wgsl.expected.msl b/test/tint/builtins/gen/literal/saturate/e40fb6.wgsl.expected.msl
new file mode 100644
index 0000000..0bb65ce
--- /dev/null
+++ b/test/tint/builtins/gen/literal/saturate/e40fb6.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void saturate_e40fb6() {
+  float2 res = float2(1.0f);
+}
+
+struct tint_symbol {
+  float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+  saturate_e40fb6();
+  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() {
+  saturate_e40fb6();
+  return;
+}
+
+kernel void compute_main() {
+  saturate_e40fb6();
+  return;
+}
+
diff --git a/test/tint/builtins/gen/literal/saturate/e40fb6.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/saturate/e40fb6.wgsl.expected.spvasm
new file mode 100644
index 0000000..770937a
--- /dev/null
+++ b/test/tint/builtins/gen/literal/saturate/e40fb6.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 %saturate_e40fb6 "saturate_e40fb6"
+               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
+%saturate_e40fb6 = 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 %saturate_e40fb6
+               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 %saturate_e40fb6
+               OpReturn
+               OpFunctionEnd
+%compute_main = OpFunction %void None %9
+         %30 = OpLabel
+         %31 = OpFunctionCall %void %saturate_e40fb6
+               OpReturn
+               OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/saturate/e40fb6.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/saturate/e40fb6.wgsl.expected.wgsl
new file mode 100644
index 0000000..b20c99e
--- /dev/null
+++ b/test/tint/builtins/gen/literal/saturate/e40fb6.wgsl.expected.wgsl
@@ -0,0 +1,19 @@
+fn saturate_e40fb6() {
+  var res = saturate(vec2(2));
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  saturate_e40fb6();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  saturate_e40fb6();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  saturate_e40fb6();
+}
diff --git a/test/tint/builtins/gen/literal/saturate/e8df56.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/saturate/e8df56.wgsl.expected.dxc.hlsl
index 661deaa..61c28d8 100644
--- a/test/tint/builtins/gen/literal/saturate/e8df56.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/saturate/e8df56.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
 void saturate_e8df56() {
-  float16_t res = saturate(float16_t(0.0h));
+  float16_t res = float16_t(0.0h);
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/saturate/e8df56.wgsl.expected.msl b/test/tint/builtins/gen/literal/saturate/e8df56.wgsl.expected.msl
index a2205c0..0219c63 100644
--- a/test/tint/builtins/gen/literal/saturate/e8df56.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/saturate/e8df56.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void saturate_e8df56() {
-  half res = saturate(0.0h);
+  half res = 0.0h;
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/var/saturate/270da5.wgsl b/test/tint/builtins/gen/var/saturate/270da5.wgsl
index 8b20b3d..84fe79d 100644
--- a/test/tint/builtins/gen/var/saturate/270da5.wgsl
+++ b/test/tint/builtins/gen/var/saturate/270da5.wgsl
@@ -23,7 +23,7 @@
 
 // fn saturate(f32) -> f32
 fn saturate_270da5() {
-  var arg_0 = 1.f;
+  var arg_0 = 2.f;
   var res: f32 = saturate(arg_0);
 }
 
diff --git a/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.dxc.hlsl
index 91ab783..1695ed7 100644
--- a/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
 void saturate_270da5() {
-  float arg_0 = 1.0f;
+  float arg_0 = 2.0f;
   float res = saturate(arg_0);
 }
 
diff --git a/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.fxc.hlsl
index 91ab783..1695ed7 100644
--- a/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.fxc.hlsl
@@ -1,5 +1,5 @@
 void saturate_270da5() {
-  float arg_0 = 1.0f;
+  float arg_0 = 2.0f;
   float res = saturate(arg_0);
 }
 
diff --git a/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.glsl b/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.glsl
index 83d9130..7a37078 100644
--- a/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.glsl
@@ -5,7 +5,7 @@
 }
 
 void saturate_270da5() {
-  float arg_0 = 1.0f;
+  float arg_0 = 2.0f;
   float res = tint_saturate(arg_0);
 }
 
@@ -30,7 +30,7 @@
 }
 
 void saturate_270da5() {
-  float arg_0 = 1.0f;
+  float arg_0 = 2.0f;
   float res = tint_saturate(arg_0);
 }
 
@@ -49,7 +49,7 @@
 }
 
 void saturate_270da5() {
-  float arg_0 = 1.0f;
+  float arg_0 = 2.0f;
   float res = tint_saturate(arg_0);
 }
 
diff --git a/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.msl b/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.msl
index f0d57ed..4d4aa56 100644
--- a/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.msl
+++ b/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void saturate_270da5() {
-  float arg_0 = 1.0f;
+  float arg_0 = 2.0f;
   float res = saturate(arg_0);
 }
 
diff --git a/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.spvasm b/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.spvasm
index 3524423..abfdea7 100644
--- a/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.spvasm
@@ -1,7 +1,7 @@
 ; SPIR-V
 ; Version: 1.3
 ; Generator: Google Tint Compiler; 0
-; Bound: 38
+; Bound: 39
 ; Schema: 0
                OpCapability Shader
          %14 = OpExtInstImport "GLSL.std.450"
@@ -36,8 +36,9 @@
     %float_1 = OpConstant %float 1
        %void = OpTypeVoid
          %16 = OpTypeFunction %void
+    %float_2 = OpConstant %float 2
 %_ptr_Function_float = OpTypePointer Function %float
-         %25 = OpTypeFunction %v4float
+         %26 = OpTypeFunction %v4float
 %tint_saturate = OpFunction %float None %9
           %v = OpFunctionParameter %float
          %12 = OpLabel
@@ -48,31 +49,31 @@
          %19 = OpLabel
       %arg_0 = OpVariable %_ptr_Function_float Function %8
         %res = OpVariable %_ptr_Function_float Function %8
-               OpStore %arg_0 %float_1
-         %23 = OpLoad %float %arg_0
-         %22 = OpFunctionCall %float %tint_saturate %23
-               OpStore %res %22
+               OpStore %arg_0 %float_2
+         %24 = OpLoad %float %arg_0
+         %23 = OpFunctionCall %float %tint_saturate %24
+               OpStore %res %23
                OpReturn
                OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %25
-         %27 = OpLabel
-         %28 = OpFunctionCall %void %saturate_270da5
+%vertex_main_inner = OpFunction %v4float None %26
+         %28 = OpLabel
+         %29 = OpFunctionCall %void %saturate_270da5
                OpReturnValue %5
                OpFunctionEnd
 %vertex_main = OpFunction %void None %16
-         %30 = OpLabel
-         %31 = OpFunctionCall %v4float %vertex_main_inner
-               OpStore %value %31
+         %31 = OpLabel
+         %32 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %32
                OpStore %vertex_point_size %float_1
                OpReturn
                OpFunctionEnd
 %fragment_main = OpFunction %void None %16
-         %33 = OpLabel
-         %34 = OpFunctionCall %void %saturate_270da5
+         %34 = OpLabel
+         %35 = OpFunctionCall %void %saturate_270da5
                OpReturn
                OpFunctionEnd
 %compute_main = OpFunction %void None %16
-         %36 = OpLabel
-         %37 = OpFunctionCall %void %saturate_270da5
+         %37 = OpLabel
+         %38 = OpFunctionCall %void %saturate_270da5
                OpReturn
                OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.wgsl b/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.wgsl
index 8a4117e..4012b51 100644
--- a/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/saturate/270da5.wgsl.expected.wgsl
@@ -1,5 +1,5 @@
 fn saturate_270da5() {
-  var arg_0 = 1.0f;
+  var arg_0 = 2.0f;
   var res : f32 = saturate(arg_0);
 }
 
diff --git a/test/tint/builtins/gen/var/saturate/4ed8d7.wgsl b/test/tint/builtins/gen/var/saturate/4ed8d7.wgsl
new file mode 100644
index 0000000..ceb9904
--- /dev/null
+++ b/test/tint/builtins/gen/var/saturate/4ed8d7.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 saturate(vec<4, fa>) -> vec<4, fa>
+fn saturate_4ed8d7() {
+  const arg_0 = vec4(2);
+  var res = saturate(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  saturate_4ed8d7();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  saturate_4ed8d7();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  saturate_4ed8d7();
+}
diff --git a/test/tint/builtins/gen/var/saturate/4ed8d7.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/saturate/4ed8d7.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..6bafa64
--- /dev/null
+++ b/test/tint/builtins/gen/var/saturate/4ed8d7.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void saturate_4ed8d7() {
+  float4 res = (1.0f).xxxx;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  saturate_4ed8d7();
+  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() {
+  saturate_4ed8d7();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  saturate_4ed8d7();
+  return;
+}
diff --git a/test/tint/builtins/gen/var/saturate/4ed8d7.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/saturate/4ed8d7.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..6bafa64
--- /dev/null
+++ b/test/tint/builtins/gen/var/saturate/4ed8d7.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void saturate_4ed8d7() {
+  float4 res = (1.0f).xxxx;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  saturate_4ed8d7();
+  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() {
+  saturate_4ed8d7();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  saturate_4ed8d7();
+  return;
+}
diff --git a/test/tint/builtins/gen/var/saturate/4ed8d7.wgsl.expected.glsl b/test/tint/builtins/gen/var/saturate/4ed8d7.wgsl.expected.glsl
new file mode 100644
index 0000000..e6bfa97
--- /dev/null
+++ b/test/tint/builtins/gen/var/saturate/4ed8d7.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void saturate_4ed8d7() {
+  vec4 res = vec4(1.0f);
+}
+
+vec4 vertex_main() {
+  saturate_4ed8d7();
+  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 saturate_4ed8d7() {
+  vec4 res = vec4(1.0f);
+}
+
+void fragment_main() {
+  saturate_4ed8d7();
+}
+
+void main() {
+  fragment_main();
+  return;
+}
+#version 310 es
+
+void saturate_4ed8d7() {
+  vec4 res = vec4(1.0f);
+}
+
+void compute_main() {
+  saturate_4ed8d7();
+}
+
+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/saturate/4ed8d7.wgsl.expected.msl b/test/tint/builtins/gen/var/saturate/4ed8d7.wgsl.expected.msl
new file mode 100644
index 0000000..f6dfde6
--- /dev/null
+++ b/test/tint/builtins/gen/var/saturate/4ed8d7.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void saturate_4ed8d7() {
+  float4 res = float4(1.0f);
+}
+
+struct tint_symbol {
+  float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+  saturate_4ed8d7();
+  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() {
+  saturate_4ed8d7();
+  return;
+}
+
+kernel void compute_main() {
+  saturate_4ed8d7();
+  return;
+}
+
diff --git a/test/tint/builtins/gen/var/saturate/4ed8d7.wgsl.expected.spvasm b/test/tint/builtins/gen/var/saturate/4ed8d7.wgsl.expected.spvasm
new file mode 100644
index 0000000..91bfee1
--- /dev/null
+++ b/test/tint/builtins/gen/var/saturate/4ed8d7.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 %saturate_4ed8d7 "saturate_4ed8d7"
+               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
+%saturate_4ed8d7 = 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 %saturate_4ed8d7
+               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 %saturate_4ed8d7
+               OpReturn
+               OpFunctionEnd
+%compute_main = OpFunction %void None %9
+         %28 = OpLabel
+         %29 = OpFunctionCall %void %saturate_4ed8d7
+               OpReturn
+               OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/saturate/4ed8d7.wgsl.expected.wgsl b/test/tint/builtins/gen/var/saturate/4ed8d7.wgsl.expected.wgsl
new file mode 100644
index 0000000..c5f28e8
--- /dev/null
+++ b/test/tint/builtins/gen/var/saturate/4ed8d7.wgsl.expected.wgsl
@@ -0,0 +1,20 @@
+fn saturate_4ed8d7() {
+  const arg_0 = vec4(2);
+  var res = saturate(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  saturate_4ed8d7();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  saturate_4ed8d7();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  saturate_4ed8d7();
+}
diff --git a/test/tint/builtins/gen/var/saturate/51567f.wgsl b/test/tint/builtins/gen/var/saturate/51567f.wgsl
index a63ec45..8479f08 100644
--- a/test/tint/builtins/gen/var/saturate/51567f.wgsl
+++ b/test/tint/builtins/gen/var/saturate/51567f.wgsl
@@ -23,7 +23,7 @@
 
 // fn saturate(vec<2, f32>) -> vec<2, f32>
 fn saturate_51567f() {
-  var arg_0 = vec2<f32>(1.f);
+  var arg_0 = vec2<f32>(2.f);
   var res: vec2<f32> = saturate(arg_0);
 }
 
diff --git a/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.dxc.hlsl
index bfa6819..1f65313 100644
--- a/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
 void saturate_51567f() {
-  float2 arg_0 = (1.0f).xx;
+  float2 arg_0 = (2.0f).xx;
   float2 res = saturate(arg_0);
 }
 
diff --git a/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.fxc.hlsl
index bfa6819..1f65313 100644
--- a/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.fxc.hlsl
@@ -1,5 +1,5 @@
 void saturate_51567f() {
-  float2 arg_0 = (1.0f).xx;
+  float2 arg_0 = (2.0f).xx;
   float2 res = saturate(arg_0);
 }
 
diff --git a/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.glsl b/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.glsl
index d833b9f..fb43f00 100644
--- a/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.glsl
@@ -5,7 +5,7 @@
 }
 
 void saturate_51567f() {
-  vec2 arg_0 = vec2(1.0f);
+  vec2 arg_0 = vec2(2.0f);
   vec2 res = tint_saturate(arg_0);
 }
 
@@ -30,7 +30,7 @@
 }
 
 void saturate_51567f() {
-  vec2 arg_0 = vec2(1.0f);
+  vec2 arg_0 = vec2(2.0f);
   vec2 res = tint_saturate(arg_0);
 }
 
@@ -49,7 +49,7 @@
 }
 
 void saturate_51567f() {
-  vec2 arg_0 = vec2(1.0f);
+  vec2 arg_0 = vec2(2.0f);
   vec2 res = tint_saturate(arg_0);
 }
 
diff --git a/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.msl b/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.msl
index 78cac48..e21f23d 100644
--- a/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.msl
+++ b/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void saturate_51567f() {
-  float2 arg_0 = float2(1.0f);
+  float2 arg_0 = float2(2.0f);
   float2 res = saturate(arg_0);
 }
 
diff --git a/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.spvasm b/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.spvasm
index b81fab6..968e7e7 100644
--- a/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.spvasm
@@ -1,7 +1,7 @@
 ; SPIR-V
 ; Version: 1.3
 ; Generator: Google Tint Compiler; 0
-; Bound: 41
+; Bound: 43
 ; Schema: 0
                OpCapability Shader
          %15 = OpExtInstImport "GLSL.std.450"
@@ -39,8 +39,10 @@
          %18 = OpConstantComposite %v2float %float_1 %float_1
        %void = OpTypeVoid
          %19 = OpTypeFunction %void
+    %float_2 = OpConstant %float 2
+         %24 = OpConstantComposite %v2float %float_2 %float_2
 %_ptr_Function_v2float = OpTypePointer Function %v2float
-         %28 = OpTypeFunction %v4float
+         %30 = OpTypeFunction %v4float
 %tint_saturate = OpFunction %v2float None %9
           %v = OpFunctionParameter %v2float
          %13 = OpLabel
@@ -51,31 +53,31 @@
          %22 = OpLabel
       %arg_0 = OpVariable %_ptr_Function_v2float Function %16
         %res = OpVariable %_ptr_Function_v2float Function %16
-               OpStore %arg_0 %18
-         %26 = OpLoad %v2float %arg_0
-         %25 = OpFunctionCall %v2float %tint_saturate %26
-               OpStore %res %25
+               OpStore %arg_0 %24
+         %28 = OpLoad %v2float %arg_0
+         %27 = OpFunctionCall %v2float %tint_saturate %28
+               OpStore %res %27
                OpReturn
                OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %28
-         %30 = OpLabel
-         %31 = OpFunctionCall %void %saturate_51567f
+%vertex_main_inner = OpFunction %v4float None %30
+         %32 = OpLabel
+         %33 = OpFunctionCall %void %saturate_51567f
                OpReturnValue %5
                OpFunctionEnd
 %vertex_main = OpFunction %void None %19
-         %33 = OpLabel
-         %34 = OpFunctionCall %v4float %vertex_main_inner
-               OpStore %value %34
+         %35 = OpLabel
+         %36 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %36
                OpStore %vertex_point_size %float_1
                OpReturn
                OpFunctionEnd
 %fragment_main = OpFunction %void None %19
-         %36 = OpLabel
-         %37 = OpFunctionCall %void %saturate_51567f
+         %38 = OpLabel
+         %39 = OpFunctionCall %void %saturate_51567f
                OpReturn
                OpFunctionEnd
 %compute_main = OpFunction %void None %19
-         %39 = OpLabel
-         %40 = OpFunctionCall %void %saturate_51567f
+         %41 = OpLabel
+         %42 = OpFunctionCall %void %saturate_51567f
                OpReturn
                OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.wgsl b/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.wgsl
index a860d88..8668958 100644
--- a/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/saturate/51567f.wgsl.expected.wgsl
@@ -1,5 +1,5 @@
 fn saturate_51567f() {
-  var arg_0 = vec2<f32>(1.0f);
+  var arg_0 = vec2<f32>(2.0f);
   var res : vec2<f32> = saturate(arg_0);
 }
 
diff --git a/test/tint/builtins/gen/var/saturate/6bcddf.wgsl b/test/tint/builtins/gen/var/saturate/6bcddf.wgsl
index 4887b30..ddd305c 100644
--- a/test/tint/builtins/gen/var/saturate/6bcddf.wgsl
+++ b/test/tint/builtins/gen/var/saturate/6bcddf.wgsl
@@ -23,7 +23,7 @@
 
 // fn saturate(vec<3, f32>) -> vec<3, f32>
 fn saturate_6bcddf() {
-  var arg_0 = vec3<f32>(1.f);
+  var arg_0 = vec3<f32>(2.f);
   var res: vec3<f32> = saturate(arg_0);
 }
 
diff --git a/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.dxc.hlsl
index d787b33..80587b0 100644
--- a/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
 void saturate_6bcddf() {
-  float3 arg_0 = (1.0f).xxx;
+  float3 arg_0 = (2.0f).xxx;
   float3 res = saturate(arg_0);
 }
 
diff --git a/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.fxc.hlsl
index d787b33..80587b0 100644
--- a/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.fxc.hlsl
@@ -1,5 +1,5 @@
 void saturate_6bcddf() {
-  float3 arg_0 = (1.0f).xxx;
+  float3 arg_0 = (2.0f).xxx;
   float3 res = saturate(arg_0);
 }
 
diff --git a/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.glsl b/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.glsl
index 1371097..a797e12 100644
--- a/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.glsl
@@ -5,7 +5,7 @@
 }
 
 void saturate_6bcddf() {
-  vec3 arg_0 = vec3(1.0f);
+  vec3 arg_0 = vec3(2.0f);
   vec3 res = tint_saturate(arg_0);
 }
 
@@ -30,7 +30,7 @@
 }
 
 void saturate_6bcddf() {
-  vec3 arg_0 = vec3(1.0f);
+  vec3 arg_0 = vec3(2.0f);
   vec3 res = tint_saturate(arg_0);
 }
 
@@ -49,7 +49,7 @@
 }
 
 void saturate_6bcddf() {
-  vec3 arg_0 = vec3(1.0f);
+  vec3 arg_0 = vec3(2.0f);
   vec3 res = tint_saturate(arg_0);
 }
 
diff --git a/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.msl b/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.msl
index 328dfcc..8aa26cf 100644
--- a/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.msl
+++ b/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void saturate_6bcddf() {
-  float3 arg_0 = float3(1.0f);
+  float3 arg_0 = float3(2.0f);
   float3 res = saturate(arg_0);
 }
 
diff --git a/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.spvasm b/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.spvasm
index ff3726e..1d5b452 100644
--- a/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.spvasm
@@ -1,7 +1,7 @@
 ; SPIR-V
 ; Version: 1.3
 ; Generator: Google Tint Compiler; 0
-; Bound: 41
+; Bound: 43
 ; Schema: 0
                OpCapability Shader
          %15 = OpExtInstImport "GLSL.std.450"
@@ -39,8 +39,10 @@
          %18 = OpConstantComposite %v3float %float_1 %float_1 %float_1
        %void = OpTypeVoid
          %19 = OpTypeFunction %void
+    %float_2 = OpConstant %float 2
+         %24 = OpConstantComposite %v3float %float_2 %float_2 %float_2
 %_ptr_Function_v3float = OpTypePointer Function %v3float
-         %28 = OpTypeFunction %v4float
+         %30 = OpTypeFunction %v4float
 %tint_saturate = OpFunction %v3float None %9
           %v = OpFunctionParameter %v3float
          %13 = OpLabel
@@ -51,31 +53,31 @@
          %22 = OpLabel
       %arg_0 = OpVariable %_ptr_Function_v3float Function %16
         %res = OpVariable %_ptr_Function_v3float Function %16
-               OpStore %arg_0 %18
-         %26 = OpLoad %v3float %arg_0
-         %25 = OpFunctionCall %v3float %tint_saturate %26
-               OpStore %res %25
+               OpStore %arg_0 %24
+         %28 = OpLoad %v3float %arg_0
+         %27 = OpFunctionCall %v3float %tint_saturate %28
+               OpStore %res %27
                OpReturn
                OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %28
-         %30 = OpLabel
-         %31 = OpFunctionCall %void %saturate_6bcddf
+%vertex_main_inner = OpFunction %v4float None %30
+         %32 = OpLabel
+         %33 = OpFunctionCall %void %saturate_6bcddf
                OpReturnValue %5
                OpFunctionEnd
 %vertex_main = OpFunction %void None %19
-         %33 = OpLabel
-         %34 = OpFunctionCall %v4float %vertex_main_inner
-               OpStore %value %34
+         %35 = OpLabel
+         %36 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %36
                OpStore %vertex_point_size %float_1
                OpReturn
                OpFunctionEnd
 %fragment_main = OpFunction %void None %19
-         %36 = OpLabel
-         %37 = OpFunctionCall %void %saturate_6bcddf
+         %38 = OpLabel
+         %39 = OpFunctionCall %void %saturate_6bcddf
                OpReturn
                OpFunctionEnd
 %compute_main = OpFunction %void None %19
-         %39 = OpLabel
-         %40 = OpFunctionCall %void %saturate_6bcddf
+         %41 = OpLabel
+         %42 = OpFunctionCall %void %saturate_6bcddf
                OpReturn
                OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.wgsl b/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.wgsl
index 81b2bc1..e34311a 100644
--- a/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/saturate/6bcddf.wgsl.expected.wgsl
@@ -1,5 +1,5 @@
 fn saturate_6bcddf() {
-  var arg_0 = vec3<f32>(1.0f);
+  var arg_0 = vec3<f32>(2.0f);
   var res : vec3<f32> = saturate(arg_0);
 }
 
diff --git a/test/tint/builtins/gen/var/saturate/78b37c.wgsl b/test/tint/builtins/gen/var/saturate/78b37c.wgsl
new file mode 100644
index 0000000..ab9e117
--- /dev/null
+++ b/test/tint/builtins/gen/var/saturate/78b37c.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 saturate(fa) -> fa
+fn saturate_78b37c() {
+  const arg_0 = 2;
+  var res = saturate(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  saturate_78b37c();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  saturate_78b37c();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  saturate_78b37c();
+}
diff --git a/test/tint/builtins/gen/var/saturate/78b37c.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/saturate/78b37c.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..68051b6
--- /dev/null
+++ b/test/tint/builtins/gen/var/saturate/78b37c.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void saturate_78b37c() {
+  float res = 1.0f;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  saturate_78b37c();
+  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() {
+  saturate_78b37c();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  saturate_78b37c();
+  return;
+}
diff --git a/test/tint/builtins/gen/var/saturate/78b37c.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/saturate/78b37c.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..68051b6
--- /dev/null
+++ b/test/tint/builtins/gen/var/saturate/78b37c.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void saturate_78b37c() {
+  float res = 1.0f;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  saturate_78b37c();
+  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() {
+  saturate_78b37c();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  saturate_78b37c();
+  return;
+}
diff --git a/test/tint/builtins/gen/var/saturate/78b37c.wgsl.expected.glsl b/test/tint/builtins/gen/var/saturate/78b37c.wgsl.expected.glsl
new file mode 100644
index 0000000..e660571
--- /dev/null
+++ b/test/tint/builtins/gen/var/saturate/78b37c.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void saturate_78b37c() {
+  float res = 1.0f;
+}
+
+vec4 vertex_main() {
+  saturate_78b37c();
+  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 saturate_78b37c() {
+  float res = 1.0f;
+}
+
+void fragment_main() {
+  saturate_78b37c();
+}
+
+void main() {
+  fragment_main();
+  return;
+}
+#version 310 es
+
+void saturate_78b37c() {
+  float res = 1.0f;
+}
+
+void compute_main() {
+  saturate_78b37c();
+}
+
+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/saturate/78b37c.wgsl.expected.msl b/test/tint/builtins/gen/var/saturate/78b37c.wgsl.expected.msl
new file mode 100644
index 0000000..4619ba0
--- /dev/null
+++ b/test/tint/builtins/gen/var/saturate/78b37c.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void saturate_78b37c() {
+  float res = 1.0f;
+}
+
+struct tint_symbol {
+  float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+  saturate_78b37c();
+  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() {
+  saturate_78b37c();
+  return;
+}
+
+kernel void compute_main() {
+  saturate_78b37c();
+  return;
+}
+
diff --git a/test/tint/builtins/gen/var/saturate/78b37c.wgsl.expected.spvasm b/test/tint/builtins/gen/var/saturate/78b37c.wgsl.expected.spvasm
new file mode 100644
index 0000000..5b55286
--- /dev/null
+++ b/test/tint/builtins/gen/var/saturate/78b37c.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 %saturate_78b37c "saturate_78b37c"
+               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
+%saturate_78b37c = 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 %saturate_78b37c
+               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 %saturate_78b37c
+               OpReturn
+               OpFunctionEnd
+%compute_main = OpFunction %void None %9
+         %27 = OpLabel
+         %28 = OpFunctionCall %void %saturate_78b37c
+               OpReturn
+               OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/saturate/78b37c.wgsl.expected.wgsl b/test/tint/builtins/gen/var/saturate/78b37c.wgsl.expected.wgsl
new file mode 100644
index 0000000..a12f95e
--- /dev/null
+++ b/test/tint/builtins/gen/var/saturate/78b37c.wgsl.expected.wgsl
@@ -0,0 +1,20 @@
+fn saturate_78b37c() {
+  const arg_0 = 2;
+  var res = saturate(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  saturate_78b37c();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  saturate_78b37c();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  saturate_78b37c();
+}
diff --git a/test/tint/builtins/gen/var/saturate/a5b571.wgsl b/test/tint/builtins/gen/var/saturate/a5b571.wgsl
index 12221dc..b8265af 100644
--- a/test/tint/builtins/gen/var/saturate/a5b571.wgsl
+++ b/test/tint/builtins/gen/var/saturate/a5b571.wgsl
@@ -23,7 +23,7 @@
 
 // fn saturate(vec<4, f32>) -> vec<4, f32>
 fn saturate_a5b571() {
-  var arg_0 = vec4<f32>(1.f);
+  var arg_0 = vec4<f32>(2.f);
   var res: vec4<f32> = saturate(arg_0);
 }
 
diff --git a/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.dxc.hlsl
index 3bd74c0..ab8cf85 100644
--- a/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
 void saturate_a5b571() {
-  float4 arg_0 = (1.0f).xxxx;
+  float4 arg_0 = (2.0f).xxxx;
   float4 res = saturate(arg_0);
 }
 
diff --git a/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.fxc.hlsl
index 3bd74c0..ab8cf85 100644
--- a/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.fxc.hlsl
@@ -1,5 +1,5 @@
 void saturate_a5b571() {
-  float4 arg_0 = (1.0f).xxxx;
+  float4 arg_0 = (2.0f).xxxx;
   float4 res = saturate(arg_0);
 }
 
diff --git a/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.glsl b/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.glsl
index f90dc80..89b06af 100644
--- a/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.glsl
@@ -5,7 +5,7 @@
 }
 
 void saturate_a5b571() {
-  vec4 arg_0 = vec4(1.0f);
+  vec4 arg_0 = vec4(2.0f);
   vec4 res = tint_saturate(arg_0);
 }
 
@@ -30,7 +30,7 @@
 }
 
 void saturate_a5b571() {
-  vec4 arg_0 = vec4(1.0f);
+  vec4 arg_0 = vec4(2.0f);
   vec4 res = tint_saturate(arg_0);
 }
 
@@ -49,7 +49,7 @@
 }
 
 void saturate_a5b571() {
-  vec4 arg_0 = vec4(1.0f);
+  vec4 arg_0 = vec4(2.0f);
   vec4 res = tint_saturate(arg_0);
 }
 
diff --git a/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.msl b/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.msl
index dc1a973..24f08fd 100644
--- a/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.msl
+++ b/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void saturate_a5b571() {
-  float4 arg_0 = float4(1.0f);
+  float4 arg_0 = float4(2.0f);
   float4 res = saturate(arg_0);
 }
 
diff --git a/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.spvasm b/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.spvasm
index 9b99538..866662f 100644
--- a/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.spvasm
@@ -1,7 +1,7 @@
 ; SPIR-V
 ; Version: 1.3
 ; Generator: Google Tint Compiler; 0
-; Bound: 39
+; Bound: 41
 ; Schema: 0
                OpCapability Shader
          %14 = OpExtInstImport "GLSL.std.450"
@@ -37,8 +37,10 @@
          %16 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
        %void = OpTypeVoid
          %17 = OpTypeFunction %void
+    %float_2 = OpConstant %float 2
+         %22 = OpConstantComposite %v4float %float_2 %float_2 %float_2 %float_2
 %_ptr_Function_v4float = OpTypePointer Function %v4float
-         %26 = OpTypeFunction %v4float
+         %28 = OpTypeFunction %v4float
 %tint_saturate = OpFunction %v4float None %9
           %v = OpFunctionParameter %v4float
          %12 = OpLabel
@@ -49,31 +51,31 @@
          %20 = OpLabel
       %arg_0 = OpVariable %_ptr_Function_v4float Function %5
         %res = OpVariable %_ptr_Function_v4float Function %5
-               OpStore %arg_0 %16
-         %24 = OpLoad %v4float %arg_0
-         %23 = OpFunctionCall %v4float %tint_saturate %24
-               OpStore %res %23
+               OpStore %arg_0 %22
+         %26 = OpLoad %v4float %arg_0
+         %25 = OpFunctionCall %v4float %tint_saturate %26
+               OpStore %res %25
                OpReturn
                OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %26
-         %28 = OpLabel
-         %29 = OpFunctionCall %void %saturate_a5b571
+%vertex_main_inner = OpFunction %v4float None %28
+         %30 = OpLabel
+         %31 = OpFunctionCall %void %saturate_a5b571
                OpReturnValue %5
                OpFunctionEnd
 %vertex_main = OpFunction %void None %17
-         %31 = OpLabel
-         %32 = OpFunctionCall %v4float %vertex_main_inner
-               OpStore %value %32
+         %33 = OpLabel
+         %34 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %34
                OpStore %vertex_point_size %float_1
                OpReturn
                OpFunctionEnd
 %fragment_main = OpFunction %void None %17
-         %34 = OpLabel
-         %35 = OpFunctionCall %void %saturate_a5b571
+         %36 = OpLabel
+         %37 = OpFunctionCall %void %saturate_a5b571
                OpReturn
                OpFunctionEnd
 %compute_main = OpFunction %void None %17
-         %37 = OpLabel
-         %38 = OpFunctionCall %void %saturate_a5b571
+         %39 = OpLabel
+         %40 = OpFunctionCall %void %saturate_a5b571
                OpReturn
                OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.wgsl b/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.wgsl
index 671c764..db30eba 100644
--- a/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/saturate/a5b571.wgsl.expected.wgsl
@@ -1,5 +1,5 @@
 fn saturate_a5b571() {
-  var arg_0 = vec4<f32>(1.0f);
+  var arg_0 = vec4<f32>(2.0f);
   var res : vec4<f32> = saturate(arg_0);
 }
 
diff --git a/test/tint/builtins/gen/var/saturate/d55822.wgsl b/test/tint/builtins/gen/var/saturate/d55822.wgsl
new file mode 100644
index 0000000..2a419d4
--- /dev/null
+++ b/test/tint/builtins/gen/var/saturate/d55822.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 saturate(vec<3, fa>) -> vec<3, fa>
+fn saturate_d55822() {
+  const arg_0 = vec3(2);
+  var res = saturate(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  saturate_d55822();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  saturate_d55822();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  saturate_d55822();
+}
diff --git a/test/tint/builtins/gen/var/saturate/d55822.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/saturate/d55822.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..8121744
--- /dev/null
+++ b/test/tint/builtins/gen/var/saturate/d55822.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void saturate_d55822() {
+  float3 res = (1.0f).xxx;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  saturate_d55822();
+  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() {
+  saturate_d55822();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  saturate_d55822();
+  return;
+}
diff --git a/test/tint/builtins/gen/var/saturate/d55822.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/saturate/d55822.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..8121744
--- /dev/null
+++ b/test/tint/builtins/gen/var/saturate/d55822.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void saturate_d55822() {
+  float3 res = (1.0f).xxx;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  saturate_d55822();
+  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() {
+  saturate_d55822();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  saturate_d55822();
+  return;
+}
diff --git a/test/tint/builtins/gen/var/saturate/d55822.wgsl.expected.glsl b/test/tint/builtins/gen/var/saturate/d55822.wgsl.expected.glsl
new file mode 100644
index 0000000..499d488
--- /dev/null
+++ b/test/tint/builtins/gen/var/saturate/d55822.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void saturate_d55822() {
+  vec3 res = vec3(1.0f);
+}
+
+vec4 vertex_main() {
+  saturate_d55822();
+  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 saturate_d55822() {
+  vec3 res = vec3(1.0f);
+}
+
+void fragment_main() {
+  saturate_d55822();
+}
+
+void main() {
+  fragment_main();
+  return;
+}
+#version 310 es
+
+void saturate_d55822() {
+  vec3 res = vec3(1.0f);
+}
+
+void compute_main() {
+  saturate_d55822();
+}
+
+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/saturate/d55822.wgsl.expected.msl b/test/tint/builtins/gen/var/saturate/d55822.wgsl.expected.msl
new file mode 100644
index 0000000..40857e4
--- /dev/null
+++ b/test/tint/builtins/gen/var/saturate/d55822.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void saturate_d55822() {
+  float3 res = float3(1.0f);
+}
+
+struct tint_symbol {
+  float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+  saturate_d55822();
+  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() {
+  saturate_d55822();
+  return;
+}
+
+kernel void compute_main() {
+  saturate_d55822();
+  return;
+}
+
diff --git a/test/tint/builtins/gen/var/saturate/d55822.wgsl.expected.spvasm b/test/tint/builtins/gen/var/saturate/d55822.wgsl.expected.spvasm
new file mode 100644
index 0000000..575588d
--- /dev/null
+++ b/test/tint/builtins/gen/var/saturate/d55822.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 %saturate_d55822 "saturate_d55822"
+               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
+%saturate_d55822 = 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 %saturate_d55822
+               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 %saturate_d55822
+               OpReturn
+               OpFunctionEnd
+%compute_main = OpFunction %void None %9
+         %30 = OpLabel
+         %31 = OpFunctionCall %void %saturate_d55822
+               OpReturn
+               OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/saturate/d55822.wgsl.expected.wgsl b/test/tint/builtins/gen/var/saturate/d55822.wgsl.expected.wgsl
new file mode 100644
index 0000000..ba4c878
--- /dev/null
+++ b/test/tint/builtins/gen/var/saturate/d55822.wgsl.expected.wgsl
@@ -0,0 +1,20 @@
+fn saturate_d55822() {
+  const arg_0 = vec3(2);
+  var res = saturate(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  saturate_d55822();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  saturate_d55822();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  saturate_d55822();
+}
diff --git a/test/tint/builtins/gen/var/saturate/e40fb6.wgsl b/test/tint/builtins/gen/var/saturate/e40fb6.wgsl
new file mode 100644
index 0000000..a0e9e91
--- /dev/null
+++ b/test/tint/builtins/gen/var/saturate/e40fb6.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 saturate(vec<2, fa>) -> vec<2, fa>
+fn saturate_e40fb6() {
+  const arg_0 = vec2(2);
+  var res = saturate(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  saturate_e40fb6();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  saturate_e40fb6();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  saturate_e40fb6();
+}
diff --git a/test/tint/builtins/gen/var/saturate/e40fb6.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/saturate/e40fb6.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..1c81096
--- /dev/null
+++ b/test/tint/builtins/gen/var/saturate/e40fb6.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void saturate_e40fb6() {
+  float2 res = (1.0f).xx;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  saturate_e40fb6();
+  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() {
+  saturate_e40fb6();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  saturate_e40fb6();
+  return;
+}
diff --git a/test/tint/builtins/gen/var/saturate/e40fb6.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/saturate/e40fb6.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..1c81096
--- /dev/null
+++ b/test/tint/builtins/gen/var/saturate/e40fb6.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void saturate_e40fb6() {
+  float2 res = (1.0f).xx;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  saturate_e40fb6();
+  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() {
+  saturate_e40fb6();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  saturate_e40fb6();
+  return;
+}
diff --git a/test/tint/builtins/gen/var/saturate/e40fb6.wgsl.expected.glsl b/test/tint/builtins/gen/var/saturate/e40fb6.wgsl.expected.glsl
new file mode 100644
index 0000000..950837f
--- /dev/null
+++ b/test/tint/builtins/gen/var/saturate/e40fb6.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void saturate_e40fb6() {
+  vec2 res = vec2(1.0f);
+}
+
+vec4 vertex_main() {
+  saturate_e40fb6();
+  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 saturate_e40fb6() {
+  vec2 res = vec2(1.0f);
+}
+
+void fragment_main() {
+  saturate_e40fb6();
+}
+
+void main() {
+  fragment_main();
+  return;
+}
+#version 310 es
+
+void saturate_e40fb6() {
+  vec2 res = vec2(1.0f);
+}
+
+void compute_main() {
+  saturate_e40fb6();
+}
+
+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/saturate/e40fb6.wgsl.expected.msl b/test/tint/builtins/gen/var/saturate/e40fb6.wgsl.expected.msl
new file mode 100644
index 0000000..0bb65ce
--- /dev/null
+++ b/test/tint/builtins/gen/var/saturate/e40fb6.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void saturate_e40fb6() {
+  float2 res = float2(1.0f);
+}
+
+struct tint_symbol {
+  float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+  saturate_e40fb6();
+  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() {
+  saturate_e40fb6();
+  return;
+}
+
+kernel void compute_main() {
+  saturate_e40fb6();
+  return;
+}
+
diff --git a/test/tint/builtins/gen/var/saturate/e40fb6.wgsl.expected.spvasm b/test/tint/builtins/gen/var/saturate/e40fb6.wgsl.expected.spvasm
new file mode 100644
index 0000000..770937a
--- /dev/null
+++ b/test/tint/builtins/gen/var/saturate/e40fb6.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 %saturate_e40fb6 "saturate_e40fb6"
+               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
+%saturate_e40fb6 = 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 %saturate_e40fb6
+               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 %saturate_e40fb6
+               OpReturn
+               OpFunctionEnd
+%compute_main = OpFunction %void None %9
+         %30 = OpLabel
+         %31 = OpFunctionCall %void %saturate_e40fb6
+               OpReturn
+               OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/saturate/e40fb6.wgsl.expected.wgsl b/test/tint/builtins/gen/var/saturate/e40fb6.wgsl.expected.wgsl
new file mode 100644
index 0000000..2cf5cdd
--- /dev/null
+++ b/test/tint/builtins/gen/var/saturate/e40fb6.wgsl.expected.wgsl
@@ -0,0 +1,20 @@
+fn saturate_e40fb6() {
+  const arg_0 = vec2(2);
+  var res = saturate(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  saturate_e40fb6();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  saturate_e40fb6();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  saturate_e40fb6();
+}