tint/resolver: Allow texture 'offset' to be const-expr

This allows the value to be declared in a `const` expression, and to use arithmetic.

Fixed: tint:1636
Change-Id: Ie641a9d4183429c79c91605cd4df78f569be3579
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105623
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
diff --git a/src/tint/resolver/builtin_validation_test.cc b/src/tint/resolver/builtin_validation_test.cc
index 95a4dbb..e5ad2e2 100644
--- a/src/tint/resolver/builtin_validation_test.cc
+++ b/src/tint/resolver/builtin_validation_test.cc
@@ -260,8 +260,7 @@
     // a vector constructor.
     bool is_vector = arg_to_replace->Is<ast::CallExpression>();
 
-    // Make the expression to be replaced, reachable. This keeps the resolver
-    // happy.
+    // Make the expression to be replaced, reachable. This keeps the resolver happy.
     WrapInFunction(arg_to_replace);
 
     arg_to_replace = expr(Source{{12, 34}}, *this);
@@ -310,13 +309,65 @@
     auto args = overload.args(this);
     auto*& arg_to_replace = (param.position == Position::kFirst) ? args.Front() : args.Back();
 
-    // Make the expression to be replaced, reachable. This keeps the resolver
-    // happy.
+    // BuildTextureVariable() uses a Literal for scalars, and a CallExpression for
+    // a vector constructor.
+    bool is_vector = arg_to_replace->Is<ast::CallExpression>();
+
+    // Make the expression to be replaced, reachable. This keeps the resolver happy.
     WrapInFunction(arg_to_replace);
 
     arg_to_replace = Expr(Source{{12, 34}}, "G");
 
-    // Call the builtin with the constexpr argument replaced
+    // Call the builtin with the constant-expression argument replaced
+    Func("func", utils::Empty, ty.void_(),
+         utils::Vector{
+             CallStmt(Call(overload.function, args)),
+         },
+         utils::Vector{
+             Stage(ast::PipelineStage::kFragment),
+         });
+
+    if (expr.invalid_index == Constexpr::kValid) {
+        EXPECT_TRUE(r()->Resolve()) << r()->error();
+    } else {
+        EXPECT_FALSE(r()->Resolve());
+        std::stringstream err;
+        if (is_vector) {
+            err << "12:34 error: each component of the " << param.name
+                << " argument must be at least " << param.min << " and at most " << param.max
+                << ". " << param.name << " component " << expr.invalid_index << " is "
+                << std::to_string(expr.values[static_cast<size_t>(expr.invalid_index)]);
+        } else {
+            err << "12:34 error: the " << param.name << " argument must be at least " << param.min
+                << " and at most " << param.max << ". " << param.name << " is "
+                << std::to_string(expr.values[static_cast<size_t>(expr.invalid_index)]);
+        }
+        EXPECT_EQ(r()->error(), err.str());
+    }
+}
+
+TEST_P(BuiltinTextureConstExprArgValidationTest, GlobalVar) {
+    auto& p = GetParam();
+    auto overload = std::get<0>(p);
+    auto param = std::get<1>(p);
+    auto expr = std::get<2>(p);
+
+    // Build the global texture and sampler variables
+    overload.BuildTextureVariable(this);
+    overload.BuildSamplerVariable(this);
+
+    // Build the module-scope var 'G' with the offset value
+    GlobalVar("G", expr({}, *this), ast::AddressSpace::kPrivate);
+
+    auto args = overload.args(this);
+    auto*& arg_to_replace = (param.position == Position::kFirst) ? args.Front() : args.Back();
+
+    // Make the expression to be replaced, reachable. This keeps the resolver happy.
+    WrapInFunction(arg_to_replace);
+
+    arg_to_replace = Expr(Source{{12, 34}}, "G");
+
+    // Call the builtin with the constant-expression argument replaced
     Func("func", utils::Empty, ty.void_(),
          utils::Vector{
              CallStmt(Call(overload.function, args)),
diff --git a/src/tint/resolver/validator.cc b/src/tint/resolver/validator.cc
index fccb50f..e8128bb 100644
--- a/src/tint/resolver/validator.cc
+++ b/src/tint/resolver/validator.cc
@@ -1663,50 +1663,29 @@
         std::string name = sem::str(usage);
         auto* arg = call->Arguments()[index];
         if (auto values = arg->ConstantValue()) {
-            // Assert that the constant values are of the expected type.
-            if (!values->Type()->is_integer_scalar_or_vector()) {
-                TINT_ICE(Resolver, diagnostics_)
-                    << "failed to resolve '" + func_name + "' " << name << " parameter type";
-                return false;
-            }
-
-            // Currently const_expr is restricted to literals and type constructors.
-            // Check that that's all we have for the parameter.
-            bool is_const_expr = true;
-            ast::TraverseExpressions(
-                arg->Declaration(), diagnostics_, [&](const ast::Expression* e) {
-                    if (e->IsAnyOf<ast::LiteralExpression, ast::CallExpression>()) {
-                        return ast::TraverseAction::Descend;
-                    }
-                    is_const_expr = false;
-                    return ast::TraverseAction::Stop;
-                });
-            if (is_const_expr) {
-                if (auto* vector = builtin->Parameters()[index]->Type()->As<sem::Vector>()) {
-                    for (size_t i = 0; i < vector->Width(); i++) {
-                        auto value = values->Index(i)->As<AInt>();
-                        if (value < min || value > max) {
-                            AddError("each component of the " + name +
-                                         " argument must be at least " + std::to_string(min) +
-                                         " and at most " + std::to_string(max) + ". " + name +
-                                         " component " + std::to_string(i) + " is " +
-                                         std::to_string(value),
-                                     arg->Declaration()->source);
-                            return false;
-                        }
-                    }
-                } else {
-                    auto value = values->As<AInt>();
+            if (auto* vector = values->Type()->As<sem::Vector>()) {
+                for (size_t i = 0; i < vector->Width(); i++) {
+                    auto value = values->Index(i)->As<AInt>();
                     if (value < min || value > max) {
-                        AddError("the " + name + " argument must be at least " +
+                        AddError("each component of the " + name + " argument must be at least " +
                                      std::to_string(min) + " and at most " + std::to_string(max) +
-                                     ". " + name + " is " + std::to_string(value),
+                                     ". " + name + " component " + std::to_string(i) + " is " +
+                                     std::to_string(value),
                                  arg->Declaration()->source);
                         return false;
                     }
                 }
-                return true;
+            } else {
+                auto value = values->As<AInt>();
+                if (value < min || value > max) {
+                    AddError("the " + name + " argument must be at least " + std::to_string(min) +
+                                 " and at most " + std::to_string(max) + ". " + name + " is " +
+                                 std::to_string(value),
+                             arg->Declaration()->source);
+                    return false;
+                }
             }
+            return true;
         }
         AddError("the " + name + " argument must be a const-expression",
                  arg->Declaration()->source);
diff --git a/test/tint/builtins/gen/gen.wgsl.tmpl b/test/tint/builtins/gen/gen.wgsl.tmpl
index 611f61b..3f07541 100644
--- a/test/tint/builtins/gen/gen.wgsl.tmpl
+++ b/test/tint/builtins/gen/gen.wgsl.tmpl
@@ -124,10 +124,10 @@
 {{template "Type" index $p.Type.TemplateArguments 1}};
 {{- /*indent*/}}  var arg_{{$i}}: {{template "Type" index $p.Type.TemplateArguments 1}};
 {{          $args.Put $i (printf "&arg_%v" $i) -}}
-{{-       else if and (not $p.IsConst) (eq "var" $mode) -}}
-{{-         if $is_abstract }}  const arg_{{$i}} = {{Eval "ArgumentValue" $p}};
-{{          else            }}  var arg_{{$i}} = {{Eval "ArgumentValue" $p}};
-{{          end             }}
+{{-       else if eq "var" $mode -}}
+{{-         if or $is_abstract $p.IsConst }}  const arg_{{$i}} = {{Eval "ArgumentValue" $p}};
+{{          else                          }}  var arg_{{$i}} = {{Eval "ArgumentValue" $p}};
+{{          end                           }}
 {{-         $args.Put $i (printf "arg_%v" $i) -}}
 {{-       else -}}
 {{-         $args.Put $i (Eval "ArgumentValue" $p) -}}
diff --git a/test/tint/builtins/gen/var/textureGather/1f7f6b.wgsl b/test/tint/builtins/gen/var/textureGather/1f7f6b.wgsl
index 2b830f6..b88af9a 100644
--- a/test/tint/builtins/gen/var/textureGather/1f7f6b.wgsl
+++ b/test/tint/builtins/gen/var/textureGather/1f7f6b.wgsl
@@ -26,7 +26,8 @@
 // fn textureGather(texture: texture_depth_2d, sampler: sampler, coords: vec2<f32>, @const offset: vec2<i32>) -> vec4<f32>
 fn textureGather_1f7f6b() {
   var arg_2 = vec2<f32>();
-  var res: vec4<f32> = textureGather(arg_0, arg_1, arg_2, vec2<i32>());
+  const arg_3 = vec2<i32>();
+  var res: vec4<f32> = textureGather(arg_0, arg_1, arg_2, arg_3);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGather/1f7f6b.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureGather/1f7f6b.wgsl.expected.wgsl
index 33aec6e..806fc3e 100644
--- a/test/tint/builtins/gen/var/textureGather/1f7f6b.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureGather/1f7f6b.wgsl.expected.wgsl
@@ -4,7 +4,8 @@
 
 fn textureGather_1f7f6b() {
   var arg_2 = vec2<f32>();
-  var res : vec4<f32> = textureGather(arg_0, arg_1, arg_2, vec2<i32>());
+  const arg_3 = vec2<i32>();
+  var res : vec4<f32> = textureGather(arg_0, arg_1, arg_2, arg_3);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGather/22e930.wgsl b/test/tint/builtins/gen/var/textureGather/22e930.wgsl
index 55a3549..f2ff88c 100644
--- a/test/tint/builtins/gen/var/textureGather/22e930.wgsl
+++ b/test/tint/builtins/gen/var/textureGather/22e930.wgsl
@@ -25,9 +25,10 @@
 
 // fn textureGather(@const component: i32, texture: texture_2d_array<f32>, sampler: sampler, coords: vec2<f32>, array_index: i32) -> vec4<f32>
 fn textureGather_22e930() {
+  const arg_0 = 1;
   var arg_3 = vec2<f32>();
   var arg_4 = 1;
-  var res: vec4<f32> = textureGather(1, arg_1, arg_2, arg_3, arg_4);
+  var res: vec4<f32> = textureGather(arg_0, arg_1, arg_2, arg_3, arg_4);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGather/22e930.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureGather/22e930.wgsl.expected.wgsl
index e804200..76f793e 100644
--- a/test/tint/builtins/gen/var/textureGather/22e930.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureGather/22e930.wgsl.expected.wgsl
@@ -3,9 +3,10 @@
 @group(1) @binding(2) var arg_2 : sampler;
 
 fn textureGather_22e930() {
+  const arg_0 = 1;
   var arg_3 = vec2<f32>();
   var arg_4 = 1;
-  var res : vec4<f32> = textureGather(1, arg_1, arg_2, arg_3, arg_4);
+  var res : vec4<f32> = textureGather(arg_0, arg_1, arg_2, arg_3, arg_4);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGather/2cc066.wgsl b/test/tint/builtins/gen/var/textureGather/2cc066.wgsl
index 01fa4da..bead55e 100644
--- a/test/tint/builtins/gen/var/textureGather/2cc066.wgsl
+++ b/test/tint/builtins/gen/var/textureGather/2cc066.wgsl
@@ -25,9 +25,10 @@
 
 // fn textureGather(@const component: i32, texture: texture_2d_array<u32>, sampler: sampler, coords: vec2<f32>, array_index: i32) -> vec4<u32>
 fn textureGather_2cc066() {
+  const arg_0 = 1;
   var arg_3 = vec2<f32>();
   var arg_4 = 1;
-  var res: vec4<u32> = textureGather(1, arg_1, arg_2, arg_3, arg_4);
+  var res: vec4<u32> = textureGather(arg_0, arg_1, arg_2, arg_3, arg_4);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGather/2cc066.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureGather/2cc066.wgsl.expected.wgsl
index d6358a9..b160e40 100644
--- a/test/tint/builtins/gen/var/textureGather/2cc066.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureGather/2cc066.wgsl.expected.wgsl
@@ -3,9 +3,10 @@
 @group(1) @binding(2) var arg_2 : sampler;
 
 fn textureGather_2cc066() {
+  const arg_0 = 1;
   var arg_3 = vec2<f32>();
   var arg_4 = 1;
-  var res : vec4<u32> = textureGather(1, arg_1, arg_2, arg_3, arg_4);
+  var res : vec4<u32> = textureGather(arg_0, arg_1, arg_2, arg_3, arg_4);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGather/32c4e8.wgsl b/test/tint/builtins/gen/var/textureGather/32c4e8.wgsl
index dc783519..9065700 100644
--- a/test/tint/builtins/gen/var/textureGather/32c4e8.wgsl
+++ b/test/tint/builtins/gen/var/textureGather/32c4e8.wgsl
@@ -25,8 +25,9 @@
 
 // fn textureGather(@const component: i32, texture: texture_cube<f32>, sampler: sampler, coords: vec3<f32>) -> vec4<f32>
 fn textureGather_32c4e8() {
+  const arg_0 = 1;
   var arg_3 = vec3<f32>();
-  var res: vec4<f32> = textureGather(1, arg_1, arg_2, arg_3);
+  var res: vec4<f32> = textureGather(arg_0, arg_1, arg_2, arg_3);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGather/32c4e8.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureGather/32c4e8.wgsl.expected.wgsl
index d748a7b..8e86b15 100644
--- a/test/tint/builtins/gen/var/textureGather/32c4e8.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureGather/32c4e8.wgsl.expected.wgsl
@@ -3,8 +3,9 @@
 @group(1) @binding(2) var arg_2 : sampler;
 
 fn textureGather_32c4e8() {
+  const arg_0 = 1;
   var arg_3 = vec3<f32>();
-  var res : vec4<f32> = textureGather(1, arg_1, arg_2, arg_3);
+  var res : vec4<f32> = textureGather(arg_0, arg_1, arg_2, arg_3);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGather/3b32cc.wgsl b/test/tint/builtins/gen/var/textureGather/3b32cc.wgsl
index 638c14c..b2746f2 100644
--- a/test/tint/builtins/gen/var/textureGather/3b32cc.wgsl
+++ b/test/tint/builtins/gen/var/textureGather/3b32cc.wgsl
@@ -25,8 +25,9 @@
 
 // fn textureGather(@const component: i32, texture: texture_cube<u32>, sampler: sampler, coords: vec3<f32>) -> vec4<u32>
 fn textureGather_3b32cc() {
+  const arg_0 = 1;
   var arg_3 = vec3<f32>();
-  var res: vec4<u32> = textureGather(1, arg_1, arg_2, arg_3);
+  var res: vec4<u32> = textureGather(arg_0, arg_1, arg_2, arg_3);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGather/3b32cc.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureGather/3b32cc.wgsl.expected.wgsl
index 3d33dcb..08fdd02 100644
--- a/test/tint/builtins/gen/var/textureGather/3b32cc.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureGather/3b32cc.wgsl.expected.wgsl
@@ -3,8 +3,9 @@
 @group(1) @binding(2) var arg_2 : sampler;
 
 fn textureGather_3b32cc() {
+  const arg_0 = 1;
   var arg_3 = vec3<f32>();
-  var res : vec4<u32> = textureGather(1, arg_1, arg_2, arg_3);
+  var res : vec4<u32> = textureGather(arg_0, arg_1, arg_2, arg_3);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGather/49b07f.wgsl b/test/tint/builtins/gen/var/textureGather/49b07f.wgsl
index 2984b5b..d175a8b 100644
--- a/test/tint/builtins/gen/var/textureGather/49b07f.wgsl
+++ b/test/tint/builtins/gen/var/textureGather/49b07f.wgsl
@@ -25,8 +25,10 @@
 
 // fn textureGather(@const component: i32, texture: texture_2d<u32>, sampler: sampler, coords: vec2<f32>, @const offset: vec2<i32>) -> vec4<u32>
 fn textureGather_49b07f() {
+  const arg_0 = 1;
   var arg_3 = vec2<f32>();
-  var res: vec4<u32> = textureGather(1, arg_1, arg_2, arg_3, vec2<i32>());
+  const arg_4 = vec2<i32>();
+  var res: vec4<u32> = textureGather(arg_0, arg_1, arg_2, arg_3, arg_4);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGather/49b07f.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureGather/49b07f.wgsl.expected.wgsl
index 78eb732..ae74eb8 100644
--- a/test/tint/builtins/gen/var/textureGather/49b07f.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureGather/49b07f.wgsl.expected.wgsl
@@ -3,8 +3,10 @@
 @group(1) @binding(2) var arg_2 : sampler;
 
 fn textureGather_49b07f() {
+  const arg_0 = 1;
   var arg_3 = vec2<f32>();
-  var res : vec4<u32> = textureGather(1, arg_1, arg_2, arg_3, vec2<i32>());
+  const arg_4 = vec2<i32>();
+  var res : vec4<u32> = textureGather(arg_0, arg_1, arg_2, arg_3, arg_4);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGather/4b8103.wgsl b/test/tint/builtins/gen/var/textureGather/4b8103.wgsl
index 4afc2bc..6daeab0 100644
--- a/test/tint/builtins/gen/var/textureGather/4b8103.wgsl
+++ b/test/tint/builtins/gen/var/textureGather/4b8103.wgsl
@@ -25,9 +25,11 @@
 
 // fn textureGather(@const component: i32, texture: texture_2d_array<f32>, sampler: sampler, coords: vec2<f32>, array_index: i32, @const offset: vec2<i32>) -> vec4<f32>
 fn textureGather_4b8103() {
+  const arg_0 = 1;
   var arg_3 = vec2<f32>();
   var arg_4 = 1;
-  var res: vec4<f32> = textureGather(1, arg_1, arg_2, arg_3, arg_4, vec2<i32>());
+  const arg_5 = vec2<i32>();
+  var res: vec4<f32> = textureGather(arg_0, arg_1, arg_2, arg_3, arg_4, arg_5);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGather/4b8103.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureGather/4b8103.wgsl.expected.wgsl
index 05fe137..ae9f4047 100644
--- a/test/tint/builtins/gen/var/textureGather/4b8103.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureGather/4b8103.wgsl.expected.wgsl
@@ -3,9 +3,11 @@
 @group(1) @binding(2) var arg_2 : sampler;
 
 fn textureGather_4b8103() {
+  const arg_0 = 1;
   var arg_3 = vec2<f32>();
   var arg_4 = 1;
-  var res : vec4<f32> = textureGather(1, arg_1, arg_2, arg_3, arg_4, vec2<i32>());
+  const arg_5 = vec2<i32>();
+  var res : vec4<f32> = textureGather(arg_0, arg_1, arg_2, arg_3, arg_4, arg_5);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGather/5266da.wgsl b/test/tint/builtins/gen/var/textureGather/5266da.wgsl
index b25487c..c7bd8a6 100644
--- a/test/tint/builtins/gen/var/textureGather/5266da.wgsl
+++ b/test/tint/builtins/gen/var/textureGather/5266da.wgsl
@@ -25,8 +25,9 @@
 
 // fn textureGather(@const component: i32, texture: texture_2d<f32>, sampler: sampler, coords: vec2<f32>) -> vec4<f32>
 fn textureGather_5266da() {
+  const arg_0 = 1;
   var arg_3 = vec2<f32>();
-  var res: vec4<f32> = textureGather(1, arg_1, arg_2, arg_3);
+  var res: vec4<f32> = textureGather(arg_0, arg_1, arg_2, arg_3);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGather/5266da.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureGather/5266da.wgsl.expected.wgsl
index 9bf8e14..e7aa64b 100644
--- a/test/tint/builtins/gen/var/textureGather/5266da.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureGather/5266da.wgsl.expected.wgsl
@@ -3,8 +3,9 @@
 @group(1) @binding(2) var arg_2 : sampler;
 
 fn textureGather_5266da() {
+  const arg_0 = 1;
   var arg_3 = vec2<f32>();
-  var res : vec4<f32> = textureGather(1, arg_1, arg_2, arg_3);
+  var res : vec4<f32> = textureGather(arg_0, arg_1, arg_2, arg_3);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGather/5ba85f.wgsl b/test/tint/builtins/gen/var/textureGather/5ba85f.wgsl
index f282cc39..c2dc744 100644
--- a/test/tint/builtins/gen/var/textureGather/5ba85f.wgsl
+++ b/test/tint/builtins/gen/var/textureGather/5ba85f.wgsl
@@ -25,8 +25,9 @@
 
 // fn textureGather(@const component: i32, texture: texture_cube<i32>, sampler: sampler, coords: vec3<f32>) -> vec4<i32>
 fn textureGather_5ba85f() {
+  const arg_0 = 1;
   var arg_3 = vec3<f32>();
-  var res: vec4<i32> = textureGather(1, arg_1, arg_2, arg_3);
+  var res: vec4<i32> = textureGather(arg_0, arg_1, arg_2, arg_3);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGather/5ba85f.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureGather/5ba85f.wgsl.expected.wgsl
index 3f97184..8ac8345 100644
--- a/test/tint/builtins/gen/var/textureGather/5ba85f.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureGather/5ba85f.wgsl.expected.wgsl
@@ -3,8 +3,9 @@
 @group(1) @binding(2) var arg_2 : sampler;
 
 fn textureGather_5ba85f() {
+  const arg_0 = 1;
   var arg_3 = vec3<f32>();
-  var res : vec4<i32> = textureGather(1, arg_1, arg_2, arg_3);
+  var res : vec4<i32> = textureGather(arg_0, arg_1, arg_2, arg_3);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGather/5bd491.wgsl b/test/tint/builtins/gen/var/textureGather/5bd491.wgsl
index 252056d..3a17d5a 100644
--- a/test/tint/builtins/gen/var/textureGather/5bd491.wgsl
+++ b/test/tint/builtins/gen/var/textureGather/5bd491.wgsl
@@ -25,8 +25,9 @@
 
 // fn textureGather(@const component: i32, texture: texture_2d<u32>, sampler: sampler, coords: vec2<f32>) -> vec4<u32>
 fn textureGather_5bd491() {
+  const arg_0 = 1;
   var arg_3 = vec2<f32>();
-  var res: vec4<u32> = textureGather(1, arg_1, arg_2, arg_3);
+  var res: vec4<u32> = textureGather(arg_0, arg_1, arg_2, arg_3);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGather/5bd491.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureGather/5bd491.wgsl.expected.wgsl
index e39e4cf..4e5fc6f 100644
--- a/test/tint/builtins/gen/var/textureGather/5bd491.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureGather/5bd491.wgsl.expected.wgsl
@@ -3,8 +3,9 @@
 @group(1) @binding(2) var arg_2 : sampler;
 
 fn textureGather_5bd491() {
+  const arg_0 = 1;
   var arg_3 = vec2<f32>();
-  var res : vec4<u32> = textureGather(1, arg_1, arg_2, arg_3);
+  var res : vec4<u32> = textureGather(arg_0, arg_1, arg_2, arg_3);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGather/751f8a.wgsl b/test/tint/builtins/gen/var/textureGather/751f8a.wgsl
index 5171396..4caa907 100644
--- a/test/tint/builtins/gen/var/textureGather/751f8a.wgsl
+++ b/test/tint/builtins/gen/var/textureGather/751f8a.wgsl
@@ -25,9 +25,10 @@
 
 // fn textureGather(@const component: i32, texture: texture_cube_array<f32>, sampler: sampler, coords: vec3<f32>, array_index: i32) -> vec4<f32>
 fn textureGather_751f8a() {
+  const arg_0 = 1;
   var arg_3 = vec3<f32>();
   var arg_4 = 1;
-  var res: vec4<f32> = textureGather(1, arg_1, arg_2, arg_3, arg_4);
+  var res: vec4<f32> = textureGather(arg_0, arg_1, arg_2, arg_3, arg_4);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGather/751f8a.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureGather/751f8a.wgsl.expected.wgsl
index 26429ac..2e05c77 100644
--- a/test/tint/builtins/gen/var/textureGather/751f8a.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureGather/751f8a.wgsl.expected.wgsl
@@ -3,9 +3,10 @@
 @group(1) @binding(2) var arg_2 : sampler;
 
 fn textureGather_751f8a() {
+  const arg_0 = 1;
   var arg_3 = vec3<f32>();
   var arg_4 = 1;
-  var res : vec4<f32> = textureGather(1, arg_1, arg_2, arg_3, arg_4);
+  var res : vec4<f32> = textureGather(arg_0, arg_1, arg_2, arg_3, arg_4);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGather/7c3828.wgsl b/test/tint/builtins/gen/var/textureGather/7c3828.wgsl
index f4e6c80..1148627 100644
--- a/test/tint/builtins/gen/var/textureGather/7c3828.wgsl
+++ b/test/tint/builtins/gen/var/textureGather/7c3828.wgsl
@@ -25,8 +25,10 @@
 
 // fn textureGather(@const component: i32, texture: texture_2d<i32>, sampler: sampler, coords: vec2<f32>, @const offset: vec2<i32>) -> vec4<i32>
 fn textureGather_7c3828() {
+  const arg_0 = 1;
   var arg_3 = vec2<f32>();
-  var res: vec4<i32> = textureGather(1, arg_1, arg_2, arg_3, vec2<i32>());
+  const arg_4 = vec2<i32>();
+  var res: vec4<i32> = textureGather(arg_0, arg_1, arg_2, arg_3, arg_4);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGather/7c3828.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureGather/7c3828.wgsl.expected.wgsl
index 326c0a7..9b6d7ef 100644
--- a/test/tint/builtins/gen/var/textureGather/7c3828.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureGather/7c3828.wgsl.expected.wgsl
@@ -3,8 +3,10 @@
 @group(1) @binding(2) var arg_2 : sampler;
 
 fn textureGather_7c3828() {
+  const arg_0 = 1;
   var arg_3 = vec2<f32>();
-  var res : vec4<i32> = textureGather(1, arg_1, arg_2, arg_3, vec2<i32>());
+  const arg_4 = vec2<i32>();
+  var res : vec4<i32> = textureGather(arg_0, arg_1, arg_2, arg_3, arg_4);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGather/8b754c.wgsl b/test/tint/builtins/gen/var/textureGather/8b754c.wgsl
index 80c76fb..809f109 100644
--- a/test/tint/builtins/gen/var/textureGather/8b754c.wgsl
+++ b/test/tint/builtins/gen/var/textureGather/8b754c.wgsl
@@ -25,9 +25,10 @@
 
 // fn textureGather(@const component: i32, texture: texture_2d_array<i32>, sampler: sampler, coords: vec2<f32>, array_index: i32) -> vec4<i32>
 fn textureGather_8b754c() {
+  const arg_0 = 1;
   var arg_3 = vec2<f32>();
   var arg_4 = 1;
-  var res: vec4<i32> = textureGather(1, arg_1, arg_2, arg_3, arg_4);
+  var res: vec4<i32> = textureGather(arg_0, arg_1, arg_2, arg_3, arg_4);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGather/8b754c.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureGather/8b754c.wgsl.expected.wgsl
index 11a8062..2beed6a 100644
--- a/test/tint/builtins/gen/var/textureGather/8b754c.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureGather/8b754c.wgsl.expected.wgsl
@@ -3,9 +3,10 @@
 @group(1) @binding(2) var arg_2 : sampler;
 
 fn textureGather_8b754c() {
+  const arg_0 = 1;
   var arg_3 = vec2<f32>();
   var arg_4 = 1;
-  var res : vec4<i32> = textureGather(1, arg_1, arg_2, arg_3, arg_4);
+  var res : vec4<i32> = textureGather(arg_0, arg_1, arg_2, arg_3, arg_4);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGather/af55b3.wgsl b/test/tint/builtins/gen/var/textureGather/af55b3.wgsl
index 536f17f..96c6725 100644
--- a/test/tint/builtins/gen/var/textureGather/af55b3.wgsl
+++ b/test/tint/builtins/gen/var/textureGather/af55b3.wgsl
@@ -25,8 +25,10 @@
 
 // fn textureGather(@const component: i32, texture: texture_2d<f32>, sampler: sampler, coords: vec2<f32>, @const offset: vec2<i32>) -> vec4<f32>
 fn textureGather_af55b3() {
+  const arg_0 = 1;
   var arg_3 = vec2<f32>();
-  var res: vec4<f32> = textureGather(1, arg_1, arg_2, arg_3, vec2<i32>());
+  const arg_4 = vec2<i32>();
+  var res: vec4<f32> = textureGather(arg_0, arg_1, arg_2, arg_3, arg_4);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGather/af55b3.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureGather/af55b3.wgsl.expected.wgsl
index bc63ad8..ea1374c 100644
--- a/test/tint/builtins/gen/var/textureGather/af55b3.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureGather/af55b3.wgsl.expected.wgsl
@@ -3,8 +3,10 @@
 @group(1) @binding(2) var arg_2 : sampler;
 
 fn textureGather_af55b3() {
+  const arg_0 = 1;
   var arg_3 = vec2<f32>();
-  var res : vec4<f32> = textureGather(1, arg_1, arg_2, arg_3, vec2<i32>());
+  const arg_4 = vec2<i32>();
+  var res : vec4<f32> = textureGather(arg_0, arg_1, arg_2, arg_3, arg_4);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGather/bb3ac5.wgsl b/test/tint/builtins/gen/var/textureGather/bb3ac5.wgsl
index 9c7772d..94fba14 100644
--- a/test/tint/builtins/gen/var/textureGather/bb3ac5.wgsl
+++ b/test/tint/builtins/gen/var/textureGather/bb3ac5.wgsl
@@ -25,8 +25,9 @@
 
 // fn textureGather(@const component: i32, texture: texture_2d<i32>, sampler: sampler, coords: vec2<f32>) -> vec4<i32>
 fn textureGather_bb3ac5() {
+  const arg_0 = 1;
   var arg_3 = vec2<f32>();
-  var res: vec4<i32> = textureGather(1, arg_1, arg_2, arg_3);
+  var res: vec4<i32> = textureGather(arg_0, arg_1, arg_2, arg_3);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGather/bb3ac5.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureGather/bb3ac5.wgsl.expected.wgsl
index 62af63a..13e9938 100644
--- a/test/tint/builtins/gen/var/textureGather/bb3ac5.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureGather/bb3ac5.wgsl.expected.wgsl
@@ -3,8 +3,9 @@
 @group(1) @binding(2) var arg_2 : sampler;
 
 fn textureGather_bb3ac5() {
+  const arg_0 = 1;
   var arg_3 = vec2<f32>();
-  var res : vec4<i32> = textureGather(1, arg_1, arg_2, arg_3);
+  var res : vec4<i32> = textureGather(arg_0, arg_1, arg_2, arg_3);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGather/c0640c.wgsl b/test/tint/builtins/gen/var/textureGather/c0640c.wgsl
index c39fad3..a0398d9 100644
--- a/test/tint/builtins/gen/var/textureGather/c0640c.wgsl
+++ b/test/tint/builtins/gen/var/textureGather/c0640c.wgsl
@@ -25,9 +25,10 @@
 
 // fn textureGather(@const component: i32, texture: texture_cube_array<i32>, sampler: sampler, coords: vec3<f32>, array_index: i32) -> vec4<i32>
 fn textureGather_c0640c() {
+  const arg_0 = 1;
   var arg_3 = vec3<f32>();
   var arg_4 = 1;
-  var res: vec4<i32> = textureGather(1, arg_1, arg_2, arg_3, arg_4);
+  var res: vec4<i32> = textureGather(arg_0, arg_1, arg_2, arg_3, arg_4);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGather/c0640c.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureGather/c0640c.wgsl.expected.wgsl
index ecea543..3ed25dc 100644
--- a/test/tint/builtins/gen/var/textureGather/c0640c.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureGather/c0640c.wgsl.expected.wgsl
@@ -3,9 +3,10 @@
 @group(1) @binding(2) var arg_2 : sampler;
 
 fn textureGather_c0640c() {
+  const arg_0 = 1;
   var arg_3 = vec3<f32>();
   var arg_4 = 1;
-  var res : vec4<i32> = textureGather(1, arg_1, arg_2, arg_3, arg_4);
+  var res : vec4<i32> = textureGather(arg_0, arg_1, arg_2, arg_3, arg_4);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGather/d1f187.wgsl b/test/tint/builtins/gen/var/textureGather/d1f187.wgsl
index 2c2a002..40ccaf0 100644
--- a/test/tint/builtins/gen/var/textureGather/d1f187.wgsl
+++ b/test/tint/builtins/gen/var/textureGather/d1f187.wgsl
@@ -25,9 +25,11 @@
 
 // fn textureGather(@const component: i32, texture: texture_2d_array<u32>, sampler: sampler, coords: vec2<f32>, array_index: i32, @const offset: vec2<i32>) -> vec4<u32>
 fn textureGather_d1f187() {
+  const arg_0 = 1;
   var arg_3 = vec2<f32>();
   var arg_4 = 1;
-  var res: vec4<u32> = textureGather(1, arg_1, arg_2, arg_3, arg_4, vec2<i32>());
+  const arg_5 = vec2<i32>();
+  var res: vec4<u32> = textureGather(arg_0, arg_1, arg_2, arg_3, arg_4, arg_5);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGather/d1f187.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureGather/d1f187.wgsl.expected.wgsl
index 6c81729..3c4f11b 100644
--- a/test/tint/builtins/gen/var/textureGather/d1f187.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureGather/d1f187.wgsl.expected.wgsl
@@ -3,9 +3,11 @@
 @group(1) @binding(2) var arg_2 : sampler;
 
 fn textureGather_d1f187() {
+  const arg_0 = 1;
   var arg_3 = vec2<f32>();
   var arg_4 = 1;
-  var res : vec4<u32> = textureGather(1, arg_1, arg_2, arg_3, arg_4, vec2<i32>());
+  const arg_5 = vec2<i32>();
+  var res : vec4<u32> = textureGather(arg_0, arg_1, arg_2, arg_3, arg_4, arg_5);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGather/d90605.wgsl b/test/tint/builtins/gen/var/textureGather/d90605.wgsl
index de29a6c..85734df 100644
--- a/test/tint/builtins/gen/var/textureGather/d90605.wgsl
+++ b/test/tint/builtins/gen/var/textureGather/d90605.wgsl
@@ -27,7 +27,8 @@
 fn textureGather_d90605() {
   var arg_2 = vec2<f32>();
   var arg_3 = 1;
-  var res: vec4<f32> = textureGather(arg_0, arg_1, arg_2, arg_3, vec2<i32>());
+  const arg_4 = vec2<i32>();
+  var res: vec4<f32> = textureGather(arg_0, arg_1, arg_2, arg_3, arg_4);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGather/d90605.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureGather/d90605.wgsl.expected.wgsl
index e27b9c7..be814a9 100644
--- a/test/tint/builtins/gen/var/textureGather/d90605.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureGather/d90605.wgsl.expected.wgsl
@@ -5,7 +5,8 @@
 fn textureGather_d90605() {
   var arg_2 = vec2<f32>();
   var arg_3 = 1;
-  var res : vec4<f32> = textureGather(arg_0, arg_1, arg_2, arg_3, vec2<i32>());
+  const arg_4 = vec2<i32>();
+  var res : vec4<f32> = textureGather(arg_0, arg_1, arg_2, arg_3, arg_4);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGather/e9d390.wgsl b/test/tint/builtins/gen/var/textureGather/e9d390.wgsl
index 15a4868..cb747a7 100644
--- a/test/tint/builtins/gen/var/textureGather/e9d390.wgsl
+++ b/test/tint/builtins/gen/var/textureGather/e9d390.wgsl
@@ -25,9 +25,11 @@
 
 // fn textureGather(@const component: i32, texture: texture_2d_array<i32>, sampler: sampler, coords: vec2<f32>, array_index: i32, @const offset: vec2<i32>) -> vec4<i32>
 fn textureGather_e9d390() {
+  const arg_0 = 1;
   var arg_3 = vec2<f32>();
   var arg_4 = 1;
-  var res: vec4<i32> = textureGather(1, arg_1, arg_2, arg_3, arg_4, vec2<i32>());
+  const arg_5 = vec2<i32>();
+  var res: vec4<i32> = textureGather(arg_0, arg_1, arg_2, arg_3, arg_4, arg_5);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGather/e9d390.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureGather/e9d390.wgsl.expected.wgsl
index b4ffcf0..6ae61fd 100644
--- a/test/tint/builtins/gen/var/textureGather/e9d390.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureGather/e9d390.wgsl.expected.wgsl
@@ -3,9 +3,11 @@
 @group(1) @binding(2) var arg_2 : sampler;
 
 fn textureGather_e9d390() {
+  const arg_0 = 1;
   var arg_3 = vec2<f32>();
   var arg_4 = 1;
-  var res : vec4<i32> = textureGather(1, arg_1, arg_2, arg_3, arg_4, vec2<i32>());
+  const arg_5 = vec2<i32>();
+  var res : vec4<i32> = textureGather(arg_0, arg_1, arg_2, arg_3, arg_4, arg_5);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGather/f2c6e3.wgsl b/test/tint/builtins/gen/var/textureGather/f2c6e3.wgsl
index ab7c3a8..bacb2fc 100644
--- a/test/tint/builtins/gen/var/textureGather/f2c6e3.wgsl
+++ b/test/tint/builtins/gen/var/textureGather/f2c6e3.wgsl
@@ -25,9 +25,10 @@
 
 // fn textureGather(@const component: i32, texture: texture_cube_array<u32>, sampler: sampler, coords: vec3<f32>, array_index: i32) -> vec4<u32>
 fn textureGather_f2c6e3() {
+  const arg_0 = 1;
   var arg_3 = vec3<f32>();
   var arg_4 = 1;
-  var res: vec4<u32> = textureGather(1, arg_1, arg_2, arg_3, arg_4);
+  var res: vec4<u32> = textureGather(arg_0, arg_1, arg_2, arg_3, arg_4);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGather/f2c6e3.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureGather/f2c6e3.wgsl.expected.wgsl
index 725af08..b689b71 100644
--- a/test/tint/builtins/gen/var/textureGather/f2c6e3.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureGather/f2c6e3.wgsl.expected.wgsl
@@ -3,9 +3,10 @@
 @group(1) @binding(2) var arg_2 : sampler;
 
 fn textureGather_f2c6e3() {
+  const arg_0 = 1;
   var arg_3 = vec3<f32>();
   var arg_4 = 1;
-  var res : vec4<u32> = textureGather(1, arg_1, arg_2, arg_3, arg_4);
+  var res : vec4<u32> = textureGather(arg_0, arg_1, arg_2, arg_3, arg_4);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGatherCompare/313add.wgsl b/test/tint/builtins/gen/var/textureGatherCompare/313add.wgsl
index 0709512..6dee4b9 100644
--- a/test/tint/builtins/gen/var/textureGatherCompare/313add.wgsl
+++ b/test/tint/builtins/gen/var/textureGatherCompare/313add.wgsl
@@ -27,7 +27,8 @@
 fn textureGatherCompare_313add() {
   var arg_2 = vec2<f32>();
   var arg_3 = 1.f;
-  var res: vec4<f32> = textureGatherCompare(arg_0, arg_1, arg_2, arg_3, vec2<i32>());
+  const arg_4 = vec2<i32>();
+  var res: vec4<f32> = textureGatherCompare(arg_0, arg_1, arg_2, arg_3, arg_4);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGatherCompare/313add.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureGatherCompare/313add.wgsl.expected.wgsl
index 7b877b4..bf8dea8 100644
--- a/test/tint/builtins/gen/var/textureGatherCompare/313add.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureGatherCompare/313add.wgsl.expected.wgsl
@@ -5,7 +5,8 @@
 fn textureGatherCompare_313add() {
   var arg_2 = vec2<f32>();
   var arg_3 = 1.0f;
-  var res : vec4<f32> = textureGatherCompare(arg_0, arg_1, arg_2, arg_3, vec2<i32>());
+  const arg_4 = vec2<i32>();
+  var res : vec4<f32> = textureGatherCompare(arg_0, arg_1, arg_2, arg_3, arg_4);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGatherCompare/f585cc.wgsl b/test/tint/builtins/gen/var/textureGatherCompare/f585cc.wgsl
index c4e7970..2ee4b70 100644
--- a/test/tint/builtins/gen/var/textureGatherCompare/f585cc.wgsl
+++ b/test/tint/builtins/gen/var/textureGatherCompare/f585cc.wgsl
@@ -28,7 +28,8 @@
   var arg_2 = vec2<f32>();
   var arg_3 = 1;
   var arg_4 = 1.f;
-  var res: vec4<f32> = textureGatherCompare(arg_0, arg_1, arg_2, arg_3, arg_4, vec2<i32>());
+  const arg_5 = vec2<i32>();
+  var res: vec4<f32> = textureGatherCompare(arg_0, arg_1, arg_2, arg_3, arg_4, arg_5);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureGatherCompare/f585cc.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureGatherCompare/f585cc.wgsl.expected.wgsl
index edea369..0fd04a0 100644
--- a/test/tint/builtins/gen/var/textureGatherCompare/f585cc.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureGatherCompare/f585cc.wgsl.expected.wgsl
@@ -6,7 +6,8 @@
   var arg_2 = vec2<f32>();
   var arg_3 = 1;
   var arg_4 = 1.0f;
-  var res : vec4<f32> = textureGatherCompare(arg_0, arg_1, arg_2, arg_3, arg_4, vec2<i32>());
+  const arg_5 = vec2<i32>();
+  var res : vec4<f32> = textureGatherCompare(arg_0, arg_1, arg_2, arg_3, arg_4, arg_5);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureSample/0dff6c.wgsl b/test/tint/builtins/gen/var/textureSample/0dff6c.wgsl
index 2a66afe..73882bb 100644
--- a/test/tint/builtins/gen/var/textureSample/0dff6c.wgsl
+++ b/test/tint/builtins/gen/var/textureSample/0dff6c.wgsl
@@ -26,7 +26,8 @@
 // fn textureSample(texture: texture_depth_2d, sampler: sampler, coords: vec2<f32>, @const offset: vec2<i32>) -> f32
 fn textureSample_0dff6c() {
   var arg_2 = vec2<f32>();
-  var res: f32 = textureSample(arg_0, arg_1, arg_2, vec2<i32>());
+  const arg_3 = vec2<i32>();
+  var res: f32 = textureSample(arg_0, arg_1, arg_2, arg_3);
 }
 
 @fragment
diff --git a/test/tint/builtins/gen/var/textureSample/0dff6c.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureSample/0dff6c.wgsl.expected.wgsl
index 699d1c5..21bf36c 100644
--- a/test/tint/builtins/gen/var/textureSample/0dff6c.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureSample/0dff6c.wgsl.expected.wgsl
@@ -4,7 +4,8 @@
 
 fn textureSample_0dff6c() {
   var arg_2 = vec2<f32>();
-  var res : f32 = textureSample(arg_0, arg_1, arg_2, vec2<i32>());
+  const arg_3 = vec2<i32>();
+  var res : f32 = textureSample(arg_0, arg_1, arg_2, arg_3);
 }
 
 @fragment
diff --git a/test/tint/builtins/gen/var/textureSample/17e988.wgsl b/test/tint/builtins/gen/var/textureSample/17e988.wgsl
index d0e4bf5..470c430 100644
--- a/test/tint/builtins/gen/var/textureSample/17e988.wgsl
+++ b/test/tint/builtins/gen/var/textureSample/17e988.wgsl
@@ -27,7 +27,8 @@
 fn textureSample_17e988() {
   var arg_2 = vec2<f32>();
   var arg_3 = 1;
-  var res: vec4<f32> = textureSample(arg_0, arg_1, arg_2, arg_3, vec2<i32>());
+  const arg_4 = vec2<i32>();
+  var res: vec4<f32> = textureSample(arg_0, arg_1, arg_2, arg_3, arg_4);
 }
 
 @fragment
diff --git a/test/tint/builtins/gen/var/textureSample/17e988.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureSample/17e988.wgsl.expected.wgsl
index 1b022a5..120b954 100644
--- a/test/tint/builtins/gen/var/textureSample/17e988.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureSample/17e988.wgsl.expected.wgsl
@@ -5,7 +5,8 @@
 fn textureSample_17e988() {
   var arg_2 = vec2<f32>();
   var arg_3 = 1;
-  var res : vec4<f32> = textureSample(arg_0, arg_1, arg_2, arg_3, vec2<i32>());
+  const arg_4 = vec2<i32>();
+  var res : vec4<f32> = textureSample(arg_0, arg_1, arg_2, arg_3, arg_4);
 }
 
 @fragment
diff --git a/test/tint/builtins/gen/var/textureSample/2149ec.wgsl b/test/tint/builtins/gen/var/textureSample/2149ec.wgsl
index b2ccbf4..b575fba 100644
--- a/test/tint/builtins/gen/var/textureSample/2149ec.wgsl
+++ b/test/tint/builtins/gen/var/textureSample/2149ec.wgsl
@@ -26,7 +26,8 @@
 // fn textureSample(texture: texture_3d<f32>, sampler: sampler, coords: vec3<f32>, @const offset: vec3<i32>) -> vec4<f32>
 fn textureSample_2149ec() {
   var arg_2 = vec3<f32>();
-  var res: vec4<f32> = textureSample(arg_0, arg_1, arg_2, vec3<i32>());
+  const arg_3 = vec3<i32>();
+  var res: vec4<f32> = textureSample(arg_0, arg_1, arg_2, arg_3);
 }
 
 @fragment
diff --git a/test/tint/builtins/gen/var/textureSample/2149ec.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureSample/2149ec.wgsl.expected.wgsl
index 8d3f05d..2d7485d 100644
--- a/test/tint/builtins/gen/var/textureSample/2149ec.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureSample/2149ec.wgsl.expected.wgsl
@@ -4,7 +4,8 @@
 
 fn textureSample_2149ec() {
   var arg_2 = vec3<f32>();
-  var res : vec4<f32> = textureSample(arg_0, arg_1, arg_2, vec3<i32>());
+  const arg_3 = vec3<i32>();
+  var res : vec4<f32> = textureSample(arg_0, arg_1, arg_2, arg_3);
 }
 
 @fragment
diff --git a/test/tint/builtins/gen/var/textureSample/60bf45.wgsl b/test/tint/builtins/gen/var/textureSample/60bf45.wgsl
index 1f7a43d..8aadc7a 100644
--- a/test/tint/builtins/gen/var/textureSample/60bf45.wgsl
+++ b/test/tint/builtins/gen/var/textureSample/60bf45.wgsl
@@ -27,7 +27,8 @@
 fn textureSample_60bf45() {
   var arg_2 = vec2<f32>();
   var arg_3 = 1;
-  var res: f32 = textureSample(arg_0, arg_1, arg_2, arg_3, vec2<i32>());
+  const arg_4 = vec2<i32>();
+  var res: f32 = textureSample(arg_0, arg_1, arg_2, arg_3, arg_4);
 }
 
 @fragment
diff --git a/test/tint/builtins/gen/var/textureSample/60bf45.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureSample/60bf45.wgsl.expected.wgsl
index b8950b6..8acade4 100644
--- a/test/tint/builtins/gen/var/textureSample/60bf45.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureSample/60bf45.wgsl.expected.wgsl
@@ -5,7 +5,8 @@
 fn textureSample_60bf45() {
   var arg_2 = vec2<f32>();
   var arg_3 = 1;
-  var res : f32 = textureSample(arg_0, arg_1, arg_2, arg_3, vec2<i32>());
+  const arg_4 = vec2<i32>();
+  var res : f32 = textureSample(arg_0, arg_1, arg_2, arg_3, arg_4);
 }
 
 @fragment
diff --git a/test/tint/builtins/gen/var/textureSample/85c4ba.wgsl b/test/tint/builtins/gen/var/textureSample/85c4ba.wgsl
index 2741ab9..a60754c 100644
--- a/test/tint/builtins/gen/var/textureSample/85c4ba.wgsl
+++ b/test/tint/builtins/gen/var/textureSample/85c4ba.wgsl
@@ -26,7 +26,8 @@
 // fn textureSample(texture: texture_2d<f32>, sampler: sampler, coords: vec2<f32>, @const offset: vec2<i32>) -> vec4<f32>
 fn textureSample_85c4ba() {
   var arg_2 = vec2<f32>();
-  var res: vec4<f32> = textureSample(arg_0, arg_1, arg_2, vec2<i32>());
+  const arg_3 = vec2<i32>();
+  var res: vec4<f32> = textureSample(arg_0, arg_1, arg_2, arg_3);
 }
 
 @fragment
diff --git a/test/tint/builtins/gen/var/textureSample/85c4ba.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureSample/85c4ba.wgsl.expected.wgsl
index 2694416..8f1a0af 100644
--- a/test/tint/builtins/gen/var/textureSample/85c4ba.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureSample/85c4ba.wgsl.expected.wgsl
@@ -4,7 +4,8 @@
 
 fn textureSample_85c4ba() {
   var arg_2 = vec2<f32>();
-  var res : vec4<f32> = textureSample(arg_0, arg_1, arg_2, vec2<i32>());
+  const arg_3 = vec2<i32>();
+  var res : vec4<f32> = textureSample(arg_0, arg_1, arg_2, arg_3);
 }
 
 @fragment
diff --git a/test/tint/builtins/gen/var/textureSampleBias/594824.wgsl b/test/tint/builtins/gen/var/textureSampleBias/594824.wgsl
index 6eacca7..db6c22f 100644
--- a/test/tint/builtins/gen/var/textureSampleBias/594824.wgsl
+++ b/test/tint/builtins/gen/var/textureSampleBias/594824.wgsl
@@ -27,7 +27,8 @@
 fn textureSampleBias_594824() {
   var arg_2 = vec3<f32>();
   var arg_3 = 1.f;
-  var res: vec4<f32> = textureSampleBias(arg_0, arg_1, arg_2, arg_3, vec3<i32>());
+  const arg_4 = vec3<i32>();
+  var res: vec4<f32> = textureSampleBias(arg_0, arg_1, arg_2, arg_3, arg_4);
 }
 
 @fragment
diff --git a/test/tint/builtins/gen/var/textureSampleBias/594824.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureSampleBias/594824.wgsl.expected.wgsl
index cca18b9..c271970 100644
--- a/test/tint/builtins/gen/var/textureSampleBias/594824.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureSampleBias/594824.wgsl.expected.wgsl
@@ -5,7 +5,8 @@
 fn textureSampleBias_594824() {
   var arg_2 = vec3<f32>();
   var arg_3 = 1.0f;
-  var res : vec4<f32> = textureSampleBias(arg_0, arg_1, arg_2, arg_3, vec3<i32>());
+  const arg_4 = vec3<i32>();
+  var res : vec4<f32> = textureSampleBias(arg_0, arg_1, arg_2, arg_3, arg_4);
 }
 
 @fragment
diff --git a/test/tint/builtins/gen/var/textureSampleBias/9dbb51.wgsl b/test/tint/builtins/gen/var/textureSampleBias/9dbb51.wgsl
index ffb36ec..7283eec 100644
--- a/test/tint/builtins/gen/var/textureSampleBias/9dbb51.wgsl
+++ b/test/tint/builtins/gen/var/textureSampleBias/9dbb51.wgsl
@@ -28,7 +28,8 @@
   var arg_2 = vec2<f32>();
   var arg_3 = 1;
   var arg_4 = 1.f;
-  var res: vec4<f32> = textureSampleBias(arg_0, arg_1, arg_2, arg_3, arg_4, vec2<i32>());
+  const arg_5 = vec2<i32>();
+  var res: vec4<f32> = textureSampleBias(arg_0, arg_1, arg_2, arg_3, arg_4, arg_5);
 }
 
 @fragment
diff --git a/test/tint/builtins/gen/var/textureSampleBias/9dbb51.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureSampleBias/9dbb51.wgsl.expected.wgsl
index 63b8038..52e9865 100644
--- a/test/tint/builtins/gen/var/textureSampleBias/9dbb51.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureSampleBias/9dbb51.wgsl.expected.wgsl
@@ -6,7 +6,8 @@
   var arg_2 = vec2<f32>();
   var arg_3 = 1;
   var arg_4 = 1.0f;
-  var res : vec4<f32> = textureSampleBias(arg_0, arg_1, arg_2, arg_3, arg_4, vec2<i32>());
+  const arg_5 = vec2<i32>();
+  var res : vec4<f32> = textureSampleBias(arg_0, arg_1, arg_2, arg_3, arg_4, arg_5);
 }
 
 @fragment
diff --git a/test/tint/builtins/gen/var/textureSampleBias/a161cf.wgsl b/test/tint/builtins/gen/var/textureSampleBias/a161cf.wgsl
index 05ab472..97f7474 100644
--- a/test/tint/builtins/gen/var/textureSampleBias/a161cf.wgsl
+++ b/test/tint/builtins/gen/var/textureSampleBias/a161cf.wgsl
@@ -27,7 +27,8 @@
 fn textureSampleBias_a161cf() {
   var arg_2 = vec2<f32>();
   var arg_3 = 1.f;
-  var res: vec4<f32> = textureSampleBias(arg_0, arg_1, arg_2, arg_3, vec2<i32>());
+  const arg_4 = vec2<i32>();
+  var res: vec4<f32> = textureSampleBias(arg_0, arg_1, arg_2, arg_3, arg_4);
 }
 
 @fragment
diff --git a/test/tint/builtins/gen/var/textureSampleBias/a161cf.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureSampleBias/a161cf.wgsl.expected.wgsl
index 45096c0..2c24a5f 100644
--- a/test/tint/builtins/gen/var/textureSampleBias/a161cf.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureSampleBias/a161cf.wgsl.expected.wgsl
@@ -5,7 +5,8 @@
 fn textureSampleBias_a161cf() {
   var arg_2 = vec2<f32>();
   var arg_3 = 1.0f;
-  var res : vec4<f32> = textureSampleBias(arg_0, arg_1, arg_2, arg_3, vec2<i32>());
+  const arg_4 = vec2<i32>();
+  var res : vec4<f32> = textureSampleBias(arg_0, arg_1, arg_2, arg_3, arg_4);
 }
 
 @fragment
diff --git a/test/tint/builtins/gen/var/textureSampleCompare/af1051.wgsl b/test/tint/builtins/gen/var/textureSampleCompare/af1051.wgsl
index 09f20fa..7d10cd7 100644
--- a/test/tint/builtins/gen/var/textureSampleCompare/af1051.wgsl
+++ b/test/tint/builtins/gen/var/textureSampleCompare/af1051.wgsl
@@ -28,7 +28,8 @@
   var arg_2 = vec2<f32>();
   var arg_3 = 1;
   var arg_4 = 1.f;
-  var res: f32 = textureSampleCompare(arg_0, arg_1, arg_2, arg_3, arg_4, vec2<i32>());
+  const arg_5 = vec2<i32>();
+  var res: f32 = textureSampleCompare(arg_0, arg_1, arg_2, arg_3, arg_4, arg_5);
 }
 
 @fragment
diff --git a/test/tint/builtins/gen/var/textureSampleCompare/af1051.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureSampleCompare/af1051.wgsl.expected.wgsl
index 9c60816..c67e82e 100644
--- a/test/tint/builtins/gen/var/textureSampleCompare/af1051.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureSampleCompare/af1051.wgsl.expected.wgsl
@@ -6,7 +6,8 @@
   var arg_2 = vec2<f32>();
   var arg_3 = 1;
   var arg_4 = 1.0f;
-  var res : f32 = textureSampleCompare(arg_0, arg_1, arg_2, arg_3, arg_4, vec2<i32>());
+  const arg_5 = vec2<i32>();
+  var res : f32 = textureSampleCompare(arg_0, arg_1, arg_2, arg_3, arg_4, arg_5);
 }
 
 @fragment
diff --git a/test/tint/builtins/gen/var/textureSampleCompare/dec064.wgsl b/test/tint/builtins/gen/var/textureSampleCompare/dec064.wgsl
index e7afea8..4487b72 100644
--- a/test/tint/builtins/gen/var/textureSampleCompare/dec064.wgsl
+++ b/test/tint/builtins/gen/var/textureSampleCompare/dec064.wgsl
@@ -27,7 +27,8 @@
 fn textureSampleCompare_dec064() {
   var arg_2 = vec2<f32>();
   var arg_3 = 1.f;
-  var res: f32 = textureSampleCompare(arg_0, arg_1, arg_2, arg_3, vec2<i32>());
+  const arg_4 = vec2<i32>();
+  var res: f32 = textureSampleCompare(arg_0, arg_1, arg_2, arg_3, arg_4);
 }
 
 @fragment
diff --git a/test/tint/builtins/gen/var/textureSampleCompare/dec064.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureSampleCompare/dec064.wgsl.expected.wgsl
index ccf80c9..fdc4189 100644
--- a/test/tint/builtins/gen/var/textureSampleCompare/dec064.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureSampleCompare/dec064.wgsl.expected.wgsl
@@ -5,7 +5,8 @@
 fn textureSampleCompare_dec064() {
   var arg_2 = vec2<f32>();
   var arg_3 = 1.0f;
-  var res : f32 = textureSampleCompare(arg_0, arg_1, arg_2, arg_3, vec2<i32>());
+  const arg_4 = vec2<i32>();
+  var res : f32 = textureSampleCompare(arg_0, arg_1, arg_2, arg_3, arg_4);
 }
 
 @fragment
diff --git a/test/tint/builtins/gen/var/textureSampleCompareLevel/7f2b9a.wgsl b/test/tint/builtins/gen/var/textureSampleCompareLevel/7f2b9a.wgsl
index 6d29969..399dfb5 100644
--- a/test/tint/builtins/gen/var/textureSampleCompareLevel/7f2b9a.wgsl
+++ b/test/tint/builtins/gen/var/textureSampleCompareLevel/7f2b9a.wgsl
@@ -27,7 +27,8 @@
 fn textureSampleCompareLevel_7f2b9a() {
   var arg_2 = vec2<f32>();
   var arg_3 = 1.f;
-  var res: f32 = textureSampleCompareLevel(arg_0, arg_1, arg_2, arg_3, vec2<i32>());
+  const arg_4 = vec2<i32>();
+  var res: f32 = textureSampleCompareLevel(arg_0, arg_1, arg_2, arg_3, arg_4);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureSampleCompareLevel/7f2b9a.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureSampleCompareLevel/7f2b9a.wgsl.expected.wgsl
index c4473ab..cbb72fd 100644
--- a/test/tint/builtins/gen/var/textureSampleCompareLevel/7f2b9a.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureSampleCompareLevel/7f2b9a.wgsl.expected.wgsl
@@ -5,7 +5,8 @@
 fn textureSampleCompareLevel_7f2b9a() {
   var arg_2 = vec2<f32>();
   var arg_3 = 1.0f;
-  var res : f32 = textureSampleCompareLevel(arg_0, arg_1, arg_2, arg_3, vec2<i32>());
+  const arg_4 = vec2<i32>();
+  var res : f32 = textureSampleCompareLevel(arg_0, arg_1, arg_2, arg_3, arg_4);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureSampleCompareLevel/b6e47c.wgsl b/test/tint/builtins/gen/var/textureSampleCompareLevel/b6e47c.wgsl
index c466840..0cc0ea7 100644
--- a/test/tint/builtins/gen/var/textureSampleCompareLevel/b6e47c.wgsl
+++ b/test/tint/builtins/gen/var/textureSampleCompareLevel/b6e47c.wgsl
@@ -28,7 +28,8 @@
   var arg_2 = vec2<f32>();
   var arg_3 = 1;
   var arg_4 = 1.f;
-  var res: f32 = textureSampleCompareLevel(arg_0, arg_1, arg_2, arg_3, arg_4, vec2<i32>());
+  const arg_5 = vec2<i32>();
+  var res: f32 = textureSampleCompareLevel(arg_0, arg_1, arg_2, arg_3, arg_4, arg_5);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureSampleCompareLevel/b6e47c.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureSampleCompareLevel/b6e47c.wgsl.expected.wgsl
index 3bf1415..9f88b6f 100644
--- a/test/tint/builtins/gen/var/textureSampleCompareLevel/b6e47c.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureSampleCompareLevel/b6e47c.wgsl.expected.wgsl
@@ -6,7 +6,8 @@
   var arg_2 = vec2<f32>();
   var arg_3 = 1;
   var arg_4 = 1.0f;
-  var res : f32 = textureSampleCompareLevel(arg_0, arg_1, arg_2, arg_3, arg_4, vec2<i32>());
+  const arg_5 = vec2<i32>();
+  var res : f32 = textureSampleCompareLevel(arg_0, arg_1, arg_2, arg_3, arg_4, arg_5);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureSampleGrad/5884dd.wgsl b/test/tint/builtins/gen/var/textureSampleGrad/5884dd.wgsl
index 029d592..082cf54 100644
--- a/test/tint/builtins/gen/var/textureSampleGrad/5884dd.wgsl
+++ b/test/tint/builtins/gen/var/textureSampleGrad/5884dd.wgsl
@@ -28,7 +28,8 @@
   var arg_2 = vec3<f32>();
   var arg_3 = vec3<f32>();
   var arg_4 = vec3<f32>();
-  var res: vec4<f32> = textureSampleGrad(arg_0, arg_1, arg_2, arg_3, arg_4, vec3<i32>());
+  const arg_5 = vec3<i32>();
+  var res: vec4<f32> = textureSampleGrad(arg_0, arg_1, arg_2, arg_3, arg_4, arg_5);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureSampleGrad/5884dd.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureSampleGrad/5884dd.wgsl.expected.wgsl
index 9e7449a..9a43b69 100644
--- a/test/tint/builtins/gen/var/textureSampleGrad/5884dd.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureSampleGrad/5884dd.wgsl.expected.wgsl
@@ -6,7 +6,8 @@
   var arg_2 = vec3<f32>();
   var arg_3 = vec3<f32>();
   var arg_4 = vec3<f32>();
-  var res : vec4<f32> = textureSampleGrad(arg_0, arg_1, arg_2, arg_3, arg_4, vec3<i32>());
+  const arg_5 = vec3<i32>();
+  var res : vec4<f32> = textureSampleGrad(arg_0, arg_1, arg_2, arg_3, arg_4, arg_5);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureSampleGrad/d4e3c5.wgsl b/test/tint/builtins/gen/var/textureSampleGrad/d4e3c5.wgsl
index 22b9b2a..d612765 100644
--- a/test/tint/builtins/gen/var/textureSampleGrad/d4e3c5.wgsl
+++ b/test/tint/builtins/gen/var/textureSampleGrad/d4e3c5.wgsl
@@ -28,7 +28,8 @@
   var arg_2 = vec2<f32>();
   var arg_3 = vec2<f32>();
   var arg_4 = vec2<f32>();
-  var res: vec4<f32> = textureSampleGrad(arg_0, arg_1, arg_2, arg_3, arg_4, vec2<i32>());
+  const arg_5 = vec2<i32>();
+  var res: vec4<f32> = textureSampleGrad(arg_0, arg_1, arg_2, arg_3, arg_4, arg_5);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureSampleGrad/d4e3c5.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureSampleGrad/d4e3c5.wgsl.expected.wgsl
index c40b807..47a0090 100644
--- a/test/tint/builtins/gen/var/textureSampleGrad/d4e3c5.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureSampleGrad/d4e3c5.wgsl.expected.wgsl
@@ -6,7 +6,8 @@
   var arg_2 = vec2<f32>();
   var arg_3 = vec2<f32>();
   var arg_4 = vec2<f32>();
-  var res : vec4<f32> = textureSampleGrad(arg_0, arg_1, arg_2, arg_3, arg_4, vec2<i32>());
+  const arg_5 = vec2<i32>();
+  var res : vec4<f32> = textureSampleGrad(arg_0, arg_1, arg_2, arg_3, arg_4, arg_5);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureSampleGrad/d65515.wgsl b/test/tint/builtins/gen/var/textureSampleGrad/d65515.wgsl
index 5fc0ab2..37b9744 100644
--- a/test/tint/builtins/gen/var/textureSampleGrad/d65515.wgsl
+++ b/test/tint/builtins/gen/var/textureSampleGrad/d65515.wgsl
@@ -29,7 +29,8 @@
   var arg_3 = 1;
   var arg_4 = vec2<f32>();
   var arg_5 = vec2<f32>();
-  var res: vec4<f32> = textureSampleGrad(arg_0, arg_1, arg_2, arg_3, arg_4, arg_5, vec2<i32>());
+  const arg_6 = vec2<i32>();
+  var res: vec4<f32> = textureSampleGrad(arg_0, arg_1, arg_2, arg_3, arg_4, arg_5, arg_6);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureSampleGrad/d65515.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureSampleGrad/d65515.wgsl.expected.wgsl
index 349514e..08dff47 100644
--- a/test/tint/builtins/gen/var/textureSampleGrad/d65515.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureSampleGrad/d65515.wgsl.expected.wgsl
@@ -7,7 +7,8 @@
   var arg_3 = 1;
   var arg_4 = vec2<f32>();
   var arg_5 = vec2<f32>();
-  var res : vec4<f32> = textureSampleGrad(arg_0, arg_1, arg_2, arg_3, arg_4, arg_5, vec2<i32>());
+  const arg_6 = vec2<i32>();
+  var res : vec4<f32> = textureSampleGrad(arg_0, arg_1, arg_2, arg_3, arg_4, arg_5, arg_6);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureSampleLevel/0b0a1b.wgsl b/test/tint/builtins/gen/var/textureSampleLevel/0b0a1b.wgsl
index 3f8f697..2a9a9c7 100644
--- a/test/tint/builtins/gen/var/textureSampleLevel/0b0a1b.wgsl
+++ b/test/tint/builtins/gen/var/textureSampleLevel/0b0a1b.wgsl
@@ -27,7 +27,8 @@
 fn textureSampleLevel_0b0a1b() {
   var arg_2 = vec2<f32>();
   var arg_3 = 1.f;
-  var res: vec4<f32> = textureSampleLevel(arg_0, arg_1, arg_2, arg_3, vec2<i32>());
+  const arg_4 = vec2<i32>();
+  var res: vec4<f32> = textureSampleLevel(arg_0, arg_1, arg_2, arg_3, arg_4);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureSampleLevel/0b0a1b.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureSampleLevel/0b0a1b.wgsl.expected.wgsl
index 751f1b3..cfa94cf 100644
--- a/test/tint/builtins/gen/var/textureSampleLevel/0b0a1b.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureSampleLevel/0b0a1b.wgsl.expected.wgsl
@@ -5,7 +5,8 @@
 fn textureSampleLevel_0b0a1b() {
   var arg_2 = vec2<f32>();
   var arg_3 = 1.0f;
-  var res : vec4<f32> = textureSampleLevel(arg_0, arg_1, arg_2, arg_3, vec2<i32>());
+  const arg_4 = vec2<i32>();
+  var res : vec4<f32> = textureSampleLevel(arg_0, arg_1, arg_2, arg_3, arg_4);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureSampleLevel/36780e.wgsl b/test/tint/builtins/gen/var/textureSampleLevel/36780e.wgsl
index 6e5af0b..f773449 100644
--- a/test/tint/builtins/gen/var/textureSampleLevel/36780e.wgsl
+++ b/test/tint/builtins/gen/var/textureSampleLevel/36780e.wgsl
@@ -28,7 +28,8 @@
   var arg_2 = vec2<f32>();
   var arg_3 = 1;
   var arg_4 = 0;
-  var res: f32 = textureSampleLevel(arg_0, arg_1, arg_2, arg_3, arg_4, vec2<i32>());
+  const arg_5 = vec2<i32>();
+  var res: f32 = textureSampleLevel(arg_0, arg_1, arg_2, arg_3, arg_4, arg_5);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureSampleLevel/36780e.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureSampleLevel/36780e.wgsl.expected.wgsl
index 8ccce18..fa77576 100644
--- a/test/tint/builtins/gen/var/textureSampleLevel/36780e.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureSampleLevel/36780e.wgsl.expected.wgsl
@@ -6,7 +6,8 @@
   var arg_2 = vec2<f32>();
   var arg_3 = 1;
   var arg_4 = 0;
-  var res : f32 = textureSampleLevel(arg_0, arg_1, arg_2, arg_3, arg_4, vec2<i32>());
+  const arg_5 = vec2<i32>();
+  var res : f32 = textureSampleLevel(arg_0, arg_1, arg_2, arg_3, arg_4, arg_5);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureSampleLevel/749baf.wgsl b/test/tint/builtins/gen/var/textureSampleLevel/749baf.wgsl
index 74d2449..f916161 100644
--- a/test/tint/builtins/gen/var/textureSampleLevel/749baf.wgsl
+++ b/test/tint/builtins/gen/var/textureSampleLevel/749baf.wgsl
@@ -27,7 +27,8 @@
 fn textureSampleLevel_749baf() {
   var arg_2 = vec2<f32>();
   var arg_3 = 0;
-  var res: f32 = textureSampleLevel(arg_0, arg_1, arg_2, arg_3, vec2<i32>());
+  const arg_4 = vec2<i32>();
+  var res: f32 = textureSampleLevel(arg_0, arg_1, arg_2, arg_3, arg_4);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureSampleLevel/749baf.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureSampleLevel/749baf.wgsl.expected.wgsl
index 534677f..e3a9f4c 100644
--- a/test/tint/builtins/gen/var/textureSampleLevel/749baf.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureSampleLevel/749baf.wgsl.expected.wgsl
@@ -5,7 +5,8 @@
 fn textureSampleLevel_749baf() {
   var arg_2 = vec2<f32>();
   var arg_3 = 0;
-  var res : f32 = textureSampleLevel(arg_0, arg_1, arg_2, arg_3, vec2<i32>());
+  const arg_4 = vec2<i32>();
+  var res : f32 = textureSampleLevel(arg_0, arg_1, arg_2, arg_3, arg_4);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureSampleLevel/b7c55c.wgsl b/test/tint/builtins/gen/var/textureSampleLevel/b7c55c.wgsl
index 70b7409..c051b44 100644
--- a/test/tint/builtins/gen/var/textureSampleLevel/b7c55c.wgsl
+++ b/test/tint/builtins/gen/var/textureSampleLevel/b7c55c.wgsl
@@ -28,7 +28,8 @@
   var arg_2 = vec2<f32>();
   var arg_3 = 1;
   var arg_4 = 1.f;
-  var res: vec4<f32> = textureSampleLevel(arg_0, arg_1, arg_2, arg_3, arg_4, vec2<i32>());
+  const arg_5 = vec2<i32>();
+  var res: vec4<f32> = textureSampleLevel(arg_0, arg_1, arg_2, arg_3, arg_4, arg_5);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureSampleLevel/b7c55c.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureSampleLevel/b7c55c.wgsl.expected.wgsl
index b03c566..1ada5fe 100644
--- a/test/tint/builtins/gen/var/textureSampleLevel/b7c55c.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureSampleLevel/b7c55c.wgsl.expected.wgsl
@@ -6,7 +6,8 @@
   var arg_2 = vec2<f32>();
   var arg_3 = 1;
   var arg_4 = 1.0f;
-  var res : vec4<f32> = textureSampleLevel(arg_0, arg_1, arg_2, arg_3, arg_4, vec2<i32>());
+  const arg_5 = vec2<i32>();
+  var res : vec4<f32> = textureSampleLevel(arg_0, arg_1, arg_2, arg_3, arg_4, arg_5);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureSampleLevel/dcbecb.wgsl b/test/tint/builtins/gen/var/textureSampleLevel/dcbecb.wgsl
index 68e6ca4..288aa58 100644
--- a/test/tint/builtins/gen/var/textureSampleLevel/dcbecb.wgsl
+++ b/test/tint/builtins/gen/var/textureSampleLevel/dcbecb.wgsl
@@ -27,7 +27,8 @@
 fn textureSampleLevel_dcbecb() {
   var arg_2 = vec3<f32>();
   var arg_3 = 1.f;
-  var res: vec4<f32> = textureSampleLevel(arg_0, arg_1, arg_2, arg_3, vec3<i32>());
+  const arg_4 = vec3<i32>();
+  var res: vec4<f32> = textureSampleLevel(arg_0, arg_1, arg_2, arg_3, arg_4);
 }
 
 @vertex
diff --git a/test/tint/builtins/gen/var/textureSampleLevel/dcbecb.wgsl.expected.wgsl b/test/tint/builtins/gen/var/textureSampleLevel/dcbecb.wgsl.expected.wgsl
index 298cf72..0169878 100644
--- a/test/tint/builtins/gen/var/textureSampleLevel/dcbecb.wgsl.expected.wgsl
+++ b/test/tint/builtins/gen/var/textureSampleLevel/dcbecb.wgsl.expected.wgsl
@@ -5,7 +5,8 @@
 fn textureSampleLevel_dcbecb() {
   var arg_2 = vec3<f32>();
   var arg_3 = 1.0f;
-  var res : vec4<f32> = textureSampleLevel(arg_0, arg_1, arg_2, arg_3, vec3<i32>());
+  const arg_4 = vec3<i32>();
+  var res : vec4<f32> = textureSampleLevel(arg_0, arg_1, arg_2, arg_3, arg_4);
 }
 
 @vertex