less.carbon 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  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. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/builtins/int/less.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/builtins/int/less.carbon
  10. // --- int_less.carbon
  11. fn Less(a: i32, b: i32) -> bool = "int.less";
  12. fn Negate(a: i32) -> i32 = "int.snegate";
  13. class True {}
  14. class False {}
  15. fn F(true_: True, false_: False) {
  16. true_ as (if Less(1, 2) then True else False);
  17. false_ as (if Less(1, 1) then True else False);
  18. false_ as (if Less(1, 0) then True else False);
  19. true_ as (if Less(Negate(1), 0) then True else False);
  20. false_ as (if Less(0, Negate(1)) then True else False);
  21. }
  22. fn RuntimeCall(a: i32, b: i32) -> bool {
  23. return Less(a, b);
  24. }
  25. // CHECK:STDOUT: --- int_less.carbon
  26. // CHECK:STDOUT:
  27. // CHECK:STDOUT: constants {
  28. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  29. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  30. // CHECK:STDOUT: %Bool.type: type = fn_type @Bool [template]
  31. // CHECK:STDOUT: %Bool: %Bool.type = struct_value () [template]
  32. // CHECK:STDOUT: %Less.type: type = fn_type @Less [template]
  33. // CHECK:STDOUT: %Less: %Less.type = struct_value () [template]
  34. // CHECK:STDOUT: %Negate.type.1: type = fn_type @Negate.1 [template]
  35. // CHECK:STDOUT: %Negate: %Negate.type.1 = struct_value () [template]
  36. // CHECK:STDOUT: %True: type = class_type @True [template]
  37. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  38. // CHECK:STDOUT: %complete_type.3: <witness> = complete_type_witness %empty_struct_type [template]
  39. // CHECK:STDOUT: %False: type = class_type @False [template]
  40. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  41. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  42. // CHECK:STDOUT: %int_1.1: Core.IntLiteral = int_value 1 [template]
  43. // CHECK:STDOUT: %int_2.1: Core.IntLiteral = int_value 2 [template]
  44. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  45. // CHECK:STDOUT: %Convert.type.10: type = fn_type @Convert.2, @impl.1(%int_32) [template]
  46. // CHECK:STDOUT: %Convert.10: %Convert.type.10 = struct_value () [template]
  47. // CHECK:STDOUT: %interface.5: <witness> = interface_witness (%Convert.10) [template]
  48. // CHECK:STDOUT: %Convert.bound.1: <bound method> = bound_method %int_1.1, %Convert.10 [template]
  49. // CHECK:STDOUT: %Convert.specific_fn.1: <specific function> = specific_function %Convert.bound.1, @Convert.2(%int_32) [template]
  50. // CHECK:STDOUT: %int_1.2: %i32 = int_value 1 [template]
  51. // CHECK:STDOUT: %Convert.bound.2: <bound method> = bound_method %int_2.1, %Convert.10 [template]
  52. // CHECK:STDOUT: %Convert.specific_fn.2: <specific function> = specific_function %Convert.bound.2, @Convert.2(%int_32) [template]
  53. // CHECK:STDOUT: %int_2.2: %i32 = int_value 2 [template]
  54. // CHECK:STDOUT: %true: bool = bool_literal true [template]
  55. // CHECK:STDOUT: %false: bool = bool_literal false [template]
  56. // CHECK:STDOUT: %int_0.1: Core.IntLiteral = int_value 0 [template]
  57. // CHECK:STDOUT: %Convert.bound.3: <bound method> = bound_method %int_0.1, %Convert.10 [template]
  58. // CHECK:STDOUT: %Convert.specific_fn.3: <specific function> = specific_function %Convert.bound.3, @Convert.2(%int_32) [template]
  59. // CHECK:STDOUT: %int_0.2: %i32 = int_value 0 [template]
  60. // CHECK:STDOUT: %int_-1: %i32 = int_value -1 [template]
  61. // CHECK:STDOUT: %RuntimeCall.type: type = fn_type @RuntimeCall [template]
  62. // CHECK:STDOUT: %RuntimeCall: %RuntimeCall.type = struct_value () [template]
  63. // CHECK:STDOUT: }
  64. // CHECK:STDOUT:
  65. // CHECK:STDOUT: imports {
  66. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  67. // CHECK:STDOUT: .Int = %import_ref.1
  68. // CHECK:STDOUT: .Bool = %import_ref.5
  69. // CHECK:STDOUT: .ImplicitAs = %import_ref.6
  70. // CHECK:STDOUT: import Core//prelude
  71. // CHECK:STDOUT: import Core//prelude/...
  72. // CHECK:STDOUT: }
  73. // CHECK:STDOUT: }
  74. // CHECK:STDOUT:
  75. // CHECK:STDOUT: file {
  76. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  77. // CHECK:STDOUT: .Core = imports.%Core
  78. // CHECK:STDOUT: .Less = %Less.decl
  79. // CHECK:STDOUT: .Negate = %Negate.decl
  80. // CHECK:STDOUT: .True = %True.decl
  81. // CHECK:STDOUT: .False = %False.decl
  82. // CHECK:STDOUT: .F = %F.decl
  83. // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl
  84. // CHECK:STDOUT: }
  85. // CHECK:STDOUT: %Core.import = import Core
  86. // CHECK:STDOUT: %Less.decl: %Less.type = fn_decl @Less [template = constants.%Less] {
  87. // CHECK:STDOUT: %a.patt: %i32 = binding_pattern a
  88. // CHECK:STDOUT: %a.param_patt: %i32 = value_param_pattern %a.patt, runtime_param0
  89. // CHECK:STDOUT: %b.patt: %i32 = binding_pattern b
  90. // CHECK:STDOUT: %b.param_patt: %i32 = value_param_pattern %b.patt, runtime_param1
  91. // CHECK:STDOUT: %return.patt: bool = return_slot_pattern
  92. // CHECK:STDOUT: %return.param_patt: bool = out_param_pattern %return.patt, runtime_param2
  93. // CHECK:STDOUT: } {
  94. // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
  95. // CHECK:STDOUT: %.loc2_28.1: type = value_of_initializer %bool.make_type [template = bool]
  96. // CHECK:STDOUT: %.loc2_28.2: type = converted %bool.make_type, %.loc2_28.1 [template = bool]
  97. // CHECK:STDOUT: %a.param: %i32 = value_param runtime_param0
  98. // CHECK:STDOUT: %.loc2_12: type = splice_block %i32.loc2_12 [template = constants.%i32] {
  99. // CHECK:STDOUT: %int_32.loc2_12: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  100. // CHECK:STDOUT: %i32.loc2_12: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  101. // CHECK:STDOUT: }
  102. // CHECK:STDOUT: %a: %i32 = bind_name a, %a.param
  103. // CHECK:STDOUT: %b.param: %i32 = value_param runtime_param1
  104. // CHECK:STDOUT: %.loc2_20: type = splice_block %i32.loc2_20 [template = constants.%i32] {
  105. // CHECK:STDOUT: %int_32.loc2_20: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  106. // CHECK:STDOUT: %i32.loc2_20: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  107. // CHECK:STDOUT: }
  108. // CHECK:STDOUT: %b: %i32 = bind_name b, %b.param
  109. // CHECK:STDOUT: %return.param: ref bool = out_param runtime_param2
  110. // CHECK:STDOUT: %return: ref bool = return_slot %return.param
  111. // CHECK:STDOUT: }
  112. // CHECK:STDOUT: %Negate.decl: %Negate.type.1 = fn_decl @Negate.1 [template = constants.%Negate] {
  113. // CHECK:STDOUT: %a.patt: %i32 = binding_pattern a
  114. // CHECK:STDOUT: %a.param_patt: %i32 = value_param_pattern %a.patt, runtime_param0
  115. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  116. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param1
  117. // CHECK:STDOUT: } {
  118. // CHECK:STDOUT: %int_32.loc3_22: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  119. // CHECK:STDOUT: %i32.loc3_22: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  120. // CHECK:STDOUT: %a.param: %i32 = value_param runtime_param0
  121. // CHECK:STDOUT: %.loc3: type = splice_block %i32.loc3_14 [template = constants.%i32] {
  122. // CHECK:STDOUT: %int_32.loc3_14: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  123. // CHECK:STDOUT: %i32.loc3_14: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  124. // CHECK:STDOUT: }
  125. // CHECK:STDOUT: %a: %i32 = bind_name a, %a.param
  126. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param1
  127. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  128. // CHECK:STDOUT: }
  129. // CHECK:STDOUT: %True.decl: type = class_decl @True [template = constants.%True] {} {}
  130. // CHECK:STDOUT: %False.decl: type = class_decl @False [template = constants.%False] {} {}
  131. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  132. // CHECK:STDOUT: %true_.patt: %True = binding_pattern true_
  133. // CHECK:STDOUT: %true_.param_patt: %True = value_param_pattern %true_.patt, runtime_param0
  134. // CHECK:STDOUT: %false_.patt: %False = binding_pattern false_
  135. // CHECK:STDOUT: %false_.param_patt: %False = value_param_pattern %false_.patt, runtime_param1
  136. // CHECK:STDOUT: } {
  137. // CHECK:STDOUT: %true_.param: %True = value_param runtime_param0
  138. // CHECK:STDOUT: %True.ref.loc8: type = name_ref True, file.%True.decl [template = constants.%True]
  139. // CHECK:STDOUT: %true_: %True = bind_name true_, %true_.param
  140. // CHECK:STDOUT: %false_.param: %False = value_param runtime_param1
  141. // CHECK:STDOUT: %False.ref.loc8: type = name_ref False, file.%False.decl [template = constants.%False]
  142. // CHECK:STDOUT: %false_: %False = bind_name false_, %false_.param
  143. // CHECK:STDOUT: }
  144. // CHECK:STDOUT: %RuntimeCall.decl: %RuntimeCall.type = fn_decl @RuntimeCall [template = constants.%RuntimeCall] {
  145. // CHECK:STDOUT: %a.patt: %i32 = binding_pattern a
  146. // CHECK:STDOUT: %a.param_patt: %i32 = value_param_pattern %a.patt, runtime_param0
  147. // CHECK:STDOUT: %b.patt: %i32 = binding_pattern b
  148. // CHECK:STDOUT: %b.param_patt: %i32 = value_param_pattern %b.patt, runtime_param1
  149. // CHECK:STDOUT: %return.patt: bool = return_slot_pattern
  150. // CHECK:STDOUT: %return.param_patt: bool = out_param_pattern %return.patt, runtime_param2
  151. // CHECK:STDOUT: } {
  152. // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
  153. // CHECK:STDOUT: %.loc16_35.1: type = value_of_initializer %bool.make_type [template = bool]
  154. // CHECK:STDOUT: %.loc16_35.2: type = converted %bool.make_type, %.loc16_35.1 [template = bool]
  155. // CHECK:STDOUT: %a.param: %i32 = value_param runtime_param0
  156. // CHECK:STDOUT: %.loc16_19: type = splice_block %i32.loc16_19 [template = constants.%i32] {
  157. // CHECK:STDOUT: %int_32.loc16_19: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  158. // CHECK:STDOUT: %i32.loc16_19: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  159. // CHECK:STDOUT: }
  160. // CHECK:STDOUT: %a: %i32 = bind_name a, %a.param
  161. // CHECK:STDOUT: %b.param: %i32 = value_param runtime_param1
  162. // CHECK:STDOUT: %.loc16_27: type = splice_block %i32.loc16_27 [template = constants.%i32] {
  163. // CHECK:STDOUT: %int_32.loc16_27: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  164. // CHECK:STDOUT: %i32.loc16_27: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  165. // CHECK:STDOUT: }
  166. // CHECK:STDOUT: %b: %i32 = bind_name b, %b.param
  167. // CHECK:STDOUT: %return.param: ref bool = out_param runtime_param2
  168. // CHECK:STDOUT: %return: ref bool = return_slot %return.param
  169. // CHECK:STDOUT: }
  170. // CHECK:STDOUT: }
  171. // CHECK:STDOUT:
  172. // CHECK:STDOUT: class @True {
  173. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type.3]
  174. // CHECK:STDOUT:
  175. // CHECK:STDOUT: !members:
  176. // CHECK:STDOUT: .Self = constants.%True
  177. // CHECK:STDOUT: complete_type_witness = %complete_type
  178. // CHECK:STDOUT: }
  179. // CHECK:STDOUT:
  180. // CHECK:STDOUT: class @False {
  181. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type.3]
  182. // CHECK:STDOUT:
  183. // CHECK:STDOUT: !members:
  184. // CHECK:STDOUT: .Self = constants.%False
  185. // CHECK:STDOUT: complete_type_witness = %complete_type
  186. // CHECK:STDOUT: }
  187. // CHECK:STDOUT:
  188. // CHECK:STDOUT: fn @Less(%a.param_patt: %i32, %b.param_patt: %i32) -> bool = "int.less";
  189. // CHECK:STDOUT:
  190. // CHECK:STDOUT: fn @Negate.1(%a.param_patt: %i32) -> %i32 = "int.snegate";
  191. // CHECK:STDOUT:
  192. // CHECK:STDOUT: fn @F(%true_.param_patt: %True, %false_.param_patt: %False) {
  193. // CHECK:STDOUT: !entry:
  194. // CHECK:STDOUT: %true_.ref.loc9: %True = name_ref true_, %true_
  195. // CHECK:STDOUT: %Less.ref.loc9: %Less.type = name_ref Less, file.%Less.decl [template = constants.%Less]
  196. // CHECK:STDOUT: %int_1.loc9: Core.IntLiteral = int_value 1 [template = constants.%int_1.1]
  197. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2.1]
  198. // CHECK:STDOUT: %impl.elem0.loc9_21: %Convert.type.2 = interface_witness_access constants.%interface.5, element0 [template = constants.%Convert.10]
  199. // CHECK:STDOUT: %Convert.bound.loc9_21: <bound method> = bound_method %int_1.loc9, %impl.elem0.loc9_21 [template = constants.%Convert.bound.1]
  200. // CHECK:STDOUT: %Convert.specific_fn.loc9_21: <specific function> = specific_function %Convert.bound.loc9_21, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.1]
  201. // CHECK:STDOUT: %int.convert_checked.loc9_21: init %i32 = call %Convert.specific_fn.loc9_21(%int_1.loc9) [template = constants.%int_1.2]
  202. // CHECK:STDOUT: %.loc9_21.1: %i32 = value_of_initializer %int.convert_checked.loc9_21 [template = constants.%int_1.2]
  203. // CHECK:STDOUT: %.loc9_21.2: %i32 = converted %int_1.loc9, %.loc9_21.1 [template = constants.%int_1.2]
  204. // CHECK:STDOUT: %impl.elem0.loc9_24: %Convert.type.2 = interface_witness_access constants.%interface.5, element0 [template = constants.%Convert.10]
  205. // CHECK:STDOUT: %Convert.bound.loc9_24: <bound method> = bound_method %int_2, %impl.elem0.loc9_24 [template = constants.%Convert.bound.2]
  206. // CHECK:STDOUT: %Convert.specific_fn.loc9_24: <specific function> = specific_function %Convert.bound.loc9_24, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.2]
  207. // CHECK:STDOUT: %int.convert_checked.loc9_24: init %i32 = call %Convert.specific_fn.loc9_24(%int_2) [template = constants.%int_2.2]
  208. // CHECK:STDOUT: %.loc9_24.1: %i32 = value_of_initializer %int.convert_checked.loc9_24 [template = constants.%int_2.2]
  209. // CHECK:STDOUT: %.loc9_24.2: %i32 = converted %int_2, %.loc9_24.1 [template = constants.%int_2.2]
  210. // CHECK:STDOUT: %int.less.loc9: init bool = call %Less.ref.loc9(%.loc9_21.2, %.loc9_24.2) [template = constants.%true]
  211. // CHECK:STDOUT: %.loc9_13.1: bool = value_of_initializer %int.less.loc9 [template = constants.%true]
  212. // CHECK:STDOUT: %.loc9_13.2: bool = converted %int.less.loc9, %.loc9_13.1 [template = constants.%true]
  213. // CHECK:STDOUT: if %.loc9_13.2 br !if.expr.then.loc9 else br !if.expr.else.loc9
  214. // CHECK:STDOUT:
  215. // CHECK:STDOUT: !if.expr.then.loc9:
  216. // CHECK:STDOUT: %True.ref.loc9: type = name_ref True, file.%True.decl [template = constants.%True]
  217. // CHECK:STDOUT: br !if.expr.result.loc9(%True.ref.loc9)
  218. // CHECK:STDOUT:
  219. // CHECK:STDOUT: !if.expr.else.loc9:
  220. // CHECK:STDOUT: %False.ref.loc9: type = name_ref False, file.%False.decl [template = constants.%False]
  221. // CHECK:STDOUT: br !if.expr.result.loc9(%False.ref.loc9)
  222. // CHECK:STDOUT:
  223. // CHECK:STDOUT: !if.expr.result.loc9:
  224. // CHECK:STDOUT: %.loc9_13.3: type = block_arg !if.expr.result.loc9 [template = constants.%True]
  225. // CHECK:STDOUT: %false_.ref.loc10: %False = name_ref false_, %false_
  226. // CHECK:STDOUT: %Less.ref.loc10: %Less.type = name_ref Less, file.%Less.decl [template = constants.%Less]
  227. // CHECK:STDOUT: %int_1.loc10_22: Core.IntLiteral = int_value 1 [template = constants.%int_1.1]
  228. // CHECK:STDOUT: %int_1.loc10_25: Core.IntLiteral = int_value 1 [template = constants.%int_1.1]
  229. // CHECK:STDOUT: %impl.elem0.loc10_22: %Convert.type.2 = interface_witness_access constants.%interface.5, element0 [template = constants.%Convert.10]
  230. // CHECK:STDOUT: %Convert.bound.loc10_22: <bound method> = bound_method %int_1.loc10_22, %impl.elem0.loc10_22 [template = constants.%Convert.bound.1]
  231. // CHECK:STDOUT: %Convert.specific_fn.loc10_22: <specific function> = specific_function %Convert.bound.loc10_22, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.1]
  232. // CHECK:STDOUT: %int.convert_checked.loc10_22: init %i32 = call %Convert.specific_fn.loc10_22(%int_1.loc10_22) [template = constants.%int_1.2]
  233. // CHECK:STDOUT: %.loc10_22.1: %i32 = value_of_initializer %int.convert_checked.loc10_22 [template = constants.%int_1.2]
  234. // CHECK:STDOUT: %.loc10_22.2: %i32 = converted %int_1.loc10_22, %.loc10_22.1 [template = constants.%int_1.2]
  235. // CHECK:STDOUT: %impl.elem0.loc10_25: %Convert.type.2 = interface_witness_access constants.%interface.5, element0 [template = constants.%Convert.10]
  236. // CHECK:STDOUT: %Convert.bound.loc10_25: <bound method> = bound_method %int_1.loc10_25, %impl.elem0.loc10_25 [template = constants.%Convert.bound.1]
  237. // CHECK:STDOUT: %Convert.specific_fn.loc10_25: <specific function> = specific_function %Convert.bound.loc10_25, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.1]
  238. // CHECK:STDOUT: %int.convert_checked.loc10_25: init %i32 = call %Convert.specific_fn.loc10_25(%int_1.loc10_25) [template = constants.%int_1.2]
  239. // CHECK:STDOUT: %.loc10_25.1: %i32 = value_of_initializer %int.convert_checked.loc10_25 [template = constants.%int_1.2]
  240. // CHECK:STDOUT: %.loc10_25.2: %i32 = converted %int_1.loc10_25, %.loc10_25.1 [template = constants.%int_1.2]
  241. // CHECK:STDOUT: %int.less.loc10: init bool = call %Less.ref.loc10(%.loc10_22.2, %.loc10_25.2) [template = constants.%false]
  242. // CHECK:STDOUT: %.loc10_14.1: bool = value_of_initializer %int.less.loc10 [template = constants.%false]
  243. // CHECK:STDOUT: %.loc10_14.2: bool = converted %int.less.loc10, %.loc10_14.1 [template = constants.%false]
  244. // CHECK:STDOUT: if %.loc10_14.2 br !if.expr.then.loc10 else br !if.expr.else.loc10
  245. // CHECK:STDOUT:
  246. // CHECK:STDOUT: !if.expr.then.loc10:
  247. // CHECK:STDOUT: %True.ref.loc10: type = name_ref True, file.%True.decl [template = constants.%True]
  248. // CHECK:STDOUT: br !if.expr.result.loc10(%True.ref.loc10)
  249. // CHECK:STDOUT:
  250. // CHECK:STDOUT: !if.expr.else.loc10:
  251. // CHECK:STDOUT: %False.ref.loc10: type = name_ref False, file.%False.decl [template = constants.%False]
  252. // CHECK:STDOUT: br !if.expr.result.loc10(%False.ref.loc10)
  253. // CHECK:STDOUT:
  254. // CHECK:STDOUT: !if.expr.result.loc10:
  255. // CHECK:STDOUT: %.loc10_14.3: type = block_arg !if.expr.result.loc10 [template = constants.%False]
  256. // CHECK:STDOUT: %false_.ref.loc11: %False = name_ref false_, %false_
  257. // CHECK:STDOUT: %Less.ref.loc11: %Less.type = name_ref Less, file.%Less.decl [template = constants.%Less]
  258. // CHECK:STDOUT: %int_1.loc11: Core.IntLiteral = int_value 1 [template = constants.%int_1.1]
  259. // CHECK:STDOUT: %int_0.loc11: Core.IntLiteral = int_value 0 [template = constants.%int_0.1]
  260. // CHECK:STDOUT: %impl.elem0.loc11_22: %Convert.type.2 = interface_witness_access constants.%interface.5, element0 [template = constants.%Convert.10]
  261. // CHECK:STDOUT: %Convert.bound.loc11_22: <bound method> = bound_method %int_1.loc11, %impl.elem0.loc11_22 [template = constants.%Convert.bound.1]
  262. // CHECK:STDOUT: %Convert.specific_fn.loc11_22: <specific function> = specific_function %Convert.bound.loc11_22, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.1]
  263. // CHECK:STDOUT: %int.convert_checked.loc11_22: init %i32 = call %Convert.specific_fn.loc11_22(%int_1.loc11) [template = constants.%int_1.2]
  264. // CHECK:STDOUT: %.loc11_22.1: %i32 = value_of_initializer %int.convert_checked.loc11_22 [template = constants.%int_1.2]
  265. // CHECK:STDOUT: %.loc11_22.2: %i32 = converted %int_1.loc11, %.loc11_22.1 [template = constants.%int_1.2]
  266. // CHECK:STDOUT: %impl.elem0.loc11_25: %Convert.type.2 = interface_witness_access constants.%interface.5, element0 [template = constants.%Convert.10]
  267. // CHECK:STDOUT: %Convert.bound.loc11_25: <bound method> = bound_method %int_0.loc11, %impl.elem0.loc11_25 [template = constants.%Convert.bound.3]
  268. // CHECK:STDOUT: %Convert.specific_fn.loc11_25: <specific function> = specific_function %Convert.bound.loc11_25, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.3]
  269. // CHECK:STDOUT: %int.convert_checked.loc11_25: init %i32 = call %Convert.specific_fn.loc11_25(%int_0.loc11) [template = constants.%int_0.2]
  270. // CHECK:STDOUT: %.loc11_25.1: %i32 = value_of_initializer %int.convert_checked.loc11_25 [template = constants.%int_0.2]
  271. // CHECK:STDOUT: %.loc11_25.2: %i32 = converted %int_0.loc11, %.loc11_25.1 [template = constants.%int_0.2]
  272. // CHECK:STDOUT: %int.less.loc11: init bool = call %Less.ref.loc11(%.loc11_22.2, %.loc11_25.2) [template = constants.%false]
  273. // CHECK:STDOUT: %.loc11_14.1: bool = value_of_initializer %int.less.loc11 [template = constants.%false]
  274. // CHECK:STDOUT: %.loc11_14.2: bool = converted %int.less.loc11, %.loc11_14.1 [template = constants.%false]
  275. // CHECK:STDOUT: if %.loc11_14.2 br !if.expr.then.loc11 else br !if.expr.else.loc11
  276. // CHECK:STDOUT:
  277. // CHECK:STDOUT: !if.expr.then.loc11:
  278. // CHECK:STDOUT: %True.ref.loc11: type = name_ref True, file.%True.decl [template = constants.%True]
  279. // CHECK:STDOUT: br !if.expr.result.loc11(%True.ref.loc11)
  280. // CHECK:STDOUT:
  281. // CHECK:STDOUT: !if.expr.else.loc11:
  282. // CHECK:STDOUT: %False.ref.loc11: type = name_ref False, file.%False.decl [template = constants.%False]
  283. // CHECK:STDOUT: br !if.expr.result.loc11(%False.ref.loc11)
  284. // CHECK:STDOUT:
  285. // CHECK:STDOUT: !if.expr.result.loc11:
  286. // CHECK:STDOUT: %.loc11_14.3: type = block_arg !if.expr.result.loc11 [template = constants.%False]
  287. // CHECK:STDOUT: %true_.ref.loc12: %True = name_ref true_, %true_
  288. // CHECK:STDOUT: %Less.ref.loc12: %Less.type = name_ref Less, file.%Less.decl [template = constants.%Less]
  289. // CHECK:STDOUT: %Negate.ref.loc12: %Negate.type.1 = name_ref Negate, file.%Negate.decl [template = constants.%Negate]
  290. // CHECK:STDOUT: %int_1.loc12: Core.IntLiteral = int_value 1 [template = constants.%int_1.1]
  291. // CHECK:STDOUT: %impl.elem0.loc12_28: %Convert.type.2 = interface_witness_access constants.%interface.5, element0 [template = constants.%Convert.10]
  292. // CHECK:STDOUT: %Convert.bound.loc12_28: <bound method> = bound_method %int_1.loc12, %impl.elem0.loc12_28 [template = constants.%Convert.bound.1]
  293. // CHECK:STDOUT: %Convert.specific_fn.loc12_28: <specific function> = specific_function %Convert.bound.loc12_28, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.1]
  294. // CHECK:STDOUT: %int.convert_checked.loc12_28: init %i32 = call %Convert.specific_fn.loc12_28(%int_1.loc12) [template = constants.%int_1.2]
  295. // CHECK:STDOUT: %.loc12_28.1: %i32 = value_of_initializer %int.convert_checked.loc12_28 [template = constants.%int_1.2]
  296. // CHECK:STDOUT: %.loc12_28.2: %i32 = converted %int_1.loc12, %.loc12_28.1 [template = constants.%int_1.2]
  297. // CHECK:STDOUT: %int.snegate.loc12: init %i32 = call %Negate.ref.loc12(%.loc12_28.2) [template = constants.%int_-1]
  298. // CHECK:STDOUT: %int_0.loc12: Core.IntLiteral = int_value 0 [template = constants.%int_0.1]
  299. // CHECK:STDOUT: %.loc12_29.1: %i32 = value_of_initializer %int.snegate.loc12 [template = constants.%int_-1]
  300. // CHECK:STDOUT: %.loc12_29.2: %i32 = converted %int.snegate.loc12, %.loc12_29.1 [template = constants.%int_-1]
  301. // CHECK:STDOUT: %impl.elem0.loc12_32: %Convert.type.2 = interface_witness_access constants.%interface.5, element0 [template = constants.%Convert.10]
  302. // CHECK:STDOUT: %Convert.bound.loc12_32: <bound method> = bound_method %int_0.loc12, %impl.elem0.loc12_32 [template = constants.%Convert.bound.3]
  303. // CHECK:STDOUT: %Convert.specific_fn.loc12_32: <specific function> = specific_function %Convert.bound.loc12_32, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.3]
  304. // CHECK:STDOUT: %int.convert_checked.loc12_32: init %i32 = call %Convert.specific_fn.loc12_32(%int_0.loc12) [template = constants.%int_0.2]
  305. // CHECK:STDOUT: %.loc12_32.1: %i32 = value_of_initializer %int.convert_checked.loc12_32 [template = constants.%int_0.2]
  306. // CHECK:STDOUT: %.loc12_32.2: %i32 = converted %int_0.loc12, %.loc12_32.1 [template = constants.%int_0.2]
  307. // CHECK:STDOUT: %int.less.loc12: init bool = call %Less.ref.loc12(%.loc12_29.2, %.loc12_32.2) [template = constants.%true]
  308. // CHECK:STDOUT: %.loc12_13.1: bool = value_of_initializer %int.less.loc12 [template = constants.%true]
  309. // CHECK:STDOUT: %.loc12_13.2: bool = converted %int.less.loc12, %.loc12_13.1 [template = constants.%true]
  310. // CHECK:STDOUT: if %.loc12_13.2 br !if.expr.then.loc12 else br !if.expr.else.loc12
  311. // CHECK:STDOUT:
  312. // CHECK:STDOUT: !if.expr.then.loc12:
  313. // CHECK:STDOUT: %True.ref.loc12: type = name_ref True, file.%True.decl [template = constants.%True]
  314. // CHECK:STDOUT: br !if.expr.result.loc12(%True.ref.loc12)
  315. // CHECK:STDOUT:
  316. // CHECK:STDOUT: !if.expr.else.loc12:
  317. // CHECK:STDOUT: %False.ref.loc12: type = name_ref False, file.%False.decl [template = constants.%False]
  318. // CHECK:STDOUT: br !if.expr.result.loc12(%False.ref.loc12)
  319. // CHECK:STDOUT:
  320. // CHECK:STDOUT: !if.expr.result.loc12:
  321. // CHECK:STDOUT: %.loc12_13.3: type = block_arg !if.expr.result.loc12 [template = constants.%True]
  322. // CHECK:STDOUT: %false_.ref.loc13: %False = name_ref false_, %false_
  323. // CHECK:STDOUT: %Less.ref.loc13: %Less.type = name_ref Less, file.%Less.decl [template = constants.%Less]
  324. // CHECK:STDOUT: %int_0.loc13: Core.IntLiteral = int_value 0 [template = constants.%int_0.1]
  325. // CHECK:STDOUT: %Negate.ref.loc13: %Negate.type.1 = name_ref Negate, file.%Negate.decl [template = constants.%Negate]
  326. // CHECK:STDOUT: %int_1.loc13: Core.IntLiteral = int_value 1 [template = constants.%int_1.1]
  327. // CHECK:STDOUT: %impl.elem0.loc13_32: %Convert.type.2 = interface_witness_access constants.%interface.5, element0 [template = constants.%Convert.10]
  328. // CHECK:STDOUT: %Convert.bound.loc13_32: <bound method> = bound_method %int_1.loc13, %impl.elem0.loc13_32 [template = constants.%Convert.bound.1]
  329. // CHECK:STDOUT: %Convert.specific_fn.loc13_32: <specific function> = specific_function %Convert.bound.loc13_32, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.1]
  330. // CHECK:STDOUT: %int.convert_checked.loc13_32: init %i32 = call %Convert.specific_fn.loc13_32(%int_1.loc13) [template = constants.%int_1.2]
  331. // CHECK:STDOUT: %.loc13_32.1: %i32 = value_of_initializer %int.convert_checked.loc13_32 [template = constants.%int_1.2]
  332. // CHECK:STDOUT: %.loc13_32.2: %i32 = converted %int_1.loc13, %.loc13_32.1 [template = constants.%int_1.2]
  333. // CHECK:STDOUT: %int.snegate.loc13: init %i32 = call %Negate.ref.loc13(%.loc13_32.2) [template = constants.%int_-1]
  334. // CHECK:STDOUT: %impl.elem0.loc13_22: %Convert.type.2 = interface_witness_access constants.%interface.5, element0 [template = constants.%Convert.10]
  335. // CHECK:STDOUT: %Convert.bound.loc13_22: <bound method> = bound_method %int_0.loc13, %impl.elem0.loc13_22 [template = constants.%Convert.bound.3]
  336. // CHECK:STDOUT: %Convert.specific_fn.loc13_22: <specific function> = specific_function %Convert.bound.loc13_22, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.3]
  337. // CHECK:STDOUT: %int.convert_checked.loc13_22: init %i32 = call %Convert.specific_fn.loc13_22(%int_0.loc13) [template = constants.%int_0.2]
  338. // CHECK:STDOUT: %.loc13_22.1: %i32 = value_of_initializer %int.convert_checked.loc13_22 [template = constants.%int_0.2]
  339. // CHECK:STDOUT: %.loc13_22.2: %i32 = converted %int_0.loc13, %.loc13_22.1 [template = constants.%int_0.2]
  340. // CHECK:STDOUT: %.loc13_33.1: %i32 = value_of_initializer %int.snegate.loc13 [template = constants.%int_-1]
  341. // CHECK:STDOUT: %.loc13_33.2: %i32 = converted %int.snegate.loc13, %.loc13_33.1 [template = constants.%int_-1]
  342. // CHECK:STDOUT: %int.less.loc13: init bool = call %Less.ref.loc13(%.loc13_22.2, %.loc13_33.2) [template = constants.%false]
  343. // CHECK:STDOUT: %.loc13_14.1: bool = value_of_initializer %int.less.loc13 [template = constants.%false]
  344. // CHECK:STDOUT: %.loc13_14.2: bool = converted %int.less.loc13, %.loc13_14.1 [template = constants.%false]
  345. // CHECK:STDOUT: if %.loc13_14.2 br !if.expr.then.loc13 else br !if.expr.else.loc13
  346. // CHECK:STDOUT:
  347. // CHECK:STDOUT: !if.expr.then.loc13:
  348. // CHECK:STDOUT: %True.ref.loc13: type = name_ref True, file.%True.decl [template = constants.%True]
  349. // CHECK:STDOUT: br !if.expr.result.loc13(%True.ref.loc13)
  350. // CHECK:STDOUT:
  351. // CHECK:STDOUT: !if.expr.else.loc13:
  352. // CHECK:STDOUT: %False.ref.loc13: type = name_ref False, file.%False.decl [template = constants.%False]
  353. // CHECK:STDOUT: br !if.expr.result.loc13(%False.ref.loc13)
  354. // CHECK:STDOUT:
  355. // CHECK:STDOUT: !if.expr.result.loc13:
  356. // CHECK:STDOUT: %.loc13_14.3: type = block_arg !if.expr.result.loc13 [template = constants.%False]
  357. // CHECK:STDOUT: return
  358. // CHECK:STDOUT: }
  359. // CHECK:STDOUT:
  360. // CHECK:STDOUT: fn @RuntimeCall(%a.param_patt: %i32, %b.param_patt: %i32) -> bool {
  361. // CHECK:STDOUT: !entry:
  362. // CHECK:STDOUT: %Less.ref: %Less.type = name_ref Less, file.%Less.decl [template = constants.%Less]
  363. // CHECK:STDOUT: %a.ref: %i32 = name_ref a, %a
  364. // CHECK:STDOUT: %b.ref: %i32 = name_ref b, %b
  365. // CHECK:STDOUT: %int.less: init bool = call %Less.ref(%a.ref, %b.ref)
  366. // CHECK:STDOUT: %.loc17_20.1: bool = value_of_initializer %int.less
  367. // CHECK:STDOUT: %.loc17_20.2: bool = converted %int.less, %.loc17_20.1
  368. // CHECK:STDOUT: return %.loc17_20.2
  369. // CHECK:STDOUT: }
  370. // CHECK:STDOUT: