Add const-eval for `log` and `log2`.

This CL adds const-eval routines for `log` and `log2`.

Bug: tint:1581
Change-Id: I052b5ddd3bc8bdcd7c0925fa7912dcbe1a60e299
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/111323
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
diff --git a/src/tint/intrinsics.def b/src/tint/intrinsics.def
index 7d81bf9..9b42919 100644
--- a/src/tint/intrinsics.def
+++ b/src/tint/intrinsics.def
@@ -493,10 +493,10 @@
 fn ldexp<N: num, T: f32_f16>(vec<N, T>, vec<N, i32>) -> vec<N, T>
 @const fn length<T: fa_f32_f16>(@test_value(0.0) T) -> T
 @const fn length<N: num, T: fa_f32_f16>(@test_value(0.0) vec<N, T>) -> T
-fn log<T: f32_f16>(T) -> T
-fn log<N: num, T: f32_f16>(vec<N, T>) -> vec<N, T>
-fn log2<T: f32_f16>(T) -> T
-fn log2<N: num, T: f32_f16>(vec<N, T>) -> vec<N, T>
+@const fn log<T: fa_f32_f16>(T) -> T
+@const fn log<N: num, T: fa_f32_f16>(vec<N, T>) -> vec<N, T>
+@const fn log2<T: fa_f32_f16>(T) -> T
+@const fn log2<N: num, T: fa_f32_f16>(vec<N, T>) -> vec<N, T>
 @const fn max<T: fia_fiu32_f16>(T, T) -> T
 @const fn max<N: num, T: fia_fiu32_f16>(vec<N, T>, vec<N, T>) -> vec<N, T>
 @const fn min<T: fia_fiu32_f16>(T, T) -> T
diff --git a/src/tint/resolver/builtins_validation_test.cc b/src/tint/resolver/builtins_validation_test.cc
index 675ff49..c0452ce 100644
--- a/src/tint/resolver/builtins_validation_test.cc
+++ b/src/tint/resolver/builtins_validation_test.cc
@@ -1099,7 +1099,7 @@
 
     utils::Vector<const ast::Expression*, 8> params;
     for (uint32_t i = 0; i < num_params; ++i) {
-        params.Push(Expr(f32(i)));
+        params.Push(Expr(f32(i + 1)));
     }
     auto* builtin = Call(name, params);
     Func("func", utils::Empty, ty.void_(),
@@ -1120,7 +1120,7 @@
 
     utils::Vector<const ast::Expression*, 8> params;
     for (uint32_t i = 0; i < num_params; ++i) {
-        params.Push(vec2<f32>(f32(i), f32(i)));
+        params.Push(vec2<f32>(f32(i + 1), f32(i + 1)));
     }
     auto* builtin = Call(name, params);
     Func("func", utils::Empty, ty.void_(),
@@ -1141,7 +1141,7 @@
 
     utils::Vector<const ast::Expression*, 8> params;
     for (uint32_t i = 0; i < num_params; ++i) {
-        params.Push(vec3<f32>(f32(i), f32(i), f32(i)));
+        params.Push(vec3<f32>(f32(i + 1), f32(i + 1), f32(i + 1)));
     }
     auto* builtin = Call(name, params);
     Func("func", utils::Empty, ty.void_(),
@@ -1162,7 +1162,7 @@
 
     utils::Vector<const ast::Expression*, 8> params;
     for (uint32_t i = 0; i < num_params; ++i) {
-        params.Push(vec4<f32>(f32(i), f32(i), f32(i), f32(i)));
+        params.Push(vec4<f32>(f32(i + 1), f32(i + 1), f32(i + 1), f32(i + 1)));
     }
     auto* builtin = Call(name, params);
     Func("func", utils::Empty, ty.void_(),
diff --git a/src/tint/resolver/const_eval.cc b/src/tint/resolver/const_eval.cc
index f3cbc9d..4b365fe 100644
--- a/src/tint/resolver/const_eval.cc
+++ b/src/tint/resolver/const_eval.cc
@@ -2300,6 +2300,40 @@
     return r;
 }
 
+ConstEval::Result ConstEval::log(const sem::Type* ty,
+                                 utils::VectorRef<const sem::Constant*> args,
+                                 const Source& source) {
+    auto transform = [&](const sem::Constant* c0) {
+        auto create = [&](auto v) -> ImplResult {
+            using NumberT = decltype(v);
+            if (v <= NumberT(0)) {
+                AddError("log must be called with a value > 0", source);
+                return utils::Failure;
+            }
+            return CreateElement(builder, source, c0->Type(), NumberT(std::log(v)));
+        };
+        return Dispatch_fa_f32_f16(create, c0);
+    };
+    return TransformElements(builder, ty, transform, args[0]);
+}
+
+ConstEval::Result ConstEval::log2(const sem::Type* ty,
+                                  utils::VectorRef<const sem::Constant*> args,
+                                  const Source& source) {
+    auto transform = [&](const sem::Constant* c0) {
+        auto create = [&](auto v) -> ImplResult {
+            using NumberT = decltype(v);
+            if (v <= NumberT(0)) {
+                AddError("log2 must be called with a value > 0", source);
+                return utils::Failure;
+            }
+            return CreateElement(builder, source, c0->Type(), NumberT(std::log2(v)));
+        };
+        return Dispatch_fa_f32_f16(create, c0);
+    };
+    return TransformElements(builder, ty, transform, args[0]);
+}
+
 ConstEval::Result ConstEval::max(const sem::Type* ty,
                                  utils::VectorRef<const sem::Constant*> args,
                                  const Source& source) {
diff --git a/src/tint/resolver/const_eval.h b/src/tint/resolver/const_eval.h
index 2f2edc4..4b3bb54 100644
--- a/src/tint/resolver/const_eval.h
+++ b/src/tint/resolver/const_eval.h
@@ -628,6 +628,24 @@
                   utils::VectorRef<const sem::Constant*> args,
                   const Source& source);
 
+    /// log builtin
+    /// @param ty the expression type
+    /// @param args the input arguments
+    /// @param source the source location
+    /// @return the result value, or null if the value cannot be calculated
+    Result log(const sem::Type* ty,
+               utils::VectorRef<const sem::Constant*> args,
+               const Source& source);
+
+    /// log2 builtin
+    /// @param ty the expression type
+    /// @param args the input arguments
+    /// @param source the source location
+    /// @return the result value, or null if the value cannot be calculated
+    Result log2(const sem::Type* ty,
+                utils::VectorRef<const sem::Constant*> args,
+                const Source& source);
+
     /// max builtin
     /// @param ty the expression type
     /// @param args the input arguments
diff --git a/src/tint/resolver/const_eval_builtin_test.cc b/src/tint/resolver/const_eval_builtin_test.cc
index fe587ff..70a5bc8 100644
--- a/src/tint/resolver/const_eval_builtin_test.cc
+++ b/src/tint/resolver/const_eval_builtin_test.cc
@@ -1297,6 +1297,110 @@
                                               LengthCases<f16>()))));
 
 template <typename T>
+std::vector<Case> LogCases() {
+    auto error_msg = [] { return "12:34 error: log must be called with a value > 0"; };
+    return std::vector<Case>{C({T(1)}, T(0)),                              //
+                             C({T(54.598150033)}, T(4)).FloatComp(0.002),  //
+
+                             E({T::Lowest()}, error_msg()), E({T(0)}, error_msg()),
+                             E({-T(0)}, error_msg())};
+}
+INSTANTIATE_TEST_SUITE_P(  //
+    Log,
+    ResolverConstEvalBuiltinTest,
+    testing::Combine(testing::Values(sem::BuiltinType::kLog),
+                     testing::ValuesIn(Concat(LogCases<AFloat>(),  //
+                                              LogCases<f32>(),
+                                              LogCases<f16>()))));
+template <typename T>
+std::vector<Case> LogF16Cases() {
+    return std::vector<Case>{
+        C({T::Highest()}, T(11.085938)).FloatComp(),
+    };
+}
+INSTANTIATE_TEST_SUITE_P(  //
+    LogF16,
+    ResolverConstEvalBuiltinTest,
+    testing::Combine(testing::Values(sem::BuiltinType::kLog),
+                     testing::ValuesIn(LogF16Cases<f16>())));
+template <typename T>
+std::vector<Case> LogF32Cases() {
+    return std::vector<Case>{
+        C({T::Highest()}, T(88.722839)).FloatComp(),
+    };
+}
+INSTANTIATE_TEST_SUITE_P(  //
+    LogF32,
+    ResolverConstEvalBuiltinTest,
+    testing::Combine(testing::Values(sem::BuiltinType::kLog),
+                     testing::ValuesIn(LogF32Cases<f32>())));
+
+template <typename T>
+std::vector<Case> LogAbstractCases() {
+    return std::vector<Case>{
+        C({T::Highest()}, T(709.78271)).FloatComp(),
+    };
+}
+INSTANTIATE_TEST_SUITE_P(  //
+    LogAbstract,
+    ResolverConstEvalBuiltinTest,
+    testing::Combine(testing::Values(sem::BuiltinType::kLog),
+                     testing::ValuesIn(LogAbstractCases<AFloat>())));
+
+template <typename T>
+std::vector<Case> Log2Cases() {
+    auto error_msg = [] { return "12:34 error: log2 must be called with a value > 0"; };
+    return std::vector<Case>{
+        C({T(1)}, T(0)),  //
+        C({T(4)}, T(2)),  //
+
+        E({T::Lowest()}, error_msg()),
+        E({T(0)}, error_msg()),
+        E({-T(0)}, error_msg()),
+    };
+}
+INSTANTIATE_TEST_SUITE_P(  //
+    Log2,
+    ResolverConstEvalBuiltinTest,
+    testing::Combine(testing::Values(sem::BuiltinType::kLog2),
+                     testing::ValuesIn(Concat(Log2Cases<AFloat>(),  //
+                                              Log2Cases<f32>(),
+                                              Log2Cases<f16>()))));
+template <typename T>
+std::vector<Case> Log2F16Cases() {
+    return std::vector<Case>{
+        C({T::Highest()}, T(15.9922)).FloatComp(),
+    };
+}
+INSTANTIATE_TEST_SUITE_P(  //
+    Log2F16,
+    ResolverConstEvalBuiltinTest,
+    testing::Combine(testing::Values(sem::BuiltinType::kLog2),
+                     testing::ValuesIn(Log2F16Cases<f16>())));
+template <typename T>
+std::vector<Case> Log2F32Cases() {
+    return std::vector<Case>{
+        C({T::Highest()}, T(128)).FloatComp(),
+    };
+}
+INSTANTIATE_TEST_SUITE_P(  //
+    Log2F32,
+    ResolverConstEvalBuiltinTest,
+    testing::Combine(testing::Values(sem::BuiltinType::kLog2),
+                     testing::ValuesIn(Log2F32Cases<f32>())));
+template <typename T>
+std::vector<Case> Log2AbstractCases() {
+    return std::vector<Case>{
+        C({T::Highest()}, T(1024)).FloatComp(),
+    };
+}
+INSTANTIATE_TEST_SUITE_P(  //
+    Log2Abstract,
+    ResolverConstEvalBuiltinTest,
+    testing::Combine(testing::Values(sem::BuiltinType::kLog2),
+                     testing::ValuesIn(Log2AbstractCases<AFloat>())));
+
+template <typename T>
 std::vector<Case> MaxCases() {
     return {
         C({T(0), T(0)}, T(0)),
diff --git a/src/tint/resolver/intrinsic_table.inl b/src/tint/resolver/intrinsic_table.inl
index 74f377c..1c54749 100644
--- a/src/tint/resolver/intrinsic_table.inl
+++ b/src/tint/resolver/intrinsic_table.inl
@@ -12750,48 +12750,48 @@
     /* num parameters */ 1,
     /* num template types */ 1,
     /* num template numbers */ 0,
-    /* template types */ &kTemplateTypes[26],
+    /* template types */ &kTemplateTypes[23],
     /* template numbers */ &kTemplateNumbers[10],
     /* parameters */ &kParameters[874],
     /* return matcher indices */ &kMatcherIndices[3],
     /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
-    /* const eval */ nullptr,
+    /* const eval */ &ConstEval::log,
   },
   {
     /* [370] */
     /* num parameters */ 1,
     /* num template types */ 1,
     /* num template numbers */ 1,
-    /* template types */ &kTemplateTypes[26],
+    /* template types */ &kTemplateTypes[23],
     /* template numbers */ &kTemplateNumbers[4],
     /* parameters */ &kParameters[875],
     /* return matcher indices */ &kMatcherIndices[30],
     /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
-    /* const eval */ nullptr,
+    /* const eval */ &ConstEval::log,
   },
   {
     /* [371] */
     /* num parameters */ 1,
     /* num template types */ 1,
     /* num template numbers */ 0,
-    /* template types */ &kTemplateTypes[26],
+    /* template types */ &kTemplateTypes[23],
     /* template numbers */ &kTemplateNumbers[10],
     /* parameters */ &kParameters[876],
     /* return matcher indices */ &kMatcherIndices[3],
     /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
-    /* const eval */ nullptr,
+    /* const eval */ &ConstEval::log2,
   },
   {
     /* [372] */
     /* num parameters */ 1,
     /* num template types */ 1,
     /* num template numbers */ 1,
-    /* template types */ &kTemplateTypes[26],
+    /* template types */ &kTemplateTypes[23],
     /* template numbers */ &kTemplateNumbers[4],
     /* parameters */ &kParameters[877],
     /* return matcher indices */ &kMatcherIndices[30],
     /* flags */ OverloadFlags(OverloadFlag::kIsBuiltin, OverloadFlag::kSupportsVertexPipeline, OverloadFlag::kSupportsFragmentPipeline, OverloadFlag::kSupportsComputePipeline),
-    /* const eval */ nullptr,
+    /* const eval */ &ConstEval::log2,
   },
   {
     /* [373] */
@@ -14315,15 +14315,15 @@
   },
   {
     /* [48] */
-    /* fn log<T : f32_f16>(T) -> T */
-    /* fn log<N : num, T : f32_f16>(vec<N, T>) -> vec<N, T> */
+    /* fn log<T : fa_f32_f16>(T) -> T */
+    /* fn log<N : num, T : fa_f32_f16>(vec<N, T>) -> vec<N, T> */
     /* num overloads */ 2,
     /* overloads */ &kOverloads[369],
   },
   {
     /* [49] */
-    /* fn log2<T : f32_f16>(T) -> T */
-    /* fn log2<N : num, T : f32_f16>(vec<N, T>) -> vec<N, T> */
+    /* fn log2<T : fa_f32_f16>(T) -> T */
+    /* fn log2<N : num, T : fa_f32_f16>(vec<N, T>) -> vec<N, T> */
     /* num overloads */ 2,
     /* overloads */ &kOverloads[371],
   },
diff --git a/test/tint/builtins/gen/literal/log/3da25a.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log/3da25a.wgsl.expected.dxc.hlsl
index c0c3c6d..8893465 100644
--- a/test/tint/builtins/gen/literal/log/3da25a.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/log/3da25a.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
 void log_3da25a() {
-  float4 res = log((1.0f).xxxx);
+  float4 res = (0.0f).xxxx;
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/log/3da25a.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/log/3da25a.wgsl.expected.fxc.hlsl
index c0c3c6d..8893465 100644
--- a/test/tint/builtins/gen/literal/log/3da25a.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/log/3da25a.wgsl.expected.fxc.hlsl
@@ -1,5 +1,5 @@
 void log_3da25a() {
-  float4 res = log((1.0f).xxxx);
+  float4 res = (0.0f).xxxx;
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/log/3da25a.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log/3da25a.wgsl.expected.glsl
index df5ca13..fe91114 100644
--- a/test/tint/builtins/gen/literal/log/3da25a.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/log/3da25a.wgsl.expected.glsl
@@ -1,7 +1,7 @@
 #version 310 es
 
 void log_3da25a() {
-  vec4 res = log(vec4(1.0f));
+  vec4 res = vec4(0.0f);
 }
 
 vec4 vertex_main() {
@@ -21,7 +21,7 @@
 precision mediump float;
 
 void log_3da25a() {
-  vec4 res = log(vec4(1.0f));
+  vec4 res = vec4(0.0f);
 }
 
 void fragment_main() {
@@ -35,7 +35,7 @@
 #version 310 es
 
 void log_3da25a() {
-  vec4 res = log(vec4(1.0f));
+  vec4 res = vec4(0.0f);
 }
 
 void compute_main() {
diff --git a/test/tint/builtins/gen/literal/log/3da25a.wgsl.expected.msl b/test/tint/builtins/gen/literal/log/3da25a.wgsl.expected.msl
index dc18bb9..e70b8f9 100644
--- a/test/tint/builtins/gen/literal/log/3da25a.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/log/3da25a.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void log_3da25a() {
-  float4 res = log(float4(1.0f));
+  float4 res = float4(0.0f);
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/log/3da25a.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log/3da25a.wgsl.expected.spvasm
index 65cc030..0966583 100644
--- a/test/tint/builtins/gen/literal/log/3da25a.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/log/3da25a.wgsl.expected.spvasm
@@ -1,10 +1,9 @@
 ; SPIR-V
 ; Version: 1.3
 ; Generator: Google Tint Compiler; 0
-; Bound: 32
+; Bound: 29
 ; Schema: 0
                OpCapability Shader
-         %14 = OpExtInstImport "GLSL.std.450"
                OpMemoryModel Logical GLSL450
                OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
                OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -31,36 +30,34 @@
 %vertex_point_size = OpVariable %_ptr_Output_float Output %8
        %void = OpTypeVoid
           %9 = OpTypeFunction %void
-    %float_1 = OpConstant %float 1
-         %16 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
 %_ptr_Function_v4float = OpTypePointer Function %v4float
-         %19 = OpTypeFunction %v4float
+         %15 = OpTypeFunction %v4float
+    %float_1 = OpConstant %float 1
  %log_3da25a = OpFunction %void None %9
          %12 = OpLabel
         %res = OpVariable %_ptr_Function_v4float Function %5
-         %13 = OpExtInst %v4float %14 Log %16
-               OpStore %res %13
+               OpStore %res %5
                OpReturn
                OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %19
-         %21 = OpLabel
-         %22 = OpFunctionCall %void %log_3da25a
+%vertex_main_inner = OpFunction %v4float None %15
+         %17 = OpLabel
+         %18 = OpFunctionCall %void %log_3da25a
                OpReturnValue %5
                OpFunctionEnd
 %vertex_main = OpFunction %void None %9
-         %24 = OpLabel
-         %25 = OpFunctionCall %v4float %vertex_main_inner
-               OpStore %value %25
+         %20 = OpLabel
+         %21 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %21
                OpStore %vertex_point_size %float_1
                OpReturn
                OpFunctionEnd
 %fragment_main = OpFunction %void None %9
-         %27 = OpLabel
-         %28 = OpFunctionCall %void %log_3da25a
+         %24 = OpLabel
+         %25 = OpFunctionCall %void %log_3da25a
                OpReturn
                OpFunctionEnd
 %compute_main = OpFunction %void None %9
-         %30 = OpLabel
-         %31 = OpFunctionCall %void %log_3da25a
+         %27 = OpLabel
+         %28 = OpFunctionCall %void %log_3da25a
                OpReturn
                OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/log/655989.wgsl b/test/tint/builtins/gen/literal/log/655989.wgsl
new file mode 100644
index 0000000..4d2b233
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log/655989.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 log(fa) -> fa
+fn log_655989() {
+  var res = log(1.);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  log_655989();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  log_655989();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  log_655989();
+}
diff --git a/test/tint/builtins/gen/literal/log/655989.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log/655989.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..a8475f8
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log/655989.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void log_655989() {
+  float res = 0.0f;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  log_655989();
+  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() {
+  log_655989();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  log_655989();
+  return;
+}
diff --git a/test/tint/builtins/gen/literal/log/655989.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/log/655989.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..a8475f8
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log/655989.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void log_655989() {
+  float res = 0.0f;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  log_655989();
+  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() {
+  log_655989();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  log_655989();
+  return;
+}
diff --git a/test/tint/builtins/gen/literal/log/655989.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log/655989.wgsl.expected.glsl
new file mode 100644
index 0000000..e6a0182
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log/655989.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void log_655989() {
+  float res = 0.0f;
+}
+
+vec4 vertex_main() {
+  log_655989();
+  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 log_655989() {
+  float res = 0.0f;
+}
+
+void fragment_main() {
+  log_655989();
+}
+
+void main() {
+  fragment_main();
+  return;
+}
+#version 310 es
+
+void log_655989() {
+  float res = 0.0f;
+}
+
+void compute_main() {
+  log_655989();
+}
+
+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/log/655989.wgsl.expected.msl b/test/tint/builtins/gen/literal/log/655989.wgsl.expected.msl
new file mode 100644
index 0000000..0b174b7
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log/655989.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void log_655989() {
+  float res = 0.0f;
+}
+
+struct tint_symbol {
+  float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+  log_655989();
+  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() {
+  log_655989();
+  return;
+}
+
+kernel void compute_main() {
+  log_655989();
+  return;
+}
+
diff --git a/test/tint/builtins/gen/literal/log/655989.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log/655989.wgsl.expected.spvasm
new file mode 100644
index 0000000..6d7f01b
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log/655989.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 %log_655989 "log_655989"
+               OpName %res "res"
+               OpName %vertex_main_inner "vertex_main_inner"
+               OpName %vertex_main "vertex_main"
+               OpName %fragment_main "fragment_main"
+               OpName %compute_main "compute_main"
+               OpDecorate %value BuiltIn Position
+               OpDecorate %vertex_point_size BuiltIn PointSize
+      %float = OpTypeFloat 32
+    %v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+          %5 = OpConstantNull %v4float
+      %value = OpVariable %_ptr_Output_v4float Output %5
+%_ptr_Output_float = OpTypePointer Output %float
+          %8 = OpConstantNull %float
+%vertex_point_size = OpVariable %_ptr_Output_float Output %8
+       %void = OpTypeVoid
+          %9 = OpTypeFunction %void
+%_ptr_Function_float = OpTypePointer Function %float
+         %15 = OpTypeFunction %v4float
+    %float_1 = OpConstant %float 1
+ %log_655989 = OpFunction %void None %9
+         %12 = OpLabel
+        %res = OpVariable %_ptr_Function_float Function %8
+               OpStore %res %8
+               OpReturn
+               OpFunctionEnd
+%vertex_main_inner = OpFunction %v4float None %15
+         %17 = OpLabel
+         %18 = OpFunctionCall %void %log_655989
+               OpReturnValue %5
+               OpFunctionEnd
+%vertex_main = OpFunction %void None %9
+         %20 = OpLabel
+         %21 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %21
+               OpStore %vertex_point_size %float_1
+               OpReturn
+               OpFunctionEnd
+%fragment_main = OpFunction %void None %9
+         %24 = OpLabel
+         %25 = OpFunctionCall %void %log_655989
+               OpReturn
+               OpFunctionEnd
+%compute_main = OpFunction %void None %9
+         %27 = OpLabel
+         %28 = OpFunctionCall %void %log_655989
+               OpReturn
+               OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/log/655989.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/log/655989.wgsl.expected.wgsl
new file mode 100644
index 0000000..2b2d5a9
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log/655989.wgsl.expected.wgsl
@@ -0,0 +1,19 @@
+fn log_655989() {
+  var res = log(1.0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  log_655989();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  log_655989();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  log_655989();
+}
diff --git a/test/tint/builtins/gen/literal/log/697e1d.wgsl b/test/tint/builtins/gen/literal/log/697e1d.wgsl
new file mode 100644
index 0000000..20086fb
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log/697e1d.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 log(vec<4, fa>) -> vec<4, fa>
+fn log_697e1d() {
+  var res = log(vec4(1.));
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  log_697e1d();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  log_697e1d();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  log_697e1d();
+}
diff --git a/test/tint/builtins/gen/literal/log/697e1d.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log/697e1d.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..56bdd4c
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log/697e1d.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void log_697e1d() {
+  float4 res = (0.0f).xxxx;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  log_697e1d();
+  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() {
+  log_697e1d();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  log_697e1d();
+  return;
+}
diff --git a/test/tint/builtins/gen/literal/log/697e1d.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/log/697e1d.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..56bdd4c
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log/697e1d.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void log_697e1d() {
+  float4 res = (0.0f).xxxx;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  log_697e1d();
+  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() {
+  log_697e1d();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  log_697e1d();
+  return;
+}
diff --git a/test/tint/builtins/gen/literal/log/697e1d.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log/697e1d.wgsl.expected.glsl
new file mode 100644
index 0000000..06b9a1b
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log/697e1d.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void log_697e1d() {
+  vec4 res = vec4(0.0f);
+}
+
+vec4 vertex_main() {
+  log_697e1d();
+  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 log_697e1d() {
+  vec4 res = vec4(0.0f);
+}
+
+void fragment_main() {
+  log_697e1d();
+}
+
+void main() {
+  fragment_main();
+  return;
+}
+#version 310 es
+
+void log_697e1d() {
+  vec4 res = vec4(0.0f);
+}
+
+void compute_main() {
+  log_697e1d();
+}
+
+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/log/697e1d.wgsl.expected.msl b/test/tint/builtins/gen/literal/log/697e1d.wgsl.expected.msl
new file mode 100644
index 0000000..c3311d4
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log/697e1d.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void log_697e1d() {
+  float4 res = float4(0.0f);
+}
+
+struct tint_symbol {
+  float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+  log_697e1d();
+  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() {
+  log_697e1d();
+  return;
+}
+
+kernel void compute_main() {
+  log_697e1d();
+  return;
+}
+
diff --git a/test/tint/builtins/gen/literal/log/697e1d.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log/697e1d.wgsl.expected.spvasm
new file mode 100644
index 0000000..7432296
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log/697e1d.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 %log_697e1d "log_697e1d"
+               OpName %res "res"
+               OpName %vertex_main_inner "vertex_main_inner"
+               OpName %vertex_main "vertex_main"
+               OpName %fragment_main "fragment_main"
+               OpName %compute_main "compute_main"
+               OpDecorate %value BuiltIn Position
+               OpDecorate %vertex_point_size BuiltIn PointSize
+      %float = OpTypeFloat 32
+    %v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+          %5 = OpConstantNull %v4float
+      %value = OpVariable %_ptr_Output_v4float Output %5
+%_ptr_Output_float = OpTypePointer Output %float
+          %8 = OpConstantNull %float
+%vertex_point_size = OpVariable %_ptr_Output_float Output %8
+       %void = OpTypeVoid
+          %9 = OpTypeFunction %void
+%_ptr_Function_v4float = OpTypePointer Function %v4float
+         %15 = OpTypeFunction %v4float
+    %float_1 = OpConstant %float 1
+ %log_697e1d = OpFunction %void None %9
+         %12 = OpLabel
+        %res = OpVariable %_ptr_Function_v4float Function %5
+               OpStore %res %5
+               OpReturn
+               OpFunctionEnd
+%vertex_main_inner = OpFunction %v4float None %15
+         %17 = OpLabel
+         %18 = OpFunctionCall %void %log_697e1d
+               OpReturnValue %5
+               OpFunctionEnd
+%vertex_main = OpFunction %void None %9
+         %20 = OpLabel
+         %21 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %21
+               OpStore %vertex_point_size %float_1
+               OpReturn
+               OpFunctionEnd
+%fragment_main = OpFunction %void None %9
+         %24 = OpLabel
+         %25 = OpFunctionCall %void %log_697e1d
+               OpReturn
+               OpFunctionEnd
+%compute_main = OpFunction %void None %9
+         %27 = OpLabel
+         %28 = OpFunctionCall %void %log_697e1d
+               OpReturn
+               OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/log/697e1d.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/log/697e1d.wgsl.expected.wgsl
new file mode 100644
index 0000000..f4d96da
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log/697e1d.wgsl.expected.wgsl
@@ -0,0 +1,19 @@
+fn log_697e1d() {
+  var res = log(vec4(1.0));
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  log_697e1d();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  log_697e1d();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  log_697e1d();
+}
diff --git a/test/tint/builtins/gen/literal/log/6ff86f.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log/6ff86f.wgsl.expected.dxc.hlsl
index 8d17f97..f537033 100644
--- a/test/tint/builtins/gen/literal/log/6ff86f.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/log/6ff86f.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
 void log_6ff86f() {
-  vector<float16_t, 3> res = log((float16_t(1.0h)).xxx);
+  vector<float16_t, 3> res = (float16_t(0.0h)).xxx;
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/log/6ff86f.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log/6ff86f.wgsl.expected.glsl
index 5efd1c3..9fc5abc 100644
--- a/test/tint/builtins/gen/literal/log/6ff86f.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/log/6ff86f.wgsl.expected.glsl
@@ -2,7 +2,7 @@
 #extension GL_AMD_gpu_shader_half_float : require
 
 void log_6ff86f() {
-  f16vec3 res = log(f16vec3(1.0hf));
+  f16vec3 res = f16vec3(0.0hf);
 }
 
 vec4 vertex_main() {
@@ -23,7 +23,7 @@
 precision mediump float;
 
 void log_6ff86f() {
-  f16vec3 res = log(f16vec3(1.0hf));
+  f16vec3 res = f16vec3(0.0hf);
 }
 
 void fragment_main() {
@@ -38,7 +38,7 @@
 #extension GL_AMD_gpu_shader_half_float : require
 
 void log_6ff86f() {
-  f16vec3 res = log(f16vec3(1.0hf));
+  f16vec3 res = f16vec3(0.0hf);
 }
 
 void compute_main() {
diff --git a/test/tint/builtins/gen/literal/log/6ff86f.wgsl.expected.msl b/test/tint/builtins/gen/literal/log/6ff86f.wgsl.expected.msl
index 5b4c531..f16f293 100644
--- a/test/tint/builtins/gen/literal/log/6ff86f.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/log/6ff86f.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void log_6ff86f() {
-  half3 res = log(half3(1.0h));
+  half3 res = half3(0.0h);
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/log/6ff86f.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log/6ff86f.wgsl.expected.spvasm
index 2579458..bfd7974 100644
--- a/test/tint/builtins/gen/literal/log/6ff86f.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/log/6ff86f.wgsl.expected.spvasm
@@ -1,14 +1,13 @@
 ; SPIR-V
 ; Version: 1.3
 ; Generator: Google Tint Compiler; 0
-; Bound: 36
+; Bound: 32
 ; Schema: 0
                OpCapability Shader
                OpCapability Float16
                OpCapability UniformAndStorageBuffer16BitAccess
                OpCapability StorageBuffer16BitAccess
                OpCapability StorageInputOutput16
-         %16 = OpExtInstImport "GLSL.std.450"
                OpMemoryModel Logical GLSL450
                OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
                OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -37,38 +36,35 @@
           %9 = OpTypeFunction %void
        %half = OpTypeFloat 16
      %v3half = OpTypeVector %half 3
-%half_0x1p_0 = OpConstant %half 0x1p+0
-         %18 = OpConstantComposite %v3half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0
+         %15 = OpConstantNull %v3half
 %_ptr_Function_v3half = OpTypePointer Function %v3half
-         %21 = OpConstantNull %v3half
-         %22 = OpTypeFunction %v4float
+         %18 = OpTypeFunction %v4float
     %float_1 = OpConstant %float 1
  %log_6ff86f = OpFunction %void None %9
          %12 = OpLabel
-        %res = OpVariable %_ptr_Function_v3half Function %21
-         %13 = OpExtInst %v3half %16 Log %18
-               OpStore %res %13
+        %res = OpVariable %_ptr_Function_v3half Function %15
+               OpStore %res %15
                OpReturn
                OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %22
-         %24 = OpLabel
-         %25 = OpFunctionCall %void %log_6ff86f
+%vertex_main_inner = OpFunction %v4float None %18
+         %20 = OpLabel
+         %21 = OpFunctionCall %void %log_6ff86f
                OpReturnValue %5
                OpFunctionEnd
 %vertex_main = OpFunction %void None %9
-         %27 = OpLabel
-         %28 = OpFunctionCall %v4float %vertex_main_inner
-               OpStore %value %28
+         %23 = OpLabel
+         %24 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %24
                OpStore %vertex_point_size %float_1
                OpReturn
                OpFunctionEnd
 %fragment_main = OpFunction %void None %9
-         %31 = OpLabel
-         %32 = OpFunctionCall %void %log_6ff86f
+         %27 = OpLabel
+         %28 = OpFunctionCall %void %log_6ff86f
                OpReturn
                OpFunctionEnd
 %compute_main = OpFunction %void None %9
-         %34 = OpLabel
-         %35 = OpFunctionCall %void %log_6ff86f
+         %30 = OpLabel
+         %31 = OpFunctionCall %void %log_6ff86f
                OpReturn
                OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/log/7114a6.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log/7114a6.wgsl.expected.dxc.hlsl
index 8b9a62b..4875199 100644
--- a/test/tint/builtins/gen/literal/log/7114a6.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/log/7114a6.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
 void log_7114a6() {
-  float res = log(1.0f);
+  float res = 0.0f;
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/log/7114a6.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/log/7114a6.wgsl.expected.fxc.hlsl
index 8b9a62b..4875199 100644
--- a/test/tint/builtins/gen/literal/log/7114a6.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/log/7114a6.wgsl.expected.fxc.hlsl
@@ -1,5 +1,5 @@
 void log_7114a6() {
-  float res = log(1.0f);
+  float res = 0.0f;
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/log/7114a6.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log/7114a6.wgsl.expected.glsl
index 0c5e7ea..6e2be1a 100644
--- a/test/tint/builtins/gen/literal/log/7114a6.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/log/7114a6.wgsl.expected.glsl
@@ -1,7 +1,7 @@
 #version 310 es
 
 void log_7114a6() {
-  float res = log(1.0f);
+  float res = 0.0f;
 }
 
 vec4 vertex_main() {
@@ -21,7 +21,7 @@
 precision mediump float;
 
 void log_7114a6() {
-  float res = log(1.0f);
+  float res = 0.0f;
 }
 
 void fragment_main() {
@@ -35,7 +35,7 @@
 #version 310 es
 
 void log_7114a6() {
-  float res = log(1.0f);
+  float res = 0.0f;
 }
 
 void compute_main() {
diff --git a/test/tint/builtins/gen/literal/log/7114a6.wgsl.expected.msl b/test/tint/builtins/gen/literal/log/7114a6.wgsl.expected.msl
index 72da25e..6f3b9c4 100644
--- a/test/tint/builtins/gen/literal/log/7114a6.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/log/7114a6.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void log_7114a6() {
-  float res = log(1.0f);
+  float res = 0.0f;
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/log/7114a6.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log/7114a6.wgsl.expected.spvasm
index 6d8292f..17e7f0d 100644
--- a/test/tint/builtins/gen/literal/log/7114a6.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/log/7114a6.wgsl.expected.spvasm
@@ -1,10 +1,9 @@
 ; SPIR-V
 ; Version: 1.3
 ; Generator: Google Tint Compiler; 0
-; Bound: 31
+; Bound: 29
 ; Schema: 0
                OpCapability Shader
-         %14 = OpExtInstImport "GLSL.std.450"
                OpMemoryModel Logical GLSL450
                OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
                OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -31,35 +30,34 @@
 %vertex_point_size = OpVariable %_ptr_Output_float Output %8
        %void = OpTypeVoid
           %9 = OpTypeFunction %void
-    %float_1 = OpConstant %float 1
 %_ptr_Function_float = OpTypePointer Function %float
-         %18 = OpTypeFunction %v4float
+         %15 = OpTypeFunction %v4float
+    %float_1 = OpConstant %float 1
  %log_7114a6 = OpFunction %void None %9
          %12 = OpLabel
         %res = OpVariable %_ptr_Function_float Function %8
-         %13 = OpExtInst %float %14 Log %float_1
-               OpStore %res %13
+               OpStore %res %8
                OpReturn
                OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %18
-         %20 = OpLabel
-         %21 = OpFunctionCall %void %log_7114a6
+%vertex_main_inner = OpFunction %v4float None %15
+         %17 = OpLabel
+         %18 = OpFunctionCall %void %log_7114a6
                OpReturnValue %5
                OpFunctionEnd
 %vertex_main = OpFunction %void None %9
-         %23 = OpLabel
-         %24 = OpFunctionCall %v4float %vertex_main_inner
-               OpStore %value %24
+         %20 = OpLabel
+         %21 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %21
                OpStore %vertex_point_size %float_1
                OpReturn
                OpFunctionEnd
 %fragment_main = OpFunction %void None %9
-         %26 = OpLabel
-         %27 = OpFunctionCall %void %log_7114a6
+         %24 = OpLabel
+         %25 = OpFunctionCall %void %log_7114a6
                OpReturn
                OpFunctionEnd
 %compute_main = OpFunction %void None %9
-         %29 = OpLabel
-         %30 = OpFunctionCall %void %log_7114a6
+         %27 = OpLabel
+         %28 = OpFunctionCall %void %log_7114a6
                OpReturn
                OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/log/8f0e32.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log/8f0e32.wgsl.expected.dxc.hlsl
index eebe64c..ef49c8f 100644
--- a/test/tint/builtins/gen/literal/log/8f0e32.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/log/8f0e32.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
 void log_8f0e32() {
-  vector<float16_t, 2> res = log((float16_t(1.0h)).xx);
+  vector<float16_t, 2> res = (float16_t(0.0h)).xx;
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/log/8f0e32.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log/8f0e32.wgsl.expected.glsl
index b75bf0d..b5dd01d 100644
--- a/test/tint/builtins/gen/literal/log/8f0e32.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/log/8f0e32.wgsl.expected.glsl
@@ -2,7 +2,7 @@
 #extension GL_AMD_gpu_shader_half_float : require
 
 void log_8f0e32() {
-  f16vec2 res = log(f16vec2(1.0hf));
+  f16vec2 res = f16vec2(0.0hf);
 }
 
 vec4 vertex_main() {
@@ -23,7 +23,7 @@
 precision mediump float;
 
 void log_8f0e32() {
-  f16vec2 res = log(f16vec2(1.0hf));
+  f16vec2 res = f16vec2(0.0hf);
 }
 
 void fragment_main() {
@@ -38,7 +38,7 @@
 #extension GL_AMD_gpu_shader_half_float : require
 
 void log_8f0e32() {
-  f16vec2 res = log(f16vec2(1.0hf));
+  f16vec2 res = f16vec2(0.0hf);
 }
 
 void compute_main() {
diff --git a/test/tint/builtins/gen/literal/log/8f0e32.wgsl.expected.msl b/test/tint/builtins/gen/literal/log/8f0e32.wgsl.expected.msl
index 2d48740..33d2dab 100644
--- a/test/tint/builtins/gen/literal/log/8f0e32.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/log/8f0e32.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void log_8f0e32() {
-  half2 res = log(half2(1.0h));
+  half2 res = half2(0.0h);
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/log/8f0e32.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log/8f0e32.wgsl.expected.spvasm
index 2a6e432..5960ad5 100644
--- a/test/tint/builtins/gen/literal/log/8f0e32.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/log/8f0e32.wgsl.expected.spvasm
@@ -1,14 +1,13 @@
 ; SPIR-V
 ; Version: 1.3
 ; Generator: Google Tint Compiler; 0
-; Bound: 36
+; Bound: 32
 ; Schema: 0
                OpCapability Shader
                OpCapability Float16
                OpCapability UniformAndStorageBuffer16BitAccess
                OpCapability StorageBuffer16BitAccess
                OpCapability StorageInputOutput16
-         %16 = OpExtInstImport "GLSL.std.450"
                OpMemoryModel Logical GLSL450
                OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
                OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -37,38 +36,35 @@
           %9 = OpTypeFunction %void
        %half = OpTypeFloat 16
      %v2half = OpTypeVector %half 2
-%half_0x1p_0 = OpConstant %half 0x1p+0
-         %18 = OpConstantComposite %v2half %half_0x1p_0 %half_0x1p_0
+         %15 = OpConstantNull %v2half
 %_ptr_Function_v2half = OpTypePointer Function %v2half
-         %21 = OpConstantNull %v2half
-         %22 = OpTypeFunction %v4float
+         %18 = OpTypeFunction %v4float
     %float_1 = OpConstant %float 1
  %log_8f0e32 = OpFunction %void None %9
          %12 = OpLabel
-        %res = OpVariable %_ptr_Function_v2half Function %21
-         %13 = OpExtInst %v2half %16 Log %18
-               OpStore %res %13
+        %res = OpVariable %_ptr_Function_v2half Function %15
+               OpStore %res %15
                OpReturn
                OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %22
-         %24 = OpLabel
-         %25 = OpFunctionCall %void %log_8f0e32
+%vertex_main_inner = OpFunction %v4float None %18
+         %20 = OpLabel
+         %21 = OpFunctionCall %void %log_8f0e32
                OpReturnValue %5
                OpFunctionEnd
 %vertex_main = OpFunction %void None %9
-         %27 = OpLabel
-         %28 = OpFunctionCall %v4float %vertex_main_inner
-               OpStore %value %28
+         %23 = OpLabel
+         %24 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %24
                OpStore %vertex_point_size %float_1
                OpReturn
                OpFunctionEnd
 %fragment_main = OpFunction %void None %9
-         %31 = OpLabel
-         %32 = OpFunctionCall %void %log_8f0e32
+         %27 = OpLabel
+         %28 = OpFunctionCall %void %log_8f0e32
                OpReturn
                OpFunctionEnd
 %compute_main = OpFunction %void None %9
-         %34 = OpLabel
-         %35 = OpFunctionCall %void %log_8f0e32
+         %30 = OpLabel
+         %31 = OpFunctionCall %void %log_8f0e32
                OpReturn
                OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/log/b2ce28.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log/b2ce28.wgsl.expected.dxc.hlsl
index 3eff95a..200c199 100644
--- a/test/tint/builtins/gen/literal/log/b2ce28.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/log/b2ce28.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
 void log_b2ce28() {
-  float2 res = log((1.0f).xx);
+  float2 res = (0.0f).xx;
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/log/b2ce28.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/log/b2ce28.wgsl.expected.fxc.hlsl
index 3eff95a..200c199 100644
--- a/test/tint/builtins/gen/literal/log/b2ce28.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/log/b2ce28.wgsl.expected.fxc.hlsl
@@ -1,5 +1,5 @@
 void log_b2ce28() {
-  float2 res = log((1.0f).xx);
+  float2 res = (0.0f).xx;
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/log/b2ce28.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log/b2ce28.wgsl.expected.glsl
index cc98643..223eccd 100644
--- a/test/tint/builtins/gen/literal/log/b2ce28.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/log/b2ce28.wgsl.expected.glsl
@@ -1,7 +1,7 @@
 #version 310 es
 
 void log_b2ce28() {
-  vec2 res = log(vec2(1.0f));
+  vec2 res = vec2(0.0f);
 }
 
 vec4 vertex_main() {
@@ -21,7 +21,7 @@
 precision mediump float;
 
 void log_b2ce28() {
-  vec2 res = log(vec2(1.0f));
+  vec2 res = vec2(0.0f);
 }
 
 void fragment_main() {
@@ -35,7 +35,7 @@
 #version 310 es
 
 void log_b2ce28() {
-  vec2 res = log(vec2(1.0f));
+  vec2 res = vec2(0.0f);
 }
 
 void compute_main() {
diff --git a/test/tint/builtins/gen/literal/log/b2ce28.wgsl.expected.msl b/test/tint/builtins/gen/literal/log/b2ce28.wgsl.expected.msl
index f9c13bd..9f693c4 100644
--- a/test/tint/builtins/gen/literal/log/b2ce28.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/log/b2ce28.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void log_b2ce28() {
-  float2 res = log(float2(1.0f));
+  float2 res = float2(0.0f);
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/log/b2ce28.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log/b2ce28.wgsl.expected.spvasm
index 5ea25fd..fc4c327 100644
--- a/test/tint/builtins/gen/literal/log/b2ce28.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/log/b2ce28.wgsl.expected.spvasm
@@ -1,10 +1,9 @@
 ; SPIR-V
 ; Version: 1.3
 ; Generator: Google Tint Compiler; 0
-; Bound: 34
+; Bound: 31
 ; Schema: 0
                OpCapability Shader
-         %15 = OpExtInstImport "GLSL.std.450"
                OpMemoryModel Logical GLSL450
                OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
                OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -32,37 +31,35 @@
        %void = OpTypeVoid
           %9 = OpTypeFunction %void
     %v2float = OpTypeVector %float 2
-    %float_1 = OpConstant %float 1
-         %17 = OpConstantComposite %v2float %float_1 %float_1
+         %14 = OpConstantNull %v2float
 %_ptr_Function_v2float = OpTypePointer Function %v2float
-         %20 = OpConstantNull %v2float
-         %21 = OpTypeFunction %v4float
+         %17 = OpTypeFunction %v4float
+    %float_1 = OpConstant %float 1
  %log_b2ce28 = OpFunction %void None %9
          %12 = OpLabel
-        %res = OpVariable %_ptr_Function_v2float Function %20
-         %13 = OpExtInst %v2float %15 Log %17
-               OpStore %res %13
+        %res = OpVariable %_ptr_Function_v2float Function %14
+               OpStore %res %14
                OpReturn
                OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %21
-         %23 = OpLabel
-         %24 = OpFunctionCall %void %log_b2ce28
+%vertex_main_inner = OpFunction %v4float None %17
+         %19 = OpLabel
+         %20 = OpFunctionCall %void %log_b2ce28
                OpReturnValue %5
                OpFunctionEnd
 %vertex_main = OpFunction %void None %9
-         %26 = OpLabel
-         %27 = OpFunctionCall %v4float %vertex_main_inner
-               OpStore %value %27
+         %22 = OpLabel
+         %23 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %23
                OpStore %vertex_point_size %float_1
                OpReturn
                OpFunctionEnd
 %fragment_main = OpFunction %void None %9
-         %29 = OpLabel
-         %30 = OpFunctionCall %void %log_b2ce28
+         %26 = OpLabel
+         %27 = OpFunctionCall %void %log_b2ce28
                OpReturn
                OpFunctionEnd
 %compute_main = OpFunction %void None %9
-         %32 = OpLabel
-         %33 = OpFunctionCall %void %log_b2ce28
+         %29 = OpLabel
+         %30 = OpFunctionCall %void %log_b2ce28
                OpReturn
                OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/log/b8088d.wgsl b/test/tint/builtins/gen/literal/log/b8088d.wgsl
new file mode 100644
index 0000000..f110dec
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log/b8088d.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 log(vec<3, fa>) -> vec<3, fa>
+fn log_b8088d() {
+  var res = log(vec3(1.));
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  log_b8088d();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  log_b8088d();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  log_b8088d();
+}
diff --git a/test/tint/builtins/gen/literal/log/b8088d.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log/b8088d.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..0234c1d
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log/b8088d.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void log_b8088d() {
+  float3 res = (0.0f).xxx;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  log_b8088d();
+  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() {
+  log_b8088d();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  log_b8088d();
+  return;
+}
diff --git a/test/tint/builtins/gen/literal/log/b8088d.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/log/b8088d.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..0234c1d
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log/b8088d.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void log_b8088d() {
+  float3 res = (0.0f).xxx;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  log_b8088d();
+  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() {
+  log_b8088d();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  log_b8088d();
+  return;
+}
diff --git a/test/tint/builtins/gen/literal/log/b8088d.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log/b8088d.wgsl.expected.glsl
new file mode 100644
index 0000000..5dc623a
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log/b8088d.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void log_b8088d() {
+  vec3 res = vec3(0.0f);
+}
+
+vec4 vertex_main() {
+  log_b8088d();
+  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 log_b8088d() {
+  vec3 res = vec3(0.0f);
+}
+
+void fragment_main() {
+  log_b8088d();
+}
+
+void main() {
+  fragment_main();
+  return;
+}
+#version 310 es
+
+void log_b8088d() {
+  vec3 res = vec3(0.0f);
+}
+
+void compute_main() {
+  log_b8088d();
+}
+
+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/log/b8088d.wgsl.expected.msl b/test/tint/builtins/gen/literal/log/b8088d.wgsl.expected.msl
new file mode 100644
index 0000000..92066b0
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log/b8088d.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void log_b8088d() {
+  float3 res = float3(0.0f);
+}
+
+struct tint_symbol {
+  float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+  log_b8088d();
+  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() {
+  log_b8088d();
+  return;
+}
+
+kernel void compute_main() {
+  log_b8088d();
+  return;
+}
+
diff --git a/test/tint/builtins/gen/literal/log/b8088d.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log/b8088d.wgsl.expected.spvasm
new file mode 100644
index 0000000..ed2010a
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log/b8088d.wgsl.expected.spvasm
@@ -0,0 +1,65 @@
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 0
+; Bound: 31
+; 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 %log_b8088d "log_b8088d"
+               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
+         %14 = OpConstantNull %v3float
+%_ptr_Function_v3float = OpTypePointer Function %v3float
+         %17 = OpTypeFunction %v4float
+    %float_1 = OpConstant %float 1
+ %log_b8088d = OpFunction %void None %9
+         %12 = OpLabel
+        %res = OpVariable %_ptr_Function_v3float Function %14
+               OpStore %res %14
+               OpReturn
+               OpFunctionEnd
+%vertex_main_inner = OpFunction %v4float None %17
+         %19 = OpLabel
+         %20 = OpFunctionCall %void %log_b8088d
+               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
+         %26 = OpLabel
+         %27 = OpFunctionCall %void %log_b8088d
+               OpReturn
+               OpFunctionEnd
+%compute_main = OpFunction %void None %9
+         %29 = OpLabel
+         %30 = OpFunctionCall %void %log_b8088d
+               OpReturn
+               OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/log/b8088d.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/log/b8088d.wgsl.expected.wgsl
new file mode 100644
index 0000000..977c78c
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log/b8088d.wgsl.expected.wgsl
@@ -0,0 +1,19 @@
+fn log_b8088d() {
+  var res = log(vec3(1.0));
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  log_b8088d();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  log_b8088d();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  log_b8088d();
+}
diff --git a/test/tint/builtins/gen/literal/log/c9f489.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log/c9f489.wgsl.expected.dxc.hlsl
index 358ac77..2102cac 100644
--- a/test/tint/builtins/gen/literal/log/c9f489.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/log/c9f489.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
 void log_c9f489() {
-  float16_t res = log(float16_t(1.0h));
+  float16_t res = float16_t(0.0h);
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/log/c9f489.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log/c9f489.wgsl.expected.glsl
index 2ae51ee..c632da4 100644
--- a/test/tint/builtins/gen/literal/log/c9f489.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/log/c9f489.wgsl.expected.glsl
@@ -2,7 +2,7 @@
 #extension GL_AMD_gpu_shader_half_float : require
 
 void log_c9f489() {
-  float16_t res = log(1.0hf);
+  float16_t res = 0.0hf;
 }
 
 vec4 vertex_main() {
@@ -23,7 +23,7 @@
 precision mediump float;
 
 void log_c9f489() {
-  float16_t res = log(1.0hf);
+  float16_t res = 0.0hf;
 }
 
 void fragment_main() {
@@ -38,7 +38,7 @@
 #extension GL_AMD_gpu_shader_half_float : require
 
 void log_c9f489() {
-  float16_t res = log(1.0hf);
+  float16_t res = 0.0hf;
 }
 
 void compute_main() {
diff --git a/test/tint/builtins/gen/literal/log/c9f489.wgsl.expected.msl b/test/tint/builtins/gen/literal/log/c9f489.wgsl.expected.msl
index cae5ee0..a879c66 100644
--- a/test/tint/builtins/gen/literal/log/c9f489.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/log/c9f489.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void log_c9f489() {
-  half res = log(1.0h);
+  half res = 0.0h;
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/log/c9f489.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log/c9f489.wgsl.expected.spvasm
index ddf328c..f056297 100644
--- a/test/tint/builtins/gen/literal/log/c9f489.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/log/c9f489.wgsl.expected.spvasm
@@ -1,14 +1,13 @@
 ; SPIR-V
 ; Version: 1.3
 ; Generator: Google Tint Compiler; 0
-; Bound: 34
+; Bound: 31
 ; Schema: 0
                OpCapability Shader
                OpCapability Float16
                OpCapability UniformAndStorageBuffer16BitAccess
                OpCapability StorageBuffer16BitAccess
                OpCapability StorageInputOutput16
-         %15 = OpExtInstImport "GLSL.std.450"
                OpMemoryModel Logical GLSL450
                OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
                OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -36,37 +35,35 @@
        %void = OpTypeVoid
           %9 = OpTypeFunction %void
        %half = OpTypeFloat 16
-%half_0x1p_0 = OpConstant %half 0x1p+0
+         %14 = OpConstantNull %half
 %_ptr_Function_half = OpTypePointer Function %half
-         %19 = OpConstantNull %half
-         %20 = OpTypeFunction %v4float
+         %17 = OpTypeFunction %v4float
     %float_1 = OpConstant %float 1
  %log_c9f489 = OpFunction %void None %9
          %12 = OpLabel
-        %res = OpVariable %_ptr_Function_half Function %19
-         %13 = OpExtInst %half %15 Log %half_0x1p_0
-               OpStore %res %13
+        %res = OpVariable %_ptr_Function_half Function %14
+               OpStore %res %14
                OpReturn
                OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %20
-         %22 = OpLabel
-         %23 = OpFunctionCall %void %log_c9f489
+%vertex_main_inner = OpFunction %v4float None %17
+         %19 = OpLabel
+         %20 = OpFunctionCall %void %log_c9f489
                OpReturnValue %5
                OpFunctionEnd
 %vertex_main = OpFunction %void None %9
-         %25 = OpLabel
-         %26 = OpFunctionCall %v4float %vertex_main_inner
-               OpStore %value %26
+         %22 = OpLabel
+         %23 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %23
                OpStore %vertex_point_size %float_1
                OpReturn
                OpFunctionEnd
 %fragment_main = OpFunction %void None %9
-         %29 = OpLabel
-         %30 = OpFunctionCall %void %log_c9f489
+         %26 = OpLabel
+         %27 = OpFunctionCall %void %log_c9f489
                OpReturn
                OpFunctionEnd
 %compute_main = OpFunction %void None %9
-         %32 = OpLabel
-         %33 = OpFunctionCall %void %log_c9f489
+         %29 = OpLabel
+         %30 = OpFunctionCall %void %log_c9f489
                OpReturn
                OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/log/cdbdc1.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log/cdbdc1.wgsl.expected.dxc.hlsl
index 0ce91e5..63f6f0c 100644
--- a/test/tint/builtins/gen/literal/log/cdbdc1.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/log/cdbdc1.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
 void log_cdbdc1() {
-  vector<float16_t, 4> res = log((float16_t(1.0h)).xxxx);
+  vector<float16_t, 4> res = (float16_t(0.0h)).xxxx;
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/log/cdbdc1.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log/cdbdc1.wgsl.expected.glsl
index 272fe40..5533178 100644
--- a/test/tint/builtins/gen/literal/log/cdbdc1.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/log/cdbdc1.wgsl.expected.glsl
@@ -2,7 +2,7 @@
 #extension GL_AMD_gpu_shader_half_float : require
 
 void log_cdbdc1() {
-  f16vec4 res = log(f16vec4(1.0hf));
+  f16vec4 res = f16vec4(0.0hf);
 }
 
 vec4 vertex_main() {
@@ -23,7 +23,7 @@
 precision mediump float;
 
 void log_cdbdc1() {
-  f16vec4 res = log(f16vec4(1.0hf));
+  f16vec4 res = f16vec4(0.0hf);
 }
 
 void fragment_main() {
@@ -38,7 +38,7 @@
 #extension GL_AMD_gpu_shader_half_float : require
 
 void log_cdbdc1() {
-  f16vec4 res = log(f16vec4(1.0hf));
+  f16vec4 res = f16vec4(0.0hf);
 }
 
 void compute_main() {
diff --git a/test/tint/builtins/gen/literal/log/cdbdc1.wgsl.expected.msl b/test/tint/builtins/gen/literal/log/cdbdc1.wgsl.expected.msl
index 7463beb..49a8c75 100644
--- a/test/tint/builtins/gen/literal/log/cdbdc1.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/log/cdbdc1.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void log_cdbdc1() {
-  half4 res = log(half4(1.0h));
+  half4 res = half4(0.0h);
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/log/cdbdc1.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log/cdbdc1.wgsl.expected.spvasm
index a8a48f1..29db7fc 100644
--- a/test/tint/builtins/gen/literal/log/cdbdc1.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/log/cdbdc1.wgsl.expected.spvasm
@@ -1,14 +1,13 @@
 ; SPIR-V
 ; Version: 1.3
 ; Generator: Google Tint Compiler; 0
-; Bound: 36
+; Bound: 32
 ; Schema: 0
                OpCapability Shader
                OpCapability Float16
                OpCapability UniformAndStorageBuffer16BitAccess
                OpCapability StorageBuffer16BitAccess
                OpCapability StorageInputOutput16
-         %16 = OpExtInstImport "GLSL.std.450"
                OpMemoryModel Logical GLSL450
                OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
                OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -37,38 +36,35 @@
           %9 = OpTypeFunction %void
        %half = OpTypeFloat 16
      %v4half = OpTypeVector %half 4
-%half_0x1p_0 = OpConstant %half 0x1p+0
-         %18 = OpConstantComposite %v4half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 %half_0x1p_0
+         %15 = OpConstantNull %v4half
 %_ptr_Function_v4half = OpTypePointer Function %v4half
-         %21 = OpConstantNull %v4half
-         %22 = OpTypeFunction %v4float
+         %18 = OpTypeFunction %v4float
     %float_1 = OpConstant %float 1
  %log_cdbdc1 = OpFunction %void None %9
          %12 = OpLabel
-        %res = OpVariable %_ptr_Function_v4half Function %21
-         %13 = OpExtInst %v4half %16 Log %18
-               OpStore %res %13
+        %res = OpVariable %_ptr_Function_v4half Function %15
+               OpStore %res %15
                OpReturn
                OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %22
-         %24 = OpLabel
-         %25 = OpFunctionCall %void %log_cdbdc1
+%vertex_main_inner = OpFunction %v4float None %18
+         %20 = OpLabel
+         %21 = OpFunctionCall %void %log_cdbdc1
                OpReturnValue %5
                OpFunctionEnd
 %vertex_main = OpFunction %void None %9
-         %27 = OpLabel
-         %28 = OpFunctionCall %v4float %vertex_main_inner
-               OpStore %value %28
+         %23 = OpLabel
+         %24 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %24
                OpStore %vertex_point_size %float_1
                OpReturn
                OpFunctionEnd
 %fragment_main = OpFunction %void None %9
-         %31 = OpLabel
-         %32 = OpFunctionCall %void %log_cdbdc1
+         %27 = OpLabel
+         %28 = OpFunctionCall %void %log_cdbdc1
                OpReturn
                OpFunctionEnd
 %compute_main = OpFunction %void None %9
-         %34 = OpLabel
-         %35 = OpFunctionCall %void %log_cdbdc1
+         %30 = OpLabel
+         %31 = OpFunctionCall %void %log_cdbdc1
                OpReturn
                OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/log/f4c570.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log/f4c570.wgsl.expected.dxc.hlsl
index 28d545b..1a94527 100644
--- a/test/tint/builtins/gen/literal/log/f4c570.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/log/f4c570.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
 void log_f4c570() {
-  float3 res = log((1.0f).xxx);
+  float3 res = (0.0f).xxx;
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/log/f4c570.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/log/f4c570.wgsl.expected.fxc.hlsl
index 28d545b..1a94527 100644
--- a/test/tint/builtins/gen/literal/log/f4c570.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/log/f4c570.wgsl.expected.fxc.hlsl
@@ -1,5 +1,5 @@
 void log_f4c570() {
-  float3 res = log((1.0f).xxx);
+  float3 res = (0.0f).xxx;
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/log/f4c570.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log/f4c570.wgsl.expected.glsl
index 6a8af44..2537bba 100644
--- a/test/tint/builtins/gen/literal/log/f4c570.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/log/f4c570.wgsl.expected.glsl
@@ -1,7 +1,7 @@
 #version 310 es
 
 void log_f4c570() {
-  vec3 res = log(vec3(1.0f));
+  vec3 res = vec3(0.0f);
 }
 
 vec4 vertex_main() {
@@ -21,7 +21,7 @@
 precision mediump float;
 
 void log_f4c570() {
-  vec3 res = log(vec3(1.0f));
+  vec3 res = vec3(0.0f);
 }
 
 void fragment_main() {
@@ -35,7 +35,7 @@
 #version 310 es
 
 void log_f4c570() {
-  vec3 res = log(vec3(1.0f));
+  vec3 res = vec3(0.0f);
 }
 
 void compute_main() {
diff --git a/test/tint/builtins/gen/literal/log/f4c570.wgsl.expected.msl b/test/tint/builtins/gen/literal/log/f4c570.wgsl.expected.msl
index 7f61e97..afa7672 100644
--- a/test/tint/builtins/gen/literal/log/f4c570.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/log/f4c570.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void log_f4c570() {
-  float3 res = log(float3(1.0f));
+  float3 res = float3(0.0f);
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/log/f4c570.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log/f4c570.wgsl.expected.spvasm
index c0d6533..799dd64 100644
--- a/test/tint/builtins/gen/literal/log/f4c570.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/log/f4c570.wgsl.expected.spvasm
@@ -1,10 +1,9 @@
 ; SPIR-V
 ; Version: 1.3
 ; Generator: Google Tint Compiler; 0
-; Bound: 34
+; Bound: 31
 ; Schema: 0
                OpCapability Shader
-         %15 = OpExtInstImport "GLSL.std.450"
                OpMemoryModel Logical GLSL450
                OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
                OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -32,37 +31,35 @@
        %void = OpTypeVoid
           %9 = OpTypeFunction %void
     %v3float = OpTypeVector %float 3
-    %float_1 = OpConstant %float 1
-         %17 = OpConstantComposite %v3float %float_1 %float_1 %float_1
+         %14 = OpConstantNull %v3float
 %_ptr_Function_v3float = OpTypePointer Function %v3float
-         %20 = OpConstantNull %v3float
-         %21 = OpTypeFunction %v4float
+         %17 = OpTypeFunction %v4float
+    %float_1 = OpConstant %float 1
  %log_f4c570 = OpFunction %void None %9
          %12 = OpLabel
-        %res = OpVariable %_ptr_Function_v3float Function %20
-         %13 = OpExtInst %v3float %15 Log %17
-               OpStore %res %13
+        %res = OpVariable %_ptr_Function_v3float Function %14
+               OpStore %res %14
                OpReturn
                OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %21
-         %23 = OpLabel
-         %24 = OpFunctionCall %void %log_f4c570
+%vertex_main_inner = OpFunction %v4float None %17
+         %19 = OpLabel
+         %20 = OpFunctionCall %void %log_f4c570
                OpReturnValue %5
                OpFunctionEnd
 %vertex_main = OpFunction %void None %9
-         %26 = OpLabel
-         %27 = OpFunctionCall %v4float %vertex_main_inner
-               OpStore %value %27
+         %22 = OpLabel
+         %23 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %23
                OpStore %vertex_point_size %float_1
                OpReturn
                OpFunctionEnd
 %fragment_main = OpFunction %void None %9
-         %29 = OpLabel
-         %30 = OpFunctionCall %void %log_f4c570
+         %26 = OpLabel
+         %27 = OpFunctionCall %void %log_f4c570
                OpReturn
                OpFunctionEnd
 %compute_main = OpFunction %void None %9
-         %32 = OpLabel
-         %33 = OpFunctionCall %void %log_f4c570
+         %29 = OpLabel
+         %30 = OpFunctionCall %void %log_f4c570
                OpReturn
                OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/log/f60cc7.wgsl b/test/tint/builtins/gen/literal/log/f60cc7.wgsl
new file mode 100644
index 0000000..971c4e1
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log/f60cc7.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 log(vec<2, fa>) -> vec<2, fa>
+fn log_f60cc7() {
+  var res = log(vec2(1.));
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  log_f60cc7();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  log_f60cc7();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  log_f60cc7();
+}
diff --git a/test/tint/builtins/gen/literal/log/f60cc7.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log/f60cc7.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..41dbc64
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log/f60cc7.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void log_f60cc7() {
+  float2 res = (0.0f).xx;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  log_f60cc7();
+  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() {
+  log_f60cc7();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  log_f60cc7();
+  return;
+}
diff --git a/test/tint/builtins/gen/literal/log/f60cc7.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/log/f60cc7.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..41dbc64
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log/f60cc7.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void log_f60cc7() {
+  float2 res = (0.0f).xx;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  log_f60cc7();
+  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() {
+  log_f60cc7();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  log_f60cc7();
+  return;
+}
diff --git a/test/tint/builtins/gen/literal/log/f60cc7.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log/f60cc7.wgsl.expected.glsl
new file mode 100644
index 0000000..d29f386
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log/f60cc7.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void log_f60cc7() {
+  vec2 res = vec2(0.0f);
+}
+
+vec4 vertex_main() {
+  log_f60cc7();
+  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 log_f60cc7() {
+  vec2 res = vec2(0.0f);
+}
+
+void fragment_main() {
+  log_f60cc7();
+}
+
+void main() {
+  fragment_main();
+  return;
+}
+#version 310 es
+
+void log_f60cc7() {
+  vec2 res = vec2(0.0f);
+}
+
+void compute_main() {
+  log_f60cc7();
+}
+
+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/log/f60cc7.wgsl.expected.msl b/test/tint/builtins/gen/literal/log/f60cc7.wgsl.expected.msl
new file mode 100644
index 0000000..831c100
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log/f60cc7.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void log_f60cc7() {
+  float2 res = float2(0.0f);
+}
+
+struct tint_symbol {
+  float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+  log_f60cc7();
+  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() {
+  log_f60cc7();
+  return;
+}
+
+kernel void compute_main() {
+  log_f60cc7();
+  return;
+}
+
diff --git a/test/tint/builtins/gen/literal/log/f60cc7.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log/f60cc7.wgsl.expected.spvasm
new file mode 100644
index 0000000..f7f08c4
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log/f60cc7.wgsl.expected.spvasm
@@ -0,0 +1,65 @@
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 0
+; Bound: 31
+; 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 %log_f60cc7 "log_f60cc7"
+               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
+         %14 = OpConstantNull %v2float
+%_ptr_Function_v2float = OpTypePointer Function %v2float
+         %17 = OpTypeFunction %v4float
+    %float_1 = OpConstant %float 1
+ %log_f60cc7 = OpFunction %void None %9
+         %12 = OpLabel
+        %res = OpVariable %_ptr_Function_v2float Function %14
+               OpStore %res %14
+               OpReturn
+               OpFunctionEnd
+%vertex_main_inner = OpFunction %v4float None %17
+         %19 = OpLabel
+         %20 = OpFunctionCall %void %log_f60cc7
+               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
+         %26 = OpLabel
+         %27 = OpFunctionCall %void %log_f60cc7
+               OpReturn
+               OpFunctionEnd
+%compute_main = OpFunction %void None %9
+         %29 = OpLabel
+         %30 = OpFunctionCall %void %log_f60cc7
+               OpReturn
+               OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/log/f60cc7.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/log/f60cc7.wgsl.expected.wgsl
new file mode 100644
index 0000000..071eddf
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log/f60cc7.wgsl.expected.wgsl
@@ -0,0 +1,19 @@
+fn log_f60cc7() {
+  var res = log(vec2(1.0));
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  log_f60cc7();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  log_f60cc7();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  log_f60cc7();
+}
diff --git a/test/tint/builtins/gen/literal/log2/0fbd39.wgsl b/test/tint/builtins/gen/literal/log2/0fbd39.wgsl
new file mode 100644
index 0000000..4e61b7b
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log2/0fbd39.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 log2(vec<3, fa>) -> vec<3, fa>
+fn log2_0fbd39() {
+  var res = log2(vec3(1.));
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  log2_0fbd39();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  log2_0fbd39();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  log2_0fbd39();
+}
diff --git a/test/tint/builtins/gen/literal/log2/0fbd39.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log2/0fbd39.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..9ddf089
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log2/0fbd39.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void log2_0fbd39() {
+  float3 res = (0.0f).xxx;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  log2_0fbd39();
+  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() {
+  log2_0fbd39();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  log2_0fbd39();
+  return;
+}
diff --git a/test/tint/builtins/gen/literal/log2/0fbd39.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/log2/0fbd39.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..9ddf089
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log2/0fbd39.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void log2_0fbd39() {
+  float3 res = (0.0f).xxx;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  log2_0fbd39();
+  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() {
+  log2_0fbd39();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  log2_0fbd39();
+  return;
+}
diff --git a/test/tint/builtins/gen/literal/log2/0fbd39.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log2/0fbd39.wgsl.expected.glsl
new file mode 100644
index 0000000..9759833
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log2/0fbd39.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void log2_0fbd39() {
+  vec3 res = vec3(0.0f);
+}
+
+vec4 vertex_main() {
+  log2_0fbd39();
+  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 log2_0fbd39() {
+  vec3 res = vec3(0.0f);
+}
+
+void fragment_main() {
+  log2_0fbd39();
+}
+
+void main() {
+  fragment_main();
+  return;
+}
+#version 310 es
+
+void log2_0fbd39() {
+  vec3 res = vec3(0.0f);
+}
+
+void compute_main() {
+  log2_0fbd39();
+}
+
+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/log2/0fbd39.wgsl.expected.msl b/test/tint/builtins/gen/literal/log2/0fbd39.wgsl.expected.msl
new file mode 100644
index 0000000..f9e505a
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log2/0fbd39.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void log2_0fbd39() {
+  float3 res = float3(0.0f);
+}
+
+struct tint_symbol {
+  float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+  log2_0fbd39();
+  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() {
+  log2_0fbd39();
+  return;
+}
+
+kernel void compute_main() {
+  log2_0fbd39();
+  return;
+}
+
diff --git a/test/tint/builtins/gen/literal/log2/0fbd39.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log2/0fbd39.wgsl.expected.spvasm
new file mode 100644
index 0000000..b983201
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log2/0fbd39.wgsl.expected.spvasm
@@ -0,0 +1,65 @@
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 0
+; Bound: 31
+; 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 %log2_0fbd39 "log2_0fbd39"
+               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
+         %14 = OpConstantNull %v3float
+%_ptr_Function_v3float = OpTypePointer Function %v3float
+         %17 = OpTypeFunction %v4float
+    %float_1 = OpConstant %float 1
+%log2_0fbd39 = OpFunction %void None %9
+         %12 = OpLabel
+        %res = OpVariable %_ptr_Function_v3float Function %14
+               OpStore %res %14
+               OpReturn
+               OpFunctionEnd
+%vertex_main_inner = OpFunction %v4float None %17
+         %19 = OpLabel
+         %20 = OpFunctionCall %void %log2_0fbd39
+               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
+         %26 = OpLabel
+         %27 = OpFunctionCall %void %log2_0fbd39
+               OpReturn
+               OpFunctionEnd
+%compute_main = OpFunction %void None %9
+         %29 = OpLabel
+         %30 = OpFunctionCall %void %log2_0fbd39
+               OpReturn
+               OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/log2/0fbd39.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/log2/0fbd39.wgsl.expected.wgsl
new file mode 100644
index 0000000..1c8922f
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log2/0fbd39.wgsl.expected.wgsl
@@ -0,0 +1,19 @@
+fn log2_0fbd39() {
+  var res = log2(vec3(1.0));
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  log2_0fbd39();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  log2_0fbd39();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  log2_0fbd39();
+}
diff --git a/test/tint/builtins/gen/literal/log2/38b478.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log2/38b478.wgsl.expected.dxc.hlsl
index 487dd6f..e03ccef 100644
--- a/test/tint/builtins/gen/literal/log2/38b478.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/log2/38b478.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
 void log2_38b478() {
-  vector<float16_t, 3> res = log2((float16_t(1.0h)).xxx);
+  vector<float16_t, 3> res = (float16_t(0.0h)).xxx;
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/log2/38b478.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log2/38b478.wgsl.expected.glsl
index a48af86..747de5e 100644
--- a/test/tint/builtins/gen/literal/log2/38b478.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/log2/38b478.wgsl.expected.glsl
@@ -2,7 +2,7 @@
 #extension GL_AMD_gpu_shader_half_float : require
 
 void log2_38b478() {
-  f16vec3 res = log2(f16vec3(1.0hf));
+  f16vec3 res = f16vec3(0.0hf);
 }
 
 vec4 vertex_main() {
@@ -23,7 +23,7 @@
 precision mediump float;
 
 void log2_38b478() {
-  f16vec3 res = log2(f16vec3(1.0hf));
+  f16vec3 res = f16vec3(0.0hf);
 }
 
 void fragment_main() {
@@ -38,7 +38,7 @@
 #extension GL_AMD_gpu_shader_half_float : require
 
 void log2_38b478() {
-  f16vec3 res = log2(f16vec3(1.0hf));
+  f16vec3 res = f16vec3(0.0hf);
 }
 
 void compute_main() {
diff --git a/test/tint/builtins/gen/literal/log2/38b478.wgsl.expected.msl b/test/tint/builtins/gen/literal/log2/38b478.wgsl.expected.msl
index 8a6fb00..c5df79a 100644
--- a/test/tint/builtins/gen/literal/log2/38b478.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/log2/38b478.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void log2_38b478() {
-  half3 res = log2(half3(1.0h));
+  half3 res = half3(0.0h);
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/log2/38b478.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log2/38b478.wgsl.expected.spvasm
index e150bb5..e8a7567 100644
--- a/test/tint/builtins/gen/literal/log2/38b478.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/log2/38b478.wgsl.expected.spvasm
@@ -1,14 +1,13 @@
 ; SPIR-V
 ; Version: 1.3
 ; Generator: Google Tint Compiler; 0
-; Bound: 36
+; Bound: 32
 ; Schema: 0
                OpCapability Shader
                OpCapability Float16
                OpCapability UniformAndStorageBuffer16BitAccess
                OpCapability StorageBuffer16BitAccess
                OpCapability StorageInputOutput16
-         %16 = OpExtInstImport "GLSL.std.450"
                OpMemoryModel Logical GLSL450
                OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
                OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -37,38 +36,35 @@
           %9 = OpTypeFunction %void
        %half = OpTypeFloat 16
      %v3half = OpTypeVector %half 3
-%half_0x1p_0 = OpConstant %half 0x1p+0
-         %18 = OpConstantComposite %v3half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0
+         %15 = OpConstantNull %v3half
 %_ptr_Function_v3half = OpTypePointer Function %v3half
-         %21 = OpConstantNull %v3half
-         %22 = OpTypeFunction %v4float
+         %18 = OpTypeFunction %v4float
     %float_1 = OpConstant %float 1
 %log2_38b478 = OpFunction %void None %9
          %12 = OpLabel
-        %res = OpVariable %_ptr_Function_v3half Function %21
-         %13 = OpExtInst %v3half %16 Log2 %18
-               OpStore %res %13
+        %res = OpVariable %_ptr_Function_v3half Function %15
+               OpStore %res %15
                OpReturn
                OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %22
-         %24 = OpLabel
-         %25 = OpFunctionCall %void %log2_38b478
+%vertex_main_inner = OpFunction %v4float None %18
+         %20 = OpLabel
+         %21 = OpFunctionCall %void %log2_38b478
                OpReturnValue %5
                OpFunctionEnd
 %vertex_main = OpFunction %void None %9
-         %27 = OpLabel
-         %28 = OpFunctionCall %v4float %vertex_main_inner
-               OpStore %value %28
+         %23 = OpLabel
+         %24 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %24
                OpStore %vertex_point_size %float_1
                OpReturn
                OpFunctionEnd
 %fragment_main = OpFunction %void None %9
-         %31 = OpLabel
-         %32 = OpFunctionCall %void %log2_38b478
+         %27 = OpLabel
+         %28 = OpFunctionCall %void %log2_38b478
                OpReturn
                OpFunctionEnd
 %compute_main = OpFunction %void None %9
-         %34 = OpLabel
-         %35 = OpFunctionCall %void %log2_38b478
+         %30 = OpLabel
+         %31 = OpFunctionCall %void %log2_38b478
                OpReturn
                OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/log2/4036ed.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log2/4036ed.wgsl.expected.dxc.hlsl
index 1bea97c..da5dd4e 100644
--- a/test/tint/builtins/gen/literal/log2/4036ed.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/log2/4036ed.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
 void log2_4036ed() {
-  float res = log2(1.0f);
+  float res = 0.0f;
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/log2/4036ed.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/log2/4036ed.wgsl.expected.fxc.hlsl
index 1bea97c..da5dd4e 100644
--- a/test/tint/builtins/gen/literal/log2/4036ed.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/log2/4036ed.wgsl.expected.fxc.hlsl
@@ -1,5 +1,5 @@
 void log2_4036ed() {
-  float res = log2(1.0f);
+  float res = 0.0f;
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/log2/4036ed.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log2/4036ed.wgsl.expected.glsl
index 842c021..01c3ca0 100644
--- a/test/tint/builtins/gen/literal/log2/4036ed.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/log2/4036ed.wgsl.expected.glsl
@@ -1,7 +1,7 @@
 #version 310 es
 
 void log2_4036ed() {
-  float res = log2(1.0f);
+  float res = 0.0f;
 }
 
 vec4 vertex_main() {
@@ -21,7 +21,7 @@
 precision mediump float;
 
 void log2_4036ed() {
-  float res = log2(1.0f);
+  float res = 0.0f;
 }
 
 void fragment_main() {
@@ -35,7 +35,7 @@
 #version 310 es
 
 void log2_4036ed() {
-  float res = log2(1.0f);
+  float res = 0.0f;
 }
 
 void compute_main() {
diff --git a/test/tint/builtins/gen/literal/log2/4036ed.wgsl.expected.msl b/test/tint/builtins/gen/literal/log2/4036ed.wgsl.expected.msl
index e88769f..12a5aec 100644
--- a/test/tint/builtins/gen/literal/log2/4036ed.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/log2/4036ed.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void log2_4036ed() {
-  float res = log2(1.0f);
+  float res = 0.0f;
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/log2/4036ed.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log2/4036ed.wgsl.expected.spvasm
index 197b7a2..0f87a46 100644
--- a/test/tint/builtins/gen/literal/log2/4036ed.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/log2/4036ed.wgsl.expected.spvasm
@@ -1,10 +1,9 @@
 ; SPIR-V
 ; Version: 1.3
 ; Generator: Google Tint Compiler; 0
-; Bound: 31
+; Bound: 29
 ; Schema: 0
                OpCapability Shader
-         %14 = OpExtInstImport "GLSL.std.450"
                OpMemoryModel Logical GLSL450
                OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
                OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -31,35 +30,34 @@
 %vertex_point_size = OpVariable %_ptr_Output_float Output %8
        %void = OpTypeVoid
           %9 = OpTypeFunction %void
-    %float_1 = OpConstant %float 1
 %_ptr_Function_float = OpTypePointer Function %float
-         %18 = OpTypeFunction %v4float
+         %15 = OpTypeFunction %v4float
+    %float_1 = OpConstant %float 1
 %log2_4036ed = OpFunction %void None %9
          %12 = OpLabel
         %res = OpVariable %_ptr_Function_float Function %8
-         %13 = OpExtInst %float %14 Log2 %float_1
-               OpStore %res %13
+               OpStore %res %8
                OpReturn
                OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %18
-         %20 = OpLabel
-         %21 = OpFunctionCall %void %log2_4036ed
+%vertex_main_inner = OpFunction %v4float None %15
+         %17 = OpLabel
+         %18 = OpFunctionCall %void %log2_4036ed
                OpReturnValue %5
                OpFunctionEnd
 %vertex_main = OpFunction %void None %9
-         %23 = OpLabel
-         %24 = OpFunctionCall %v4float %vertex_main_inner
-               OpStore %value %24
+         %20 = OpLabel
+         %21 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %21
                OpStore %vertex_point_size %float_1
                OpReturn
                OpFunctionEnd
 %fragment_main = OpFunction %void None %9
-         %26 = OpLabel
-         %27 = OpFunctionCall %void %log2_4036ed
+         %24 = OpLabel
+         %25 = OpFunctionCall %void %log2_4036ed
                OpReturn
                OpFunctionEnd
 %compute_main = OpFunction %void None %9
-         %29 = OpLabel
-         %30 = OpFunctionCall %void %log2_4036ed
+         %27 = OpLabel
+         %28 = OpFunctionCall %void %log2_4036ed
                OpReturn
                OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/log2/5b464b.wgsl b/test/tint/builtins/gen/literal/log2/5b464b.wgsl
new file mode 100644
index 0000000..4610d94
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log2/5b464b.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 log2(fa) -> fa
+fn log2_5b464b() {
+  var res = log2(1.);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  log2_5b464b();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  log2_5b464b();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  log2_5b464b();
+}
diff --git a/test/tint/builtins/gen/literal/log2/5b464b.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log2/5b464b.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..87f9f25
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log2/5b464b.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void log2_5b464b() {
+  float res = 0.0f;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  log2_5b464b();
+  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() {
+  log2_5b464b();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  log2_5b464b();
+  return;
+}
diff --git a/test/tint/builtins/gen/literal/log2/5b464b.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/log2/5b464b.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..87f9f25
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log2/5b464b.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void log2_5b464b() {
+  float res = 0.0f;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  log2_5b464b();
+  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() {
+  log2_5b464b();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  log2_5b464b();
+  return;
+}
diff --git a/test/tint/builtins/gen/literal/log2/5b464b.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log2/5b464b.wgsl.expected.glsl
new file mode 100644
index 0000000..1429b32
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log2/5b464b.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void log2_5b464b() {
+  float res = 0.0f;
+}
+
+vec4 vertex_main() {
+  log2_5b464b();
+  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 log2_5b464b() {
+  float res = 0.0f;
+}
+
+void fragment_main() {
+  log2_5b464b();
+}
+
+void main() {
+  fragment_main();
+  return;
+}
+#version 310 es
+
+void log2_5b464b() {
+  float res = 0.0f;
+}
+
+void compute_main() {
+  log2_5b464b();
+}
+
+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/log2/5b464b.wgsl.expected.msl b/test/tint/builtins/gen/literal/log2/5b464b.wgsl.expected.msl
new file mode 100644
index 0000000..a7547e3
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log2/5b464b.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void log2_5b464b() {
+  float res = 0.0f;
+}
+
+struct tint_symbol {
+  float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+  log2_5b464b();
+  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() {
+  log2_5b464b();
+  return;
+}
+
+kernel void compute_main() {
+  log2_5b464b();
+  return;
+}
+
diff --git a/test/tint/builtins/gen/literal/log2/5b464b.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log2/5b464b.wgsl.expected.spvasm
new file mode 100644
index 0000000..d42ca7e
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log2/5b464b.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 %log2_5b464b "log2_5b464b"
+               OpName %res "res"
+               OpName %vertex_main_inner "vertex_main_inner"
+               OpName %vertex_main "vertex_main"
+               OpName %fragment_main "fragment_main"
+               OpName %compute_main "compute_main"
+               OpDecorate %value BuiltIn Position
+               OpDecorate %vertex_point_size BuiltIn PointSize
+      %float = OpTypeFloat 32
+    %v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+          %5 = OpConstantNull %v4float
+      %value = OpVariable %_ptr_Output_v4float Output %5
+%_ptr_Output_float = OpTypePointer Output %float
+          %8 = OpConstantNull %float
+%vertex_point_size = OpVariable %_ptr_Output_float Output %8
+       %void = OpTypeVoid
+          %9 = OpTypeFunction %void
+%_ptr_Function_float = OpTypePointer Function %float
+         %15 = OpTypeFunction %v4float
+    %float_1 = OpConstant %float 1
+%log2_5b464b = OpFunction %void None %9
+         %12 = OpLabel
+        %res = OpVariable %_ptr_Function_float Function %8
+               OpStore %res %8
+               OpReturn
+               OpFunctionEnd
+%vertex_main_inner = OpFunction %v4float None %15
+         %17 = OpLabel
+         %18 = OpFunctionCall %void %log2_5b464b
+               OpReturnValue %5
+               OpFunctionEnd
+%vertex_main = OpFunction %void None %9
+         %20 = OpLabel
+         %21 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %21
+               OpStore %vertex_point_size %float_1
+               OpReturn
+               OpFunctionEnd
+%fragment_main = OpFunction %void None %9
+         %24 = OpLabel
+         %25 = OpFunctionCall %void %log2_5b464b
+               OpReturn
+               OpFunctionEnd
+%compute_main = OpFunction %void None %9
+         %27 = OpLabel
+         %28 = OpFunctionCall %void %log2_5b464b
+               OpReturn
+               OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/log2/5b464b.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/log2/5b464b.wgsl.expected.wgsl
new file mode 100644
index 0000000..8439fe7
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log2/5b464b.wgsl.expected.wgsl
@@ -0,0 +1,19 @@
+fn log2_5b464b() {
+  var res = log2(1.0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  log2_5b464b();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  log2_5b464b();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  log2_5b464b();
+}
diff --git a/test/tint/builtins/gen/literal/log2/6b8954.wgsl b/test/tint/builtins/gen/literal/log2/6b8954.wgsl
new file mode 100644
index 0000000..0455660
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log2/6b8954.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 log2(vec<2, fa>) -> vec<2, fa>
+fn log2_6b8954() {
+  var res = log2(vec2(1.));
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  log2_6b8954();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  log2_6b8954();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  log2_6b8954();
+}
diff --git a/test/tint/builtins/gen/literal/log2/6b8954.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log2/6b8954.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..1bd35a7
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log2/6b8954.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void log2_6b8954() {
+  float2 res = (0.0f).xx;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  log2_6b8954();
+  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() {
+  log2_6b8954();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  log2_6b8954();
+  return;
+}
diff --git a/test/tint/builtins/gen/literal/log2/6b8954.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/log2/6b8954.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..1bd35a7
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log2/6b8954.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void log2_6b8954() {
+  float2 res = (0.0f).xx;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  log2_6b8954();
+  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() {
+  log2_6b8954();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  log2_6b8954();
+  return;
+}
diff --git a/test/tint/builtins/gen/literal/log2/6b8954.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log2/6b8954.wgsl.expected.glsl
new file mode 100644
index 0000000..b7d204c
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log2/6b8954.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void log2_6b8954() {
+  vec2 res = vec2(0.0f);
+}
+
+vec4 vertex_main() {
+  log2_6b8954();
+  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 log2_6b8954() {
+  vec2 res = vec2(0.0f);
+}
+
+void fragment_main() {
+  log2_6b8954();
+}
+
+void main() {
+  fragment_main();
+  return;
+}
+#version 310 es
+
+void log2_6b8954() {
+  vec2 res = vec2(0.0f);
+}
+
+void compute_main() {
+  log2_6b8954();
+}
+
+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/log2/6b8954.wgsl.expected.msl b/test/tint/builtins/gen/literal/log2/6b8954.wgsl.expected.msl
new file mode 100644
index 0000000..8e2cad2
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log2/6b8954.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void log2_6b8954() {
+  float2 res = float2(0.0f);
+}
+
+struct tint_symbol {
+  float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+  log2_6b8954();
+  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() {
+  log2_6b8954();
+  return;
+}
+
+kernel void compute_main() {
+  log2_6b8954();
+  return;
+}
+
diff --git a/test/tint/builtins/gen/literal/log2/6b8954.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log2/6b8954.wgsl.expected.spvasm
new file mode 100644
index 0000000..e3a10e7
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log2/6b8954.wgsl.expected.spvasm
@@ -0,0 +1,65 @@
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 0
+; Bound: 31
+; 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 %log2_6b8954 "log2_6b8954"
+               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
+         %14 = OpConstantNull %v2float
+%_ptr_Function_v2float = OpTypePointer Function %v2float
+         %17 = OpTypeFunction %v4float
+    %float_1 = OpConstant %float 1
+%log2_6b8954 = OpFunction %void None %9
+         %12 = OpLabel
+        %res = OpVariable %_ptr_Function_v2float Function %14
+               OpStore %res %14
+               OpReturn
+               OpFunctionEnd
+%vertex_main_inner = OpFunction %v4float None %17
+         %19 = OpLabel
+         %20 = OpFunctionCall %void %log2_6b8954
+               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
+         %26 = OpLabel
+         %27 = OpFunctionCall %void %log2_6b8954
+               OpReturn
+               OpFunctionEnd
+%compute_main = OpFunction %void None %9
+         %29 = OpLabel
+         %30 = OpFunctionCall %void %log2_6b8954
+               OpReturn
+               OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/log2/6b8954.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/log2/6b8954.wgsl.expected.wgsl
new file mode 100644
index 0000000..f2cf58e
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log2/6b8954.wgsl.expected.wgsl
@@ -0,0 +1,19 @@
+fn log2_6b8954() {
+  var res = log2(vec2(1.0));
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  log2_6b8954();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  log2_6b8954();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  log2_6b8954();
+}
diff --git a/test/tint/builtins/gen/literal/log2/776088.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log2/776088.wgsl.expected.dxc.hlsl
index 70fb5d8..6eba104 100644
--- a/test/tint/builtins/gen/literal/log2/776088.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/log2/776088.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
 void log2_776088() {
-  vector<float16_t, 4> res = log2((float16_t(1.0h)).xxxx);
+  vector<float16_t, 4> res = (float16_t(0.0h)).xxxx;
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/log2/776088.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log2/776088.wgsl.expected.glsl
index 2024e28..75dfbd1 100644
--- a/test/tint/builtins/gen/literal/log2/776088.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/log2/776088.wgsl.expected.glsl
@@ -2,7 +2,7 @@
 #extension GL_AMD_gpu_shader_half_float : require
 
 void log2_776088() {
-  f16vec4 res = log2(f16vec4(1.0hf));
+  f16vec4 res = f16vec4(0.0hf);
 }
 
 vec4 vertex_main() {
@@ -23,7 +23,7 @@
 precision mediump float;
 
 void log2_776088() {
-  f16vec4 res = log2(f16vec4(1.0hf));
+  f16vec4 res = f16vec4(0.0hf);
 }
 
 void fragment_main() {
@@ -38,7 +38,7 @@
 #extension GL_AMD_gpu_shader_half_float : require
 
 void log2_776088() {
-  f16vec4 res = log2(f16vec4(1.0hf));
+  f16vec4 res = f16vec4(0.0hf);
 }
 
 void compute_main() {
diff --git a/test/tint/builtins/gen/literal/log2/776088.wgsl.expected.msl b/test/tint/builtins/gen/literal/log2/776088.wgsl.expected.msl
index 62e73b1..e88c875 100644
--- a/test/tint/builtins/gen/literal/log2/776088.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/log2/776088.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void log2_776088() {
-  half4 res = log2(half4(1.0h));
+  half4 res = half4(0.0h);
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/log2/776088.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log2/776088.wgsl.expected.spvasm
index aa2534c..965facb 100644
--- a/test/tint/builtins/gen/literal/log2/776088.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/log2/776088.wgsl.expected.spvasm
@@ -1,14 +1,13 @@
 ; SPIR-V
 ; Version: 1.3
 ; Generator: Google Tint Compiler; 0
-; Bound: 36
+; Bound: 32
 ; Schema: 0
                OpCapability Shader
                OpCapability Float16
                OpCapability UniformAndStorageBuffer16BitAccess
                OpCapability StorageBuffer16BitAccess
                OpCapability StorageInputOutput16
-         %16 = OpExtInstImport "GLSL.std.450"
                OpMemoryModel Logical GLSL450
                OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
                OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -37,38 +36,35 @@
           %9 = OpTypeFunction %void
        %half = OpTypeFloat 16
      %v4half = OpTypeVector %half 4
-%half_0x1p_0 = OpConstant %half 0x1p+0
-         %18 = OpConstantComposite %v4half %half_0x1p_0 %half_0x1p_0 %half_0x1p_0 %half_0x1p_0
+         %15 = OpConstantNull %v4half
 %_ptr_Function_v4half = OpTypePointer Function %v4half
-         %21 = OpConstantNull %v4half
-         %22 = OpTypeFunction %v4float
+         %18 = OpTypeFunction %v4float
     %float_1 = OpConstant %float 1
 %log2_776088 = OpFunction %void None %9
          %12 = OpLabel
-        %res = OpVariable %_ptr_Function_v4half Function %21
-         %13 = OpExtInst %v4half %16 Log2 %18
-               OpStore %res %13
+        %res = OpVariable %_ptr_Function_v4half Function %15
+               OpStore %res %15
                OpReturn
                OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %22
-         %24 = OpLabel
-         %25 = OpFunctionCall %void %log2_776088
+%vertex_main_inner = OpFunction %v4float None %18
+         %20 = OpLabel
+         %21 = OpFunctionCall %void %log2_776088
                OpReturnValue %5
                OpFunctionEnd
 %vertex_main = OpFunction %void None %9
-         %27 = OpLabel
-         %28 = OpFunctionCall %v4float %vertex_main_inner
-               OpStore %value %28
+         %23 = OpLabel
+         %24 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %24
                OpStore %vertex_point_size %float_1
                OpReturn
                OpFunctionEnd
 %fragment_main = OpFunction %void None %9
-         %31 = OpLabel
-         %32 = OpFunctionCall %void %log2_776088
+         %27 = OpLabel
+         %28 = OpFunctionCall %void %log2_776088
                OpReturn
                OpFunctionEnd
 %compute_main = OpFunction %void None %9
-         %34 = OpLabel
-         %35 = OpFunctionCall %void %log2_776088
+         %30 = OpLabel
+         %31 = OpFunctionCall %void %log2_776088
                OpReturn
                OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/log2/8c10b3.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log2/8c10b3.wgsl.expected.dxc.hlsl
index 6049929..af4452e 100644
--- a/test/tint/builtins/gen/literal/log2/8c10b3.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/log2/8c10b3.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
 void log2_8c10b3() {
-  float16_t res = log2(float16_t(1.0h));
+  float16_t res = float16_t(0.0h);
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/log2/8c10b3.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log2/8c10b3.wgsl.expected.glsl
index 92d34db..34fdf37 100644
--- a/test/tint/builtins/gen/literal/log2/8c10b3.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/log2/8c10b3.wgsl.expected.glsl
@@ -2,7 +2,7 @@
 #extension GL_AMD_gpu_shader_half_float : require
 
 void log2_8c10b3() {
-  float16_t res = log2(1.0hf);
+  float16_t res = 0.0hf;
 }
 
 vec4 vertex_main() {
@@ -23,7 +23,7 @@
 precision mediump float;
 
 void log2_8c10b3() {
-  float16_t res = log2(1.0hf);
+  float16_t res = 0.0hf;
 }
 
 void fragment_main() {
@@ -38,7 +38,7 @@
 #extension GL_AMD_gpu_shader_half_float : require
 
 void log2_8c10b3() {
-  float16_t res = log2(1.0hf);
+  float16_t res = 0.0hf;
 }
 
 void compute_main() {
diff --git a/test/tint/builtins/gen/literal/log2/8c10b3.wgsl.expected.msl b/test/tint/builtins/gen/literal/log2/8c10b3.wgsl.expected.msl
index 55342a8..c1d8b32 100644
--- a/test/tint/builtins/gen/literal/log2/8c10b3.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/log2/8c10b3.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void log2_8c10b3() {
-  half res = log2(1.0h);
+  half res = 0.0h;
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/log2/8c10b3.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log2/8c10b3.wgsl.expected.spvasm
index 121842e..994bb14 100644
--- a/test/tint/builtins/gen/literal/log2/8c10b3.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/log2/8c10b3.wgsl.expected.spvasm
@@ -1,14 +1,13 @@
 ; SPIR-V
 ; Version: 1.3
 ; Generator: Google Tint Compiler; 0
-; Bound: 34
+; Bound: 31
 ; Schema: 0
                OpCapability Shader
                OpCapability Float16
                OpCapability UniformAndStorageBuffer16BitAccess
                OpCapability StorageBuffer16BitAccess
                OpCapability StorageInputOutput16
-         %15 = OpExtInstImport "GLSL.std.450"
                OpMemoryModel Logical GLSL450
                OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
                OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -36,37 +35,35 @@
        %void = OpTypeVoid
           %9 = OpTypeFunction %void
        %half = OpTypeFloat 16
-%half_0x1p_0 = OpConstant %half 0x1p+0
+         %14 = OpConstantNull %half
 %_ptr_Function_half = OpTypePointer Function %half
-         %19 = OpConstantNull %half
-         %20 = OpTypeFunction %v4float
+         %17 = OpTypeFunction %v4float
     %float_1 = OpConstant %float 1
 %log2_8c10b3 = OpFunction %void None %9
          %12 = OpLabel
-        %res = OpVariable %_ptr_Function_half Function %19
-         %13 = OpExtInst %half %15 Log2 %half_0x1p_0
-               OpStore %res %13
+        %res = OpVariable %_ptr_Function_half Function %14
+               OpStore %res %14
                OpReturn
                OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %20
-         %22 = OpLabel
-         %23 = OpFunctionCall %void %log2_8c10b3
+%vertex_main_inner = OpFunction %v4float None %17
+         %19 = OpLabel
+         %20 = OpFunctionCall %void %log2_8c10b3
                OpReturnValue %5
                OpFunctionEnd
 %vertex_main = OpFunction %void None %9
-         %25 = OpLabel
-         %26 = OpFunctionCall %v4float %vertex_main_inner
-               OpStore %value %26
+         %22 = OpLabel
+         %23 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %23
                OpStore %vertex_point_size %float_1
                OpReturn
                OpFunctionEnd
 %fragment_main = OpFunction %void None %9
-         %29 = OpLabel
-         %30 = OpFunctionCall %void %log2_8c10b3
+         %26 = OpLabel
+         %27 = OpFunctionCall %void %log2_8c10b3
                OpReturn
                OpFunctionEnd
 %compute_main = OpFunction %void None %9
-         %32 = OpLabel
-         %33 = OpFunctionCall %void %log2_8c10b3
+         %29 = OpLabel
+         %30 = OpFunctionCall %void %log2_8c10b3
                OpReturn
                OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/log2/902988.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log2/902988.wgsl.expected.dxc.hlsl
index 500098e..d9ea63b 100644
--- a/test/tint/builtins/gen/literal/log2/902988.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/log2/902988.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
 void log2_902988() {
-  float4 res = log2((1.0f).xxxx);
+  float4 res = (0.0f).xxxx;
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/log2/902988.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/log2/902988.wgsl.expected.fxc.hlsl
index 500098e..d9ea63b 100644
--- a/test/tint/builtins/gen/literal/log2/902988.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/log2/902988.wgsl.expected.fxc.hlsl
@@ -1,5 +1,5 @@
 void log2_902988() {
-  float4 res = log2((1.0f).xxxx);
+  float4 res = (0.0f).xxxx;
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/log2/902988.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log2/902988.wgsl.expected.glsl
index 117b10c..472adc5 100644
--- a/test/tint/builtins/gen/literal/log2/902988.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/log2/902988.wgsl.expected.glsl
@@ -1,7 +1,7 @@
 #version 310 es
 
 void log2_902988() {
-  vec4 res = log2(vec4(1.0f));
+  vec4 res = vec4(0.0f);
 }
 
 vec4 vertex_main() {
@@ -21,7 +21,7 @@
 precision mediump float;
 
 void log2_902988() {
-  vec4 res = log2(vec4(1.0f));
+  vec4 res = vec4(0.0f);
 }
 
 void fragment_main() {
@@ -35,7 +35,7 @@
 #version 310 es
 
 void log2_902988() {
-  vec4 res = log2(vec4(1.0f));
+  vec4 res = vec4(0.0f);
 }
 
 void compute_main() {
diff --git a/test/tint/builtins/gen/literal/log2/902988.wgsl.expected.msl b/test/tint/builtins/gen/literal/log2/902988.wgsl.expected.msl
index 354f761..8d88fe8 100644
--- a/test/tint/builtins/gen/literal/log2/902988.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/log2/902988.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void log2_902988() {
-  float4 res = log2(float4(1.0f));
+  float4 res = float4(0.0f);
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/log2/902988.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log2/902988.wgsl.expected.spvasm
index 6a493b9..6d40f39 100644
--- a/test/tint/builtins/gen/literal/log2/902988.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/log2/902988.wgsl.expected.spvasm
@@ -1,10 +1,9 @@
 ; SPIR-V
 ; Version: 1.3
 ; Generator: Google Tint Compiler; 0
-; Bound: 32
+; Bound: 29
 ; Schema: 0
                OpCapability Shader
-         %14 = OpExtInstImport "GLSL.std.450"
                OpMemoryModel Logical GLSL450
                OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
                OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -31,36 +30,34 @@
 %vertex_point_size = OpVariable %_ptr_Output_float Output %8
        %void = OpTypeVoid
           %9 = OpTypeFunction %void
-    %float_1 = OpConstant %float 1
-         %16 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
 %_ptr_Function_v4float = OpTypePointer Function %v4float
-         %19 = OpTypeFunction %v4float
+         %15 = OpTypeFunction %v4float
+    %float_1 = OpConstant %float 1
 %log2_902988 = OpFunction %void None %9
          %12 = OpLabel
         %res = OpVariable %_ptr_Function_v4float Function %5
-         %13 = OpExtInst %v4float %14 Log2 %16
-               OpStore %res %13
+               OpStore %res %5
                OpReturn
                OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %19
-         %21 = OpLabel
-         %22 = OpFunctionCall %void %log2_902988
+%vertex_main_inner = OpFunction %v4float None %15
+         %17 = OpLabel
+         %18 = OpFunctionCall %void %log2_902988
                OpReturnValue %5
                OpFunctionEnd
 %vertex_main = OpFunction %void None %9
-         %24 = OpLabel
-         %25 = OpFunctionCall %v4float %vertex_main_inner
-               OpStore %value %25
+         %20 = OpLabel
+         %21 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %21
                OpStore %vertex_point_size %float_1
                OpReturn
                OpFunctionEnd
 %fragment_main = OpFunction %void None %9
-         %27 = OpLabel
-         %28 = OpFunctionCall %void %log2_902988
+         %24 = OpLabel
+         %25 = OpFunctionCall %void %log2_902988
                OpReturn
                OpFunctionEnd
 %compute_main = OpFunction %void None %9
-         %30 = OpLabel
-         %31 = OpFunctionCall %void %log2_902988
+         %27 = OpLabel
+         %28 = OpFunctionCall %void %log2_902988
                OpReturn
                OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/log2/a52bbb.wgsl b/test/tint/builtins/gen/literal/log2/a52bbb.wgsl
new file mode 100644
index 0000000..bde0cbb
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log2/a52bbb.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 log2(vec<4, fa>) -> vec<4, fa>
+fn log2_a52bbb() {
+  var res = log2(vec4(1.));
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  log2_a52bbb();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  log2_a52bbb();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  log2_a52bbb();
+}
diff --git a/test/tint/builtins/gen/literal/log2/a52bbb.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log2/a52bbb.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..4ea9b28
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log2/a52bbb.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void log2_a52bbb() {
+  float4 res = (0.0f).xxxx;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  log2_a52bbb();
+  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() {
+  log2_a52bbb();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  log2_a52bbb();
+  return;
+}
diff --git a/test/tint/builtins/gen/literal/log2/a52bbb.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/log2/a52bbb.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..4ea9b28
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log2/a52bbb.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void log2_a52bbb() {
+  float4 res = (0.0f).xxxx;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  log2_a52bbb();
+  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() {
+  log2_a52bbb();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  log2_a52bbb();
+  return;
+}
diff --git a/test/tint/builtins/gen/literal/log2/a52bbb.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log2/a52bbb.wgsl.expected.glsl
new file mode 100644
index 0000000..8b2864c
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log2/a52bbb.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void log2_a52bbb() {
+  vec4 res = vec4(0.0f);
+}
+
+vec4 vertex_main() {
+  log2_a52bbb();
+  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 log2_a52bbb() {
+  vec4 res = vec4(0.0f);
+}
+
+void fragment_main() {
+  log2_a52bbb();
+}
+
+void main() {
+  fragment_main();
+  return;
+}
+#version 310 es
+
+void log2_a52bbb() {
+  vec4 res = vec4(0.0f);
+}
+
+void compute_main() {
+  log2_a52bbb();
+}
+
+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/log2/a52bbb.wgsl.expected.msl b/test/tint/builtins/gen/literal/log2/a52bbb.wgsl.expected.msl
new file mode 100644
index 0000000..b1c8005
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log2/a52bbb.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void log2_a52bbb() {
+  float4 res = float4(0.0f);
+}
+
+struct tint_symbol {
+  float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+  log2_a52bbb();
+  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() {
+  log2_a52bbb();
+  return;
+}
+
+kernel void compute_main() {
+  log2_a52bbb();
+  return;
+}
+
diff --git a/test/tint/builtins/gen/literal/log2/a52bbb.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log2/a52bbb.wgsl.expected.spvasm
new file mode 100644
index 0000000..9920241
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log2/a52bbb.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 %log2_a52bbb "log2_a52bbb"
+               OpName %res "res"
+               OpName %vertex_main_inner "vertex_main_inner"
+               OpName %vertex_main "vertex_main"
+               OpName %fragment_main "fragment_main"
+               OpName %compute_main "compute_main"
+               OpDecorate %value BuiltIn Position
+               OpDecorate %vertex_point_size BuiltIn PointSize
+      %float = OpTypeFloat 32
+    %v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+          %5 = OpConstantNull %v4float
+      %value = OpVariable %_ptr_Output_v4float Output %5
+%_ptr_Output_float = OpTypePointer Output %float
+          %8 = OpConstantNull %float
+%vertex_point_size = OpVariable %_ptr_Output_float Output %8
+       %void = OpTypeVoid
+          %9 = OpTypeFunction %void
+%_ptr_Function_v4float = OpTypePointer Function %v4float
+         %15 = OpTypeFunction %v4float
+    %float_1 = OpConstant %float 1
+%log2_a52bbb = OpFunction %void None %9
+         %12 = OpLabel
+        %res = OpVariable %_ptr_Function_v4float Function %5
+               OpStore %res %5
+               OpReturn
+               OpFunctionEnd
+%vertex_main_inner = OpFunction %v4float None %15
+         %17 = OpLabel
+         %18 = OpFunctionCall %void %log2_a52bbb
+               OpReturnValue %5
+               OpFunctionEnd
+%vertex_main = OpFunction %void None %9
+         %20 = OpLabel
+         %21 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %21
+               OpStore %vertex_point_size %float_1
+               OpReturn
+               OpFunctionEnd
+%fragment_main = OpFunction %void None %9
+         %24 = OpLabel
+         %25 = OpFunctionCall %void %log2_a52bbb
+               OpReturn
+               OpFunctionEnd
+%compute_main = OpFunction %void None %9
+         %27 = OpLabel
+         %28 = OpFunctionCall %void %log2_a52bbb
+               OpReturn
+               OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/log2/a52bbb.wgsl.expected.wgsl b/test/tint/builtins/gen/literal/log2/a52bbb.wgsl.expected.wgsl
new file mode 100644
index 0000000..5b5b3a1
--- /dev/null
+++ b/test/tint/builtins/gen/literal/log2/a52bbb.wgsl.expected.wgsl
@@ -0,0 +1,19 @@
+fn log2_a52bbb() {
+  var res = log2(vec4(1.0));
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  log2_a52bbb();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  log2_a52bbb();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  log2_a52bbb();
+}
diff --git a/test/tint/builtins/gen/literal/log2/adb233.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log2/adb233.wgsl.expected.dxc.hlsl
index 73bd8d58..04376aa 100644
--- a/test/tint/builtins/gen/literal/log2/adb233.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/log2/adb233.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
 void log2_adb233() {
-  float3 res = log2((1.0f).xxx);
+  float3 res = (0.0f).xxx;
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/log2/adb233.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/log2/adb233.wgsl.expected.fxc.hlsl
index 73bd8d58..04376aa 100644
--- a/test/tint/builtins/gen/literal/log2/adb233.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/log2/adb233.wgsl.expected.fxc.hlsl
@@ -1,5 +1,5 @@
 void log2_adb233() {
-  float3 res = log2((1.0f).xxx);
+  float3 res = (0.0f).xxx;
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/log2/adb233.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log2/adb233.wgsl.expected.glsl
index 82d0d60..35de9d3 100644
--- a/test/tint/builtins/gen/literal/log2/adb233.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/log2/adb233.wgsl.expected.glsl
@@ -1,7 +1,7 @@
 #version 310 es
 
 void log2_adb233() {
-  vec3 res = log2(vec3(1.0f));
+  vec3 res = vec3(0.0f);
 }
 
 vec4 vertex_main() {
@@ -21,7 +21,7 @@
 precision mediump float;
 
 void log2_adb233() {
-  vec3 res = log2(vec3(1.0f));
+  vec3 res = vec3(0.0f);
 }
 
 void fragment_main() {
@@ -35,7 +35,7 @@
 #version 310 es
 
 void log2_adb233() {
-  vec3 res = log2(vec3(1.0f));
+  vec3 res = vec3(0.0f);
 }
 
 void compute_main() {
diff --git a/test/tint/builtins/gen/literal/log2/adb233.wgsl.expected.msl b/test/tint/builtins/gen/literal/log2/adb233.wgsl.expected.msl
index 6d394dc..8b5e766 100644
--- a/test/tint/builtins/gen/literal/log2/adb233.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/log2/adb233.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void log2_adb233() {
-  float3 res = log2(float3(1.0f));
+  float3 res = float3(0.0f);
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/log2/adb233.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log2/adb233.wgsl.expected.spvasm
index ac19e97..6f2635a 100644
--- a/test/tint/builtins/gen/literal/log2/adb233.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/log2/adb233.wgsl.expected.spvasm
@@ -1,10 +1,9 @@
 ; SPIR-V
 ; Version: 1.3
 ; Generator: Google Tint Compiler; 0
-; Bound: 34
+; Bound: 31
 ; Schema: 0
                OpCapability Shader
-         %15 = OpExtInstImport "GLSL.std.450"
                OpMemoryModel Logical GLSL450
                OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
                OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -32,37 +31,35 @@
        %void = OpTypeVoid
           %9 = OpTypeFunction %void
     %v3float = OpTypeVector %float 3
-    %float_1 = OpConstant %float 1
-         %17 = OpConstantComposite %v3float %float_1 %float_1 %float_1
+         %14 = OpConstantNull %v3float
 %_ptr_Function_v3float = OpTypePointer Function %v3float
-         %20 = OpConstantNull %v3float
-         %21 = OpTypeFunction %v4float
+         %17 = OpTypeFunction %v4float
+    %float_1 = OpConstant %float 1
 %log2_adb233 = OpFunction %void None %9
          %12 = OpLabel
-        %res = OpVariable %_ptr_Function_v3float Function %20
-         %13 = OpExtInst %v3float %15 Log2 %17
-               OpStore %res %13
+        %res = OpVariable %_ptr_Function_v3float Function %14
+               OpStore %res %14
                OpReturn
                OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %21
-         %23 = OpLabel
-         %24 = OpFunctionCall %void %log2_adb233
+%vertex_main_inner = OpFunction %v4float None %17
+         %19 = OpLabel
+         %20 = OpFunctionCall %void %log2_adb233
                OpReturnValue %5
                OpFunctionEnd
 %vertex_main = OpFunction %void None %9
-         %26 = OpLabel
-         %27 = OpFunctionCall %v4float %vertex_main_inner
-               OpStore %value %27
+         %22 = OpLabel
+         %23 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %23
                OpStore %vertex_point_size %float_1
                OpReturn
                OpFunctionEnd
 %fragment_main = OpFunction %void None %9
-         %29 = OpLabel
-         %30 = OpFunctionCall %void %log2_adb233
+         %26 = OpLabel
+         %27 = OpFunctionCall %void %log2_adb233
                OpReturn
                OpFunctionEnd
 %compute_main = OpFunction %void None %9
-         %32 = OpLabel
-         %33 = OpFunctionCall %void %log2_adb233
+         %29 = OpLabel
+         %30 = OpFunctionCall %void %log2_adb233
                OpReturn
                OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/log2/aea659.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log2/aea659.wgsl.expected.dxc.hlsl
index 8c58800..e6088a3 100644
--- a/test/tint/builtins/gen/literal/log2/aea659.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/log2/aea659.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
 void log2_aea659() {
-  float2 res = log2((1.0f).xx);
+  float2 res = (0.0f).xx;
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/log2/aea659.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/log2/aea659.wgsl.expected.fxc.hlsl
index 8c58800..e6088a3 100644
--- a/test/tint/builtins/gen/literal/log2/aea659.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/log2/aea659.wgsl.expected.fxc.hlsl
@@ -1,5 +1,5 @@
 void log2_aea659() {
-  float2 res = log2((1.0f).xx);
+  float2 res = (0.0f).xx;
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/log2/aea659.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log2/aea659.wgsl.expected.glsl
index 6b1412f..354998d 100644
--- a/test/tint/builtins/gen/literal/log2/aea659.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/log2/aea659.wgsl.expected.glsl
@@ -1,7 +1,7 @@
 #version 310 es
 
 void log2_aea659() {
-  vec2 res = log2(vec2(1.0f));
+  vec2 res = vec2(0.0f);
 }
 
 vec4 vertex_main() {
@@ -21,7 +21,7 @@
 precision mediump float;
 
 void log2_aea659() {
-  vec2 res = log2(vec2(1.0f));
+  vec2 res = vec2(0.0f);
 }
 
 void fragment_main() {
@@ -35,7 +35,7 @@
 #version 310 es
 
 void log2_aea659() {
-  vec2 res = log2(vec2(1.0f));
+  vec2 res = vec2(0.0f);
 }
 
 void compute_main() {
diff --git a/test/tint/builtins/gen/literal/log2/aea659.wgsl.expected.msl b/test/tint/builtins/gen/literal/log2/aea659.wgsl.expected.msl
index 83e3e7d..ecd1f50 100644
--- a/test/tint/builtins/gen/literal/log2/aea659.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/log2/aea659.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void log2_aea659() {
-  float2 res = log2(float2(1.0f));
+  float2 res = float2(0.0f);
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/log2/aea659.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log2/aea659.wgsl.expected.spvasm
index 9f381bc..3c63c4a 100644
--- a/test/tint/builtins/gen/literal/log2/aea659.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/log2/aea659.wgsl.expected.spvasm
@@ -1,10 +1,9 @@
 ; SPIR-V
 ; Version: 1.3
 ; Generator: Google Tint Compiler; 0
-; Bound: 34
+; Bound: 31
 ; Schema: 0
                OpCapability Shader
-         %15 = OpExtInstImport "GLSL.std.450"
                OpMemoryModel Logical GLSL450
                OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
                OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -32,37 +31,35 @@
        %void = OpTypeVoid
           %9 = OpTypeFunction %void
     %v2float = OpTypeVector %float 2
-    %float_1 = OpConstant %float 1
-         %17 = OpConstantComposite %v2float %float_1 %float_1
+         %14 = OpConstantNull %v2float
 %_ptr_Function_v2float = OpTypePointer Function %v2float
-         %20 = OpConstantNull %v2float
-         %21 = OpTypeFunction %v4float
+         %17 = OpTypeFunction %v4float
+    %float_1 = OpConstant %float 1
 %log2_aea659 = OpFunction %void None %9
          %12 = OpLabel
-        %res = OpVariable %_ptr_Function_v2float Function %20
-         %13 = OpExtInst %v2float %15 Log2 %17
-               OpStore %res %13
+        %res = OpVariable %_ptr_Function_v2float Function %14
+               OpStore %res %14
                OpReturn
                OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %21
-         %23 = OpLabel
-         %24 = OpFunctionCall %void %log2_aea659
+%vertex_main_inner = OpFunction %v4float None %17
+         %19 = OpLabel
+         %20 = OpFunctionCall %void %log2_aea659
                OpReturnValue %5
                OpFunctionEnd
 %vertex_main = OpFunction %void None %9
-         %26 = OpLabel
-         %27 = OpFunctionCall %v4float %vertex_main_inner
-               OpStore %value %27
+         %22 = OpLabel
+         %23 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %23
                OpStore %vertex_point_size %float_1
                OpReturn
                OpFunctionEnd
 %fragment_main = OpFunction %void None %9
-         %29 = OpLabel
-         %30 = OpFunctionCall %void %log2_aea659
+         %26 = OpLabel
+         %27 = OpFunctionCall %void %log2_aea659
                OpReturn
                OpFunctionEnd
 %compute_main = OpFunction %void None %9
-         %32 = OpLabel
-         %33 = OpFunctionCall %void %log2_aea659
+         %29 = OpLabel
+         %30 = OpFunctionCall %void %log2_aea659
                OpReturn
                OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/log2/fb9f0b.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/log2/fb9f0b.wgsl.expected.dxc.hlsl
index 86a9e68..b09eff5 100644
--- a/test/tint/builtins/gen/literal/log2/fb9f0b.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/log2/fb9f0b.wgsl.expected.dxc.hlsl
@@ -1,5 +1,5 @@
 void log2_fb9f0b() {
-  vector<float16_t, 2> res = log2((float16_t(1.0h)).xx);
+  vector<float16_t, 2> res = (float16_t(0.0h)).xx;
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/log2/fb9f0b.wgsl.expected.glsl b/test/tint/builtins/gen/literal/log2/fb9f0b.wgsl.expected.glsl
index b768f1b..75a4369 100644
--- a/test/tint/builtins/gen/literal/log2/fb9f0b.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/log2/fb9f0b.wgsl.expected.glsl
@@ -2,7 +2,7 @@
 #extension GL_AMD_gpu_shader_half_float : require
 
 void log2_fb9f0b() {
-  f16vec2 res = log2(f16vec2(1.0hf));
+  f16vec2 res = f16vec2(0.0hf);
 }
 
 vec4 vertex_main() {
@@ -23,7 +23,7 @@
 precision mediump float;
 
 void log2_fb9f0b() {
-  f16vec2 res = log2(f16vec2(1.0hf));
+  f16vec2 res = f16vec2(0.0hf);
 }
 
 void fragment_main() {
@@ -38,7 +38,7 @@
 #extension GL_AMD_gpu_shader_half_float : require
 
 void log2_fb9f0b() {
-  f16vec2 res = log2(f16vec2(1.0hf));
+  f16vec2 res = f16vec2(0.0hf);
 }
 
 void compute_main() {
diff --git a/test/tint/builtins/gen/literal/log2/fb9f0b.wgsl.expected.msl b/test/tint/builtins/gen/literal/log2/fb9f0b.wgsl.expected.msl
index bd5984f..0e844fd 100644
--- a/test/tint/builtins/gen/literal/log2/fb9f0b.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/log2/fb9f0b.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void log2_fb9f0b() {
-  half2 res = log2(half2(1.0h));
+  half2 res = half2(0.0h);
 }
 
 struct tint_symbol {
diff --git a/test/tint/builtins/gen/literal/log2/fb9f0b.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/log2/fb9f0b.wgsl.expected.spvasm
index f68a857..8c6b96e 100644
--- a/test/tint/builtins/gen/literal/log2/fb9f0b.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/log2/fb9f0b.wgsl.expected.spvasm
@@ -1,14 +1,13 @@
 ; SPIR-V
 ; Version: 1.3
 ; Generator: Google Tint Compiler; 0
-; Bound: 36
+; Bound: 32
 ; Schema: 0
                OpCapability Shader
                OpCapability Float16
                OpCapability UniformAndStorageBuffer16BitAccess
                OpCapability StorageBuffer16BitAccess
                OpCapability StorageInputOutput16
-         %16 = OpExtInstImport "GLSL.std.450"
                OpMemoryModel Logical GLSL450
                OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
                OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -37,38 +36,35 @@
           %9 = OpTypeFunction %void
        %half = OpTypeFloat 16
      %v2half = OpTypeVector %half 2
-%half_0x1p_0 = OpConstant %half 0x1p+0
-         %18 = OpConstantComposite %v2half %half_0x1p_0 %half_0x1p_0
+         %15 = OpConstantNull %v2half
 %_ptr_Function_v2half = OpTypePointer Function %v2half
-         %21 = OpConstantNull %v2half
-         %22 = OpTypeFunction %v4float
+         %18 = OpTypeFunction %v4float
     %float_1 = OpConstant %float 1
 %log2_fb9f0b = OpFunction %void None %9
          %12 = OpLabel
-        %res = OpVariable %_ptr_Function_v2half Function %21
-         %13 = OpExtInst %v2half %16 Log2 %18
-               OpStore %res %13
+        %res = OpVariable %_ptr_Function_v2half Function %15
+               OpStore %res %15
                OpReturn
                OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %22
-         %24 = OpLabel
-         %25 = OpFunctionCall %void %log2_fb9f0b
+%vertex_main_inner = OpFunction %v4float None %18
+         %20 = OpLabel
+         %21 = OpFunctionCall %void %log2_fb9f0b
                OpReturnValue %5
                OpFunctionEnd
 %vertex_main = OpFunction %void None %9
-         %27 = OpLabel
-         %28 = OpFunctionCall %v4float %vertex_main_inner
-               OpStore %value %28
+         %23 = OpLabel
+         %24 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %24
                OpStore %vertex_point_size %float_1
                OpReturn
                OpFunctionEnd
 %fragment_main = OpFunction %void None %9
-         %31 = OpLabel
-         %32 = OpFunctionCall %void %log2_fb9f0b
+         %27 = OpLabel
+         %28 = OpFunctionCall %void %log2_fb9f0b
                OpReturn
                OpFunctionEnd
 %compute_main = OpFunction %void None %9
-         %34 = OpLabel
-         %35 = OpFunctionCall %void %log2_fb9f0b
+         %30 = OpLabel
+         %31 = OpFunctionCall %void %log2_fb9f0b
                OpReturn
                OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/log/655989.wgsl b/test/tint/builtins/gen/var/log/655989.wgsl
new file mode 100644
index 0000000..062a3e9
--- /dev/null
+++ b/test/tint/builtins/gen/var/log/655989.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 log(fa) -> fa
+fn log_655989() {
+  const arg_0 = 1.;
+  var res = log(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  log_655989();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  log_655989();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  log_655989();
+}
diff --git a/test/tint/builtins/gen/var/log/655989.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/log/655989.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..a8475f8
--- /dev/null
+++ b/test/tint/builtins/gen/var/log/655989.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void log_655989() {
+  float res = 0.0f;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  log_655989();
+  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() {
+  log_655989();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  log_655989();
+  return;
+}
diff --git a/test/tint/builtins/gen/var/log/655989.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/log/655989.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..a8475f8
--- /dev/null
+++ b/test/tint/builtins/gen/var/log/655989.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void log_655989() {
+  float res = 0.0f;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  log_655989();
+  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() {
+  log_655989();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  log_655989();
+  return;
+}
diff --git a/test/tint/builtins/gen/var/log/655989.wgsl.expected.glsl b/test/tint/builtins/gen/var/log/655989.wgsl.expected.glsl
new file mode 100644
index 0000000..e6a0182
--- /dev/null
+++ b/test/tint/builtins/gen/var/log/655989.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void log_655989() {
+  float res = 0.0f;
+}
+
+vec4 vertex_main() {
+  log_655989();
+  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 log_655989() {
+  float res = 0.0f;
+}
+
+void fragment_main() {
+  log_655989();
+}
+
+void main() {
+  fragment_main();
+  return;
+}
+#version 310 es
+
+void log_655989() {
+  float res = 0.0f;
+}
+
+void compute_main() {
+  log_655989();
+}
+
+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/log/655989.wgsl.expected.msl b/test/tint/builtins/gen/var/log/655989.wgsl.expected.msl
new file mode 100644
index 0000000..0b174b7
--- /dev/null
+++ b/test/tint/builtins/gen/var/log/655989.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void log_655989() {
+  float res = 0.0f;
+}
+
+struct tint_symbol {
+  float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+  log_655989();
+  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() {
+  log_655989();
+  return;
+}
+
+kernel void compute_main() {
+  log_655989();
+  return;
+}
+
diff --git a/test/tint/builtins/gen/var/log/655989.wgsl.expected.spvasm b/test/tint/builtins/gen/var/log/655989.wgsl.expected.spvasm
new file mode 100644
index 0000000..6d7f01b
--- /dev/null
+++ b/test/tint/builtins/gen/var/log/655989.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 %log_655989 "log_655989"
+               OpName %res "res"
+               OpName %vertex_main_inner "vertex_main_inner"
+               OpName %vertex_main "vertex_main"
+               OpName %fragment_main "fragment_main"
+               OpName %compute_main "compute_main"
+               OpDecorate %value BuiltIn Position
+               OpDecorate %vertex_point_size BuiltIn PointSize
+      %float = OpTypeFloat 32
+    %v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+          %5 = OpConstantNull %v4float
+      %value = OpVariable %_ptr_Output_v4float Output %5
+%_ptr_Output_float = OpTypePointer Output %float
+          %8 = OpConstantNull %float
+%vertex_point_size = OpVariable %_ptr_Output_float Output %8
+       %void = OpTypeVoid
+          %9 = OpTypeFunction %void
+%_ptr_Function_float = OpTypePointer Function %float
+         %15 = OpTypeFunction %v4float
+    %float_1 = OpConstant %float 1
+ %log_655989 = OpFunction %void None %9
+         %12 = OpLabel
+        %res = OpVariable %_ptr_Function_float Function %8
+               OpStore %res %8
+               OpReturn
+               OpFunctionEnd
+%vertex_main_inner = OpFunction %v4float None %15
+         %17 = OpLabel
+         %18 = OpFunctionCall %void %log_655989
+               OpReturnValue %5
+               OpFunctionEnd
+%vertex_main = OpFunction %void None %9
+         %20 = OpLabel
+         %21 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %21
+               OpStore %vertex_point_size %float_1
+               OpReturn
+               OpFunctionEnd
+%fragment_main = OpFunction %void None %9
+         %24 = OpLabel
+         %25 = OpFunctionCall %void %log_655989
+               OpReturn
+               OpFunctionEnd
+%compute_main = OpFunction %void None %9
+         %27 = OpLabel
+         %28 = OpFunctionCall %void %log_655989
+               OpReturn
+               OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/log/655989.wgsl.expected.wgsl b/test/tint/builtins/gen/var/log/655989.wgsl.expected.wgsl
new file mode 100644
index 0000000..64ad88d
--- /dev/null
+++ b/test/tint/builtins/gen/var/log/655989.wgsl.expected.wgsl
@@ -0,0 +1,20 @@
+fn log_655989() {
+  const arg_0 = 1.0;
+  var res = log(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  log_655989();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  log_655989();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  log_655989();
+}
diff --git a/test/tint/builtins/gen/var/log/697e1d.wgsl b/test/tint/builtins/gen/var/log/697e1d.wgsl
new file mode 100644
index 0000000..7f7822f
--- /dev/null
+++ b/test/tint/builtins/gen/var/log/697e1d.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 log(vec<4, fa>) -> vec<4, fa>
+fn log_697e1d() {
+  const arg_0 = vec4(1.);
+  var res = log(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  log_697e1d();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  log_697e1d();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  log_697e1d();
+}
diff --git a/test/tint/builtins/gen/var/log/697e1d.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/log/697e1d.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..56bdd4c
--- /dev/null
+++ b/test/tint/builtins/gen/var/log/697e1d.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void log_697e1d() {
+  float4 res = (0.0f).xxxx;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  log_697e1d();
+  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() {
+  log_697e1d();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  log_697e1d();
+  return;
+}
diff --git a/test/tint/builtins/gen/var/log/697e1d.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/log/697e1d.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..56bdd4c
--- /dev/null
+++ b/test/tint/builtins/gen/var/log/697e1d.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void log_697e1d() {
+  float4 res = (0.0f).xxxx;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  log_697e1d();
+  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() {
+  log_697e1d();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  log_697e1d();
+  return;
+}
diff --git a/test/tint/builtins/gen/var/log/697e1d.wgsl.expected.glsl b/test/tint/builtins/gen/var/log/697e1d.wgsl.expected.glsl
new file mode 100644
index 0000000..06b9a1b
--- /dev/null
+++ b/test/tint/builtins/gen/var/log/697e1d.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void log_697e1d() {
+  vec4 res = vec4(0.0f);
+}
+
+vec4 vertex_main() {
+  log_697e1d();
+  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 log_697e1d() {
+  vec4 res = vec4(0.0f);
+}
+
+void fragment_main() {
+  log_697e1d();
+}
+
+void main() {
+  fragment_main();
+  return;
+}
+#version 310 es
+
+void log_697e1d() {
+  vec4 res = vec4(0.0f);
+}
+
+void compute_main() {
+  log_697e1d();
+}
+
+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/log/697e1d.wgsl.expected.msl b/test/tint/builtins/gen/var/log/697e1d.wgsl.expected.msl
new file mode 100644
index 0000000..c3311d4
--- /dev/null
+++ b/test/tint/builtins/gen/var/log/697e1d.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void log_697e1d() {
+  float4 res = float4(0.0f);
+}
+
+struct tint_symbol {
+  float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+  log_697e1d();
+  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() {
+  log_697e1d();
+  return;
+}
+
+kernel void compute_main() {
+  log_697e1d();
+  return;
+}
+
diff --git a/test/tint/builtins/gen/var/log/697e1d.wgsl.expected.spvasm b/test/tint/builtins/gen/var/log/697e1d.wgsl.expected.spvasm
new file mode 100644
index 0000000..7432296
--- /dev/null
+++ b/test/tint/builtins/gen/var/log/697e1d.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 %log_697e1d "log_697e1d"
+               OpName %res "res"
+               OpName %vertex_main_inner "vertex_main_inner"
+               OpName %vertex_main "vertex_main"
+               OpName %fragment_main "fragment_main"
+               OpName %compute_main "compute_main"
+               OpDecorate %value BuiltIn Position
+               OpDecorate %vertex_point_size BuiltIn PointSize
+      %float = OpTypeFloat 32
+    %v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+          %5 = OpConstantNull %v4float
+      %value = OpVariable %_ptr_Output_v4float Output %5
+%_ptr_Output_float = OpTypePointer Output %float
+          %8 = OpConstantNull %float
+%vertex_point_size = OpVariable %_ptr_Output_float Output %8
+       %void = OpTypeVoid
+          %9 = OpTypeFunction %void
+%_ptr_Function_v4float = OpTypePointer Function %v4float
+         %15 = OpTypeFunction %v4float
+    %float_1 = OpConstant %float 1
+ %log_697e1d = OpFunction %void None %9
+         %12 = OpLabel
+        %res = OpVariable %_ptr_Function_v4float Function %5
+               OpStore %res %5
+               OpReturn
+               OpFunctionEnd
+%vertex_main_inner = OpFunction %v4float None %15
+         %17 = OpLabel
+         %18 = OpFunctionCall %void %log_697e1d
+               OpReturnValue %5
+               OpFunctionEnd
+%vertex_main = OpFunction %void None %9
+         %20 = OpLabel
+         %21 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %21
+               OpStore %vertex_point_size %float_1
+               OpReturn
+               OpFunctionEnd
+%fragment_main = OpFunction %void None %9
+         %24 = OpLabel
+         %25 = OpFunctionCall %void %log_697e1d
+               OpReturn
+               OpFunctionEnd
+%compute_main = OpFunction %void None %9
+         %27 = OpLabel
+         %28 = OpFunctionCall %void %log_697e1d
+               OpReturn
+               OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/log/697e1d.wgsl.expected.wgsl b/test/tint/builtins/gen/var/log/697e1d.wgsl.expected.wgsl
new file mode 100644
index 0000000..e0a026c
--- /dev/null
+++ b/test/tint/builtins/gen/var/log/697e1d.wgsl.expected.wgsl
@@ -0,0 +1,20 @@
+fn log_697e1d() {
+  const arg_0 = vec4(1.0);
+  var res = log(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  log_697e1d();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  log_697e1d();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  log_697e1d();
+}
diff --git a/test/tint/builtins/gen/var/log/b8088d.wgsl b/test/tint/builtins/gen/var/log/b8088d.wgsl
new file mode 100644
index 0000000..2bcdc0f
--- /dev/null
+++ b/test/tint/builtins/gen/var/log/b8088d.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 log(vec<3, fa>) -> vec<3, fa>
+fn log_b8088d() {
+  const arg_0 = vec3(1.);
+  var res = log(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  log_b8088d();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  log_b8088d();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  log_b8088d();
+}
diff --git a/test/tint/builtins/gen/var/log/b8088d.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/log/b8088d.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..0234c1d
--- /dev/null
+++ b/test/tint/builtins/gen/var/log/b8088d.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void log_b8088d() {
+  float3 res = (0.0f).xxx;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  log_b8088d();
+  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() {
+  log_b8088d();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  log_b8088d();
+  return;
+}
diff --git a/test/tint/builtins/gen/var/log/b8088d.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/log/b8088d.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..0234c1d
--- /dev/null
+++ b/test/tint/builtins/gen/var/log/b8088d.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void log_b8088d() {
+  float3 res = (0.0f).xxx;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  log_b8088d();
+  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() {
+  log_b8088d();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  log_b8088d();
+  return;
+}
diff --git a/test/tint/builtins/gen/var/log/b8088d.wgsl.expected.glsl b/test/tint/builtins/gen/var/log/b8088d.wgsl.expected.glsl
new file mode 100644
index 0000000..5dc623a
--- /dev/null
+++ b/test/tint/builtins/gen/var/log/b8088d.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void log_b8088d() {
+  vec3 res = vec3(0.0f);
+}
+
+vec4 vertex_main() {
+  log_b8088d();
+  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 log_b8088d() {
+  vec3 res = vec3(0.0f);
+}
+
+void fragment_main() {
+  log_b8088d();
+}
+
+void main() {
+  fragment_main();
+  return;
+}
+#version 310 es
+
+void log_b8088d() {
+  vec3 res = vec3(0.0f);
+}
+
+void compute_main() {
+  log_b8088d();
+}
+
+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/log/b8088d.wgsl.expected.msl b/test/tint/builtins/gen/var/log/b8088d.wgsl.expected.msl
new file mode 100644
index 0000000..92066b0
--- /dev/null
+++ b/test/tint/builtins/gen/var/log/b8088d.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void log_b8088d() {
+  float3 res = float3(0.0f);
+}
+
+struct tint_symbol {
+  float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+  log_b8088d();
+  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() {
+  log_b8088d();
+  return;
+}
+
+kernel void compute_main() {
+  log_b8088d();
+  return;
+}
+
diff --git a/test/tint/builtins/gen/var/log/b8088d.wgsl.expected.spvasm b/test/tint/builtins/gen/var/log/b8088d.wgsl.expected.spvasm
new file mode 100644
index 0000000..ed2010a
--- /dev/null
+++ b/test/tint/builtins/gen/var/log/b8088d.wgsl.expected.spvasm
@@ -0,0 +1,65 @@
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 0
+; Bound: 31
+; 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 %log_b8088d "log_b8088d"
+               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
+         %14 = OpConstantNull %v3float
+%_ptr_Function_v3float = OpTypePointer Function %v3float
+         %17 = OpTypeFunction %v4float
+    %float_1 = OpConstant %float 1
+ %log_b8088d = OpFunction %void None %9
+         %12 = OpLabel
+        %res = OpVariable %_ptr_Function_v3float Function %14
+               OpStore %res %14
+               OpReturn
+               OpFunctionEnd
+%vertex_main_inner = OpFunction %v4float None %17
+         %19 = OpLabel
+         %20 = OpFunctionCall %void %log_b8088d
+               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
+         %26 = OpLabel
+         %27 = OpFunctionCall %void %log_b8088d
+               OpReturn
+               OpFunctionEnd
+%compute_main = OpFunction %void None %9
+         %29 = OpLabel
+         %30 = OpFunctionCall %void %log_b8088d
+               OpReturn
+               OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/log/b8088d.wgsl.expected.wgsl b/test/tint/builtins/gen/var/log/b8088d.wgsl.expected.wgsl
new file mode 100644
index 0000000..75039e7
--- /dev/null
+++ b/test/tint/builtins/gen/var/log/b8088d.wgsl.expected.wgsl
@@ -0,0 +1,20 @@
+fn log_b8088d() {
+  const arg_0 = vec3(1.0);
+  var res = log(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  log_b8088d();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  log_b8088d();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  log_b8088d();
+}
diff --git a/test/tint/builtins/gen/var/log/f60cc7.wgsl b/test/tint/builtins/gen/var/log/f60cc7.wgsl
new file mode 100644
index 0000000..ea4f452
--- /dev/null
+++ b/test/tint/builtins/gen/var/log/f60cc7.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 log(vec<2, fa>) -> vec<2, fa>
+fn log_f60cc7() {
+  const arg_0 = vec2(1.);
+  var res = log(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  log_f60cc7();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  log_f60cc7();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  log_f60cc7();
+}
diff --git a/test/tint/builtins/gen/var/log/f60cc7.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/log/f60cc7.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..41dbc64
--- /dev/null
+++ b/test/tint/builtins/gen/var/log/f60cc7.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void log_f60cc7() {
+  float2 res = (0.0f).xx;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  log_f60cc7();
+  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() {
+  log_f60cc7();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  log_f60cc7();
+  return;
+}
diff --git a/test/tint/builtins/gen/var/log/f60cc7.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/log/f60cc7.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..41dbc64
--- /dev/null
+++ b/test/tint/builtins/gen/var/log/f60cc7.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void log_f60cc7() {
+  float2 res = (0.0f).xx;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  log_f60cc7();
+  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() {
+  log_f60cc7();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  log_f60cc7();
+  return;
+}
diff --git a/test/tint/builtins/gen/var/log/f60cc7.wgsl.expected.glsl b/test/tint/builtins/gen/var/log/f60cc7.wgsl.expected.glsl
new file mode 100644
index 0000000..d29f386
--- /dev/null
+++ b/test/tint/builtins/gen/var/log/f60cc7.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void log_f60cc7() {
+  vec2 res = vec2(0.0f);
+}
+
+vec4 vertex_main() {
+  log_f60cc7();
+  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 log_f60cc7() {
+  vec2 res = vec2(0.0f);
+}
+
+void fragment_main() {
+  log_f60cc7();
+}
+
+void main() {
+  fragment_main();
+  return;
+}
+#version 310 es
+
+void log_f60cc7() {
+  vec2 res = vec2(0.0f);
+}
+
+void compute_main() {
+  log_f60cc7();
+}
+
+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/log/f60cc7.wgsl.expected.msl b/test/tint/builtins/gen/var/log/f60cc7.wgsl.expected.msl
new file mode 100644
index 0000000..831c100
--- /dev/null
+++ b/test/tint/builtins/gen/var/log/f60cc7.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void log_f60cc7() {
+  float2 res = float2(0.0f);
+}
+
+struct tint_symbol {
+  float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+  log_f60cc7();
+  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() {
+  log_f60cc7();
+  return;
+}
+
+kernel void compute_main() {
+  log_f60cc7();
+  return;
+}
+
diff --git a/test/tint/builtins/gen/var/log/f60cc7.wgsl.expected.spvasm b/test/tint/builtins/gen/var/log/f60cc7.wgsl.expected.spvasm
new file mode 100644
index 0000000..f7f08c4
--- /dev/null
+++ b/test/tint/builtins/gen/var/log/f60cc7.wgsl.expected.spvasm
@@ -0,0 +1,65 @@
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 0
+; Bound: 31
+; 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 %log_f60cc7 "log_f60cc7"
+               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
+         %14 = OpConstantNull %v2float
+%_ptr_Function_v2float = OpTypePointer Function %v2float
+         %17 = OpTypeFunction %v4float
+    %float_1 = OpConstant %float 1
+ %log_f60cc7 = OpFunction %void None %9
+         %12 = OpLabel
+        %res = OpVariable %_ptr_Function_v2float Function %14
+               OpStore %res %14
+               OpReturn
+               OpFunctionEnd
+%vertex_main_inner = OpFunction %v4float None %17
+         %19 = OpLabel
+         %20 = OpFunctionCall %void %log_f60cc7
+               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
+         %26 = OpLabel
+         %27 = OpFunctionCall %void %log_f60cc7
+               OpReturn
+               OpFunctionEnd
+%compute_main = OpFunction %void None %9
+         %29 = OpLabel
+         %30 = OpFunctionCall %void %log_f60cc7
+               OpReturn
+               OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/log/f60cc7.wgsl.expected.wgsl b/test/tint/builtins/gen/var/log/f60cc7.wgsl.expected.wgsl
new file mode 100644
index 0000000..7f736ab
--- /dev/null
+++ b/test/tint/builtins/gen/var/log/f60cc7.wgsl.expected.wgsl
@@ -0,0 +1,20 @@
+fn log_f60cc7() {
+  const arg_0 = vec2(1.0);
+  var res = log(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  log_f60cc7();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  log_f60cc7();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  log_f60cc7();
+}
diff --git a/test/tint/builtins/gen/var/log2/0fbd39.wgsl b/test/tint/builtins/gen/var/log2/0fbd39.wgsl
new file mode 100644
index 0000000..c61df79
--- /dev/null
+++ b/test/tint/builtins/gen/var/log2/0fbd39.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 log2(vec<3, fa>) -> vec<3, fa>
+fn log2_0fbd39() {
+  const arg_0 = vec3(1.);
+  var res = log2(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  log2_0fbd39();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  log2_0fbd39();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  log2_0fbd39();
+}
diff --git a/test/tint/builtins/gen/var/log2/0fbd39.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/log2/0fbd39.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..9ddf089
--- /dev/null
+++ b/test/tint/builtins/gen/var/log2/0fbd39.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void log2_0fbd39() {
+  float3 res = (0.0f).xxx;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  log2_0fbd39();
+  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() {
+  log2_0fbd39();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  log2_0fbd39();
+  return;
+}
diff --git a/test/tint/builtins/gen/var/log2/0fbd39.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/log2/0fbd39.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..9ddf089
--- /dev/null
+++ b/test/tint/builtins/gen/var/log2/0fbd39.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void log2_0fbd39() {
+  float3 res = (0.0f).xxx;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  log2_0fbd39();
+  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() {
+  log2_0fbd39();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  log2_0fbd39();
+  return;
+}
diff --git a/test/tint/builtins/gen/var/log2/0fbd39.wgsl.expected.glsl b/test/tint/builtins/gen/var/log2/0fbd39.wgsl.expected.glsl
new file mode 100644
index 0000000..9759833
--- /dev/null
+++ b/test/tint/builtins/gen/var/log2/0fbd39.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void log2_0fbd39() {
+  vec3 res = vec3(0.0f);
+}
+
+vec4 vertex_main() {
+  log2_0fbd39();
+  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 log2_0fbd39() {
+  vec3 res = vec3(0.0f);
+}
+
+void fragment_main() {
+  log2_0fbd39();
+}
+
+void main() {
+  fragment_main();
+  return;
+}
+#version 310 es
+
+void log2_0fbd39() {
+  vec3 res = vec3(0.0f);
+}
+
+void compute_main() {
+  log2_0fbd39();
+}
+
+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/log2/0fbd39.wgsl.expected.msl b/test/tint/builtins/gen/var/log2/0fbd39.wgsl.expected.msl
new file mode 100644
index 0000000..f9e505a
--- /dev/null
+++ b/test/tint/builtins/gen/var/log2/0fbd39.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void log2_0fbd39() {
+  float3 res = float3(0.0f);
+}
+
+struct tint_symbol {
+  float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+  log2_0fbd39();
+  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() {
+  log2_0fbd39();
+  return;
+}
+
+kernel void compute_main() {
+  log2_0fbd39();
+  return;
+}
+
diff --git a/test/tint/builtins/gen/var/log2/0fbd39.wgsl.expected.spvasm b/test/tint/builtins/gen/var/log2/0fbd39.wgsl.expected.spvasm
new file mode 100644
index 0000000..b983201
--- /dev/null
+++ b/test/tint/builtins/gen/var/log2/0fbd39.wgsl.expected.spvasm
@@ -0,0 +1,65 @@
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 0
+; Bound: 31
+; 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 %log2_0fbd39 "log2_0fbd39"
+               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
+         %14 = OpConstantNull %v3float
+%_ptr_Function_v3float = OpTypePointer Function %v3float
+         %17 = OpTypeFunction %v4float
+    %float_1 = OpConstant %float 1
+%log2_0fbd39 = OpFunction %void None %9
+         %12 = OpLabel
+        %res = OpVariable %_ptr_Function_v3float Function %14
+               OpStore %res %14
+               OpReturn
+               OpFunctionEnd
+%vertex_main_inner = OpFunction %v4float None %17
+         %19 = OpLabel
+         %20 = OpFunctionCall %void %log2_0fbd39
+               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
+         %26 = OpLabel
+         %27 = OpFunctionCall %void %log2_0fbd39
+               OpReturn
+               OpFunctionEnd
+%compute_main = OpFunction %void None %9
+         %29 = OpLabel
+         %30 = OpFunctionCall %void %log2_0fbd39
+               OpReturn
+               OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/log2/0fbd39.wgsl.expected.wgsl b/test/tint/builtins/gen/var/log2/0fbd39.wgsl.expected.wgsl
new file mode 100644
index 0000000..d92b5ad
--- /dev/null
+++ b/test/tint/builtins/gen/var/log2/0fbd39.wgsl.expected.wgsl
@@ -0,0 +1,20 @@
+fn log2_0fbd39() {
+  const arg_0 = vec3(1.0);
+  var res = log2(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  log2_0fbd39();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  log2_0fbd39();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  log2_0fbd39();
+}
diff --git a/test/tint/builtins/gen/var/log2/5b464b.wgsl b/test/tint/builtins/gen/var/log2/5b464b.wgsl
new file mode 100644
index 0000000..ec03520
--- /dev/null
+++ b/test/tint/builtins/gen/var/log2/5b464b.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 log2(fa) -> fa
+fn log2_5b464b() {
+  const arg_0 = 1.;
+  var res = log2(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  log2_5b464b();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  log2_5b464b();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  log2_5b464b();
+}
diff --git a/test/tint/builtins/gen/var/log2/5b464b.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/log2/5b464b.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..87f9f25
--- /dev/null
+++ b/test/tint/builtins/gen/var/log2/5b464b.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void log2_5b464b() {
+  float res = 0.0f;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  log2_5b464b();
+  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() {
+  log2_5b464b();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  log2_5b464b();
+  return;
+}
diff --git a/test/tint/builtins/gen/var/log2/5b464b.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/log2/5b464b.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..87f9f25
--- /dev/null
+++ b/test/tint/builtins/gen/var/log2/5b464b.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void log2_5b464b() {
+  float res = 0.0f;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  log2_5b464b();
+  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() {
+  log2_5b464b();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  log2_5b464b();
+  return;
+}
diff --git a/test/tint/builtins/gen/var/log2/5b464b.wgsl.expected.glsl b/test/tint/builtins/gen/var/log2/5b464b.wgsl.expected.glsl
new file mode 100644
index 0000000..1429b32
--- /dev/null
+++ b/test/tint/builtins/gen/var/log2/5b464b.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void log2_5b464b() {
+  float res = 0.0f;
+}
+
+vec4 vertex_main() {
+  log2_5b464b();
+  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 log2_5b464b() {
+  float res = 0.0f;
+}
+
+void fragment_main() {
+  log2_5b464b();
+}
+
+void main() {
+  fragment_main();
+  return;
+}
+#version 310 es
+
+void log2_5b464b() {
+  float res = 0.0f;
+}
+
+void compute_main() {
+  log2_5b464b();
+}
+
+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/log2/5b464b.wgsl.expected.msl b/test/tint/builtins/gen/var/log2/5b464b.wgsl.expected.msl
new file mode 100644
index 0000000..a7547e3
--- /dev/null
+++ b/test/tint/builtins/gen/var/log2/5b464b.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void log2_5b464b() {
+  float res = 0.0f;
+}
+
+struct tint_symbol {
+  float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+  log2_5b464b();
+  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() {
+  log2_5b464b();
+  return;
+}
+
+kernel void compute_main() {
+  log2_5b464b();
+  return;
+}
+
diff --git a/test/tint/builtins/gen/var/log2/5b464b.wgsl.expected.spvasm b/test/tint/builtins/gen/var/log2/5b464b.wgsl.expected.spvasm
new file mode 100644
index 0000000..d42ca7e
--- /dev/null
+++ b/test/tint/builtins/gen/var/log2/5b464b.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 %log2_5b464b "log2_5b464b"
+               OpName %res "res"
+               OpName %vertex_main_inner "vertex_main_inner"
+               OpName %vertex_main "vertex_main"
+               OpName %fragment_main "fragment_main"
+               OpName %compute_main "compute_main"
+               OpDecorate %value BuiltIn Position
+               OpDecorate %vertex_point_size BuiltIn PointSize
+      %float = OpTypeFloat 32
+    %v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+          %5 = OpConstantNull %v4float
+      %value = OpVariable %_ptr_Output_v4float Output %5
+%_ptr_Output_float = OpTypePointer Output %float
+          %8 = OpConstantNull %float
+%vertex_point_size = OpVariable %_ptr_Output_float Output %8
+       %void = OpTypeVoid
+          %9 = OpTypeFunction %void
+%_ptr_Function_float = OpTypePointer Function %float
+         %15 = OpTypeFunction %v4float
+    %float_1 = OpConstant %float 1
+%log2_5b464b = OpFunction %void None %9
+         %12 = OpLabel
+        %res = OpVariable %_ptr_Function_float Function %8
+               OpStore %res %8
+               OpReturn
+               OpFunctionEnd
+%vertex_main_inner = OpFunction %v4float None %15
+         %17 = OpLabel
+         %18 = OpFunctionCall %void %log2_5b464b
+               OpReturnValue %5
+               OpFunctionEnd
+%vertex_main = OpFunction %void None %9
+         %20 = OpLabel
+         %21 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %21
+               OpStore %vertex_point_size %float_1
+               OpReturn
+               OpFunctionEnd
+%fragment_main = OpFunction %void None %9
+         %24 = OpLabel
+         %25 = OpFunctionCall %void %log2_5b464b
+               OpReturn
+               OpFunctionEnd
+%compute_main = OpFunction %void None %9
+         %27 = OpLabel
+         %28 = OpFunctionCall %void %log2_5b464b
+               OpReturn
+               OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/log2/5b464b.wgsl.expected.wgsl b/test/tint/builtins/gen/var/log2/5b464b.wgsl.expected.wgsl
new file mode 100644
index 0000000..b824c8e
--- /dev/null
+++ b/test/tint/builtins/gen/var/log2/5b464b.wgsl.expected.wgsl
@@ -0,0 +1,20 @@
+fn log2_5b464b() {
+  const arg_0 = 1.0;
+  var res = log2(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  log2_5b464b();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  log2_5b464b();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  log2_5b464b();
+}
diff --git a/test/tint/builtins/gen/var/log2/6b8954.wgsl b/test/tint/builtins/gen/var/log2/6b8954.wgsl
new file mode 100644
index 0000000..adc9400
--- /dev/null
+++ b/test/tint/builtins/gen/var/log2/6b8954.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 log2(vec<2, fa>) -> vec<2, fa>
+fn log2_6b8954() {
+  const arg_0 = vec2(1.);
+  var res = log2(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  log2_6b8954();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  log2_6b8954();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  log2_6b8954();
+}
diff --git a/test/tint/builtins/gen/var/log2/6b8954.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/log2/6b8954.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..1bd35a7
--- /dev/null
+++ b/test/tint/builtins/gen/var/log2/6b8954.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void log2_6b8954() {
+  float2 res = (0.0f).xx;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  log2_6b8954();
+  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() {
+  log2_6b8954();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  log2_6b8954();
+  return;
+}
diff --git a/test/tint/builtins/gen/var/log2/6b8954.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/log2/6b8954.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..1bd35a7
--- /dev/null
+++ b/test/tint/builtins/gen/var/log2/6b8954.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void log2_6b8954() {
+  float2 res = (0.0f).xx;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  log2_6b8954();
+  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() {
+  log2_6b8954();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  log2_6b8954();
+  return;
+}
diff --git a/test/tint/builtins/gen/var/log2/6b8954.wgsl.expected.glsl b/test/tint/builtins/gen/var/log2/6b8954.wgsl.expected.glsl
new file mode 100644
index 0000000..b7d204c
--- /dev/null
+++ b/test/tint/builtins/gen/var/log2/6b8954.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void log2_6b8954() {
+  vec2 res = vec2(0.0f);
+}
+
+vec4 vertex_main() {
+  log2_6b8954();
+  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 log2_6b8954() {
+  vec2 res = vec2(0.0f);
+}
+
+void fragment_main() {
+  log2_6b8954();
+}
+
+void main() {
+  fragment_main();
+  return;
+}
+#version 310 es
+
+void log2_6b8954() {
+  vec2 res = vec2(0.0f);
+}
+
+void compute_main() {
+  log2_6b8954();
+}
+
+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/log2/6b8954.wgsl.expected.msl b/test/tint/builtins/gen/var/log2/6b8954.wgsl.expected.msl
new file mode 100644
index 0000000..8e2cad2
--- /dev/null
+++ b/test/tint/builtins/gen/var/log2/6b8954.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void log2_6b8954() {
+  float2 res = float2(0.0f);
+}
+
+struct tint_symbol {
+  float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+  log2_6b8954();
+  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() {
+  log2_6b8954();
+  return;
+}
+
+kernel void compute_main() {
+  log2_6b8954();
+  return;
+}
+
diff --git a/test/tint/builtins/gen/var/log2/6b8954.wgsl.expected.spvasm b/test/tint/builtins/gen/var/log2/6b8954.wgsl.expected.spvasm
new file mode 100644
index 0000000..e3a10e7
--- /dev/null
+++ b/test/tint/builtins/gen/var/log2/6b8954.wgsl.expected.spvasm
@@ -0,0 +1,65 @@
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 0
+; Bound: 31
+; 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 %log2_6b8954 "log2_6b8954"
+               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
+         %14 = OpConstantNull %v2float
+%_ptr_Function_v2float = OpTypePointer Function %v2float
+         %17 = OpTypeFunction %v4float
+    %float_1 = OpConstant %float 1
+%log2_6b8954 = OpFunction %void None %9
+         %12 = OpLabel
+        %res = OpVariable %_ptr_Function_v2float Function %14
+               OpStore %res %14
+               OpReturn
+               OpFunctionEnd
+%vertex_main_inner = OpFunction %v4float None %17
+         %19 = OpLabel
+         %20 = OpFunctionCall %void %log2_6b8954
+               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
+         %26 = OpLabel
+         %27 = OpFunctionCall %void %log2_6b8954
+               OpReturn
+               OpFunctionEnd
+%compute_main = OpFunction %void None %9
+         %29 = OpLabel
+         %30 = OpFunctionCall %void %log2_6b8954
+               OpReturn
+               OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/log2/6b8954.wgsl.expected.wgsl b/test/tint/builtins/gen/var/log2/6b8954.wgsl.expected.wgsl
new file mode 100644
index 0000000..52e4604
--- /dev/null
+++ b/test/tint/builtins/gen/var/log2/6b8954.wgsl.expected.wgsl
@@ -0,0 +1,20 @@
+fn log2_6b8954() {
+  const arg_0 = vec2(1.0);
+  var res = log2(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  log2_6b8954();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  log2_6b8954();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  log2_6b8954();
+}
diff --git a/test/tint/builtins/gen/var/log2/a52bbb.wgsl b/test/tint/builtins/gen/var/log2/a52bbb.wgsl
new file mode 100644
index 0000000..4d4cf71
--- /dev/null
+++ b/test/tint/builtins/gen/var/log2/a52bbb.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 log2(vec<4, fa>) -> vec<4, fa>
+fn log2_a52bbb() {
+  const arg_0 = vec4(1.);
+  var res = log2(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  log2_a52bbb();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  log2_a52bbb();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  log2_a52bbb();
+}
diff --git a/test/tint/builtins/gen/var/log2/a52bbb.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/log2/a52bbb.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..4ea9b28
--- /dev/null
+++ b/test/tint/builtins/gen/var/log2/a52bbb.wgsl.expected.dxc.hlsl
@@ -0,0 +1,30 @@
+void log2_a52bbb() {
+  float4 res = (0.0f).xxxx;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  log2_a52bbb();
+  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() {
+  log2_a52bbb();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  log2_a52bbb();
+  return;
+}
diff --git a/test/tint/builtins/gen/var/log2/a52bbb.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/log2/a52bbb.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..4ea9b28
--- /dev/null
+++ b/test/tint/builtins/gen/var/log2/a52bbb.wgsl.expected.fxc.hlsl
@@ -0,0 +1,30 @@
+void log2_a52bbb() {
+  float4 res = (0.0f).xxxx;
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  log2_a52bbb();
+  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() {
+  log2_a52bbb();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  log2_a52bbb();
+  return;
+}
diff --git a/test/tint/builtins/gen/var/log2/a52bbb.wgsl.expected.glsl b/test/tint/builtins/gen/var/log2/a52bbb.wgsl.expected.glsl
new file mode 100644
index 0000000..8b2864c
--- /dev/null
+++ b/test/tint/builtins/gen/var/log2/a52bbb.wgsl.expected.glsl
@@ -0,0 +1,49 @@
+#version 310 es
+
+void log2_a52bbb() {
+  vec4 res = vec4(0.0f);
+}
+
+vec4 vertex_main() {
+  log2_a52bbb();
+  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 log2_a52bbb() {
+  vec4 res = vec4(0.0f);
+}
+
+void fragment_main() {
+  log2_a52bbb();
+}
+
+void main() {
+  fragment_main();
+  return;
+}
+#version 310 es
+
+void log2_a52bbb() {
+  vec4 res = vec4(0.0f);
+}
+
+void compute_main() {
+  log2_a52bbb();
+}
+
+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/log2/a52bbb.wgsl.expected.msl b/test/tint/builtins/gen/var/log2/a52bbb.wgsl.expected.msl
new file mode 100644
index 0000000..b1c8005
--- /dev/null
+++ b/test/tint/builtins/gen/var/log2/a52bbb.wgsl.expected.msl
@@ -0,0 +1,33 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void log2_a52bbb() {
+  float4 res = float4(0.0f);
+}
+
+struct tint_symbol {
+  float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+  log2_a52bbb();
+  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() {
+  log2_a52bbb();
+  return;
+}
+
+kernel void compute_main() {
+  log2_a52bbb();
+  return;
+}
+
diff --git a/test/tint/builtins/gen/var/log2/a52bbb.wgsl.expected.spvasm b/test/tint/builtins/gen/var/log2/a52bbb.wgsl.expected.spvasm
new file mode 100644
index 0000000..9920241
--- /dev/null
+++ b/test/tint/builtins/gen/var/log2/a52bbb.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 %log2_a52bbb "log2_a52bbb"
+               OpName %res "res"
+               OpName %vertex_main_inner "vertex_main_inner"
+               OpName %vertex_main "vertex_main"
+               OpName %fragment_main "fragment_main"
+               OpName %compute_main "compute_main"
+               OpDecorate %value BuiltIn Position
+               OpDecorate %vertex_point_size BuiltIn PointSize
+      %float = OpTypeFloat 32
+    %v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+          %5 = OpConstantNull %v4float
+      %value = OpVariable %_ptr_Output_v4float Output %5
+%_ptr_Output_float = OpTypePointer Output %float
+          %8 = OpConstantNull %float
+%vertex_point_size = OpVariable %_ptr_Output_float Output %8
+       %void = OpTypeVoid
+          %9 = OpTypeFunction %void
+%_ptr_Function_v4float = OpTypePointer Function %v4float
+         %15 = OpTypeFunction %v4float
+    %float_1 = OpConstant %float 1
+%log2_a52bbb = OpFunction %void None %9
+         %12 = OpLabel
+        %res = OpVariable %_ptr_Function_v4float Function %5
+               OpStore %res %5
+               OpReturn
+               OpFunctionEnd
+%vertex_main_inner = OpFunction %v4float None %15
+         %17 = OpLabel
+         %18 = OpFunctionCall %void %log2_a52bbb
+               OpReturnValue %5
+               OpFunctionEnd
+%vertex_main = OpFunction %void None %9
+         %20 = OpLabel
+         %21 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %21
+               OpStore %vertex_point_size %float_1
+               OpReturn
+               OpFunctionEnd
+%fragment_main = OpFunction %void None %9
+         %24 = OpLabel
+         %25 = OpFunctionCall %void %log2_a52bbb
+               OpReturn
+               OpFunctionEnd
+%compute_main = OpFunction %void None %9
+         %27 = OpLabel
+         %28 = OpFunctionCall %void %log2_a52bbb
+               OpReturn
+               OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/log2/a52bbb.wgsl.expected.wgsl b/test/tint/builtins/gen/var/log2/a52bbb.wgsl.expected.wgsl
new file mode 100644
index 0000000..506d5f0
--- /dev/null
+++ b/test/tint/builtins/gen/var/log2/a52bbb.wgsl.expected.wgsl
@@ -0,0 +1,20 @@
+fn log2_a52bbb() {
+  const arg_0 = vec4(1.0);
+  var res = log2(arg_0);
+}
+
+@vertex
+fn vertex_main() -> @builtin(position) vec4<f32> {
+  log2_a52bbb();
+  return vec4<f32>();
+}
+
+@fragment
+fn fragment_main() {
+  log2_a52bbb();
+}
+
+@compute @workgroup_size(1)
+fn compute_main() {
+  log2_a52bbb();
+}