| ... | @@ -8898,16 +8898,10 @@ fn analyzeErrUnionCode(sema: *Sema, block: *Block, src: LazySrcLoc, operand: Air | ... | @@ -8898,16 +8898,10 @@ fn analyzeErrUnionCode(sema: *Sema, block: *Block, src: LazySrcLoc, operand: Air |
| 8898 | const result_ty = operand_ty.errorUnionSet(mod); | 8898 | const result_ty = operand_ty.errorUnionSet(mod); |
| 8899 | | 8899 | |
| 8900 | if (try sema.resolveDefinedValue(block, src, operand)) |val| { | 8900 | if (try sema.resolveDefinedValue(block, src, operand)) |val| { |
| 8901 | switch (mod.intern_pool.indexToKey(val.toIntern()).error_union.val) { | 8901 | return Air.internedToRef((try mod.intern(.{ .err = .{ |
| 8902 | .err_name => |err_name| return Air.internedToRef((try mod.intern(.{ .err = .{ | 8902 | .ty = result_ty.toIntern(), |
| 8903 | .ty = result_ty.toIntern(), | 8903 | .name = mod.intern_pool.indexToKey(val.toIntern()).error_union.val.err_name, |
| 8904 | .name = err_name, | 8904 | } }))); |
| 8905 | } }))), | | |
| 8906 | .payload => |payload| { | | |
| 8907 | assert(payload.toValue().isUndef(mod)); | | |
| 8908 | return mod.undefRef(result_ty); | | |
| 8909 | }, | | |
| 8910 | } | | |
| 8911 | } | 8905 | } |
| 8912 | | 8906 | |
| 8913 | try sema.requireRuntimeBlock(block, src, null); | 8907 | try sema.requireRuntimeBlock(block, src, null); |
| ... | @@ -16419,7 +16413,6 @@ fn zirCmp( | ... | @@ -16419,7 +16413,6 @@ fn zirCmp( |
| 16419 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; | 16413 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; |
| 16420 | const lhs = try sema.resolveInst(extra.lhs); | 16414 | const lhs = try sema.resolveInst(extra.lhs); |
| 16421 | const rhs = try sema.resolveInst(extra.rhs); | 16415 | const rhs = try sema.resolveInst(extra.rhs); |
| 16422 | | | |
| 16423 | return sema.analyzeCmp(block, src, lhs, rhs, op, lhs_src, rhs_src, false); | 16416 | return sema.analyzeCmp(block, src, lhs, rhs, op, lhs_src, rhs_src, false); |
| 16424 | } | 16417 | } |
| 16425 | | 16418 | |
| ... | @@ -16451,16 +16444,10 @@ fn analyzeCmp( | ... | @@ -16451,16 +16444,10 @@ fn analyzeCmp( |
| 16451 | return sema.cmpNumeric(block, src, lhs, rhs, op, lhs_src, rhs_src); | 16444 | return sema.cmpNumeric(block, src, lhs, rhs, op, lhs_src, rhs_src); |
| 16452 | } | 16445 | } |
| 16453 | if (is_equality_cmp and lhs_ty.zigTypeTag(mod) == .ErrorUnion and rhs_ty.zigTypeTag(mod) == .ErrorSet) { | 16446 | if (is_equality_cmp and lhs_ty.zigTypeTag(mod) == .ErrorUnion and rhs_ty.zigTypeTag(mod) == .ErrorSet) { |
| 16454 | if (try sema.resolveValue(lhs)) |lhs_val| { | | |
| 16455 | if (lhs_val.isUndef(mod)) return mod.undefRef(Type.bool); | | |
| 16456 | } | | |
| 16457 | const casted_lhs = try sema.analyzeErrUnionCode(block, lhs_src, lhs); | 16447 | const casted_lhs = try sema.analyzeErrUnionCode(block, lhs_src, lhs); |
| 16458 | return sema.cmpSelf(block, src, casted_lhs, rhs, op, lhs_src, rhs_src); | 16448 | return sema.cmpSelf(block, src, casted_lhs, rhs, op, lhs_src, rhs_src); |
| 16459 | } | 16449 | } |
| 16460 | if (is_equality_cmp and lhs_ty.zigTypeTag(mod) == .ErrorSet and rhs_ty.zigTypeTag(mod) == .ErrorUnion) { | 16450 | if (is_equality_cmp and lhs_ty.zigTypeTag(mod) == .ErrorSet and rhs_ty.zigTypeTag(mod) == .ErrorUnion) { |
| 16461 | if (try sema.resolveValue(rhs)) |rhs_val| { | | |
| 16462 | if (rhs_val.isUndef(mod)) return mod.undefRef(Type.bool); | | |
| 16463 | } | | |
| 16464 | const casted_rhs = try sema.analyzeErrUnionCode(block, rhs_src, rhs); | 16451 | const casted_rhs = try sema.analyzeErrUnionCode(block, rhs_src, rhs); |
| 16465 | return sema.cmpSelf(block, src, lhs, casted_rhs, op, lhs_src, rhs_src); | 16452 | return sema.cmpSelf(block, src, lhs, casted_rhs, op, lhs_src, rhs_src); |
| 16466 | } | 16453 | } |
| ... | @@ -16524,9 +16511,11 @@ fn cmpSelf( | ... | @@ -16524,9 +16511,11 @@ fn cmpSelf( |
| 16524 | } else { | 16511 | } else { |
| 16525 | // For bools, we still check the other operand, because we can lower | 16512 | // For bools, we still check the other operand, because we can lower |
| 16526 | // bool eq/neq more efficiently. | 16513 | // bool eq/neq more efficiently. |
| 16527 | if (try sema.resolveValue(casted_rhs)) |rhs_val| { | 16514 | if (resolved_type.zigTypeTag(mod) == .Bool) { |
| 16528 | if (rhs_val.isUndef(mod)) return mod.undefRef(Type.bool); | 16515 | if (try sema.resolveValue(casted_rhs)) |rhs_val| { |
| 16529 | if (resolved_type.zigTypeTag(mod) == .Bool) return sema.runtimeBoolCmp(block, src, op, casted_lhs, rhs_val.toBool(), lhs_src); | 16516 | if (rhs_val.isUndef(mod)) return mod.undefRef(Type.bool); |
| | 16517 | return sema.runtimeBoolCmp(block, src, op, casted_lhs, rhs_val.toBool(), lhs_src); |
| | 16518 | } |
| 16530 | } | 16519 | } |
| 16531 | break :src lhs_src; | 16520 | break :src lhs_src; |
| 16532 | } | 16521 | } |
| ... | @@ -38011,10 +38000,7 @@ fn compareVector( | ... | @@ -38011,10 +38000,7 @@ fn compareVector( |
| 38011 | const lhs_elem = try lhs.elemValue(sema.mod, i); | 38000 | const lhs_elem = try lhs.elemValue(sema.mod, i); |
| 38012 | const rhs_elem = try rhs.elemValue(sema.mod, i); | 38001 | const rhs_elem = try rhs.elemValue(sema.mod, i); |
| 38013 | const res_bool = try sema.compareScalar(lhs_elem, op, rhs_elem, ty.scalarType(mod)); | 38002 | const res_bool = try sema.compareScalar(lhs_elem, op, rhs_elem, ty.scalarType(mod)); |
| 38014 | scalar.* = if (lhs_elem.isUndef(mod) or rhs_elem.isUndef(mod)) | 38003 | scalar.* = try Value.makeBool(res_bool).intern(Type.bool, mod); |
| 38015 | Air.refToInterned(try mod.undefRef(Type.bool)).? | | |
| 38016 | else | | |
| 38017 | try Value.makeBool(res_bool).intern(Type.bool, mod); | | |
| 38018 | } | 38004 | } |
| 38019 | return (try mod.intern(.{ .aggregate = .{ | 38005 | return (try mod.intern(.{ .aggregate = .{ |
| 38020 | .ty = (try mod.vectorType(.{ .len = ty.vectorLen(mod), .child = .bool_type })).toIntern(), | 38006 | .ty = (try mod.vectorType(.{ .len = ty.vectorLen(mod), .child = .bool_type })).toIntern(), |