Explorar o código

Switch the prelude to using 'export import'. (#3976)

Note, I assume this doesn't affect all the TODOs (like for i32.carbon),
but does cut some things down (and requires updating some tests that
have prelude name conflicts, but I think they were intended to be
updated this way).
Jon Ross-Perkins hai 1 ano
pai
achega
3561ab5fae
Modificáronse 35 ficheiros con 1358 adicións e 3123 borrados
  1. 2 2
      core/prelude.carbon
  2. 3 4
      core/prelude/operators.carbon
  3. 0 5
      core/prelude/types/i32.carbon
  4. 0 3
      examples/sieve.carbon
  5. 9 9
      toolchain/check/testdata/class/cross_package_import.carbon
  6. 39 41
      toolchain/check/testdata/function/builtin/import.carbon
  7. 40 30
      toolchain/check/testdata/function/builtin/no_prelude/call_from_operator.carbon
  8. 8 8
      toolchain/check/testdata/impl/lookup/import.carbon
  9. 24 8
      toolchain/check/testdata/index/fail_negative_indexing.carbon
  10. 28 15
      toolchain/check/testdata/operators/builtin/fail_type_mismatch_once.carbon
  11. 25 9
      toolchain/check/testdata/operators/builtin/fail_unimplemented_op.carbon
  12. 63 160
      toolchain/check/testdata/operators/overloaded/add.carbon
  13. 0 15
      toolchain/check/testdata/operators/overloaded/binary_op.carbon.tmpl
  14. 63 160
      toolchain/check/testdata/operators/overloaded/bit_and.carbon
  15. 26 80
      toolchain/check/testdata/operators/overloaded/bit_complement.carbon
  16. 63 160
      toolchain/check/testdata/operators/overloaded/bit_or.carbon
  17. 63 160
      toolchain/check/testdata/operators/overloaded/bit_xor.carbon
  18. 21 74
      toolchain/check/testdata/operators/overloaded/dec.carbon
  19. 63 160
      toolchain/check/testdata/operators/overloaded/div.carbon
  20. 114 196
      toolchain/check/testdata/operators/overloaded/eq.carbon
  21. 47 138
      toolchain/check/testdata/operators/overloaded/fail_assign_non_ref.carbon
  22. 49 209
      toolchain/check/testdata/operators/overloaded/fail_no_impl.carbon
  23. 57 154
      toolchain/check/testdata/operators/overloaded/fail_no_impl_for_arg.carbon
  24. 21 74
      toolchain/check/testdata/operators/overloaded/inc.carbon
  25. 63 160
      toolchain/check/testdata/operators/overloaded/left_shift.carbon
  26. 63 160
      toolchain/check/testdata/operators/overloaded/mod.carbon
  27. 63 160
      toolchain/check/testdata/operators/overloaded/mul.carbon
  28. 26 80
      toolchain/check/testdata/operators/overloaded/negate.carbon
  29. 146 271
      toolchain/check/testdata/operators/overloaded/ordered.carbon
  30. 63 160
      toolchain/check/testdata/operators/overloaded/right_shift.carbon
  31. 63 160
      toolchain/check/testdata/operators/overloaded/sub.carbon
  32. 0 12
      toolchain/check/testdata/operators/overloaded/unary_op.carbon.tmpl
  33. 0 12
      toolchain/check/testdata/operators/overloaded/unary_stmt.carbon.tmpl
  34. 8 22
      toolchain/lower/testdata/builtins/overloaded_operator.carbon
  35. 35 52
      toolchain/lower/testdata/operators/overloaded.carbon

+ 2 - 2
core/prelude.carbon

@@ -6,8 +6,8 @@
 
 package Core library "prelude";
 
-import library "prelude/operators";
-import library "prelude/types";
+export import library "prelude/operators";
+export import library "prelude/types";
 
 // TODO: Uncomment once name deduplication works.
 // TODO: These are here for name lookup. Add a way to export import and move them out.

+ 3 - 4
core/prelude/operators.carbon

@@ -4,7 +4,6 @@
 
 package Core library "prelude/operators";
 
-// TODO: Add a mechanism to re-export the names declared here.
-import library "prelude/operators/arithmetic";
-import library "prelude/operators/bitwise";
-import library "prelude/operators/comparison";
+export import library "prelude/operators/arithmetic";
+export import library "prelude/operators/bitwise";
+export import library "prelude/operators/comparison";

+ 0 - 5
core/prelude/types/i32.carbon

@@ -6,11 +6,6 @@ package Core library "prelude/types/i32";
 
 import library "prelude/operators";
 
-// TODO: Remove these once prelude/operators re-exports their contents.
-import library "prelude/operators/arithmetic";
-import library "prelude/operators/bitwise";
-import library "prelude/operators/comparison";
-
 impl i32 as Add {
   fn Op[self: Self](other: Self) -> Self = "int.sadd";
 }

+ 0 - 3
examples/sieve.carbon

@@ -4,9 +4,6 @@
 
 // Compute and return the number of primes less than 1000.
 
-import Core library "prelude/operators/arithmetic";
-import Core library "prelude/operators/comparison";
-
 // TODO: Copied from core/prelude/types/i32.carbon.
 // Because we don't deduplicate interfaces, the implementations in that file are
 // treated as implementing a different interface from the one we import above.

+ 9 - 9
toolchain/check/testdata/class/cross_package_import.carbon

@@ -184,8 +184,8 @@ var c: Other.C = {};
 // CHECK:STDOUT:   %Core: <namespace> = namespace [template] {}
 // CHECK:STDOUT:   %Other: <namespace> = namespace [template] {}
 // CHECK:STDOUT:   %Other.ref: <namespace> = name_ref Other, %Other [template = %Other]
-// CHECK:STDOUT:   %import_ref.1: type = import_ref ir2, inst+2, loaded [template = constants.%C]
-// CHECK:STDOUT:   %import_ref.2 = import_ref ir2, inst+3, unloaded
+// CHECK:STDOUT:   %import_ref.1: type = import_ref ir7, inst+2, loaded [template = constants.%C]
+// CHECK:STDOUT:   %import_ref.2 = import_ref ir7, inst+3, unloaded
 // CHECK:STDOUT:   %C.ref: type = name_ref C, %import_ref.1 [template = constants.%C]
 // CHECK:STDOUT:   %c.var: ref C = var c
 // CHECK:STDOUT:   %c: ref C = bind_name c, %c.var
@@ -221,7 +221,7 @@ var c: Other.C = {};
 // CHECK:STDOUT:   %Core: <namespace> = namespace [template] {}
 // CHECK:STDOUT:   %Other: <namespace> = namespace [template] {}
 // CHECK:STDOUT:   %Other.ref: <namespace> = name_ref Other, %Other [template = %Other]
-// CHECK:STDOUT:   %import_ref: type = import_ref ir2, inst+2, loaded [template = constants.%C]
+// CHECK:STDOUT:   %import_ref: type = import_ref ir7, inst+2, loaded [template = constants.%C]
 // CHECK:STDOUT:   %C.ref: type = name_ref C, %import_ref [template = constants.%C]
 // CHECK:STDOUT:   %c.var: ref <error> = var c
 // CHECK:STDOUT:   %c: ref <error> = bind_name c, %c.var
@@ -255,9 +255,9 @@ var c: Other.C = {};
 // CHECK:STDOUT:   %Core: <namespace> = namespace [template] {}
 // CHECK:STDOUT:   %Other: <namespace> = namespace [template] {}
 // CHECK:STDOUT:   %Other.ref: <namespace> = name_ref Other, %Other [template = %Other]
-// CHECK:STDOUT:   %import_ref.1: type = import_ref ir2, inst+2, loaded [template = constants.%C]
-// CHECK:STDOUT:   %import_ref.2 = import_ref ir2, inst+3, unloaded
-// CHECK:STDOUT:   %import_ref.3 = import_ref ir3, inst+2, unloaded
+// CHECK:STDOUT:   %import_ref.1: type = import_ref ir7, inst+2, loaded [template = constants.%C]
+// CHECK:STDOUT:   %import_ref.2 = import_ref ir7, inst+3, unloaded
+// CHECK:STDOUT:   %import_ref.3 = import_ref ir8, inst+2, unloaded
 // CHECK:STDOUT:   %C.ref: type = name_ref C, %import_ref.1 [template = constants.%C]
 // CHECK:STDOUT:   %c.var: ref C = var c
 // CHECK:STDOUT:   %c: ref C = bind_name c, %c.var
@@ -296,9 +296,9 @@ var c: Other.C = {};
 // CHECK:STDOUT:   %Core: <namespace> = namespace [template] {}
 // CHECK:STDOUT:   %Other: <namespace> = namespace [template] {}
 // CHECK:STDOUT:   %Other.ref: <namespace> = name_ref Other, %Other [template = %Other]
-// CHECK:STDOUT:   %import_ref.1: type = import_ref ir2, inst+2, loaded [template = constants.%C]
-// CHECK:STDOUT:   %import_ref.2 = import_ref ir2, inst+3, unloaded
-// CHECK:STDOUT:   %import_ref.3 = import_ref ir3, inst+2, unloaded
+// CHECK:STDOUT:   %import_ref.1: type = import_ref ir7, inst+2, loaded [template = constants.%C]
+// CHECK:STDOUT:   %import_ref.2 = import_ref ir7, inst+3, unloaded
+// CHECK:STDOUT:   %import_ref.3 = import_ref ir8, inst+2, unloaded
 // CHECK:STDOUT:   %C.ref: type = name_ref C, %import_ref.1 [template = constants.%C]
 // CHECK:STDOUT:   %c.var: ref C = var c
 // CHECK:STDOUT:   %c: ref C = bind_name c, %c.var

+ 39 - 41
toolchain/check/testdata/function/builtin/import.carbon

@@ -6,47 +6,45 @@
 
 // --- core.carbon
 
-package Core;
+package Core library "test";
 
-import library "prelude";
-
-fn Add(a: i32, b: i32) -> i32 = "int.sadd";
+fn TestAdd(a: i32, b: i32) -> i32 = "int.sadd";
 
 // --- use.carbon
 
-import Core;
+import Core library "test";
 
-var arr: [i32; Core.Add(1, 2)] = (1, 2, 3);
+var arr: [i32; Core.TestAdd(1, 2)] = (1, 2, 3);
 
 // CHECK:STDOUT: --- core.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: constants {
-// CHECK:STDOUT:   %Add: type = fn_type @Add [template]
+// CHECK:STDOUT:   %TestAdd: type = fn_type @TestAdd [template]
 // CHECK:STDOUT:   %.1: type = tuple_type () [template]
-// CHECK:STDOUT:   %struct: Add = struct_value () [template]
+// CHECK:STDOUT:   %struct: TestAdd = struct_value () [template]
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
 // CHECK:STDOUT:   package: <namespace> = namespace [template] {
-// CHECK:STDOUT:     .Add = %Add.decl
+// CHECK:STDOUT:     .TestAdd = %TestAdd.decl
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %Add.decl: Add = fn_decl @Add [template = constants.%struct] {
-// CHECK:STDOUT:     %a.loc6_8.1: i32 = param a
-// CHECK:STDOUT:     @Add.%a: i32 = bind_name a, %a.loc6_8.1
-// CHECK:STDOUT:     %b.loc6_16.1: i32 = param b
-// CHECK:STDOUT:     @Add.%b: i32 = bind_name b, %b.loc6_16.1
-// CHECK:STDOUT:     @Add.%return: ref i32 = var <return slot>
+// CHECK:STDOUT:   %TestAdd.decl: TestAdd = fn_decl @TestAdd [template = constants.%struct] {
+// CHECK:STDOUT:     %a.loc4_12.1: i32 = param a
+// CHECK:STDOUT:     @TestAdd.%a: i32 = bind_name a, %a.loc4_12.1
+// CHECK:STDOUT:     %b.loc4_20.1: i32 = param b
+// CHECK:STDOUT:     @TestAdd.%b: i32 = bind_name b, %b.loc4_20.1
+// CHECK:STDOUT:     @TestAdd.%return: ref i32 = var <return slot>
 // CHECK:STDOUT:   }
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: fn @Add(%a: i32, %b: i32) -> i32 = "int.sadd";
+// CHECK:STDOUT: fn @TestAdd(%a: i32, %b: i32) -> i32 = "int.sadd";
 // CHECK:STDOUT:
 // CHECK:STDOUT: --- use.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: constants {
-// CHECK:STDOUT:   %Add: type = fn_type @Add [template]
+// CHECK:STDOUT:   %TestAdd: type = fn_type @TestAdd [template]
 // CHECK:STDOUT:   %.1: type = tuple_type () [template]
-// CHECK:STDOUT:   %struct: Add = struct_value () [template]
+// CHECK:STDOUT:   %struct: TestAdd = struct_value () [template]
 // CHECK:STDOUT:   %.2: i32 = int_literal 1 [template]
 // CHECK:STDOUT:   %.3: i32 = int_literal 2 [template]
 // CHECK:STDOUT:   %.4: i32 = int_literal 3 [template]
@@ -64,36 +62,36 @@ var arr: [i32; Core.Add(1, 2)] = (1, 2, 3);
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %Core: <namespace> = namespace [template] {}
 // CHECK:STDOUT:   %Core.ref: <namespace> = name_ref Core, %Core [template = %Core]
-// CHECK:STDOUT:   %import_ref: Add = import_ref ir2, inst+6, loaded [template = constants.%struct]
-// CHECK:STDOUT:   %Add.ref: Add = name_ref Add, %import_ref [template = constants.%struct]
-// CHECK:STDOUT:   %.loc4_25: i32 = int_literal 1 [template = constants.%.2]
-// CHECK:STDOUT:   %.loc4_28: i32 = int_literal 2 [template = constants.%.3]
-// CHECK:STDOUT:   %int.sadd: init i32 = call %Add.ref(%.loc4_25, %.loc4_28) [template = constants.%.4]
-// CHECK:STDOUT:   %.loc4_30: type = array_type %int.sadd, i32 [template = constants.%.5]
+// CHECK:STDOUT:   %import_ref: TestAdd = import_ref ir2, inst+6, loaded [template = constants.%struct]
+// CHECK:STDOUT:   %TestAdd.ref: TestAdd = name_ref TestAdd, %import_ref [template = constants.%struct]
+// CHECK:STDOUT:   %.loc4_29: i32 = int_literal 1 [template = constants.%.2]
+// CHECK:STDOUT:   %.loc4_32: i32 = int_literal 2 [template = constants.%.3]
+// CHECK:STDOUT:   %int.sadd: init i32 = call %TestAdd.ref(%.loc4_29, %.loc4_32) [template = constants.%.4]
+// CHECK:STDOUT:   %.loc4_34: type = array_type %int.sadd, i32 [template = constants.%.5]
 // CHECK:STDOUT:   %arr.var: ref [i32; 3] = var arr
 // CHECK:STDOUT:   %arr: ref [i32; 3] = bind_name arr, %arr.var
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: fn @Add(%a: i32, %b: i32) -> i32 = "int.sadd";
+// CHECK:STDOUT: fn @TestAdd(%a: i32, %b: i32) -> i32 = "int.sadd";
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @__global_init() {
 // CHECK:STDOUT: !entry:
-// CHECK:STDOUT:   %.loc4_35: i32 = int_literal 1 [template = constants.%.2]
-// CHECK:STDOUT:   %.loc4_38: i32 = int_literal 2 [template = constants.%.3]
-// CHECK:STDOUT:   %.loc4_41: i32 = int_literal 3 [template = constants.%.4]
-// CHECK:STDOUT:   %.loc4_42.1: (i32, i32, i32) = tuple_literal (%.loc4_35, %.loc4_38, %.loc4_41)
-// CHECK:STDOUT:   %.loc4_42.2: i32 = int_literal 0 [template = constants.%.8]
-// CHECK:STDOUT:   %.loc4_42.3: ref i32 = array_index file.%arr.var, %.loc4_42.2
-// CHECK:STDOUT:   %.loc4_42.4: init i32 = initialize_from %.loc4_35 to %.loc4_42.3 [template = constants.%.2]
-// CHECK:STDOUT:   %.loc4_42.5: i32 = int_literal 1 [template = constants.%.2]
-// CHECK:STDOUT:   %.loc4_42.6: ref i32 = array_index file.%arr.var, %.loc4_42.5
-// CHECK:STDOUT:   %.loc4_42.7: init i32 = initialize_from %.loc4_38 to %.loc4_42.6 [template = constants.%.3]
-// CHECK:STDOUT:   %.loc4_42.8: i32 = int_literal 2 [template = constants.%.3]
-// CHECK:STDOUT:   %.loc4_42.9: ref i32 = array_index file.%arr.var, %.loc4_42.8
-// CHECK:STDOUT:   %.loc4_42.10: init i32 = initialize_from %.loc4_41 to %.loc4_42.9 [template = constants.%.4]
-// CHECK:STDOUT:   %.loc4_42.11: init [i32; 3] = array_init (%.loc4_42.4, %.loc4_42.7, %.loc4_42.10) to file.%arr.var [template = constants.%array]
-// CHECK:STDOUT:   %.loc4_43: init [i32; 3] = converted %.loc4_42.1, %.loc4_42.11 [template = constants.%array]
-// CHECK:STDOUT:   assign file.%arr.var, %.loc4_43
+// CHECK:STDOUT:   %.loc4_39: i32 = int_literal 1 [template = constants.%.2]
+// CHECK:STDOUT:   %.loc4_42: i32 = int_literal 2 [template = constants.%.3]
+// CHECK:STDOUT:   %.loc4_45: i32 = int_literal 3 [template = constants.%.4]
+// CHECK:STDOUT:   %.loc4_46.1: (i32, i32, i32) = tuple_literal (%.loc4_39, %.loc4_42, %.loc4_45)
+// CHECK:STDOUT:   %.loc4_46.2: i32 = int_literal 0 [template = constants.%.8]
+// CHECK:STDOUT:   %.loc4_46.3: ref i32 = array_index file.%arr.var, %.loc4_46.2
+// CHECK:STDOUT:   %.loc4_46.4: init i32 = initialize_from %.loc4_39 to %.loc4_46.3 [template = constants.%.2]
+// CHECK:STDOUT:   %.loc4_46.5: i32 = int_literal 1 [template = constants.%.2]
+// CHECK:STDOUT:   %.loc4_46.6: ref i32 = array_index file.%arr.var, %.loc4_46.5
+// CHECK:STDOUT:   %.loc4_46.7: init i32 = initialize_from %.loc4_42 to %.loc4_46.6 [template = constants.%.3]
+// CHECK:STDOUT:   %.loc4_46.8: i32 = int_literal 2 [template = constants.%.3]
+// CHECK:STDOUT:   %.loc4_46.9: ref i32 = array_index file.%arr.var, %.loc4_46.8
+// CHECK:STDOUT:   %.loc4_46.10: init i32 = initialize_from %.loc4_45 to %.loc4_46.9 [template = constants.%.4]
+// CHECK:STDOUT:   %.loc4_46.11: init [i32; 3] = array_init (%.loc4_46.4, %.loc4_46.7, %.loc4_46.10) to file.%arr.var [template = constants.%array]
+// CHECK:STDOUT:   %.loc4_47: init [i32; 3] = converted %.loc4_46.1, %.loc4_46.11 [template = constants.%array]
+// CHECK:STDOUT:   assign file.%arr.var, %.loc4_47
 // CHECK:STDOUT:   return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 40 - 30
toolchain/check/testdata/function/builtin/call_from_operator.carbon → toolchain/check/testdata/function/builtin/no_prelude/call_from_operator.carbon

@@ -8,6 +8,8 @@
 
 package Core;
 
+fn Int32() -> type = "int.make_type_32";
+
 interface Add {
   fn Op[self: Self](other: Self) -> Self;
 }
@@ -27,49 +29,57 @@ var arr: [i32; 1 + 2] = (3, 4, 3 + 4);
 // CHECK:STDOUT: --- core.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: constants {
-// CHECK:STDOUT:   %.1: type = interface_type @Add [template]
+// CHECK:STDOUT:   %Int32: type = fn_type @Int32 [template]
+// CHECK:STDOUT:   %.1: type = tuple_type () [template]
+// CHECK:STDOUT:   %struct.1: Int32 = struct_value () [template]
+// CHECK:STDOUT:   %.2: type = interface_type @Add [template]
 // CHECK:STDOUT:   %Self: Add = bind_symbolic_name Self 0 [symbolic]
 // CHECK:STDOUT:   %Op: type = fn_type @Op [template]
-// CHECK:STDOUT:   %.2: type = tuple_type () [template]
-// CHECK:STDOUT:   %struct: Op = struct_value () [template]
+// CHECK:STDOUT:   %struct.2: Op = struct_value () [template]
 // CHECK:STDOUT:   %.3: type = assoc_entity_type @Add, Op [template]
 // CHECK:STDOUT:   %.4: <associated Op in Add> = assoc_entity element0, @Add.%Op.decl [template]
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
 // CHECK:STDOUT:   package: <namespace> = namespace [template] {
+// CHECK:STDOUT:     .Int32 = %Int32.decl
 // CHECK:STDOUT:     .Add = %Add.decl
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %Add.decl: type = interface_decl @Add [template = constants.%.1] {}
+// CHECK:STDOUT:   %Int32.decl: Int32 = fn_decl @Int32 [template = constants.%struct.1] {
+// CHECK:STDOUT:     @Int32.%return: ref type = var <return slot>
+// CHECK:STDOUT:   }
+// CHECK:STDOUT:   %Add.decl: type = interface_decl @Add [template = constants.%.2] {}
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: interface @Add {
 // CHECK:STDOUT:   %Self: Add = bind_symbolic_name Self 0 [symbolic = constants.%Self]
-// CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op [template = constants.%struct] {
-// CHECK:STDOUT:     %Self.ref.loc5_15: Add = name_ref Self, %Self [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc5_15.1: type = facet_type_access %Self.ref.loc5_15 [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc5_15.2: type = converted %Self.ref.loc5_15, %.loc5_15.1 [symbolic = constants.%Self]
-// CHECK:STDOUT:     %self.loc5_9.1: Self = param self
-// CHECK:STDOUT:     %self.loc5_9.2: Self = bind_name self, %self.loc5_9.1
-// CHECK:STDOUT:     %Self.ref.loc5_28: Add = name_ref Self, %Self [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc5_28.1: type = facet_type_access %Self.ref.loc5_28 [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc5_28.2: type = converted %Self.ref.loc5_28, %.loc5_28.1 [symbolic = constants.%Self]
-// CHECK:STDOUT:     %other.loc5_21.1: Self = param other
-// CHECK:STDOUT:     %other.loc5_21.2: Self = bind_name other, %other.loc5_21.1
-// CHECK:STDOUT:     %Self.ref.loc5_37: Add = name_ref Self, %Self [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc5_37.1: type = facet_type_access %Self.ref.loc5_37 [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc5_37.2: type = converted %Self.ref.loc5_37, %.loc5_37.1 [symbolic = constants.%Self]
+// CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op [template = constants.%struct.2] {
+// CHECK:STDOUT:     %Self.ref.loc7_15: Add = name_ref Self, %Self [symbolic = constants.%Self]
+// CHECK:STDOUT:     %.loc7_15.1: type = facet_type_access %Self.ref.loc7_15 [symbolic = constants.%Self]
+// CHECK:STDOUT:     %.loc7_15.2: type = converted %Self.ref.loc7_15, %.loc7_15.1 [symbolic = constants.%Self]
+// CHECK:STDOUT:     %self.loc7_9.1: Self = param self
+// CHECK:STDOUT:     %self.loc7_9.2: Self = bind_name self, %self.loc7_9.1
+// CHECK:STDOUT:     %Self.ref.loc7_28: Add = name_ref Self, %Self [symbolic = constants.%Self]
+// CHECK:STDOUT:     %.loc7_28.1: type = facet_type_access %Self.ref.loc7_28 [symbolic = constants.%Self]
+// CHECK:STDOUT:     %.loc7_28.2: type = converted %Self.ref.loc7_28, %.loc7_28.1 [symbolic = constants.%Self]
+// CHECK:STDOUT:     %other.loc7_21.1: Self = param other
+// CHECK:STDOUT:     %other.loc7_21.2: Self = bind_name other, %other.loc7_21.1
+// CHECK:STDOUT:     %Self.ref.loc7_37: Add = name_ref Self, %Self [symbolic = constants.%Self]
+// CHECK:STDOUT:     %.loc7_37.1: type = facet_type_access %Self.ref.loc7_37 [symbolic = constants.%Self]
+// CHECK:STDOUT:     %.loc7_37.2: type = converted %Self.ref.loc7_37, %.loc7_37.1 [symbolic = constants.%Self]
 // CHECK:STDOUT:     %return.var: ref Self = var <return slot>
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %.loc5_41: <associated Op in Add> = assoc_entity element0, %Op.decl [template = constants.%.4]
+// CHECK:STDOUT:   %.loc7_41: <associated Op in Add> = assoc_entity element0, %Op.decl [template = constants.%.4]
 // CHECK:STDOUT:
 // CHECK:STDOUT: !members:
 // CHECK:STDOUT:   .Self = %Self
-// CHECK:STDOUT:   .Op = %.loc5_41
+// CHECK:STDOUT:   .Op = %.loc7_41
 // CHECK:STDOUT:   witness = (%Op.decl)
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op[@Add.%self.loc5_9.2: Self](@Add.%other.loc5_21.2: Self) -> Self;
+// CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
+// CHECK:STDOUT:
+// CHECK:STDOUT: fn @Op[@Add.%self.loc7_9.2: Self](@Add.%other.loc7_21.2: Self) -> Self;
 // CHECK:STDOUT:
 // CHECK:STDOUT: --- user.carbon
 // CHECK:STDOUT:
@@ -104,31 +114,31 @@ var arr: [i32; 1 + 2] = (3, 4, 3 + 4);
 // CHECK:STDOUT:     .arr = %arr
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %Core: <namespace> = namespace [template] {}
-// CHECK:STDOUT:   %import_ref.1: type = import_ref ir2, inst+1, loaded [template = constants.%.1]
-// CHECK:STDOUT:   %import_ref.2: <associated Op in Add> = import_ref ir2, inst+24, loaded [template = constants.%.7]
-// CHECK:STDOUT:   %import_ref.3 = import_ref ir2, inst+3, unloaded
-// CHECK:STDOUT:   %import_ref.4: Op = import_ref ir2, inst+19, loaded [template = constants.%struct.2]
+// CHECK:STDOUT:   %import_ref.1: type = import_ref ir1, inst+6, loaded [template = constants.%.1]
+// CHECK:STDOUT:   %import_ref.2 = import_ref ir1, inst+8, unloaded
+// CHECK:STDOUT:   %import_ref.3: <associated Op in Add> = import_ref ir1, inst+28, loaded [template = constants.%.7]
+// CHECK:STDOUT:   %import_ref.4: Op = import_ref ir1, inst+24, loaded [template = constants.%struct.2]
 // CHECK:STDOUT:   impl_decl @impl {
 // CHECK:STDOUT:     %Core.ref: <namespace> = name_ref Core, %Core [template = %Core]
 // CHECK:STDOUT:     %Add.ref: type = name_ref Add, %import_ref.1 [template = constants.%.1]
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %.loc10_16: i32 = int_literal 1 [template = constants.%.4]
 // CHECK:STDOUT:   %.loc10_20: i32 = int_literal 2 [template = constants.%.5]
-// CHECK:STDOUT:   %import_ref.5: type = import_ref ir2, inst+1, loaded [template = constants.%.1]
-// CHECK:STDOUT:   %import_ref.6 = import_ref ir2, inst+19, unloaded
+// CHECK:STDOUT:   %import_ref.5: type = import_ref ir1, inst+6, loaded [template = constants.%.1]
+// CHECK:STDOUT:   %import_ref.6 = import_ref ir1, inst+24, unloaded
 // CHECK:STDOUT:   %.1: Op = interface_witness_access @impl.%.1, element0 [template = constants.%struct.1]
 // CHECK:STDOUT:   %.loc10_18: <bound method> = bound_method %.loc10_16, %.1 [template = constants.%.8]
 // CHECK:STDOUT:   %int.sadd: init i32 = call %.loc10_18(%.loc10_16, %.loc10_20) [template = constants.%.9]
 // CHECK:STDOUT:   %.loc10_21: type = array_type %int.sadd, i32 [template = constants.%.10]
 // CHECK:STDOUT:   %arr.var: ref [i32; 3] = var arr
 // CHECK:STDOUT:   %arr: ref [i32; 3] = bind_name arr, %arr.var
-// CHECK:STDOUT:   %import_ref.7: type = import_ref ir2, inst+1, loaded [template = constants.%.1]
+// CHECK:STDOUT:   %import_ref.7: type = import_ref ir1, inst+6, loaded [template = constants.%.1]
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: interface @Add {
 // CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Op = file.%import_ref.2
-// CHECK:STDOUT:   .Self = file.%import_ref.3
+// CHECK:STDOUT:   .Self = file.%import_ref.2
+// CHECK:STDOUT:   .Op = file.%import_ref.3
 // CHECK:STDOUT:   witness = (file.%import_ref.4)
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 8 - 8
toolchain/check/testdata/impl/lookup/import.carbon

@@ -118,20 +118,20 @@ fn G(c: Impl.C) {
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %Core: <namespace> = namespace [template] {}
 // CHECK:STDOUT:   %Impl: <namespace> = namespace [template] {}
-// CHECK:STDOUT:   %import_ref.1 = import_ref ir2, inst+14, unloaded
-// CHECK:STDOUT:   %import_ref.2: <associated F in HasF> = import_ref ir2, inst+11, loaded [template = constants.%.6]
-// CHECK:STDOUT:   %import_ref.3 = import_ref ir2, inst+4, unloaded
-// CHECK:STDOUT:   %import_ref.4 = import_ref ir2, inst+6, unloaded
-// CHECK:STDOUT:   %import_ref.5: <witness> = import_ref ir2, inst+22, loaded [template = constants.%.7]
-// CHECK:STDOUT:   %import_ref.6: type = import_ref ir2, inst+13, loaded [template = constants.%C]
+// CHECK:STDOUT:   %import_ref.1 = import_ref ir7, inst+14, unloaded
+// CHECK:STDOUT:   %import_ref.2: <associated F in HasF> = import_ref ir7, inst+11, loaded [template = constants.%.6]
+// CHECK:STDOUT:   %import_ref.3 = import_ref ir7, inst+4, unloaded
+// CHECK:STDOUT:   %import_ref.4 = import_ref ir7, inst+6, unloaded
+// CHECK:STDOUT:   %import_ref.5: <witness> = import_ref ir7, inst+22, loaded [template = constants.%.7]
+// CHECK:STDOUT:   %import_ref.6: type = import_ref ir7, inst+13, loaded [template = constants.%C]
 // CHECK:STDOUT:   %G.decl: G = fn_decl @G [template = constants.%struct.1] {
 // CHECK:STDOUT:     %Impl.ref: <namespace> = name_ref Impl, %Impl [template = %Impl]
 // CHECK:STDOUT:     %C.ref: type = name_ref C, %import_ref.6 [template = constants.%C]
 // CHECK:STDOUT:     %c.loc4_6.1: C = param c
 // CHECK:STDOUT:     @G.%c: C = bind_name c, %c.loc4_6.1
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.7: type = import_ref ir2, inst+2, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.8 = import_ref ir2, inst+6, unloaded
+// CHECK:STDOUT:   %import_ref.7: type = import_ref ir7, inst+2, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.8 = import_ref ir7, inst+6, unloaded
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: interface @HasF {

+ 24 - 8
toolchain/check/testdata/index/fail_negative_indexing.carbon

@@ -5,12 +5,7 @@
 // AUTOUPDATE
 
 var a: (i32, i32) = (12, 6);
-// TODO: Only diagnose this once, and make the diagnostic clearer.
-// CHECK:STDERR: fail_negative_indexing.carbon:[[@LINE+7]]:16: ERROR: Name `Negate` not found.
-// CHECK:STDERR: var b: i32 = a[-10];
-// CHECK:STDERR:                ^~~
-// CHECK:STDERR:
-// CHECK:STDERR: fail_negative_indexing.carbon:[[@LINE+3]]:16: ERROR: Semantics TODO: `missing or invalid operator interface, also avoid duplicate diagnostic if prelude is unavailable`.
+// CHECK:STDERR: fail_negative_indexing.carbon:[[@LINE+3]]:16: ERROR: Cannot access member of interface Negate in type i32 that does not implement that interface.
 // CHECK:STDERR: var b: i32 = a[-10];
 // CHECK:STDERR:                ^~~
 var b: i32 = a[-10];
@@ -25,6 +20,13 @@ var b: i32 = a[-10];
 // CHECK:STDOUT:   %.5: i32 = int_literal 6 [template]
 // CHECK:STDOUT:   %tuple: (i32, i32) = tuple_value (%.4, %.5) [template]
 // CHECK:STDOUT:   %.6: i32 = int_literal 10 [template]
+// CHECK:STDOUT:   %.7: type = interface_type @Negate [template]
+// CHECK:STDOUT:   %Self: Negate = bind_symbolic_name Self 0 [symbolic]
+// CHECK:STDOUT:   %Op: type = fn_type @Op [template]
+// CHECK:STDOUT:   %.8: type = tuple_type () [template]
+// CHECK:STDOUT:   %struct: Op = struct_value () [template]
+// CHECK:STDOUT:   %.9: type = assoc_entity_type @Negate, Op [template]
+// CHECK:STDOUT:   %.10: <associated Op in Negate> = assoc_entity element0, file.%import_ref.5 [template]
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
@@ -40,8 +42,22 @@ var b: i32 = a[-10];
 // CHECK:STDOUT:   %a: ref (i32, i32) = bind_name a, %a.var
 // CHECK:STDOUT:   %b.var: ref i32 = var b
 // CHECK:STDOUT:   %b: ref i32 = bind_name b, %b.var
+// CHECK:STDOUT:   %import_ref.1: type = import_ref ir4, inst+67, loaded [template = constants.%.7]
+// CHECK:STDOUT:   %import_ref.2 = import_ref ir4, inst+69, unloaded
+// CHECK:STDOUT:   %import_ref.3: <associated Op in Negate> = import_ref ir4, inst+84, loaded [template = constants.%.10]
+// CHECK:STDOUT:   %import_ref.4 = import_ref ir4, inst+80, unloaded
+// CHECK:STDOUT:   %import_ref.5 = import_ref ir4, inst+80, unloaded
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
+// CHECK:STDOUT: interface @Negate {
+// CHECK:STDOUT: !members:
+// CHECK:STDOUT:   .Self = file.%import_ref.2
+// CHECK:STDOUT:   .Op = file.%import_ref.3
+// CHECK:STDOUT:   witness = (file.%import_ref.4)
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: fn @Op[%self: Self]() -> Self;
+// CHECK:STDOUT:
 // CHECK:STDOUT: fn @__global_init() {
 // CHECK:STDOUT: !entry:
 // CHECK:STDOUT:   %.loc7_22: i32 = int_literal 12 [template = constants.%.4]
@@ -55,8 +71,8 @@ var b: i32 = a[-10];
 // CHECK:STDOUT:   %.loc7_28: init (i32, i32) = converted %.loc7_27.1, %.loc7_27.6 [template = constants.%tuple]
 // CHECK:STDOUT:   assign file.%a.var, %.loc7_28
 // CHECK:STDOUT:   %a.ref: ref (i32, i32) = name_ref a, file.%a
-// CHECK:STDOUT:   %.loc16_17: i32 = int_literal 10 [template = constants.%.6]
-// CHECK:STDOUT:   %.loc16_19: ref <error> = tuple_index %a.ref, <error>
+// CHECK:STDOUT:   %.loc11_17: i32 = int_literal 10 [template = constants.%.6]
+// CHECK:STDOUT:   %.loc11_19: ref <error> = tuple_index %a.ref, <error>
 // CHECK:STDOUT:   assign file.%b.var, <error>
 // CHECK:STDOUT:   return
 // CHECK:STDOUT: }

+ 28 - 15
toolchain/check/testdata/operators/builtin/fail_type_mismatch_once.carbon

@@ -7,19 +7,11 @@
 fn Main() -> i32 {
   // The following line has two mismatches, but after the first, it shouldn't
   // keep erroring.
-  // CHECK:STDERR: fail_type_mismatch_once.carbon:[[@LINE+15]]:10: ERROR: Name `Add` not found.
+  // CHECK:STDERR: fail_type_mismatch_once.carbon:[[@LINE+7]]:10: ERROR: Cannot access member of interface Add in type i32 that does not implement that interface.
   // CHECK:STDERR:   return 12 + 3.4 + 12;
   // CHECK:STDERR:          ^~~~~~~~
   // CHECK:STDERR:
-  // CHECK:STDERR: fail_type_mismatch_once.carbon:[[@LINE+11]]:10: ERROR: Semantics TODO: `missing or invalid operator interface`.
-  // CHECK:STDERR:   return 12 + 3.4 + 12;
-  // CHECK:STDERR:          ^~~~~~~~
-  // CHECK:STDERR:
-  // CHECK:STDERR: fail_type_mismatch_once.carbon:[[@LINE+7]]:10: ERROR: Name `Add` not found.
-  // CHECK:STDERR:   return 12 + 3.4 + 12;
-  // CHECK:STDERR:          ^~~~~~~~~~~~~
-  // CHECK:STDERR:
-  // CHECK:STDERR: fail_type_mismatch_once.carbon:[[@LINE+3]]:10: ERROR: Semantics TODO: `missing or invalid operator interface`.
+  // CHECK:STDERR: fail_type_mismatch_once.carbon:[[@LINE+3]]:10: ERROR: Cannot access member of interface Add in type <error> that does not implement that interface.
   // CHECK:STDERR:   return 12 + 3.4 + 12;
   // CHECK:STDERR:          ^~~~~~~~~~~~~
   return 12 + 3.4 + 12;
@@ -30,9 +22,15 @@ fn Main() -> i32 {
 // CHECK:STDOUT: constants {
 // CHECK:STDOUT:   %Main: type = fn_type @Main [template]
 // CHECK:STDOUT:   %.1: type = tuple_type () [template]
-// CHECK:STDOUT:   %struct: Main = struct_value () [template]
+// CHECK:STDOUT:   %struct.1: Main = struct_value () [template]
 // CHECK:STDOUT:   %.2: i32 = int_literal 12 [template]
 // CHECK:STDOUT:   %.3: f64 = float_literal 3.4000000000000004 [template]
+// CHECK:STDOUT:   %.4: type = interface_type @Add [template]
+// CHECK:STDOUT:   %Self: Add = bind_symbolic_name Self 0 [symbolic]
+// CHECK:STDOUT:   %Op: type = fn_type @Op [template]
+// CHECK:STDOUT:   %struct.2: Op = struct_value () [template]
+// CHECK:STDOUT:   %.5: type = assoc_entity_type @Add, Op [template]
+// CHECK:STDOUT:   %.6: <associated Op in Add> = assoc_entity element0, file.%import_ref.5 [template]
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
@@ -41,16 +39,31 @@ fn Main() -> i32 {
 // CHECK:STDOUT:     .Main = %Main.decl
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %Core: <namespace> = namespace [template] {}
-// CHECK:STDOUT:   %Main.decl: Main = fn_decl @Main [template = constants.%struct] {
+// CHECK:STDOUT:   %Main.decl: Main = fn_decl @Main [template = constants.%struct.1] {
 // CHECK:STDOUT:     @Main.%return: ref i32 = var <return slot>
 // CHECK:STDOUT:   }
+// CHECK:STDOUT:   %import_ref.1: type = import_ref ir4, inst+1, loaded [template = constants.%.4]
+// CHECK:STDOUT:   %import_ref.2 = import_ref ir4, inst+3, unloaded
+// CHECK:STDOUT:   %import_ref.3: <associated Op in Add> = import_ref ir4, inst+24, loaded [template = constants.%.6]
+// CHECK:STDOUT:   %import_ref.4 = import_ref ir4, inst+19, unloaded
+// CHECK:STDOUT:   %import_ref.5 = import_ref ir4, inst+19, unloaded
+// CHECK:STDOUT:   %import_ref.6: type = import_ref ir4, inst+1, loaded [template = constants.%.4]
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: interface @Add {
+// CHECK:STDOUT: !members:
+// CHECK:STDOUT:   .Self = file.%import_ref.2
+// CHECK:STDOUT:   .Op = file.%import_ref.3
+// CHECK:STDOUT:   witness = (file.%import_ref.4)
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @Main() -> i32 {
 // CHECK:STDOUT: !entry:
-// CHECK:STDOUT:   %.loc25_10: i32 = int_literal 12 [template = constants.%.2]
-// CHECK:STDOUT:   %.loc25_15: f64 = float_literal 3.4000000000000004 [template = constants.%.3]
-// CHECK:STDOUT:   %.loc25_21: i32 = int_literal 12 [template = constants.%.2]
+// CHECK:STDOUT:   %.loc17_10: i32 = int_literal 12 [template = constants.%.2]
+// CHECK:STDOUT:   %.loc17_15: f64 = float_literal 3.4000000000000004 [template = constants.%.3]
+// CHECK:STDOUT:   %.loc17_21: i32 = int_literal 12 [template = constants.%.2]
 // CHECK:STDOUT:   return <error>
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
+// CHECK:STDOUT: fn @Op[%self: Self](%other: Self) -> Self;
+// CHECK:STDOUT:

+ 25 - 9
toolchain/check/testdata/operators/builtin/fail_unimplemented_op.carbon

@@ -5,11 +5,7 @@
 // AUTOUPDATE
 
 fn Main() -> i32 {
-  // CHECK:STDERR: fail_unimplemented_op.carbon:[[@LINE+7]]:10: ERROR: Name `Add` not found.
-  // CHECK:STDERR:   return 12 + 34;
-  // CHECK:STDERR:          ^~~~~~~
-  // CHECK:STDERR:
-  // CHECK:STDERR: fail_unimplemented_op.carbon:[[@LINE+3]]:10: ERROR: Semantics TODO: `missing or invalid operator interface`.
+  // CHECK:STDERR: fail_unimplemented_op.carbon:[[@LINE+3]]:10: ERROR: Cannot access member of interface Add in type i32 that does not implement that interface.
   // CHECK:STDERR:   return 12 + 34;
   // CHECK:STDERR:          ^~~~~~~
   return 12 + 34;
@@ -20,9 +16,15 @@ fn Main() -> i32 {
 // CHECK:STDOUT: constants {
 // CHECK:STDOUT:   %Main: type = fn_type @Main [template]
 // CHECK:STDOUT:   %.1: type = tuple_type () [template]
-// CHECK:STDOUT:   %struct: Main = struct_value () [template]
+// CHECK:STDOUT:   %struct.1: Main = struct_value () [template]
 // CHECK:STDOUT:   %.2: i32 = int_literal 12 [template]
 // CHECK:STDOUT:   %.3: i32 = int_literal 34 [template]
+// CHECK:STDOUT:   %.4: type = interface_type @Add [template]
+// CHECK:STDOUT:   %Self: Add = bind_symbolic_name Self 0 [symbolic]
+// CHECK:STDOUT:   %Op: type = fn_type @Op [template]
+// CHECK:STDOUT:   %struct.2: Op = struct_value () [template]
+// CHECK:STDOUT:   %.5: type = assoc_entity_type @Add, Op [template]
+// CHECK:STDOUT:   %.6: <associated Op in Add> = assoc_entity element0, file.%import_ref.5 [template]
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: file {
@@ -31,15 +33,29 @@ fn Main() -> i32 {
 // CHECK:STDOUT:     .Main = %Main.decl
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %Core: <namespace> = namespace [template] {}
-// CHECK:STDOUT:   %Main.decl: Main = fn_decl @Main [template = constants.%struct] {
+// CHECK:STDOUT:   %Main.decl: Main = fn_decl @Main [template = constants.%struct.1] {
 // CHECK:STDOUT:     @Main.%return: ref i32 = var <return slot>
 // CHECK:STDOUT:   }
+// CHECK:STDOUT:   %import_ref.1: type = import_ref ir4, inst+1, loaded [template = constants.%.4]
+// CHECK:STDOUT:   %import_ref.2 = import_ref ir4, inst+3, unloaded
+// CHECK:STDOUT:   %import_ref.3: <associated Op in Add> = import_ref ir4, inst+24, loaded [template = constants.%.6]
+// CHECK:STDOUT:   %import_ref.4 = import_ref ir4, inst+19, unloaded
+// CHECK:STDOUT:   %import_ref.5 = import_ref ir4, inst+19, unloaded
+// CHECK:STDOUT: }
+// CHECK:STDOUT:
+// CHECK:STDOUT: interface @Add {
+// CHECK:STDOUT: !members:
+// CHECK:STDOUT:   .Self = file.%import_ref.2
+// CHECK:STDOUT:   .Op = file.%import_ref.3
+// CHECK:STDOUT:   witness = (file.%import_ref.4)
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @Main() -> i32 {
 // CHECK:STDOUT: !entry:
-// CHECK:STDOUT:   %.loc15_10: i32 = int_literal 12 [template = constants.%.2]
-// CHECK:STDOUT:   %.loc15_15: i32 = int_literal 34 [template = constants.%.3]
+// CHECK:STDOUT:   %.loc11_10: i32 = int_literal 12 [template = constants.%.2]
+// CHECK:STDOUT:   %.loc11_15: i32 = int_literal 34 [template = constants.%.3]
 // CHECK:STDOUT:   return <error>
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
+// CHECK:STDOUT: fn @Op[%self: Self](%other: Self) -> Self;
+// CHECK:STDOUT:

+ 63 - 160
toolchain/check/testdata/operators/overloaded/add.carbon

@@ -6,23 +6,8 @@
 
 // This file was generated from binary_op.carbon.tmpl. Run make_tests.sh to regenerate.
 
-// --- prelude.carbon
-
-package Core;
-
-interface Add {
-  fn Op[self: Self](other: Self) -> Self;
-}
-interface AddAssign {
-  fn Op[addr self: Self*](other: Self);
-}
-
-// --- user.carbon
-
 package User;
 
-import Core;
-
 class C {};
 
 impl C as Core.Add {
@@ -42,89 +27,7 @@ fn TestAssign(a: C*, b: C) {
   *a += b;
 }
 
-// CHECK:STDOUT: --- prelude.carbon
-// CHECK:STDOUT:
-// CHECK:STDOUT: constants {
-// CHECK:STDOUT:   %.1: type = interface_type @Add [template]
-// CHECK:STDOUT:   %Self.1: Add = bind_symbolic_name Self 0 [symbolic]
-// CHECK:STDOUT:   %Op.1: type = fn_type @Op.1 [template]
-// CHECK:STDOUT:   %.2: type = tuple_type () [template]
-// CHECK:STDOUT:   %struct.1: Op = struct_value () [template]
-// CHECK:STDOUT:   %.3: type = assoc_entity_type @Add, Op [template]
-// CHECK:STDOUT:   %.4: <associated Op in Add> = assoc_entity element0, @Add.%Op.decl [template]
-// CHECK:STDOUT:   %.5: type = interface_type @AddAssign [template]
-// CHECK:STDOUT:   %Self.2: AddAssign = bind_symbolic_name Self 0 [symbolic]
-// CHECK:STDOUT:   %.6: type = ptr_type Self [symbolic]
-// CHECK:STDOUT:   %Op.2: type = fn_type @Op.2 [template]
-// CHECK:STDOUT:   %struct.2: Op = struct_value () [template]
-// CHECK:STDOUT:   %.7: type = assoc_entity_type @AddAssign, Op [template]
-// CHECK:STDOUT:   %.8: <associated Op in AddAssign> = assoc_entity element0, @AddAssign.%Op.decl [template]
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace [template] {
-// CHECK:STDOUT:     .Add = %Add.decl
-// CHECK:STDOUT:     .AddAssign = %AddAssign.decl
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %Add.decl: type = interface_decl @Add [template = constants.%.1] {}
-// CHECK:STDOUT:   %AddAssign.decl: type = interface_decl @AddAssign [template = constants.%.5] {}
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: interface @Add {
-// CHECK:STDOUT:   %Self: Add = bind_symbolic_name Self 0 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.1 [template = constants.%struct.1] {
-// CHECK:STDOUT:     %Self.ref.loc5_15: Add = name_ref Self, %Self [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_15.1: type = facet_type_access %Self.ref.loc5_15 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_15.2: type = converted %Self.ref.loc5_15, %.loc5_15.1 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %self.loc5_9.1: Self = param self
-// CHECK:STDOUT:     %self.loc5_9.2: Self = bind_name self, %self.loc5_9.1
-// CHECK:STDOUT:     %Self.ref.loc5_28: Add = name_ref Self, %Self [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_28.1: type = facet_type_access %Self.ref.loc5_28 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_28.2: type = converted %Self.ref.loc5_28, %.loc5_28.1 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %other.loc5_21.1: Self = param other
-// CHECK:STDOUT:     %other.loc5_21.2: Self = bind_name other, %other.loc5_21.1
-// CHECK:STDOUT:     %Self.ref.loc5_37: Add = name_ref Self, %Self [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_37.1: type = facet_type_access %Self.ref.loc5_37 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_37.2: type = converted %Self.ref.loc5_37, %.loc5_37.1 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %return.var: ref Self = var <return slot>
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %.loc5_41: <associated Op in Add> = assoc_entity element0, %Op.decl [template = constants.%.4]
-// CHECK:STDOUT:
-// CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Self = %Self
-// CHECK:STDOUT:   .Op = %.loc5_41
-// CHECK:STDOUT:   witness = (%Op.decl)
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: interface @AddAssign {
-// CHECK:STDOUT:   %Self: AddAssign = bind_symbolic_name Self 0 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.2 [template = constants.%struct.2] {
-// CHECK:STDOUT:     %Self.ref.loc8_20: AddAssign = name_ref Self, %Self [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_24.1: type = facet_type_access %Self.ref.loc8_20 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_24.2: type = converted %Self.ref.loc8_20, %.loc8_24.1 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_24.3: type = ptr_type Self [symbolic = constants.%.6]
-// CHECK:STDOUT:     %self.loc8_14.1: Self* = param self
-// CHECK:STDOUT:     %self.loc8_14.3: Self* = bind_name self, %self.loc8_14.1
-// CHECK:STDOUT:     %.loc8_9: Self* = addr_pattern %self.loc8_14.3
-// CHECK:STDOUT:     %Self.ref.loc8_34: AddAssign = name_ref Self, %Self [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_34.1: type = facet_type_access %Self.ref.loc8_34 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_34.2: type = converted %Self.ref.loc8_34, %.loc8_34.1 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %other.loc8_27.1: Self = param other
-// CHECK:STDOUT:     %other.loc8_27.2: Self = bind_name other, %other.loc8_27.1
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %.loc8_39: <associated Op in AddAssign> = assoc_entity element0, %Op.decl [template = constants.%.8]
-// CHECK:STDOUT:
-// CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Self = %Self
-// CHECK:STDOUT:   .Op = %.loc8_39
-// CHECK:STDOUT:   witness = (%Op.decl)
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.1[@Add.%self.loc5_9.2: Self](@Add.%other.loc5_21.2: Self) -> Self;
-// CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.2[addr @AddAssign.%self.loc8_14.3: Self*](@AddAssign.%other.loc8_27.2: Self);
-// CHECK:STDOUT:
-// CHECK:STDOUT: --- user.carbon
+// CHECK:STDOUT: --- add.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: constants {
 // CHECK:STDOUT:   %C: type = class_type @C [template]
@@ -167,72 +70,72 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %Core: <namespace> = namespace [template] {}
 // CHECK:STDOUT:   %C.decl: type = class_decl @C [template = constants.%C] {}
-// CHECK:STDOUT:   %import_ref.1: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.2: <associated Op in Add> = import_ref ir2, inst+24, loaded [template = constants.%.11]
-// CHECK:STDOUT:   %import_ref.3 = import_ref ir2, inst+3, unloaded
-// CHECK:STDOUT:   %import_ref.4: Op = import_ref ir2, inst+19, loaded [template = constants.%struct.2]
+// CHECK:STDOUT:   %import_ref.1: type = import_ref ir4, inst+1, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.2 = import_ref ir4, inst+3, unloaded
+// CHECK:STDOUT:   %import_ref.3: <associated Op in Add> = import_ref ir4, inst+24, loaded [template = constants.%.11]
+// CHECK:STDOUT:   %import_ref.4: Op = import_ref ir4, inst+19, loaded [template = constants.%struct.2]
 // CHECK:STDOUT:   impl_decl @impl.1 {
-// CHECK:STDOUT:     %C.ref.loc8: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %Core.ref.loc8: <namespace> = name_ref Core, %Core [template = %Core]
+// CHECK:STDOUT:     %C.ref.loc13: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %Core.ref.loc13: <namespace> = name_ref Core, %Core [template = %Core]
 // CHECK:STDOUT:     %Add.ref: type = name_ref Add, %import_ref.1 [template = constants.%.2]
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.5: type = import_ref ir2, inst+26, loaded [template = constants.%.6]
-// CHECK:STDOUT:   %import_ref.6: <associated Op in AddAssign> = import_ref ir2, inst+47, loaded [template = constants.%.13]
-// CHECK:STDOUT:   %import_ref.7 = import_ref ir2, inst+28, unloaded
-// CHECK:STDOUT:   %import_ref.8: Op = import_ref ir2, inst+43, loaded [template = constants.%struct.5]
+// CHECK:STDOUT:   %import_ref.5: type = import_ref ir4, inst+26, loaded [template = constants.%.6]
+// CHECK:STDOUT:   %import_ref.6 = import_ref ir4, inst+28, unloaded
+// CHECK:STDOUT:   %import_ref.7: <associated Op in AddAssign> = import_ref ir4, inst+47, loaded [template = constants.%.13]
+// CHECK:STDOUT:   %import_ref.8: Op = import_ref ir4, inst+43, loaded [template = constants.%struct.5]
 // CHECK:STDOUT:   impl_decl @impl.2 {
-// CHECK:STDOUT:     %C.ref.loc13: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %Core.ref.loc13: <namespace> = name_ref Core, %Core [template = %Core]
+// CHECK:STDOUT:     %C.ref.loc18: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %Core.ref.loc18: <namespace> = name_ref Core, %Core [template = %Core]
 // CHECK:STDOUT:     %AddAssign.ref: type = name_ref AddAssign, %import_ref.5 [template = constants.%.6]
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %TestOp.decl: TestOp = fn_decl @TestOp [template = constants.%struct.6] {
-// CHECK:STDOUT:     %C.ref.loc17_14: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %a.loc17_11.1: C = param a
-// CHECK:STDOUT:     @TestOp.%a: C = bind_name a, %a.loc17_11.1
-// CHECK:STDOUT:     %C.ref.loc17_20: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %b.loc17_17.1: C = param b
-// CHECK:STDOUT:     @TestOp.%b: C = bind_name b, %b.loc17_17.1
-// CHECK:STDOUT:     %C.ref.loc17_26: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %C.ref.loc22_14: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %a.loc22_11.1: C = param a
+// CHECK:STDOUT:     @TestOp.%a: C = bind_name a, %a.loc22_11.1
+// CHECK:STDOUT:     %C.ref.loc22_20: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %b.loc22_17.1: C = param b
+// CHECK:STDOUT:     @TestOp.%b: C = bind_name b, %b.loc22_17.1
+// CHECK:STDOUT:     %C.ref.loc22_26: type = name_ref C, %C.decl [template = constants.%C]
 // CHECK:STDOUT:     @TestOp.%return: ref C = var <return slot>
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.9: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.10 = import_ref ir2, inst+19, unloaded
+// CHECK:STDOUT:   %import_ref.9: type = import_ref ir4, inst+1, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.10 = import_ref ir4, inst+19, unloaded
 // CHECK:STDOUT:   %TestAssign.decl: TestAssign = fn_decl @TestAssign [template = constants.%struct.7] {
-// CHECK:STDOUT:     %C.ref.loc21_18: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %.loc21: type = ptr_type C [template = constants.%.7]
-// CHECK:STDOUT:     %a.loc21_15.1: C* = param a
-// CHECK:STDOUT:     @TestAssign.%a: C* = bind_name a, %a.loc21_15.1
-// CHECK:STDOUT:     %C.ref.loc21_25: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %b.loc21_22.1: C = param b
-// CHECK:STDOUT:     @TestAssign.%b: C = bind_name b, %b.loc21_22.1
+// CHECK:STDOUT:     %C.ref.loc26_18: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %.loc26: type = ptr_type C [template = constants.%.7]
+// CHECK:STDOUT:     %a.loc26_15.1: C* = param a
+// CHECK:STDOUT:     @TestAssign.%a: C* = bind_name a, %a.loc26_15.1
+// CHECK:STDOUT:     %C.ref.loc26_25: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %b.loc26_22.1: C = param b
+// CHECK:STDOUT:     @TestAssign.%b: C = bind_name b, %b.loc26_22.1
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.11: type = import_ref ir2, inst+26, loaded [template = constants.%.6]
-// CHECK:STDOUT:   %import_ref.12 = import_ref ir2, inst+43, unloaded
+// CHECK:STDOUT:   %import_ref.11: type = import_ref ir4, inst+26, loaded [template = constants.%.6]
+// CHECK:STDOUT:   %import_ref.12 = import_ref ir4, inst+43, unloaded
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: interface @Add {
 // CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Op = file.%import_ref.2
-// CHECK:STDOUT:   .Self = file.%import_ref.3
+// CHECK:STDOUT:   .Self = file.%import_ref.2
+// CHECK:STDOUT:   .Op = file.%import_ref.3
 // CHECK:STDOUT:   witness = (file.%import_ref.4)
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: interface @AddAssign {
 // CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Op = file.%import_ref.6
-// CHECK:STDOUT:   .Self = file.%import_ref.7
+// CHECK:STDOUT:   .Self = file.%import_ref.6
+// CHECK:STDOUT:   .Op = file.%import_ref.7
 // CHECK:STDOUT:   witness = (file.%import_ref.8)
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: impl @impl.1: C as Add {
 // CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.1 [template = constants.%struct.1] {
-// CHECK:STDOUT:     %C.ref.loc9_15: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %self.loc9_9.1: C = param self
-// CHECK:STDOUT:     %self.loc9_9.2: C = bind_name self, %self.loc9_9.1
-// CHECK:STDOUT:     %C.ref.loc9_25: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %other.loc9_18.1: C = param other
-// CHECK:STDOUT:     %other.loc9_18.2: C = bind_name other, %other.loc9_18.1
-// CHECK:STDOUT:     %C.ref.loc9_31: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %C.ref.loc14_15: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %self.loc14_9.1: C = param self
+// CHECK:STDOUT:     %self.loc14_9.2: C = bind_name self, %self.loc14_9.1
+// CHECK:STDOUT:     %C.ref.loc14_25: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %other.loc14_18.1: C = param other
+// CHECK:STDOUT:     %other.loc14_18.2: C = bind_name other, %other.loc14_18.1
+// CHECK:STDOUT:     %C.ref.loc14_31: type = name_ref C, file.%C.decl [template = constants.%C]
 // CHECK:STDOUT:     %return.var: ref C = var <return slot>
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %.1: <witness> = interface_witness (%Op.decl) [template = constants.%.4]
@@ -244,14 +147,14 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:
 // CHECK:STDOUT: impl @impl.2: C as AddAssign {
 // CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.3 [template = constants.%struct.4] {
-// CHECK:STDOUT:     %C.ref.loc14_20: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %.loc14_21: type = ptr_type C [template = constants.%.7]
-// CHECK:STDOUT:     %self.loc14_14.1: C* = param self
-// CHECK:STDOUT:     %self.loc14_14.3: C* = bind_name self, %self.loc14_14.1
-// CHECK:STDOUT:     %.loc14_9: C* = addr_pattern %self.loc14_14.3
-// CHECK:STDOUT:     %C.ref.loc14_31: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %other.loc14_24.1: C = param other
-// CHECK:STDOUT:     %other.loc14_24.2: C = bind_name other, %other.loc14_24.1
+// CHECK:STDOUT:     %C.ref.loc19_20: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %.loc19_21: type = ptr_type C [template = constants.%.7]
+// CHECK:STDOUT:     %self.loc19_14.1: C* = param self
+// CHECK:STDOUT:     %self.loc19_14.3: C* = bind_name self, %self.loc19_14.1
+// CHECK:STDOUT:     %.loc19_9: C* = addr_pattern %self.loc19_14.3
+// CHECK:STDOUT:     %C.ref.loc19_31: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %other.loc19_24.1: C = param other
+// CHECK:STDOUT:     %other.loc19_24.2: C = bind_name other, %other.loc19_24.1
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %.1: <witness> = interface_witness (%Op.decl) [template = constants.%.9]
 // CHECK:STDOUT:
@@ -265,17 +168,17 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:   .Self = constants.%C
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.1[@impl.1.%self.loc9_9.2: C](@impl.1.%other.loc9_18.2: C) -> @impl.1.%return.var: C {
+// CHECK:STDOUT: fn @Op.1[@impl.1.%self.loc14_9.2: C](@impl.1.%other.loc14_18.2: C) -> @impl.1.%return.var: C {
 // CHECK:STDOUT: !entry:
-// CHECK:STDOUT:   %.loc10_13.1: {} = struct_literal ()
-// CHECK:STDOUT:   %.loc10_13.2: init C = class_init (), @impl.1.%return.var [template = constants.%struct.3]
-// CHECK:STDOUT:   %.loc10_14: init C = converted %.loc10_13.1, %.loc10_13.2 [template = constants.%struct.3]
-// CHECK:STDOUT:   return %.loc10_14 to @impl.1.%return.var
+// CHECK:STDOUT:   %.loc15_13.1: {} = struct_literal ()
+// CHECK:STDOUT:   %.loc15_13.2: init C = class_init (), @impl.1.%return.var [template = constants.%struct.3]
+// CHECK:STDOUT:   %.loc15_14: init C = converted %.loc15_13.1, %.loc15_13.2 [template = constants.%struct.3]
+// CHECK:STDOUT:   return %.loc15_14 to @impl.1.%return.var
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @Op.2[%self: Self](%other: Self) -> Self;
 // CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.3[addr @impl.2.%self.loc14_14.3: C*](@impl.2.%other.loc14_24.2: C) {
+// CHECK:STDOUT: fn @Op.3[addr @impl.2.%self.loc19_14.3: C*](@impl.2.%other.loc19_24.2: C) {
 // CHECK:STDOUT: !entry:
 // CHECK:STDOUT:   return
 // CHECK:STDOUT: }
@@ -287,21 +190,21 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:   %a.ref: C = name_ref a, %a
 // CHECK:STDOUT:   %b.ref: C = name_ref b, %b
 // CHECK:STDOUT:   %.1: Op = interface_witness_access @impl.1.%.1, element0 [template = constants.%struct.1]
-// CHECK:STDOUT:   %.loc18: <bound method> = bound_method %a.ref, %.1
-// CHECK:STDOUT:   %.loc17: ref C = splice_block %return {}
-// CHECK:STDOUT:   %Op.call: init C = call %.loc18(%a.ref, %b.ref) to %.loc17
+// CHECK:STDOUT:   %.loc23: <bound method> = bound_method %a.ref, %.1
+// CHECK:STDOUT:   %.loc22: ref C = splice_block %return {}
+// CHECK:STDOUT:   %Op.call: init C = call %.loc23(%a.ref, %b.ref) to %.loc22
 // CHECK:STDOUT:   return %Op.call to %return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @TestAssign(%a: C*, %b: C) {
 // CHECK:STDOUT: !entry:
 // CHECK:STDOUT:   %a.ref: C* = name_ref a, %a
-// CHECK:STDOUT:   %.loc22_3.1: ref C = deref %a.ref
+// CHECK:STDOUT:   %.loc27_3.1: ref C = deref %a.ref
 // CHECK:STDOUT:   %b.ref: C = name_ref b, %b
 // CHECK:STDOUT:   %.1: Op = interface_witness_access @impl.2.%.1, element0 [template = constants.%struct.4]
-// CHECK:STDOUT:   %.loc22_6: <bound method> = bound_method %.loc22_3.1, %.1
-// CHECK:STDOUT:   %.loc22_3.2: C* = addr_of %.loc22_3.1
-// CHECK:STDOUT:   %Op.call: init () = call %.loc22_6(%.loc22_3.2, %b.ref)
+// CHECK:STDOUT:   %.loc27_6: <bound method> = bound_method %.loc27_3.1, %.1
+// CHECK:STDOUT:   %.loc27_3.2: C* = addr_of %.loc27_3.1
+// CHECK:STDOUT:   %Op.call: init () = call %.loc27_6(%.loc27_3.2, %b.ref)
 // CHECK:STDOUT:   return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 0 - 15
toolchain/check/testdata/operators/overloaded/binary_op.carbon.tmpl

@@ -6,23 +6,8 @@
 
 HEADER
 
-// --- prelude.carbon
-
-package Core;
-
-interface INTERFACE {
-  fn Op[self: Self](other: Self) -> Self;
-}
-interface INTERFACEAssign {
-  fn Op[addr self: Self*](other: Self);
-}
-
-// --- user.carbon
-
 package User;
 
-import Core;
-
 class C {};
 
 impl C as Core.INTERFACE {

+ 63 - 160
toolchain/check/testdata/operators/overloaded/bit_and.carbon

@@ -6,23 +6,8 @@
 
 // This file was generated from binary_op.carbon.tmpl. Run make_tests.sh to regenerate.
 
-// --- prelude.carbon
-
-package Core;
-
-interface BitAnd {
-  fn Op[self: Self](other: Self) -> Self;
-}
-interface BitAndAssign {
-  fn Op[addr self: Self*](other: Self);
-}
-
-// --- user.carbon
-
 package User;
 
-import Core;
-
 class C {};
 
 impl C as Core.BitAnd {
@@ -42,89 +27,7 @@ fn TestAssign(a: C*, b: C) {
   *a &= b;
 }
 
-// CHECK:STDOUT: --- prelude.carbon
-// CHECK:STDOUT:
-// CHECK:STDOUT: constants {
-// CHECK:STDOUT:   %.1: type = interface_type @BitAnd [template]
-// CHECK:STDOUT:   %Self.1: BitAnd = bind_symbolic_name Self 0 [symbolic]
-// CHECK:STDOUT:   %Op.1: type = fn_type @Op.1 [template]
-// CHECK:STDOUT:   %.2: type = tuple_type () [template]
-// CHECK:STDOUT:   %struct.1: Op = struct_value () [template]
-// CHECK:STDOUT:   %.3: type = assoc_entity_type @BitAnd, Op [template]
-// CHECK:STDOUT:   %.4: <associated Op in BitAnd> = assoc_entity element0, @BitAnd.%Op.decl [template]
-// CHECK:STDOUT:   %.5: type = interface_type @BitAndAssign [template]
-// CHECK:STDOUT:   %Self.2: BitAndAssign = bind_symbolic_name Self 0 [symbolic]
-// CHECK:STDOUT:   %.6: type = ptr_type Self [symbolic]
-// CHECK:STDOUT:   %Op.2: type = fn_type @Op.2 [template]
-// CHECK:STDOUT:   %struct.2: Op = struct_value () [template]
-// CHECK:STDOUT:   %.7: type = assoc_entity_type @BitAndAssign, Op [template]
-// CHECK:STDOUT:   %.8: <associated Op in BitAndAssign> = assoc_entity element0, @BitAndAssign.%Op.decl [template]
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace [template] {
-// CHECK:STDOUT:     .BitAnd = %BitAnd.decl
-// CHECK:STDOUT:     .BitAndAssign = %BitAndAssign.decl
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %BitAnd.decl: type = interface_decl @BitAnd [template = constants.%.1] {}
-// CHECK:STDOUT:   %BitAndAssign.decl: type = interface_decl @BitAndAssign [template = constants.%.5] {}
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: interface @BitAnd {
-// CHECK:STDOUT:   %Self: BitAnd = bind_symbolic_name Self 0 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.1 [template = constants.%struct.1] {
-// CHECK:STDOUT:     %Self.ref.loc5_15: BitAnd = name_ref Self, %Self [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_15.1: type = facet_type_access %Self.ref.loc5_15 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_15.2: type = converted %Self.ref.loc5_15, %.loc5_15.1 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %self.loc5_9.1: Self = param self
-// CHECK:STDOUT:     %self.loc5_9.2: Self = bind_name self, %self.loc5_9.1
-// CHECK:STDOUT:     %Self.ref.loc5_28: BitAnd = name_ref Self, %Self [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_28.1: type = facet_type_access %Self.ref.loc5_28 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_28.2: type = converted %Self.ref.loc5_28, %.loc5_28.1 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %other.loc5_21.1: Self = param other
-// CHECK:STDOUT:     %other.loc5_21.2: Self = bind_name other, %other.loc5_21.1
-// CHECK:STDOUT:     %Self.ref.loc5_37: BitAnd = name_ref Self, %Self [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_37.1: type = facet_type_access %Self.ref.loc5_37 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_37.2: type = converted %Self.ref.loc5_37, %.loc5_37.1 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %return.var: ref Self = var <return slot>
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %.loc5_41: <associated Op in BitAnd> = assoc_entity element0, %Op.decl [template = constants.%.4]
-// CHECK:STDOUT:
-// CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Self = %Self
-// CHECK:STDOUT:   .Op = %.loc5_41
-// CHECK:STDOUT:   witness = (%Op.decl)
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: interface @BitAndAssign {
-// CHECK:STDOUT:   %Self: BitAndAssign = bind_symbolic_name Self 0 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.2 [template = constants.%struct.2] {
-// CHECK:STDOUT:     %Self.ref.loc8_20: BitAndAssign = name_ref Self, %Self [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_24.1: type = facet_type_access %Self.ref.loc8_20 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_24.2: type = converted %Self.ref.loc8_20, %.loc8_24.1 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_24.3: type = ptr_type Self [symbolic = constants.%.6]
-// CHECK:STDOUT:     %self.loc8_14.1: Self* = param self
-// CHECK:STDOUT:     %self.loc8_14.3: Self* = bind_name self, %self.loc8_14.1
-// CHECK:STDOUT:     %.loc8_9: Self* = addr_pattern %self.loc8_14.3
-// CHECK:STDOUT:     %Self.ref.loc8_34: BitAndAssign = name_ref Self, %Self [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_34.1: type = facet_type_access %Self.ref.loc8_34 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_34.2: type = converted %Self.ref.loc8_34, %.loc8_34.1 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %other.loc8_27.1: Self = param other
-// CHECK:STDOUT:     %other.loc8_27.2: Self = bind_name other, %other.loc8_27.1
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %.loc8_39: <associated Op in BitAndAssign> = assoc_entity element0, %Op.decl [template = constants.%.8]
-// CHECK:STDOUT:
-// CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Self = %Self
-// CHECK:STDOUT:   .Op = %.loc8_39
-// CHECK:STDOUT:   witness = (%Op.decl)
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.1[@BitAnd.%self.loc5_9.2: Self](@BitAnd.%other.loc5_21.2: Self) -> Self;
-// CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.2[addr @BitAndAssign.%self.loc8_14.3: Self*](@BitAndAssign.%other.loc8_27.2: Self);
-// CHECK:STDOUT:
-// CHECK:STDOUT: --- user.carbon
+// CHECK:STDOUT: --- bit_and.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: constants {
 // CHECK:STDOUT:   %C: type = class_type @C [template]
@@ -167,72 +70,72 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %Core: <namespace> = namespace [template] {}
 // CHECK:STDOUT:   %C.decl: type = class_decl @C [template = constants.%C] {}
-// CHECK:STDOUT:   %import_ref.1: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.2: <associated Op in BitAnd> = import_ref ir2, inst+24, loaded [template = constants.%.11]
-// CHECK:STDOUT:   %import_ref.3 = import_ref ir2, inst+3, unloaded
-// CHECK:STDOUT:   %import_ref.4: Op = import_ref ir2, inst+19, loaded [template = constants.%struct.2]
+// CHECK:STDOUT:   %import_ref.1: type = import_ref ir5, inst+21, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.2 = import_ref ir5, inst+23, unloaded
+// CHECK:STDOUT:   %import_ref.3: <associated Op in BitAnd> = import_ref ir5, inst+43, loaded [template = constants.%.11]
+// CHECK:STDOUT:   %import_ref.4: Op = import_ref ir5, inst+39, loaded [template = constants.%struct.2]
 // CHECK:STDOUT:   impl_decl @impl.1 {
-// CHECK:STDOUT:     %C.ref.loc8: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %Core.ref.loc8: <namespace> = name_ref Core, %Core [template = %Core]
+// CHECK:STDOUT:     %C.ref.loc13: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %Core.ref.loc13: <namespace> = name_ref Core, %Core [template = %Core]
 // CHECK:STDOUT:     %BitAnd.ref: type = name_ref BitAnd, %import_ref.1 [template = constants.%.2]
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.5: type = import_ref ir2, inst+26, loaded [template = constants.%.6]
-// CHECK:STDOUT:   %import_ref.6: <associated Op in BitAndAssign> = import_ref ir2, inst+47, loaded [template = constants.%.13]
-// CHECK:STDOUT:   %import_ref.7 = import_ref ir2, inst+28, unloaded
-// CHECK:STDOUT:   %import_ref.8: Op = import_ref ir2, inst+43, loaded [template = constants.%struct.5]
+// CHECK:STDOUT:   %import_ref.5: type = import_ref ir5, inst+45, loaded [template = constants.%.6]
+// CHECK:STDOUT:   %import_ref.6 = import_ref ir5, inst+47, unloaded
+// CHECK:STDOUT:   %import_ref.7: <associated Op in BitAndAssign> = import_ref ir5, inst+66, loaded [template = constants.%.13]
+// CHECK:STDOUT:   %import_ref.8: Op = import_ref ir5, inst+62, loaded [template = constants.%struct.5]
 // CHECK:STDOUT:   impl_decl @impl.2 {
-// CHECK:STDOUT:     %C.ref.loc13: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %Core.ref.loc13: <namespace> = name_ref Core, %Core [template = %Core]
+// CHECK:STDOUT:     %C.ref.loc18: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %Core.ref.loc18: <namespace> = name_ref Core, %Core [template = %Core]
 // CHECK:STDOUT:     %BitAndAssign.ref: type = name_ref BitAndAssign, %import_ref.5 [template = constants.%.6]
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %TestOp.decl: TestOp = fn_decl @TestOp [template = constants.%struct.6] {
-// CHECK:STDOUT:     %C.ref.loc17_14: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %a.loc17_11.1: C = param a
-// CHECK:STDOUT:     @TestOp.%a: C = bind_name a, %a.loc17_11.1
-// CHECK:STDOUT:     %C.ref.loc17_20: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %b.loc17_17.1: C = param b
-// CHECK:STDOUT:     @TestOp.%b: C = bind_name b, %b.loc17_17.1
-// CHECK:STDOUT:     %C.ref.loc17_26: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %C.ref.loc22_14: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %a.loc22_11.1: C = param a
+// CHECK:STDOUT:     @TestOp.%a: C = bind_name a, %a.loc22_11.1
+// CHECK:STDOUT:     %C.ref.loc22_20: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %b.loc22_17.1: C = param b
+// CHECK:STDOUT:     @TestOp.%b: C = bind_name b, %b.loc22_17.1
+// CHECK:STDOUT:     %C.ref.loc22_26: type = name_ref C, %C.decl [template = constants.%C]
 // CHECK:STDOUT:     @TestOp.%return: ref C = var <return slot>
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.9: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.10 = import_ref ir2, inst+19, unloaded
+// CHECK:STDOUT:   %import_ref.9: type = import_ref ir5, inst+21, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.10 = import_ref ir5, inst+39, unloaded
 // CHECK:STDOUT:   %TestAssign.decl: TestAssign = fn_decl @TestAssign [template = constants.%struct.7] {
-// CHECK:STDOUT:     %C.ref.loc21_18: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %.loc21: type = ptr_type C [template = constants.%.7]
-// CHECK:STDOUT:     %a.loc21_15.1: C* = param a
-// CHECK:STDOUT:     @TestAssign.%a: C* = bind_name a, %a.loc21_15.1
-// CHECK:STDOUT:     %C.ref.loc21_25: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %b.loc21_22.1: C = param b
-// CHECK:STDOUT:     @TestAssign.%b: C = bind_name b, %b.loc21_22.1
+// CHECK:STDOUT:     %C.ref.loc26_18: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %.loc26: type = ptr_type C [template = constants.%.7]
+// CHECK:STDOUT:     %a.loc26_15.1: C* = param a
+// CHECK:STDOUT:     @TestAssign.%a: C* = bind_name a, %a.loc26_15.1
+// CHECK:STDOUT:     %C.ref.loc26_25: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %b.loc26_22.1: C = param b
+// CHECK:STDOUT:     @TestAssign.%b: C = bind_name b, %b.loc26_22.1
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.11: type = import_ref ir2, inst+26, loaded [template = constants.%.6]
-// CHECK:STDOUT:   %import_ref.12 = import_ref ir2, inst+43, unloaded
+// CHECK:STDOUT:   %import_ref.11: type = import_ref ir5, inst+45, loaded [template = constants.%.6]
+// CHECK:STDOUT:   %import_ref.12 = import_ref ir5, inst+62, unloaded
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: interface @BitAnd {
 // CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Op = file.%import_ref.2
-// CHECK:STDOUT:   .Self = file.%import_ref.3
+// CHECK:STDOUT:   .Self = file.%import_ref.2
+// CHECK:STDOUT:   .Op = file.%import_ref.3
 // CHECK:STDOUT:   witness = (file.%import_ref.4)
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: interface @BitAndAssign {
 // CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Op = file.%import_ref.6
-// CHECK:STDOUT:   .Self = file.%import_ref.7
+// CHECK:STDOUT:   .Self = file.%import_ref.6
+// CHECK:STDOUT:   .Op = file.%import_ref.7
 // CHECK:STDOUT:   witness = (file.%import_ref.8)
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: impl @impl.1: C as BitAnd {
 // CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.1 [template = constants.%struct.1] {
-// CHECK:STDOUT:     %C.ref.loc9_15: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %self.loc9_9.1: C = param self
-// CHECK:STDOUT:     %self.loc9_9.2: C = bind_name self, %self.loc9_9.1
-// CHECK:STDOUT:     %C.ref.loc9_25: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %other.loc9_18.1: C = param other
-// CHECK:STDOUT:     %other.loc9_18.2: C = bind_name other, %other.loc9_18.1
-// CHECK:STDOUT:     %C.ref.loc9_31: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %C.ref.loc14_15: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %self.loc14_9.1: C = param self
+// CHECK:STDOUT:     %self.loc14_9.2: C = bind_name self, %self.loc14_9.1
+// CHECK:STDOUT:     %C.ref.loc14_25: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %other.loc14_18.1: C = param other
+// CHECK:STDOUT:     %other.loc14_18.2: C = bind_name other, %other.loc14_18.1
+// CHECK:STDOUT:     %C.ref.loc14_31: type = name_ref C, file.%C.decl [template = constants.%C]
 // CHECK:STDOUT:     %return.var: ref C = var <return slot>
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %.1: <witness> = interface_witness (%Op.decl) [template = constants.%.4]
@@ -244,14 +147,14 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:
 // CHECK:STDOUT: impl @impl.2: C as BitAndAssign {
 // CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.3 [template = constants.%struct.4] {
-// CHECK:STDOUT:     %C.ref.loc14_20: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %.loc14_21: type = ptr_type C [template = constants.%.7]
-// CHECK:STDOUT:     %self.loc14_14.1: C* = param self
-// CHECK:STDOUT:     %self.loc14_14.3: C* = bind_name self, %self.loc14_14.1
-// CHECK:STDOUT:     %.loc14_9: C* = addr_pattern %self.loc14_14.3
-// CHECK:STDOUT:     %C.ref.loc14_31: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %other.loc14_24.1: C = param other
-// CHECK:STDOUT:     %other.loc14_24.2: C = bind_name other, %other.loc14_24.1
+// CHECK:STDOUT:     %C.ref.loc19_20: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %.loc19_21: type = ptr_type C [template = constants.%.7]
+// CHECK:STDOUT:     %self.loc19_14.1: C* = param self
+// CHECK:STDOUT:     %self.loc19_14.3: C* = bind_name self, %self.loc19_14.1
+// CHECK:STDOUT:     %.loc19_9: C* = addr_pattern %self.loc19_14.3
+// CHECK:STDOUT:     %C.ref.loc19_31: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %other.loc19_24.1: C = param other
+// CHECK:STDOUT:     %other.loc19_24.2: C = bind_name other, %other.loc19_24.1
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %.1: <witness> = interface_witness (%Op.decl) [template = constants.%.9]
 // CHECK:STDOUT:
@@ -265,17 +168,17 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:   .Self = constants.%C
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.1[@impl.1.%self.loc9_9.2: C](@impl.1.%other.loc9_18.2: C) -> @impl.1.%return.var: C {
+// CHECK:STDOUT: fn @Op.1[@impl.1.%self.loc14_9.2: C](@impl.1.%other.loc14_18.2: C) -> @impl.1.%return.var: C {
 // CHECK:STDOUT: !entry:
-// CHECK:STDOUT:   %.loc10_13.1: {} = struct_literal ()
-// CHECK:STDOUT:   %.loc10_13.2: init C = class_init (), @impl.1.%return.var [template = constants.%struct.3]
-// CHECK:STDOUT:   %.loc10_14: init C = converted %.loc10_13.1, %.loc10_13.2 [template = constants.%struct.3]
-// CHECK:STDOUT:   return %.loc10_14 to @impl.1.%return.var
+// CHECK:STDOUT:   %.loc15_13.1: {} = struct_literal ()
+// CHECK:STDOUT:   %.loc15_13.2: init C = class_init (), @impl.1.%return.var [template = constants.%struct.3]
+// CHECK:STDOUT:   %.loc15_14: init C = converted %.loc15_13.1, %.loc15_13.2 [template = constants.%struct.3]
+// CHECK:STDOUT:   return %.loc15_14 to @impl.1.%return.var
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @Op.2[%self: Self](%other: Self) -> Self;
 // CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.3[addr @impl.2.%self.loc14_14.3: C*](@impl.2.%other.loc14_24.2: C) {
+// CHECK:STDOUT: fn @Op.3[addr @impl.2.%self.loc19_14.3: C*](@impl.2.%other.loc19_24.2: C) {
 // CHECK:STDOUT: !entry:
 // CHECK:STDOUT:   return
 // CHECK:STDOUT: }
@@ -287,21 +190,21 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:   %a.ref: C = name_ref a, %a
 // CHECK:STDOUT:   %b.ref: C = name_ref b, %b
 // CHECK:STDOUT:   %.1: Op = interface_witness_access @impl.1.%.1, element0 [template = constants.%struct.1]
-// CHECK:STDOUT:   %.loc18: <bound method> = bound_method %a.ref, %.1
-// CHECK:STDOUT:   %.loc17: ref C = splice_block %return {}
-// CHECK:STDOUT:   %Op.call: init C = call %.loc18(%a.ref, %b.ref) to %.loc17
+// CHECK:STDOUT:   %.loc23: <bound method> = bound_method %a.ref, %.1
+// CHECK:STDOUT:   %.loc22: ref C = splice_block %return {}
+// CHECK:STDOUT:   %Op.call: init C = call %.loc23(%a.ref, %b.ref) to %.loc22
 // CHECK:STDOUT:   return %Op.call to %return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @TestAssign(%a: C*, %b: C) {
 // CHECK:STDOUT: !entry:
 // CHECK:STDOUT:   %a.ref: C* = name_ref a, %a
-// CHECK:STDOUT:   %.loc22_3.1: ref C = deref %a.ref
+// CHECK:STDOUT:   %.loc27_3.1: ref C = deref %a.ref
 // CHECK:STDOUT:   %b.ref: C = name_ref b, %b
 // CHECK:STDOUT:   %.1: Op = interface_witness_access @impl.2.%.1, element0 [template = constants.%struct.4]
-// CHECK:STDOUT:   %.loc22_6: <bound method> = bound_method %.loc22_3.1, %.1
-// CHECK:STDOUT:   %.loc22_3.2: C* = addr_of %.loc22_3.1
-// CHECK:STDOUT:   %Op.call: init () = call %.loc22_6(%.loc22_3.2, %b.ref)
+// CHECK:STDOUT:   %.loc27_6: <bound method> = bound_method %.loc27_3.1, %.1
+// CHECK:STDOUT:   %.loc27_3.2: C* = addr_of %.loc27_3.1
+// CHECK:STDOUT:   %Op.call: init () = call %.loc27_6(%.loc27_3.2, %b.ref)
 // CHECK:STDOUT:   return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 26 - 80
toolchain/check/testdata/operators/overloaded/bit_complement.carbon

@@ -6,20 +6,8 @@
 
 // This file was generated from unary_op.carbon.tmpl. Run make_tests.sh to regenerate.
 
-// --- prelude.carbon
-
-package Core;
-
-interface BitComplement {
-  fn Op[self: Self]() -> Self;
-}
-
-// --- user.carbon
-
 package User;
 
-import Core;
-
 class C {};
 
 impl C as Core.BitComplement {
@@ -32,49 +20,7 @@ fn TestOp(a: C) -> C {
   return ^a;
 }
 
-// CHECK:STDOUT: --- prelude.carbon
-// CHECK:STDOUT:
-// CHECK:STDOUT: constants {
-// CHECK:STDOUT:   %.1: type = interface_type @BitComplement [template]
-// CHECK:STDOUT:   %Self: BitComplement = bind_symbolic_name Self 0 [symbolic]
-// CHECK:STDOUT:   %Op: type = fn_type @Op [template]
-// CHECK:STDOUT:   %.2: type = tuple_type () [template]
-// CHECK:STDOUT:   %struct: Op = struct_value () [template]
-// CHECK:STDOUT:   %.3: type = assoc_entity_type @BitComplement, Op [template]
-// CHECK:STDOUT:   %.4: <associated Op in BitComplement> = assoc_entity element0, @BitComplement.%Op.decl [template]
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace [template] {
-// CHECK:STDOUT:     .BitComplement = %BitComplement.decl
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %BitComplement.decl: type = interface_decl @BitComplement [template = constants.%.1] {}
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: interface @BitComplement {
-// CHECK:STDOUT:   %Self: BitComplement = bind_symbolic_name Self 0 [symbolic = constants.%Self]
-// CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op [template = constants.%struct] {
-// CHECK:STDOUT:     %Self.ref.loc5_15: BitComplement = name_ref Self, %Self [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc5_15.1: type = facet_type_access %Self.ref.loc5_15 [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc5_15.2: type = converted %Self.ref.loc5_15, %.loc5_15.1 [symbolic = constants.%Self]
-// CHECK:STDOUT:     %self.loc5_9.1: Self = param self
-// CHECK:STDOUT:     %self.loc5_9.2: Self = bind_name self, %self.loc5_9.1
-// CHECK:STDOUT:     %Self.ref.loc5_26: BitComplement = name_ref Self, %Self [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc5_26.1: type = facet_type_access %Self.ref.loc5_26 [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc5_26.2: type = converted %Self.ref.loc5_26, %.loc5_26.1 [symbolic = constants.%Self]
-// CHECK:STDOUT:     %return.var: ref Self = var <return slot>
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %.loc5_30: <associated Op in BitComplement> = assoc_entity element0, %Op.decl [template = constants.%.4]
-// CHECK:STDOUT:
-// CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Self = %Self
-// CHECK:STDOUT:   .Op = %.loc5_30
-// CHECK:STDOUT:   witness = (%Op.decl)
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op[@BitComplement.%self.loc5_9.2: Self]() -> Self;
-// CHECK:STDOUT:
-// CHECK:STDOUT: --- user.carbon
+// CHECK:STDOUT: --- bit_complement.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: constants {
 // CHECK:STDOUT:   %C: type = class_type @C [template]
@@ -103,39 +49,39 @@ fn TestOp(a: C) -> C {
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %Core: <namespace> = namespace [template] {}
 // CHECK:STDOUT:   %C.decl: type = class_decl @C [template = constants.%C] {}
-// CHECK:STDOUT:   %import_ref.1: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.2: <associated Op in BitComplement> = import_ref ir2, inst+19, loaded [template = constants.%.7]
-// CHECK:STDOUT:   %import_ref.3 = import_ref ir2, inst+3, unloaded
-// CHECK:STDOUT:   %import_ref.4: Op = import_ref ir2, inst+14, loaded [template = constants.%struct.2]
+// CHECK:STDOUT:   %import_ref.1: type = import_ref ir5, inst+1, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.2 = import_ref ir5, inst+3, unloaded
+// CHECK:STDOUT:   %import_ref.3: <associated Op in BitComplement> = import_ref ir5, inst+19, loaded [template = constants.%.7]
+// CHECK:STDOUT:   %import_ref.4: Op = import_ref ir5, inst+14, loaded [template = constants.%struct.2]
 // CHECK:STDOUT:   impl_decl @impl {
-// CHECK:STDOUT:     %C.ref.loc8: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %C.ref.loc13: type = name_ref C, %C.decl [template = constants.%C]
 // CHECK:STDOUT:     %Core.ref: <namespace> = name_ref Core, %Core [template = %Core]
 // CHECK:STDOUT:     %BitComplement.ref: type = name_ref BitComplement, %import_ref.1 [template = constants.%.2]
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %TestOp.decl: TestOp = fn_decl @TestOp [template = constants.%struct.4] {
-// CHECK:STDOUT:     %C.ref.loc14_14: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %a.loc14_11.1: C = param a
-// CHECK:STDOUT:     @TestOp.%a: C = bind_name a, %a.loc14_11.1
-// CHECK:STDOUT:     %C.ref.loc14_20: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %C.ref.loc19_14: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %a.loc19_11.1: C = param a
+// CHECK:STDOUT:     @TestOp.%a: C = bind_name a, %a.loc19_11.1
+// CHECK:STDOUT:     %C.ref.loc19_20: type = name_ref C, %C.decl [template = constants.%C]
 // CHECK:STDOUT:     @TestOp.%return: ref C = var <return slot>
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.5: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.6 = import_ref ir2, inst+14, unloaded
+// CHECK:STDOUT:   %import_ref.5: type = import_ref ir5, inst+1, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.6 = import_ref ir5, inst+14, unloaded
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: interface @BitComplement {
 // CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Op = file.%import_ref.2
-// CHECK:STDOUT:   .Self = file.%import_ref.3
+// CHECK:STDOUT:   .Self = file.%import_ref.2
+// CHECK:STDOUT:   .Op = file.%import_ref.3
 // CHECK:STDOUT:   witness = (file.%import_ref.4)
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: impl @impl: C as BitComplement {
 // CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.1 [template = constants.%struct.1] {
-// CHECK:STDOUT:     %C.ref.loc9_15: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %self.loc9_9.1: C = param self
-// CHECK:STDOUT:     %self.loc9_9.2: C = bind_name self, %self.loc9_9.1
-// CHECK:STDOUT:     %C.ref.loc9_23: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %C.ref.loc14_15: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %self.loc14_9.1: C = param self
+// CHECK:STDOUT:     %self.loc14_9.2: C = bind_name self, %self.loc14_9.1
+// CHECK:STDOUT:     %C.ref.loc14_23: type = name_ref C, file.%C.decl [template = constants.%C]
 // CHECK:STDOUT:     %return.var: ref C = var <return slot>
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %.1: <witness> = interface_witness (%Op.decl) [template = constants.%.4]
@@ -150,12 +96,12 @@ fn TestOp(a: C) -> C {
 // CHECK:STDOUT:   .Self = constants.%C
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.1[@impl.%self.loc9_9.2: C]() -> @impl.%return.var: C {
+// CHECK:STDOUT: fn @Op.1[@impl.%self.loc14_9.2: C]() -> @impl.%return.var: C {
 // CHECK:STDOUT: !entry:
-// CHECK:STDOUT:   %.loc10_13.1: {} = struct_literal ()
-// CHECK:STDOUT:   %.loc10_13.2: init C = class_init (), @impl.%return.var [template = constants.%struct.3]
-// CHECK:STDOUT:   %.loc10_14: init C = converted %.loc10_13.1, %.loc10_13.2 [template = constants.%struct.3]
-// CHECK:STDOUT:   return %.loc10_14 to @impl.%return.var
+// CHECK:STDOUT:   %.loc15_13.1: {} = struct_literal ()
+// CHECK:STDOUT:   %.loc15_13.2: init C = class_init (), @impl.%return.var [template = constants.%struct.3]
+// CHECK:STDOUT:   %.loc15_14: init C = converted %.loc15_13.1, %.loc15_13.2 [template = constants.%struct.3]
+// CHECK:STDOUT:   return %.loc15_14 to @impl.%return.var
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @Op.2[%self: Self]() -> Self;
@@ -164,9 +110,9 @@ fn TestOp(a: C) -> C {
 // CHECK:STDOUT: !entry:
 // CHECK:STDOUT:   %a.ref: C = name_ref a, %a
 // CHECK:STDOUT:   %.1: Op = interface_witness_access @impl.%.1, element0 [template = constants.%struct.1]
-// CHECK:STDOUT:   %.loc15: <bound method> = bound_method %a.ref, %.1
-// CHECK:STDOUT:   %.loc14: ref C = splice_block %return {}
-// CHECK:STDOUT:   %Op.call: init C = call %.loc15(%a.ref) to %.loc14
+// CHECK:STDOUT:   %.loc20: <bound method> = bound_method %a.ref, %.1
+// CHECK:STDOUT:   %.loc19: ref C = splice_block %return {}
+// CHECK:STDOUT:   %Op.call: init C = call %.loc20(%a.ref) to %.loc19
 // CHECK:STDOUT:   return %Op.call to %return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 63 - 160
toolchain/check/testdata/operators/overloaded/bit_or.carbon

@@ -6,23 +6,8 @@
 
 // This file was generated from binary_op.carbon.tmpl. Run make_tests.sh to regenerate.
 
-// --- prelude.carbon
-
-package Core;
-
-interface BitOr {
-  fn Op[self: Self](other: Self) -> Self;
-}
-interface BitOrAssign {
-  fn Op[addr self: Self*](other: Self);
-}
-
-// --- user.carbon
-
 package User;
 
-import Core;
-
 class C {};
 
 impl C as Core.BitOr {
@@ -42,89 +27,7 @@ fn TestAssign(a: C*, b: C) {
   *a |= b;
 }
 
-// CHECK:STDOUT: --- prelude.carbon
-// CHECK:STDOUT:
-// CHECK:STDOUT: constants {
-// CHECK:STDOUT:   %.1: type = interface_type @BitOr [template]
-// CHECK:STDOUT:   %Self.1: BitOr = bind_symbolic_name Self 0 [symbolic]
-// CHECK:STDOUT:   %Op.1: type = fn_type @Op.1 [template]
-// CHECK:STDOUT:   %.2: type = tuple_type () [template]
-// CHECK:STDOUT:   %struct.1: Op = struct_value () [template]
-// CHECK:STDOUT:   %.3: type = assoc_entity_type @BitOr, Op [template]
-// CHECK:STDOUT:   %.4: <associated Op in BitOr> = assoc_entity element0, @BitOr.%Op.decl [template]
-// CHECK:STDOUT:   %.5: type = interface_type @BitOrAssign [template]
-// CHECK:STDOUT:   %Self.2: BitOrAssign = bind_symbolic_name Self 0 [symbolic]
-// CHECK:STDOUT:   %.6: type = ptr_type Self [symbolic]
-// CHECK:STDOUT:   %Op.2: type = fn_type @Op.2 [template]
-// CHECK:STDOUT:   %struct.2: Op = struct_value () [template]
-// CHECK:STDOUT:   %.7: type = assoc_entity_type @BitOrAssign, Op [template]
-// CHECK:STDOUT:   %.8: <associated Op in BitOrAssign> = assoc_entity element0, @BitOrAssign.%Op.decl [template]
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace [template] {
-// CHECK:STDOUT:     .BitOr = %BitOr.decl
-// CHECK:STDOUT:     .BitOrAssign = %BitOrAssign.decl
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %BitOr.decl: type = interface_decl @BitOr [template = constants.%.1] {}
-// CHECK:STDOUT:   %BitOrAssign.decl: type = interface_decl @BitOrAssign [template = constants.%.5] {}
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: interface @BitOr {
-// CHECK:STDOUT:   %Self: BitOr = bind_symbolic_name Self 0 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.1 [template = constants.%struct.1] {
-// CHECK:STDOUT:     %Self.ref.loc5_15: BitOr = name_ref Self, %Self [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_15.1: type = facet_type_access %Self.ref.loc5_15 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_15.2: type = converted %Self.ref.loc5_15, %.loc5_15.1 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %self.loc5_9.1: Self = param self
-// CHECK:STDOUT:     %self.loc5_9.2: Self = bind_name self, %self.loc5_9.1
-// CHECK:STDOUT:     %Self.ref.loc5_28: BitOr = name_ref Self, %Self [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_28.1: type = facet_type_access %Self.ref.loc5_28 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_28.2: type = converted %Self.ref.loc5_28, %.loc5_28.1 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %other.loc5_21.1: Self = param other
-// CHECK:STDOUT:     %other.loc5_21.2: Self = bind_name other, %other.loc5_21.1
-// CHECK:STDOUT:     %Self.ref.loc5_37: BitOr = name_ref Self, %Self [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_37.1: type = facet_type_access %Self.ref.loc5_37 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_37.2: type = converted %Self.ref.loc5_37, %.loc5_37.1 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %return.var: ref Self = var <return slot>
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %.loc5_41: <associated Op in BitOr> = assoc_entity element0, %Op.decl [template = constants.%.4]
-// CHECK:STDOUT:
-// CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Self = %Self
-// CHECK:STDOUT:   .Op = %.loc5_41
-// CHECK:STDOUT:   witness = (%Op.decl)
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: interface @BitOrAssign {
-// CHECK:STDOUT:   %Self: BitOrAssign = bind_symbolic_name Self 0 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.2 [template = constants.%struct.2] {
-// CHECK:STDOUT:     %Self.ref.loc8_20: BitOrAssign = name_ref Self, %Self [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_24.1: type = facet_type_access %Self.ref.loc8_20 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_24.2: type = converted %Self.ref.loc8_20, %.loc8_24.1 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_24.3: type = ptr_type Self [symbolic = constants.%.6]
-// CHECK:STDOUT:     %self.loc8_14.1: Self* = param self
-// CHECK:STDOUT:     %self.loc8_14.3: Self* = bind_name self, %self.loc8_14.1
-// CHECK:STDOUT:     %.loc8_9: Self* = addr_pattern %self.loc8_14.3
-// CHECK:STDOUT:     %Self.ref.loc8_34: BitOrAssign = name_ref Self, %Self [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_34.1: type = facet_type_access %Self.ref.loc8_34 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_34.2: type = converted %Self.ref.loc8_34, %.loc8_34.1 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %other.loc8_27.1: Self = param other
-// CHECK:STDOUT:     %other.loc8_27.2: Self = bind_name other, %other.loc8_27.1
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %.loc8_39: <associated Op in BitOrAssign> = assoc_entity element0, %Op.decl [template = constants.%.8]
-// CHECK:STDOUT:
-// CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Self = %Self
-// CHECK:STDOUT:   .Op = %.loc8_39
-// CHECK:STDOUT:   witness = (%Op.decl)
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.1[@BitOr.%self.loc5_9.2: Self](@BitOr.%other.loc5_21.2: Self) -> Self;
-// CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.2[addr @BitOrAssign.%self.loc8_14.3: Self*](@BitOrAssign.%other.loc8_27.2: Self);
-// CHECK:STDOUT:
-// CHECK:STDOUT: --- user.carbon
+// CHECK:STDOUT: --- bit_or.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: constants {
 // CHECK:STDOUT:   %C: type = class_type @C [template]
@@ -167,72 +70,72 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %Core: <namespace> = namespace [template] {}
 // CHECK:STDOUT:   %C.decl: type = class_decl @C [template = constants.%C] {}
-// CHECK:STDOUT:   %import_ref.1: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.2: <associated Op in BitOr> = import_ref ir2, inst+24, loaded [template = constants.%.11]
-// CHECK:STDOUT:   %import_ref.3 = import_ref ir2, inst+3, unloaded
-// CHECK:STDOUT:   %import_ref.4: Op = import_ref ir2, inst+19, loaded [template = constants.%struct.2]
+// CHECK:STDOUT:   %import_ref.1: type = import_ref ir5, inst+68, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.2 = import_ref ir5, inst+70, unloaded
+// CHECK:STDOUT:   %import_ref.3: <associated Op in BitOr> = import_ref ir5, inst+90, loaded [template = constants.%.11]
+// CHECK:STDOUT:   %import_ref.4: Op = import_ref ir5, inst+86, loaded [template = constants.%struct.2]
 // CHECK:STDOUT:   impl_decl @impl.1 {
-// CHECK:STDOUT:     %C.ref.loc8: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %Core.ref.loc8: <namespace> = name_ref Core, %Core [template = %Core]
+// CHECK:STDOUT:     %C.ref.loc13: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %Core.ref.loc13: <namespace> = name_ref Core, %Core [template = %Core]
 // CHECK:STDOUT:     %BitOr.ref: type = name_ref BitOr, %import_ref.1 [template = constants.%.2]
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.5: type = import_ref ir2, inst+26, loaded [template = constants.%.6]
-// CHECK:STDOUT:   %import_ref.6: <associated Op in BitOrAssign> = import_ref ir2, inst+47, loaded [template = constants.%.13]
-// CHECK:STDOUT:   %import_ref.7 = import_ref ir2, inst+28, unloaded
-// CHECK:STDOUT:   %import_ref.8: Op = import_ref ir2, inst+43, loaded [template = constants.%struct.5]
+// CHECK:STDOUT:   %import_ref.5: type = import_ref ir5, inst+92, loaded [template = constants.%.6]
+// CHECK:STDOUT:   %import_ref.6 = import_ref ir5, inst+94, unloaded
+// CHECK:STDOUT:   %import_ref.7: <associated Op in BitOrAssign> = import_ref ir5, inst+113, loaded [template = constants.%.13]
+// CHECK:STDOUT:   %import_ref.8: Op = import_ref ir5, inst+109, loaded [template = constants.%struct.5]
 // CHECK:STDOUT:   impl_decl @impl.2 {
-// CHECK:STDOUT:     %C.ref.loc13: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %Core.ref.loc13: <namespace> = name_ref Core, %Core [template = %Core]
+// CHECK:STDOUT:     %C.ref.loc18: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %Core.ref.loc18: <namespace> = name_ref Core, %Core [template = %Core]
 // CHECK:STDOUT:     %BitOrAssign.ref: type = name_ref BitOrAssign, %import_ref.5 [template = constants.%.6]
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %TestOp.decl: TestOp = fn_decl @TestOp [template = constants.%struct.6] {
-// CHECK:STDOUT:     %C.ref.loc17_14: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %a.loc17_11.1: C = param a
-// CHECK:STDOUT:     @TestOp.%a: C = bind_name a, %a.loc17_11.1
-// CHECK:STDOUT:     %C.ref.loc17_20: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %b.loc17_17.1: C = param b
-// CHECK:STDOUT:     @TestOp.%b: C = bind_name b, %b.loc17_17.1
-// CHECK:STDOUT:     %C.ref.loc17_26: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %C.ref.loc22_14: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %a.loc22_11.1: C = param a
+// CHECK:STDOUT:     @TestOp.%a: C = bind_name a, %a.loc22_11.1
+// CHECK:STDOUT:     %C.ref.loc22_20: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %b.loc22_17.1: C = param b
+// CHECK:STDOUT:     @TestOp.%b: C = bind_name b, %b.loc22_17.1
+// CHECK:STDOUT:     %C.ref.loc22_26: type = name_ref C, %C.decl [template = constants.%C]
 // CHECK:STDOUT:     @TestOp.%return: ref C = var <return slot>
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.9: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.10 = import_ref ir2, inst+19, unloaded
+// CHECK:STDOUT:   %import_ref.9: type = import_ref ir5, inst+68, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.10 = import_ref ir5, inst+86, unloaded
 // CHECK:STDOUT:   %TestAssign.decl: TestAssign = fn_decl @TestAssign [template = constants.%struct.7] {
-// CHECK:STDOUT:     %C.ref.loc21_18: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %.loc21: type = ptr_type C [template = constants.%.7]
-// CHECK:STDOUT:     %a.loc21_15.1: C* = param a
-// CHECK:STDOUT:     @TestAssign.%a: C* = bind_name a, %a.loc21_15.1
-// CHECK:STDOUT:     %C.ref.loc21_25: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %b.loc21_22.1: C = param b
-// CHECK:STDOUT:     @TestAssign.%b: C = bind_name b, %b.loc21_22.1
+// CHECK:STDOUT:     %C.ref.loc26_18: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %.loc26: type = ptr_type C [template = constants.%.7]
+// CHECK:STDOUT:     %a.loc26_15.1: C* = param a
+// CHECK:STDOUT:     @TestAssign.%a: C* = bind_name a, %a.loc26_15.1
+// CHECK:STDOUT:     %C.ref.loc26_25: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %b.loc26_22.1: C = param b
+// CHECK:STDOUT:     @TestAssign.%b: C = bind_name b, %b.loc26_22.1
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.11: type = import_ref ir2, inst+26, loaded [template = constants.%.6]
-// CHECK:STDOUT:   %import_ref.12 = import_ref ir2, inst+43, unloaded
+// CHECK:STDOUT:   %import_ref.11: type = import_ref ir5, inst+92, loaded [template = constants.%.6]
+// CHECK:STDOUT:   %import_ref.12 = import_ref ir5, inst+109, unloaded
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: interface @BitOr {
 // CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Op = file.%import_ref.2
-// CHECK:STDOUT:   .Self = file.%import_ref.3
+// CHECK:STDOUT:   .Self = file.%import_ref.2
+// CHECK:STDOUT:   .Op = file.%import_ref.3
 // CHECK:STDOUT:   witness = (file.%import_ref.4)
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: interface @BitOrAssign {
 // CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Op = file.%import_ref.6
-// CHECK:STDOUT:   .Self = file.%import_ref.7
+// CHECK:STDOUT:   .Self = file.%import_ref.6
+// CHECK:STDOUT:   .Op = file.%import_ref.7
 // CHECK:STDOUT:   witness = (file.%import_ref.8)
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: impl @impl.1: C as BitOr {
 // CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.1 [template = constants.%struct.1] {
-// CHECK:STDOUT:     %C.ref.loc9_15: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %self.loc9_9.1: C = param self
-// CHECK:STDOUT:     %self.loc9_9.2: C = bind_name self, %self.loc9_9.1
-// CHECK:STDOUT:     %C.ref.loc9_25: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %other.loc9_18.1: C = param other
-// CHECK:STDOUT:     %other.loc9_18.2: C = bind_name other, %other.loc9_18.1
-// CHECK:STDOUT:     %C.ref.loc9_31: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %C.ref.loc14_15: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %self.loc14_9.1: C = param self
+// CHECK:STDOUT:     %self.loc14_9.2: C = bind_name self, %self.loc14_9.1
+// CHECK:STDOUT:     %C.ref.loc14_25: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %other.loc14_18.1: C = param other
+// CHECK:STDOUT:     %other.loc14_18.2: C = bind_name other, %other.loc14_18.1
+// CHECK:STDOUT:     %C.ref.loc14_31: type = name_ref C, file.%C.decl [template = constants.%C]
 // CHECK:STDOUT:     %return.var: ref C = var <return slot>
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %.1: <witness> = interface_witness (%Op.decl) [template = constants.%.4]
@@ -244,14 +147,14 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:
 // CHECK:STDOUT: impl @impl.2: C as BitOrAssign {
 // CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.3 [template = constants.%struct.4] {
-// CHECK:STDOUT:     %C.ref.loc14_20: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %.loc14_21: type = ptr_type C [template = constants.%.7]
-// CHECK:STDOUT:     %self.loc14_14.1: C* = param self
-// CHECK:STDOUT:     %self.loc14_14.3: C* = bind_name self, %self.loc14_14.1
-// CHECK:STDOUT:     %.loc14_9: C* = addr_pattern %self.loc14_14.3
-// CHECK:STDOUT:     %C.ref.loc14_31: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %other.loc14_24.1: C = param other
-// CHECK:STDOUT:     %other.loc14_24.2: C = bind_name other, %other.loc14_24.1
+// CHECK:STDOUT:     %C.ref.loc19_20: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %.loc19_21: type = ptr_type C [template = constants.%.7]
+// CHECK:STDOUT:     %self.loc19_14.1: C* = param self
+// CHECK:STDOUT:     %self.loc19_14.3: C* = bind_name self, %self.loc19_14.1
+// CHECK:STDOUT:     %.loc19_9: C* = addr_pattern %self.loc19_14.3
+// CHECK:STDOUT:     %C.ref.loc19_31: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %other.loc19_24.1: C = param other
+// CHECK:STDOUT:     %other.loc19_24.2: C = bind_name other, %other.loc19_24.1
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %.1: <witness> = interface_witness (%Op.decl) [template = constants.%.9]
 // CHECK:STDOUT:
@@ -265,17 +168,17 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:   .Self = constants.%C
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.1[@impl.1.%self.loc9_9.2: C](@impl.1.%other.loc9_18.2: C) -> @impl.1.%return.var: C {
+// CHECK:STDOUT: fn @Op.1[@impl.1.%self.loc14_9.2: C](@impl.1.%other.loc14_18.2: C) -> @impl.1.%return.var: C {
 // CHECK:STDOUT: !entry:
-// CHECK:STDOUT:   %.loc10_13.1: {} = struct_literal ()
-// CHECK:STDOUT:   %.loc10_13.2: init C = class_init (), @impl.1.%return.var [template = constants.%struct.3]
-// CHECK:STDOUT:   %.loc10_14: init C = converted %.loc10_13.1, %.loc10_13.2 [template = constants.%struct.3]
-// CHECK:STDOUT:   return %.loc10_14 to @impl.1.%return.var
+// CHECK:STDOUT:   %.loc15_13.1: {} = struct_literal ()
+// CHECK:STDOUT:   %.loc15_13.2: init C = class_init (), @impl.1.%return.var [template = constants.%struct.3]
+// CHECK:STDOUT:   %.loc15_14: init C = converted %.loc15_13.1, %.loc15_13.2 [template = constants.%struct.3]
+// CHECK:STDOUT:   return %.loc15_14 to @impl.1.%return.var
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @Op.2[%self: Self](%other: Self) -> Self;
 // CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.3[addr @impl.2.%self.loc14_14.3: C*](@impl.2.%other.loc14_24.2: C) {
+// CHECK:STDOUT: fn @Op.3[addr @impl.2.%self.loc19_14.3: C*](@impl.2.%other.loc19_24.2: C) {
 // CHECK:STDOUT: !entry:
 // CHECK:STDOUT:   return
 // CHECK:STDOUT: }
@@ -287,21 +190,21 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:   %a.ref: C = name_ref a, %a
 // CHECK:STDOUT:   %b.ref: C = name_ref b, %b
 // CHECK:STDOUT:   %.1: Op = interface_witness_access @impl.1.%.1, element0 [template = constants.%struct.1]
-// CHECK:STDOUT:   %.loc18: <bound method> = bound_method %a.ref, %.1
-// CHECK:STDOUT:   %.loc17: ref C = splice_block %return {}
-// CHECK:STDOUT:   %Op.call: init C = call %.loc18(%a.ref, %b.ref) to %.loc17
+// CHECK:STDOUT:   %.loc23: <bound method> = bound_method %a.ref, %.1
+// CHECK:STDOUT:   %.loc22: ref C = splice_block %return {}
+// CHECK:STDOUT:   %Op.call: init C = call %.loc23(%a.ref, %b.ref) to %.loc22
 // CHECK:STDOUT:   return %Op.call to %return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @TestAssign(%a: C*, %b: C) {
 // CHECK:STDOUT: !entry:
 // CHECK:STDOUT:   %a.ref: C* = name_ref a, %a
-// CHECK:STDOUT:   %.loc22_3.1: ref C = deref %a.ref
+// CHECK:STDOUT:   %.loc27_3.1: ref C = deref %a.ref
 // CHECK:STDOUT:   %b.ref: C = name_ref b, %b
 // CHECK:STDOUT:   %.1: Op = interface_witness_access @impl.2.%.1, element0 [template = constants.%struct.4]
-// CHECK:STDOUT:   %.loc22_6: <bound method> = bound_method %.loc22_3.1, %.1
-// CHECK:STDOUT:   %.loc22_3.2: C* = addr_of %.loc22_3.1
-// CHECK:STDOUT:   %Op.call: init () = call %.loc22_6(%.loc22_3.2, %b.ref)
+// CHECK:STDOUT:   %.loc27_6: <bound method> = bound_method %.loc27_3.1, %.1
+// CHECK:STDOUT:   %.loc27_3.2: C* = addr_of %.loc27_3.1
+// CHECK:STDOUT:   %Op.call: init () = call %.loc27_6(%.loc27_3.2, %b.ref)
 // CHECK:STDOUT:   return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 63 - 160
toolchain/check/testdata/operators/overloaded/bit_xor.carbon

@@ -6,23 +6,8 @@
 
 // This file was generated from binary_op.carbon.tmpl. Run make_tests.sh to regenerate.
 
-// --- prelude.carbon
-
-package Core;
-
-interface BitXor {
-  fn Op[self: Self](other: Self) -> Self;
-}
-interface BitXorAssign {
-  fn Op[addr self: Self*](other: Self);
-}
-
-// --- user.carbon
-
 package User;
 
-import Core;
-
 class C {};
 
 impl C as Core.BitXor {
@@ -42,89 +27,7 @@ fn TestAssign(a: C*, b: C) {
   *a ^= b;
 }
 
-// CHECK:STDOUT: --- prelude.carbon
-// CHECK:STDOUT:
-// CHECK:STDOUT: constants {
-// CHECK:STDOUT:   %.1: type = interface_type @BitXor [template]
-// CHECK:STDOUT:   %Self.1: BitXor = bind_symbolic_name Self 0 [symbolic]
-// CHECK:STDOUT:   %Op.1: type = fn_type @Op.1 [template]
-// CHECK:STDOUT:   %.2: type = tuple_type () [template]
-// CHECK:STDOUT:   %struct.1: Op = struct_value () [template]
-// CHECK:STDOUT:   %.3: type = assoc_entity_type @BitXor, Op [template]
-// CHECK:STDOUT:   %.4: <associated Op in BitXor> = assoc_entity element0, @BitXor.%Op.decl [template]
-// CHECK:STDOUT:   %.5: type = interface_type @BitXorAssign [template]
-// CHECK:STDOUT:   %Self.2: BitXorAssign = bind_symbolic_name Self 0 [symbolic]
-// CHECK:STDOUT:   %.6: type = ptr_type Self [symbolic]
-// CHECK:STDOUT:   %Op.2: type = fn_type @Op.2 [template]
-// CHECK:STDOUT:   %struct.2: Op = struct_value () [template]
-// CHECK:STDOUT:   %.7: type = assoc_entity_type @BitXorAssign, Op [template]
-// CHECK:STDOUT:   %.8: <associated Op in BitXorAssign> = assoc_entity element0, @BitXorAssign.%Op.decl [template]
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace [template] {
-// CHECK:STDOUT:     .BitXor = %BitXor.decl
-// CHECK:STDOUT:     .BitXorAssign = %BitXorAssign.decl
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %BitXor.decl: type = interface_decl @BitXor [template = constants.%.1] {}
-// CHECK:STDOUT:   %BitXorAssign.decl: type = interface_decl @BitXorAssign [template = constants.%.5] {}
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: interface @BitXor {
-// CHECK:STDOUT:   %Self: BitXor = bind_symbolic_name Self 0 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.1 [template = constants.%struct.1] {
-// CHECK:STDOUT:     %Self.ref.loc5_15: BitXor = name_ref Self, %Self [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_15.1: type = facet_type_access %Self.ref.loc5_15 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_15.2: type = converted %Self.ref.loc5_15, %.loc5_15.1 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %self.loc5_9.1: Self = param self
-// CHECK:STDOUT:     %self.loc5_9.2: Self = bind_name self, %self.loc5_9.1
-// CHECK:STDOUT:     %Self.ref.loc5_28: BitXor = name_ref Self, %Self [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_28.1: type = facet_type_access %Self.ref.loc5_28 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_28.2: type = converted %Self.ref.loc5_28, %.loc5_28.1 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %other.loc5_21.1: Self = param other
-// CHECK:STDOUT:     %other.loc5_21.2: Self = bind_name other, %other.loc5_21.1
-// CHECK:STDOUT:     %Self.ref.loc5_37: BitXor = name_ref Self, %Self [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_37.1: type = facet_type_access %Self.ref.loc5_37 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_37.2: type = converted %Self.ref.loc5_37, %.loc5_37.1 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %return.var: ref Self = var <return slot>
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %.loc5_41: <associated Op in BitXor> = assoc_entity element0, %Op.decl [template = constants.%.4]
-// CHECK:STDOUT:
-// CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Self = %Self
-// CHECK:STDOUT:   .Op = %.loc5_41
-// CHECK:STDOUT:   witness = (%Op.decl)
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: interface @BitXorAssign {
-// CHECK:STDOUT:   %Self: BitXorAssign = bind_symbolic_name Self 0 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.2 [template = constants.%struct.2] {
-// CHECK:STDOUT:     %Self.ref.loc8_20: BitXorAssign = name_ref Self, %Self [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_24.1: type = facet_type_access %Self.ref.loc8_20 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_24.2: type = converted %Self.ref.loc8_20, %.loc8_24.1 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_24.3: type = ptr_type Self [symbolic = constants.%.6]
-// CHECK:STDOUT:     %self.loc8_14.1: Self* = param self
-// CHECK:STDOUT:     %self.loc8_14.3: Self* = bind_name self, %self.loc8_14.1
-// CHECK:STDOUT:     %.loc8_9: Self* = addr_pattern %self.loc8_14.3
-// CHECK:STDOUT:     %Self.ref.loc8_34: BitXorAssign = name_ref Self, %Self [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_34.1: type = facet_type_access %Self.ref.loc8_34 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_34.2: type = converted %Self.ref.loc8_34, %.loc8_34.1 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %other.loc8_27.1: Self = param other
-// CHECK:STDOUT:     %other.loc8_27.2: Self = bind_name other, %other.loc8_27.1
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %.loc8_39: <associated Op in BitXorAssign> = assoc_entity element0, %Op.decl [template = constants.%.8]
-// CHECK:STDOUT:
-// CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Self = %Self
-// CHECK:STDOUT:   .Op = %.loc8_39
-// CHECK:STDOUT:   witness = (%Op.decl)
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.1[@BitXor.%self.loc5_9.2: Self](@BitXor.%other.loc5_21.2: Self) -> Self;
-// CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.2[addr @BitXorAssign.%self.loc8_14.3: Self*](@BitXorAssign.%other.loc8_27.2: Self);
-// CHECK:STDOUT:
-// CHECK:STDOUT: --- user.carbon
+// CHECK:STDOUT: --- bit_xor.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: constants {
 // CHECK:STDOUT:   %C: type = class_type @C [template]
@@ -167,72 +70,72 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %Core: <namespace> = namespace [template] {}
 // CHECK:STDOUT:   %C.decl: type = class_decl @C [template = constants.%C] {}
-// CHECK:STDOUT:   %import_ref.1: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.2: <associated Op in BitXor> = import_ref ir2, inst+24, loaded [template = constants.%.11]
-// CHECK:STDOUT:   %import_ref.3 = import_ref ir2, inst+3, unloaded
-// CHECK:STDOUT:   %import_ref.4: Op = import_ref ir2, inst+19, loaded [template = constants.%struct.2]
+// CHECK:STDOUT:   %import_ref.1: type = import_ref ir5, inst+115, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.2 = import_ref ir5, inst+117, unloaded
+// CHECK:STDOUT:   %import_ref.3: <associated Op in BitXor> = import_ref ir5, inst+137, loaded [template = constants.%.11]
+// CHECK:STDOUT:   %import_ref.4: Op = import_ref ir5, inst+133, loaded [template = constants.%struct.2]
 // CHECK:STDOUT:   impl_decl @impl.1 {
-// CHECK:STDOUT:     %C.ref.loc8: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %Core.ref.loc8: <namespace> = name_ref Core, %Core [template = %Core]
+// CHECK:STDOUT:     %C.ref.loc13: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %Core.ref.loc13: <namespace> = name_ref Core, %Core [template = %Core]
 // CHECK:STDOUT:     %BitXor.ref: type = name_ref BitXor, %import_ref.1 [template = constants.%.2]
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.5: type = import_ref ir2, inst+26, loaded [template = constants.%.6]
-// CHECK:STDOUT:   %import_ref.6: <associated Op in BitXorAssign> = import_ref ir2, inst+47, loaded [template = constants.%.13]
-// CHECK:STDOUT:   %import_ref.7 = import_ref ir2, inst+28, unloaded
-// CHECK:STDOUT:   %import_ref.8: Op = import_ref ir2, inst+43, loaded [template = constants.%struct.5]
+// CHECK:STDOUT:   %import_ref.5: type = import_ref ir5, inst+139, loaded [template = constants.%.6]
+// CHECK:STDOUT:   %import_ref.6 = import_ref ir5, inst+141, unloaded
+// CHECK:STDOUT:   %import_ref.7: <associated Op in BitXorAssign> = import_ref ir5, inst+160, loaded [template = constants.%.13]
+// CHECK:STDOUT:   %import_ref.8: Op = import_ref ir5, inst+156, loaded [template = constants.%struct.5]
 // CHECK:STDOUT:   impl_decl @impl.2 {
-// CHECK:STDOUT:     %C.ref.loc13: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %Core.ref.loc13: <namespace> = name_ref Core, %Core [template = %Core]
+// CHECK:STDOUT:     %C.ref.loc18: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %Core.ref.loc18: <namespace> = name_ref Core, %Core [template = %Core]
 // CHECK:STDOUT:     %BitXorAssign.ref: type = name_ref BitXorAssign, %import_ref.5 [template = constants.%.6]
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %TestOp.decl: TestOp = fn_decl @TestOp [template = constants.%struct.6] {
-// CHECK:STDOUT:     %C.ref.loc17_14: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %a.loc17_11.1: C = param a
-// CHECK:STDOUT:     @TestOp.%a: C = bind_name a, %a.loc17_11.1
-// CHECK:STDOUT:     %C.ref.loc17_20: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %b.loc17_17.1: C = param b
-// CHECK:STDOUT:     @TestOp.%b: C = bind_name b, %b.loc17_17.1
-// CHECK:STDOUT:     %C.ref.loc17_26: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %C.ref.loc22_14: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %a.loc22_11.1: C = param a
+// CHECK:STDOUT:     @TestOp.%a: C = bind_name a, %a.loc22_11.1
+// CHECK:STDOUT:     %C.ref.loc22_20: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %b.loc22_17.1: C = param b
+// CHECK:STDOUT:     @TestOp.%b: C = bind_name b, %b.loc22_17.1
+// CHECK:STDOUT:     %C.ref.loc22_26: type = name_ref C, %C.decl [template = constants.%C]
 // CHECK:STDOUT:     @TestOp.%return: ref C = var <return slot>
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.9: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.10 = import_ref ir2, inst+19, unloaded
+// CHECK:STDOUT:   %import_ref.9: type = import_ref ir5, inst+115, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.10 = import_ref ir5, inst+133, unloaded
 // CHECK:STDOUT:   %TestAssign.decl: TestAssign = fn_decl @TestAssign [template = constants.%struct.7] {
-// CHECK:STDOUT:     %C.ref.loc21_18: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %.loc21: type = ptr_type C [template = constants.%.7]
-// CHECK:STDOUT:     %a.loc21_15.1: C* = param a
-// CHECK:STDOUT:     @TestAssign.%a: C* = bind_name a, %a.loc21_15.1
-// CHECK:STDOUT:     %C.ref.loc21_25: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %b.loc21_22.1: C = param b
-// CHECK:STDOUT:     @TestAssign.%b: C = bind_name b, %b.loc21_22.1
+// CHECK:STDOUT:     %C.ref.loc26_18: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %.loc26: type = ptr_type C [template = constants.%.7]
+// CHECK:STDOUT:     %a.loc26_15.1: C* = param a
+// CHECK:STDOUT:     @TestAssign.%a: C* = bind_name a, %a.loc26_15.1
+// CHECK:STDOUT:     %C.ref.loc26_25: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %b.loc26_22.1: C = param b
+// CHECK:STDOUT:     @TestAssign.%b: C = bind_name b, %b.loc26_22.1
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.11: type = import_ref ir2, inst+26, loaded [template = constants.%.6]
-// CHECK:STDOUT:   %import_ref.12 = import_ref ir2, inst+43, unloaded
+// CHECK:STDOUT:   %import_ref.11: type = import_ref ir5, inst+139, loaded [template = constants.%.6]
+// CHECK:STDOUT:   %import_ref.12 = import_ref ir5, inst+156, unloaded
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: interface @BitXor {
 // CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Op = file.%import_ref.2
-// CHECK:STDOUT:   .Self = file.%import_ref.3
+// CHECK:STDOUT:   .Self = file.%import_ref.2
+// CHECK:STDOUT:   .Op = file.%import_ref.3
 // CHECK:STDOUT:   witness = (file.%import_ref.4)
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: interface @BitXorAssign {
 // CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Op = file.%import_ref.6
-// CHECK:STDOUT:   .Self = file.%import_ref.7
+// CHECK:STDOUT:   .Self = file.%import_ref.6
+// CHECK:STDOUT:   .Op = file.%import_ref.7
 // CHECK:STDOUT:   witness = (file.%import_ref.8)
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: impl @impl.1: C as BitXor {
 // CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.1 [template = constants.%struct.1] {
-// CHECK:STDOUT:     %C.ref.loc9_15: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %self.loc9_9.1: C = param self
-// CHECK:STDOUT:     %self.loc9_9.2: C = bind_name self, %self.loc9_9.1
-// CHECK:STDOUT:     %C.ref.loc9_25: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %other.loc9_18.1: C = param other
-// CHECK:STDOUT:     %other.loc9_18.2: C = bind_name other, %other.loc9_18.1
-// CHECK:STDOUT:     %C.ref.loc9_31: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %C.ref.loc14_15: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %self.loc14_9.1: C = param self
+// CHECK:STDOUT:     %self.loc14_9.2: C = bind_name self, %self.loc14_9.1
+// CHECK:STDOUT:     %C.ref.loc14_25: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %other.loc14_18.1: C = param other
+// CHECK:STDOUT:     %other.loc14_18.2: C = bind_name other, %other.loc14_18.1
+// CHECK:STDOUT:     %C.ref.loc14_31: type = name_ref C, file.%C.decl [template = constants.%C]
 // CHECK:STDOUT:     %return.var: ref C = var <return slot>
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %.1: <witness> = interface_witness (%Op.decl) [template = constants.%.4]
@@ -244,14 +147,14 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:
 // CHECK:STDOUT: impl @impl.2: C as BitXorAssign {
 // CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.3 [template = constants.%struct.4] {
-// CHECK:STDOUT:     %C.ref.loc14_20: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %.loc14_21: type = ptr_type C [template = constants.%.7]
-// CHECK:STDOUT:     %self.loc14_14.1: C* = param self
-// CHECK:STDOUT:     %self.loc14_14.3: C* = bind_name self, %self.loc14_14.1
-// CHECK:STDOUT:     %.loc14_9: C* = addr_pattern %self.loc14_14.3
-// CHECK:STDOUT:     %C.ref.loc14_31: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %other.loc14_24.1: C = param other
-// CHECK:STDOUT:     %other.loc14_24.2: C = bind_name other, %other.loc14_24.1
+// CHECK:STDOUT:     %C.ref.loc19_20: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %.loc19_21: type = ptr_type C [template = constants.%.7]
+// CHECK:STDOUT:     %self.loc19_14.1: C* = param self
+// CHECK:STDOUT:     %self.loc19_14.3: C* = bind_name self, %self.loc19_14.1
+// CHECK:STDOUT:     %.loc19_9: C* = addr_pattern %self.loc19_14.3
+// CHECK:STDOUT:     %C.ref.loc19_31: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %other.loc19_24.1: C = param other
+// CHECK:STDOUT:     %other.loc19_24.2: C = bind_name other, %other.loc19_24.1
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %.1: <witness> = interface_witness (%Op.decl) [template = constants.%.9]
 // CHECK:STDOUT:
@@ -265,17 +168,17 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:   .Self = constants.%C
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.1[@impl.1.%self.loc9_9.2: C](@impl.1.%other.loc9_18.2: C) -> @impl.1.%return.var: C {
+// CHECK:STDOUT: fn @Op.1[@impl.1.%self.loc14_9.2: C](@impl.1.%other.loc14_18.2: C) -> @impl.1.%return.var: C {
 // CHECK:STDOUT: !entry:
-// CHECK:STDOUT:   %.loc10_13.1: {} = struct_literal ()
-// CHECK:STDOUT:   %.loc10_13.2: init C = class_init (), @impl.1.%return.var [template = constants.%struct.3]
-// CHECK:STDOUT:   %.loc10_14: init C = converted %.loc10_13.1, %.loc10_13.2 [template = constants.%struct.3]
-// CHECK:STDOUT:   return %.loc10_14 to @impl.1.%return.var
+// CHECK:STDOUT:   %.loc15_13.1: {} = struct_literal ()
+// CHECK:STDOUT:   %.loc15_13.2: init C = class_init (), @impl.1.%return.var [template = constants.%struct.3]
+// CHECK:STDOUT:   %.loc15_14: init C = converted %.loc15_13.1, %.loc15_13.2 [template = constants.%struct.3]
+// CHECK:STDOUT:   return %.loc15_14 to @impl.1.%return.var
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @Op.2[%self: Self](%other: Self) -> Self;
 // CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.3[addr @impl.2.%self.loc14_14.3: C*](@impl.2.%other.loc14_24.2: C) {
+// CHECK:STDOUT: fn @Op.3[addr @impl.2.%self.loc19_14.3: C*](@impl.2.%other.loc19_24.2: C) {
 // CHECK:STDOUT: !entry:
 // CHECK:STDOUT:   return
 // CHECK:STDOUT: }
@@ -287,21 +190,21 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:   %a.ref: C = name_ref a, %a
 // CHECK:STDOUT:   %b.ref: C = name_ref b, %b
 // CHECK:STDOUT:   %.1: Op = interface_witness_access @impl.1.%.1, element0 [template = constants.%struct.1]
-// CHECK:STDOUT:   %.loc18: <bound method> = bound_method %a.ref, %.1
-// CHECK:STDOUT:   %.loc17: ref C = splice_block %return {}
-// CHECK:STDOUT:   %Op.call: init C = call %.loc18(%a.ref, %b.ref) to %.loc17
+// CHECK:STDOUT:   %.loc23: <bound method> = bound_method %a.ref, %.1
+// CHECK:STDOUT:   %.loc22: ref C = splice_block %return {}
+// CHECK:STDOUT:   %Op.call: init C = call %.loc23(%a.ref, %b.ref) to %.loc22
 // CHECK:STDOUT:   return %Op.call to %return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @TestAssign(%a: C*, %b: C) {
 // CHECK:STDOUT: !entry:
 // CHECK:STDOUT:   %a.ref: C* = name_ref a, %a
-// CHECK:STDOUT:   %.loc22_3.1: ref C = deref %a.ref
+// CHECK:STDOUT:   %.loc27_3.1: ref C = deref %a.ref
 // CHECK:STDOUT:   %b.ref: C = name_ref b, %b
 // CHECK:STDOUT:   %.1: Op = interface_witness_access @impl.2.%.1, element0 [template = constants.%struct.4]
-// CHECK:STDOUT:   %.loc22_6: <bound method> = bound_method %.loc22_3.1, %.1
-// CHECK:STDOUT:   %.loc22_3.2: C* = addr_of %.loc22_3.1
-// CHECK:STDOUT:   %Op.call: init () = call %.loc22_6(%.loc22_3.2, %b.ref)
+// CHECK:STDOUT:   %.loc27_6: <bound method> = bound_method %.loc27_3.1, %.1
+// CHECK:STDOUT:   %.loc27_3.2: C* = addr_of %.loc27_3.1
+// CHECK:STDOUT:   %Op.call: init () = call %.loc27_6(%.loc27_3.2, %b.ref)
 // CHECK:STDOUT:   return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 21 - 74
toolchain/check/testdata/operators/overloaded/dec.carbon

@@ -6,20 +6,8 @@
 
 // This file was generated from unary_stmt.carbon.tmpl. Run make_tests.sh to regenerate.
 
-// --- prelude.carbon
-
-package Core;
-
-interface Dec {
-  fn Op[addr self: Self*]();
-}
-
-// --- user.carbon
-
 package User;
 
-import Core;
-
 class C {};
 
 impl C as Core.Dec {
@@ -31,48 +19,7 @@ fn TestOp() {
   --c;
 }
 
-// CHECK:STDOUT: --- prelude.carbon
-// CHECK:STDOUT:
-// CHECK:STDOUT: constants {
-// CHECK:STDOUT:   %.1: type = interface_type @Dec [template]
-// CHECK:STDOUT:   %Self: Dec = bind_symbolic_name Self 0 [symbolic]
-// CHECK:STDOUT:   %.2: type = ptr_type Self [symbolic]
-// CHECK:STDOUT:   %Op: type = fn_type @Op [template]
-// CHECK:STDOUT:   %.3: type = tuple_type () [template]
-// CHECK:STDOUT:   %struct: Op = struct_value () [template]
-// CHECK:STDOUT:   %.4: type = assoc_entity_type @Dec, Op [template]
-// CHECK:STDOUT:   %.5: <associated Op in Dec> = assoc_entity element0, @Dec.%Op.decl [template]
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace [template] {
-// CHECK:STDOUT:     .Dec = %Dec.decl
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %Dec.decl: type = interface_decl @Dec [template = constants.%.1] {}
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: interface @Dec {
-// CHECK:STDOUT:   %Self: Dec = bind_symbolic_name Self 0 [symbolic = constants.%Self]
-// CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op [template = constants.%struct] {
-// CHECK:STDOUT:     %Self.ref: Dec = name_ref Self, %Self [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc5_24.1: type = facet_type_access %Self.ref [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc5_24.2: type = converted %Self.ref, %.loc5_24.1 [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc5_24.3: type = ptr_type Self [symbolic = constants.%.2]
-// CHECK:STDOUT:     %self.loc5_14.1: Self* = param self
-// CHECK:STDOUT:     %self.loc5_14.3: Self* = bind_name self, %self.loc5_14.1
-// CHECK:STDOUT:     %.loc5_9: Self* = addr_pattern %self.loc5_14.3
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %.loc5_28: <associated Op in Dec> = assoc_entity element0, %Op.decl [template = constants.%.5]
-// CHECK:STDOUT:
-// CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Self = %Self
-// CHECK:STDOUT:   .Op = %.loc5_28
-// CHECK:STDOUT:   witness = (%Op.decl)
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op[addr @Dec.%self.loc5_14.3: Self*]();
-// CHECK:STDOUT:
-// CHECK:STDOUT: --- user.carbon
+// CHECK:STDOUT: --- dec.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: constants {
 // CHECK:STDOUT:   %C: type = class_type @C [template]
@@ -103,34 +50,34 @@ fn TestOp() {
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %Core: <namespace> = namespace [template] {}
 // CHECK:STDOUT:   %C.decl: type = class_decl @C [template = constants.%C] {}
-// CHECK:STDOUT:   %import_ref.1: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.2: <associated Op in Dec> = import_ref ir2, inst+18, loaded [template = constants.%.9]
-// CHECK:STDOUT:   %import_ref.3 = import_ref ir2, inst+3, unloaded
-// CHECK:STDOUT:   %import_ref.4: Op = import_ref ir2, inst+13, loaded [template = constants.%struct.2]
+// CHECK:STDOUT:   %import_ref.1: type = import_ref ir4, inst+133, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.2 = import_ref ir4, inst+135, unloaded
+// CHECK:STDOUT:   %import_ref.3: <associated Op in Dec> = import_ref ir4, inst+149, loaded [template = constants.%.9]
+// CHECK:STDOUT:   %import_ref.4: Op = import_ref ir4, inst+145, loaded [template = constants.%struct.2]
 // CHECK:STDOUT:   impl_decl @impl {
 // CHECK:STDOUT:     %C.ref: type = name_ref C, %C.decl [template = constants.%C]
 // CHECK:STDOUT:     %Core.ref: <namespace> = name_ref Core, %Core [template = %Core]
 // CHECK:STDOUT:     %Dec.ref: type = name_ref Dec, %import_ref.1 [template = constants.%.2]
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %TestOp.decl: TestOp = fn_decl @TestOp [template = constants.%struct.3] {}
-// CHECK:STDOUT:   %import_ref.5: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.6 = import_ref ir2, inst+13, unloaded
+// CHECK:STDOUT:   %import_ref.5: type = import_ref ir4, inst+133, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.6 = import_ref ir4, inst+145, unloaded
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: interface @Dec {
 // CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Op = file.%import_ref.2
-// CHECK:STDOUT:   .Self = file.%import_ref.3
+// CHECK:STDOUT:   .Self = file.%import_ref.2
+// CHECK:STDOUT:   .Op = file.%import_ref.3
 // CHECK:STDOUT:   witness = (file.%import_ref.4)
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: impl @impl: C as Dec {
 // CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.1 [template = constants.%struct.1] {
 // CHECK:STDOUT:     %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %.loc9_21: type = ptr_type C [template = constants.%.3]
-// CHECK:STDOUT:     %self.loc9_14.1: C* = param self
-// CHECK:STDOUT:     %self.loc9_14.3: C* = bind_name self, %self.loc9_14.1
-// CHECK:STDOUT:     %.loc9_9: C* = addr_pattern %self.loc9_14.3
+// CHECK:STDOUT:     %.loc14_21: type = ptr_type C [template = constants.%.3]
+// CHECK:STDOUT:     %self.loc14_14.1: C* = param self
+// CHECK:STDOUT:     %self.loc14_14.3: C* = bind_name self, %self.loc14_14.1
+// CHECK:STDOUT:     %.loc14_9: C* = addr_pattern %self.loc14_14.3
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %.1: <witness> = interface_witness (%Op.decl) [template = constants.%.6]
 // CHECK:STDOUT:
@@ -144,7 +91,7 @@ fn TestOp() {
 // CHECK:STDOUT:   .Self = constants.%C
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.1[addr @impl.%self.loc9_14.3: C*]();
+// CHECK:STDOUT: fn @Op.1[addr @impl.%self.loc14_14.3: C*]();
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @Op.2[addr %self: Self*]();
 // CHECK:STDOUT:
@@ -153,15 +100,15 @@ fn TestOp() {
 // CHECK:STDOUT:   %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
 // CHECK:STDOUT:   %c.var: ref C = var c
 // CHECK:STDOUT:   %c: ref C = bind_name c, %c.var
-// CHECK:STDOUT:   %.loc13_15.1: {} = struct_literal ()
-// CHECK:STDOUT:   %.loc13_15.2: init C = class_init (), %c.var [template = constants.%struct.4]
-// CHECK:STDOUT:   %.loc13_16: init C = converted %.loc13_15.1, %.loc13_15.2 [template = constants.%struct.4]
-// CHECK:STDOUT:   assign %c.var, %.loc13_16
+// CHECK:STDOUT:   %.loc18_15.1: {} = struct_literal ()
+// CHECK:STDOUT:   %.loc18_15.2: init C = class_init (), %c.var [template = constants.%struct.4]
+// CHECK:STDOUT:   %.loc18_16: init C = converted %.loc18_15.1, %.loc18_15.2 [template = constants.%struct.4]
+// CHECK:STDOUT:   assign %c.var, %.loc18_16
 // CHECK:STDOUT:   %c.ref: ref C = name_ref c, %c
 // CHECK:STDOUT:   %.1: Op = interface_witness_access @impl.%.1, element0 [template = constants.%struct.1]
-// CHECK:STDOUT:   %.loc14_3: <bound method> = bound_method %c.ref, %.1
-// CHECK:STDOUT:   %.loc14_5: C* = addr_of %c.ref
-// CHECK:STDOUT:   %Op.call: init () = call %.loc14_3(%.loc14_5)
+// CHECK:STDOUT:   %.loc19_3: <bound method> = bound_method %c.ref, %.1
+// CHECK:STDOUT:   %.loc19_5: C* = addr_of %c.ref
+// CHECK:STDOUT:   %Op.call: init () = call %.loc19_3(%.loc19_5)
 // CHECK:STDOUT:   return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 63 - 160
toolchain/check/testdata/operators/overloaded/div.carbon

@@ -6,23 +6,8 @@
 
 // This file was generated from binary_op.carbon.tmpl. Run make_tests.sh to regenerate.
 
-// --- prelude.carbon
-
-package Core;
-
-interface Div {
-  fn Op[self: Self](other: Self) -> Self;
-}
-interface DivAssign {
-  fn Op[addr self: Self*](other: Self);
-}
-
-// --- user.carbon
-
 package User;
 
-import Core;
-
 class C {};
 
 impl C as Core.Div {
@@ -42,89 +27,7 @@ fn TestAssign(a: C*, b: C) {
   *a /= b;
 }
 
-// CHECK:STDOUT: --- prelude.carbon
-// CHECK:STDOUT:
-// CHECK:STDOUT: constants {
-// CHECK:STDOUT:   %.1: type = interface_type @Div [template]
-// CHECK:STDOUT:   %Self.1: Div = bind_symbolic_name Self 0 [symbolic]
-// CHECK:STDOUT:   %Op.1: type = fn_type @Op.1 [template]
-// CHECK:STDOUT:   %.2: type = tuple_type () [template]
-// CHECK:STDOUT:   %struct.1: Op = struct_value () [template]
-// CHECK:STDOUT:   %.3: type = assoc_entity_type @Div, Op [template]
-// CHECK:STDOUT:   %.4: <associated Op in Div> = assoc_entity element0, @Div.%Op.decl [template]
-// CHECK:STDOUT:   %.5: type = interface_type @DivAssign [template]
-// CHECK:STDOUT:   %Self.2: DivAssign = bind_symbolic_name Self 0 [symbolic]
-// CHECK:STDOUT:   %.6: type = ptr_type Self [symbolic]
-// CHECK:STDOUT:   %Op.2: type = fn_type @Op.2 [template]
-// CHECK:STDOUT:   %struct.2: Op = struct_value () [template]
-// CHECK:STDOUT:   %.7: type = assoc_entity_type @DivAssign, Op [template]
-// CHECK:STDOUT:   %.8: <associated Op in DivAssign> = assoc_entity element0, @DivAssign.%Op.decl [template]
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace [template] {
-// CHECK:STDOUT:     .Div = %Div.decl
-// CHECK:STDOUT:     .DivAssign = %DivAssign.decl
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %Div.decl: type = interface_decl @Div [template = constants.%.1] {}
-// CHECK:STDOUT:   %DivAssign.decl: type = interface_decl @DivAssign [template = constants.%.5] {}
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: interface @Div {
-// CHECK:STDOUT:   %Self: Div = bind_symbolic_name Self 0 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.1 [template = constants.%struct.1] {
-// CHECK:STDOUT:     %Self.ref.loc5_15: Div = name_ref Self, %Self [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_15.1: type = facet_type_access %Self.ref.loc5_15 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_15.2: type = converted %Self.ref.loc5_15, %.loc5_15.1 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %self.loc5_9.1: Self = param self
-// CHECK:STDOUT:     %self.loc5_9.2: Self = bind_name self, %self.loc5_9.1
-// CHECK:STDOUT:     %Self.ref.loc5_28: Div = name_ref Self, %Self [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_28.1: type = facet_type_access %Self.ref.loc5_28 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_28.2: type = converted %Self.ref.loc5_28, %.loc5_28.1 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %other.loc5_21.1: Self = param other
-// CHECK:STDOUT:     %other.loc5_21.2: Self = bind_name other, %other.loc5_21.1
-// CHECK:STDOUT:     %Self.ref.loc5_37: Div = name_ref Self, %Self [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_37.1: type = facet_type_access %Self.ref.loc5_37 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_37.2: type = converted %Self.ref.loc5_37, %.loc5_37.1 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %return.var: ref Self = var <return slot>
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %.loc5_41: <associated Op in Div> = assoc_entity element0, %Op.decl [template = constants.%.4]
-// CHECK:STDOUT:
-// CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Self = %Self
-// CHECK:STDOUT:   .Op = %.loc5_41
-// CHECK:STDOUT:   witness = (%Op.decl)
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: interface @DivAssign {
-// CHECK:STDOUT:   %Self: DivAssign = bind_symbolic_name Self 0 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.2 [template = constants.%struct.2] {
-// CHECK:STDOUT:     %Self.ref.loc8_20: DivAssign = name_ref Self, %Self [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_24.1: type = facet_type_access %Self.ref.loc8_20 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_24.2: type = converted %Self.ref.loc8_20, %.loc8_24.1 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_24.3: type = ptr_type Self [symbolic = constants.%.6]
-// CHECK:STDOUT:     %self.loc8_14.1: Self* = param self
-// CHECK:STDOUT:     %self.loc8_14.3: Self* = bind_name self, %self.loc8_14.1
-// CHECK:STDOUT:     %.loc8_9: Self* = addr_pattern %self.loc8_14.3
-// CHECK:STDOUT:     %Self.ref.loc8_34: DivAssign = name_ref Self, %Self [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_34.1: type = facet_type_access %Self.ref.loc8_34 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_34.2: type = converted %Self.ref.loc8_34, %.loc8_34.1 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %other.loc8_27.1: Self = param other
-// CHECK:STDOUT:     %other.loc8_27.2: Self = bind_name other, %other.loc8_27.1
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %.loc8_39: <associated Op in DivAssign> = assoc_entity element0, %Op.decl [template = constants.%.8]
-// CHECK:STDOUT:
-// CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Self = %Self
-// CHECK:STDOUT:   .Op = %.loc8_39
-// CHECK:STDOUT:   witness = (%Op.decl)
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.1[@Div.%self.loc5_9.2: Self](@Div.%other.loc5_21.2: Self) -> Self;
-// CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.2[addr @DivAssign.%self.loc8_14.3: Self*](@DivAssign.%other.loc8_27.2: Self);
-// CHECK:STDOUT:
-// CHECK:STDOUT: --- user.carbon
+// CHECK:STDOUT: --- div.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: constants {
 // CHECK:STDOUT:   %C: type = class_type @C [template]
@@ -167,72 +70,72 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %Core: <namespace> = namespace [template] {}
 // CHECK:STDOUT:   %C.decl: type = class_decl @C [template = constants.%C] {}
-// CHECK:STDOUT:   %import_ref.1: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.2: <associated Op in Div> = import_ref ir2, inst+24, loaded [template = constants.%.11]
-// CHECK:STDOUT:   %import_ref.3 = import_ref ir2, inst+3, unloaded
-// CHECK:STDOUT:   %import_ref.4: Op = import_ref ir2, inst+19, loaded [template = constants.%struct.2]
+// CHECK:STDOUT:   %import_ref.1: type = import_ref ir4, inst+198, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.2 = import_ref ir4, inst+200, unloaded
+// CHECK:STDOUT:   %import_ref.3: <associated Op in Div> = import_ref ir4, inst+220, loaded [template = constants.%.11]
+// CHECK:STDOUT:   %import_ref.4: Op = import_ref ir4, inst+216, loaded [template = constants.%struct.2]
 // CHECK:STDOUT:   impl_decl @impl.1 {
-// CHECK:STDOUT:     %C.ref.loc8: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %Core.ref.loc8: <namespace> = name_ref Core, %Core [template = %Core]
+// CHECK:STDOUT:     %C.ref.loc13: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %Core.ref.loc13: <namespace> = name_ref Core, %Core [template = %Core]
 // CHECK:STDOUT:     %Div.ref: type = name_ref Div, %import_ref.1 [template = constants.%.2]
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.5: type = import_ref ir2, inst+26, loaded [template = constants.%.6]
-// CHECK:STDOUT:   %import_ref.6: <associated Op in DivAssign> = import_ref ir2, inst+47, loaded [template = constants.%.13]
-// CHECK:STDOUT:   %import_ref.7 = import_ref ir2, inst+28, unloaded
-// CHECK:STDOUT:   %import_ref.8: Op = import_ref ir2, inst+43, loaded [template = constants.%struct.5]
+// CHECK:STDOUT:   %import_ref.5: type = import_ref ir4, inst+222, loaded [template = constants.%.6]
+// CHECK:STDOUT:   %import_ref.6 = import_ref ir4, inst+224, unloaded
+// CHECK:STDOUT:   %import_ref.7: <associated Op in DivAssign> = import_ref ir4, inst+243, loaded [template = constants.%.13]
+// CHECK:STDOUT:   %import_ref.8: Op = import_ref ir4, inst+239, loaded [template = constants.%struct.5]
 // CHECK:STDOUT:   impl_decl @impl.2 {
-// CHECK:STDOUT:     %C.ref.loc13: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %Core.ref.loc13: <namespace> = name_ref Core, %Core [template = %Core]
+// CHECK:STDOUT:     %C.ref.loc18: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %Core.ref.loc18: <namespace> = name_ref Core, %Core [template = %Core]
 // CHECK:STDOUT:     %DivAssign.ref: type = name_ref DivAssign, %import_ref.5 [template = constants.%.6]
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %TestOp.decl: TestOp = fn_decl @TestOp [template = constants.%struct.6] {
-// CHECK:STDOUT:     %C.ref.loc17_14: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %a.loc17_11.1: C = param a
-// CHECK:STDOUT:     @TestOp.%a: C = bind_name a, %a.loc17_11.1
-// CHECK:STDOUT:     %C.ref.loc17_20: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %b.loc17_17.1: C = param b
-// CHECK:STDOUT:     @TestOp.%b: C = bind_name b, %b.loc17_17.1
-// CHECK:STDOUT:     %C.ref.loc17_26: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %C.ref.loc22_14: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %a.loc22_11.1: C = param a
+// CHECK:STDOUT:     @TestOp.%a: C = bind_name a, %a.loc22_11.1
+// CHECK:STDOUT:     %C.ref.loc22_20: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %b.loc22_17.1: C = param b
+// CHECK:STDOUT:     @TestOp.%b: C = bind_name b, %b.loc22_17.1
+// CHECK:STDOUT:     %C.ref.loc22_26: type = name_ref C, %C.decl [template = constants.%C]
 // CHECK:STDOUT:     @TestOp.%return: ref C = var <return slot>
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.9: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.10 = import_ref ir2, inst+19, unloaded
+// CHECK:STDOUT:   %import_ref.9: type = import_ref ir4, inst+198, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.10 = import_ref ir4, inst+216, unloaded
 // CHECK:STDOUT:   %TestAssign.decl: TestAssign = fn_decl @TestAssign [template = constants.%struct.7] {
-// CHECK:STDOUT:     %C.ref.loc21_18: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %.loc21: type = ptr_type C [template = constants.%.7]
-// CHECK:STDOUT:     %a.loc21_15.1: C* = param a
-// CHECK:STDOUT:     @TestAssign.%a: C* = bind_name a, %a.loc21_15.1
-// CHECK:STDOUT:     %C.ref.loc21_25: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %b.loc21_22.1: C = param b
-// CHECK:STDOUT:     @TestAssign.%b: C = bind_name b, %b.loc21_22.1
+// CHECK:STDOUT:     %C.ref.loc26_18: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %.loc26: type = ptr_type C [template = constants.%.7]
+// CHECK:STDOUT:     %a.loc26_15.1: C* = param a
+// CHECK:STDOUT:     @TestAssign.%a: C* = bind_name a, %a.loc26_15.1
+// CHECK:STDOUT:     %C.ref.loc26_25: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %b.loc26_22.1: C = param b
+// CHECK:STDOUT:     @TestAssign.%b: C = bind_name b, %b.loc26_22.1
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.11: type = import_ref ir2, inst+26, loaded [template = constants.%.6]
-// CHECK:STDOUT:   %import_ref.12 = import_ref ir2, inst+43, unloaded
+// CHECK:STDOUT:   %import_ref.11: type = import_ref ir4, inst+222, loaded [template = constants.%.6]
+// CHECK:STDOUT:   %import_ref.12 = import_ref ir4, inst+239, unloaded
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: interface @Div {
 // CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Op = file.%import_ref.2
-// CHECK:STDOUT:   .Self = file.%import_ref.3
+// CHECK:STDOUT:   .Self = file.%import_ref.2
+// CHECK:STDOUT:   .Op = file.%import_ref.3
 // CHECK:STDOUT:   witness = (file.%import_ref.4)
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: interface @DivAssign {
 // CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Op = file.%import_ref.6
-// CHECK:STDOUT:   .Self = file.%import_ref.7
+// CHECK:STDOUT:   .Self = file.%import_ref.6
+// CHECK:STDOUT:   .Op = file.%import_ref.7
 // CHECK:STDOUT:   witness = (file.%import_ref.8)
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: impl @impl.1: C as Div {
 // CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.1 [template = constants.%struct.1] {
-// CHECK:STDOUT:     %C.ref.loc9_15: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %self.loc9_9.1: C = param self
-// CHECK:STDOUT:     %self.loc9_9.2: C = bind_name self, %self.loc9_9.1
-// CHECK:STDOUT:     %C.ref.loc9_25: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %other.loc9_18.1: C = param other
-// CHECK:STDOUT:     %other.loc9_18.2: C = bind_name other, %other.loc9_18.1
-// CHECK:STDOUT:     %C.ref.loc9_31: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %C.ref.loc14_15: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %self.loc14_9.1: C = param self
+// CHECK:STDOUT:     %self.loc14_9.2: C = bind_name self, %self.loc14_9.1
+// CHECK:STDOUT:     %C.ref.loc14_25: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %other.loc14_18.1: C = param other
+// CHECK:STDOUT:     %other.loc14_18.2: C = bind_name other, %other.loc14_18.1
+// CHECK:STDOUT:     %C.ref.loc14_31: type = name_ref C, file.%C.decl [template = constants.%C]
 // CHECK:STDOUT:     %return.var: ref C = var <return slot>
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %.1: <witness> = interface_witness (%Op.decl) [template = constants.%.4]
@@ -244,14 +147,14 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:
 // CHECK:STDOUT: impl @impl.2: C as DivAssign {
 // CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.3 [template = constants.%struct.4] {
-// CHECK:STDOUT:     %C.ref.loc14_20: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %.loc14_21: type = ptr_type C [template = constants.%.7]
-// CHECK:STDOUT:     %self.loc14_14.1: C* = param self
-// CHECK:STDOUT:     %self.loc14_14.3: C* = bind_name self, %self.loc14_14.1
-// CHECK:STDOUT:     %.loc14_9: C* = addr_pattern %self.loc14_14.3
-// CHECK:STDOUT:     %C.ref.loc14_31: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %other.loc14_24.1: C = param other
-// CHECK:STDOUT:     %other.loc14_24.2: C = bind_name other, %other.loc14_24.1
+// CHECK:STDOUT:     %C.ref.loc19_20: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %.loc19_21: type = ptr_type C [template = constants.%.7]
+// CHECK:STDOUT:     %self.loc19_14.1: C* = param self
+// CHECK:STDOUT:     %self.loc19_14.3: C* = bind_name self, %self.loc19_14.1
+// CHECK:STDOUT:     %.loc19_9: C* = addr_pattern %self.loc19_14.3
+// CHECK:STDOUT:     %C.ref.loc19_31: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %other.loc19_24.1: C = param other
+// CHECK:STDOUT:     %other.loc19_24.2: C = bind_name other, %other.loc19_24.1
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %.1: <witness> = interface_witness (%Op.decl) [template = constants.%.9]
 // CHECK:STDOUT:
@@ -265,17 +168,17 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:   .Self = constants.%C
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.1[@impl.1.%self.loc9_9.2: C](@impl.1.%other.loc9_18.2: C) -> @impl.1.%return.var: C {
+// CHECK:STDOUT: fn @Op.1[@impl.1.%self.loc14_9.2: C](@impl.1.%other.loc14_18.2: C) -> @impl.1.%return.var: C {
 // CHECK:STDOUT: !entry:
-// CHECK:STDOUT:   %.loc10_13.1: {} = struct_literal ()
-// CHECK:STDOUT:   %.loc10_13.2: init C = class_init (), @impl.1.%return.var [template = constants.%struct.3]
-// CHECK:STDOUT:   %.loc10_14: init C = converted %.loc10_13.1, %.loc10_13.2 [template = constants.%struct.3]
-// CHECK:STDOUT:   return %.loc10_14 to @impl.1.%return.var
+// CHECK:STDOUT:   %.loc15_13.1: {} = struct_literal ()
+// CHECK:STDOUT:   %.loc15_13.2: init C = class_init (), @impl.1.%return.var [template = constants.%struct.3]
+// CHECK:STDOUT:   %.loc15_14: init C = converted %.loc15_13.1, %.loc15_13.2 [template = constants.%struct.3]
+// CHECK:STDOUT:   return %.loc15_14 to @impl.1.%return.var
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @Op.2[%self: Self](%other: Self) -> Self;
 // CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.3[addr @impl.2.%self.loc14_14.3: C*](@impl.2.%other.loc14_24.2: C) {
+// CHECK:STDOUT: fn @Op.3[addr @impl.2.%self.loc19_14.3: C*](@impl.2.%other.loc19_24.2: C) {
 // CHECK:STDOUT: !entry:
 // CHECK:STDOUT:   return
 // CHECK:STDOUT: }
@@ -287,21 +190,21 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:   %a.ref: C = name_ref a, %a
 // CHECK:STDOUT:   %b.ref: C = name_ref b, %b
 // CHECK:STDOUT:   %.1: Op = interface_witness_access @impl.1.%.1, element0 [template = constants.%struct.1]
-// CHECK:STDOUT:   %.loc18: <bound method> = bound_method %a.ref, %.1
-// CHECK:STDOUT:   %.loc17: ref C = splice_block %return {}
-// CHECK:STDOUT:   %Op.call: init C = call %.loc18(%a.ref, %b.ref) to %.loc17
+// CHECK:STDOUT:   %.loc23: <bound method> = bound_method %a.ref, %.1
+// CHECK:STDOUT:   %.loc22: ref C = splice_block %return {}
+// CHECK:STDOUT:   %Op.call: init C = call %.loc23(%a.ref, %b.ref) to %.loc22
 // CHECK:STDOUT:   return %Op.call to %return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @TestAssign(%a: C*, %b: C) {
 // CHECK:STDOUT: !entry:
 // CHECK:STDOUT:   %a.ref: C* = name_ref a, %a
-// CHECK:STDOUT:   %.loc22_3.1: ref C = deref %a.ref
+// CHECK:STDOUT:   %.loc27_3.1: ref C = deref %a.ref
 // CHECK:STDOUT:   %b.ref: C = name_ref b, %b
 // CHECK:STDOUT:   %.1: Op = interface_witness_access @impl.2.%.1, element0 [template = constants.%struct.4]
-// CHECK:STDOUT:   %.loc22_6: <bound method> = bound_method %.loc22_3.1, %.1
-// CHECK:STDOUT:   %.loc22_3.2: C* = addr_of %.loc22_3.1
-// CHECK:STDOUT:   %Op.call: init () = call %.loc22_6(%.loc22_3.2, %b.ref)
+// CHECK:STDOUT:   %.loc27_6: <bound method> = bound_method %.loc27_3.1, %.1
+// CHECK:STDOUT:   %.loc27_3.2: C* = addr_of %.loc27_3.1
+// CHECK:STDOUT:   %Op.call: init () = call %.loc27_6(%.loc27_3.2, %b.ref)
 // CHECK:STDOUT:   return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 114 - 196
toolchain/check/testdata/operators/overloaded/eq.carbon

@@ -4,23 +4,10 @@
 //
 // AUTOUPDATE
 
-// --- prelude.carbon
-
-package Core;
-
-import library "prelude";
-
-interface Eq {
-  fn Equal[self: Self](other: Self) -> bool;
-  fn NotEqual[self: Self](other: Self) -> bool;
-}
-
 // --- user.carbon
 
 package User;
 
-import Core;
-
 class C {};
 
 impl C as Core.Eq {
@@ -40,8 +27,6 @@ fn TestNotEqual(a: C, b: C) -> bool {
 
 package FailNoImpl;
 
-import Core;
-
 class D {};
 
 fn TestEqual(a: D, b: D) -> bool {
@@ -64,8 +49,6 @@ fn TestNotEqual(a: D, b: D) -> bool {
 
 package FailNoImplForArgs;
 
-import Core;
-
 class C {};
 class D {};
 
@@ -92,71 +75,6 @@ fn TestLhsBad(a: D, b: C) -> bool {
   return a != b;
 }
 
-// CHECK:STDOUT: --- prelude.carbon
-// CHECK:STDOUT:
-// CHECK:STDOUT: constants {
-// CHECK:STDOUT:   %.1: type = interface_type @Eq [template]
-// CHECK:STDOUT:   %Self: Eq = bind_symbolic_name Self 0 [symbolic]
-// CHECK:STDOUT:   %Equal: type = fn_type @Equal [template]
-// CHECK:STDOUT:   %.2: type = tuple_type () [template]
-// CHECK:STDOUT:   %struct.1: Equal = struct_value () [template]
-// CHECK:STDOUT:   %.3: type = assoc_entity_type @Eq, Equal [template]
-// CHECK:STDOUT:   %.4: <associated Equal in Eq> = assoc_entity element0, @Eq.%Equal.decl [template]
-// CHECK:STDOUT:   %NotEqual: type = fn_type @NotEqual [template]
-// CHECK:STDOUT:   %struct.2: NotEqual = struct_value () [template]
-// CHECK:STDOUT:   %.5: type = assoc_entity_type @Eq, NotEqual [template]
-// CHECK:STDOUT:   %.6: <associated NotEqual in Eq> = assoc_entity element1, @Eq.%NotEqual.decl [template]
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace [template] {
-// CHECK:STDOUT:     .Eq = %Eq.decl
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %Eq.decl: type = interface_decl @Eq [template = constants.%.1] {}
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: interface @Eq {
-// CHECK:STDOUT:   %Self: Eq = bind_symbolic_name Self 0 [symbolic = constants.%Self]
-// CHECK:STDOUT:   %Equal.decl: Equal = fn_decl @Equal [template = constants.%struct.1] {
-// CHECK:STDOUT:     %Self.ref.loc7_18: Eq = name_ref Self, %Self [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc7_18.1: type = facet_type_access %Self.ref.loc7_18 [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc7_18.2: type = converted %Self.ref.loc7_18, %.loc7_18.1 [symbolic = constants.%Self]
-// CHECK:STDOUT:     %self.loc7_12.1: Self = param self
-// CHECK:STDOUT:     %self.loc7_12.2: Self = bind_name self, %self.loc7_12.1
-// CHECK:STDOUT:     %Self.ref.loc7_31: Eq = name_ref Self, %Self [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc7_31.1: type = facet_type_access %Self.ref.loc7_31 [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc7_31.2: type = converted %Self.ref.loc7_31, %.loc7_31.1 [symbolic = constants.%Self]
-// CHECK:STDOUT:     %other.loc7_24.1: Self = param other
-// CHECK:STDOUT:     %other.loc7_24.2: Self = bind_name other, %other.loc7_24.1
-// CHECK:STDOUT:     %return.var.loc7: ref bool = var <return slot>
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %.loc7_44: <associated Equal in Eq> = assoc_entity element0, %Equal.decl [template = constants.%.4]
-// CHECK:STDOUT:   %NotEqual.decl: NotEqual = fn_decl @NotEqual [template = constants.%struct.2] {
-// CHECK:STDOUT:     %Self.ref.loc8_21: Eq = name_ref Self, %Self [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc8_21.1: type = facet_type_access %Self.ref.loc8_21 [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc8_21.2: type = converted %Self.ref.loc8_21, %.loc8_21.1 [symbolic = constants.%Self]
-// CHECK:STDOUT:     %self.loc8_15.1: Self = param self
-// CHECK:STDOUT:     %self.loc8_15.2: Self = bind_name self, %self.loc8_15.1
-// CHECK:STDOUT:     %Self.ref.loc8_34: Eq = name_ref Self, %Self [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc8_34.1: type = facet_type_access %Self.ref.loc8_34 [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc8_34.2: type = converted %Self.ref.loc8_34, %.loc8_34.1 [symbolic = constants.%Self]
-// CHECK:STDOUT:     %other.loc8_27.1: Self = param other
-// CHECK:STDOUT:     %other.loc8_27.2: Self = bind_name other, %other.loc8_27.1
-// CHECK:STDOUT:     %return.var.loc8: ref bool = var <return slot>
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %.loc8_47: <associated NotEqual in Eq> = assoc_entity element1, %NotEqual.decl [template = constants.%.6]
-// CHECK:STDOUT:
-// CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Self = %Self
-// CHECK:STDOUT:   .Equal = %.loc7_44
-// CHECK:STDOUT:   .NotEqual = %.loc8_47
-// CHECK:STDOUT:   witness = (%Equal.decl, %NotEqual.decl)
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: fn @Equal[@Eq.%self.loc7_12.2: Self](@Eq.%other.loc7_24.2: Self) -> bool;
-// CHECK:STDOUT:
-// CHECK:STDOUT: fn @NotEqual[@Eq.%self.loc8_15.2: Self](@Eq.%other.loc8_27.2: Self) -> bool;
-// CHECK:STDOUT:
 // CHECK:STDOUT: --- user.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: constants {
@@ -194,39 +112,39 @@ fn TestLhsBad(a: D, b: C) -> bool {
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %Core: <namespace> = namespace [template] {}
 // CHECK:STDOUT:   %C.decl: type = class_decl @C [template = constants.%C] {}
-// CHECK:STDOUT:   %import_ref.1: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.2 = import_ref ir2, inst+3, unloaded
-// CHECK:STDOUT:   %import_ref.3: <associated Equal in Eq> = import_ref ir2, inst+21, loaded [template = constants.%.7]
-// CHECK:STDOUT:   %import_ref.4: <associated NotEqual in Eq> = import_ref ir2, inst+38, loaded [template = constants.%.9]
-// CHECK:STDOUT:   %import_ref.5: Equal = import_ref ir2, inst+16, loaded [template = constants.%struct.3]
-// CHECK:STDOUT:   %import_ref.6: NotEqual = import_ref ir2, inst+34, loaded [template = constants.%struct.4]
+// CHECK:STDOUT:   %import_ref.1: type = import_ref ir6, inst+1, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.2 = import_ref ir6, inst+3, unloaded
+// CHECK:STDOUT:   %import_ref.3: <associated Equal in Eq> = import_ref ir6, inst+21, loaded [template = constants.%.7]
+// CHECK:STDOUT:   %import_ref.4: <associated NotEqual in Eq> = import_ref ir6, inst+38, loaded [template = constants.%.9]
+// CHECK:STDOUT:   %import_ref.5: Equal = import_ref ir6, inst+16, loaded [template = constants.%struct.3]
+// CHECK:STDOUT:   %import_ref.6: NotEqual = import_ref ir6, inst+34, loaded [template = constants.%struct.4]
 // CHECK:STDOUT:   impl_decl @impl {
-// CHECK:STDOUT:     %C.ref.loc8: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %C.ref.loc6: type = name_ref C, %C.decl [template = constants.%C]
 // CHECK:STDOUT:     %Core.ref: <namespace> = name_ref Core, %Core [template = %Core]
 // CHECK:STDOUT:     %Eq.ref: type = name_ref Eq, %import_ref.1 [template = constants.%.2]
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %TestEqual.decl: TestEqual = fn_decl @TestEqual [template = constants.%struct.5] {
-// CHECK:STDOUT:     %C.ref.loc13_17: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %a.loc13_14.1: C = param a
-// CHECK:STDOUT:     @TestEqual.%a: C = bind_name a, %a.loc13_14.1
-// CHECK:STDOUT:     %C.ref.loc13_23: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %b.loc13_20.1: C = param b
-// CHECK:STDOUT:     @TestEqual.%b: C = bind_name b, %b.loc13_20.1
+// CHECK:STDOUT:     %C.ref.loc11_17: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %a.loc11_14.1: C = param a
+// CHECK:STDOUT:     @TestEqual.%a: C = bind_name a, %a.loc11_14.1
+// CHECK:STDOUT:     %C.ref.loc11_23: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %b.loc11_20.1: C = param b
+// CHECK:STDOUT:     @TestEqual.%b: C = bind_name b, %b.loc11_20.1
 // CHECK:STDOUT:     @TestEqual.%return: ref bool = var <return slot>
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.7: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.8 = import_ref ir2, inst+16, unloaded
+// CHECK:STDOUT:   %import_ref.7: type = import_ref ir6, inst+1, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.8 = import_ref ir6, inst+16, unloaded
 // CHECK:STDOUT:   %TestNotEqual.decl: TestNotEqual = fn_decl @TestNotEqual [template = constants.%struct.6] {
-// CHECK:STDOUT:     %C.ref.loc17_20: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %a.loc17_17.1: C = param a
-// CHECK:STDOUT:     @TestNotEqual.%a: C = bind_name a, %a.loc17_17.1
-// CHECK:STDOUT:     %C.ref.loc17_26: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %b.loc17_23.1: C = param b
-// CHECK:STDOUT:     @TestNotEqual.%b: C = bind_name b, %b.loc17_23.1
+// CHECK:STDOUT:     %C.ref.loc15_20: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %a.loc15_17.1: C = param a
+// CHECK:STDOUT:     @TestNotEqual.%a: C = bind_name a, %a.loc15_17.1
+// CHECK:STDOUT:     %C.ref.loc15_26: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %b.loc15_23.1: C = param b
+// CHECK:STDOUT:     @TestNotEqual.%b: C = bind_name b, %b.loc15_23.1
 // CHECK:STDOUT:     @TestNotEqual.%return: ref bool = var <return slot>
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.9: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.10 = import_ref ir2, inst+34, unloaded
+// CHECK:STDOUT:   %import_ref.9: type = import_ref ir6, inst+1, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.10 = import_ref ir6, inst+34, unloaded
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: interface @Eq {
@@ -239,22 +157,22 @@ fn TestLhsBad(a: D, b: C) -> bool {
 // CHECK:STDOUT:
 // CHECK:STDOUT: impl @impl: C as Eq {
 // CHECK:STDOUT:   %Equal.decl: Equal = fn_decl @Equal.1 [template = constants.%struct.1] {
-// CHECK:STDOUT:     %C.ref.loc9_18: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %self.loc9_12.1: C = param self
-// CHECK:STDOUT:     %self.loc9_12.2: C = bind_name self, %self.loc9_12.1
-// CHECK:STDOUT:     %C.ref.loc9_28: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %other.loc9_21.1: C = param other
-// CHECK:STDOUT:     %other.loc9_21.2: C = bind_name other, %other.loc9_21.1
-// CHECK:STDOUT:     %return.var.loc9: ref bool = var <return slot>
+// CHECK:STDOUT:     %C.ref.loc7_18: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %self.loc7_12.1: C = param self
+// CHECK:STDOUT:     %self.loc7_12.2: C = bind_name self, %self.loc7_12.1
+// CHECK:STDOUT:     %C.ref.loc7_28: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %other.loc7_21.1: C = param other
+// CHECK:STDOUT:     %other.loc7_21.2: C = bind_name other, %other.loc7_21.1
+// CHECK:STDOUT:     %return.var.loc7: ref bool = var <return slot>
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %NotEqual.decl: NotEqual = fn_decl @NotEqual.1 [template = constants.%struct.2] {
-// CHECK:STDOUT:     %C.ref.loc10_21: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %self.loc10_15.1: C = param self
-// CHECK:STDOUT:     %self.loc10_15.2: C = bind_name self, %self.loc10_15.1
-// CHECK:STDOUT:     %C.ref.loc10_31: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %other.loc10_24.1: C = param other
-// CHECK:STDOUT:     %other.loc10_24.2: C = bind_name other, %other.loc10_24.1
-// CHECK:STDOUT:     %return.var.loc10: ref bool = var <return slot>
+// CHECK:STDOUT:     %C.ref.loc8_21: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %self.loc8_15.1: C = param self
+// CHECK:STDOUT:     %self.loc8_15.2: C = bind_name self, %self.loc8_15.1
+// CHECK:STDOUT:     %C.ref.loc8_31: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %other.loc8_24.1: C = param other
+// CHECK:STDOUT:     %other.loc8_24.2: C = bind_name other, %other.loc8_24.1
+// CHECK:STDOUT:     %return.var.loc8: ref bool = var <return slot>
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %.1: <witness> = interface_witness (%Equal.decl, %NotEqual.decl) [template = constants.%.4]
 // CHECK:STDOUT:
@@ -269,9 +187,9 @@ fn TestLhsBad(a: D, b: C) -> bool {
 // CHECK:STDOUT:   .Self = constants.%C
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: fn @Equal.1[@impl.%self.loc9_12.2: C](@impl.%other.loc9_21.2: C) -> bool;
+// CHECK:STDOUT: fn @Equal.1[@impl.%self.loc7_12.2: C](@impl.%other.loc7_21.2: C) -> bool;
 // CHECK:STDOUT:
-// CHECK:STDOUT: fn @NotEqual.1[@impl.%self.loc10_15.2: C](@impl.%other.loc10_24.2: C) -> bool;
+// CHECK:STDOUT: fn @NotEqual.1[@impl.%self.loc8_15.2: C](@impl.%other.loc8_24.2: C) -> bool;
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @Equal.2[%self: Self](%other: Self) -> bool;
 // CHECK:STDOUT:
@@ -282,11 +200,11 @@ fn TestLhsBad(a: D, b: C) -> bool {
 // CHECK:STDOUT:   %a.ref: C = name_ref a, %a
 // CHECK:STDOUT:   %b.ref: C = name_ref b, %b
 // CHECK:STDOUT:   %.1: Equal = interface_witness_access @impl.%.1, element0 [template = constants.%struct.1]
-// CHECK:STDOUT:   %.loc14_12: <bound method> = bound_method %a.ref, %.1
-// CHECK:STDOUT:   %Equal.call: init bool = call %.loc14_12(%a.ref, %b.ref)
-// CHECK:STDOUT:   %.loc14_16.1: bool = value_of_initializer %Equal.call
-// CHECK:STDOUT:   %.loc14_16.2: bool = converted %Equal.call, %.loc14_16.1
-// CHECK:STDOUT:   return %.loc14_16.2
+// CHECK:STDOUT:   %.loc12_12: <bound method> = bound_method %a.ref, %.1
+// CHECK:STDOUT:   %Equal.call: init bool = call %.loc12_12(%a.ref, %b.ref)
+// CHECK:STDOUT:   %.loc12_16.1: bool = value_of_initializer %Equal.call
+// CHECK:STDOUT:   %.loc12_16.2: bool = converted %Equal.call, %.loc12_16.1
+// CHECK:STDOUT:   return %.loc12_16.2
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @TestNotEqual(%a: C, %b: C) -> bool {
@@ -294,11 +212,11 @@ fn TestLhsBad(a: D, b: C) -> bool {
 // CHECK:STDOUT:   %a.ref: C = name_ref a, %a
 // CHECK:STDOUT:   %b.ref: C = name_ref b, %b
 // CHECK:STDOUT:   %.1: NotEqual = interface_witness_access @impl.%.1, element1 [template = constants.%struct.2]
-// CHECK:STDOUT:   %.loc18_12: <bound method> = bound_method %a.ref, %.1
-// CHECK:STDOUT:   %NotEqual.call: init bool = call %.loc18_12(%a.ref, %b.ref)
-// CHECK:STDOUT:   %.loc18_16.1: bool = value_of_initializer %NotEqual.call
-// CHECK:STDOUT:   %.loc18_16.2: bool = converted %NotEqual.call, %.loc18_16.1
-// CHECK:STDOUT:   return %.loc18_16.2
+// CHECK:STDOUT:   %.loc16_12: <bound method> = bound_method %a.ref, %.1
+// CHECK:STDOUT:   %NotEqual.call: init bool = call %.loc16_12(%a.ref, %b.ref)
+// CHECK:STDOUT:   %.loc16_16.1: bool = value_of_initializer %NotEqual.call
+// CHECK:STDOUT:   %.loc16_16.2: bool = converted %NotEqual.call, %.loc16_16.1
+// CHECK:STDOUT:   return %.loc16_16.2
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: --- fail_no_impl.carbon
@@ -334,32 +252,32 @@ fn TestLhsBad(a: D, b: C) -> bool {
 // CHECK:STDOUT:   %Core: <namespace> = namespace [template] {}
 // CHECK:STDOUT:   %D.decl: type = class_decl @D [template = constants.%D] {}
 // CHECK:STDOUT:   %TestEqual.decl: TestEqual = fn_decl @TestEqual [template = constants.%struct.1] {
-// CHECK:STDOUT:     %D.ref.loc8_17: type = name_ref D, %D.decl [template = constants.%D]
-// CHECK:STDOUT:     %a.loc8_14.1: D = param a
-// CHECK:STDOUT:     @TestEqual.%a: D = bind_name a, %a.loc8_14.1
-// CHECK:STDOUT:     %D.ref.loc8_23: type = name_ref D, %D.decl [template = constants.%D]
-// CHECK:STDOUT:     %b.loc8_20.1: D = param b
-// CHECK:STDOUT:     @TestEqual.%b: D = bind_name b, %b.loc8_20.1
+// CHECK:STDOUT:     %D.ref.loc6_17: type = name_ref D, %D.decl [template = constants.%D]
+// CHECK:STDOUT:     %a.loc6_14.1: D = param a
+// CHECK:STDOUT:     @TestEqual.%a: D = bind_name a, %a.loc6_14.1
+// CHECK:STDOUT:     %D.ref.loc6_23: type = name_ref D, %D.decl [template = constants.%D]
+// CHECK:STDOUT:     %b.loc6_20.1: D = param b
+// CHECK:STDOUT:     @TestEqual.%b: D = bind_name b, %b.loc6_20.1
 // CHECK:STDOUT:     @TestEqual.%return: ref bool = var <return slot>
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.1: type = import_ref ir2, inst+1, loaded [template = constants.%.4]
-// CHECK:STDOUT:   %import_ref.2 = import_ref ir2, inst+3, unloaded
-// CHECK:STDOUT:   %import_ref.3: <associated Equal in Eq> = import_ref ir2, inst+21, loaded [template = constants.%.6]
-// CHECK:STDOUT:   %import_ref.4: <associated NotEqual in Eq> = import_ref ir2, inst+38, loaded [template = constants.%.8]
-// CHECK:STDOUT:   %import_ref.5 = import_ref ir2, inst+16, unloaded
-// CHECK:STDOUT:   %import_ref.6 = import_ref ir2, inst+34, unloaded
-// CHECK:STDOUT:   %import_ref.7 = import_ref ir2, inst+16, unloaded
+// CHECK:STDOUT:   %import_ref.1: type = import_ref ir6, inst+1, loaded [template = constants.%.4]
+// CHECK:STDOUT:   %import_ref.2 = import_ref ir6, inst+3, unloaded
+// CHECK:STDOUT:   %import_ref.3: <associated Equal in Eq> = import_ref ir6, inst+21, loaded [template = constants.%.6]
+// CHECK:STDOUT:   %import_ref.4: <associated NotEqual in Eq> = import_ref ir6, inst+38, loaded [template = constants.%.8]
+// CHECK:STDOUT:   %import_ref.5 = import_ref ir6, inst+16, unloaded
+// CHECK:STDOUT:   %import_ref.6 = import_ref ir6, inst+34, unloaded
+// CHECK:STDOUT:   %import_ref.7 = import_ref ir6, inst+16, unloaded
 // CHECK:STDOUT:   %TestNotEqual.decl: TestNotEqual = fn_decl @TestNotEqual [template = constants.%struct.3] {
-// CHECK:STDOUT:     %D.ref.loc16_20: type = name_ref D, %D.decl [template = constants.%D]
-// CHECK:STDOUT:     %a.loc16_17.1: D = param a
-// CHECK:STDOUT:     @TestNotEqual.%a: D = bind_name a, %a.loc16_17.1
-// CHECK:STDOUT:     %D.ref.loc16_26: type = name_ref D, %D.decl [template = constants.%D]
-// CHECK:STDOUT:     %b.loc16_23.1: D = param b
-// CHECK:STDOUT:     @TestNotEqual.%b: D = bind_name b, %b.loc16_23.1
+// CHECK:STDOUT:     %D.ref.loc14_20: type = name_ref D, %D.decl [template = constants.%D]
+// CHECK:STDOUT:     %a.loc14_17.1: D = param a
+// CHECK:STDOUT:     @TestNotEqual.%a: D = bind_name a, %a.loc14_17.1
+// CHECK:STDOUT:     %D.ref.loc14_26: type = name_ref D, %D.decl [template = constants.%D]
+// CHECK:STDOUT:     %b.loc14_23.1: D = param b
+// CHECK:STDOUT:     @TestNotEqual.%b: D = bind_name b, %b.loc14_23.1
 // CHECK:STDOUT:     @TestNotEqual.%return: ref bool = var <return slot>
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.8: type = import_ref ir2, inst+1, loaded [template = constants.%.4]
-// CHECK:STDOUT:   %import_ref.9 = import_ref ir2, inst+34, unloaded
+// CHECK:STDOUT:   %import_ref.8: type = import_ref ir6, inst+1, loaded [template = constants.%.4]
+// CHECK:STDOUT:   %import_ref.9 = import_ref ir6, inst+34, unloaded
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: interface @Eq {
@@ -433,39 +351,39 @@ fn TestLhsBad(a: D, b: C) -> bool {
 // CHECK:STDOUT:   %Core: <namespace> = namespace [template] {}
 // CHECK:STDOUT:   %C.decl: type = class_decl @C [template = constants.%C] {}
 // CHECK:STDOUT:   %D.decl: type = class_decl @D [template = constants.%D] {}
-// CHECK:STDOUT:   %import_ref.1: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.2 = import_ref ir2, inst+3, unloaded
-// CHECK:STDOUT:   %import_ref.3: <associated Equal in Eq> = import_ref ir2, inst+21, loaded [template = constants.%.7]
-// CHECK:STDOUT:   %import_ref.4: <associated NotEqual in Eq> = import_ref ir2, inst+38, loaded [template = constants.%.9]
-// CHECK:STDOUT:   %import_ref.5: Equal = import_ref ir2, inst+16, loaded [template = constants.%struct.3]
-// CHECK:STDOUT:   %import_ref.6: NotEqual = import_ref ir2, inst+34, loaded [template = constants.%struct.4]
+// CHECK:STDOUT:   %import_ref.1: type = import_ref ir6, inst+1, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.2 = import_ref ir6, inst+3, unloaded
+// CHECK:STDOUT:   %import_ref.3: <associated Equal in Eq> = import_ref ir6, inst+21, loaded [template = constants.%.7]
+// CHECK:STDOUT:   %import_ref.4: <associated NotEqual in Eq> = import_ref ir6, inst+38, loaded [template = constants.%.9]
+// CHECK:STDOUT:   %import_ref.5: Equal = import_ref ir6, inst+16, loaded [template = constants.%struct.3]
+// CHECK:STDOUT:   %import_ref.6: NotEqual = import_ref ir6, inst+34, loaded [template = constants.%struct.4]
 // CHECK:STDOUT:   impl_decl @impl {
-// CHECK:STDOUT:     %C.ref.loc9: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %C.ref.loc7: type = name_ref C, %C.decl [template = constants.%C]
 // CHECK:STDOUT:     %Core.ref: <namespace> = name_ref Core, %Core [template = %Core]
 // CHECK:STDOUT:     %Eq.ref: type = name_ref Eq, %import_ref.1 [template = constants.%.2]
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %TestRhsBad.decl: TestRhsBad = fn_decl @TestRhsBad [template = constants.%struct.5] {
-// CHECK:STDOUT:     %C.ref.loc14: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %a.loc14_15.1: C = param a
-// CHECK:STDOUT:     @TestRhsBad.%a: C = bind_name a, %a.loc14_15.1
-// CHECK:STDOUT:     %D.ref.loc14: type = name_ref D, %D.decl [template = constants.%D]
-// CHECK:STDOUT:     %b.loc14_21.1: D = param b
-// CHECK:STDOUT:     @TestRhsBad.%b: D = bind_name b, %b.loc14_21.1
+// CHECK:STDOUT:     %C.ref.loc12: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %a.loc12_15.1: C = param a
+// CHECK:STDOUT:     @TestRhsBad.%a: C = bind_name a, %a.loc12_15.1
+// CHECK:STDOUT:     %D.ref.loc12: type = name_ref D, %D.decl [template = constants.%D]
+// CHECK:STDOUT:     %b.loc12_21.1: D = param b
+// CHECK:STDOUT:     @TestRhsBad.%b: D = bind_name b, %b.loc12_21.1
 // CHECK:STDOUT:     @TestRhsBad.%return: ref bool = var <return slot>
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.7: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.8 = import_ref ir2, inst+16, unloaded
+// CHECK:STDOUT:   %import_ref.7: type = import_ref ir6, inst+1, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.8 = import_ref ir6, inst+16, unloaded
 // CHECK:STDOUT:   %TestLhsBad.decl: TestLhsBad = fn_decl @TestLhsBad [template = constants.%struct.6] {
-// CHECK:STDOUT:     %D.ref.loc25: type = name_ref D, %D.decl [template = constants.%D]
-// CHECK:STDOUT:     %a.loc25_15.1: D = param a
-// CHECK:STDOUT:     @TestLhsBad.%a: D = bind_name a, %a.loc25_15.1
-// CHECK:STDOUT:     %C.ref.loc25: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %b.loc25_21.1: C = param b
-// CHECK:STDOUT:     @TestLhsBad.%b: C = bind_name b, %b.loc25_21.1
+// CHECK:STDOUT:     %D.ref.loc23: type = name_ref D, %D.decl [template = constants.%D]
+// CHECK:STDOUT:     %a.loc23_15.1: D = param a
+// CHECK:STDOUT:     @TestLhsBad.%a: D = bind_name a, %a.loc23_15.1
+// CHECK:STDOUT:     %C.ref.loc23: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %b.loc23_21.1: C = param b
+// CHECK:STDOUT:     @TestLhsBad.%b: C = bind_name b, %b.loc23_21.1
 // CHECK:STDOUT:     @TestLhsBad.%return: ref bool = var <return slot>
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.9: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.10 = import_ref ir2, inst+34, unloaded
+// CHECK:STDOUT:   %import_ref.9: type = import_ref ir6, inst+1, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.10 = import_ref ir6, inst+34, unloaded
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: interface @Eq {
@@ -478,22 +396,22 @@ fn TestLhsBad(a: D, b: C) -> bool {
 // CHECK:STDOUT:
 // CHECK:STDOUT: impl @impl: C as Eq {
 // CHECK:STDOUT:   %Equal.decl: Equal = fn_decl @Equal.1 [template = constants.%struct.1] {
-// CHECK:STDOUT:     %C.ref.loc10_18: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %self.loc10_12.1: C = param self
-// CHECK:STDOUT:     %self.loc10_12.2: C = bind_name self, %self.loc10_12.1
-// CHECK:STDOUT:     %C.ref.loc10_28: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %other.loc10_21.1: C = param other
-// CHECK:STDOUT:     %other.loc10_21.2: C = bind_name other, %other.loc10_21.1
-// CHECK:STDOUT:     %return.var.loc10: ref bool = var <return slot>
+// CHECK:STDOUT:     %C.ref.loc8_18: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %self.loc8_12.1: C = param self
+// CHECK:STDOUT:     %self.loc8_12.2: C = bind_name self, %self.loc8_12.1
+// CHECK:STDOUT:     %C.ref.loc8_28: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %other.loc8_21.1: C = param other
+// CHECK:STDOUT:     %other.loc8_21.2: C = bind_name other, %other.loc8_21.1
+// CHECK:STDOUT:     %return.var.loc8: ref bool = var <return slot>
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %NotEqual.decl: NotEqual = fn_decl @NotEqual.1 [template = constants.%struct.2] {
-// CHECK:STDOUT:     %C.ref.loc11_21: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %self.loc11_15.1: C = param self
-// CHECK:STDOUT:     %self.loc11_15.2: C = bind_name self, %self.loc11_15.1
-// CHECK:STDOUT:     %C.ref.loc11_31: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %other.loc11_24.1: C = param other
-// CHECK:STDOUT:     %other.loc11_24.2: C = bind_name other, %other.loc11_24.1
-// CHECK:STDOUT:     %return.var.loc11: ref bool = var <return slot>
+// CHECK:STDOUT:     %C.ref.loc9_21: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %self.loc9_15.1: C = param self
+// CHECK:STDOUT:     %self.loc9_15.2: C = bind_name self, %self.loc9_15.1
+// CHECK:STDOUT:     %C.ref.loc9_31: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %other.loc9_24.1: C = param other
+// CHECK:STDOUT:     %other.loc9_24.2: C = bind_name other, %other.loc9_24.1
+// CHECK:STDOUT:     %return.var.loc9: ref bool = var <return slot>
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %.1: <witness> = interface_witness (%Equal.decl, %NotEqual.decl) [template = constants.%.4]
 // CHECK:STDOUT:
@@ -513,9 +431,9 @@ fn TestLhsBad(a: D, b: C) -> bool {
 // CHECK:STDOUT:   .Self = constants.%D
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: fn @Equal.1[@impl.%self.loc10_12.2: C](@impl.%other.loc10_21.2: C) -> bool;
+// CHECK:STDOUT: fn @Equal.1[@impl.%self.loc8_12.2: C](@impl.%other.loc8_21.2: C) -> bool;
 // CHECK:STDOUT:
-// CHECK:STDOUT: fn @NotEqual.1[@impl.%self.loc11_15.2: C](@impl.%other.loc11_24.2: C) -> bool;
+// CHECK:STDOUT: fn @NotEqual.1[@impl.%self.loc9_15.2: C](@impl.%other.loc9_24.2: C) -> bool;
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @Equal.2[%self: Self](%other: Self) -> bool;
 // CHECK:STDOUT:
@@ -526,11 +444,11 @@ fn TestLhsBad(a: D, b: C) -> bool {
 // CHECK:STDOUT:   %a.ref: C = name_ref a, %a
 // CHECK:STDOUT:   %b.ref: D = name_ref b, %b
 // CHECK:STDOUT:   %.1: Equal = interface_witness_access @impl.%.1, element0 [template = constants.%struct.1]
-// CHECK:STDOUT:   %.loc22_12: <bound method> = bound_method %a.ref, %.1
-// CHECK:STDOUT:   %Equal.call: init bool = call %.loc22_12(<invalid>) [template = <error>]
-// CHECK:STDOUT:   %.loc22_16.1: bool = value_of_initializer %Equal.call [template = <error>]
-// CHECK:STDOUT:   %.loc22_16.2: bool = converted %Equal.call, %.loc22_16.1 [template = <error>]
-// CHECK:STDOUT:   return %.loc22_16.2
+// CHECK:STDOUT:   %.loc20_12: <bound method> = bound_method %a.ref, %.1
+// CHECK:STDOUT:   %Equal.call: init bool = call %.loc20_12(<invalid>) [template = <error>]
+// CHECK:STDOUT:   %.loc20_16.1: bool = value_of_initializer %Equal.call [template = <error>]
+// CHECK:STDOUT:   %.loc20_16.2: bool = converted %Equal.call, %.loc20_16.1 [template = <error>]
+// CHECK:STDOUT:   return %.loc20_16.2
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @TestLhsBad(%a: D, %b: C) -> bool {

+ 47 - 138
toolchain/check/testdata/operators/overloaded/fail_assign_non_ref.carbon

@@ -4,23 +4,8 @@
 //
 // AUTOUPDATE
 
-// --- prelude.carbon
-
-package Core;
-
-interface Inc {
-  fn Op[addr self: Self*]();
-}
-interface AddAssign {
-  fn Op[addr self: Self*](other: Self);
-}
-
-// --- fail_assign_non_ref.carbon
-
 package User;
 
-import Core;
-
 class C {};
 
 impl C as Core.Inc {
@@ -51,82 +36,6 @@ fn TestAddAssignNonRef(a: C, b: C) {
   a += b;
 }
 
-// CHECK:STDOUT: --- prelude.carbon
-// CHECK:STDOUT:
-// CHECK:STDOUT: constants {
-// CHECK:STDOUT:   %.1: type = interface_type @Inc [template]
-// CHECK:STDOUT:   %Self.1: Inc = bind_symbolic_name Self 0 [symbolic]
-// CHECK:STDOUT:   %.2: type = ptr_type Self [symbolic]
-// CHECK:STDOUT:   %Op.1: type = fn_type @Op.1 [template]
-// CHECK:STDOUT:   %.3: type = tuple_type () [template]
-// CHECK:STDOUT:   %struct.1: Op = struct_value () [template]
-// CHECK:STDOUT:   %.4: type = assoc_entity_type @Inc, Op [template]
-// CHECK:STDOUT:   %.5: <associated Op in Inc> = assoc_entity element0, @Inc.%Op.decl [template]
-// CHECK:STDOUT:   %.6: type = interface_type @AddAssign [template]
-// CHECK:STDOUT:   %Self.2: AddAssign = bind_symbolic_name Self 0 [symbolic]
-// CHECK:STDOUT:   %.7: type = ptr_type Self [symbolic]
-// CHECK:STDOUT:   %Op.2: type = fn_type @Op.2 [template]
-// CHECK:STDOUT:   %struct.2: Op = struct_value () [template]
-// CHECK:STDOUT:   %.8: type = assoc_entity_type @AddAssign, Op [template]
-// CHECK:STDOUT:   %.9: <associated Op in AddAssign> = assoc_entity element0, @AddAssign.%Op.decl [template]
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace [template] {
-// CHECK:STDOUT:     .Inc = %Inc.decl
-// CHECK:STDOUT:     .AddAssign = %AddAssign.decl
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %Inc.decl: type = interface_decl @Inc [template = constants.%.1] {}
-// CHECK:STDOUT:   %AddAssign.decl: type = interface_decl @AddAssign [template = constants.%.6] {}
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: interface @Inc {
-// CHECK:STDOUT:   %Self: Inc = bind_symbolic_name Self 0 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.1 [template = constants.%struct.1] {
-// CHECK:STDOUT:     %Self.ref: Inc = name_ref Self, %Self [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_24.1: type = facet_type_access %Self.ref [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_24.2: type = converted %Self.ref, %.loc5_24.1 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_24.3: type = ptr_type Self [symbolic = constants.%.2]
-// CHECK:STDOUT:     %self.loc5_14.1: Self* = param self
-// CHECK:STDOUT:     %self.loc5_14.3: Self* = bind_name self, %self.loc5_14.1
-// CHECK:STDOUT:     %.loc5_9: Self* = addr_pattern %self.loc5_14.3
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %.loc5_28: <associated Op in Inc> = assoc_entity element0, %Op.decl [template = constants.%.5]
-// CHECK:STDOUT:
-// CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Self = %Self
-// CHECK:STDOUT:   .Op = %.loc5_28
-// CHECK:STDOUT:   witness = (%Op.decl)
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: interface @AddAssign {
-// CHECK:STDOUT:   %Self: AddAssign = bind_symbolic_name Self 0 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.2 [template = constants.%struct.2] {
-// CHECK:STDOUT:     %Self.ref.loc8_20: AddAssign = name_ref Self, %Self [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_24.1: type = facet_type_access %Self.ref.loc8_20 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_24.2: type = converted %Self.ref.loc8_20, %.loc8_24.1 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_24.3: type = ptr_type Self [symbolic = constants.%.7]
-// CHECK:STDOUT:     %self.loc8_14.1: Self* = param self
-// CHECK:STDOUT:     %self.loc8_14.3: Self* = bind_name self, %self.loc8_14.1
-// CHECK:STDOUT:     %.loc8_9: Self* = addr_pattern %self.loc8_14.3
-// CHECK:STDOUT:     %Self.ref.loc8_34: AddAssign = name_ref Self, %Self [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_34.1: type = facet_type_access %Self.ref.loc8_34 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_34.2: type = converted %Self.ref.loc8_34, %.loc8_34.1 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %other.loc8_27.1: Self = param other
-// CHECK:STDOUT:     %other.loc8_27.2: Self = bind_name other, %other.loc8_27.1
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %.loc8_39: <associated Op in AddAssign> = assoc_entity element0, %Op.decl [template = constants.%.9]
-// CHECK:STDOUT:
-// CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Self = %Self
-// CHECK:STDOUT:   .Op = %.loc8_39
-// CHECK:STDOUT:   witness = (%Op.decl)
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.1[addr @Inc.%self.loc5_14.3: Self*]();
-// CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.2[addr @AddAssign.%self.loc8_14.3: Self*](@AddAssign.%other.loc8_27.2: Self);
-// CHECK:STDOUT:
 // CHECK:STDOUT: --- fail_assign_non_ref.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: constants {
@@ -170,64 +79,64 @@ fn TestAddAssignNonRef(a: C, b: C) {
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %Core: <namespace> = namespace [template] {}
 // CHECK:STDOUT:   %C.decl: type = class_decl @C [template = constants.%C] {}
-// CHECK:STDOUT:   %import_ref.1: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.2: <associated Op in Inc> = import_ref ir2, inst+18, loaded [template = constants.%.12]
-// CHECK:STDOUT:   %import_ref.3 = import_ref ir2, inst+3, unloaded
-// CHECK:STDOUT:   %import_ref.4: Op = import_ref ir2, inst+13, loaded [template = constants.%struct.2]
+// CHECK:STDOUT:   %import_ref.1: type = import_ref ir4, inst+49, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.2 = import_ref ir4, inst+51, unloaded
+// CHECK:STDOUT:   %import_ref.3: <associated Op in Inc> = import_ref ir4, inst+65, loaded [template = constants.%.12]
+// CHECK:STDOUT:   %import_ref.4: Op = import_ref ir4, inst+61, loaded [template = constants.%struct.2]
 // CHECK:STDOUT:   impl_decl @impl.1 {
-// CHECK:STDOUT:     %C.ref.loc8: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %Core.ref.loc8: <namespace> = name_ref Core, %Core [template = %Core]
+// CHECK:STDOUT:     %C.ref.loc11: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %Core.ref.loc11: <namespace> = name_ref Core, %Core [template = %Core]
 // CHECK:STDOUT:     %Inc.ref: type = name_ref Inc, %import_ref.1 [template = constants.%.2]
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.5: type = import_ref ir2, inst+20, loaded [template = constants.%.7]
-// CHECK:STDOUT:   %import_ref.6: <associated Op in AddAssign> = import_ref ir2, inst+41, loaded [template = constants.%.14]
-// CHECK:STDOUT:   %import_ref.7 = import_ref ir2, inst+22, unloaded
-// CHECK:STDOUT:   %import_ref.8: Op = import_ref ir2, inst+37, loaded [template = constants.%struct.4]
+// CHECK:STDOUT:   %import_ref.5: type = import_ref ir4, inst+26, loaded [template = constants.%.7]
+// CHECK:STDOUT:   %import_ref.6 = import_ref ir4, inst+28, unloaded
+// CHECK:STDOUT:   %import_ref.7: <associated Op in AddAssign> = import_ref ir4, inst+47, loaded [template = constants.%.14]
+// CHECK:STDOUT:   %import_ref.8: Op = import_ref ir4, inst+43, loaded [template = constants.%struct.4]
 // CHECK:STDOUT:   impl_decl @impl.2 {
-// CHECK:STDOUT:     %C.ref.loc11: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %Core.ref.loc11: <namespace> = name_ref Core, %Core [template = %Core]
+// CHECK:STDOUT:     %C.ref.loc14: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %Core.ref.loc14: <namespace> = name_ref Core, %Core [template = %Core]
 // CHECK:STDOUT:     %AddAssign.ref: type = name_ref AddAssign, %import_ref.5 [template = constants.%.7]
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %TestIncNonRef.decl: TestIncNonRef = fn_decl @TestIncNonRef [template = constants.%struct.5] {
-// CHECK:STDOUT:     %C.ref.loc15: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %a.loc15_18.1: C = param a
-// CHECK:STDOUT:     @TestIncNonRef.%a: C = bind_name a, %a.loc15_18.1
+// CHECK:STDOUT:     %C.ref.loc18: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %a.loc18_18.1: C = param a
+// CHECK:STDOUT:     @TestIncNonRef.%a: C = bind_name a, %a.loc18_18.1
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.9: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.10 = import_ref ir2, inst+13, unloaded
+// CHECK:STDOUT:   %import_ref.9: type = import_ref ir4, inst+49, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.10 = import_ref ir4, inst+61, unloaded
 // CHECK:STDOUT:   %TestAddAssignNonRef.decl: TestAddAssignNonRef = fn_decl @TestAddAssignNonRef [template = constants.%struct.6] {
-// CHECK:STDOUT:     %C.ref.loc26_27: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %a.loc26_24.1: C = param a
-// CHECK:STDOUT:     @TestAddAssignNonRef.%a: C = bind_name a, %a.loc26_24.1
-// CHECK:STDOUT:     %C.ref.loc26_33: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %b.loc26_30.1: C = param b
-// CHECK:STDOUT:     @TestAddAssignNonRef.%b: C = bind_name b, %b.loc26_30.1
+// CHECK:STDOUT:     %C.ref.loc29_27: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %a.loc29_24.1: C = param a
+// CHECK:STDOUT:     @TestAddAssignNonRef.%a: C = bind_name a, %a.loc29_24.1
+// CHECK:STDOUT:     %C.ref.loc29_33: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %b.loc29_30.1: C = param b
+// CHECK:STDOUT:     @TestAddAssignNonRef.%b: C = bind_name b, %b.loc29_30.1
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.11: type = import_ref ir2, inst+20, loaded [template = constants.%.7]
-// CHECK:STDOUT:   %import_ref.12 = import_ref ir2, inst+37, unloaded
+// CHECK:STDOUT:   %import_ref.11: type = import_ref ir4, inst+26, loaded [template = constants.%.7]
+// CHECK:STDOUT:   %import_ref.12 = import_ref ir4, inst+43, unloaded
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: interface @Inc {
 // CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Op = file.%import_ref.2
-// CHECK:STDOUT:   .Self = file.%import_ref.3
+// CHECK:STDOUT:   .Self = file.%import_ref.2
+// CHECK:STDOUT:   .Op = file.%import_ref.3
 // CHECK:STDOUT:   witness = (file.%import_ref.4)
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: interface @AddAssign {
 // CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Op = file.%import_ref.6
-// CHECK:STDOUT:   .Self = file.%import_ref.7
+// CHECK:STDOUT:   .Self = file.%import_ref.6
+// CHECK:STDOUT:   .Op = file.%import_ref.7
 // CHECK:STDOUT:   witness = (file.%import_ref.8)
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: impl @impl.1: C as Inc {
 // CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.1 [template = constants.%struct.1] {
 // CHECK:STDOUT:     %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %.loc9_21: type = ptr_type C [template = constants.%.3]
-// CHECK:STDOUT:     %self.loc9_14.1: C* = param self
-// CHECK:STDOUT:     %self.loc9_14.3: C* = bind_name self, %self.loc9_14.1
-// CHECK:STDOUT:     %.loc9_9: C* = addr_pattern %self.loc9_14.3
+// CHECK:STDOUT:     %.loc12_21: type = ptr_type C [template = constants.%.3]
+// CHECK:STDOUT:     %self.loc12_14.1: C* = param self
+// CHECK:STDOUT:     %self.loc12_14.3: C* = bind_name self, %self.loc12_14.1
+// CHECK:STDOUT:     %.loc12_9: C* = addr_pattern %self.loc12_14.3
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %.1: <witness> = interface_witness (%Op.decl) [template = constants.%.6]
 // CHECK:STDOUT:
@@ -238,14 +147,14 @@ fn TestAddAssignNonRef(a: C, b: C) {
 // CHECK:STDOUT:
 // CHECK:STDOUT: impl @impl.2: C as AddAssign {
 // CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.3 [template = constants.%struct.3] {
-// CHECK:STDOUT:     %C.ref.loc12_20: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %.loc12_21: type = ptr_type C [template = constants.%.3]
-// CHECK:STDOUT:     %self.loc12_14.1: C* = param self
-// CHECK:STDOUT:     %self.loc12_14.3: C* = bind_name self, %self.loc12_14.1
-// CHECK:STDOUT:     %.loc12_9: C* = addr_pattern %self.loc12_14.3
-// CHECK:STDOUT:     %C.ref.loc12_31: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %other.loc12_24.1: C = param other
-// CHECK:STDOUT:     %other.loc12_24.2: C = bind_name other, %other.loc12_24.1
+// CHECK:STDOUT:     %C.ref.loc15_20: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %.loc15_21: type = ptr_type C [template = constants.%.3]
+// CHECK:STDOUT:     %self.loc15_14.1: C* = param self
+// CHECK:STDOUT:     %self.loc15_14.3: C* = bind_name self, %self.loc15_14.1
+// CHECK:STDOUT:     %.loc15_9: C* = addr_pattern %self.loc15_14.3
+// CHECK:STDOUT:     %C.ref.loc15_31: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %other.loc15_24.1: C = param other
+// CHECK:STDOUT:     %other.loc15_24.2: C = bind_name other, %other.loc15_24.1
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %.1: <witness> = interface_witness (%Op.decl) [template = constants.%.9]
 // CHECK:STDOUT:
@@ -259,11 +168,11 @@ fn TestAddAssignNonRef(a: C, b: C) {
 // CHECK:STDOUT:   .Self = constants.%C
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.1[addr @impl.1.%self.loc9_14.3: C*]();
+// CHECK:STDOUT: fn @Op.1[addr @impl.1.%self.loc12_14.3: C*]();
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @Op.2[addr %self: Self*]();
 // CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.3[addr @impl.2.%self.loc12_14.3: C*](@impl.2.%other.loc12_24.2: C);
+// CHECK:STDOUT: fn @Op.3[addr @impl.2.%self.loc15_14.3: C*](@impl.2.%other.loc15_24.2: C);
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @Op.4[addr %self: Self*](%other: Self);
 // CHECK:STDOUT:
@@ -271,8 +180,8 @@ fn TestAddAssignNonRef(a: C, b: C) {
 // CHECK:STDOUT: !entry:
 // CHECK:STDOUT:   %a.ref: C = name_ref a, %a
 // CHECK:STDOUT:   %.1: Op = interface_witness_access @impl.1.%.1, element0 [template = constants.%struct.1]
-// CHECK:STDOUT:   %.loc23: <bound method> = bound_method %a.ref, %.1
-// CHECK:STDOUT:   %Op.call: init () = call %.loc23(<invalid>) [template = <error>]
+// CHECK:STDOUT:   %.loc26: <bound method> = bound_method %a.ref, %.1
+// CHECK:STDOUT:   %Op.call: init () = call %.loc26(<invalid>) [template = <error>]
 // CHECK:STDOUT:   return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
@@ -281,8 +190,8 @@ fn TestAddAssignNonRef(a: C, b: C) {
 // CHECK:STDOUT:   %a.ref: C = name_ref a, %a
 // CHECK:STDOUT:   %b.ref: C = name_ref b, %b
 // CHECK:STDOUT:   %.1: Op = interface_witness_access @impl.2.%.1, element0 [template = constants.%struct.3]
-// CHECK:STDOUT:   %.loc33: <bound method> = bound_method %a.ref, %.1
-// CHECK:STDOUT:   %Op.call: init () = call %.loc33(<invalid>) [template = <error>]
+// CHECK:STDOUT:   %.loc36: <bound method> = bound_method %a.ref, %.1
+// CHECK:STDOUT:   %Op.call: init () = call %.loc36(<invalid>) [template = <error>]
 // CHECK:STDOUT:   return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 49 - 209
toolchain/check/testdata/operators/overloaded/fail_no_impl.carbon

@@ -4,29 +4,8 @@
 //
 // AUTOUPDATE
 
-// --- prelude.carbon
-
-package Core;
-
-interface Negate {
-  fn Op[self: Self]();
-}
-interface Add {
-  fn Op[self: Self](other: Self) -> Self;
-}
-interface AddAssign {
-  fn Op[addr self: Self*](other: Self);
-}
-interface Inc {
-  fn Op[addr self: Self*]();
-}
-
-// --- fail_no_impl.carbon
-
 package User;
 
-import Core;
-
 class C {};
 
 fn TestUnary(a: C) -> C {
@@ -58,145 +37,6 @@ fn TestRef(b: C) {
   ++a;
 }
 
-// CHECK:STDOUT: --- prelude.carbon
-// CHECK:STDOUT:
-// CHECK:STDOUT: constants {
-// CHECK:STDOUT:   %.1: type = interface_type @Negate [template]
-// CHECK:STDOUT:   %Self.1: Negate = bind_symbolic_name Self 0 [symbolic]
-// CHECK:STDOUT:   %Op.1: type = fn_type @Op.1 [template]
-// CHECK:STDOUT:   %.2: type = tuple_type () [template]
-// CHECK:STDOUT:   %struct.1: Op = struct_value () [template]
-// CHECK:STDOUT:   %.3: type = assoc_entity_type @Negate, Op [template]
-// CHECK:STDOUT:   %.4: <associated Op in Negate> = assoc_entity element0, @Negate.%Op.decl [template]
-// CHECK:STDOUT:   %.5: type = interface_type @Add [template]
-// CHECK:STDOUT:   %Self.2: Add = bind_symbolic_name Self 0 [symbolic]
-// CHECK:STDOUT:   %Op.2: type = fn_type @Op.2 [template]
-// CHECK:STDOUT:   %struct.2: Op = struct_value () [template]
-// CHECK:STDOUT:   %.6: type = assoc_entity_type @Add, Op [template]
-// CHECK:STDOUT:   %.7: <associated Op in Add> = assoc_entity element0, @Add.%Op.decl [template]
-// CHECK:STDOUT:   %.8: type = interface_type @AddAssign [template]
-// CHECK:STDOUT:   %Self.3: AddAssign = bind_symbolic_name Self 0 [symbolic]
-// CHECK:STDOUT:   %.9: type = ptr_type Self [symbolic]
-// CHECK:STDOUT:   %Op.3: type = fn_type @Op.3 [template]
-// CHECK:STDOUT:   %struct.3: Op = struct_value () [template]
-// CHECK:STDOUT:   %.10: type = assoc_entity_type @AddAssign, Op [template]
-// CHECK:STDOUT:   %.11: <associated Op in AddAssign> = assoc_entity element0, @AddAssign.%Op.decl [template]
-// CHECK:STDOUT:   %.12: type = interface_type @Inc [template]
-// CHECK:STDOUT:   %Self.4: Inc = bind_symbolic_name Self 0 [symbolic]
-// CHECK:STDOUT:   %.13: type = ptr_type Self [symbolic]
-// CHECK:STDOUT:   %Op.4: type = fn_type @Op.4 [template]
-// CHECK:STDOUT:   %struct.4: Op = struct_value () [template]
-// CHECK:STDOUT:   %.14: type = assoc_entity_type @Inc, Op [template]
-// CHECK:STDOUT:   %.15: <associated Op in Inc> = assoc_entity element0, @Inc.%Op.decl [template]
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace [template] {
-// CHECK:STDOUT:     .Negate = %Negate.decl
-// CHECK:STDOUT:     .Add = %Add.decl
-// CHECK:STDOUT:     .AddAssign = %AddAssign.decl
-// CHECK:STDOUT:     .Inc = %Inc.decl
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %Negate.decl: type = interface_decl @Negate [template = constants.%.1] {}
-// CHECK:STDOUT:   %Add.decl: type = interface_decl @Add [template = constants.%.5] {}
-// CHECK:STDOUT:   %AddAssign.decl: type = interface_decl @AddAssign [template = constants.%.8] {}
-// CHECK:STDOUT:   %Inc.decl: type = interface_decl @Inc [template = constants.%.12] {}
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: interface @Negate {
-// CHECK:STDOUT:   %Self: Negate = bind_symbolic_name Self 0 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.1 [template = constants.%struct.1] {
-// CHECK:STDOUT:     %Self.ref: Negate = name_ref Self, %Self [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_15.1: type = facet_type_access %Self.ref [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_15.2: type = converted %Self.ref, %.loc5_15.1 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %self.loc5_9.1: Self = param self
-// CHECK:STDOUT:     %self.loc5_9.2: Self = bind_name self, %self.loc5_9.1
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %.loc5_22: <associated Op in Negate> = assoc_entity element0, %Op.decl [template = constants.%.4]
-// CHECK:STDOUT:
-// CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Self = %Self
-// CHECK:STDOUT:   .Op = %.loc5_22
-// CHECK:STDOUT:   witness = (%Op.decl)
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: interface @Add {
-// CHECK:STDOUT:   %Self: Add = bind_symbolic_name Self 0 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.2 [template = constants.%struct.2] {
-// CHECK:STDOUT:     %Self.ref.loc8_15: Add = name_ref Self, %Self [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_15.1: type = facet_type_access %Self.ref.loc8_15 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_15.2: type = converted %Self.ref.loc8_15, %.loc8_15.1 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %self.loc8_9.1: Self = param self
-// CHECK:STDOUT:     %self.loc8_9.2: Self = bind_name self, %self.loc8_9.1
-// CHECK:STDOUT:     %Self.ref.loc8_28: Add = name_ref Self, %Self [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_28.1: type = facet_type_access %Self.ref.loc8_28 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_28.2: type = converted %Self.ref.loc8_28, %.loc8_28.1 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %other.loc8_21.1: Self = param other
-// CHECK:STDOUT:     %other.loc8_21.2: Self = bind_name other, %other.loc8_21.1
-// CHECK:STDOUT:     %Self.ref.loc8_37: Add = name_ref Self, %Self [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_37.1: type = facet_type_access %Self.ref.loc8_37 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_37.2: type = converted %Self.ref.loc8_37, %.loc8_37.1 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %return.var: ref Self = var <return slot>
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %.loc8_41: <associated Op in Add> = assoc_entity element0, %Op.decl [template = constants.%.7]
-// CHECK:STDOUT:
-// CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Self = %Self
-// CHECK:STDOUT:   .Op = %.loc8_41
-// CHECK:STDOUT:   witness = (%Op.decl)
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: interface @AddAssign {
-// CHECK:STDOUT:   %Self: AddAssign = bind_symbolic_name Self 0 [symbolic = constants.%Self.3]
-// CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.3 [template = constants.%struct.3] {
-// CHECK:STDOUT:     %Self.ref.loc11_20: AddAssign = name_ref Self, %Self [symbolic = constants.%Self.3]
-// CHECK:STDOUT:     %.loc11_24.1: type = facet_type_access %Self.ref.loc11_20 [symbolic = constants.%Self.3]
-// CHECK:STDOUT:     %.loc11_24.2: type = converted %Self.ref.loc11_20, %.loc11_24.1 [symbolic = constants.%Self.3]
-// CHECK:STDOUT:     %.loc11_24.3: type = ptr_type Self [symbolic = constants.%.9]
-// CHECK:STDOUT:     %self.loc11_14.1: Self* = param self
-// CHECK:STDOUT:     %self.loc11_14.3: Self* = bind_name self, %self.loc11_14.1
-// CHECK:STDOUT:     %.loc11_9: Self* = addr_pattern %self.loc11_14.3
-// CHECK:STDOUT:     %Self.ref.loc11_34: AddAssign = name_ref Self, %Self [symbolic = constants.%Self.3]
-// CHECK:STDOUT:     %.loc11_34.1: type = facet_type_access %Self.ref.loc11_34 [symbolic = constants.%Self.3]
-// CHECK:STDOUT:     %.loc11_34.2: type = converted %Self.ref.loc11_34, %.loc11_34.1 [symbolic = constants.%Self.3]
-// CHECK:STDOUT:     %other.loc11_27.1: Self = param other
-// CHECK:STDOUT:     %other.loc11_27.2: Self = bind_name other, %other.loc11_27.1
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %.loc11_39: <associated Op in AddAssign> = assoc_entity element0, %Op.decl [template = constants.%.11]
-// CHECK:STDOUT:
-// CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Self = %Self
-// CHECK:STDOUT:   .Op = %.loc11_39
-// CHECK:STDOUT:   witness = (%Op.decl)
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: interface @Inc {
-// CHECK:STDOUT:   %Self: Inc = bind_symbolic_name Self 0 [symbolic = constants.%Self.4]
-// CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.4 [template = constants.%struct.4] {
-// CHECK:STDOUT:     %Self.ref: Inc = name_ref Self, %Self [symbolic = constants.%Self.4]
-// CHECK:STDOUT:     %.loc14_24.1: type = facet_type_access %Self.ref [symbolic = constants.%Self.4]
-// CHECK:STDOUT:     %.loc14_24.2: type = converted %Self.ref, %.loc14_24.1 [symbolic = constants.%Self.4]
-// CHECK:STDOUT:     %.loc14_24.3: type = ptr_type Self [symbolic = constants.%.13]
-// CHECK:STDOUT:     %self.loc14_14.1: Self* = param self
-// CHECK:STDOUT:     %self.loc14_14.3: Self* = bind_name self, %self.loc14_14.1
-// CHECK:STDOUT:     %.loc14_9: Self* = addr_pattern %self.loc14_14.3
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %.loc14_28: <associated Op in Inc> = assoc_entity element0, %Op.decl [template = constants.%.15]
-// CHECK:STDOUT:
-// CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Self = %Self
-// CHECK:STDOUT:   .Op = %.loc14_28
-// CHECK:STDOUT:   witness = (%Op.decl)
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.1[@Negate.%self.loc5_9.2: Self]();
-// CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.2[@Add.%self.loc8_9.2: Self](@Add.%other.loc8_21.2: Self) -> Self;
-// CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.3[addr @AddAssign.%self.loc11_14.3: Self*](@AddAssign.%other.loc11_27.2: Self);
-// CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.4[addr @Inc.%self.loc14_14.3: Self*]();
-// CHECK:STDOUT:
 // CHECK:STDOUT: --- fail_no_impl.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: constants {
@@ -250,74 +90,74 @@ fn TestRef(b: C) {
 // CHECK:STDOUT:   %Core: <namespace> = namespace [template] {}
 // CHECK:STDOUT:   %C.decl: type = class_decl @C [template = constants.%C] {}
 // CHECK:STDOUT:   %TestUnary.decl: TestUnary = fn_decl @TestUnary [template = constants.%struct.1] {
-// CHECK:STDOUT:     %C.ref.loc8_17: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %a.loc8_14.1: C = param a
-// CHECK:STDOUT:     @TestUnary.%a: C = bind_name a, %a.loc8_14.1
-// CHECK:STDOUT:     %C.ref.loc8_23: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %C.ref.loc11_17: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %a.loc11_14.1: C = param a
+// CHECK:STDOUT:     @TestUnary.%a: C = bind_name a, %a.loc11_14.1
+// CHECK:STDOUT:     %C.ref.loc11_23: type = name_ref C, %C.decl [template = constants.%C]
 // CHECK:STDOUT:     @TestUnary.%return: ref C = var <return slot>
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.1: type = import_ref ir2, inst+1, loaded [template = constants.%.4]
-// CHECK:STDOUT:   %import_ref.2: <associated Op in Negate> = import_ref ir2, inst+15, loaded [template = constants.%.6]
-// CHECK:STDOUT:   %import_ref.3 = import_ref ir2, inst+3, unloaded
-// CHECK:STDOUT:   %import_ref.4 = import_ref ir2, inst+10, unloaded
-// CHECK:STDOUT:   %import_ref.5 = import_ref ir2, inst+10, unloaded
+// CHECK:STDOUT:   %import_ref.1: type = import_ref ir4, inst+67, loaded [template = constants.%.4]
+// CHECK:STDOUT:   %import_ref.2 = import_ref ir4, inst+69, unloaded
+// CHECK:STDOUT:   %import_ref.3: <associated Op in Negate> = import_ref ir4, inst+84, loaded [template = constants.%.6]
+// CHECK:STDOUT:   %import_ref.4 = import_ref ir4, inst+80, unloaded
+// CHECK:STDOUT:   %import_ref.5 = import_ref ir4, inst+80, unloaded
 // CHECK:STDOUT:   %TestBinary.decl: TestBinary = fn_decl @TestBinary [template = constants.%struct.3] {
-// CHECK:STDOUT:     %C.ref.loc16_18: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %a.loc16_15.1: C = param a
-// CHECK:STDOUT:     @TestBinary.%a: C = bind_name a, %a.loc16_15.1
-// CHECK:STDOUT:     %C.ref.loc16_24: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %b.loc16_21.1: C = param b
-// CHECK:STDOUT:     @TestBinary.%b: C = bind_name b, %b.loc16_21.1
-// CHECK:STDOUT:     %C.ref.loc16_30: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %C.ref.loc19_18: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %a.loc19_15.1: C = param a
+// CHECK:STDOUT:     @TestBinary.%a: C = bind_name a, %a.loc19_15.1
+// CHECK:STDOUT:     %C.ref.loc19_24: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %b.loc19_21.1: C = param b
+// CHECK:STDOUT:     @TestBinary.%b: C = bind_name b, %b.loc19_21.1
+// CHECK:STDOUT:     %C.ref.loc19_30: type = name_ref C, %C.decl [template = constants.%C]
 // CHECK:STDOUT:     @TestBinary.%return: ref C = var <return slot>
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.6: type = import_ref ir2, inst+17, loaded [template = constants.%.7]
-// CHECK:STDOUT:   %import_ref.7: <associated Op in Add> = import_ref ir2, inst+39, loaded [template = constants.%.9]
-// CHECK:STDOUT:   %import_ref.8 = import_ref ir2, inst+19, unloaded
-// CHECK:STDOUT:   %import_ref.9 = import_ref ir2, inst+35, unloaded
-// CHECK:STDOUT:   %import_ref.10 = import_ref ir2, inst+35, unloaded
+// CHECK:STDOUT:   %import_ref.6: type = import_ref ir4, inst+1, loaded [template = constants.%.7]
+// CHECK:STDOUT:   %import_ref.7 = import_ref ir4, inst+3, unloaded
+// CHECK:STDOUT:   %import_ref.8: <associated Op in Add> = import_ref ir4, inst+24, loaded [template = constants.%.9]
+// CHECK:STDOUT:   %import_ref.9 = import_ref ir4, inst+19, unloaded
+// CHECK:STDOUT:   %import_ref.10 = import_ref ir4, inst+19, unloaded
 // CHECK:STDOUT:   %TestRef.decl: TestRef = fn_decl @TestRef [template = constants.%struct.5] {
-// CHECK:STDOUT:     %C.ref.loc24: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %b.loc24_12.1: C = param b
-// CHECK:STDOUT:     @TestRef.%b: C = bind_name b, %b.loc24_12.1
+// CHECK:STDOUT:     %C.ref.loc27: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %b.loc27_12.1: C = param b
+// CHECK:STDOUT:     @TestRef.%b: C = bind_name b, %b.loc27_12.1
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.11: type = import_ref ir2, inst+41, loaded [template = constants.%.10]
-// CHECK:STDOUT:   %import_ref.12: <associated Op in AddAssign> = import_ref ir2, inst+62, loaded [template = constants.%.13]
-// CHECK:STDOUT:   %import_ref.13 = import_ref ir2, inst+43, unloaded
-// CHECK:STDOUT:   %import_ref.14 = import_ref ir2, inst+58, unloaded
-// CHECK:STDOUT:   %import_ref.15 = import_ref ir2, inst+58, unloaded
-// CHECK:STDOUT:   %import_ref.16: type = import_ref ir2, inst+64, loaded [template = constants.%.14]
-// CHECK:STDOUT:   %import_ref.17: <associated Op in Inc> = import_ref ir2, inst+80, loaded [template = constants.%.17]
-// CHECK:STDOUT:   %import_ref.18 = import_ref ir2, inst+66, unloaded
-// CHECK:STDOUT:   %import_ref.19 = import_ref ir2, inst+76, unloaded
-// CHECK:STDOUT:   %import_ref.20 = import_ref ir2, inst+76, unloaded
+// CHECK:STDOUT:   %import_ref.11: type = import_ref ir4, inst+26, loaded [template = constants.%.10]
+// CHECK:STDOUT:   %import_ref.12 = import_ref ir4, inst+28, unloaded
+// CHECK:STDOUT:   %import_ref.13: <associated Op in AddAssign> = import_ref ir4, inst+47, loaded [template = constants.%.13]
+// CHECK:STDOUT:   %import_ref.14 = import_ref ir4, inst+43, unloaded
+// CHECK:STDOUT:   %import_ref.15 = import_ref ir4, inst+43, unloaded
+// CHECK:STDOUT:   %import_ref.16: type = import_ref ir4, inst+49, loaded [template = constants.%.14]
+// CHECK:STDOUT:   %import_ref.17 = import_ref ir4, inst+51, unloaded
+// CHECK:STDOUT:   %import_ref.18: <associated Op in Inc> = import_ref ir4, inst+65, loaded [template = constants.%.17]
+// CHECK:STDOUT:   %import_ref.19 = import_ref ir4, inst+61, unloaded
+// CHECK:STDOUT:   %import_ref.20 = import_ref ir4, inst+61, unloaded
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: interface @Negate {
 // CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Op = file.%import_ref.2
-// CHECK:STDOUT:   .Self = file.%import_ref.3
+// CHECK:STDOUT:   .Self = file.%import_ref.2
+// CHECK:STDOUT:   .Op = file.%import_ref.3
 // CHECK:STDOUT:   witness = (file.%import_ref.4)
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: interface @Add {
 // CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Op = file.%import_ref.7
-// CHECK:STDOUT:   .Self = file.%import_ref.8
+// CHECK:STDOUT:   .Self = file.%import_ref.7
+// CHECK:STDOUT:   .Op = file.%import_ref.8
 // CHECK:STDOUT:   witness = (file.%import_ref.9)
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: interface @AddAssign {
 // CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Op = file.%import_ref.12
-// CHECK:STDOUT:   .Self = file.%import_ref.13
+// CHECK:STDOUT:   .Self = file.%import_ref.12
+// CHECK:STDOUT:   .Op = file.%import_ref.13
 // CHECK:STDOUT:   witness = (file.%import_ref.14)
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: interface @Inc {
 // CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Op = file.%import_ref.17
-// CHECK:STDOUT:   .Self = file.%import_ref.18
+// CHECK:STDOUT:   .Self = file.%import_ref.17
+// CHECK:STDOUT:   .Op = file.%import_ref.18
 // CHECK:STDOUT:   witness = (file.%import_ref.19)
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
@@ -332,7 +172,7 @@ fn TestRef(b: C) {
 // CHECK:STDOUT:   return <error> to %return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.1[%self: Self]();
+// CHECK:STDOUT: fn @Op.1[%self: Self]() -> Self;
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @TestBinary(%a: C, %b: C) -> %return: C {
 // CHECK:STDOUT: !entry:
@@ -348,13 +188,13 @@ fn TestRef(b: C) {
 // CHECK:STDOUT:   %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
 // CHECK:STDOUT:   %a.var: ref C = var a
 // CHECK:STDOUT:   %a: ref C = bind_name a, %a.var
-// CHECK:STDOUT:   %.loc25_15.1: {} = struct_literal ()
-// CHECK:STDOUT:   %.loc25_15.2: init C = class_init (), %a.var [template = constants.%struct.6]
-// CHECK:STDOUT:   %.loc25_16: init C = converted %.loc25_15.1, %.loc25_15.2 [template = constants.%struct.6]
-// CHECK:STDOUT:   assign %a.var, %.loc25_16
-// CHECK:STDOUT:   %a.ref.loc30: ref C = name_ref a, %a
+// CHECK:STDOUT:   %.loc28_15.1: {} = struct_literal ()
+// CHECK:STDOUT:   %.loc28_15.2: init C = class_init (), %a.var [template = constants.%struct.6]
+// CHECK:STDOUT:   %.loc28_16: init C = converted %.loc28_15.1, %.loc28_15.2 [template = constants.%struct.6]
+// CHECK:STDOUT:   assign %a.var, %.loc28_16
+// CHECK:STDOUT:   %a.ref.loc33: ref C = name_ref a, %a
 // CHECK:STDOUT:   %b.ref: C = name_ref b, %b
-// CHECK:STDOUT:   %a.ref.loc34: ref C = name_ref a, %a
+// CHECK:STDOUT:   %a.ref.loc37: ref C = name_ref a, %a
 // CHECK:STDOUT:   return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 57 - 154
toolchain/check/testdata/operators/overloaded/fail_no_impl_for_arg.carbon

@@ -4,23 +4,8 @@
 //
 // AUTOUPDATE
 
-// --- prelude.carbon
-
-package Core;
-
-interface Add {
-  fn Op[self: Self](other: Self) -> Self;
-}
-interface AddAssign {
-  fn Op[addr self: Self*](other: Self);
-}
-
-// --- fail_no_impl_for_arg.carbon
-
 package User;
 
-import Core;
-
 class C {};
 class D {};
 
@@ -53,88 +38,6 @@ fn TestAssign(b: D) {
   a += b;
 }
 
-// CHECK:STDOUT: --- prelude.carbon
-// CHECK:STDOUT:
-// CHECK:STDOUT: constants {
-// CHECK:STDOUT:   %.1: type = interface_type @Add [template]
-// CHECK:STDOUT:   %Self.1: Add = bind_symbolic_name Self 0 [symbolic]
-// CHECK:STDOUT:   %Op.1: type = fn_type @Op.1 [template]
-// CHECK:STDOUT:   %.2: type = tuple_type () [template]
-// CHECK:STDOUT:   %struct.1: Op = struct_value () [template]
-// CHECK:STDOUT:   %.3: type = assoc_entity_type @Add, Op [template]
-// CHECK:STDOUT:   %.4: <associated Op in Add> = assoc_entity element0, @Add.%Op.decl [template]
-// CHECK:STDOUT:   %.5: type = interface_type @AddAssign [template]
-// CHECK:STDOUT:   %Self.2: AddAssign = bind_symbolic_name Self 0 [symbolic]
-// CHECK:STDOUT:   %.6: type = ptr_type Self [symbolic]
-// CHECK:STDOUT:   %Op.2: type = fn_type @Op.2 [template]
-// CHECK:STDOUT:   %struct.2: Op = struct_value () [template]
-// CHECK:STDOUT:   %.7: type = assoc_entity_type @AddAssign, Op [template]
-// CHECK:STDOUT:   %.8: <associated Op in AddAssign> = assoc_entity element0, @AddAssign.%Op.decl [template]
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace [template] {
-// CHECK:STDOUT:     .Add = %Add.decl
-// CHECK:STDOUT:     .AddAssign = %AddAssign.decl
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %Add.decl: type = interface_decl @Add [template = constants.%.1] {}
-// CHECK:STDOUT:   %AddAssign.decl: type = interface_decl @AddAssign [template = constants.%.5] {}
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: interface @Add {
-// CHECK:STDOUT:   %Self: Add = bind_symbolic_name Self 0 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.1 [template = constants.%struct.1] {
-// CHECK:STDOUT:     %Self.ref.loc5_15: Add = name_ref Self, %Self [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_15.1: type = facet_type_access %Self.ref.loc5_15 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_15.2: type = converted %Self.ref.loc5_15, %.loc5_15.1 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %self.loc5_9.1: Self = param self
-// CHECK:STDOUT:     %self.loc5_9.2: Self = bind_name self, %self.loc5_9.1
-// CHECK:STDOUT:     %Self.ref.loc5_28: Add = name_ref Self, %Self [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_28.1: type = facet_type_access %Self.ref.loc5_28 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_28.2: type = converted %Self.ref.loc5_28, %.loc5_28.1 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %other.loc5_21.1: Self = param other
-// CHECK:STDOUT:     %other.loc5_21.2: Self = bind_name other, %other.loc5_21.1
-// CHECK:STDOUT:     %Self.ref.loc5_37: Add = name_ref Self, %Self [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_37.1: type = facet_type_access %Self.ref.loc5_37 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_37.2: type = converted %Self.ref.loc5_37, %.loc5_37.1 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %return.var: ref Self = var <return slot>
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %.loc5_41: <associated Op in Add> = assoc_entity element0, %Op.decl [template = constants.%.4]
-// CHECK:STDOUT:
-// CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Self = %Self
-// CHECK:STDOUT:   .Op = %.loc5_41
-// CHECK:STDOUT:   witness = (%Op.decl)
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: interface @AddAssign {
-// CHECK:STDOUT:   %Self: AddAssign = bind_symbolic_name Self 0 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.2 [template = constants.%struct.2] {
-// CHECK:STDOUT:     %Self.ref.loc8_20: AddAssign = name_ref Self, %Self [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_24.1: type = facet_type_access %Self.ref.loc8_20 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_24.2: type = converted %Self.ref.loc8_20, %.loc8_24.1 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_24.3: type = ptr_type Self [symbolic = constants.%.6]
-// CHECK:STDOUT:     %self.loc8_14.1: Self* = param self
-// CHECK:STDOUT:     %self.loc8_14.3: Self* = bind_name self, %self.loc8_14.1
-// CHECK:STDOUT:     %.loc8_9: Self* = addr_pattern %self.loc8_14.3
-// CHECK:STDOUT:     %Self.ref.loc8_34: AddAssign = name_ref Self, %Self [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_34.1: type = facet_type_access %Self.ref.loc8_34 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_34.2: type = converted %Self.ref.loc8_34, %.loc8_34.1 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %other.loc8_27.1: Self = param other
-// CHECK:STDOUT:     %other.loc8_27.2: Self = bind_name other, %other.loc8_27.1
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %.loc8_39: <associated Op in AddAssign> = assoc_entity element0, %Op.decl [template = constants.%.8]
-// CHECK:STDOUT:
-// CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Self = %Self
-// CHECK:STDOUT:   .Op = %.loc8_39
-// CHECK:STDOUT:   witness = (%Op.decl)
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.1[@Add.%self.loc5_9.2: Self](@Add.%other.loc5_21.2: Self) -> Self;
-// CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.2[addr @AddAssign.%self.loc8_14.3: Self*](@AddAssign.%other.loc8_27.2: Self);
-// CHECK:STDOUT:
 // CHECK:STDOUT: --- fail_no_impl_for_arg.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: constants {
@@ -181,68 +84,68 @@ fn TestAssign(b: D) {
 // CHECK:STDOUT:   %Core: <namespace> = namespace [template] {}
 // CHECK:STDOUT:   %C.decl: type = class_decl @C [template = constants.%C] {}
 // CHECK:STDOUT:   %D.decl: type = class_decl @D [template = constants.%D] {}
-// CHECK:STDOUT:   %import_ref.1: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.2: <associated Op in Add> = import_ref ir2, inst+24, loaded [template = constants.%.11]
-// CHECK:STDOUT:   %import_ref.3 = import_ref ir2, inst+3, unloaded
-// CHECK:STDOUT:   %import_ref.4: Op = import_ref ir2, inst+19, loaded [template = constants.%struct.2]
+// CHECK:STDOUT:   %import_ref.1: type = import_ref ir4, inst+1, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.2 = import_ref ir4, inst+3, unloaded
+// CHECK:STDOUT:   %import_ref.3: <associated Op in Add> = import_ref ir4, inst+24, loaded [template = constants.%.11]
+// CHECK:STDOUT:   %import_ref.4: Op = import_ref ir4, inst+19, loaded [template = constants.%struct.2]
 // CHECK:STDOUT:   impl_decl @impl.1 {
-// CHECK:STDOUT:     %C.ref.loc9: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %Core.ref.loc9: <namespace> = name_ref Core, %Core [template = %Core]
+// CHECK:STDOUT:     %C.ref.loc12: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %Core.ref.loc12: <namespace> = name_ref Core, %Core [template = %Core]
 // CHECK:STDOUT:     %Add.ref: type = name_ref Add, %import_ref.1 [template = constants.%.2]
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.5: type = import_ref ir2, inst+26, loaded [template = constants.%.5]
-// CHECK:STDOUT:   %import_ref.6: <associated Op in AddAssign> = import_ref ir2, inst+47, loaded [template = constants.%.13]
-// CHECK:STDOUT:   %import_ref.7 = import_ref ir2, inst+28, unloaded
-// CHECK:STDOUT:   %import_ref.8: Op = import_ref ir2, inst+43, loaded [template = constants.%struct.4]
+// CHECK:STDOUT:   %import_ref.5: type = import_ref ir4, inst+26, loaded [template = constants.%.5]
+// CHECK:STDOUT:   %import_ref.6 = import_ref ir4, inst+28, unloaded
+// CHECK:STDOUT:   %import_ref.7: <associated Op in AddAssign> = import_ref ir4, inst+47, loaded [template = constants.%.13]
+// CHECK:STDOUT:   %import_ref.8: Op = import_ref ir4, inst+43, loaded [template = constants.%struct.4]
 // CHECK:STDOUT:   impl_decl @impl.2 {
-// CHECK:STDOUT:     %C.ref.loc12: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %Core.ref.loc12: <namespace> = name_ref Core, %Core [template = %Core]
+// CHECK:STDOUT:     %C.ref.loc15: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %Core.ref.loc15: <namespace> = name_ref Core, %Core [template = %Core]
 // CHECK:STDOUT:     %AddAssign.ref: type = name_ref AddAssign, %import_ref.5 [template = constants.%.5]
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %Test.decl: Test = fn_decl @Test [template = constants.%struct.5] {
-// CHECK:STDOUT:     %C.ref.loc16_12: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %a.loc16_9.1: C = param a
-// CHECK:STDOUT:     @Test.%a: C = bind_name a, %a.loc16_9.1
-// CHECK:STDOUT:     %D.ref.loc16: type = name_ref D, %D.decl [template = constants.%D]
-// CHECK:STDOUT:     %b.loc16_15.1: D = param b
-// CHECK:STDOUT:     @Test.%b: D = bind_name b, %b.loc16_15.1
-// CHECK:STDOUT:     %C.ref.loc16_24: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %C.ref.loc19_12: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %a.loc19_9.1: C = param a
+// CHECK:STDOUT:     @Test.%a: C = bind_name a, %a.loc19_9.1
+// CHECK:STDOUT:     %D.ref.loc19: type = name_ref D, %D.decl [template = constants.%D]
+// CHECK:STDOUT:     %b.loc19_15.1: D = param b
+// CHECK:STDOUT:     @Test.%b: D = bind_name b, %b.loc19_15.1
+// CHECK:STDOUT:     %C.ref.loc19_24: type = name_ref C, %C.decl [template = constants.%C]
 // CHECK:STDOUT:     @Test.%return: ref C = var <return slot>
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.9: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.10 = import_ref ir2, inst+19, unloaded
+// CHECK:STDOUT:   %import_ref.9: type = import_ref ir4, inst+1, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.10 = import_ref ir4, inst+19, unloaded
 // CHECK:STDOUT:   %TestAssign.decl: TestAssign = fn_decl @TestAssign [template = constants.%struct.6] {
-// CHECK:STDOUT:     %D.ref.loc27: type = name_ref D, %D.decl [template = constants.%D]
-// CHECK:STDOUT:     %b.loc27_15.1: D = param b
-// CHECK:STDOUT:     @TestAssign.%b: D = bind_name b, %b.loc27_15.1
+// CHECK:STDOUT:     %D.ref.loc30: type = name_ref D, %D.decl [template = constants.%D]
+// CHECK:STDOUT:     %b.loc30_15.1: D = param b
+// CHECK:STDOUT:     @TestAssign.%b: D = bind_name b, %b.loc30_15.1
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.11: type = import_ref ir2, inst+26, loaded [template = constants.%.5]
-// CHECK:STDOUT:   %import_ref.12 = import_ref ir2, inst+43, unloaded
+// CHECK:STDOUT:   %import_ref.11: type = import_ref ir4, inst+26, loaded [template = constants.%.5]
+// CHECK:STDOUT:   %import_ref.12 = import_ref ir4, inst+43, unloaded
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: interface @Add {
 // CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Op = file.%import_ref.2
-// CHECK:STDOUT:   .Self = file.%import_ref.3
+// CHECK:STDOUT:   .Self = file.%import_ref.2
+// CHECK:STDOUT:   .Op = file.%import_ref.3
 // CHECK:STDOUT:   witness = (file.%import_ref.4)
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: interface @AddAssign {
 // CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Op = file.%import_ref.6
-// CHECK:STDOUT:   .Self = file.%import_ref.7
+// CHECK:STDOUT:   .Self = file.%import_ref.6
+// CHECK:STDOUT:   .Op = file.%import_ref.7
 // CHECK:STDOUT:   witness = (file.%import_ref.8)
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: impl @impl.1: C as Add {
 // CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.1 [template = constants.%struct.1] {
-// CHECK:STDOUT:     %C.ref.loc10_15: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %self.loc10_9.1: C = param self
-// CHECK:STDOUT:     %self.loc10_9.2: C = bind_name self, %self.loc10_9.1
-// CHECK:STDOUT:     %C.ref.loc10_25: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %other.loc10_18.1: C = param other
-// CHECK:STDOUT:     %other.loc10_18.2: C = bind_name other, %other.loc10_18.1
-// CHECK:STDOUT:     %C.ref.loc10_31: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %C.ref.loc13_15: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %self.loc13_9.1: C = param self
+// CHECK:STDOUT:     %self.loc13_9.2: C = bind_name self, %self.loc13_9.1
+// CHECK:STDOUT:     %C.ref.loc13_25: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %other.loc13_18.1: C = param other
+// CHECK:STDOUT:     %other.loc13_18.2: C = bind_name other, %other.loc13_18.1
+// CHECK:STDOUT:     %C.ref.loc13_31: type = name_ref C, file.%C.decl [template = constants.%C]
 // CHECK:STDOUT:     %return.var: ref C = var <return slot>
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %.1: <witness> = interface_witness (%Op.decl) [template = constants.%.4]
@@ -254,14 +157,14 @@ fn TestAssign(b: D) {
 // CHECK:STDOUT:
 // CHECK:STDOUT: impl @impl.2: C as AddAssign {
 // CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.3 [template = constants.%struct.3] {
-// CHECK:STDOUT:     %C.ref.loc13_20: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %.loc13_21: type = ptr_type C [template = constants.%.6]
-// CHECK:STDOUT:     %self.loc13_14.1: C* = param self
-// CHECK:STDOUT:     %self.loc13_14.3: C* = bind_name self, %self.loc13_14.1
-// CHECK:STDOUT:     %.loc13_9: C* = addr_pattern %self.loc13_14.3
-// CHECK:STDOUT:     %C.ref.loc13_31: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %other.loc13_24.1: C = param other
-// CHECK:STDOUT:     %other.loc13_24.2: C = bind_name other, %other.loc13_24.1
+// CHECK:STDOUT:     %C.ref.loc16_20: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %.loc16_21: type = ptr_type C [template = constants.%.6]
+// CHECK:STDOUT:     %self.loc16_14.1: C* = param self
+// CHECK:STDOUT:     %self.loc16_14.3: C* = bind_name self, %self.loc16_14.1
+// CHECK:STDOUT:     %.loc16_9: C* = addr_pattern %self.loc16_14.3
+// CHECK:STDOUT:     %C.ref.loc16_31: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %other.loc16_24.1: C = param other
+// CHECK:STDOUT:     %other.loc16_24.2: C = bind_name other, %other.loc16_24.1
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %.1: <witness> = interface_witness (%Op.decl) [template = constants.%.8]
 // CHECK:STDOUT:
@@ -280,11 +183,11 @@ fn TestAssign(b: D) {
 // CHECK:STDOUT:   .Self = constants.%D
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.1[@impl.1.%self.loc10_9.2: C](@impl.1.%other.loc10_18.2: C) -> C;
+// CHECK:STDOUT: fn @Op.1[@impl.1.%self.loc13_9.2: C](@impl.1.%other.loc13_18.2: C) -> C;
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @Op.2[%self: Self](%other: Self) -> Self;
 // CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.3[addr @impl.2.%self.loc13_14.3: C*](@impl.2.%other.loc13_24.2: C);
+// CHECK:STDOUT: fn @Op.3[addr @impl.2.%self.loc16_14.3: C*](@impl.2.%other.loc16_24.2: C);
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @Op.4[addr %self: Self*](%other: Self);
 // CHECK:STDOUT:
@@ -293,9 +196,9 @@ fn TestAssign(b: D) {
 // CHECK:STDOUT:   %a.ref: C = name_ref a, %a
 // CHECK:STDOUT:   %b.ref: D = name_ref b, %b
 // CHECK:STDOUT:   %.1: Op = interface_witness_access @impl.1.%.1, element0 [template = constants.%struct.1]
-// CHECK:STDOUT:   %.loc24_12.1: <bound method> = bound_method %a.ref, %.1
-// CHECK:STDOUT:   %.loc24_12.2: ref C = temporary_storage
-// CHECK:STDOUT:   %Op.call: init C = call %.loc24_12.1(<invalid>) [template = <error>]
+// CHECK:STDOUT:   %.loc27_12.1: <bound method> = bound_method %a.ref, %.1
+// CHECK:STDOUT:   %.loc27_12.2: ref C = temporary_storage
+// CHECK:STDOUT:   %Op.call: init C = call %.loc27_12.1(<invalid>) [template = <error>]
 // CHECK:STDOUT:   return %Op.call to %return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
@@ -304,16 +207,16 @@ fn TestAssign(b: D) {
 // CHECK:STDOUT:   %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
 // CHECK:STDOUT:   %a.var: ref C = var a
 // CHECK:STDOUT:   %a: ref C = bind_name a, %a.var
-// CHECK:STDOUT:   %.loc28_15.1: {} = struct_literal ()
-// CHECK:STDOUT:   %.loc28_15.2: init C = class_init (), %a.var [template = constants.%struct.7]
-// CHECK:STDOUT:   %.loc28_16: init C = converted %.loc28_15.1, %.loc28_15.2 [template = constants.%struct.7]
-// CHECK:STDOUT:   assign %a.var, %.loc28_16
+// CHECK:STDOUT:   %.loc31_15.1: {} = struct_literal ()
+// CHECK:STDOUT:   %.loc31_15.2: init C = class_init (), %a.var [template = constants.%struct.7]
+// CHECK:STDOUT:   %.loc31_16: init C = converted %.loc31_15.1, %.loc31_15.2 [template = constants.%struct.7]
+// CHECK:STDOUT:   assign %a.var, %.loc31_16
 // CHECK:STDOUT:   %a.ref: ref C = name_ref a, %a
 // CHECK:STDOUT:   %b.ref: D = name_ref b, %b
 // CHECK:STDOUT:   %.1: Op = interface_witness_access @impl.2.%.1, element0 [template = constants.%struct.3]
-// CHECK:STDOUT:   %.loc35_5: <bound method> = bound_method %a.ref, %.1
-// CHECK:STDOUT:   %.loc35_3: C* = addr_of %a.ref
-// CHECK:STDOUT:   %Op.call: init () = call %.loc35_5(<invalid>) [template = <error>]
+// CHECK:STDOUT:   %.loc38_5: <bound method> = bound_method %a.ref, %.1
+// CHECK:STDOUT:   %.loc38_3: C* = addr_of %a.ref
+// CHECK:STDOUT:   %Op.call: init () = call %.loc38_5(<invalid>) [template = <error>]
 // CHECK:STDOUT:   return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 21 - 74
toolchain/check/testdata/operators/overloaded/inc.carbon

@@ -6,20 +6,8 @@
 
 // This file was generated from unary_stmt.carbon.tmpl. Run make_tests.sh to regenerate.
 
-// --- prelude.carbon
-
-package Core;
-
-interface Inc {
-  fn Op[addr self: Self*]();
-}
-
-// --- user.carbon
-
 package User;
 
-import Core;
-
 class C {};
 
 impl C as Core.Inc {
@@ -31,48 +19,7 @@ fn TestOp() {
   ++c;
 }
 
-// CHECK:STDOUT: --- prelude.carbon
-// CHECK:STDOUT:
-// CHECK:STDOUT: constants {
-// CHECK:STDOUT:   %.1: type = interface_type @Inc [template]
-// CHECK:STDOUT:   %Self: Inc = bind_symbolic_name Self 0 [symbolic]
-// CHECK:STDOUT:   %.2: type = ptr_type Self [symbolic]
-// CHECK:STDOUT:   %Op: type = fn_type @Op [template]
-// CHECK:STDOUT:   %.3: type = tuple_type () [template]
-// CHECK:STDOUT:   %struct: Op = struct_value () [template]
-// CHECK:STDOUT:   %.4: type = assoc_entity_type @Inc, Op [template]
-// CHECK:STDOUT:   %.5: <associated Op in Inc> = assoc_entity element0, @Inc.%Op.decl [template]
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace [template] {
-// CHECK:STDOUT:     .Inc = %Inc.decl
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %Inc.decl: type = interface_decl @Inc [template = constants.%.1] {}
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: interface @Inc {
-// CHECK:STDOUT:   %Self: Inc = bind_symbolic_name Self 0 [symbolic = constants.%Self]
-// CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op [template = constants.%struct] {
-// CHECK:STDOUT:     %Self.ref: Inc = name_ref Self, %Self [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc5_24.1: type = facet_type_access %Self.ref [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc5_24.2: type = converted %Self.ref, %.loc5_24.1 [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc5_24.3: type = ptr_type Self [symbolic = constants.%.2]
-// CHECK:STDOUT:     %self.loc5_14.1: Self* = param self
-// CHECK:STDOUT:     %self.loc5_14.3: Self* = bind_name self, %self.loc5_14.1
-// CHECK:STDOUT:     %.loc5_9: Self* = addr_pattern %self.loc5_14.3
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %.loc5_28: <associated Op in Inc> = assoc_entity element0, %Op.decl [template = constants.%.5]
-// CHECK:STDOUT:
-// CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Self = %Self
-// CHECK:STDOUT:   .Op = %.loc5_28
-// CHECK:STDOUT:   witness = (%Op.decl)
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op[addr @Inc.%self.loc5_14.3: Self*]();
-// CHECK:STDOUT:
-// CHECK:STDOUT: --- user.carbon
+// CHECK:STDOUT: --- inc.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: constants {
 // CHECK:STDOUT:   %C: type = class_type @C [template]
@@ -103,34 +50,34 @@ fn TestOp() {
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %Core: <namespace> = namespace [template] {}
 // CHECK:STDOUT:   %C.decl: type = class_decl @C [template = constants.%C] {}
-// CHECK:STDOUT:   %import_ref.1: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.2: <associated Op in Inc> = import_ref ir2, inst+18, loaded [template = constants.%.9]
-// CHECK:STDOUT:   %import_ref.3 = import_ref ir2, inst+3, unloaded
-// CHECK:STDOUT:   %import_ref.4: Op = import_ref ir2, inst+13, loaded [template = constants.%struct.2]
+// CHECK:STDOUT:   %import_ref.1: type = import_ref ir4, inst+49, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.2 = import_ref ir4, inst+51, unloaded
+// CHECK:STDOUT:   %import_ref.3: <associated Op in Inc> = import_ref ir4, inst+65, loaded [template = constants.%.9]
+// CHECK:STDOUT:   %import_ref.4: Op = import_ref ir4, inst+61, loaded [template = constants.%struct.2]
 // CHECK:STDOUT:   impl_decl @impl {
 // CHECK:STDOUT:     %C.ref: type = name_ref C, %C.decl [template = constants.%C]
 // CHECK:STDOUT:     %Core.ref: <namespace> = name_ref Core, %Core [template = %Core]
 // CHECK:STDOUT:     %Inc.ref: type = name_ref Inc, %import_ref.1 [template = constants.%.2]
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %TestOp.decl: TestOp = fn_decl @TestOp [template = constants.%struct.3] {}
-// CHECK:STDOUT:   %import_ref.5: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.6 = import_ref ir2, inst+13, unloaded
+// CHECK:STDOUT:   %import_ref.5: type = import_ref ir4, inst+49, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.6 = import_ref ir4, inst+61, unloaded
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: interface @Inc {
 // CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Op = file.%import_ref.2
-// CHECK:STDOUT:   .Self = file.%import_ref.3
+// CHECK:STDOUT:   .Self = file.%import_ref.2
+// CHECK:STDOUT:   .Op = file.%import_ref.3
 // CHECK:STDOUT:   witness = (file.%import_ref.4)
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: impl @impl: C as Inc {
 // CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.1 [template = constants.%struct.1] {
 // CHECK:STDOUT:     %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %.loc9_21: type = ptr_type C [template = constants.%.3]
-// CHECK:STDOUT:     %self.loc9_14.1: C* = param self
-// CHECK:STDOUT:     %self.loc9_14.3: C* = bind_name self, %self.loc9_14.1
-// CHECK:STDOUT:     %.loc9_9: C* = addr_pattern %self.loc9_14.3
+// CHECK:STDOUT:     %.loc14_21: type = ptr_type C [template = constants.%.3]
+// CHECK:STDOUT:     %self.loc14_14.1: C* = param self
+// CHECK:STDOUT:     %self.loc14_14.3: C* = bind_name self, %self.loc14_14.1
+// CHECK:STDOUT:     %.loc14_9: C* = addr_pattern %self.loc14_14.3
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %.1: <witness> = interface_witness (%Op.decl) [template = constants.%.6]
 // CHECK:STDOUT:
@@ -144,7 +91,7 @@ fn TestOp() {
 // CHECK:STDOUT:   .Self = constants.%C
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.1[addr @impl.%self.loc9_14.3: C*]();
+// CHECK:STDOUT: fn @Op.1[addr @impl.%self.loc14_14.3: C*]();
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @Op.2[addr %self: Self*]();
 // CHECK:STDOUT:
@@ -153,15 +100,15 @@ fn TestOp() {
 // CHECK:STDOUT:   %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
 // CHECK:STDOUT:   %c.var: ref C = var c
 // CHECK:STDOUT:   %c: ref C = bind_name c, %c.var
-// CHECK:STDOUT:   %.loc13_15.1: {} = struct_literal ()
-// CHECK:STDOUT:   %.loc13_15.2: init C = class_init (), %c.var [template = constants.%struct.4]
-// CHECK:STDOUT:   %.loc13_16: init C = converted %.loc13_15.1, %.loc13_15.2 [template = constants.%struct.4]
-// CHECK:STDOUT:   assign %c.var, %.loc13_16
+// CHECK:STDOUT:   %.loc18_15.1: {} = struct_literal ()
+// CHECK:STDOUT:   %.loc18_15.2: init C = class_init (), %c.var [template = constants.%struct.4]
+// CHECK:STDOUT:   %.loc18_16: init C = converted %.loc18_15.1, %.loc18_15.2 [template = constants.%struct.4]
+// CHECK:STDOUT:   assign %c.var, %.loc18_16
 // CHECK:STDOUT:   %c.ref: ref C = name_ref c, %c
 // CHECK:STDOUT:   %.1: Op = interface_witness_access @impl.%.1, element0 [template = constants.%struct.1]
-// CHECK:STDOUT:   %.loc14_3: <bound method> = bound_method %c.ref, %.1
-// CHECK:STDOUT:   %.loc14_5: C* = addr_of %c.ref
-// CHECK:STDOUT:   %Op.call: init () = call %.loc14_3(%.loc14_5)
+// CHECK:STDOUT:   %.loc19_3: <bound method> = bound_method %c.ref, %.1
+// CHECK:STDOUT:   %.loc19_5: C* = addr_of %c.ref
+// CHECK:STDOUT:   %Op.call: init () = call %.loc19_3(%.loc19_5)
 // CHECK:STDOUT:   return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 63 - 160
toolchain/check/testdata/operators/overloaded/left_shift.carbon

@@ -6,23 +6,8 @@
 
 // This file was generated from binary_op.carbon.tmpl. Run make_tests.sh to regenerate.
 
-// --- prelude.carbon
-
-package Core;
-
-interface LeftShift {
-  fn Op[self: Self](other: Self) -> Self;
-}
-interface LeftShiftAssign {
-  fn Op[addr self: Self*](other: Self);
-}
-
-// --- user.carbon
-
 package User;
 
-import Core;
-
 class C {};
 
 impl C as Core.LeftShift {
@@ -42,89 +27,7 @@ fn TestAssign(a: C*, b: C) {
   *a <<= b;
 }
 
-// CHECK:STDOUT: --- prelude.carbon
-// CHECK:STDOUT:
-// CHECK:STDOUT: constants {
-// CHECK:STDOUT:   %.1: type = interface_type @LeftShift [template]
-// CHECK:STDOUT:   %Self.1: LeftShift = bind_symbolic_name Self 0 [symbolic]
-// CHECK:STDOUT:   %Op.1: type = fn_type @Op.1 [template]
-// CHECK:STDOUT:   %.2: type = tuple_type () [template]
-// CHECK:STDOUT:   %struct.1: Op = struct_value () [template]
-// CHECK:STDOUT:   %.3: type = assoc_entity_type @LeftShift, Op [template]
-// CHECK:STDOUT:   %.4: <associated Op in LeftShift> = assoc_entity element0, @LeftShift.%Op.decl [template]
-// CHECK:STDOUT:   %.5: type = interface_type @LeftShiftAssign [template]
-// CHECK:STDOUT:   %Self.2: LeftShiftAssign = bind_symbolic_name Self 0 [symbolic]
-// CHECK:STDOUT:   %.6: type = ptr_type Self [symbolic]
-// CHECK:STDOUT:   %Op.2: type = fn_type @Op.2 [template]
-// CHECK:STDOUT:   %struct.2: Op = struct_value () [template]
-// CHECK:STDOUT:   %.7: type = assoc_entity_type @LeftShiftAssign, Op [template]
-// CHECK:STDOUT:   %.8: <associated Op in LeftShiftAssign> = assoc_entity element0, @LeftShiftAssign.%Op.decl [template]
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace [template] {
-// CHECK:STDOUT:     .LeftShift = %LeftShift.decl
-// CHECK:STDOUT:     .LeftShiftAssign = %LeftShiftAssign.decl
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %LeftShift.decl: type = interface_decl @LeftShift [template = constants.%.1] {}
-// CHECK:STDOUT:   %LeftShiftAssign.decl: type = interface_decl @LeftShiftAssign [template = constants.%.5] {}
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: interface @LeftShift {
-// CHECK:STDOUT:   %Self: LeftShift = bind_symbolic_name Self 0 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.1 [template = constants.%struct.1] {
-// CHECK:STDOUT:     %Self.ref.loc5_15: LeftShift = name_ref Self, %Self [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_15.1: type = facet_type_access %Self.ref.loc5_15 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_15.2: type = converted %Self.ref.loc5_15, %.loc5_15.1 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %self.loc5_9.1: Self = param self
-// CHECK:STDOUT:     %self.loc5_9.2: Self = bind_name self, %self.loc5_9.1
-// CHECK:STDOUT:     %Self.ref.loc5_28: LeftShift = name_ref Self, %Self [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_28.1: type = facet_type_access %Self.ref.loc5_28 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_28.2: type = converted %Self.ref.loc5_28, %.loc5_28.1 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %other.loc5_21.1: Self = param other
-// CHECK:STDOUT:     %other.loc5_21.2: Self = bind_name other, %other.loc5_21.1
-// CHECK:STDOUT:     %Self.ref.loc5_37: LeftShift = name_ref Self, %Self [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_37.1: type = facet_type_access %Self.ref.loc5_37 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_37.2: type = converted %Self.ref.loc5_37, %.loc5_37.1 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %return.var: ref Self = var <return slot>
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %.loc5_41: <associated Op in LeftShift> = assoc_entity element0, %Op.decl [template = constants.%.4]
-// CHECK:STDOUT:
-// CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Self = %Self
-// CHECK:STDOUT:   .Op = %.loc5_41
-// CHECK:STDOUT:   witness = (%Op.decl)
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: interface @LeftShiftAssign {
-// CHECK:STDOUT:   %Self: LeftShiftAssign = bind_symbolic_name Self 0 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.2 [template = constants.%struct.2] {
-// CHECK:STDOUT:     %Self.ref.loc8_20: LeftShiftAssign = name_ref Self, %Self [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_24.1: type = facet_type_access %Self.ref.loc8_20 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_24.2: type = converted %Self.ref.loc8_20, %.loc8_24.1 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_24.3: type = ptr_type Self [symbolic = constants.%.6]
-// CHECK:STDOUT:     %self.loc8_14.1: Self* = param self
-// CHECK:STDOUT:     %self.loc8_14.3: Self* = bind_name self, %self.loc8_14.1
-// CHECK:STDOUT:     %.loc8_9: Self* = addr_pattern %self.loc8_14.3
-// CHECK:STDOUT:     %Self.ref.loc8_34: LeftShiftAssign = name_ref Self, %Self [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_34.1: type = facet_type_access %Self.ref.loc8_34 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_34.2: type = converted %Self.ref.loc8_34, %.loc8_34.1 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %other.loc8_27.1: Self = param other
-// CHECK:STDOUT:     %other.loc8_27.2: Self = bind_name other, %other.loc8_27.1
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %.loc8_39: <associated Op in LeftShiftAssign> = assoc_entity element0, %Op.decl [template = constants.%.8]
-// CHECK:STDOUT:
-// CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Self = %Self
-// CHECK:STDOUT:   .Op = %.loc8_39
-// CHECK:STDOUT:   witness = (%Op.decl)
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.1[@LeftShift.%self.loc5_9.2: Self](@LeftShift.%other.loc5_21.2: Self) -> Self;
-// CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.2[addr @LeftShiftAssign.%self.loc8_14.3: Self*](@LeftShiftAssign.%other.loc8_27.2: Self);
-// CHECK:STDOUT:
-// CHECK:STDOUT: --- user.carbon
+// CHECK:STDOUT: --- left_shift.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: constants {
 // CHECK:STDOUT:   %C: type = class_type @C [template]
@@ -167,72 +70,72 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %Core: <namespace> = namespace [template] {}
 // CHECK:STDOUT:   %C.decl: type = class_decl @C [template = constants.%C] {}
-// CHECK:STDOUT:   %import_ref.1: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.2: <associated Op in LeftShift> = import_ref ir2, inst+24, loaded [template = constants.%.11]
-// CHECK:STDOUT:   %import_ref.3 = import_ref ir2, inst+3, unloaded
-// CHECK:STDOUT:   %import_ref.4: Op = import_ref ir2, inst+19, loaded [template = constants.%struct.2]
+// CHECK:STDOUT:   %import_ref.1: type = import_ref ir5, inst+162, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.2 = import_ref ir5, inst+164, unloaded
+// CHECK:STDOUT:   %import_ref.3: <associated Op in LeftShift> = import_ref ir5, inst+184, loaded [template = constants.%.11]
+// CHECK:STDOUT:   %import_ref.4: Op = import_ref ir5, inst+180, loaded [template = constants.%struct.2]
 // CHECK:STDOUT:   impl_decl @impl.1 {
-// CHECK:STDOUT:     %C.ref.loc8: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %Core.ref.loc8: <namespace> = name_ref Core, %Core [template = %Core]
+// CHECK:STDOUT:     %C.ref.loc13: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %Core.ref.loc13: <namespace> = name_ref Core, %Core [template = %Core]
 // CHECK:STDOUT:     %LeftShift.ref: type = name_ref LeftShift, %import_ref.1 [template = constants.%.2]
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.5: type = import_ref ir2, inst+26, loaded [template = constants.%.6]
-// CHECK:STDOUT:   %import_ref.6: <associated Op in LeftShiftAssign> = import_ref ir2, inst+47, loaded [template = constants.%.13]
-// CHECK:STDOUT:   %import_ref.7 = import_ref ir2, inst+28, unloaded
-// CHECK:STDOUT:   %import_ref.8: Op = import_ref ir2, inst+43, loaded [template = constants.%struct.5]
+// CHECK:STDOUT:   %import_ref.5: type = import_ref ir5, inst+186, loaded [template = constants.%.6]
+// CHECK:STDOUT:   %import_ref.6 = import_ref ir5, inst+188, unloaded
+// CHECK:STDOUT:   %import_ref.7: <associated Op in LeftShiftAssign> = import_ref ir5, inst+207, loaded [template = constants.%.13]
+// CHECK:STDOUT:   %import_ref.8: Op = import_ref ir5, inst+203, loaded [template = constants.%struct.5]
 // CHECK:STDOUT:   impl_decl @impl.2 {
-// CHECK:STDOUT:     %C.ref.loc13: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %Core.ref.loc13: <namespace> = name_ref Core, %Core [template = %Core]
+// CHECK:STDOUT:     %C.ref.loc18: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %Core.ref.loc18: <namespace> = name_ref Core, %Core [template = %Core]
 // CHECK:STDOUT:     %LeftShiftAssign.ref: type = name_ref LeftShiftAssign, %import_ref.5 [template = constants.%.6]
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %TestOp.decl: TestOp = fn_decl @TestOp [template = constants.%struct.6] {
-// CHECK:STDOUT:     %C.ref.loc17_14: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %a.loc17_11.1: C = param a
-// CHECK:STDOUT:     @TestOp.%a: C = bind_name a, %a.loc17_11.1
-// CHECK:STDOUT:     %C.ref.loc17_20: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %b.loc17_17.1: C = param b
-// CHECK:STDOUT:     @TestOp.%b: C = bind_name b, %b.loc17_17.1
-// CHECK:STDOUT:     %C.ref.loc17_26: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %C.ref.loc22_14: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %a.loc22_11.1: C = param a
+// CHECK:STDOUT:     @TestOp.%a: C = bind_name a, %a.loc22_11.1
+// CHECK:STDOUT:     %C.ref.loc22_20: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %b.loc22_17.1: C = param b
+// CHECK:STDOUT:     @TestOp.%b: C = bind_name b, %b.loc22_17.1
+// CHECK:STDOUT:     %C.ref.loc22_26: type = name_ref C, %C.decl [template = constants.%C]
 // CHECK:STDOUT:     @TestOp.%return: ref C = var <return slot>
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.9: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.10 = import_ref ir2, inst+19, unloaded
+// CHECK:STDOUT:   %import_ref.9: type = import_ref ir5, inst+162, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.10 = import_ref ir5, inst+180, unloaded
 // CHECK:STDOUT:   %TestAssign.decl: TestAssign = fn_decl @TestAssign [template = constants.%struct.7] {
-// CHECK:STDOUT:     %C.ref.loc21_18: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %.loc21: type = ptr_type C [template = constants.%.7]
-// CHECK:STDOUT:     %a.loc21_15.1: C* = param a
-// CHECK:STDOUT:     @TestAssign.%a: C* = bind_name a, %a.loc21_15.1
-// CHECK:STDOUT:     %C.ref.loc21_25: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %b.loc21_22.1: C = param b
-// CHECK:STDOUT:     @TestAssign.%b: C = bind_name b, %b.loc21_22.1
+// CHECK:STDOUT:     %C.ref.loc26_18: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %.loc26: type = ptr_type C [template = constants.%.7]
+// CHECK:STDOUT:     %a.loc26_15.1: C* = param a
+// CHECK:STDOUT:     @TestAssign.%a: C* = bind_name a, %a.loc26_15.1
+// CHECK:STDOUT:     %C.ref.loc26_25: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %b.loc26_22.1: C = param b
+// CHECK:STDOUT:     @TestAssign.%b: C = bind_name b, %b.loc26_22.1
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.11: type = import_ref ir2, inst+26, loaded [template = constants.%.6]
-// CHECK:STDOUT:   %import_ref.12 = import_ref ir2, inst+43, unloaded
+// CHECK:STDOUT:   %import_ref.11: type = import_ref ir5, inst+186, loaded [template = constants.%.6]
+// CHECK:STDOUT:   %import_ref.12 = import_ref ir5, inst+203, unloaded
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: interface @LeftShift {
 // CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Op = file.%import_ref.2
-// CHECK:STDOUT:   .Self = file.%import_ref.3
+// CHECK:STDOUT:   .Self = file.%import_ref.2
+// CHECK:STDOUT:   .Op = file.%import_ref.3
 // CHECK:STDOUT:   witness = (file.%import_ref.4)
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: interface @LeftShiftAssign {
 // CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Op = file.%import_ref.6
-// CHECK:STDOUT:   .Self = file.%import_ref.7
+// CHECK:STDOUT:   .Self = file.%import_ref.6
+// CHECK:STDOUT:   .Op = file.%import_ref.7
 // CHECK:STDOUT:   witness = (file.%import_ref.8)
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: impl @impl.1: C as LeftShift {
 // CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.1 [template = constants.%struct.1] {
-// CHECK:STDOUT:     %C.ref.loc9_15: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %self.loc9_9.1: C = param self
-// CHECK:STDOUT:     %self.loc9_9.2: C = bind_name self, %self.loc9_9.1
-// CHECK:STDOUT:     %C.ref.loc9_25: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %other.loc9_18.1: C = param other
-// CHECK:STDOUT:     %other.loc9_18.2: C = bind_name other, %other.loc9_18.1
-// CHECK:STDOUT:     %C.ref.loc9_31: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %C.ref.loc14_15: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %self.loc14_9.1: C = param self
+// CHECK:STDOUT:     %self.loc14_9.2: C = bind_name self, %self.loc14_9.1
+// CHECK:STDOUT:     %C.ref.loc14_25: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %other.loc14_18.1: C = param other
+// CHECK:STDOUT:     %other.loc14_18.2: C = bind_name other, %other.loc14_18.1
+// CHECK:STDOUT:     %C.ref.loc14_31: type = name_ref C, file.%C.decl [template = constants.%C]
 // CHECK:STDOUT:     %return.var: ref C = var <return slot>
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %.1: <witness> = interface_witness (%Op.decl) [template = constants.%.4]
@@ -244,14 +147,14 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:
 // CHECK:STDOUT: impl @impl.2: C as LeftShiftAssign {
 // CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.3 [template = constants.%struct.4] {
-// CHECK:STDOUT:     %C.ref.loc14_20: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %.loc14_21: type = ptr_type C [template = constants.%.7]
-// CHECK:STDOUT:     %self.loc14_14.1: C* = param self
-// CHECK:STDOUT:     %self.loc14_14.3: C* = bind_name self, %self.loc14_14.1
-// CHECK:STDOUT:     %.loc14_9: C* = addr_pattern %self.loc14_14.3
-// CHECK:STDOUT:     %C.ref.loc14_31: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %other.loc14_24.1: C = param other
-// CHECK:STDOUT:     %other.loc14_24.2: C = bind_name other, %other.loc14_24.1
+// CHECK:STDOUT:     %C.ref.loc19_20: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %.loc19_21: type = ptr_type C [template = constants.%.7]
+// CHECK:STDOUT:     %self.loc19_14.1: C* = param self
+// CHECK:STDOUT:     %self.loc19_14.3: C* = bind_name self, %self.loc19_14.1
+// CHECK:STDOUT:     %.loc19_9: C* = addr_pattern %self.loc19_14.3
+// CHECK:STDOUT:     %C.ref.loc19_31: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %other.loc19_24.1: C = param other
+// CHECK:STDOUT:     %other.loc19_24.2: C = bind_name other, %other.loc19_24.1
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %.1: <witness> = interface_witness (%Op.decl) [template = constants.%.9]
 // CHECK:STDOUT:
@@ -265,17 +168,17 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:   .Self = constants.%C
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.1[@impl.1.%self.loc9_9.2: C](@impl.1.%other.loc9_18.2: C) -> @impl.1.%return.var: C {
+// CHECK:STDOUT: fn @Op.1[@impl.1.%self.loc14_9.2: C](@impl.1.%other.loc14_18.2: C) -> @impl.1.%return.var: C {
 // CHECK:STDOUT: !entry:
-// CHECK:STDOUT:   %.loc10_13.1: {} = struct_literal ()
-// CHECK:STDOUT:   %.loc10_13.2: init C = class_init (), @impl.1.%return.var [template = constants.%struct.3]
-// CHECK:STDOUT:   %.loc10_14: init C = converted %.loc10_13.1, %.loc10_13.2 [template = constants.%struct.3]
-// CHECK:STDOUT:   return %.loc10_14 to @impl.1.%return.var
+// CHECK:STDOUT:   %.loc15_13.1: {} = struct_literal ()
+// CHECK:STDOUT:   %.loc15_13.2: init C = class_init (), @impl.1.%return.var [template = constants.%struct.3]
+// CHECK:STDOUT:   %.loc15_14: init C = converted %.loc15_13.1, %.loc15_13.2 [template = constants.%struct.3]
+// CHECK:STDOUT:   return %.loc15_14 to @impl.1.%return.var
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @Op.2[%self: Self](%other: Self) -> Self;
 // CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.3[addr @impl.2.%self.loc14_14.3: C*](@impl.2.%other.loc14_24.2: C) {
+// CHECK:STDOUT: fn @Op.3[addr @impl.2.%self.loc19_14.3: C*](@impl.2.%other.loc19_24.2: C) {
 // CHECK:STDOUT: !entry:
 // CHECK:STDOUT:   return
 // CHECK:STDOUT: }
@@ -287,21 +190,21 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:   %a.ref: C = name_ref a, %a
 // CHECK:STDOUT:   %b.ref: C = name_ref b, %b
 // CHECK:STDOUT:   %.1: Op = interface_witness_access @impl.1.%.1, element0 [template = constants.%struct.1]
-// CHECK:STDOUT:   %.loc18: <bound method> = bound_method %a.ref, %.1
-// CHECK:STDOUT:   %.loc17: ref C = splice_block %return {}
-// CHECK:STDOUT:   %Op.call: init C = call %.loc18(%a.ref, %b.ref) to %.loc17
+// CHECK:STDOUT:   %.loc23: <bound method> = bound_method %a.ref, %.1
+// CHECK:STDOUT:   %.loc22: ref C = splice_block %return {}
+// CHECK:STDOUT:   %Op.call: init C = call %.loc23(%a.ref, %b.ref) to %.loc22
 // CHECK:STDOUT:   return %Op.call to %return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @TestAssign(%a: C*, %b: C) {
 // CHECK:STDOUT: !entry:
 // CHECK:STDOUT:   %a.ref: C* = name_ref a, %a
-// CHECK:STDOUT:   %.loc22_3.1: ref C = deref %a.ref
+// CHECK:STDOUT:   %.loc27_3.1: ref C = deref %a.ref
 // CHECK:STDOUT:   %b.ref: C = name_ref b, %b
 // CHECK:STDOUT:   %.1: Op = interface_witness_access @impl.2.%.1, element0 [template = constants.%struct.4]
-// CHECK:STDOUT:   %.loc22_6: <bound method> = bound_method %.loc22_3.1, %.1
-// CHECK:STDOUT:   %.loc22_3.2: C* = addr_of %.loc22_3.1
-// CHECK:STDOUT:   %Op.call: init () = call %.loc22_6(%.loc22_3.2, %b.ref)
+// CHECK:STDOUT:   %.loc27_6: <bound method> = bound_method %.loc27_3.1, %.1
+// CHECK:STDOUT:   %.loc27_3.2: C* = addr_of %.loc27_3.1
+// CHECK:STDOUT:   %Op.call: init () = call %.loc27_6(%.loc27_3.2, %b.ref)
 // CHECK:STDOUT:   return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 63 - 160
toolchain/check/testdata/operators/overloaded/mod.carbon

@@ -6,23 +6,8 @@
 
 // This file was generated from binary_op.carbon.tmpl. Run make_tests.sh to regenerate.
 
-// --- prelude.carbon
-
-package Core;
-
-interface Mod {
-  fn Op[self: Self](other: Self) -> Self;
-}
-interface ModAssign {
-  fn Op[addr self: Self*](other: Self);
-}
-
-// --- user.carbon
-
 package User;
 
-import Core;
-
 class C {};
 
 impl C as Core.Mod {
@@ -42,89 +27,7 @@ fn TestAssign(a: C*, b: C) {
   *a %= b;
 }
 
-// CHECK:STDOUT: --- prelude.carbon
-// CHECK:STDOUT:
-// CHECK:STDOUT: constants {
-// CHECK:STDOUT:   %.1: type = interface_type @Mod [template]
-// CHECK:STDOUT:   %Self.1: Mod = bind_symbolic_name Self 0 [symbolic]
-// CHECK:STDOUT:   %Op.1: type = fn_type @Op.1 [template]
-// CHECK:STDOUT:   %.2: type = tuple_type () [template]
-// CHECK:STDOUT:   %struct.1: Op = struct_value () [template]
-// CHECK:STDOUT:   %.3: type = assoc_entity_type @Mod, Op [template]
-// CHECK:STDOUT:   %.4: <associated Op in Mod> = assoc_entity element0, @Mod.%Op.decl [template]
-// CHECK:STDOUT:   %.5: type = interface_type @ModAssign [template]
-// CHECK:STDOUT:   %Self.2: ModAssign = bind_symbolic_name Self 0 [symbolic]
-// CHECK:STDOUT:   %.6: type = ptr_type Self [symbolic]
-// CHECK:STDOUT:   %Op.2: type = fn_type @Op.2 [template]
-// CHECK:STDOUT:   %struct.2: Op = struct_value () [template]
-// CHECK:STDOUT:   %.7: type = assoc_entity_type @ModAssign, Op [template]
-// CHECK:STDOUT:   %.8: <associated Op in ModAssign> = assoc_entity element0, @ModAssign.%Op.decl [template]
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace [template] {
-// CHECK:STDOUT:     .Mod = %Mod.decl
-// CHECK:STDOUT:     .ModAssign = %ModAssign.decl
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %Mod.decl: type = interface_decl @Mod [template = constants.%.1] {}
-// CHECK:STDOUT:   %ModAssign.decl: type = interface_decl @ModAssign [template = constants.%.5] {}
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: interface @Mod {
-// CHECK:STDOUT:   %Self: Mod = bind_symbolic_name Self 0 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.1 [template = constants.%struct.1] {
-// CHECK:STDOUT:     %Self.ref.loc5_15: Mod = name_ref Self, %Self [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_15.1: type = facet_type_access %Self.ref.loc5_15 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_15.2: type = converted %Self.ref.loc5_15, %.loc5_15.1 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %self.loc5_9.1: Self = param self
-// CHECK:STDOUT:     %self.loc5_9.2: Self = bind_name self, %self.loc5_9.1
-// CHECK:STDOUT:     %Self.ref.loc5_28: Mod = name_ref Self, %Self [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_28.1: type = facet_type_access %Self.ref.loc5_28 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_28.2: type = converted %Self.ref.loc5_28, %.loc5_28.1 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %other.loc5_21.1: Self = param other
-// CHECK:STDOUT:     %other.loc5_21.2: Self = bind_name other, %other.loc5_21.1
-// CHECK:STDOUT:     %Self.ref.loc5_37: Mod = name_ref Self, %Self [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_37.1: type = facet_type_access %Self.ref.loc5_37 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_37.2: type = converted %Self.ref.loc5_37, %.loc5_37.1 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %return.var: ref Self = var <return slot>
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %.loc5_41: <associated Op in Mod> = assoc_entity element0, %Op.decl [template = constants.%.4]
-// CHECK:STDOUT:
-// CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Self = %Self
-// CHECK:STDOUT:   .Op = %.loc5_41
-// CHECK:STDOUT:   witness = (%Op.decl)
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: interface @ModAssign {
-// CHECK:STDOUT:   %Self: ModAssign = bind_symbolic_name Self 0 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.2 [template = constants.%struct.2] {
-// CHECK:STDOUT:     %Self.ref.loc8_20: ModAssign = name_ref Self, %Self [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_24.1: type = facet_type_access %Self.ref.loc8_20 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_24.2: type = converted %Self.ref.loc8_20, %.loc8_24.1 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_24.3: type = ptr_type Self [symbolic = constants.%.6]
-// CHECK:STDOUT:     %self.loc8_14.1: Self* = param self
-// CHECK:STDOUT:     %self.loc8_14.3: Self* = bind_name self, %self.loc8_14.1
-// CHECK:STDOUT:     %.loc8_9: Self* = addr_pattern %self.loc8_14.3
-// CHECK:STDOUT:     %Self.ref.loc8_34: ModAssign = name_ref Self, %Self [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_34.1: type = facet_type_access %Self.ref.loc8_34 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_34.2: type = converted %Self.ref.loc8_34, %.loc8_34.1 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %other.loc8_27.1: Self = param other
-// CHECK:STDOUT:     %other.loc8_27.2: Self = bind_name other, %other.loc8_27.1
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %.loc8_39: <associated Op in ModAssign> = assoc_entity element0, %Op.decl [template = constants.%.8]
-// CHECK:STDOUT:
-// CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Self = %Self
-// CHECK:STDOUT:   .Op = %.loc8_39
-// CHECK:STDOUT:   witness = (%Op.decl)
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.1[@Mod.%self.loc5_9.2: Self](@Mod.%other.loc5_21.2: Self) -> Self;
-// CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.2[addr @ModAssign.%self.loc8_14.3: Self*](@ModAssign.%other.loc8_27.2: Self);
-// CHECK:STDOUT:
-// CHECK:STDOUT: --- user.carbon
+// CHECK:STDOUT: --- mod.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: constants {
 // CHECK:STDOUT:   %C: type = class_type @C [template]
@@ -167,72 +70,72 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %Core: <namespace> = namespace [template] {}
 // CHECK:STDOUT:   %C.decl: type = class_decl @C [template = constants.%C] {}
-// CHECK:STDOUT:   %import_ref.1: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.2: <associated Op in Mod> = import_ref ir2, inst+24, loaded [template = constants.%.11]
-// CHECK:STDOUT:   %import_ref.3 = import_ref ir2, inst+3, unloaded
-// CHECK:STDOUT:   %import_ref.4: Op = import_ref ir2, inst+19, loaded [template = constants.%struct.2]
+// CHECK:STDOUT:   %import_ref.1: type = import_ref ir4, inst+245, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.2 = import_ref ir4, inst+247, unloaded
+// CHECK:STDOUT:   %import_ref.3: <associated Op in Mod> = import_ref ir4, inst+267, loaded [template = constants.%.11]
+// CHECK:STDOUT:   %import_ref.4: Op = import_ref ir4, inst+263, loaded [template = constants.%struct.2]
 // CHECK:STDOUT:   impl_decl @impl.1 {
-// CHECK:STDOUT:     %C.ref.loc8: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %Core.ref.loc8: <namespace> = name_ref Core, %Core [template = %Core]
+// CHECK:STDOUT:     %C.ref.loc13: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %Core.ref.loc13: <namespace> = name_ref Core, %Core [template = %Core]
 // CHECK:STDOUT:     %Mod.ref: type = name_ref Mod, %import_ref.1 [template = constants.%.2]
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.5: type = import_ref ir2, inst+26, loaded [template = constants.%.6]
-// CHECK:STDOUT:   %import_ref.6: <associated Op in ModAssign> = import_ref ir2, inst+47, loaded [template = constants.%.13]
-// CHECK:STDOUT:   %import_ref.7 = import_ref ir2, inst+28, unloaded
-// CHECK:STDOUT:   %import_ref.8: Op = import_ref ir2, inst+43, loaded [template = constants.%struct.5]
+// CHECK:STDOUT:   %import_ref.5: type = import_ref ir4, inst+269, loaded [template = constants.%.6]
+// CHECK:STDOUT:   %import_ref.6 = import_ref ir4, inst+271, unloaded
+// CHECK:STDOUT:   %import_ref.7: <associated Op in ModAssign> = import_ref ir4, inst+290, loaded [template = constants.%.13]
+// CHECK:STDOUT:   %import_ref.8: Op = import_ref ir4, inst+286, loaded [template = constants.%struct.5]
 // CHECK:STDOUT:   impl_decl @impl.2 {
-// CHECK:STDOUT:     %C.ref.loc13: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %Core.ref.loc13: <namespace> = name_ref Core, %Core [template = %Core]
+// CHECK:STDOUT:     %C.ref.loc18: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %Core.ref.loc18: <namespace> = name_ref Core, %Core [template = %Core]
 // CHECK:STDOUT:     %ModAssign.ref: type = name_ref ModAssign, %import_ref.5 [template = constants.%.6]
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %TestOp.decl: TestOp = fn_decl @TestOp [template = constants.%struct.6] {
-// CHECK:STDOUT:     %C.ref.loc17_14: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %a.loc17_11.1: C = param a
-// CHECK:STDOUT:     @TestOp.%a: C = bind_name a, %a.loc17_11.1
-// CHECK:STDOUT:     %C.ref.loc17_20: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %b.loc17_17.1: C = param b
-// CHECK:STDOUT:     @TestOp.%b: C = bind_name b, %b.loc17_17.1
-// CHECK:STDOUT:     %C.ref.loc17_26: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %C.ref.loc22_14: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %a.loc22_11.1: C = param a
+// CHECK:STDOUT:     @TestOp.%a: C = bind_name a, %a.loc22_11.1
+// CHECK:STDOUT:     %C.ref.loc22_20: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %b.loc22_17.1: C = param b
+// CHECK:STDOUT:     @TestOp.%b: C = bind_name b, %b.loc22_17.1
+// CHECK:STDOUT:     %C.ref.loc22_26: type = name_ref C, %C.decl [template = constants.%C]
 // CHECK:STDOUT:     @TestOp.%return: ref C = var <return slot>
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.9: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.10 = import_ref ir2, inst+19, unloaded
+// CHECK:STDOUT:   %import_ref.9: type = import_ref ir4, inst+245, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.10 = import_ref ir4, inst+263, unloaded
 // CHECK:STDOUT:   %TestAssign.decl: TestAssign = fn_decl @TestAssign [template = constants.%struct.7] {
-// CHECK:STDOUT:     %C.ref.loc21_18: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %.loc21: type = ptr_type C [template = constants.%.7]
-// CHECK:STDOUT:     %a.loc21_15.1: C* = param a
-// CHECK:STDOUT:     @TestAssign.%a: C* = bind_name a, %a.loc21_15.1
-// CHECK:STDOUT:     %C.ref.loc21_25: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %b.loc21_22.1: C = param b
-// CHECK:STDOUT:     @TestAssign.%b: C = bind_name b, %b.loc21_22.1
+// CHECK:STDOUT:     %C.ref.loc26_18: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %.loc26: type = ptr_type C [template = constants.%.7]
+// CHECK:STDOUT:     %a.loc26_15.1: C* = param a
+// CHECK:STDOUT:     @TestAssign.%a: C* = bind_name a, %a.loc26_15.1
+// CHECK:STDOUT:     %C.ref.loc26_25: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %b.loc26_22.1: C = param b
+// CHECK:STDOUT:     @TestAssign.%b: C = bind_name b, %b.loc26_22.1
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.11: type = import_ref ir2, inst+26, loaded [template = constants.%.6]
-// CHECK:STDOUT:   %import_ref.12 = import_ref ir2, inst+43, unloaded
+// CHECK:STDOUT:   %import_ref.11: type = import_ref ir4, inst+269, loaded [template = constants.%.6]
+// CHECK:STDOUT:   %import_ref.12 = import_ref ir4, inst+286, unloaded
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: interface @Mod {
 // CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Op = file.%import_ref.2
-// CHECK:STDOUT:   .Self = file.%import_ref.3
+// CHECK:STDOUT:   .Self = file.%import_ref.2
+// CHECK:STDOUT:   .Op = file.%import_ref.3
 // CHECK:STDOUT:   witness = (file.%import_ref.4)
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: interface @ModAssign {
 // CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Op = file.%import_ref.6
-// CHECK:STDOUT:   .Self = file.%import_ref.7
+// CHECK:STDOUT:   .Self = file.%import_ref.6
+// CHECK:STDOUT:   .Op = file.%import_ref.7
 // CHECK:STDOUT:   witness = (file.%import_ref.8)
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: impl @impl.1: C as Mod {
 // CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.1 [template = constants.%struct.1] {
-// CHECK:STDOUT:     %C.ref.loc9_15: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %self.loc9_9.1: C = param self
-// CHECK:STDOUT:     %self.loc9_9.2: C = bind_name self, %self.loc9_9.1
-// CHECK:STDOUT:     %C.ref.loc9_25: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %other.loc9_18.1: C = param other
-// CHECK:STDOUT:     %other.loc9_18.2: C = bind_name other, %other.loc9_18.1
-// CHECK:STDOUT:     %C.ref.loc9_31: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %C.ref.loc14_15: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %self.loc14_9.1: C = param self
+// CHECK:STDOUT:     %self.loc14_9.2: C = bind_name self, %self.loc14_9.1
+// CHECK:STDOUT:     %C.ref.loc14_25: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %other.loc14_18.1: C = param other
+// CHECK:STDOUT:     %other.loc14_18.2: C = bind_name other, %other.loc14_18.1
+// CHECK:STDOUT:     %C.ref.loc14_31: type = name_ref C, file.%C.decl [template = constants.%C]
 // CHECK:STDOUT:     %return.var: ref C = var <return slot>
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %.1: <witness> = interface_witness (%Op.decl) [template = constants.%.4]
@@ -244,14 +147,14 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:
 // CHECK:STDOUT: impl @impl.2: C as ModAssign {
 // CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.3 [template = constants.%struct.4] {
-// CHECK:STDOUT:     %C.ref.loc14_20: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %.loc14_21: type = ptr_type C [template = constants.%.7]
-// CHECK:STDOUT:     %self.loc14_14.1: C* = param self
-// CHECK:STDOUT:     %self.loc14_14.3: C* = bind_name self, %self.loc14_14.1
-// CHECK:STDOUT:     %.loc14_9: C* = addr_pattern %self.loc14_14.3
-// CHECK:STDOUT:     %C.ref.loc14_31: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %other.loc14_24.1: C = param other
-// CHECK:STDOUT:     %other.loc14_24.2: C = bind_name other, %other.loc14_24.1
+// CHECK:STDOUT:     %C.ref.loc19_20: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %.loc19_21: type = ptr_type C [template = constants.%.7]
+// CHECK:STDOUT:     %self.loc19_14.1: C* = param self
+// CHECK:STDOUT:     %self.loc19_14.3: C* = bind_name self, %self.loc19_14.1
+// CHECK:STDOUT:     %.loc19_9: C* = addr_pattern %self.loc19_14.3
+// CHECK:STDOUT:     %C.ref.loc19_31: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %other.loc19_24.1: C = param other
+// CHECK:STDOUT:     %other.loc19_24.2: C = bind_name other, %other.loc19_24.1
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %.1: <witness> = interface_witness (%Op.decl) [template = constants.%.9]
 // CHECK:STDOUT:
@@ -265,17 +168,17 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:   .Self = constants.%C
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.1[@impl.1.%self.loc9_9.2: C](@impl.1.%other.loc9_18.2: C) -> @impl.1.%return.var: C {
+// CHECK:STDOUT: fn @Op.1[@impl.1.%self.loc14_9.2: C](@impl.1.%other.loc14_18.2: C) -> @impl.1.%return.var: C {
 // CHECK:STDOUT: !entry:
-// CHECK:STDOUT:   %.loc10_13.1: {} = struct_literal ()
-// CHECK:STDOUT:   %.loc10_13.2: init C = class_init (), @impl.1.%return.var [template = constants.%struct.3]
-// CHECK:STDOUT:   %.loc10_14: init C = converted %.loc10_13.1, %.loc10_13.2 [template = constants.%struct.3]
-// CHECK:STDOUT:   return %.loc10_14 to @impl.1.%return.var
+// CHECK:STDOUT:   %.loc15_13.1: {} = struct_literal ()
+// CHECK:STDOUT:   %.loc15_13.2: init C = class_init (), @impl.1.%return.var [template = constants.%struct.3]
+// CHECK:STDOUT:   %.loc15_14: init C = converted %.loc15_13.1, %.loc15_13.2 [template = constants.%struct.3]
+// CHECK:STDOUT:   return %.loc15_14 to @impl.1.%return.var
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @Op.2[%self: Self](%other: Self) -> Self;
 // CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.3[addr @impl.2.%self.loc14_14.3: C*](@impl.2.%other.loc14_24.2: C) {
+// CHECK:STDOUT: fn @Op.3[addr @impl.2.%self.loc19_14.3: C*](@impl.2.%other.loc19_24.2: C) {
 // CHECK:STDOUT: !entry:
 // CHECK:STDOUT:   return
 // CHECK:STDOUT: }
@@ -287,21 +190,21 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:   %a.ref: C = name_ref a, %a
 // CHECK:STDOUT:   %b.ref: C = name_ref b, %b
 // CHECK:STDOUT:   %.1: Op = interface_witness_access @impl.1.%.1, element0 [template = constants.%struct.1]
-// CHECK:STDOUT:   %.loc18: <bound method> = bound_method %a.ref, %.1
-// CHECK:STDOUT:   %.loc17: ref C = splice_block %return {}
-// CHECK:STDOUT:   %Op.call: init C = call %.loc18(%a.ref, %b.ref) to %.loc17
+// CHECK:STDOUT:   %.loc23: <bound method> = bound_method %a.ref, %.1
+// CHECK:STDOUT:   %.loc22: ref C = splice_block %return {}
+// CHECK:STDOUT:   %Op.call: init C = call %.loc23(%a.ref, %b.ref) to %.loc22
 // CHECK:STDOUT:   return %Op.call to %return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @TestAssign(%a: C*, %b: C) {
 // CHECK:STDOUT: !entry:
 // CHECK:STDOUT:   %a.ref: C* = name_ref a, %a
-// CHECK:STDOUT:   %.loc22_3.1: ref C = deref %a.ref
+// CHECK:STDOUT:   %.loc27_3.1: ref C = deref %a.ref
 // CHECK:STDOUT:   %b.ref: C = name_ref b, %b
 // CHECK:STDOUT:   %.1: Op = interface_witness_access @impl.2.%.1, element0 [template = constants.%struct.4]
-// CHECK:STDOUT:   %.loc22_6: <bound method> = bound_method %.loc22_3.1, %.1
-// CHECK:STDOUT:   %.loc22_3.2: C* = addr_of %.loc22_3.1
-// CHECK:STDOUT:   %Op.call: init () = call %.loc22_6(%.loc22_3.2, %b.ref)
+// CHECK:STDOUT:   %.loc27_6: <bound method> = bound_method %.loc27_3.1, %.1
+// CHECK:STDOUT:   %.loc27_3.2: C* = addr_of %.loc27_3.1
+// CHECK:STDOUT:   %Op.call: init () = call %.loc27_6(%.loc27_3.2, %b.ref)
 // CHECK:STDOUT:   return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 63 - 160
toolchain/check/testdata/operators/overloaded/mul.carbon

@@ -6,23 +6,8 @@
 
 // This file was generated from binary_op.carbon.tmpl. Run make_tests.sh to regenerate.
 
-// --- prelude.carbon
-
-package Core;
-
-interface Mul {
-  fn Op[self: Self](other: Self) -> Self;
-}
-interface MulAssign {
-  fn Op[addr self: Self*](other: Self);
-}
-
-// --- user.carbon
-
 package User;
 
-import Core;
-
 class C {};
 
 impl C as Core.Mul {
@@ -42,89 +27,7 @@ fn TestAssign(a: C*, b: C) {
   *a *= b;
 }
 
-// CHECK:STDOUT: --- prelude.carbon
-// CHECK:STDOUT:
-// CHECK:STDOUT: constants {
-// CHECK:STDOUT:   %.1: type = interface_type @Mul [template]
-// CHECK:STDOUT:   %Self.1: Mul = bind_symbolic_name Self 0 [symbolic]
-// CHECK:STDOUT:   %Op.1: type = fn_type @Op.1 [template]
-// CHECK:STDOUT:   %.2: type = tuple_type () [template]
-// CHECK:STDOUT:   %struct.1: Op = struct_value () [template]
-// CHECK:STDOUT:   %.3: type = assoc_entity_type @Mul, Op [template]
-// CHECK:STDOUT:   %.4: <associated Op in Mul> = assoc_entity element0, @Mul.%Op.decl [template]
-// CHECK:STDOUT:   %.5: type = interface_type @MulAssign [template]
-// CHECK:STDOUT:   %Self.2: MulAssign = bind_symbolic_name Self 0 [symbolic]
-// CHECK:STDOUT:   %.6: type = ptr_type Self [symbolic]
-// CHECK:STDOUT:   %Op.2: type = fn_type @Op.2 [template]
-// CHECK:STDOUT:   %struct.2: Op = struct_value () [template]
-// CHECK:STDOUT:   %.7: type = assoc_entity_type @MulAssign, Op [template]
-// CHECK:STDOUT:   %.8: <associated Op in MulAssign> = assoc_entity element0, @MulAssign.%Op.decl [template]
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace [template] {
-// CHECK:STDOUT:     .Mul = %Mul.decl
-// CHECK:STDOUT:     .MulAssign = %MulAssign.decl
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %Mul.decl: type = interface_decl @Mul [template = constants.%.1] {}
-// CHECK:STDOUT:   %MulAssign.decl: type = interface_decl @MulAssign [template = constants.%.5] {}
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: interface @Mul {
-// CHECK:STDOUT:   %Self: Mul = bind_symbolic_name Self 0 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.1 [template = constants.%struct.1] {
-// CHECK:STDOUT:     %Self.ref.loc5_15: Mul = name_ref Self, %Self [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_15.1: type = facet_type_access %Self.ref.loc5_15 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_15.2: type = converted %Self.ref.loc5_15, %.loc5_15.1 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %self.loc5_9.1: Self = param self
-// CHECK:STDOUT:     %self.loc5_9.2: Self = bind_name self, %self.loc5_9.1
-// CHECK:STDOUT:     %Self.ref.loc5_28: Mul = name_ref Self, %Self [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_28.1: type = facet_type_access %Self.ref.loc5_28 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_28.2: type = converted %Self.ref.loc5_28, %.loc5_28.1 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %other.loc5_21.1: Self = param other
-// CHECK:STDOUT:     %other.loc5_21.2: Self = bind_name other, %other.loc5_21.1
-// CHECK:STDOUT:     %Self.ref.loc5_37: Mul = name_ref Self, %Self [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_37.1: type = facet_type_access %Self.ref.loc5_37 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_37.2: type = converted %Self.ref.loc5_37, %.loc5_37.1 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %return.var: ref Self = var <return slot>
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %.loc5_41: <associated Op in Mul> = assoc_entity element0, %Op.decl [template = constants.%.4]
-// CHECK:STDOUT:
-// CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Self = %Self
-// CHECK:STDOUT:   .Op = %.loc5_41
-// CHECK:STDOUT:   witness = (%Op.decl)
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: interface @MulAssign {
-// CHECK:STDOUT:   %Self: MulAssign = bind_symbolic_name Self 0 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.2 [template = constants.%struct.2] {
-// CHECK:STDOUT:     %Self.ref.loc8_20: MulAssign = name_ref Self, %Self [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_24.1: type = facet_type_access %Self.ref.loc8_20 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_24.2: type = converted %Self.ref.loc8_20, %.loc8_24.1 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_24.3: type = ptr_type Self [symbolic = constants.%.6]
-// CHECK:STDOUT:     %self.loc8_14.1: Self* = param self
-// CHECK:STDOUT:     %self.loc8_14.3: Self* = bind_name self, %self.loc8_14.1
-// CHECK:STDOUT:     %.loc8_9: Self* = addr_pattern %self.loc8_14.3
-// CHECK:STDOUT:     %Self.ref.loc8_34: MulAssign = name_ref Self, %Self [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_34.1: type = facet_type_access %Self.ref.loc8_34 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_34.2: type = converted %Self.ref.loc8_34, %.loc8_34.1 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %other.loc8_27.1: Self = param other
-// CHECK:STDOUT:     %other.loc8_27.2: Self = bind_name other, %other.loc8_27.1
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %.loc8_39: <associated Op in MulAssign> = assoc_entity element0, %Op.decl [template = constants.%.8]
-// CHECK:STDOUT:
-// CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Self = %Self
-// CHECK:STDOUT:   .Op = %.loc8_39
-// CHECK:STDOUT:   witness = (%Op.decl)
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.1[@Mul.%self.loc5_9.2: Self](@Mul.%other.loc5_21.2: Self) -> Self;
-// CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.2[addr @MulAssign.%self.loc8_14.3: Self*](@MulAssign.%other.loc8_27.2: Self);
-// CHECK:STDOUT:
-// CHECK:STDOUT: --- user.carbon
+// CHECK:STDOUT: --- mul.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: constants {
 // CHECK:STDOUT:   %C: type = class_type @C [template]
@@ -167,72 +70,72 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %Core: <namespace> = namespace [template] {}
 // CHECK:STDOUT:   %C.decl: type = class_decl @C [template = constants.%C] {}
-// CHECK:STDOUT:   %import_ref.1: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.2: <associated Op in Mul> = import_ref ir2, inst+24, loaded [template = constants.%.11]
-// CHECK:STDOUT:   %import_ref.3 = import_ref ir2, inst+3, unloaded
-// CHECK:STDOUT:   %import_ref.4: Op = import_ref ir2, inst+19, loaded [template = constants.%struct.2]
+// CHECK:STDOUT:   %import_ref.1: type = import_ref ir4, inst+151, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.2 = import_ref ir4, inst+153, unloaded
+// CHECK:STDOUT:   %import_ref.3: <associated Op in Mul> = import_ref ir4, inst+173, loaded [template = constants.%.11]
+// CHECK:STDOUT:   %import_ref.4: Op = import_ref ir4, inst+169, loaded [template = constants.%struct.2]
 // CHECK:STDOUT:   impl_decl @impl.1 {
-// CHECK:STDOUT:     %C.ref.loc8: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %Core.ref.loc8: <namespace> = name_ref Core, %Core [template = %Core]
+// CHECK:STDOUT:     %C.ref.loc13: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %Core.ref.loc13: <namespace> = name_ref Core, %Core [template = %Core]
 // CHECK:STDOUT:     %Mul.ref: type = name_ref Mul, %import_ref.1 [template = constants.%.2]
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.5: type = import_ref ir2, inst+26, loaded [template = constants.%.6]
-// CHECK:STDOUT:   %import_ref.6: <associated Op in MulAssign> = import_ref ir2, inst+47, loaded [template = constants.%.13]
-// CHECK:STDOUT:   %import_ref.7 = import_ref ir2, inst+28, unloaded
-// CHECK:STDOUT:   %import_ref.8: Op = import_ref ir2, inst+43, loaded [template = constants.%struct.5]
+// CHECK:STDOUT:   %import_ref.5: type = import_ref ir4, inst+175, loaded [template = constants.%.6]
+// CHECK:STDOUT:   %import_ref.6 = import_ref ir4, inst+177, unloaded
+// CHECK:STDOUT:   %import_ref.7: <associated Op in MulAssign> = import_ref ir4, inst+196, loaded [template = constants.%.13]
+// CHECK:STDOUT:   %import_ref.8: Op = import_ref ir4, inst+192, loaded [template = constants.%struct.5]
 // CHECK:STDOUT:   impl_decl @impl.2 {
-// CHECK:STDOUT:     %C.ref.loc13: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %Core.ref.loc13: <namespace> = name_ref Core, %Core [template = %Core]
+// CHECK:STDOUT:     %C.ref.loc18: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %Core.ref.loc18: <namespace> = name_ref Core, %Core [template = %Core]
 // CHECK:STDOUT:     %MulAssign.ref: type = name_ref MulAssign, %import_ref.5 [template = constants.%.6]
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %TestOp.decl: TestOp = fn_decl @TestOp [template = constants.%struct.6] {
-// CHECK:STDOUT:     %C.ref.loc17_14: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %a.loc17_11.1: C = param a
-// CHECK:STDOUT:     @TestOp.%a: C = bind_name a, %a.loc17_11.1
-// CHECK:STDOUT:     %C.ref.loc17_20: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %b.loc17_17.1: C = param b
-// CHECK:STDOUT:     @TestOp.%b: C = bind_name b, %b.loc17_17.1
-// CHECK:STDOUT:     %C.ref.loc17_26: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %C.ref.loc22_14: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %a.loc22_11.1: C = param a
+// CHECK:STDOUT:     @TestOp.%a: C = bind_name a, %a.loc22_11.1
+// CHECK:STDOUT:     %C.ref.loc22_20: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %b.loc22_17.1: C = param b
+// CHECK:STDOUT:     @TestOp.%b: C = bind_name b, %b.loc22_17.1
+// CHECK:STDOUT:     %C.ref.loc22_26: type = name_ref C, %C.decl [template = constants.%C]
 // CHECK:STDOUT:     @TestOp.%return: ref C = var <return slot>
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.9: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.10 = import_ref ir2, inst+19, unloaded
+// CHECK:STDOUT:   %import_ref.9: type = import_ref ir4, inst+151, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.10 = import_ref ir4, inst+169, unloaded
 // CHECK:STDOUT:   %TestAssign.decl: TestAssign = fn_decl @TestAssign [template = constants.%struct.7] {
-// CHECK:STDOUT:     %C.ref.loc21_18: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %.loc21: type = ptr_type C [template = constants.%.7]
-// CHECK:STDOUT:     %a.loc21_15.1: C* = param a
-// CHECK:STDOUT:     @TestAssign.%a: C* = bind_name a, %a.loc21_15.1
-// CHECK:STDOUT:     %C.ref.loc21_25: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %b.loc21_22.1: C = param b
-// CHECK:STDOUT:     @TestAssign.%b: C = bind_name b, %b.loc21_22.1
+// CHECK:STDOUT:     %C.ref.loc26_18: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %.loc26: type = ptr_type C [template = constants.%.7]
+// CHECK:STDOUT:     %a.loc26_15.1: C* = param a
+// CHECK:STDOUT:     @TestAssign.%a: C* = bind_name a, %a.loc26_15.1
+// CHECK:STDOUT:     %C.ref.loc26_25: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %b.loc26_22.1: C = param b
+// CHECK:STDOUT:     @TestAssign.%b: C = bind_name b, %b.loc26_22.1
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.11: type = import_ref ir2, inst+26, loaded [template = constants.%.6]
-// CHECK:STDOUT:   %import_ref.12 = import_ref ir2, inst+43, unloaded
+// CHECK:STDOUT:   %import_ref.11: type = import_ref ir4, inst+175, loaded [template = constants.%.6]
+// CHECK:STDOUT:   %import_ref.12 = import_ref ir4, inst+192, unloaded
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: interface @Mul {
 // CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Op = file.%import_ref.2
-// CHECK:STDOUT:   .Self = file.%import_ref.3
+// CHECK:STDOUT:   .Self = file.%import_ref.2
+// CHECK:STDOUT:   .Op = file.%import_ref.3
 // CHECK:STDOUT:   witness = (file.%import_ref.4)
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: interface @MulAssign {
 // CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Op = file.%import_ref.6
-// CHECK:STDOUT:   .Self = file.%import_ref.7
+// CHECK:STDOUT:   .Self = file.%import_ref.6
+// CHECK:STDOUT:   .Op = file.%import_ref.7
 // CHECK:STDOUT:   witness = (file.%import_ref.8)
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: impl @impl.1: C as Mul {
 // CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.1 [template = constants.%struct.1] {
-// CHECK:STDOUT:     %C.ref.loc9_15: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %self.loc9_9.1: C = param self
-// CHECK:STDOUT:     %self.loc9_9.2: C = bind_name self, %self.loc9_9.1
-// CHECK:STDOUT:     %C.ref.loc9_25: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %other.loc9_18.1: C = param other
-// CHECK:STDOUT:     %other.loc9_18.2: C = bind_name other, %other.loc9_18.1
-// CHECK:STDOUT:     %C.ref.loc9_31: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %C.ref.loc14_15: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %self.loc14_9.1: C = param self
+// CHECK:STDOUT:     %self.loc14_9.2: C = bind_name self, %self.loc14_9.1
+// CHECK:STDOUT:     %C.ref.loc14_25: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %other.loc14_18.1: C = param other
+// CHECK:STDOUT:     %other.loc14_18.2: C = bind_name other, %other.loc14_18.1
+// CHECK:STDOUT:     %C.ref.loc14_31: type = name_ref C, file.%C.decl [template = constants.%C]
 // CHECK:STDOUT:     %return.var: ref C = var <return slot>
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %.1: <witness> = interface_witness (%Op.decl) [template = constants.%.4]
@@ -244,14 +147,14 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:
 // CHECK:STDOUT: impl @impl.2: C as MulAssign {
 // CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.3 [template = constants.%struct.4] {
-// CHECK:STDOUT:     %C.ref.loc14_20: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %.loc14_21: type = ptr_type C [template = constants.%.7]
-// CHECK:STDOUT:     %self.loc14_14.1: C* = param self
-// CHECK:STDOUT:     %self.loc14_14.3: C* = bind_name self, %self.loc14_14.1
-// CHECK:STDOUT:     %.loc14_9: C* = addr_pattern %self.loc14_14.3
-// CHECK:STDOUT:     %C.ref.loc14_31: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %other.loc14_24.1: C = param other
-// CHECK:STDOUT:     %other.loc14_24.2: C = bind_name other, %other.loc14_24.1
+// CHECK:STDOUT:     %C.ref.loc19_20: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %.loc19_21: type = ptr_type C [template = constants.%.7]
+// CHECK:STDOUT:     %self.loc19_14.1: C* = param self
+// CHECK:STDOUT:     %self.loc19_14.3: C* = bind_name self, %self.loc19_14.1
+// CHECK:STDOUT:     %.loc19_9: C* = addr_pattern %self.loc19_14.3
+// CHECK:STDOUT:     %C.ref.loc19_31: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %other.loc19_24.1: C = param other
+// CHECK:STDOUT:     %other.loc19_24.2: C = bind_name other, %other.loc19_24.1
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %.1: <witness> = interface_witness (%Op.decl) [template = constants.%.9]
 // CHECK:STDOUT:
@@ -265,17 +168,17 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:   .Self = constants.%C
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.1[@impl.1.%self.loc9_9.2: C](@impl.1.%other.loc9_18.2: C) -> @impl.1.%return.var: C {
+// CHECK:STDOUT: fn @Op.1[@impl.1.%self.loc14_9.2: C](@impl.1.%other.loc14_18.2: C) -> @impl.1.%return.var: C {
 // CHECK:STDOUT: !entry:
-// CHECK:STDOUT:   %.loc10_13.1: {} = struct_literal ()
-// CHECK:STDOUT:   %.loc10_13.2: init C = class_init (), @impl.1.%return.var [template = constants.%struct.3]
-// CHECK:STDOUT:   %.loc10_14: init C = converted %.loc10_13.1, %.loc10_13.2 [template = constants.%struct.3]
-// CHECK:STDOUT:   return %.loc10_14 to @impl.1.%return.var
+// CHECK:STDOUT:   %.loc15_13.1: {} = struct_literal ()
+// CHECK:STDOUT:   %.loc15_13.2: init C = class_init (), @impl.1.%return.var [template = constants.%struct.3]
+// CHECK:STDOUT:   %.loc15_14: init C = converted %.loc15_13.1, %.loc15_13.2 [template = constants.%struct.3]
+// CHECK:STDOUT:   return %.loc15_14 to @impl.1.%return.var
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @Op.2[%self: Self](%other: Self) -> Self;
 // CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.3[addr @impl.2.%self.loc14_14.3: C*](@impl.2.%other.loc14_24.2: C) {
+// CHECK:STDOUT: fn @Op.3[addr @impl.2.%self.loc19_14.3: C*](@impl.2.%other.loc19_24.2: C) {
 // CHECK:STDOUT: !entry:
 // CHECK:STDOUT:   return
 // CHECK:STDOUT: }
@@ -287,21 +190,21 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:   %a.ref: C = name_ref a, %a
 // CHECK:STDOUT:   %b.ref: C = name_ref b, %b
 // CHECK:STDOUT:   %.1: Op = interface_witness_access @impl.1.%.1, element0 [template = constants.%struct.1]
-// CHECK:STDOUT:   %.loc18: <bound method> = bound_method %a.ref, %.1
-// CHECK:STDOUT:   %.loc17: ref C = splice_block %return {}
-// CHECK:STDOUT:   %Op.call: init C = call %.loc18(%a.ref, %b.ref) to %.loc17
+// CHECK:STDOUT:   %.loc23: <bound method> = bound_method %a.ref, %.1
+// CHECK:STDOUT:   %.loc22: ref C = splice_block %return {}
+// CHECK:STDOUT:   %Op.call: init C = call %.loc23(%a.ref, %b.ref) to %.loc22
 // CHECK:STDOUT:   return %Op.call to %return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @TestAssign(%a: C*, %b: C) {
 // CHECK:STDOUT: !entry:
 // CHECK:STDOUT:   %a.ref: C* = name_ref a, %a
-// CHECK:STDOUT:   %.loc22_3.1: ref C = deref %a.ref
+// CHECK:STDOUT:   %.loc27_3.1: ref C = deref %a.ref
 // CHECK:STDOUT:   %b.ref: C = name_ref b, %b
 // CHECK:STDOUT:   %.1: Op = interface_witness_access @impl.2.%.1, element0 [template = constants.%struct.4]
-// CHECK:STDOUT:   %.loc22_6: <bound method> = bound_method %.loc22_3.1, %.1
-// CHECK:STDOUT:   %.loc22_3.2: C* = addr_of %.loc22_3.1
-// CHECK:STDOUT:   %Op.call: init () = call %.loc22_6(%.loc22_3.2, %b.ref)
+// CHECK:STDOUT:   %.loc27_6: <bound method> = bound_method %.loc27_3.1, %.1
+// CHECK:STDOUT:   %.loc27_3.2: C* = addr_of %.loc27_3.1
+// CHECK:STDOUT:   %Op.call: init () = call %.loc27_6(%.loc27_3.2, %b.ref)
 // CHECK:STDOUT:   return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 26 - 80
toolchain/check/testdata/operators/overloaded/negate.carbon

@@ -6,20 +6,8 @@
 
 // This file was generated from unary_op.carbon.tmpl. Run make_tests.sh to regenerate.
 
-// --- prelude.carbon
-
-package Core;
-
-interface Negate {
-  fn Op[self: Self]() -> Self;
-}
-
-// --- user.carbon
-
 package User;
 
-import Core;
-
 class C {};
 
 impl C as Core.Negate {
@@ -32,49 +20,7 @@ fn TestOp(a: C) -> C {
   return -a;
 }
 
-// CHECK:STDOUT: --- prelude.carbon
-// CHECK:STDOUT:
-// CHECK:STDOUT: constants {
-// CHECK:STDOUT:   %.1: type = interface_type @Negate [template]
-// CHECK:STDOUT:   %Self: Negate = bind_symbolic_name Self 0 [symbolic]
-// CHECK:STDOUT:   %Op: type = fn_type @Op [template]
-// CHECK:STDOUT:   %.2: type = tuple_type () [template]
-// CHECK:STDOUT:   %struct: Op = struct_value () [template]
-// CHECK:STDOUT:   %.3: type = assoc_entity_type @Negate, Op [template]
-// CHECK:STDOUT:   %.4: <associated Op in Negate> = assoc_entity element0, @Negate.%Op.decl [template]
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace [template] {
-// CHECK:STDOUT:     .Negate = %Negate.decl
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %Negate.decl: type = interface_decl @Negate [template = constants.%.1] {}
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: interface @Negate {
-// CHECK:STDOUT:   %Self: Negate = bind_symbolic_name Self 0 [symbolic = constants.%Self]
-// CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op [template = constants.%struct] {
-// CHECK:STDOUT:     %Self.ref.loc5_15: Negate = name_ref Self, %Self [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc5_15.1: type = facet_type_access %Self.ref.loc5_15 [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc5_15.2: type = converted %Self.ref.loc5_15, %.loc5_15.1 [symbolic = constants.%Self]
-// CHECK:STDOUT:     %self.loc5_9.1: Self = param self
-// CHECK:STDOUT:     %self.loc5_9.2: Self = bind_name self, %self.loc5_9.1
-// CHECK:STDOUT:     %Self.ref.loc5_26: Negate = name_ref Self, %Self [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc5_26.1: type = facet_type_access %Self.ref.loc5_26 [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc5_26.2: type = converted %Self.ref.loc5_26, %.loc5_26.1 [symbolic = constants.%Self]
-// CHECK:STDOUT:     %return.var: ref Self = var <return slot>
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %.loc5_30: <associated Op in Negate> = assoc_entity element0, %Op.decl [template = constants.%.4]
-// CHECK:STDOUT:
-// CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Self = %Self
-// CHECK:STDOUT:   .Op = %.loc5_30
-// CHECK:STDOUT:   witness = (%Op.decl)
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op[@Negate.%self.loc5_9.2: Self]() -> Self;
-// CHECK:STDOUT:
-// CHECK:STDOUT: --- user.carbon
+// CHECK:STDOUT: --- negate.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: constants {
 // CHECK:STDOUT:   %C: type = class_type @C [template]
@@ -103,39 +49,39 @@ fn TestOp(a: C) -> C {
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %Core: <namespace> = namespace [template] {}
 // CHECK:STDOUT:   %C.decl: type = class_decl @C [template = constants.%C] {}
-// CHECK:STDOUT:   %import_ref.1: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.2: <associated Op in Negate> = import_ref ir2, inst+19, loaded [template = constants.%.7]
-// CHECK:STDOUT:   %import_ref.3 = import_ref ir2, inst+3, unloaded
-// CHECK:STDOUT:   %import_ref.4: Op = import_ref ir2, inst+14, loaded [template = constants.%struct.2]
+// CHECK:STDOUT:   %import_ref.1: type = import_ref ir4, inst+67, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.2 = import_ref ir4, inst+69, unloaded
+// CHECK:STDOUT:   %import_ref.3: <associated Op in Negate> = import_ref ir4, inst+84, loaded [template = constants.%.7]
+// CHECK:STDOUT:   %import_ref.4: Op = import_ref ir4, inst+80, loaded [template = constants.%struct.2]
 // CHECK:STDOUT:   impl_decl @impl {
-// CHECK:STDOUT:     %C.ref.loc8: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %C.ref.loc13: type = name_ref C, %C.decl [template = constants.%C]
 // CHECK:STDOUT:     %Core.ref: <namespace> = name_ref Core, %Core [template = %Core]
 // CHECK:STDOUT:     %Negate.ref: type = name_ref Negate, %import_ref.1 [template = constants.%.2]
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %TestOp.decl: TestOp = fn_decl @TestOp [template = constants.%struct.4] {
-// CHECK:STDOUT:     %C.ref.loc14_14: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %a.loc14_11.1: C = param a
-// CHECK:STDOUT:     @TestOp.%a: C = bind_name a, %a.loc14_11.1
-// CHECK:STDOUT:     %C.ref.loc14_20: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %C.ref.loc19_14: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %a.loc19_11.1: C = param a
+// CHECK:STDOUT:     @TestOp.%a: C = bind_name a, %a.loc19_11.1
+// CHECK:STDOUT:     %C.ref.loc19_20: type = name_ref C, %C.decl [template = constants.%C]
 // CHECK:STDOUT:     @TestOp.%return: ref C = var <return slot>
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.5: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.6 = import_ref ir2, inst+14, unloaded
+// CHECK:STDOUT:   %import_ref.5: type = import_ref ir4, inst+67, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.6 = import_ref ir4, inst+80, unloaded
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: interface @Negate {
 // CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Op = file.%import_ref.2
-// CHECK:STDOUT:   .Self = file.%import_ref.3
+// CHECK:STDOUT:   .Self = file.%import_ref.2
+// CHECK:STDOUT:   .Op = file.%import_ref.3
 // CHECK:STDOUT:   witness = (file.%import_ref.4)
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: impl @impl: C as Negate {
 // CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.1 [template = constants.%struct.1] {
-// CHECK:STDOUT:     %C.ref.loc9_15: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %self.loc9_9.1: C = param self
-// CHECK:STDOUT:     %self.loc9_9.2: C = bind_name self, %self.loc9_9.1
-// CHECK:STDOUT:     %C.ref.loc9_23: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %C.ref.loc14_15: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %self.loc14_9.1: C = param self
+// CHECK:STDOUT:     %self.loc14_9.2: C = bind_name self, %self.loc14_9.1
+// CHECK:STDOUT:     %C.ref.loc14_23: type = name_ref C, file.%C.decl [template = constants.%C]
 // CHECK:STDOUT:     %return.var: ref C = var <return slot>
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %.1: <witness> = interface_witness (%Op.decl) [template = constants.%.4]
@@ -150,12 +96,12 @@ fn TestOp(a: C) -> C {
 // CHECK:STDOUT:   .Self = constants.%C
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.1[@impl.%self.loc9_9.2: C]() -> @impl.%return.var: C {
+// CHECK:STDOUT: fn @Op.1[@impl.%self.loc14_9.2: C]() -> @impl.%return.var: C {
 // CHECK:STDOUT: !entry:
-// CHECK:STDOUT:   %.loc10_13.1: {} = struct_literal ()
-// CHECK:STDOUT:   %.loc10_13.2: init C = class_init (), @impl.%return.var [template = constants.%struct.3]
-// CHECK:STDOUT:   %.loc10_14: init C = converted %.loc10_13.1, %.loc10_13.2 [template = constants.%struct.3]
-// CHECK:STDOUT:   return %.loc10_14 to @impl.%return.var
+// CHECK:STDOUT:   %.loc15_13.1: {} = struct_literal ()
+// CHECK:STDOUT:   %.loc15_13.2: init C = class_init (), @impl.%return.var [template = constants.%struct.3]
+// CHECK:STDOUT:   %.loc15_14: init C = converted %.loc15_13.1, %.loc15_13.2 [template = constants.%struct.3]
+// CHECK:STDOUT:   return %.loc15_14 to @impl.%return.var
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @Op.2[%self: Self]() -> Self;
@@ -164,9 +110,9 @@ fn TestOp(a: C) -> C {
 // CHECK:STDOUT: !entry:
 // CHECK:STDOUT:   %a.ref: C = name_ref a, %a
 // CHECK:STDOUT:   %.1: Op = interface_witness_access @impl.%.1, element0 [template = constants.%struct.1]
-// CHECK:STDOUT:   %.loc15: <bound method> = bound_method %a.ref, %.1
-// CHECK:STDOUT:   %.loc14: ref C = splice_block %return {}
-// CHECK:STDOUT:   %Op.call: init C = call %.loc15(%a.ref) to %.loc14
+// CHECK:STDOUT:   %.loc20: <bound method> = bound_method %a.ref, %.1
+// CHECK:STDOUT:   %.loc19: ref C = splice_block %return {}
+// CHECK:STDOUT:   %Op.call: init C = call %.loc20(%a.ref) to %.loc19
 // CHECK:STDOUT:   return %Op.call to %return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 146 - 271
toolchain/check/testdata/operators/overloaded/ordered.carbon

@@ -4,26 +4,10 @@
 //
 // AUTOUPDATE
 
-// --- prelude.carbon
-
-package Core;
-
-import library "prelude";
-
-interface Ordered {
-  // TODO: fn Compare
-  fn Less[self: Self](other: Self) -> bool;
-  fn LessOrEquivalent[self: Self](other: Self) -> bool;
-  fn Greater[self: Self](other: Self) -> bool;
-  fn GreaterOrEquivalent[self: Self](other: Self) -> bool;
-}
-
 // --- user.carbon
 
 package User;
 
-import Core;
-
 class C {};
 
 impl C as Core.Ordered {
@@ -53,8 +37,6 @@ fn TestGreaterEqual(a: C, b: C) -> bool {
 
 package FailNoImpl;
 
-import Core;
-
 class D {};
 
 fn TestLess(a: D, b: D) -> bool {
@@ -88,113 +70,6 @@ fn TestGreaterEqual(a: D, b: D) -> bool {
   return a >= b;
 }
 
-// CHECK:STDOUT: --- prelude.carbon
-// CHECK:STDOUT:
-// CHECK:STDOUT: constants {
-// CHECK:STDOUT:   %.1: type = interface_type @Ordered [template]
-// CHECK:STDOUT:   %Self: Ordered = bind_symbolic_name Self 0 [symbolic]
-// CHECK:STDOUT:   %Less: type = fn_type @Less [template]
-// CHECK:STDOUT:   %.2: type = tuple_type () [template]
-// CHECK:STDOUT:   %struct.1: Less = struct_value () [template]
-// CHECK:STDOUT:   %.3: type = assoc_entity_type @Ordered, Less [template]
-// CHECK:STDOUT:   %.4: <associated Less in Ordered> = assoc_entity element0, @Ordered.%Less.decl [template]
-// CHECK:STDOUT:   %LessOrEquivalent: type = fn_type @LessOrEquivalent [template]
-// CHECK:STDOUT:   %struct.2: LessOrEquivalent = struct_value () [template]
-// CHECK:STDOUT:   %.5: type = assoc_entity_type @Ordered, LessOrEquivalent [template]
-// CHECK:STDOUT:   %.6: <associated LessOrEquivalent in Ordered> = assoc_entity element1, @Ordered.%LessOrEquivalent.decl [template]
-// CHECK:STDOUT:   %Greater: type = fn_type @Greater [template]
-// CHECK:STDOUT:   %struct.3: Greater = struct_value () [template]
-// CHECK:STDOUT:   %.7: type = assoc_entity_type @Ordered, Greater [template]
-// CHECK:STDOUT:   %.8: <associated Greater in Ordered> = assoc_entity element2, @Ordered.%Greater.decl [template]
-// CHECK:STDOUT:   %GreaterOrEquivalent: type = fn_type @GreaterOrEquivalent [template]
-// CHECK:STDOUT:   %struct.4: GreaterOrEquivalent = struct_value () [template]
-// CHECK:STDOUT:   %.9: type = assoc_entity_type @Ordered, GreaterOrEquivalent [template]
-// CHECK:STDOUT:   %.10: <associated GreaterOrEquivalent in Ordered> = assoc_entity element3, @Ordered.%GreaterOrEquivalent.decl [template]
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace [template] {
-// CHECK:STDOUT:     .Ordered = %Ordered.decl
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %Ordered.decl: type = interface_decl @Ordered [template = constants.%.1] {}
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: interface @Ordered {
-// CHECK:STDOUT:   %Self: Ordered = bind_symbolic_name Self 0 [symbolic = constants.%Self]
-// CHECK:STDOUT:   %Less.decl: Less = fn_decl @Less [template = constants.%struct.1] {
-// CHECK:STDOUT:     %Self.ref.loc8_17: Ordered = name_ref Self, %Self [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc8_17.1: type = facet_type_access %Self.ref.loc8_17 [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc8_17.2: type = converted %Self.ref.loc8_17, %.loc8_17.1 [symbolic = constants.%Self]
-// CHECK:STDOUT:     %self.loc8_11.1: Self = param self
-// CHECK:STDOUT:     %self.loc8_11.2: Self = bind_name self, %self.loc8_11.1
-// CHECK:STDOUT:     %Self.ref.loc8_30: Ordered = name_ref Self, %Self [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc8_30.1: type = facet_type_access %Self.ref.loc8_30 [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc8_30.2: type = converted %Self.ref.loc8_30, %.loc8_30.1 [symbolic = constants.%Self]
-// CHECK:STDOUT:     %other.loc8_23.1: Self = param other
-// CHECK:STDOUT:     %other.loc8_23.2: Self = bind_name other, %other.loc8_23.1
-// CHECK:STDOUT:     %return.var.loc8: ref bool = var <return slot>
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %.loc8_43: <associated Less in Ordered> = assoc_entity element0, %Less.decl [template = constants.%.4]
-// CHECK:STDOUT:   %LessOrEquivalent.decl: LessOrEquivalent = fn_decl @LessOrEquivalent [template = constants.%struct.2] {
-// CHECK:STDOUT:     %Self.ref.loc9_29: Ordered = name_ref Self, %Self [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc9_29.1: type = facet_type_access %Self.ref.loc9_29 [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc9_29.2: type = converted %Self.ref.loc9_29, %.loc9_29.1 [symbolic = constants.%Self]
-// CHECK:STDOUT:     %self.loc9_23.1: Self = param self
-// CHECK:STDOUT:     %self.loc9_23.2: Self = bind_name self, %self.loc9_23.1
-// CHECK:STDOUT:     %Self.ref.loc9_42: Ordered = name_ref Self, %Self [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc9_42.1: type = facet_type_access %Self.ref.loc9_42 [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc9_42.2: type = converted %Self.ref.loc9_42, %.loc9_42.1 [symbolic = constants.%Self]
-// CHECK:STDOUT:     %other.loc9_35.1: Self = param other
-// CHECK:STDOUT:     %other.loc9_35.2: Self = bind_name other, %other.loc9_35.1
-// CHECK:STDOUT:     %return.var.loc9: ref bool = var <return slot>
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %.loc9_55: <associated LessOrEquivalent in Ordered> = assoc_entity element1, %LessOrEquivalent.decl [template = constants.%.6]
-// CHECK:STDOUT:   %Greater.decl: Greater = fn_decl @Greater [template = constants.%struct.3] {
-// CHECK:STDOUT:     %Self.ref.loc10_20: Ordered = name_ref Self, %Self [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc10_20.1: type = facet_type_access %Self.ref.loc10_20 [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc10_20.2: type = converted %Self.ref.loc10_20, %.loc10_20.1 [symbolic = constants.%Self]
-// CHECK:STDOUT:     %self.loc10_14.1: Self = param self
-// CHECK:STDOUT:     %self.loc10_14.2: Self = bind_name self, %self.loc10_14.1
-// CHECK:STDOUT:     %Self.ref.loc10_33: Ordered = name_ref Self, %Self [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc10_33.1: type = facet_type_access %Self.ref.loc10_33 [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc10_33.2: type = converted %Self.ref.loc10_33, %.loc10_33.1 [symbolic = constants.%Self]
-// CHECK:STDOUT:     %other.loc10_26.1: Self = param other
-// CHECK:STDOUT:     %other.loc10_26.2: Self = bind_name other, %other.loc10_26.1
-// CHECK:STDOUT:     %return.var.loc10: ref bool = var <return slot>
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %.loc10_46: <associated Greater in Ordered> = assoc_entity element2, %Greater.decl [template = constants.%.8]
-// CHECK:STDOUT:   %GreaterOrEquivalent.decl: GreaterOrEquivalent = fn_decl @GreaterOrEquivalent [template = constants.%struct.4] {
-// CHECK:STDOUT:     %Self.ref.loc11_32: Ordered = name_ref Self, %Self [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc11_32.1: type = facet_type_access %Self.ref.loc11_32 [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc11_32.2: type = converted %Self.ref.loc11_32, %.loc11_32.1 [symbolic = constants.%Self]
-// CHECK:STDOUT:     %self.loc11_26.1: Self = param self
-// CHECK:STDOUT:     %self.loc11_26.2: Self = bind_name self, %self.loc11_26.1
-// CHECK:STDOUT:     %Self.ref.loc11_45: Ordered = name_ref Self, %Self [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc11_45.1: type = facet_type_access %Self.ref.loc11_45 [symbolic = constants.%Self]
-// CHECK:STDOUT:     %.loc11_45.2: type = converted %Self.ref.loc11_45, %.loc11_45.1 [symbolic = constants.%Self]
-// CHECK:STDOUT:     %other.loc11_38.1: Self = param other
-// CHECK:STDOUT:     %other.loc11_38.2: Self = bind_name other, %other.loc11_38.1
-// CHECK:STDOUT:     %return.var.loc11: ref bool = var <return slot>
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %.loc11_58: <associated GreaterOrEquivalent in Ordered> = assoc_entity element3, %GreaterOrEquivalent.decl [template = constants.%.10]
-// CHECK:STDOUT:
-// CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Self = %Self
-// CHECK:STDOUT:   .Less = %.loc8_43
-// CHECK:STDOUT:   .LessOrEquivalent = %.loc9_55
-// CHECK:STDOUT:   .Greater = %.loc10_46
-// CHECK:STDOUT:   .GreaterOrEquivalent = %.loc11_58
-// CHECK:STDOUT:   witness = (%Less.decl, %LessOrEquivalent.decl, %Greater.decl, %GreaterOrEquivalent.decl)
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: fn @Less[@Ordered.%self.loc8_11.2: Self](@Ordered.%other.loc8_23.2: Self) -> bool;
-// CHECK:STDOUT:
-// CHECK:STDOUT: fn @LessOrEquivalent[@Ordered.%self.loc9_23.2: Self](@Ordered.%other.loc9_35.2: Self) -> bool;
-// CHECK:STDOUT:
-// CHECK:STDOUT: fn @Greater[@Ordered.%self.loc10_14.2: Self](@Ordered.%other.loc10_26.2: Self) -> bool;
-// CHECK:STDOUT:
-// CHECK:STDOUT: fn @GreaterOrEquivalent[@Ordered.%self.loc11_26.2: Self](@Ordered.%other.loc11_38.2: Self) -> bool;
-// CHECK:STDOUT:
 // CHECK:STDOUT: --- user.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: constants {
@@ -250,113 +125,113 @@ fn TestGreaterEqual(a: D, b: D) -> bool {
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %Core: <namespace> = namespace [template] {}
 // CHECK:STDOUT:   %C.decl: type = class_decl @C [template = constants.%C] {}
-// CHECK:STDOUT:   %import_ref.1: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.2: <associated GreaterOrEquivalent in Ordered> = import_ref ir2, inst+72, loaded [template = constants.%.13]
-// CHECK:STDOUT:   %import_ref.3 = import_ref ir2, inst+3, unloaded
-// CHECK:STDOUT:   %import_ref.4: <associated Greater in Ordered> = import_ref ir2, inst+55, loaded [template = constants.%.11]
-// CHECK:STDOUT:   %import_ref.5: <associated Less in Ordered> = import_ref ir2, inst+21, loaded [template = constants.%.7]
-// CHECK:STDOUT:   %import_ref.6: <associated LessOrEquivalent in Ordered> = import_ref ir2, inst+38, loaded [template = constants.%.9]
-// CHECK:STDOUT:   %import_ref.7: Less = import_ref ir2, inst+16, loaded [template = constants.%struct.5]
-// CHECK:STDOUT:   %import_ref.8: LessOrEquivalent = import_ref ir2, inst+34, loaded [template = constants.%struct.6]
-// CHECK:STDOUT:   %import_ref.9: Greater = import_ref ir2, inst+51, loaded [template = constants.%struct.7]
-// CHECK:STDOUT:   %import_ref.10: GreaterOrEquivalent = import_ref ir2, inst+68, loaded [template = constants.%struct.8]
+// CHECK:STDOUT:   %import_ref.1: type = import_ref ir6, inst+40, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.2: <associated Less in Ordered> = import_ref ir6, inst+59, loaded [template = constants.%.7]
+// CHECK:STDOUT:   %import_ref.3: <associated Greater in Ordered> = import_ref ir6, inst+93, loaded [template = constants.%.11]
+// CHECK:STDOUT:   %import_ref.4 = import_ref ir6, inst+42, unloaded
+// CHECK:STDOUT:   %import_ref.5: <associated LessOrEquivalent in Ordered> = import_ref ir6, inst+76, loaded [template = constants.%.9]
+// CHECK:STDOUT:   %import_ref.6: <associated GreaterOrEquivalent in Ordered> = import_ref ir6, inst+110, loaded [template = constants.%.13]
+// CHECK:STDOUT:   %import_ref.7: Less = import_ref ir6, inst+55, loaded [template = constants.%struct.5]
+// CHECK:STDOUT:   %import_ref.8: LessOrEquivalent = import_ref ir6, inst+72, loaded [template = constants.%struct.6]
+// CHECK:STDOUT:   %import_ref.9: Greater = import_ref ir6, inst+89, loaded [template = constants.%struct.7]
+// CHECK:STDOUT:   %import_ref.10: GreaterOrEquivalent = import_ref ir6, inst+106, loaded [template = constants.%struct.8]
 // CHECK:STDOUT:   impl_decl @impl {
-// CHECK:STDOUT:     %C.ref.loc8: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %C.ref.loc6: type = name_ref C, %C.decl [template = constants.%C]
 // CHECK:STDOUT:     %Core.ref: <namespace> = name_ref Core, %Core [template = %Core]
 // CHECK:STDOUT:     %Ordered.ref: type = name_ref Ordered, %import_ref.1 [template = constants.%.2]
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %TestLess.decl: TestLess = fn_decl @TestLess [template = constants.%struct.9] {
-// CHECK:STDOUT:     %C.ref.loc15_16: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %a.loc15_13.1: C = param a
-// CHECK:STDOUT:     @TestLess.%a: C = bind_name a, %a.loc15_13.1
-// CHECK:STDOUT:     %C.ref.loc15_22: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %b.loc15_19.1: C = param b
-// CHECK:STDOUT:     @TestLess.%b: C = bind_name b, %b.loc15_19.1
+// CHECK:STDOUT:     %C.ref.loc13_16: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %a.loc13_13.1: C = param a
+// CHECK:STDOUT:     @TestLess.%a: C = bind_name a, %a.loc13_13.1
+// CHECK:STDOUT:     %C.ref.loc13_22: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %b.loc13_19.1: C = param b
+// CHECK:STDOUT:     @TestLess.%b: C = bind_name b, %b.loc13_19.1
 // CHECK:STDOUT:     @TestLess.%return: ref bool = var <return slot>
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.11: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.12 = import_ref ir2, inst+16, unloaded
+// CHECK:STDOUT:   %import_ref.11: type = import_ref ir6, inst+40, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.12 = import_ref ir6, inst+55, unloaded
 // CHECK:STDOUT:   %TestLessEqual.decl: TestLessEqual = fn_decl @TestLessEqual [template = constants.%struct.10] {
-// CHECK:STDOUT:     %C.ref.loc19_21: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %a.loc19_18.1: C = param a
-// CHECK:STDOUT:     @TestLessEqual.%a: C = bind_name a, %a.loc19_18.1
-// CHECK:STDOUT:     %C.ref.loc19_27: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %b.loc19_24.1: C = param b
-// CHECK:STDOUT:     @TestLessEqual.%b: C = bind_name b, %b.loc19_24.1
+// CHECK:STDOUT:     %C.ref.loc17_21: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %a.loc17_18.1: C = param a
+// CHECK:STDOUT:     @TestLessEqual.%a: C = bind_name a, %a.loc17_18.1
+// CHECK:STDOUT:     %C.ref.loc17_27: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %b.loc17_24.1: C = param b
+// CHECK:STDOUT:     @TestLessEqual.%b: C = bind_name b, %b.loc17_24.1
 // CHECK:STDOUT:     @TestLessEqual.%return: ref bool = var <return slot>
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.13: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.14 = import_ref ir2, inst+34, unloaded
+// CHECK:STDOUT:   %import_ref.13: type = import_ref ir6, inst+40, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.14 = import_ref ir6, inst+72, unloaded
 // CHECK:STDOUT:   %TestGreater.decl: TestGreater = fn_decl @TestGreater [template = constants.%struct.11] {
-// CHECK:STDOUT:     %C.ref.loc23_19: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %a.loc23_16.1: C = param a
-// CHECK:STDOUT:     @TestGreater.%a: C = bind_name a, %a.loc23_16.1
-// CHECK:STDOUT:     %C.ref.loc23_25: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %b.loc23_22.1: C = param b
-// CHECK:STDOUT:     @TestGreater.%b: C = bind_name b, %b.loc23_22.1
+// CHECK:STDOUT:     %C.ref.loc21_19: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %a.loc21_16.1: C = param a
+// CHECK:STDOUT:     @TestGreater.%a: C = bind_name a, %a.loc21_16.1
+// CHECK:STDOUT:     %C.ref.loc21_25: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %b.loc21_22.1: C = param b
+// CHECK:STDOUT:     @TestGreater.%b: C = bind_name b, %b.loc21_22.1
 // CHECK:STDOUT:     @TestGreater.%return: ref bool = var <return slot>
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.15: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.16 = import_ref ir2, inst+51, unloaded
+// CHECK:STDOUT:   %import_ref.15: type = import_ref ir6, inst+40, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.16 = import_ref ir6, inst+89, unloaded
 // CHECK:STDOUT:   %TestGreaterEqual.decl: TestGreaterEqual = fn_decl @TestGreaterEqual [template = constants.%struct.12] {
-// CHECK:STDOUT:     %C.ref.loc27_24: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %a.loc27_21.1: C = param a
-// CHECK:STDOUT:     @TestGreaterEqual.%a: C = bind_name a, %a.loc27_21.1
-// CHECK:STDOUT:     %C.ref.loc27_30: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %b.loc27_27.1: C = param b
-// CHECK:STDOUT:     @TestGreaterEqual.%b: C = bind_name b, %b.loc27_27.1
+// CHECK:STDOUT:     %C.ref.loc25_24: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %a.loc25_21.1: C = param a
+// CHECK:STDOUT:     @TestGreaterEqual.%a: C = bind_name a, %a.loc25_21.1
+// CHECK:STDOUT:     %C.ref.loc25_30: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %b.loc25_27.1: C = param b
+// CHECK:STDOUT:     @TestGreaterEqual.%b: C = bind_name b, %b.loc25_27.1
 // CHECK:STDOUT:     @TestGreaterEqual.%return: ref bool = var <return slot>
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.17: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.18 = import_ref ir2, inst+68, unloaded
+// CHECK:STDOUT:   %import_ref.17: type = import_ref ir6, inst+40, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.18 = import_ref ir6, inst+106, unloaded
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: interface @Ordered {
 // CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .GreaterOrEquivalent = file.%import_ref.2
-// CHECK:STDOUT:   .Self = file.%import_ref.3
-// CHECK:STDOUT:   .Greater = file.%import_ref.4
-// CHECK:STDOUT:   .Less = file.%import_ref.5
-// CHECK:STDOUT:   .LessOrEquivalent = file.%import_ref.6
+// CHECK:STDOUT:   .Less = file.%import_ref.2
+// CHECK:STDOUT:   .Greater = file.%import_ref.3
+// CHECK:STDOUT:   .Self = file.%import_ref.4
+// CHECK:STDOUT:   .LessOrEquivalent = file.%import_ref.5
+// CHECK:STDOUT:   .GreaterOrEquivalent = file.%import_ref.6
 // CHECK:STDOUT:   witness = (file.%import_ref.7, file.%import_ref.8, file.%import_ref.9, file.%import_ref.10)
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: impl @impl: C as Ordered {
 // CHECK:STDOUT:   %Less.decl: Less = fn_decl @Less.1 [template = constants.%struct.1] {
-// CHECK:STDOUT:     %C.ref.loc9_17: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %self.loc9_11.1: C = param self
-// CHECK:STDOUT:     %self.loc9_11.2: C = bind_name self, %self.loc9_11.1
-// CHECK:STDOUT:     %C.ref.loc9_27: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %other.loc9_20.1: C = param other
-// CHECK:STDOUT:     %other.loc9_20.2: C = bind_name other, %other.loc9_20.1
-// CHECK:STDOUT:     %return.var.loc9: ref bool = var <return slot>
+// CHECK:STDOUT:     %C.ref.loc7_17: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %self.loc7_11.1: C = param self
+// CHECK:STDOUT:     %self.loc7_11.2: C = bind_name self, %self.loc7_11.1
+// CHECK:STDOUT:     %C.ref.loc7_27: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %other.loc7_20.1: C = param other
+// CHECK:STDOUT:     %other.loc7_20.2: C = bind_name other, %other.loc7_20.1
+// CHECK:STDOUT:     %return.var.loc7: ref bool = var <return slot>
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %LessOrEquivalent.decl: LessOrEquivalent = fn_decl @LessOrEquivalent.1 [template = constants.%struct.2] {
-// CHECK:STDOUT:     %C.ref.loc10_29: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %self.loc10_23.1: C = param self
-// CHECK:STDOUT:     %self.loc10_23.2: C = bind_name self, %self.loc10_23.1
-// CHECK:STDOUT:     %C.ref.loc10_39: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %other.loc10_32.1: C = param other
-// CHECK:STDOUT:     %other.loc10_32.2: C = bind_name other, %other.loc10_32.1
-// CHECK:STDOUT:     %return.var.loc10: ref bool = var <return slot>
+// CHECK:STDOUT:     %C.ref.loc8_29: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %self.loc8_23.1: C = param self
+// CHECK:STDOUT:     %self.loc8_23.2: C = bind_name self, %self.loc8_23.1
+// CHECK:STDOUT:     %C.ref.loc8_39: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %other.loc8_32.1: C = param other
+// CHECK:STDOUT:     %other.loc8_32.2: C = bind_name other, %other.loc8_32.1
+// CHECK:STDOUT:     %return.var.loc8: ref bool = var <return slot>
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %Greater.decl: Greater = fn_decl @Greater.1 [template = constants.%struct.3] {
-// CHECK:STDOUT:     %C.ref.loc11_20: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %self.loc11_14.1: C = param self
-// CHECK:STDOUT:     %self.loc11_14.2: C = bind_name self, %self.loc11_14.1
-// CHECK:STDOUT:     %C.ref.loc11_30: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %other.loc11_23.1: C = param other
-// CHECK:STDOUT:     %other.loc11_23.2: C = bind_name other, %other.loc11_23.1
-// CHECK:STDOUT:     %return.var.loc11: ref bool = var <return slot>
+// CHECK:STDOUT:     %C.ref.loc9_20: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %self.loc9_14.1: C = param self
+// CHECK:STDOUT:     %self.loc9_14.2: C = bind_name self, %self.loc9_14.1
+// CHECK:STDOUT:     %C.ref.loc9_30: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %other.loc9_23.1: C = param other
+// CHECK:STDOUT:     %other.loc9_23.2: C = bind_name other, %other.loc9_23.1
+// CHECK:STDOUT:     %return.var.loc9: ref bool = var <return slot>
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %GreaterOrEquivalent.decl: GreaterOrEquivalent = fn_decl @GreaterOrEquivalent.1 [template = constants.%struct.4] {
-// CHECK:STDOUT:     %C.ref.loc12_32: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %self.loc12_26.1: C = param self
-// CHECK:STDOUT:     %self.loc12_26.2: C = bind_name self, %self.loc12_26.1
-// CHECK:STDOUT:     %C.ref.loc12_42: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %other.loc12_35.1: C = param other
-// CHECK:STDOUT:     %other.loc12_35.2: C = bind_name other, %other.loc12_35.1
-// CHECK:STDOUT:     %return.var.loc12: ref bool = var <return slot>
+// CHECK:STDOUT:     %C.ref.loc10_32: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %self.loc10_26.1: C = param self
+// CHECK:STDOUT:     %self.loc10_26.2: C = bind_name self, %self.loc10_26.1
+// CHECK:STDOUT:     %C.ref.loc10_42: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %other.loc10_35.1: C = param other
+// CHECK:STDOUT:     %other.loc10_35.2: C = bind_name other, %other.loc10_35.1
+// CHECK:STDOUT:     %return.var.loc10: ref bool = var <return slot>
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %.1: <witness> = interface_witness (%Less.decl, %LessOrEquivalent.decl, %Greater.decl, %GreaterOrEquivalent.decl) [template = constants.%.4]
 // CHECK:STDOUT:
@@ -373,13 +248,13 @@ fn TestGreaterEqual(a: D, b: D) -> bool {
 // CHECK:STDOUT:   .Self = constants.%C
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: fn @Less.1[@impl.%self.loc9_11.2: C](@impl.%other.loc9_20.2: C) -> bool;
+// CHECK:STDOUT: fn @Less.1[@impl.%self.loc7_11.2: C](@impl.%other.loc7_20.2: C) -> bool;
 // CHECK:STDOUT:
-// CHECK:STDOUT: fn @LessOrEquivalent.1[@impl.%self.loc10_23.2: C](@impl.%other.loc10_32.2: C) -> bool;
+// CHECK:STDOUT: fn @LessOrEquivalent.1[@impl.%self.loc8_23.2: C](@impl.%other.loc8_32.2: C) -> bool;
 // CHECK:STDOUT:
-// CHECK:STDOUT: fn @Greater.1[@impl.%self.loc11_14.2: C](@impl.%other.loc11_23.2: C) -> bool;
+// CHECK:STDOUT: fn @Greater.1[@impl.%self.loc9_14.2: C](@impl.%other.loc9_23.2: C) -> bool;
 // CHECK:STDOUT:
-// CHECK:STDOUT: fn @GreaterOrEquivalent.1[@impl.%self.loc12_26.2: C](@impl.%other.loc12_35.2: C) -> bool;
+// CHECK:STDOUT: fn @GreaterOrEquivalent.1[@impl.%self.loc10_26.2: C](@impl.%other.loc10_35.2: C) -> bool;
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @Less.2[%self: Self](%other: Self) -> bool;
 // CHECK:STDOUT:
@@ -394,11 +269,11 @@ fn TestGreaterEqual(a: D, b: D) -> bool {
 // CHECK:STDOUT:   %a.ref: C = name_ref a, %a
 // CHECK:STDOUT:   %b.ref: C = name_ref b, %b
 // CHECK:STDOUT:   %.1: Less = interface_witness_access @impl.%.1, element0 [template = constants.%struct.1]
-// CHECK:STDOUT:   %.loc16_12: <bound method> = bound_method %a.ref, %.1
-// CHECK:STDOUT:   %Less.call: init bool = call %.loc16_12(%a.ref, %b.ref)
-// CHECK:STDOUT:   %.loc16_15.1: bool = value_of_initializer %Less.call
-// CHECK:STDOUT:   %.loc16_15.2: bool = converted %Less.call, %.loc16_15.1
-// CHECK:STDOUT:   return %.loc16_15.2
+// CHECK:STDOUT:   %.loc14_12: <bound method> = bound_method %a.ref, %.1
+// CHECK:STDOUT:   %Less.call: init bool = call %.loc14_12(%a.ref, %b.ref)
+// CHECK:STDOUT:   %.loc14_15.1: bool = value_of_initializer %Less.call
+// CHECK:STDOUT:   %.loc14_15.2: bool = converted %Less.call, %.loc14_15.1
+// CHECK:STDOUT:   return %.loc14_15.2
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @TestLessEqual(%a: C, %b: C) -> bool {
@@ -406,11 +281,11 @@ fn TestGreaterEqual(a: D, b: D) -> bool {
 // CHECK:STDOUT:   %a.ref: C = name_ref a, %a
 // CHECK:STDOUT:   %b.ref: C = name_ref b, %b
 // CHECK:STDOUT:   %.1: LessOrEquivalent = interface_witness_access @impl.%.1, element1 [template = constants.%struct.2]
-// CHECK:STDOUT:   %.loc20_12: <bound method> = bound_method %a.ref, %.1
-// CHECK:STDOUT:   %LessOrEquivalent.call: init bool = call %.loc20_12(%a.ref, %b.ref)
-// CHECK:STDOUT:   %.loc20_16.1: bool = value_of_initializer %LessOrEquivalent.call
-// CHECK:STDOUT:   %.loc20_16.2: bool = converted %LessOrEquivalent.call, %.loc20_16.1
-// CHECK:STDOUT:   return %.loc20_16.2
+// CHECK:STDOUT:   %.loc18_12: <bound method> = bound_method %a.ref, %.1
+// CHECK:STDOUT:   %LessOrEquivalent.call: init bool = call %.loc18_12(%a.ref, %b.ref)
+// CHECK:STDOUT:   %.loc18_16.1: bool = value_of_initializer %LessOrEquivalent.call
+// CHECK:STDOUT:   %.loc18_16.2: bool = converted %LessOrEquivalent.call, %.loc18_16.1
+// CHECK:STDOUT:   return %.loc18_16.2
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @TestGreater(%a: C, %b: C) -> bool {
@@ -418,11 +293,11 @@ fn TestGreaterEqual(a: D, b: D) -> bool {
 // CHECK:STDOUT:   %a.ref: C = name_ref a, %a
 // CHECK:STDOUT:   %b.ref: C = name_ref b, %b
 // CHECK:STDOUT:   %.1: Greater = interface_witness_access @impl.%.1, element2 [template = constants.%struct.3]
-// CHECK:STDOUT:   %.loc24_12: <bound method> = bound_method %a.ref, %.1
-// CHECK:STDOUT:   %Greater.call: init bool = call %.loc24_12(%a.ref, %b.ref)
-// CHECK:STDOUT:   %.loc24_15.1: bool = value_of_initializer %Greater.call
-// CHECK:STDOUT:   %.loc24_15.2: bool = converted %Greater.call, %.loc24_15.1
-// CHECK:STDOUT:   return %.loc24_15.2
+// CHECK:STDOUT:   %.loc22_12: <bound method> = bound_method %a.ref, %.1
+// CHECK:STDOUT:   %Greater.call: init bool = call %.loc22_12(%a.ref, %b.ref)
+// CHECK:STDOUT:   %.loc22_15.1: bool = value_of_initializer %Greater.call
+// CHECK:STDOUT:   %.loc22_15.2: bool = converted %Greater.call, %.loc22_15.1
+// CHECK:STDOUT:   return %.loc22_15.2
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @TestGreaterEqual(%a: C, %b: C) -> bool {
@@ -430,11 +305,11 @@ fn TestGreaterEqual(a: D, b: D) -> bool {
 // CHECK:STDOUT:   %a.ref: C = name_ref a, %a
 // CHECK:STDOUT:   %b.ref: C = name_ref b, %b
 // CHECK:STDOUT:   %.1: GreaterOrEquivalent = interface_witness_access @impl.%.1, element3 [template = constants.%struct.4]
-// CHECK:STDOUT:   %.loc28_12: <bound method> = bound_method %a.ref, %.1
-// CHECK:STDOUT:   %GreaterOrEquivalent.call: init bool = call %.loc28_12(%a.ref, %b.ref)
-// CHECK:STDOUT:   %.loc28_16.1: bool = value_of_initializer %GreaterOrEquivalent.call
-// CHECK:STDOUT:   %.loc28_16.2: bool = converted %GreaterOrEquivalent.call, %.loc28_16.1
-// CHECK:STDOUT:   return %.loc28_16.2
+// CHECK:STDOUT:   %.loc26_12: <bound method> = bound_method %a.ref, %.1
+// CHECK:STDOUT:   %GreaterOrEquivalent.call: init bool = call %.loc26_12(%a.ref, %b.ref)
+// CHECK:STDOUT:   %.loc26_16.1: bool = value_of_initializer %GreaterOrEquivalent.call
+// CHECK:STDOUT:   %.loc26_16.2: bool = converted %GreaterOrEquivalent.call, %.loc26_16.1
+// CHECK:STDOUT:   return %.loc26_16.2
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: --- fail_no_impl.carbon
@@ -484,67 +359,67 @@ fn TestGreaterEqual(a: D, b: D) -> bool {
 // CHECK:STDOUT:   %Core: <namespace> = namespace [template] {}
 // CHECK:STDOUT:   %D.decl: type = class_decl @D [template = constants.%D] {}
 // CHECK:STDOUT:   %TestLess.decl: TestLess = fn_decl @TestLess [template = constants.%struct.1] {
-// CHECK:STDOUT:     %D.ref.loc8_16: type = name_ref D, %D.decl [template = constants.%D]
-// CHECK:STDOUT:     %a.loc8_13.1: D = param a
-// CHECK:STDOUT:     @TestLess.%a: D = bind_name a, %a.loc8_13.1
-// CHECK:STDOUT:     %D.ref.loc8_22: type = name_ref D, %D.decl [template = constants.%D]
-// CHECK:STDOUT:     %b.loc8_19.1: D = param b
-// CHECK:STDOUT:     @TestLess.%b: D = bind_name b, %b.loc8_19.1
+// CHECK:STDOUT:     %D.ref.loc6_16: type = name_ref D, %D.decl [template = constants.%D]
+// CHECK:STDOUT:     %a.loc6_13.1: D = param a
+// CHECK:STDOUT:     @TestLess.%a: D = bind_name a, %a.loc6_13.1
+// CHECK:STDOUT:     %D.ref.loc6_22: type = name_ref D, %D.decl [template = constants.%D]
+// CHECK:STDOUT:     %b.loc6_19.1: D = param b
+// CHECK:STDOUT:     @TestLess.%b: D = bind_name b, %b.loc6_19.1
 // CHECK:STDOUT:     @TestLess.%return: ref bool = var <return slot>
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.1: type = import_ref ir2, inst+1, loaded [template = constants.%.4]
-// CHECK:STDOUT:   %import_ref.2: <associated GreaterOrEquivalent in Ordered> = import_ref ir2, inst+72, loaded [template = constants.%.12]
-// CHECK:STDOUT:   %import_ref.3 = import_ref ir2, inst+3, unloaded
-// CHECK:STDOUT:   %import_ref.4: <associated Greater in Ordered> = import_ref ir2, inst+55, loaded [template = constants.%.10]
-// CHECK:STDOUT:   %import_ref.5: <associated Less in Ordered> = import_ref ir2, inst+21, loaded [template = constants.%.6]
-// CHECK:STDOUT:   %import_ref.6: <associated LessOrEquivalent in Ordered> = import_ref ir2, inst+38, loaded [template = constants.%.8]
-// CHECK:STDOUT:   %import_ref.7 = import_ref ir2, inst+16, unloaded
-// CHECK:STDOUT:   %import_ref.8 = import_ref ir2, inst+34, unloaded
-// CHECK:STDOUT:   %import_ref.9 = import_ref ir2, inst+51, unloaded
-// CHECK:STDOUT:   %import_ref.10 = import_ref ir2, inst+68, unloaded
-// CHECK:STDOUT:   %import_ref.11 = import_ref ir2, inst+16, unloaded
+// CHECK:STDOUT:   %import_ref.1: type = import_ref ir6, inst+40, loaded [template = constants.%.4]
+// CHECK:STDOUT:   %import_ref.2: <associated Less in Ordered> = import_ref ir6, inst+59, loaded [template = constants.%.6]
+// CHECK:STDOUT:   %import_ref.3: <associated Greater in Ordered> = import_ref ir6, inst+93, loaded [template = constants.%.10]
+// CHECK:STDOUT:   %import_ref.4 = import_ref ir6, inst+42, unloaded
+// CHECK:STDOUT:   %import_ref.5: <associated LessOrEquivalent in Ordered> = import_ref ir6, inst+76, loaded [template = constants.%.8]
+// CHECK:STDOUT:   %import_ref.6: <associated GreaterOrEquivalent in Ordered> = import_ref ir6, inst+110, loaded [template = constants.%.12]
+// CHECK:STDOUT:   %import_ref.7 = import_ref ir6, inst+55, unloaded
+// CHECK:STDOUT:   %import_ref.8 = import_ref ir6, inst+72, unloaded
+// CHECK:STDOUT:   %import_ref.9 = import_ref ir6, inst+89, unloaded
+// CHECK:STDOUT:   %import_ref.10 = import_ref ir6, inst+106, unloaded
+// CHECK:STDOUT:   %import_ref.11 = import_ref ir6, inst+55, unloaded
 // CHECK:STDOUT:   %TestLessEqual.decl: TestLessEqual = fn_decl @TestLessEqual [template = constants.%struct.3] {
-// CHECK:STDOUT:     %D.ref.loc16_21: type = name_ref D, %D.decl [template = constants.%D]
-// CHECK:STDOUT:     %a.loc16_18.1: D = param a
-// CHECK:STDOUT:     @TestLessEqual.%a: D = bind_name a, %a.loc16_18.1
-// CHECK:STDOUT:     %D.ref.loc16_27: type = name_ref D, %D.decl [template = constants.%D]
-// CHECK:STDOUT:     %b.loc16_24.1: D = param b
-// CHECK:STDOUT:     @TestLessEqual.%b: D = bind_name b, %b.loc16_24.1
+// CHECK:STDOUT:     %D.ref.loc14_21: type = name_ref D, %D.decl [template = constants.%D]
+// CHECK:STDOUT:     %a.loc14_18.1: D = param a
+// CHECK:STDOUT:     @TestLessEqual.%a: D = bind_name a, %a.loc14_18.1
+// CHECK:STDOUT:     %D.ref.loc14_27: type = name_ref D, %D.decl [template = constants.%D]
+// CHECK:STDOUT:     %b.loc14_24.1: D = param b
+// CHECK:STDOUT:     @TestLessEqual.%b: D = bind_name b, %b.loc14_24.1
 // CHECK:STDOUT:     @TestLessEqual.%return: ref bool = var <return slot>
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.12: type = import_ref ir2, inst+1, loaded [template = constants.%.4]
-// CHECK:STDOUT:   %import_ref.13 = import_ref ir2, inst+34, unloaded
+// CHECK:STDOUT:   %import_ref.12: type = import_ref ir6, inst+40, loaded [template = constants.%.4]
+// CHECK:STDOUT:   %import_ref.13 = import_ref ir6, inst+72, unloaded
 // CHECK:STDOUT:   %TestGreater.decl: TestGreater = fn_decl @TestGreater [template = constants.%struct.5] {
-// CHECK:STDOUT:     %D.ref.loc24_19: type = name_ref D, %D.decl [template = constants.%D]
-// CHECK:STDOUT:     %a.loc24_16.1: D = param a
-// CHECK:STDOUT:     @TestGreater.%a: D = bind_name a, %a.loc24_16.1
-// CHECK:STDOUT:     %D.ref.loc24_25: type = name_ref D, %D.decl [template = constants.%D]
-// CHECK:STDOUT:     %b.loc24_22.1: D = param b
-// CHECK:STDOUT:     @TestGreater.%b: D = bind_name b, %b.loc24_22.1
+// CHECK:STDOUT:     %D.ref.loc22_19: type = name_ref D, %D.decl [template = constants.%D]
+// CHECK:STDOUT:     %a.loc22_16.1: D = param a
+// CHECK:STDOUT:     @TestGreater.%a: D = bind_name a, %a.loc22_16.1
+// CHECK:STDOUT:     %D.ref.loc22_25: type = name_ref D, %D.decl [template = constants.%D]
+// CHECK:STDOUT:     %b.loc22_22.1: D = param b
+// CHECK:STDOUT:     @TestGreater.%b: D = bind_name b, %b.loc22_22.1
 // CHECK:STDOUT:     @TestGreater.%return: ref bool = var <return slot>
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.14: type = import_ref ir2, inst+1, loaded [template = constants.%.4]
-// CHECK:STDOUT:   %import_ref.15 = import_ref ir2, inst+51, unloaded
+// CHECK:STDOUT:   %import_ref.14: type = import_ref ir6, inst+40, loaded [template = constants.%.4]
+// CHECK:STDOUT:   %import_ref.15 = import_ref ir6, inst+89, unloaded
 // CHECK:STDOUT:   %TestGreaterEqual.decl: TestGreaterEqual = fn_decl @TestGreaterEqual [template = constants.%struct.7] {
-// CHECK:STDOUT:     %D.ref.loc32_24: type = name_ref D, %D.decl [template = constants.%D]
-// CHECK:STDOUT:     %a.loc32_21.1: D = param a
-// CHECK:STDOUT:     @TestGreaterEqual.%a: D = bind_name a, %a.loc32_21.1
-// CHECK:STDOUT:     %D.ref.loc32_30: type = name_ref D, %D.decl [template = constants.%D]
-// CHECK:STDOUT:     %b.loc32_27.1: D = param b
-// CHECK:STDOUT:     @TestGreaterEqual.%b: D = bind_name b, %b.loc32_27.1
+// CHECK:STDOUT:     %D.ref.loc30_24: type = name_ref D, %D.decl [template = constants.%D]
+// CHECK:STDOUT:     %a.loc30_21.1: D = param a
+// CHECK:STDOUT:     @TestGreaterEqual.%a: D = bind_name a, %a.loc30_21.1
+// CHECK:STDOUT:     %D.ref.loc30_30: type = name_ref D, %D.decl [template = constants.%D]
+// CHECK:STDOUT:     %b.loc30_27.1: D = param b
+// CHECK:STDOUT:     @TestGreaterEqual.%b: D = bind_name b, %b.loc30_27.1
 // CHECK:STDOUT:     @TestGreaterEqual.%return: ref bool = var <return slot>
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.16: type = import_ref ir2, inst+1, loaded [template = constants.%.4]
-// CHECK:STDOUT:   %import_ref.17 = import_ref ir2, inst+68, unloaded
+// CHECK:STDOUT:   %import_ref.16: type = import_ref ir6, inst+40, loaded [template = constants.%.4]
+// CHECK:STDOUT:   %import_ref.17 = import_ref ir6, inst+106, unloaded
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: interface @Ordered {
 // CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .GreaterOrEquivalent = file.%import_ref.2
-// CHECK:STDOUT:   .Self = file.%import_ref.3
-// CHECK:STDOUT:   .Greater = file.%import_ref.4
-// CHECK:STDOUT:   .Less = file.%import_ref.5
-// CHECK:STDOUT:   .LessOrEquivalent = file.%import_ref.6
+// CHECK:STDOUT:   .Less = file.%import_ref.2
+// CHECK:STDOUT:   .Greater = file.%import_ref.3
+// CHECK:STDOUT:   .Self = file.%import_ref.4
+// CHECK:STDOUT:   .LessOrEquivalent = file.%import_ref.5
+// CHECK:STDOUT:   .GreaterOrEquivalent = file.%import_ref.6
 // CHECK:STDOUT:   witness = (file.%import_ref.7, file.%import_ref.8, file.%import_ref.9, file.%import_ref.10)
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 63 - 160
toolchain/check/testdata/operators/overloaded/right_shift.carbon

@@ -6,23 +6,8 @@
 
 // This file was generated from binary_op.carbon.tmpl. Run make_tests.sh to regenerate.
 
-// --- prelude.carbon
-
-package Core;
-
-interface RightShift {
-  fn Op[self: Self](other: Self) -> Self;
-}
-interface RightShiftAssign {
-  fn Op[addr self: Self*](other: Self);
-}
-
-// --- user.carbon
-
 package User;
 
-import Core;
-
 class C {};
 
 impl C as Core.RightShift {
@@ -42,89 +27,7 @@ fn TestAssign(a: C*, b: C) {
   *a >>= b;
 }
 
-// CHECK:STDOUT: --- prelude.carbon
-// CHECK:STDOUT:
-// CHECK:STDOUT: constants {
-// CHECK:STDOUT:   %.1: type = interface_type @RightShift [template]
-// CHECK:STDOUT:   %Self.1: RightShift = bind_symbolic_name Self 0 [symbolic]
-// CHECK:STDOUT:   %Op.1: type = fn_type @Op.1 [template]
-// CHECK:STDOUT:   %.2: type = tuple_type () [template]
-// CHECK:STDOUT:   %struct.1: Op = struct_value () [template]
-// CHECK:STDOUT:   %.3: type = assoc_entity_type @RightShift, Op [template]
-// CHECK:STDOUT:   %.4: <associated Op in RightShift> = assoc_entity element0, @RightShift.%Op.decl [template]
-// CHECK:STDOUT:   %.5: type = interface_type @RightShiftAssign [template]
-// CHECK:STDOUT:   %Self.2: RightShiftAssign = bind_symbolic_name Self 0 [symbolic]
-// CHECK:STDOUT:   %.6: type = ptr_type Self [symbolic]
-// CHECK:STDOUT:   %Op.2: type = fn_type @Op.2 [template]
-// CHECK:STDOUT:   %struct.2: Op = struct_value () [template]
-// CHECK:STDOUT:   %.7: type = assoc_entity_type @RightShiftAssign, Op [template]
-// CHECK:STDOUT:   %.8: <associated Op in RightShiftAssign> = assoc_entity element0, @RightShiftAssign.%Op.decl [template]
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace [template] {
-// CHECK:STDOUT:     .RightShift = %RightShift.decl
-// CHECK:STDOUT:     .RightShiftAssign = %RightShiftAssign.decl
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %RightShift.decl: type = interface_decl @RightShift [template = constants.%.1] {}
-// CHECK:STDOUT:   %RightShiftAssign.decl: type = interface_decl @RightShiftAssign [template = constants.%.5] {}
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: interface @RightShift {
-// CHECK:STDOUT:   %Self: RightShift = bind_symbolic_name Self 0 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.1 [template = constants.%struct.1] {
-// CHECK:STDOUT:     %Self.ref.loc5_15: RightShift = name_ref Self, %Self [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_15.1: type = facet_type_access %Self.ref.loc5_15 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_15.2: type = converted %Self.ref.loc5_15, %.loc5_15.1 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %self.loc5_9.1: Self = param self
-// CHECK:STDOUT:     %self.loc5_9.2: Self = bind_name self, %self.loc5_9.1
-// CHECK:STDOUT:     %Self.ref.loc5_28: RightShift = name_ref Self, %Self [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_28.1: type = facet_type_access %Self.ref.loc5_28 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_28.2: type = converted %Self.ref.loc5_28, %.loc5_28.1 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %other.loc5_21.1: Self = param other
-// CHECK:STDOUT:     %other.loc5_21.2: Self = bind_name other, %other.loc5_21.1
-// CHECK:STDOUT:     %Self.ref.loc5_37: RightShift = name_ref Self, %Self [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_37.1: type = facet_type_access %Self.ref.loc5_37 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_37.2: type = converted %Self.ref.loc5_37, %.loc5_37.1 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %return.var: ref Self = var <return slot>
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %.loc5_41: <associated Op in RightShift> = assoc_entity element0, %Op.decl [template = constants.%.4]
-// CHECK:STDOUT:
-// CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Self = %Self
-// CHECK:STDOUT:   .Op = %.loc5_41
-// CHECK:STDOUT:   witness = (%Op.decl)
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: interface @RightShiftAssign {
-// CHECK:STDOUT:   %Self: RightShiftAssign = bind_symbolic_name Self 0 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.2 [template = constants.%struct.2] {
-// CHECK:STDOUT:     %Self.ref.loc8_20: RightShiftAssign = name_ref Self, %Self [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_24.1: type = facet_type_access %Self.ref.loc8_20 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_24.2: type = converted %Self.ref.loc8_20, %.loc8_24.1 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_24.3: type = ptr_type Self [symbolic = constants.%.6]
-// CHECK:STDOUT:     %self.loc8_14.1: Self* = param self
-// CHECK:STDOUT:     %self.loc8_14.3: Self* = bind_name self, %self.loc8_14.1
-// CHECK:STDOUT:     %.loc8_9: Self* = addr_pattern %self.loc8_14.3
-// CHECK:STDOUT:     %Self.ref.loc8_34: RightShiftAssign = name_ref Self, %Self [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_34.1: type = facet_type_access %Self.ref.loc8_34 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_34.2: type = converted %Self.ref.loc8_34, %.loc8_34.1 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %other.loc8_27.1: Self = param other
-// CHECK:STDOUT:     %other.loc8_27.2: Self = bind_name other, %other.loc8_27.1
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %.loc8_39: <associated Op in RightShiftAssign> = assoc_entity element0, %Op.decl [template = constants.%.8]
-// CHECK:STDOUT:
-// CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Self = %Self
-// CHECK:STDOUT:   .Op = %.loc8_39
-// CHECK:STDOUT:   witness = (%Op.decl)
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.1[@RightShift.%self.loc5_9.2: Self](@RightShift.%other.loc5_21.2: Self) -> Self;
-// CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.2[addr @RightShiftAssign.%self.loc8_14.3: Self*](@RightShiftAssign.%other.loc8_27.2: Self);
-// CHECK:STDOUT:
-// CHECK:STDOUT: --- user.carbon
+// CHECK:STDOUT: --- right_shift.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: constants {
 // CHECK:STDOUT:   %C: type = class_type @C [template]
@@ -167,72 +70,72 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %Core: <namespace> = namespace [template] {}
 // CHECK:STDOUT:   %C.decl: type = class_decl @C [template = constants.%C] {}
-// CHECK:STDOUT:   %import_ref.1: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.2: <associated Op in RightShift> = import_ref ir2, inst+24, loaded [template = constants.%.11]
-// CHECK:STDOUT:   %import_ref.3 = import_ref ir2, inst+3, unloaded
-// CHECK:STDOUT:   %import_ref.4: Op = import_ref ir2, inst+19, loaded [template = constants.%struct.2]
+// CHECK:STDOUT:   %import_ref.1: type = import_ref ir5, inst+209, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.2 = import_ref ir5, inst+211, unloaded
+// CHECK:STDOUT:   %import_ref.3: <associated Op in RightShift> = import_ref ir5, inst+231, loaded [template = constants.%.11]
+// CHECK:STDOUT:   %import_ref.4: Op = import_ref ir5, inst+227, loaded [template = constants.%struct.2]
 // CHECK:STDOUT:   impl_decl @impl.1 {
-// CHECK:STDOUT:     %C.ref.loc8: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %Core.ref.loc8: <namespace> = name_ref Core, %Core [template = %Core]
+// CHECK:STDOUT:     %C.ref.loc13: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %Core.ref.loc13: <namespace> = name_ref Core, %Core [template = %Core]
 // CHECK:STDOUT:     %RightShift.ref: type = name_ref RightShift, %import_ref.1 [template = constants.%.2]
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.5: type = import_ref ir2, inst+26, loaded [template = constants.%.6]
-// CHECK:STDOUT:   %import_ref.6: <associated Op in RightShiftAssign> = import_ref ir2, inst+47, loaded [template = constants.%.13]
-// CHECK:STDOUT:   %import_ref.7 = import_ref ir2, inst+28, unloaded
-// CHECK:STDOUT:   %import_ref.8: Op = import_ref ir2, inst+43, loaded [template = constants.%struct.5]
+// CHECK:STDOUT:   %import_ref.5: type = import_ref ir5, inst+233, loaded [template = constants.%.6]
+// CHECK:STDOUT:   %import_ref.6 = import_ref ir5, inst+235, unloaded
+// CHECK:STDOUT:   %import_ref.7: <associated Op in RightShiftAssign> = import_ref ir5, inst+254, loaded [template = constants.%.13]
+// CHECK:STDOUT:   %import_ref.8: Op = import_ref ir5, inst+250, loaded [template = constants.%struct.5]
 // CHECK:STDOUT:   impl_decl @impl.2 {
-// CHECK:STDOUT:     %C.ref.loc13: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %Core.ref.loc13: <namespace> = name_ref Core, %Core [template = %Core]
+// CHECK:STDOUT:     %C.ref.loc18: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %Core.ref.loc18: <namespace> = name_ref Core, %Core [template = %Core]
 // CHECK:STDOUT:     %RightShiftAssign.ref: type = name_ref RightShiftAssign, %import_ref.5 [template = constants.%.6]
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %TestOp.decl: TestOp = fn_decl @TestOp [template = constants.%struct.6] {
-// CHECK:STDOUT:     %C.ref.loc17_14: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %a.loc17_11.1: C = param a
-// CHECK:STDOUT:     @TestOp.%a: C = bind_name a, %a.loc17_11.1
-// CHECK:STDOUT:     %C.ref.loc17_20: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %b.loc17_17.1: C = param b
-// CHECK:STDOUT:     @TestOp.%b: C = bind_name b, %b.loc17_17.1
-// CHECK:STDOUT:     %C.ref.loc17_26: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %C.ref.loc22_14: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %a.loc22_11.1: C = param a
+// CHECK:STDOUT:     @TestOp.%a: C = bind_name a, %a.loc22_11.1
+// CHECK:STDOUT:     %C.ref.loc22_20: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %b.loc22_17.1: C = param b
+// CHECK:STDOUT:     @TestOp.%b: C = bind_name b, %b.loc22_17.1
+// CHECK:STDOUT:     %C.ref.loc22_26: type = name_ref C, %C.decl [template = constants.%C]
 // CHECK:STDOUT:     @TestOp.%return: ref C = var <return slot>
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.9: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.10 = import_ref ir2, inst+19, unloaded
+// CHECK:STDOUT:   %import_ref.9: type = import_ref ir5, inst+209, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.10 = import_ref ir5, inst+227, unloaded
 // CHECK:STDOUT:   %TestAssign.decl: TestAssign = fn_decl @TestAssign [template = constants.%struct.7] {
-// CHECK:STDOUT:     %C.ref.loc21_18: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %.loc21: type = ptr_type C [template = constants.%.7]
-// CHECK:STDOUT:     %a.loc21_15.1: C* = param a
-// CHECK:STDOUT:     @TestAssign.%a: C* = bind_name a, %a.loc21_15.1
-// CHECK:STDOUT:     %C.ref.loc21_25: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %b.loc21_22.1: C = param b
-// CHECK:STDOUT:     @TestAssign.%b: C = bind_name b, %b.loc21_22.1
+// CHECK:STDOUT:     %C.ref.loc26_18: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %.loc26: type = ptr_type C [template = constants.%.7]
+// CHECK:STDOUT:     %a.loc26_15.1: C* = param a
+// CHECK:STDOUT:     @TestAssign.%a: C* = bind_name a, %a.loc26_15.1
+// CHECK:STDOUT:     %C.ref.loc26_25: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %b.loc26_22.1: C = param b
+// CHECK:STDOUT:     @TestAssign.%b: C = bind_name b, %b.loc26_22.1
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.11: type = import_ref ir2, inst+26, loaded [template = constants.%.6]
-// CHECK:STDOUT:   %import_ref.12 = import_ref ir2, inst+43, unloaded
+// CHECK:STDOUT:   %import_ref.11: type = import_ref ir5, inst+233, loaded [template = constants.%.6]
+// CHECK:STDOUT:   %import_ref.12 = import_ref ir5, inst+250, unloaded
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: interface @RightShift {
 // CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Op = file.%import_ref.2
-// CHECK:STDOUT:   .Self = file.%import_ref.3
+// CHECK:STDOUT:   .Self = file.%import_ref.2
+// CHECK:STDOUT:   .Op = file.%import_ref.3
 // CHECK:STDOUT:   witness = (file.%import_ref.4)
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: interface @RightShiftAssign {
 // CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Op = file.%import_ref.6
-// CHECK:STDOUT:   .Self = file.%import_ref.7
+// CHECK:STDOUT:   .Self = file.%import_ref.6
+// CHECK:STDOUT:   .Op = file.%import_ref.7
 // CHECK:STDOUT:   witness = (file.%import_ref.8)
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: impl @impl.1: C as RightShift {
 // CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.1 [template = constants.%struct.1] {
-// CHECK:STDOUT:     %C.ref.loc9_15: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %self.loc9_9.1: C = param self
-// CHECK:STDOUT:     %self.loc9_9.2: C = bind_name self, %self.loc9_9.1
-// CHECK:STDOUT:     %C.ref.loc9_25: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %other.loc9_18.1: C = param other
-// CHECK:STDOUT:     %other.loc9_18.2: C = bind_name other, %other.loc9_18.1
-// CHECK:STDOUT:     %C.ref.loc9_31: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %C.ref.loc14_15: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %self.loc14_9.1: C = param self
+// CHECK:STDOUT:     %self.loc14_9.2: C = bind_name self, %self.loc14_9.1
+// CHECK:STDOUT:     %C.ref.loc14_25: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %other.loc14_18.1: C = param other
+// CHECK:STDOUT:     %other.loc14_18.2: C = bind_name other, %other.loc14_18.1
+// CHECK:STDOUT:     %C.ref.loc14_31: type = name_ref C, file.%C.decl [template = constants.%C]
 // CHECK:STDOUT:     %return.var: ref C = var <return slot>
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %.1: <witness> = interface_witness (%Op.decl) [template = constants.%.4]
@@ -244,14 +147,14 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:
 // CHECK:STDOUT: impl @impl.2: C as RightShiftAssign {
 // CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.3 [template = constants.%struct.4] {
-// CHECK:STDOUT:     %C.ref.loc14_20: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %.loc14_21: type = ptr_type C [template = constants.%.7]
-// CHECK:STDOUT:     %self.loc14_14.1: C* = param self
-// CHECK:STDOUT:     %self.loc14_14.3: C* = bind_name self, %self.loc14_14.1
-// CHECK:STDOUT:     %.loc14_9: C* = addr_pattern %self.loc14_14.3
-// CHECK:STDOUT:     %C.ref.loc14_31: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %other.loc14_24.1: C = param other
-// CHECK:STDOUT:     %other.loc14_24.2: C = bind_name other, %other.loc14_24.1
+// CHECK:STDOUT:     %C.ref.loc19_20: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %.loc19_21: type = ptr_type C [template = constants.%.7]
+// CHECK:STDOUT:     %self.loc19_14.1: C* = param self
+// CHECK:STDOUT:     %self.loc19_14.3: C* = bind_name self, %self.loc19_14.1
+// CHECK:STDOUT:     %.loc19_9: C* = addr_pattern %self.loc19_14.3
+// CHECK:STDOUT:     %C.ref.loc19_31: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %other.loc19_24.1: C = param other
+// CHECK:STDOUT:     %other.loc19_24.2: C = bind_name other, %other.loc19_24.1
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %.1: <witness> = interface_witness (%Op.decl) [template = constants.%.9]
 // CHECK:STDOUT:
@@ -265,17 +168,17 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:   .Self = constants.%C
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.1[@impl.1.%self.loc9_9.2: C](@impl.1.%other.loc9_18.2: C) -> @impl.1.%return.var: C {
+// CHECK:STDOUT: fn @Op.1[@impl.1.%self.loc14_9.2: C](@impl.1.%other.loc14_18.2: C) -> @impl.1.%return.var: C {
 // CHECK:STDOUT: !entry:
-// CHECK:STDOUT:   %.loc10_13.1: {} = struct_literal ()
-// CHECK:STDOUT:   %.loc10_13.2: init C = class_init (), @impl.1.%return.var [template = constants.%struct.3]
-// CHECK:STDOUT:   %.loc10_14: init C = converted %.loc10_13.1, %.loc10_13.2 [template = constants.%struct.3]
-// CHECK:STDOUT:   return %.loc10_14 to @impl.1.%return.var
+// CHECK:STDOUT:   %.loc15_13.1: {} = struct_literal ()
+// CHECK:STDOUT:   %.loc15_13.2: init C = class_init (), @impl.1.%return.var [template = constants.%struct.3]
+// CHECK:STDOUT:   %.loc15_14: init C = converted %.loc15_13.1, %.loc15_13.2 [template = constants.%struct.3]
+// CHECK:STDOUT:   return %.loc15_14 to @impl.1.%return.var
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @Op.2[%self: Self](%other: Self) -> Self;
 // CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.3[addr @impl.2.%self.loc14_14.3: C*](@impl.2.%other.loc14_24.2: C) {
+// CHECK:STDOUT: fn @Op.3[addr @impl.2.%self.loc19_14.3: C*](@impl.2.%other.loc19_24.2: C) {
 // CHECK:STDOUT: !entry:
 // CHECK:STDOUT:   return
 // CHECK:STDOUT: }
@@ -287,21 +190,21 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:   %a.ref: C = name_ref a, %a
 // CHECK:STDOUT:   %b.ref: C = name_ref b, %b
 // CHECK:STDOUT:   %.1: Op = interface_witness_access @impl.1.%.1, element0 [template = constants.%struct.1]
-// CHECK:STDOUT:   %.loc18: <bound method> = bound_method %a.ref, %.1
-// CHECK:STDOUT:   %.loc17: ref C = splice_block %return {}
-// CHECK:STDOUT:   %Op.call: init C = call %.loc18(%a.ref, %b.ref) to %.loc17
+// CHECK:STDOUT:   %.loc23: <bound method> = bound_method %a.ref, %.1
+// CHECK:STDOUT:   %.loc22: ref C = splice_block %return {}
+// CHECK:STDOUT:   %Op.call: init C = call %.loc23(%a.ref, %b.ref) to %.loc22
 // CHECK:STDOUT:   return %Op.call to %return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @TestAssign(%a: C*, %b: C) {
 // CHECK:STDOUT: !entry:
 // CHECK:STDOUT:   %a.ref: C* = name_ref a, %a
-// CHECK:STDOUT:   %.loc22_3.1: ref C = deref %a.ref
+// CHECK:STDOUT:   %.loc27_3.1: ref C = deref %a.ref
 // CHECK:STDOUT:   %b.ref: C = name_ref b, %b
 // CHECK:STDOUT:   %.1: Op = interface_witness_access @impl.2.%.1, element0 [template = constants.%struct.4]
-// CHECK:STDOUT:   %.loc22_6: <bound method> = bound_method %.loc22_3.1, %.1
-// CHECK:STDOUT:   %.loc22_3.2: C* = addr_of %.loc22_3.1
-// CHECK:STDOUT:   %Op.call: init () = call %.loc22_6(%.loc22_3.2, %b.ref)
+// CHECK:STDOUT:   %.loc27_6: <bound method> = bound_method %.loc27_3.1, %.1
+// CHECK:STDOUT:   %.loc27_3.2: C* = addr_of %.loc27_3.1
+// CHECK:STDOUT:   %Op.call: init () = call %.loc27_6(%.loc27_3.2, %b.ref)
 // CHECK:STDOUT:   return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 63 - 160
toolchain/check/testdata/operators/overloaded/sub.carbon

@@ -6,23 +6,8 @@
 
 // This file was generated from binary_op.carbon.tmpl. Run make_tests.sh to regenerate.
 
-// --- prelude.carbon
-
-package Core;
-
-interface Sub {
-  fn Op[self: Self](other: Self) -> Self;
-}
-interface SubAssign {
-  fn Op[addr self: Self*](other: Self);
-}
-
-// --- user.carbon
-
 package User;
 
-import Core;
-
 class C {};
 
 impl C as Core.Sub {
@@ -42,89 +27,7 @@ fn TestAssign(a: C*, b: C) {
   *a -= b;
 }
 
-// CHECK:STDOUT: --- prelude.carbon
-// CHECK:STDOUT:
-// CHECK:STDOUT: constants {
-// CHECK:STDOUT:   %.1: type = interface_type @Sub [template]
-// CHECK:STDOUT:   %Self.1: Sub = bind_symbolic_name Self 0 [symbolic]
-// CHECK:STDOUT:   %Op.1: type = fn_type @Op.1 [template]
-// CHECK:STDOUT:   %.2: type = tuple_type () [template]
-// CHECK:STDOUT:   %struct.1: Op = struct_value () [template]
-// CHECK:STDOUT:   %.3: type = assoc_entity_type @Sub, Op [template]
-// CHECK:STDOUT:   %.4: <associated Op in Sub> = assoc_entity element0, @Sub.%Op.decl [template]
-// CHECK:STDOUT:   %.5: type = interface_type @SubAssign [template]
-// CHECK:STDOUT:   %Self.2: SubAssign = bind_symbolic_name Self 0 [symbolic]
-// CHECK:STDOUT:   %.6: type = ptr_type Self [symbolic]
-// CHECK:STDOUT:   %Op.2: type = fn_type @Op.2 [template]
-// CHECK:STDOUT:   %struct.2: Op = struct_value () [template]
-// CHECK:STDOUT:   %.7: type = assoc_entity_type @SubAssign, Op [template]
-// CHECK:STDOUT:   %.8: <associated Op in SubAssign> = assoc_entity element0, @SubAssign.%Op.decl [template]
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: file {
-// CHECK:STDOUT:   package: <namespace> = namespace [template] {
-// CHECK:STDOUT:     .Sub = %Sub.decl
-// CHECK:STDOUT:     .SubAssign = %SubAssign.decl
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %Sub.decl: type = interface_decl @Sub [template = constants.%.1] {}
-// CHECK:STDOUT:   %SubAssign.decl: type = interface_decl @SubAssign [template = constants.%.5] {}
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: interface @Sub {
-// CHECK:STDOUT:   %Self: Sub = bind_symbolic_name Self 0 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.1 [template = constants.%struct.1] {
-// CHECK:STDOUT:     %Self.ref.loc5_15: Sub = name_ref Self, %Self [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_15.1: type = facet_type_access %Self.ref.loc5_15 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_15.2: type = converted %Self.ref.loc5_15, %.loc5_15.1 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %self.loc5_9.1: Self = param self
-// CHECK:STDOUT:     %self.loc5_9.2: Self = bind_name self, %self.loc5_9.1
-// CHECK:STDOUT:     %Self.ref.loc5_28: Sub = name_ref Self, %Self [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_28.1: type = facet_type_access %Self.ref.loc5_28 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_28.2: type = converted %Self.ref.loc5_28, %.loc5_28.1 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %other.loc5_21.1: Self = param other
-// CHECK:STDOUT:     %other.loc5_21.2: Self = bind_name other, %other.loc5_21.1
-// CHECK:STDOUT:     %Self.ref.loc5_37: Sub = name_ref Self, %Self [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_37.1: type = facet_type_access %Self.ref.loc5_37 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %.loc5_37.2: type = converted %Self.ref.loc5_37, %.loc5_37.1 [symbolic = constants.%Self.1]
-// CHECK:STDOUT:     %return.var: ref Self = var <return slot>
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %.loc5_41: <associated Op in Sub> = assoc_entity element0, %Op.decl [template = constants.%.4]
-// CHECK:STDOUT:
-// CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Self = %Self
-// CHECK:STDOUT:   .Op = %.loc5_41
-// CHECK:STDOUT:   witness = (%Op.decl)
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: interface @SubAssign {
-// CHECK:STDOUT:   %Self: SubAssign = bind_symbolic_name Self 0 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.2 [template = constants.%struct.2] {
-// CHECK:STDOUT:     %Self.ref.loc8_20: SubAssign = name_ref Self, %Self [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_24.1: type = facet_type_access %Self.ref.loc8_20 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_24.2: type = converted %Self.ref.loc8_20, %.loc8_24.1 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_24.3: type = ptr_type Self [symbolic = constants.%.6]
-// CHECK:STDOUT:     %self.loc8_14.1: Self* = param self
-// CHECK:STDOUT:     %self.loc8_14.3: Self* = bind_name self, %self.loc8_14.1
-// CHECK:STDOUT:     %.loc8_9: Self* = addr_pattern %self.loc8_14.3
-// CHECK:STDOUT:     %Self.ref.loc8_34: SubAssign = name_ref Self, %Self [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_34.1: type = facet_type_access %Self.ref.loc8_34 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %.loc8_34.2: type = converted %Self.ref.loc8_34, %.loc8_34.1 [symbolic = constants.%Self.2]
-// CHECK:STDOUT:     %other.loc8_27.1: Self = param other
-// CHECK:STDOUT:     %other.loc8_27.2: Self = bind_name other, %other.loc8_27.1
-// CHECK:STDOUT:   }
-// CHECK:STDOUT:   %.loc8_39: <associated Op in SubAssign> = assoc_entity element0, %Op.decl [template = constants.%.8]
-// CHECK:STDOUT:
-// CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Self = %Self
-// CHECK:STDOUT:   .Op = %.loc8_39
-// CHECK:STDOUT:   witness = (%Op.decl)
-// CHECK:STDOUT: }
-// CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.1[@Sub.%self.loc5_9.2: Self](@Sub.%other.loc5_21.2: Self) -> Self;
-// CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.2[addr @SubAssign.%self.loc8_14.3: Self*](@SubAssign.%other.loc8_27.2: Self);
-// CHECK:STDOUT:
-// CHECK:STDOUT: --- user.carbon
+// CHECK:STDOUT: --- sub.carbon
 // CHECK:STDOUT:
 // CHECK:STDOUT: constants {
 // CHECK:STDOUT:   %C: type = class_type @C [template]
@@ -167,72 +70,72 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %Core: <namespace> = namespace [template] {}
 // CHECK:STDOUT:   %C.decl: type = class_decl @C [template = constants.%C] {}
-// CHECK:STDOUT:   %import_ref.1: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.2: <associated Op in Sub> = import_ref ir2, inst+24, loaded [template = constants.%.11]
-// CHECK:STDOUT:   %import_ref.3 = import_ref ir2, inst+3, unloaded
-// CHECK:STDOUT:   %import_ref.4: Op = import_ref ir2, inst+19, loaded [template = constants.%struct.2]
+// CHECK:STDOUT:   %import_ref.1: type = import_ref ir4, inst+86, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.2 = import_ref ir4, inst+88, unloaded
+// CHECK:STDOUT:   %import_ref.3: <associated Op in Sub> = import_ref ir4, inst+108, loaded [template = constants.%.11]
+// CHECK:STDOUT:   %import_ref.4: Op = import_ref ir4, inst+104, loaded [template = constants.%struct.2]
 // CHECK:STDOUT:   impl_decl @impl.1 {
-// CHECK:STDOUT:     %C.ref.loc8: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %Core.ref.loc8: <namespace> = name_ref Core, %Core [template = %Core]
+// CHECK:STDOUT:     %C.ref.loc13: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %Core.ref.loc13: <namespace> = name_ref Core, %Core [template = %Core]
 // CHECK:STDOUT:     %Sub.ref: type = name_ref Sub, %import_ref.1 [template = constants.%.2]
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.5: type = import_ref ir2, inst+26, loaded [template = constants.%.6]
-// CHECK:STDOUT:   %import_ref.6: <associated Op in SubAssign> = import_ref ir2, inst+47, loaded [template = constants.%.13]
-// CHECK:STDOUT:   %import_ref.7 = import_ref ir2, inst+28, unloaded
-// CHECK:STDOUT:   %import_ref.8: Op = import_ref ir2, inst+43, loaded [template = constants.%struct.5]
+// CHECK:STDOUT:   %import_ref.5: type = import_ref ir4, inst+110, loaded [template = constants.%.6]
+// CHECK:STDOUT:   %import_ref.6 = import_ref ir4, inst+112, unloaded
+// CHECK:STDOUT:   %import_ref.7: <associated Op in SubAssign> = import_ref ir4, inst+131, loaded [template = constants.%.13]
+// CHECK:STDOUT:   %import_ref.8: Op = import_ref ir4, inst+127, loaded [template = constants.%struct.5]
 // CHECK:STDOUT:   impl_decl @impl.2 {
-// CHECK:STDOUT:     %C.ref.loc13: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %Core.ref.loc13: <namespace> = name_ref Core, %Core [template = %Core]
+// CHECK:STDOUT:     %C.ref.loc18: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %Core.ref.loc18: <namespace> = name_ref Core, %Core [template = %Core]
 // CHECK:STDOUT:     %SubAssign.ref: type = name_ref SubAssign, %import_ref.5 [template = constants.%.6]
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %TestOp.decl: TestOp = fn_decl @TestOp [template = constants.%struct.6] {
-// CHECK:STDOUT:     %C.ref.loc17_14: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %a.loc17_11.1: C = param a
-// CHECK:STDOUT:     @TestOp.%a: C = bind_name a, %a.loc17_11.1
-// CHECK:STDOUT:     %C.ref.loc17_20: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %b.loc17_17.1: C = param b
-// CHECK:STDOUT:     @TestOp.%b: C = bind_name b, %b.loc17_17.1
-// CHECK:STDOUT:     %C.ref.loc17_26: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %C.ref.loc22_14: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %a.loc22_11.1: C = param a
+// CHECK:STDOUT:     @TestOp.%a: C = bind_name a, %a.loc22_11.1
+// CHECK:STDOUT:     %C.ref.loc22_20: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %b.loc22_17.1: C = param b
+// CHECK:STDOUT:     @TestOp.%b: C = bind_name b, %b.loc22_17.1
+// CHECK:STDOUT:     %C.ref.loc22_26: type = name_ref C, %C.decl [template = constants.%C]
 // CHECK:STDOUT:     @TestOp.%return: ref C = var <return slot>
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.9: type = import_ref ir2, inst+1, loaded [template = constants.%.2]
-// CHECK:STDOUT:   %import_ref.10 = import_ref ir2, inst+19, unloaded
+// CHECK:STDOUT:   %import_ref.9: type = import_ref ir4, inst+86, loaded [template = constants.%.2]
+// CHECK:STDOUT:   %import_ref.10 = import_ref ir4, inst+104, unloaded
 // CHECK:STDOUT:   %TestAssign.decl: TestAssign = fn_decl @TestAssign [template = constants.%struct.7] {
-// CHECK:STDOUT:     %C.ref.loc21_18: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %.loc21: type = ptr_type C [template = constants.%.7]
-// CHECK:STDOUT:     %a.loc21_15.1: C* = param a
-// CHECK:STDOUT:     @TestAssign.%a: C* = bind_name a, %a.loc21_15.1
-// CHECK:STDOUT:     %C.ref.loc21_25: type = name_ref C, %C.decl [template = constants.%C]
-// CHECK:STDOUT:     %b.loc21_22.1: C = param b
-// CHECK:STDOUT:     @TestAssign.%b: C = bind_name b, %b.loc21_22.1
+// CHECK:STDOUT:     %C.ref.loc26_18: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %.loc26: type = ptr_type C [template = constants.%.7]
+// CHECK:STDOUT:     %a.loc26_15.1: C* = param a
+// CHECK:STDOUT:     @TestAssign.%a: C* = bind_name a, %a.loc26_15.1
+// CHECK:STDOUT:     %C.ref.loc26_25: type = name_ref C, %C.decl [template = constants.%C]
+// CHECK:STDOUT:     %b.loc26_22.1: C = param b
+// CHECK:STDOUT:     @TestAssign.%b: C = bind_name b, %b.loc26_22.1
 // CHECK:STDOUT:   }
-// CHECK:STDOUT:   %import_ref.11: type = import_ref ir2, inst+26, loaded [template = constants.%.6]
-// CHECK:STDOUT:   %import_ref.12 = import_ref ir2, inst+43, unloaded
+// CHECK:STDOUT:   %import_ref.11: type = import_ref ir4, inst+110, loaded [template = constants.%.6]
+// CHECK:STDOUT:   %import_ref.12 = import_ref ir4, inst+127, unloaded
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: interface @Sub {
 // CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Op = file.%import_ref.2
-// CHECK:STDOUT:   .Self = file.%import_ref.3
+// CHECK:STDOUT:   .Self = file.%import_ref.2
+// CHECK:STDOUT:   .Op = file.%import_ref.3
 // CHECK:STDOUT:   witness = (file.%import_ref.4)
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: interface @SubAssign {
 // CHECK:STDOUT: !members:
-// CHECK:STDOUT:   .Op = file.%import_ref.6
-// CHECK:STDOUT:   .Self = file.%import_ref.7
+// CHECK:STDOUT:   .Self = file.%import_ref.6
+// CHECK:STDOUT:   .Op = file.%import_ref.7
 // CHECK:STDOUT:   witness = (file.%import_ref.8)
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: impl @impl.1: C as Sub {
 // CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.1 [template = constants.%struct.1] {
-// CHECK:STDOUT:     %C.ref.loc9_15: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %self.loc9_9.1: C = param self
-// CHECK:STDOUT:     %self.loc9_9.2: C = bind_name self, %self.loc9_9.1
-// CHECK:STDOUT:     %C.ref.loc9_25: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %other.loc9_18.1: C = param other
-// CHECK:STDOUT:     %other.loc9_18.2: C = bind_name other, %other.loc9_18.1
-// CHECK:STDOUT:     %C.ref.loc9_31: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %C.ref.loc14_15: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %self.loc14_9.1: C = param self
+// CHECK:STDOUT:     %self.loc14_9.2: C = bind_name self, %self.loc14_9.1
+// CHECK:STDOUT:     %C.ref.loc14_25: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %other.loc14_18.1: C = param other
+// CHECK:STDOUT:     %other.loc14_18.2: C = bind_name other, %other.loc14_18.1
+// CHECK:STDOUT:     %C.ref.loc14_31: type = name_ref C, file.%C.decl [template = constants.%C]
 // CHECK:STDOUT:     %return.var: ref C = var <return slot>
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %.1: <witness> = interface_witness (%Op.decl) [template = constants.%.4]
@@ -244,14 +147,14 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:
 // CHECK:STDOUT: impl @impl.2: C as SubAssign {
 // CHECK:STDOUT:   %Op.decl: Op = fn_decl @Op.3 [template = constants.%struct.4] {
-// CHECK:STDOUT:     %C.ref.loc14_20: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %.loc14_21: type = ptr_type C [template = constants.%.7]
-// CHECK:STDOUT:     %self.loc14_14.1: C* = param self
-// CHECK:STDOUT:     %self.loc14_14.3: C* = bind_name self, %self.loc14_14.1
-// CHECK:STDOUT:     %.loc14_9: C* = addr_pattern %self.loc14_14.3
-// CHECK:STDOUT:     %C.ref.loc14_31: type = name_ref C, file.%C.decl [template = constants.%C]
-// CHECK:STDOUT:     %other.loc14_24.1: C = param other
-// CHECK:STDOUT:     %other.loc14_24.2: C = bind_name other, %other.loc14_24.1
+// CHECK:STDOUT:     %C.ref.loc19_20: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %.loc19_21: type = ptr_type C [template = constants.%.7]
+// CHECK:STDOUT:     %self.loc19_14.1: C* = param self
+// CHECK:STDOUT:     %self.loc19_14.3: C* = bind_name self, %self.loc19_14.1
+// CHECK:STDOUT:     %.loc19_9: C* = addr_pattern %self.loc19_14.3
+// CHECK:STDOUT:     %C.ref.loc19_31: type = name_ref C, file.%C.decl [template = constants.%C]
+// CHECK:STDOUT:     %other.loc19_24.1: C = param other
+// CHECK:STDOUT:     %other.loc19_24.2: C = bind_name other, %other.loc19_24.1
 // CHECK:STDOUT:   }
 // CHECK:STDOUT:   %.1: <witness> = interface_witness (%Op.decl) [template = constants.%.9]
 // CHECK:STDOUT:
@@ -265,17 +168,17 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:   .Self = constants.%C
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.1[@impl.1.%self.loc9_9.2: C](@impl.1.%other.loc9_18.2: C) -> @impl.1.%return.var: C {
+// CHECK:STDOUT: fn @Op.1[@impl.1.%self.loc14_9.2: C](@impl.1.%other.loc14_18.2: C) -> @impl.1.%return.var: C {
 // CHECK:STDOUT: !entry:
-// CHECK:STDOUT:   %.loc10_13.1: {} = struct_literal ()
-// CHECK:STDOUT:   %.loc10_13.2: init C = class_init (), @impl.1.%return.var [template = constants.%struct.3]
-// CHECK:STDOUT:   %.loc10_14: init C = converted %.loc10_13.1, %.loc10_13.2 [template = constants.%struct.3]
-// CHECK:STDOUT:   return %.loc10_14 to @impl.1.%return.var
+// CHECK:STDOUT:   %.loc15_13.1: {} = struct_literal ()
+// CHECK:STDOUT:   %.loc15_13.2: init C = class_init (), @impl.1.%return.var [template = constants.%struct.3]
+// CHECK:STDOUT:   %.loc15_14: init C = converted %.loc15_13.1, %.loc15_13.2 [template = constants.%struct.3]
+// CHECK:STDOUT:   return %.loc15_14 to @impl.1.%return.var
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @Op.2[%self: Self](%other: Self) -> Self;
 // CHECK:STDOUT:
-// CHECK:STDOUT: fn @Op.3[addr @impl.2.%self.loc14_14.3: C*](@impl.2.%other.loc14_24.2: C) {
+// CHECK:STDOUT: fn @Op.3[addr @impl.2.%self.loc19_14.3: C*](@impl.2.%other.loc19_24.2: C) {
 // CHECK:STDOUT: !entry:
 // CHECK:STDOUT:   return
 // CHECK:STDOUT: }
@@ -287,21 +190,21 @@ fn TestAssign(a: C*, b: C) {
 // CHECK:STDOUT:   %a.ref: C = name_ref a, %a
 // CHECK:STDOUT:   %b.ref: C = name_ref b, %b
 // CHECK:STDOUT:   %.1: Op = interface_witness_access @impl.1.%.1, element0 [template = constants.%struct.1]
-// CHECK:STDOUT:   %.loc18: <bound method> = bound_method %a.ref, %.1
-// CHECK:STDOUT:   %.loc17: ref C = splice_block %return {}
-// CHECK:STDOUT:   %Op.call: init C = call %.loc18(%a.ref, %b.ref) to %.loc17
+// CHECK:STDOUT:   %.loc23: <bound method> = bound_method %a.ref, %.1
+// CHECK:STDOUT:   %.loc22: ref C = splice_block %return {}
+// CHECK:STDOUT:   %Op.call: init C = call %.loc23(%a.ref, %b.ref) to %.loc22
 // CHECK:STDOUT:   return %Op.call to %return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: fn @TestAssign(%a: C*, %b: C) {
 // CHECK:STDOUT: !entry:
 // CHECK:STDOUT:   %a.ref: C* = name_ref a, %a
-// CHECK:STDOUT:   %.loc22_3.1: ref C = deref %a.ref
+// CHECK:STDOUT:   %.loc27_3.1: ref C = deref %a.ref
 // CHECK:STDOUT:   %b.ref: C = name_ref b, %b
 // CHECK:STDOUT:   %.1: Op = interface_witness_access @impl.2.%.1, element0 [template = constants.%struct.4]
-// CHECK:STDOUT:   %.loc22_6: <bound method> = bound_method %.loc22_3.1, %.1
-// CHECK:STDOUT:   %.loc22_3.2: C* = addr_of %.loc22_3.1
-// CHECK:STDOUT:   %Op.call: init () = call %.loc22_6(%.loc22_3.2, %b.ref)
+// CHECK:STDOUT:   %.loc27_6: <bound method> = bound_method %.loc27_3.1, %.1
+// CHECK:STDOUT:   %.loc27_3.2: C* = addr_of %.loc27_3.1
+// CHECK:STDOUT:   %Op.call: init () = call %.loc27_6(%.loc27_3.2, %b.ref)
 // CHECK:STDOUT:   return
 // CHECK:STDOUT: }
 // CHECK:STDOUT:

+ 0 - 12
toolchain/check/testdata/operators/overloaded/unary_op.carbon.tmpl

@@ -6,20 +6,8 @@
 
 HEADER
 
-// --- prelude.carbon
-
-package Core;
-
-interface INTERFACE {
-  fn Op[self: Self]() -> Self;
-}
-
-// --- user.carbon
-
 package User;
 
-import Core;
-
 class C {};
 
 impl C as Core.INTERFACE {

+ 0 - 12
toolchain/check/testdata/operators/overloaded/unary_stmt.carbon.tmpl

@@ -6,20 +6,8 @@
 
 HEADER
 
-// --- prelude.carbon
-
-package Core;
-
-interface INTERFACE {
-  fn Op[addr self: Self*]();
-}
-
-// --- user.carbon
-
 package User;
 
-import Core;
-
 class C {};
 
 impl C as Core.INTERFACE {

+ 8 - 22
toolchain/lower/testdata/builtins/overloaded_operator.carbon

@@ -4,18 +4,6 @@
 //
 // AUTOUPDATE
 
-// --- prelude.carbon
-
-package Core;
-
-interface Add {
-  fn Op[self: Self](other: Self) -> Self;
-}
-
-// --- user.carbon
-
-import Core;
-
 // TODO: Move this into prelude.carbon when possible. For now, impl lookup only
 // looks in the current file.
 impl i32 as Core.Add {
@@ -26,17 +14,15 @@ fn AddThreeIntegers(a: i32, b: i32, c: i32) -> i32 {
   return a + b + c;
 }
 
-// CHECK:STDOUT: ; ModuleID = 'prelude.carbon'
-// CHECK:STDOUT: source_filename = "prelude.carbon"
-// CHECK:STDOUT: ; ModuleID = 'user.carbon'
-// CHECK:STDOUT: source_filename = "user.carbon"
+// CHECK:STDOUT: ; ModuleID = 'overloaded_operator.carbon'
+// CHECK:STDOUT: source_filename = "overloaded_operator.carbon"
 // CHECK:STDOUT:
 // CHECK:STDOUT: define i32 @AddThreeIntegers(i32 %a, i32 %b, i32 %c) {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %int.sadd.loc11_12 = add i32 %a, %b
-// CHECK:STDOUT:   %.loc11_12.2.temp = alloca i32, align 4
-// CHECK:STDOUT:   store i32 %int.sadd.loc11_12, ptr %.loc11_12.2.temp, align 4
-// CHECK:STDOUT:   %.loc11_12.4 = load i32, ptr %.loc11_12.2.temp, align 4
-// CHECK:STDOUT:   %int.sadd.loc11_16 = add i32 %.loc11_12.4, %c
-// CHECK:STDOUT:   ret i32 %int.sadd.loc11_16
+// CHECK:STDOUT:   %int.sadd.loc14_12 = add i32 %a, %b
+// CHECK:STDOUT:   %.loc14_12.2.temp = alloca i32, align 4
+// CHECK:STDOUT:   store i32 %int.sadd.loc14_12, ptr %.loc14_12.2.temp, align 4
+// CHECK:STDOUT:   %.loc14_12.4 = load i32, ptr %.loc14_12.2.temp, align 4
+// CHECK:STDOUT:   %int.sadd.loc14_16 = add i32 %.loc14_12.4, %c
+// CHECK:STDOUT:   ret i32 %int.sadd.loc14_16
 // CHECK:STDOUT: }

+ 35 - 52
toolchain/lower/testdata/operators/overloaded.carbon

@@ -4,21 +4,6 @@
 //
 // AUTOUPDATE
 
-// --- prelude.carbon
-
-package Core;
-
-interface Negate {
-  fn Op[self: Self]() -> Self;
-}
-interface Mul {
-  fn Op[self: Self](other: Self) -> Self;
-}
-
-// --- overloaded.carbon
-
-import Core;
-
 class Number {
   var is_positive: bool;
 }
@@ -39,65 +24,63 @@ fn Calculate(a: Number, b: Number) -> Number {
   return -a * b;
 }
 
-// CHECK:STDOUT: ; ModuleID = 'prelude.carbon'
-// CHECK:STDOUT: source_filename = "prelude.carbon"
 // CHECK:STDOUT: ; ModuleID = 'overloaded.carbon'
 // CHECK:STDOUT: source_filename = "overloaded.carbon"
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @Op(ptr sret({ i1 }) %return, ptr %self) {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %.loc10_36.1.is_positive = getelementptr inbounds { i1 }, ptr %self, i32 0, i32 0
-// CHECK:STDOUT:   %.loc10_36.2 = load i1, ptr %.loc10_36.1.is_positive, align 1
-// CHECK:STDOUT:   %.loc10_28 = xor i1 %.loc10_36.2, true
-// CHECK:STDOUT:   %.loc10_48.2.is_positive = getelementptr inbounds { i1 }, ptr %return, i32 0, i32 0
-// CHECK:STDOUT:   store i1 %.loc10_28, ptr %.loc10_48.2.is_positive, align 1
+// CHECK:STDOUT:   %.loc13_36.1.is_positive = getelementptr inbounds { i1 }, ptr %self, i32 0, i32 0
+// CHECK:STDOUT:   %.loc13_36.2 = load i1, ptr %.loc13_36.1.is_positive, align 1
+// CHECK:STDOUT:   %.loc13_28 = xor i1 %.loc13_36.2, true
+// CHECK:STDOUT:   %.loc13_48.2.is_positive = getelementptr inbounds { i1 }, ptr %return, i32 0, i32 0
+// CHECK:STDOUT:   store i1 %.loc13_28, ptr %.loc13_48.2.is_positive, align 1
 // CHECK:STDOUT:   ret void
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @Op.1(ptr sret({ i1 }) %return, ptr %self, ptr %other) {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %.loc15_33.1.is_positive = getelementptr inbounds { i1 }, ptr %self, i32 0, i32 0
-// CHECK:STDOUT:   %.loc15_33.2 = load i1, ptr %.loc15_33.1.is_positive, align 1
-// CHECK:STDOUT:   br i1 %.loc15_33.2, label %and.rhs.loc15, label %and.result.loc15
+// CHECK:STDOUT:   %.loc18_33.1.is_positive = getelementptr inbounds { i1 }, ptr %self, i32 0, i32 0
+// CHECK:STDOUT:   %.loc18_33.2 = load i1, ptr %.loc18_33.1.is_positive, align 1
+// CHECK:STDOUT:   br i1 %.loc18_33.2, label %and.rhs.loc18, label %and.result.loc18
 // CHECK:STDOUT:
-// CHECK:STDOUT: and.rhs.loc15:                                    ; preds = %entry
-// CHECK:STDOUT:   %.loc15_55.1.is_positive = getelementptr inbounds { i1 }, ptr %other, i32 0, i32 0
-// CHECK:STDOUT:   %.loc15_55.2 = load i1, ptr %.loc15_55.1.is_positive, align 1
-// CHECK:STDOUT:   br label %and.result.loc15
+// CHECK:STDOUT: and.rhs.loc18:                                    ; preds = %entry
+// CHECK:STDOUT:   %.loc18_55.1.is_positive = getelementptr inbounds { i1 }, ptr %other, i32 0, i32 0
+// CHECK:STDOUT:   %.loc18_55.2 = load i1, ptr %.loc18_55.1.is_positive, align 1
+// CHECK:STDOUT:   br label %and.result.loc18
 // CHECK:STDOUT:
-// CHECK:STDOUT: and.result.loc15:                                 ; preds = %and.rhs.loc15, %entry
-// CHECK:STDOUT:   %0 = phi i1 [ false, %entry ], [ %.loc15_55.2, %and.rhs.loc15 ]
-// CHECK:STDOUT:   %.loc15_69.1 = xor i1 %0, true
-// CHECK:STDOUT:   br i1 %.loc15_69.1, label %or.rhs, label %or.result
+// CHECK:STDOUT: and.result.loc18:                                 ; preds = %and.rhs.loc18, %entry
+// CHECK:STDOUT:   %0 = phi i1 [ false, %entry ], [ %.loc18_55.2, %and.rhs.loc18 ]
+// CHECK:STDOUT:   %.loc18_69.1 = xor i1 %0, true
+// CHECK:STDOUT:   br i1 %.loc18_69.1, label %or.rhs, label %or.result
 // CHECK:STDOUT:
-// CHECK:STDOUT: or.rhs:                                           ; preds = %and.result.loc15
-// CHECK:STDOUT:   %.loc16_38.1.is_positive = getelementptr inbounds { i1 }, ptr %self, i32 0, i32 0
-// CHECK:STDOUT:   %.loc16_38.2 = load i1, ptr %.loc16_38.1.is_positive, align 1
-// CHECK:STDOUT:   %.loc16_30 = xor i1 %.loc16_38.2, true
-// CHECK:STDOUT:   br i1 %.loc16_30, label %and.rhs.loc16, label %and.result.loc16
+// CHECK:STDOUT: or.rhs:                                           ; preds = %and.result.loc18
+// CHECK:STDOUT:   %.loc19_38.1.is_positive = getelementptr inbounds { i1 }, ptr %self, i32 0, i32 0
+// CHECK:STDOUT:   %.loc19_38.2 = load i1, ptr %.loc19_38.1.is_positive, align 1
+// CHECK:STDOUT:   %.loc19_30 = xor i1 %.loc19_38.2, true
+// CHECK:STDOUT:   br i1 %.loc19_30, label %and.rhs.loc19, label %and.result.loc19
 // CHECK:STDOUT:
-// CHECK:STDOUT: and.rhs.loc16:                                    ; preds = %or.rhs
-// CHECK:STDOUT:   %.loc16_64.1.is_positive = getelementptr inbounds { i1 }, ptr %other, i32 0, i32 0
-// CHECK:STDOUT:   %.loc16_64.2 = load i1, ptr %.loc16_64.1.is_positive, align 1
-// CHECK:STDOUT:   %.loc16_55 = xor i1 %.loc16_64.2, true
-// CHECK:STDOUT:   br label %and.result.loc16
+// CHECK:STDOUT: and.rhs.loc19:                                    ; preds = %or.rhs
+// CHECK:STDOUT:   %.loc19_64.1.is_positive = getelementptr inbounds { i1 }, ptr %other, i32 0, i32 0
+// CHECK:STDOUT:   %.loc19_64.2 = load i1, ptr %.loc19_64.1.is_positive, align 1
+// CHECK:STDOUT:   %.loc19_55 = xor i1 %.loc19_64.2, true
+// CHECK:STDOUT:   br label %and.result.loc19
 // CHECK:STDOUT:
-// CHECK:STDOUT: and.result.loc16:                                 ; preds = %and.rhs.loc16, %or.rhs
-// CHECK:STDOUT:   %1 = phi i1 [ false, %or.rhs ], [ %.loc16_55, %and.rhs.loc16 ]
+// CHECK:STDOUT: and.result.loc19:                                 ; preds = %and.rhs.loc19, %or.rhs
+// CHECK:STDOUT:   %1 = phi i1 [ false, %or.rhs ], [ %.loc19_55, %and.rhs.loc19 ]
 // CHECK:STDOUT:   br label %or.result
 // CHECK:STDOUT:
-// CHECK:STDOUT: or.result:                                        ; preds = %and.result.loc16, %and.result.loc15
-// CHECK:STDOUT:   %2 = phi i1 [ true, %and.result.loc15 ], [ %1, %and.result.loc16 ]
-// CHECK:STDOUT:   %.loc16_77.2.is_positive = getelementptr inbounds { i1 }, ptr %return, i32 0, i32 0
-// CHECK:STDOUT:   store i1 %2, ptr %.loc16_77.2.is_positive, align 1
+// CHECK:STDOUT: or.result:                                        ; preds = %and.result.loc19, %and.result.loc18
+// CHECK:STDOUT:   %2 = phi i1 [ true, %and.result.loc18 ], [ %1, %and.result.loc19 ]
+// CHECK:STDOUT:   %.loc19_77.2.is_positive = getelementptr inbounds { i1 }, ptr %return, i32 0, i32 0
+// CHECK:STDOUT:   store i1 %2, ptr %.loc19_77.2.is_positive, align 1
 // CHECK:STDOUT:   ret void
 // CHECK:STDOUT: }
 // CHECK:STDOUT:
 // CHECK:STDOUT: define void @Calculate(ptr sret({ i1 }) %return, ptr %a, ptr %b) {
 // CHECK:STDOUT: entry:
-// CHECK:STDOUT:   %.loc21_10.2.temp = alloca { i1 }, align 8
-// CHECK:STDOUT:   call void @Op(ptr %.loc21_10.2.temp, ptr %a)
-// CHECK:STDOUT:   call void @Op.1(ptr %return, ptr %.loc21_10.2.temp, ptr %b)
+// CHECK:STDOUT:   %.loc24_10.2.temp = alloca { i1 }, align 8
+// CHECK:STDOUT:   call void @Op(ptr %.loc24_10.2.temp, ptr %a)
+// CHECK:STDOUT:   call void @Op.1(ptr %return, ptr %.loc24_10.2.temp, ptr %b)
 // CHECK:STDOUT:   ret void
 // CHECK:STDOUT: }
 // CHECK:STDOUT: