| ... | @@ -3403,7 +3403,7 @@ fn airUnwrapErrUnionError(self: *Self, inst: Air.Inst.Index, op_is_ptr: bool) In | ... | @@ -3403,7 +3403,7 @@ fn airUnwrapErrUnionError(self: *Self, inst: Air.Inst.Index, op_is_ptr: bool) In |
| 3403 | } | 3403 | } |
| 3404 | | 3404 | |
| 3405 | if (op_is_ptr or !payload_ty.hasRuntimeBitsIgnoreComptime()) { | 3405 | if (op_is_ptr or !payload_ty.hasRuntimeBitsIgnoreComptime()) { |
| 3406 | break :result operand; | 3406 | break :result self.reuseOperand(ty_op.operand, operand); |
| 3407 | } | 3407 | } |
| 3408 | | 3408 | |
| 3409 | const error_val = try self.load(operand, Type.anyerror, @intCast(u32, errUnionErrorOffset(payload_ty, self.target))); | 3409 | const error_val = try self.load(operand, Type.anyerror, @intCast(u32, errUnionErrorOffset(payload_ty, self.target))); |
| ... | @@ -3422,7 +3422,7 @@ fn airWrapErrUnionPayload(self: *Self, inst: Air.Inst.Index) InnerError!void { | ... | @@ -3422,7 +3422,7 @@ fn airWrapErrUnionPayload(self: *Self, inst: Air.Inst.Index) InnerError!void { |
| 3422 | const pl_ty = self.air.typeOf(ty_op.operand); | 3422 | const pl_ty = self.air.typeOf(ty_op.operand); |
| 3423 | const result = result: { | 3423 | const result = result: { |
| 3424 | if (!pl_ty.hasRuntimeBitsIgnoreComptime()) { | 3424 | if (!pl_ty.hasRuntimeBitsIgnoreComptime()) { |
| 3425 | break :result operand; | 3425 | break :result self.reuseOperand(ty_op.operand, operand); |
| 3426 | } | 3426 | } |
| 3427 | | 3427 | |
| 3428 | const err_union = try self.allocStack(err_ty); | 3428 | const err_union = try self.allocStack(err_ty); |
| ... | @@ -3449,7 +3449,7 @@ fn airWrapErrUnionErr(self: *Self, inst: Air.Inst.Index) InnerError!void { | ... | @@ -3449,7 +3449,7 @@ fn airWrapErrUnionErr(self: *Self, inst: Air.Inst.Index) InnerError!void { |
| 3449 | | 3449 | |
| 3450 | const result = result: { | 3450 | const result = result: { |
| 3451 | if (!pl_ty.hasRuntimeBitsIgnoreComptime()) { | 3451 | if (!pl_ty.hasRuntimeBitsIgnoreComptime()) { |
| 3452 | break :result operand; | 3452 | break :result self.reuseOperand(ty_op.operand, operand); |
| 3453 | } | 3453 | } |
| 3454 | | 3454 | |
| 3455 | const err_union = try self.allocStack(err_ty); | 3455 | const err_union = try self.allocStack(err_ty); |
| ... | @@ -3481,7 +3481,7 @@ fn airIntcast(self: *Self, inst: Air.Inst.Index) InnerError!void { | ... | @@ -3481,7 +3481,7 @@ fn airIntcast(self: *Self, inst: Air.Inst.Index) InnerError!void { |
| 3481 | } | 3481 | } |
| 3482 | | 3482 | |
| 3483 | const result = try (try self.intcast(operand, operand_ty, ty)).toLocal(self, ty); | 3483 | const result = try (try self.intcast(operand, operand_ty, ty)).toLocal(self, ty); |
| 3484 | self.finishAir(inst, result, &.{ty_op.operand}); | 3484 | self.finishAir(inst, result, &.{}); |
| 3485 | } | 3485 | } |
| 3486 | | 3486 | |
| 3487 | /// Upcasts or downcasts an integer based on the given and wanted types, | 3487 | /// Upcasts or downcasts an integer based on the given and wanted types, |
| ... | @@ -3579,7 +3579,7 @@ fn airOptionalPayload(self: *Self, inst: Air.Inst.Index) InnerError!void { | ... | @@ -3579,7 +3579,7 @@ fn airOptionalPayload(self: *Self, inst: Air.Inst.Index) InnerError!void { |
| 3579 | | 3579 | |
| 3580 | const result = result: { | 3580 | const result = result: { |
| 3581 | const operand = try self.resolveInst(ty_op.operand); | 3581 | const operand = try self.resolveInst(ty_op.operand); |
| 3582 | if (opt_ty.optionalReprIsPayload()) break :result operand; | 3582 | if (opt_ty.optionalReprIsPayload()) break :result self.reuseOperand(ty_op.operand, operand); |
| 3583 | | 3583 | |
| 3584 | const offset = opt_ty.abiSize(self.target) - payload_ty.abiSize(self.target); | 3584 | const offset = opt_ty.abiSize(self.target) - payload_ty.abiSize(self.target); |
| 3585 | | 3585 | |
| ... | @@ -3603,7 +3603,7 @@ fn airOptionalPayloadPtr(self: *Self, inst: Air.Inst.Index) InnerError!void { | ... | @@ -3603,7 +3603,7 @@ fn airOptionalPayloadPtr(self: *Self, inst: Air.Inst.Index) InnerError!void { |
| 3603 | var buf: Type.Payload.ElemType = undefined; | 3603 | var buf: Type.Payload.ElemType = undefined; |
| 3604 | const payload_ty = opt_ty.optionalChild(&buf); | 3604 | const payload_ty = opt_ty.optionalChild(&buf); |
| 3605 | if (!payload_ty.hasRuntimeBitsIgnoreComptime() or opt_ty.optionalReprIsPayload()) { | 3605 | if (!payload_ty.hasRuntimeBitsIgnoreComptime() or opt_ty.optionalReprIsPayload()) { |
| 3606 | break :result operand; | 3606 | break :result self.reuseOperand(ty_op.operand, operand); |
| 3607 | } | 3607 | } |
| 3608 | | 3608 | |
| 3609 | const offset = opt_ty.abiSize(self.target) - payload_ty.abiSize(self.target); | 3609 | const offset = opt_ty.abiSize(self.target) - payload_ty.abiSize(self.target); |
| ... | @@ -3656,7 +3656,7 @@ fn airWrapOptional(self: *Self, inst: Air.Inst.Index) InnerError!void { | ... | @@ -3656,7 +3656,7 @@ fn airWrapOptional(self: *Self, inst: Air.Inst.Index) InnerError!void { |
| 3656 | const operand = try self.resolveInst(ty_op.operand); | 3656 | const operand = try self.resolveInst(ty_op.operand); |
| 3657 | const op_ty = self.air.typeOfIndex(inst); | 3657 | const op_ty = self.air.typeOfIndex(inst); |
| 3658 | if (op_ty.optionalReprIsPayload()) { | 3658 | if (op_ty.optionalReprIsPayload()) { |
| 3659 | break :result operand; | 3659 | break :result self.reuseOperand(ty_op.operand, operand); |
| 3660 | } | 3660 | } |
| 3661 | const offset = std.math.cast(u32, op_ty.abiSize(self.target) - payload_ty.abiSize(self.target)) orelse { | 3661 | const offset = std.math.cast(u32, op_ty.abiSize(self.target) - payload_ty.abiSize(self.target)) orelse { |
| 3662 | const module = self.bin_file.base.options.module.?; | 3662 | const module = self.bin_file.base.options.module.?; |
| ... | @@ -3793,8 +3793,10 @@ fn airBoolToInt(self: *Self, inst: Air.Inst.Index) InnerError!void { | ... | @@ -3793,8 +3793,10 @@ fn airBoolToInt(self: *Self, inst: Air.Inst.Index) InnerError!void { |
| 3793 | const un_op = self.air.instructions.items(.data)[inst].un_op; | 3793 | const un_op = self.air.instructions.items(.data)[inst].un_op; |
| 3794 | const result = if (self.liveness.isUnused(inst)) | 3794 | const result = if (self.liveness.isUnused(inst)) |
| 3795 | WValue{ .none = {} } | 3795 | WValue{ .none = {} } |
| 3796 | else | 3796 | else result: { |
| 3797 | try self.resolveInst(un_op); | 3797 | const operand = try self.resolveInst(un_op); |
| | 3798 | break :result self.reuseOperand(un_op, operand); |
| | 3799 | }; |
| 3798 | | 3800 | |
| 3799 | self.finishAir(inst, result, &.{un_op}); | 3801 | self.finishAir(inst, result, &.{un_op}); |
| 3800 | } | 3802 | } |
| ... | @@ -3939,7 +3941,7 @@ fn airMemset(self: *Self, inst: Air.Inst.Index) InnerError!void { | ... | @@ -3939,7 +3941,7 @@ fn airMemset(self: *Self, inst: Air.Inst.Index) InnerError!void { |
| 3939 | const len = try self.resolveInst(bin_op.rhs); | 3941 | const len = try self.resolveInst(bin_op.rhs); |
| 3940 | try self.memset(ptr, len, value); | 3942 | try self.memset(ptr, len, value); |
| 3941 | | 3943 | |
| 3942 | self.finishAir(inst, .none, &.{ bin_op.lhs, bin_op.rhs }); | 3944 | self.finishAir(inst, .none, &.{pl_op.operand}); |
| 3943 | } | 3945 | } |
| 3944 | | 3946 | |
| 3945 | /// Sets a region of memory at `ptr` to the value of `value` | 3947 | /// Sets a region of memory at `ptr` to the value of `value` |
| ... | @@ -4489,7 +4491,7 @@ fn airErrUnionPayloadPtrSet(self: *Self, inst: Air.Inst.Index) InnerError!void { | ... | @@ -4489,7 +4491,7 @@ fn airErrUnionPayloadPtrSet(self: *Self, inst: Air.Inst.Index) InnerError!void { |
| 4489 | if (self.liveness.isUnused(inst)) break :result WValue{ .none = {} }; | 4491 | if (self.liveness.isUnused(inst)) break :result WValue{ .none = {} }; |
| 4490 | | 4492 | |
| 4491 | if (!payload_ty.hasRuntimeBitsIgnoreComptime()) { | 4493 | if (!payload_ty.hasRuntimeBitsIgnoreComptime()) { |
| 4492 | break :result operand; | 4494 | break :result self.reuseOperand(ty_op.operand, operand); |
| 4493 | } | 4495 | } |
| 4494 | | 4496 | |
| 4495 | break :result try self.buildPointerOffset(operand, @intCast(u32, errUnionPayloadOffset(payload_ty, self.target)), .new); | 4497 | break :result try self.buildPointerOffset(operand, @intCast(u32, errUnionPayloadOffset(payload_ty, self.target)), .new); |
| ... | @@ -4513,7 +4515,7 @@ fn airFieldParentPtr(self: *Self, inst: Air.Inst.Index) InnerError!void { | ... | @@ -4513,7 +4515,7 @@ fn airFieldParentPtr(self: *Self, inst: Air.Inst.Index) InnerError!void { |
| 4513 | try self.addTag(.i32_sub); | 4515 | try self.addTag(.i32_sub); |
| 4514 | try self.addLabel(.local_set, base.local.value); | 4516 | try self.addLabel(.local_set, base.local.value); |
| 4515 | break :result base; | 4517 | break :result base; |
| 4516 | } else field_ptr; | 4518 | } else self.reuseOperand(extra.field_ptr, field_ptr); |
| 4517 | | 4519 | |
| 4518 | self.finishAir(inst, result, &.{extra.field_ptr}); | 4520 | self.finishAir(inst, result, &.{extra.field_ptr}); |
| 4519 | } | 4521 | } |
| ... | @@ -4526,7 +4528,7 @@ fn airMemcpy(self: *Self, inst: Air.Inst.Index) InnerError!void { | ... | @@ -4526,7 +4528,7 @@ fn airMemcpy(self: *Self, inst: Air.Inst.Index) InnerError!void { |
| 4526 | const len = try self.resolveInst(bin_op.rhs); | 4528 | const len = try self.resolveInst(bin_op.rhs); |
| 4527 | try self.memcpy(dst, src, len); | 4529 | try self.memcpy(dst, src, len); |
| 4528 | | 4530 | |
| 4529 | self.finishAir(inst, .none, &.{ pl_op.operand, bin_op.lhs, bin_op.rhs }); | 4531 | self.finishAir(inst, .none, &.{pl_op.operand}); |
| 4530 | } | 4532 | } |
| 4531 | | 4533 | |
| 4532 | fn airPopcount(self: *Self, inst: Air.Inst.Index) InnerError!void { | 4534 | fn airPopcount(self: *Self, inst: Air.Inst.Index) InnerError!void { |
| ... | @@ -5220,7 +5222,7 @@ fn airByteSwap(self: *Self, inst: Air.Inst.Index) InnerError!void { | ... | @@ -5220,7 +5222,7 @@ fn airByteSwap(self: *Self, inst: Air.Inst.Index) InnerError!void { |
| 5220 | | 5222 | |
| 5221 | // bytes are no-op | 5223 | // bytes are no-op |
| 5222 | if (int_info.bits == 8) { | 5224 | if (int_info.bits == 8) { |
| 5223 | return self.finishAir(inst, operand, &.{ty_op.operand}); | 5225 | return self.finishAir(inst, self.reuseOperand(ty_op.operand, operand), &.{ty_op.operand}); |
| 5224 | } | 5226 | } |
| 5225 | | 5227 | |
| 5226 | const result = result: { | 5228 | const result = result: { |