[tint][spriv] Fix SampledImage::Equal()

This was not considering the image type, occasionally resulting in sampled images of different types getting merged.
This would only happen when the hash of the sampled image and the pointer of the image type collided.

Change-Id: I7417cb1a7585b1c4f6bd447e97956263c02b4183
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/174360
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
diff --git a/src/tint/cmd/test/BUILD.bazel b/src/tint/cmd/test/BUILD.bazel
index 6fe5481..0eec522 100644
--- a/src/tint/cmd/test/BUILD.bazel
+++ b/src/tint/cmd/test/BUILD.bazel
@@ -56,6 +56,7 @@
     "//src/tint/lang/msl/ir:test",
     "//src/tint/lang/spirv/ir:test",
     "//src/tint/lang/spirv/reader/lower:test",
+    "//src/tint/lang/spirv/type:test",
     "//src/tint/lang/wgsl/ast:test",
     "//src/tint/lang/wgsl/common:test",
     "//src/tint/lang/wgsl/helpers:test",
diff --git a/src/tint/cmd/test/BUILD.cmake b/src/tint/cmd/test/BUILD.cmake
index 35d79f7..4b50533 100644
--- a/src/tint/cmd/test/BUILD.cmake
+++ b/src/tint/cmd/test/BUILD.cmake
@@ -57,6 +57,7 @@
   tint_lang_msl_ir_test
   tint_lang_spirv_ir_test
   tint_lang_spirv_reader_lower_test
+  tint_lang_spirv_type_test
   tint_lang_wgsl_ast_test
   tint_lang_wgsl_common_test
   tint_lang_wgsl_helpers_test
diff --git a/src/tint/cmd/test/BUILD.gn b/src/tint/cmd/test/BUILD.gn
index 2d49bfc..65fd5c2 100644
--- a/src/tint/cmd/test/BUILD.gn
+++ b/src/tint/cmd/test/BUILD.gn
@@ -62,6 +62,7 @@
       "${tint_src_dir}/lang/msl/ir:unittests",
       "${tint_src_dir}/lang/spirv/ir:unittests",
       "${tint_src_dir}/lang/spirv/reader/lower:unittests",
+      "${tint_src_dir}/lang/spirv/type:unittests",
       "${tint_src_dir}/lang/wgsl:unittests",
       "${tint_src_dir}/lang/wgsl/ast:unittests",
       "${tint_src_dir}/lang/wgsl/common:unittests",
diff --git a/src/tint/lang/spirv/type/BUILD.bazel b/src/tint/lang/spirv/type/BUILD.bazel
index 53c59e9..6503b17 100644
--- a/src/tint/lang/spirv/type/BUILD.bazel
+++ b/src/tint/lang/spirv/type/BUILD.bazel
@@ -66,4 +66,31 @@
   copts = COPTS,
   visibility = ["//visibility:public"],
 )
+cc_library(
+  name = "test",
+  alwayslink = True,
+  srcs = [
+    "sampled_image_test.cc",
+  ],
+  deps = [
+    "//src/tint/lang/core",
+    "//src/tint/lang/core/constant",
+    "//src/tint/lang/core/ir",
+    "//src/tint/lang/core/type",
+    "//src/tint/lang/spirv/type",
+    "//src/tint/utils/containers",
+    "//src/tint/utils/diagnostic",
+    "//src/tint/utils/ice",
+    "//src/tint/utils/macros",
+    "//src/tint/utils/math",
+    "//src/tint/utils/memory",
+    "//src/tint/utils/result",
+    "//src/tint/utils/rtti",
+    "//src/tint/utils/text",
+    "//src/tint/utils/traits",
+    "@gtest",
+  ],
+  copts = COPTS,
+  visibility = ["//visibility:public"],
+)
 
diff --git a/src/tint/lang/spirv/type/BUILD.cmake b/src/tint/lang/spirv/type/BUILD.cmake
index 7d21774..ef39fed 100644
--- a/src/tint/lang/spirv/type/BUILD.cmake
+++ b/src/tint/lang/spirv/type/BUILD.cmake
@@ -62,3 +62,33 @@
   tint_utils_text
   tint_utils_traits
 )
+
+################################################################################
+# Target:    tint_lang_spirv_type_test
+# Kind:      test
+################################################################################
+tint_add_target(tint_lang_spirv_type_test test
+  lang/spirv/type/sampled_image_test.cc
+)
+
+tint_target_add_dependencies(tint_lang_spirv_type_test test
+  tint_lang_core
+  tint_lang_core_constant
+  tint_lang_core_ir
+  tint_lang_core_type
+  tint_lang_spirv_type
+  tint_utils_containers
+  tint_utils_diagnostic
+  tint_utils_ice
+  tint_utils_macros
+  tint_utils_math
+  tint_utils_memory
+  tint_utils_result
+  tint_utils_rtti
+  tint_utils_text
+  tint_utils_traits
+)
+
+tint_target_add_external_dependencies(tint_lang_spirv_type_test test
+  "gtest"
+)
diff --git a/src/tint/lang/spirv/type/BUILD.gn b/src/tint/lang/spirv/type/BUILD.gn
index 2834593..345e2db 100644
--- a/src/tint/lang/spirv/type/BUILD.gn
+++ b/src/tint/lang/spirv/type/BUILD.gn
@@ -38,6 +38,10 @@
 
 import("${tint_src_dir}/tint.gni")
 
+if (tint_build_unittests || tint_build_benchmarks) {
+  import("//testing/test.gni")
+}
+
 libtint_source_set("type") {
   sources = [
     "sampled_image.cc",
@@ -63,3 +67,26 @@
     "${tint_src_dir}/utils/traits",
   ]
 }
+if (tint_build_unittests) {
+  tint_unittests_source_set("unittests") {
+    sources = [ "sampled_image_test.cc" ]
+    deps = [
+      "${tint_src_dir}:gmock_and_gtest",
+      "${tint_src_dir}/lang/core",
+      "${tint_src_dir}/lang/core/constant",
+      "${tint_src_dir}/lang/core/ir",
+      "${tint_src_dir}/lang/core/type",
+      "${tint_src_dir}/lang/spirv/type",
+      "${tint_src_dir}/utils/containers",
+      "${tint_src_dir}/utils/diagnostic",
+      "${tint_src_dir}/utils/ice",
+      "${tint_src_dir}/utils/macros",
+      "${tint_src_dir}/utils/math",
+      "${tint_src_dir}/utils/memory",
+      "${tint_src_dir}/utils/result",
+      "${tint_src_dir}/utils/rtti",
+      "${tint_src_dir}/utils/text",
+      "${tint_src_dir}/utils/traits",
+    ]
+  }
+}
diff --git a/src/tint/lang/spirv/type/sampled_image.cc b/src/tint/lang/spirv/type/sampled_image.cc
index 7d09f21..6d4e062 100644
--- a/src/tint/lang/spirv/type/sampled_image.cc
+++ b/src/tint/lang/spirv/type/sampled_image.cc
@@ -38,6 +38,17 @@
            core::type::Flags{}),
       image_(image) {}
 
+bool SampledImage::Equals(const UniqueNode& other) const {
+    if (auto* o = other.As<SampledImage>()) {
+        return o->image_ == image_;
+    }
+    return false;
+}
+
+std::string SampledImage::FriendlyName() const {
+    return "spirv.sampled_image<" + image_->FriendlyName() + ">";
+}
+
 SampledImage* SampledImage::Clone(core::type::CloneContext& ctx) const {
     auto* image = image_->Clone(ctx);
     return ctx.dst.mgr->Get<SampledImage>(image);
diff --git a/src/tint/lang/spirv/type/sampled_image.h b/src/tint/lang/spirv/type/sampled_image.h
index f935b56..b0146df 100644
--- a/src/tint/lang/spirv/type/sampled_image.h
+++ b/src/tint/lang/spirv/type/sampled_image.h
@@ -45,10 +45,10 @@
 
     /// @param other the other node to compare against
     /// @returns true if the this type is equal to @p other
-    bool Equals(const UniqueNode& other) const override { return &other.TypeInfo() == &TypeInfo(); }
+    bool Equals(const UniqueNode& other) const override;
 
     /// @returns the friendly name for this type
-    std::string FriendlyName() const override { return "spirv.sampled_image"; }
+    std::string FriendlyName() const override;
 
     /// @param ctx the clone context
     /// @returns a clone of this type
diff --git a/src/tint/lang/spirv/type/sampled_image_test.cc b/src/tint/lang/spirv/type/sampled_image_test.cc
new file mode 100644
index 0000000..0b12e12
--- /dev/null
+++ b/src/tint/lang/spirv/type/sampled_image_test.cc
@@ -0,0 +1,56 @@
+// Copyright 2024 The Dawn & Tint Authors
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice, this
+//    list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+//    this list of conditions and the following disclaimer in the documentation
+//    and/or other materials provided with the distribution.
+//
+// 3. Neither the name of the copyright holder nor the names of its
+//    contributors may be used to endorse or promote products derived from
+//    this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include "src/tint/lang/spirv/type/sampled_image.h"
+
+#include <gtest/gtest.h>
+
+#include "src/tint/lang/core/type/i32.h"
+#include "src/tint/lang/core/type/u32.h"
+
+namespace tint::spirv::type {
+namespace {
+
+TEST(SampledImageTest, Equals) {
+    core::type::I32 i32;
+    core::type::U32 u32;
+    SampledImage a{&i32};
+    SampledImage b{&i32};
+    SampledImage c{&u32};
+
+    EXPECT_TRUE(a.Equals(b));
+    EXPECT_FALSE(a.Equals(c));
+}
+
+TEST(SampledImageTest, FriendlyName) {
+    core::type::I32 i32;
+    SampledImage s{&i32};
+    EXPECT_EQ(s.FriendlyName(), "spirv.sampled_image<i32>");
+}
+
+}  // namespace
+}  // namespace tint::spirv::type
diff --git a/src/tint/lang/spirv/writer/raise/builtin_polyfill_test.cc b/src/tint/lang/spirv/writer/raise/builtin_polyfill_test.cc
index f4849ee..29b11d0 100644
--- a/src/tint/lang/spirv/writer/raise/builtin_polyfill_test.cc
+++ b/src/tint/lang/spirv/writer/raise/builtin_polyfill_test.cc
@@ -1406,7 +1406,7 @@
     auto* expect = R"(
 %foo = func(%t:texture_1d<f32>, %s:sampler, %coords:f32):vec4<f32> -> %b1 {
   %b1 = block {
-    %5:spirv.sampled_image = spirv.sampled_image %t, %s
+    %5:spirv.sampled_image<texture_1d<f32>> = spirv.sampled_image %t, %s
     %6:vec4<f32> = spirv.image_sample_implicit_lod %5, %coords, 0u
     ret %6
   }
@@ -1444,7 +1444,7 @@
     auto* expect = R"(
 %foo = func(%t:texture_2d<f32>, %s:sampler, %coords:vec2<f32>):vec4<f32> -> %b1 {
   %b1 = block {
-    %5:spirv.sampled_image = spirv.sampled_image %t, %s
+    %5:spirv.sampled_image<texture_2d<f32>> = spirv.sampled_image %t, %s
     %6:vec4<f32> = spirv.image_sample_implicit_lod %5, %coords, 0u
     ret %6
   }
@@ -1483,7 +1483,7 @@
     auto* expect = R"(
 %foo = func(%t:texture_2d<f32>, %s:sampler, %coords:vec2<f32>):vec4<f32> -> %b1 {
   %b1 = block {
-    %5:spirv.sampled_image = spirv.sampled_image %t, %s
+    %5:spirv.sampled_image<texture_2d<f32>> = spirv.sampled_image %t, %s
     %6:vec4<f32> = spirv.image_sample_implicit_lod %5, %coords, 8u, vec2<i32>(1i)
     ret %6
   }
@@ -1523,7 +1523,7 @@
     auto* expect = R"(
 %foo = func(%t:texture_2d_array<f32>, %s:sampler, %coords:vec2<f32>, %array_idx:i32):vec4<f32> -> %b1 {
   %b1 = block {
-    %6:spirv.sampled_image = spirv.sampled_image %t, %s
+    %6:spirv.sampled_image<texture_2d_array<f32>> = spirv.sampled_image %t, %s
     %7:f32 = convert %array_idx
     %8:vec3<f32> = construct %coords, %7
     %9:vec4<f32> = spirv.image_sample_implicit_lod %6, %8, 8u, vec2<i32>(1i)
@@ -1565,7 +1565,7 @@
     auto* expect = R"(
 %foo = func(%t:texture_2d<f32>, %s:sampler, %coords:vec2<f32>, %bias:f32):vec4<f32> -> %b1 {
   %b1 = block {
-    %6:spirv.sampled_image = spirv.sampled_image %t, %s
+    %6:spirv.sampled_image<texture_2d<f32>> = spirv.sampled_image %t, %s
     %7:vec4<f32> = spirv.image_sample_implicit_lod %6, %coords, 1u, %bias
     ret %7
   }
@@ -1605,7 +1605,7 @@
     auto* expect = R"(
 %foo = func(%t:texture_2d<f32>, %s:sampler, %coords:vec2<f32>, %bias:f32):vec4<f32> -> %b1 {
   %b1 = block {
-    %6:spirv.sampled_image = spirv.sampled_image %t, %s
+    %6:spirv.sampled_image<texture_2d<f32>> = spirv.sampled_image %t, %s
     %7:vec4<f32> = spirv.image_sample_implicit_lod %6, %coords, 9u, %bias, vec2<i32>(1i)
     ret %7
   }
@@ -1646,7 +1646,7 @@
     auto* expect = R"(
 %foo = func(%t:texture_2d_array<f32>, %s:sampler, %coords:vec2<f32>, %array_idx:i32, %bias:f32):vec4<f32> -> %b1 {
   %b1 = block {
-    %7:spirv.sampled_image = spirv.sampled_image %t, %s
+    %7:spirv.sampled_image<texture_2d_array<f32>> = spirv.sampled_image %t, %s
     %8:f32 = convert %array_idx
     %9:vec3<f32> = construct %coords, %8
     %10:vec4<f32> = spirv.image_sample_implicit_lod %7, %9, 9u, %bias, vec2<i32>(1i)
@@ -1687,7 +1687,7 @@
     auto* expect = R"(
 %foo = func(%t:texture_depth_2d, %s:sampler_comparison, %coords:vec2<f32>, %dref:f32):f32 -> %b1 {
   %b1 = block {
-    %6:spirv.sampled_image = spirv.sampled_image %t, %s
+    %6:spirv.sampled_image<texture_depth_2d> = spirv.sampled_image %t, %s
     %7:f32 = spirv.image_sample_dref_implicit_lod %6, %coords, %dref, 0u
     ret %7
   }
@@ -1727,7 +1727,7 @@
     auto* expect = R"(
 %foo = func(%t:texture_depth_2d, %s:sampler_comparison, %coords:vec2<f32>, %dref:f32):f32 -> %b1 {
   %b1 = block {
-    %6:spirv.sampled_image = spirv.sampled_image %t, %s
+    %6:spirv.sampled_image<texture_depth_2d> = spirv.sampled_image %t, %s
     %7:f32 = spirv.image_sample_dref_implicit_lod %6, %coords, %dref, 8u, vec2<i32>(1i)
     ret %7
   }
@@ -1768,7 +1768,7 @@
     auto* expect = R"(
 %foo = func(%t:texture_depth_2d_array, %s:sampler_comparison, %coords:vec2<f32>, %array_idx:i32, %bias:f32):f32 -> %b1 {
   %b1 = block {
-    %7:spirv.sampled_image = spirv.sampled_image %t, %s
+    %7:spirv.sampled_image<texture_depth_2d_array> = spirv.sampled_image %t, %s
     %8:f32 = convert %array_idx
     %9:vec3<f32> = construct %coords, %8
     %10:f32 = spirv.image_sample_dref_implicit_lod %7, %9, %bias, 8u, vec2<i32>(1i)
@@ -1810,7 +1810,7 @@
     auto* expect = R"(
 %foo = func(%t:texture_depth_2d, %s:sampler_comparison, %coords:vec2<f32>, %dref:f32):f32 -> %b1 {
   %b1 = block {
-    %6:spirv.sampled_image = spirv.sampled_image %t, %s
+    %6:spirv.sampled_image<texture_depth_2d> = spirv.sampled_image %t, %s
     %7:f32 = spirv.image_sample_dref_explicit_lod %6, %coords, %dref, 2u, 0.0f
     ret %7
   }
@@ -1850,7 +1850,7 @@
     auto* expect = R"(
 %foo = func(%t:texture_depth_2d, %s:sampler_comparison, %coords:vec2<f32>, %dref:f32):f32 -> %b1 {
   %b1 = block {
-    %6:spirv.sampled_image = spirv.sampled_image %t, %s
+    %6:spirv.sampled_image<texture_depth_2d> = spirv.sampled_image %t, %s
     %7:f32 = spirv.image_sample_dref_explicit_lod %6, %coords, %dref, 10u, 0.0f, vec2<i32>(1i)
     ret %7
   }
@@ -1891,7 +1891,7 @@
     auto* expect = R"(
 %foo = func(%t:texture_depth_2d_array, %s:sampler_comparison, %coords:vec2<f32>, %array_idx:i32, %bias:f32):f32 -> %b1 {
   %b1 = block {
-    %7:spirv.sampled_image = spirv.sampled_image %t, %s
+    %7:spirv.sampled_image<texture_depth_2d_array> = spirv.sampled_image %t, %s
     %8:f32 = convert %array_idx
     %9:vec3<f32> = construct %coords, %8
     %10:f32 = spirv.image_sample_dref_explicit_lod %7, %9, %bias, 10u, 0.0f, vec2<i32>(1i)
@@ -1934,7 +1934,7 @@
     auto* expect = R"(
 %foo = func(%t:texture_2d<f32>, %s:sampler, %coords:vec2<f32>, %ddx:vec2<f32>, %ddy:vec2<f32>):vec4<f32> -> %b1 {
   %b1 = block {
-    %7:spirv.sampled_image = spirv.sampled_image %t, %s
+    %7:spirv.sampled_image<texture_2d<f32>> = spirv.sampled_image %t, %s
     %8:vec4<f32> = spirv.image_sample_explicit_lod %7, %coords, 4u, %ddx, %ddy
     ret %8
   }
@@ -1975,7 +1975,7 @@
     auto* expect = R"(
 %foo = func(%t:texture_2d<f32>, %s:sampler, %coords:vec2<f32>, %ddx:vec2<f32>, %ddy:vec2<f32>):vec4<f32> -> %b1 {
   %b1 = block {
-    %7:spirv.sampled_image = spirv.sampled_image %t, %s
+    %7:spirv.sampled_image<texture_2d<f32>> = spirv.sampled_image %t, %s
     %8:vec4<f32> = spirv.image_sample_explicit_lod %7, %coords, 12u, %ddx, %ddy, vec2<i32>(1i)
     ret %8
   }
@@ -2017,7 +2017,7 @@
     auto* expect = R"(
 %foo = func(%t:texture_2d_array<f32>, %s:sampler, %coords:vec2<f32>, %array_idx:i32, %ddx:vec2<f32>, %ddy:vec2<f32>):vec4<f32> -> %b1 {
   %b1 = block {
-    %8:spirv.sampled_image = spirv.sampled_image %t, %s
+    %8:spirv.sampled_image<texture_2d_array<f32>> = spirv.sampled_image %t, %s
     %9:f32 = convert %array_idx
     %10:vec3<f32> = construct %coords, %9
     %11:vec4<f32> = spirv.image_sample_explicit_lod %8, %10, 12u, %ddx, %ddy, vec2<i32>(1i)
@@ -2059,7 +2059,7 @@
     auto* expect = R"(
 %foo = func(%t:texture_2d<f32>, %s:sampler, %coords:vec2<f32>, %lod:f32):vec4<f32> -> %b1 {
   %b1 = block {
-    %6:spirv.sampled_image = spirv.sampled_image %t, %s
+    %6:spirv.sampled_image<texture_2d<f32>> = spirv.sampled_image %t, %s
     %7:vec4<f32> = spirv.image_sample_explicit_lod %6, %coords, 2u, %lod
     ret %7
   }
@@ -2099,7 +2099,7 @@
     auto* expect = R"(
 %foo = func(%t:texture_2d<f32>, %s:sampler, %coords:vec2<f32>, %lod:f32):vec4<f32> -> %b1 {
   %b1 = block {
-    %6:spirv.sampled_image = spirv.sampled_image %t, %s
+    %6:spirv.sampled_image<texture_2d<f32>> = spirv.sampled_image %t, %s
     %7:vec4<f32> = spirv.image_sample_explicit_lod %6, %coords, 10u, %lod, vec2<i32>(1i)
     ret %7
   }
@@ -2140,7 +2140,7 @@
     auto* expect = R"(
 %foo = func(%t:texture_2d_array<f32>, %s:sampler, %coords:vec2<f32>, %array_idx:i32, %lod:f32):vec4<f32> -> %b1 {
   %b1 = block {
-    %7:spirv.sampled_image = spirv.sampled_image %t, %s
+    %7:spirv.sampled_image<texture_2d_array<f32>> = spirv.sampled_image %t, %s
     %8:f32 = convert %array_idx
     %9:vec3<f32> = construct %coords, %8
     %10:vec4<f32> = spirv.image_sample_explicit_lod %7, %9, 10u, %lod, vec2<i32>(1i)
@@ -2182,7 +2182,7 @@
     auto* expect = R"(
 %foo = func(%component:i32, %t:texture_2d<f32>, %s:sampler, %coords:vec2<f32>):vec4<f32> -> %b1 {
   %b1 = block {
-    %6:spirv.sampled_image = spirv.sampled_image %t, %s
+    %6:spirv.sampled_image<texture_2d<f32>> = spirv.sampled_image %t, %s
     %7:vec4<f32> = spirv.image_gather %6, %coords, %component, 0u
     ret %7
   }
@@ -2222,7 +2222,7 @@
     auto* expect = R"(
 %foo = func(%t:texture_2d<f32>, %s:sampler, %component:i32, %coords:vec2<f32>):vec4<f32> -> %b1 {
   %b1 = block {
-    %6:spirv.sampled_image = spirv.sampled_image %t, %s
+    %6:spirv.sampled_image<texture_2d<f32>> = spirv.sampled_image %t, %s
     %7:vec4<f32> = spirv.image_gather %6, %coords, %component, 8u, vec2<i32>(1i)
     ret %7
   }
@@ -2263,7 +2263,7 @@
     auto* expect = R"(
 %foo = func(%t:texture_2d_array<f32>, %s:sampler, %component:i32, %coords:vec2<f32>, %array_idx:i32):vec4<f32> -> %b1 {
   %b1 = block {
-    %7:spirv.sampled_image = spirv.sampled_image %t, %s
+    %7:spirv.sampled_image<texture_2d_array<f32>> = spirv.sampled_image %t, %s
     %8:f32 = convert %array_idx
     %9:vec3<f32> = construct %coords, %8
     %10:vec4<f32> = spirv.image_gather %7, %9, %component, 8u, vec2<i32>(1i)
@@ -2303,7 +2303,7 @@
     auto* expect = R"(
 %foo = func(%t:texture_depth_2d, %s:sampler, %coords:vec2<f32>):vec4<f32> -> %b1 {
   %b1 = block {
-    %5:spirv.sampled_image = spirv.sampled_image %t, %s
+    %5:spirv.sampled_image<texture_depth_2d> = spirv.sampled_image %t, %s
     %6:vec4<f32> = spirv.image_gather %5, %coords, 0u, 0u
     ret %6
   }
@@ -2343,7 +2343,7 @@
     auto* expect = R"(
 %foo = func(%t:texture_depth_2d, %s:sampler_comparison, %coords:vec2<f32>, %depth:f32):vec4<f32> -> %b1 {
   %b1 = block {
-    %6:spirv.sampled_image = spirv.sampled_image %t, %s
+    %6:spirv.sampled_image<texture_depth_2d> = spirv.sampled_image %t, %s
     %7:vec4<f32> = spirv.image_dref_gather %6, %coords, %depth, 0u
     ret %7
   }
@@ -2383,7 +2383,7 @@
     auto* expect = R"(
 %foo = func(%t:texture_depth_2d, %s:sampler_comparison, %coords:vec2<f32>, %depth:f32):vec4<f32> -> %b1 {
   %b1 = block {
-    %6:spirv.sampled_image = spirv.sampled_image %t, %s
+    %6:spirv.sampled_image<texture_depth_2d> = spirv.sampled_image %t, %s
     %7:vec4<f32> = spirv.image_dref_gather %6, %coords, %depth, 8u, vec2<i32>(1i)
     ret %7
   }
@@ -2424,7 +2424,7 @@
     auto* expect = R"(
 %foo = func(%t:texture_depth_2d_array, %s:sampler_comparison, %coords:vec2<f32>, %array_idx:u32, %depth:f32):vec4<f32> -> %b1 {
   %b1 = block {
-    %7:spirv.sampled_image = spirv.sampled_image %t, %s
+    %7:spirv.sampled_image<texture_depth_2d_array> = spirv.sampled_image %t, %s
     %8:f32 = convert %array_idx
     %9:vec3<f32> = construct %coords, %8
     %10:vec4<f32> = spirv.image_dref_gather %7, %9, %depth, 0u