constant_condition.carbon 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  6. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  7. //
  8. // AUTOUPDATE
  9. // TIP: To test this file alone, run:
  10. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/if_expr/constant_condition.carbon
  11. // TIP: To dump output, run:
  12. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/if_expr/constant_condition.carbon
  13. fn A() -> i32 { return 1; }
  14. fn B() -> i32 { return 2; }
  15. fn F() -> i32 {
  16. return if true then A() else B();
  17. }
  18. fn G() -> i32 {
  19. return if false then A() else B();
  20. }
  21. fn Constant() -> i32 {
  22. var v: if true then i32 else i32* = 1;
  23. var w: if false then i32 else i32* = &v;
  24. return *w;
  25. }
  26. fn PartiallyConstant(t: type) -> i32 {
  27. var v: if true then i32 else t = 1;
  28. var w: if false then t else i32* = &v;
  29. return *w;
  30. }
  31. // CHECK:STDOUT: --- constant_condition.carbon
  32. // CHECK:STDOUT:
  33. // CHECK:STDOUT: constants {
  34. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  35. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  36. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  37. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  38. // CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
  39. // CHECK:STDOUT: %A.type: type = fn_type @A [concrete]
  40. // CHECK:STDOUT: %A: %A.type = struct_value () [concrete]
  41. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  42. // CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete]
  43. // CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete]
  44. // CHECK:STDOUT: %pattern_type.98f: type = pattern_type type [concrete]
  45. // CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
  46. // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [concrete]
  47. // CHECK:STDOUT: %To.c80: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  48. // CHECK:STDOUT: %Convert.type.0f9: type = fn_type @Convert.2, @impl.4f9(%To.c80) [symbolic]
  49. // CHECK:STDOUT: %Convert.f06: %Convert.type.0f9 = struct_value () [symbolic]
  50. // CHECK:STDOUT: %ImplicitAs.impl_witness.c75: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.a2f, @impl.4f9(%int_32) [concrete]
  51. // CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.4f9(%int_32) [concrete]
  52. // CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [concrete]
  53. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.c75) [concrete]
  54. // CHECK:STDOUT: %.9c3: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [concrete]
  55. // CHECK:STDOUT: %Convert.bound.ab5: <bound method> = bound_method %int_1.5b8, %Convert.956 [concrete]
  56. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.956, @Convert.2(%int_32) [concrete]
  57. // CHECK:STDOUT: %bound_method.9a1: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
  58. // CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete]
  59. // CHECK:STDOUT: %B.type: type = fn_type @B [concrete]
  60. // CHECK:STDOUT: %B: %B.type = struct_value () [concrete]
  61. // CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [concrete]
  62. // CHECK:STDOUT: %Convert.bound.ef9: <bound method> = bound_method %int_2.ecc, %Convert.956 [concrete]
  63. // CHECK:STDOUT: %bound_method.b92: <bound method> = bound_method %int_2.ecc, %Convert.specific_fn [concrete]
  64. // CHECK:STDOUT: %int_2.ef8: %i32 = int_value 2 [concrete]
  65. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  66. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  67. // CHECK:STDOUT: %true: bool = bool_literal true [concrete]
  68. // CHECK:STDOUT: %G.type: type = fn_type @G [concrete]
  69. // CHECK:STDOUT: %G: %G.type = struct_value () [concrete]
  70. // CHECK:STDOUT: %false: bool = bool_literal false [concrete]
  71. // CHECK:STDOUT: %Constant.type: type = fn_type @Constant [concrete]
  72. // CHECK:STDOUT: %Constant: %Constant.type = struct_value () [concrete]
  73. // CHECK:STDOUT: %ptr.235: type = ptr_type %i32 [concrete]
  74. // CHECK:STDOUT: %pattern_type.fe8: type = pattern_type %ptr.235 [concrete]
  75. // CHECK:STDOUT: %PartiallyConstant.type: type = fn_type @PartiallyConstant [concrete]
  76. // CHECK:STDOUT: %PartiallyConstant: %PartiallyConstant.type = struct_value () [concrete]
  77. // CHECK:STDOUT: }
  78. // CHECK:STDOUT:
  79. // CHECK:STDOUT: imports {
  80. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  81. // CHECK:STDOUT: .Int = %Core.Int
  82. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  83. // CHECK:STDOUT: import Core//prelude
  84. // CHECK:STDOUT: import Core//prelude/...
  85. // CHECK:STDOUT: }
  86. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/types/int, Int, loaded [concrete = constants.%Int.generic]
  87. // CHECK:STDOUT: %Core.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/operators/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
  88. // CHECK:STDOUT: %Core.import_ref.a5b: @impl.4f9.%Convert.type (%Convert.type.0f9) = import_ref Core//prelude/types/int, loc19_39, loaded [symbolic = @impl.4f9.%Convert (constants.%Convert.f06)]
  89. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.a2f = impl_witness_table (%Core.import_ref.a5b), @impl.4f9 [concrete]
  90. // CHECK:STDOUT: }
  91. // CHECK:STDOUT:
  92. // CHECK:STDOUT: file {
  93. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  94. // CHECK:STDOUT: .Core = imports.%Core
  95. // CHECK:STDOUT: .A = %A.decl
  96. // CHECK:STDOUT: .B = %B.decl
  97. // CHECK:STDOUT: .F = %F.decl
  98. // CHECK:STDOUT: .G = %G.decl
  99. // CHECK:STDOUT: .Constant = %Constant.decl
  100. // CHECK:STDOUT: .PartiallyConstant = %PartiallyConstant.decl
  101. // CHECK:STDOUT: }
  102. // CHECK:STDOUT: %Core.import = import Core
  103. // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [concrete = constants.%A] {
  104. // CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
  105. // CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param0 [concrete]
  106. // CHECK:STDOUT: } {
  107. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  108. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  109. // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param0
  110. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  111. // CHECK:STDOUT: }
  112. // CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [concrete = constants.%B] {
  113. // CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
  114. // CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param0 [concrete]
  115. // CHECK:STDOUT: } {
  116. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  117. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  118. // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param0
  119. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  120. // CHECK:STDOUT: }
  121. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  122. // CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
  123. // CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param0 [concrete]
  124. // CHECK:STDOUT: } {
  125. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  126. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  127. // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param0
  128. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  129. // CHECK:STDOUT: }
  130. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {
  131. // CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
  132. // CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param0 [concrete]
  133. // CHECK:STDOUT: } {
  134. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  135. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  136. // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param0
  137. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  138. // CHECK:STDOUT: }
  139. // CHECK:STDOUT: %Constant.decl: %Constant.type = fn_decl @Constant [concrete = constants.%Constant] {
  140. // CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
  141. // CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param0 [concrete]
  142. // CHECK:STDOUT: } {
  143. // CHECK:STDOUT: %int_32.loc25: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  144. // CHECK:STDOUT: %i32.loc25: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  145. // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param0
  146. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  147. // CHECK:STDOUT: }
  148. // CHECK:STDOUT: %PartiallyConstant.decl: %PartiallyConstant.type = fn_decl @PartiallyConstant [concrete = constants.%PartiallyConstant] {
  149. // CHECK:STDOUT: %t.patt: %pattern_type.98f = binding_pattern t [concrete]
  150. // CHECK:STDOUT: %t.param_patt: %pattern_type.98f = value_param_pattern %t.patt, call_param0 [concrete]
  151. // CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
  152. // CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param1 [concrete]
  153. // CHECK:STDOUT: } {
  154. // CHECK:STDOUT: %int_32.loc31: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  155. // CHECK:STDOUT: %i32.loc31: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  156. // CHECK:STDOUT: %t.param: type = value_param call_param0
  157. // CHECK:STDOUT: %t: type = bind_name t, %t.param
  158. // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1
  159. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  160. // CHECK:STDOUT: }
  161. // CHECK:STDOUT: }
  162. // CHECK:STDOUT:
  163. // CHECK:STDOUT: fn @A() -> %i32 {
  164. // CHECK:STDOUT: !entry:
  165. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  166. // CHECK:STDOUT: %impl.elem0: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
  167. // CHECK:STDOUT: %bound_method.loc14_25.1: <bound method> = bound_method %int_1, %impl.elem0 [concrete = constants.%Convert.bound.ab5]
  168. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  169. // CHECK:STDOUT: %bound_method.loc14_25.2: <bound method> = bound_method %int_1, %specific_fn [concrete = constants.%bound_method.9a1]
  170. // CHECK:STDOUT: %int.convert_checked: init %i32 = call %bound_method.loc14_25.2(%int_1) [concrete = constants.%int_1.5d2]
  171. // CHECK:STDOUT: %.loc14_25.1: %i32 = value_of_initializer %int.convert_checked [concrete = constants.%int_1.5d2]
  172. // CHECK:STDOUT: %.loc14_25.2: %i32 = converted %int_1, %.loc14_25.1 [concrete = constants.%int_1.5d2]
  173. // CHECK:STDOUT: return %.loc14_25.2
  174. // CHECK:STDOUT: }
  175. // CHECK:STDOUT:
  176. // CHECK:STDOUT: fn @B() -> %i32 {
  177. // CHECK:STDOUT: !entry:
  178. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
  179. // CHECK:STDOUT: %impl.elem0: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
  180. // CHECK:STDOUT: %bound_method.loc15_25.1: <bound method> = bound_method %int_2, %impl.elem0 [concrete = constants.%Convert.bound.ef9]
  181. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  182. // CHECK:STDOUT: %bound_method.loc15_25.2: <bound method> = bound_method %int_2, %specific_fn [concrete = constants.%bound_method.b92]
  183. // CHECK:STDOUT: %int.convert_checked: init %i32 = call %bound_method.loc15_25.2(%int_2) [concrete = constants.%int_2.ef8]
  184. // CHECK:STDOUT: %.loc15_25.1: %i32 = value_of_initializer %int.convert_checked [concrete = constants.%int_2.ef8]
  185. // CHECK:STDOUT: %.loc15_25.2: %i32 = converted %int_2, %.loc15_25.1 [concrete = constants.%int_2.ef8]
  186. // CHECK:STDOUT: return %.loc15_25.2
  187. // CHECK:STDOUT: }
  188. // CHECK:STDOUT:
  189. // CHECK:STDOUT: fn @F() -> %i32 {
  190. // CHECK:STDOUT: !entry:
  191. // CHECK:STDOUT: %true: bool = bool_literal true [concrete = constants.%true]
  192. // CHECK:STDOUT: if %true br !if.expr.then else br !if.expr.else
  193. // CHECK:STDOUT:
  194. // CHECK:STDOUT: !if.expr.then:
  195. // CHECK:STDOUT: %A.ref: %A.type = name_ref A, file.%A.decl [concrete = constants.%A]
  196. // CHECK:STDOUT: %A.call: init %i32 = call %A.ref()
  197. // CHECK:STDOUT: %.loc18_25.1: %i32 = value_of_initializer %A.call
  198. // CHECK:STDOUT: %.loc18_25.2: %i32 = converted %A.call, %.loc18_25.1
  199. // CHECK:STDOUT: br !if.expr.result(%.loc18_25.2)
  200. // CHECK:STDOUT:
  201. // CHECK:STDOUT: !if.expr.else:
  202. // CHECK:STDOUT: %B.ref: %B.type = name_ref B, file.%B.decl [concrete = constants.%B]
  203. // CHECK:STDOUT: %B.call: init %i32 = call %B.ref()
  204. // CHECK:STDOUT: %.loc18_27.1: %i32 = value_of_initializer %B.call
  205. // CHECK:STDOUT: %.loc18_27.2: %i32 = converted %B.call, %.loc18_27.1
  206. // CHECK:STDOUT: br !if.expr.result(%.loc18_27.2)
  207. // CHECK:STDOUT:
  208. // CHECK:STDOUT: !if.expr.result:
  209. // CHECK:STDOUT: %.loc18_10: %i32 = block_arg !if.expr.result
  210. // CHECK:STDOUT: return %.loc18_10
  211. // CHECK:STDOUT: }
  212. // CHECK:STDOUT:
  213. // CHECK:STDOUT: fn @G() -> %i32 {
  214. // CHECK:STDOUT: !entry:
  215. // CHECK:STDOUT: %false: bool = bool_literal false [concrete = constants.%false]
  216. // CHECK:STDOUT: if %false br !if.expr.then else br !if.expr.else
  217. // CHECK:STDOUT:
  218. // CHECK:STDOUT: !if.expr.then:
  219. // CHECK:STDOUT: %A.ref: %A.type = name_ref A, file.%A.decl [concrete = constants.%A]
  220. // CHECK:STDOUT: %A.call: init %i32 = call %A.ref()
  221. // CHECK:STDOUT: %.loc22_26.1: %i32 = value_of_initializer %A.call
  222. // CHECK:STDOUT: %.loc22_26.2: %i32 = converted %A.call, %.loc22_26.1
  223. // CHECK:STDOUT: br !if.expr.result(%.loc22_26.2)
  224. // CHECK:STDOUT:
  225. // CHECK:STDOUT: !if.expr.else:
  226. // CHECK:STDOUT: %B.ref: %B.type = name_ref B, file.%B.decl [concrete = constants.%B]
  227. // CHECK:STDOUT: %B.call: init %i32 = call %B.ref()
  228. // CHECK:STDOUT: %.loc22_28.1: %i32 = value_of_initializer %B.call
  229. // CHECK:STDOUT: %.loc22_28.2: %i32 = converted %B.call, %.loc22_28.1
  230. // CHECK:STDOUT: br !if.expr.result(%.loc22_28.2)
  231. // CHECK:STDOUT:
  232. // CHECK:STDOUT: !if.expr.result:
  233. // CHECK:STDOUT: %.loc22_10: %i32 = block_arg !if.expr.result
  234. // CHECK:STDOUT: return %.loc22_10
  235. // CHECK:STDOUT: }
  236. // CHECK:STDOUT:
  237. // CHECK:STDOUT: fn @Constant() -> %i32 {
  238. // CHECK:STDOUT: !entry:
  239. // CHECK:STDOUT: name_binding_decl {
  240. // CHECK:STDOUT: %v.patt: %pattern_type.7ce = binding_pattern v [concrete]
  241. // CHECK:STDOUT: %v.var_patt: %pattern_type.7ce = var_pattern %v.patt [concrete]
  242. // CHECK:STDOUT: }
  243. // CHECK:STDOUT: %v.var: ref %i32 = var %v.var_patt
  244. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  245. // CHECK:STDOUT: %impl.elem0: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
  246. // CHECK:STDOUT: %bound_method.loc26_3.1: <bound method> = bound_method %int_1, %impl.elem0 [concrete = constants.%Convert.bound.ab5]
  247. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  248. // CHECK:STDOUT: %bound_method.loc26_3.2: <bound method> = bound_method %int_1, %specific_fn [concrete = constants.%bound_method.9a1]
  249. // CHECK:STDOUT: %int.convert_checked: init %i32 = call %bound_method.loc26_3.2(%int_1) [concrete = constants.%int_1.5d2]
  250. // CHECK:STDOUT: %.loc26_3: init %i32 = converted %int_1, %int.convert_checked [concrete = constants.%int_1.5d2]
  251. // CHECK:STDOUT: assign %v.var, %.loc26_3
  252. // CHECK:STDOUT: br !.loc26_13
  253. // CHECK:STDOUT:
  254. // CHECK:STDOUT: !.loc26_13:
  255. // CHECK:STDOUT: %true: bool = bool_literal true [concrete = constants.%true]
  256. // CHECK:STDOUT: if %true br !if.expr.then.loc26 else br !if.expr.else.loc26
  257. // CHECK:STDOUT:
  258. // CHECK:STDOUT: !if.expr.then.loc26:
  259. // CHECK:STDOUT: %int_32.loc26_23: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  260. // CHECK:STDOUT: %i32.loc26_23: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  261. // CHECK:STDOUT: br !if.expr.result.loc26(%i32.loc26_23)
  262. // CHECK:STDOUT:
  263. // CHECK:STDOUT: !if.expr.else.loc26:
  264. // CHECK:STDOUT: %int_32.loc26_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  265. // CHECK:STDOUT: %i32.loc26_32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  266. // CHECK:STDOUT: %ptr.loc26: type = ptr_type %i32.loc26_32 [concrete = constants.%ptr.235]
  267. // CHECK:STDOUT: br !if.expr.result.loc26(%ptr.loc26)
  268. // CHECK:STDOUT:
  269. // CHECK:STDOUT: !if.expr.result.loc26:
  270. // CHECK:STDOUT: %.loc26_10: type = block_arg !if.expr.result.loc26 [concrete = constants.%i32]
  271. // CHECK:STDOUT: br !.loc26_7
  272. // CHECK:STDOUT:
  273. // CHECK:STDOUT: !.loc26_7:
  274. // CHECK:STDOUT: %v: ref %i32 = bind_name v, %v.var
  275. // CHECK:STDOUT: name_binding_decl {
  276. // CHECK:STDOUT: %w.patt: %pattern_type.fe8 = binding_pattern w [concrete]
  277. // CHECK:STDOUT: %w.var_patt: %pattern_type.fe8 = var_pattern %w.patt [concrete]
  278. // CHECK:STDOUT: }
  279. // CHECK:STDOUT: %w.var: ref %ptr.235 = var %w.var_patt
  280. // CHECK:STDOUT: %v.ref: ref %i32 = name_ref v, %v
  281. // CHECK:STDOUT: %addr: %ptr.235 = addr_of %v.ref
  282. // CHECK:STDOUT: assign %w.var, %addr
  283. // CHECK:STDOUT: br !.loc27_13
  284. // CHECK:STDOUT:
  285. // CHECK:STDOUT: !.loc27_13:
  286. // CHECK:STDOUT: %false: bool = bool_literal false [concrete = constants.%false]
  287. // CHECK:STDOUT: if %false br !if.expr.then.loc27 else br !if.expr.else.loc27
  288. // CHECK:STDOUT:
  289. // CHECK:STDOUT: !if.expr.then.loc27:
  290. // CHECK:STDOUT: %int_32.loc27_24: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  291. // CHECK:STDOUT: %i32.loc27_24: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  292. // CHECK:STDOUT: br !if.expr.result.loc27(%i32.loc27_24)
  293. // CHECK:STDOUT:
  294. // CHECK:STDOUT: !if.expr.else.loc27:
  295. // CHECK:STDOUT: %int_32.loc27_33: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  296. // CHECK:STDOUT: %i32.loc27_33: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  297. // CHECK:STDOUT: %ptr.loc27: type = ptr_type %i32.loc27_33 [concrete = constants.%ptr.235]
  298. // CHECK:STDOUT: br !if.expr.result.loc27(%ptr.loc27)
  299. // CHECK:STDOUT:
  300. // CHECK:STDOUT: !if.expr.result.loc27:
  301. // CHECK:STDOUT: %.loc27: type = block_arg !if.expr.result.loc27 [concrete = constants.%ptr.235]
  302. // CHECK:STDOUT: br !.loc27_7
  303. // CHECK:STDOUT:
  304. // CHECK:STDOUT: !.loc27_7:
  305. // CHECK:STDOUT: %w: ref %ptr.235 = bind_name w, %w.var
  306. // CHECK:STDOUT: %w.ref: ref %ptr.235 = name_ref w, %w
  307. // CHECK:STDOUT: %.loc28_11: %ptr.235 = bind_value %w.ref
  308. // CHECK:STDOUT: %.loc28_10.1: ref %i32 = deref %.loc28_11
  309. // CHECK:STDOUT: %.loc28_10.2: %i32 = bind_value %.loc28_10.1
  310. // CHECK:STDOUT: return %.loc28_10.2
  311. // CHECK:STDOUT: }
  312. // CHECK:STDOUT:
  313. // CHECK:STDOUT: fn @PartiallyConstant(%t.param: type) -> %i32 {
  314. // CHECK:STDOUT: !entry:
  315. // CHECK:STDOUT: name_binding_decl {
  316. // CHECK:STDOUT: %v.patt: %pattern_type.7ce = binding_pattern v [concrete]
  317. // CHECK:STDOUT: %v.var_patt: %pattern_type.7ce = var_pattern %v.patt [concrete]
  318. // CHECK:STDOUT: }
  319. // CHECK:STDOUT: %v.var: ref %i32 = var %v.var_patt
  320. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  321. // CHECK:STDOUT: %impl.elem0: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Convert.956]
  322. // CHECK:STDOUT: %bound_method.loc32_3.1: <bound method> = bound_method %int_1, %impl.elem0 [concrete = constants.%Convert.bound.ab5]
  323. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  324. // CHECK:STDOUT: %bound_method.loc32_3.2: <bound method> = bound_method %int_1, %specific_fn [concrete = constants.%bound_method.9a1]
  325. // CHECK:STDOUT: %int.convert_checked: init %i32 = call %bound_method.loc32_3.2(%int_1) [concrete = constants.%int_1.5d2]
  326. // CHECK:STDOUT: %.loc32_3: init %i32 = converted %int_1, %int.convert_checked [concrete = constants.%int_1.5d2]
  327. // CHECK:STDOUT: assign %v.var, %.loc32_3
  328. // CHECK:STDOUT: br !.loc32_13
  329. // CHECK:STDOUT:
  330. // CHECK:STDOUT: !.loc32_13:
  331. // CHECK:STDOUT: %true: bool = bool_literal true [concrete = constants.%true]
  332. // CHECK:STDOUT: if %true br !if.expr.then.loc32 else br !if.expr.else.loc32
  333. // CHECK:STDOUT:
  334. // CHECK:STDOUT: !if.expr.then.loc32:
  335. // CHECK:STDOUT: %int_32.loc32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  336. // CHECK:STDOUT: %i32.loc32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  337. // CHECK:STDOUT: br !if.expr.result.loc32(%i32.loc32)
  338. // CHECK:STDOUT:
  339. // CHECK:STDOUT: !if.expr.else.loc32:
  340. // CHECK:STDOUT: %t.ref.loc32: type = name_ref t, %t
  341. // CHECK:STDOUT: br !if.expr.result.loc32(%t.ref.loc32)
  342. // CHECK:STDOUT:
  343. // CHECK:STDOUT: !if.expr.result.loc32:
  344. // CHECK:STDOUT: %.loc32_10: type = block_arg !if.expr.result.loc32 [concrete = constants.%i32]
  345. // CHECK:STDOUT: br !.loc32_7
  346. // CHECK:STDOUT:
  347. // CHECK:STDOUT: !.loc32_7:
  348. // CHECK:STDOUT: %v: ref %i32 = bind_name v, %v.var
  349. // CHECK:STDOUT: name_binding_decl {
  350. // CHECK:STDOUT: %w.patt: %pattern_type.fe8 = binding_pattern w [concrete]
  351. // CHECK:STDOUT: %w.var_patt: %pattern_type.fe8 = var_pattern %w.patt [concrete]
  352. // CHECK:STDOUT: }
  353. // CHECK:STDOUT: %w.var: ref %ptr.235 = var %w.var_patt
  354. // CHECK:STDOUT: %v.ref: ref %i32 = name_ref v, %v
  355. // CHECK:STDOUT: %addr: %ptr.235 = addr_of %v.ref
  356. // CHECK:STDOUT: assign %w.var, %addr
  357. // CHECK:STDOUT: br !.loc33_13
  358. // CHECK:STDOUT:
  359. // CHECK:STDOUT: !.loc33_13:
  360. // CHECK:STDOUT: %false: bool = bool_literal false [concrete = constants.%false]
  361. // CHECK:STDOUT: if %false br !if.expr.then.loc33 else br !if.expr.else.loc33
  362. // CHECK:STDOUT:
  363. // CHECK:STDOUT: !if.expr.then.loc33:
  364. // CHECK:STDOUT: %t.ref.loc33: type = name_ref t, %t
  365. // CHECK:STDOUT: br !if.expr.result.loc33(%t.ref.loc33)
  366. // CHECK:STDOUT:
  367. // CHECK:STDOUT: !if.expr.else.loc33:
  368. // CHECK:STDOUT: %int_32.loc33: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  369. // CHECK:STDOUT: %i32.loc33: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  370. // CHECK:STDOUT: %ptr: type = ptr_type %i32.loc33 [concrete = constants.%ptr.235]
  371. // CHECK:STDOUT: br !if.expr.result.loc33(%ptr)
  372. // CHECK:STDOUT:
  373. // CHECK:STDOUT: !if.expr.result.loc33:
  374. // CHECK:STDOUT: %.loc33: type = block_arg !if.expr.result.loc33 [concrete = constants.%ptr.235]
  375. // CHECK:STDOUT: br !.loc33_7
  376. // CHECK:STDOUT:
  377. // CHECK:STDOUT: !.loc33_7:
  378. // CHECK:STDOUT: %w: ref %ptr.235 = bind_name w, %w.var
  379. // CHECK:STDOUT: %w.ref: ref %ptr.235 = name_ref w, %w
  380. // CHECK:STDOUT: %.loc34_11: %ptr.235 = bind_value %w.ref
  381. // CHECK:STDOUT: %.loc34_10.1: ref %i32 = deref %.loc34_11
  382. // CHECK:STDOUT: %.loc34_10.2: %i32 = bind_value %.loc34_10.1
  383. // CHECK:STDOUT: return %.loc34_10.2
  384. // CHECK:STDOUT: }
  385. // CHECK:STDOUT: