x86_64: actually track state during @divFloor of i128

Closes #17998
This commit is contained in:
Jacob Young 2023-11-14 18:10:29 -05:00
parent 6fd1c64f23
commit 0c6cb8d8c8
2 changed files with 9 additions and 4 deletions

View File

@ -1443,9 +1443,6 @@ test "big.int divFloor #11166" {
}
test "big.int gcd #10932" {
// TODO https://github.com/ziglang/zig/issues/17998
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
var a = try Managed.init(testing.allocator);
defer a.deinit();

View File

@ -3235,6 +3235,7 @@ fn airMulDivBinOp(self: *Self, inst: Air.Inst.Index) !void {
var callee_buf: ["__udiv?i3".len]u8 = undefined;
const signed_div_floor_state: struct {
frame_index: FrameIndex,
state: State,
reloc: Mir.Inst.Index,
} = if (signed and tag == .div_floor) state: {
const frame_index = try self.allocFrameIndex(FrameAlloc.initType(Type.usize, mod));
@ -3295,9 +3296,10 @@ fn airMulDivBinOp(self: *Self, inst: Air.Inst.Index) !void {
tmp_reg,
mat_rhs_mcv.register_pair[1],
);
const state = try self.saveState();
const reloc = try self.asmJccReloc(.ns, undefined);
break :state .{ .frame_index = frame_index, .reloc = reloc };
break :state .{ .frame_index = frame_index, .state = state, .reloc = reloc };
} else undefined;
const call_mcv = try self.genCall(
.{ .lib = .{
@ -3328,6 +3330,12 @@ fn airMulDivBinOp(self: *Self, inst: Air.Inst.Index) !void {
.base = .{ .frame = signed_div_floor_state.frame_index },
.mod = .{ .rm = .{ .size = .byte } },
});
try self.restoreState(signed_div_floor_state.state, &.{}, .{
.emit_instructions = true,
.update_tracking = true,
.resurrect = true,
.close_scope = true,
});
try self.performReloc(signed_div_floor_state.reloc);
const dst_mcv = try self.genCall(
.{ .lib = .{