| ... | @@ -21940,10 +21940,18 @@ fn analyzeMinMax( | ... | @@ -21940,10 +21940,18 @@ fn analyzeMinMax( |
| 21940 | } | 21940 | } |
| 21941 | } | 21941 | } |
| 21942 | | 21942 | |
| | 21943 | const opt_runtime_idx = runtime_known.findFirstSet(); |
| | 21944 | |
| 21943 | const comptime_refined_ty: ?Type = if (cur_minmax) |ct_minmax_ref| refined: { | 21945 | const comptime_refined_ty: ?Type = if (cur_minmax) |ct_minmax_ref| refined: { |
| 21944 | // Refine the comptime-known result type based on the operation | 21946 | // Refine the comptime-known result type based on the operation |
| 21945 | const val = (try sema.resolveMaybeUndefVal(ct_minmax_ref)).?; | 21947 | const val = (try sema.resolveMaybeUndefVal(ct_minmax_ref)).?; |
| 21946 | const orig_ty = sema.typeOf(ct_minmax_ref); | 21948 | const orig_ty = sema.typeOf(ct_minmax_ref); |
| | 21949 | |
| | 21950 | if (opt_runtime_idx == null and orig_ty.eql(Type.comptime_int, mod)) { |
| | 21951 | // If all arguments were `comptime_int`, and there are no runtime args, we'll preserve that type |
| | 21952 | break :refined orig_ty; |
| | 21953 | } |
| | 21954 | |
| 21947 | const refined_ty = if (orig_ty.zigTypeTag() == .Vector) blk: { | 21955 | const refined_ty = if (orig_ty.zigTypeTag() == .Vector) blk: { |
| 21948 | const elem_ty = orig_ty.childType(); | 21956 | const elem_ty = orig_ty.childType(); |
| 21949 | const len = orig_ty.vectorLen(); | 21957 | const len = orig_ty.vectorLen(); |
| ... | @@ -21982,7 +21990,7 @@ fn analyzeMinMax( | ... | @@ -21982,7 +21990,7 @@ fn analyzeMinMax( |
| 21982 | break :refined refined_ty; | 21990 | break :refined refined_ty; |
| 21983 | } else null; | 21991 | } else null; |
| 21984 | | 21992 | |
| 21985 | const runtime_idx = runtime_known.findFirstSet() orelse return cur_minmax.?; | 21993 | const runtime_idx = opt_runtime_idx orelse return cur_minmax.?; |
| 21986 | const runtime_src = operand_srcs[runtime_idx]; | 21994 | const runtime_src = operand_srcs[runtime_idx]; |
| 21987 | try sema.requireRuntimeBlock(block, src, runtime_src); | 21995 | try sema.requireRuntimeBlock(block, src, runtime_src); |
| 21988 | | 21996 | |