Skip to content

Commit 0c6cb8d

Browse files
committed
x86_64: actually track state during @divFloor of i128
Closes #17998
1 parent 6fd1c64 commit 0c6cb8d

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

lib/std/math/big/int_test.zig

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,9 +1443,6 @@ test "big.int divFloor #11166" {
14431443
}
14441444

14451445
test "big.int gcd #10932" {
1446-
// TODO https://github.com/ziglang/zig/issues/17998
1447-
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1448-
14491446
var a = try Managed.init(testing.allocator);
14501447
defer a.deinit();
14511448

src/arch/x86_64/CodeGen.zig

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3235,6 +3235,7 @@ fn airMulDivBinOp(self: *Self, inst: Air.Inst.Index) !void {
32353235
var callee_buf: ["__udiv?i3".len]u8 = undefined;
32363236
const signed_div_floor_state: struct {
32373237
frame_index: FrameIndex,
3238+
state: State,
32383239
reloc: Mir.Inst.Index,
32393240
} = if (signed and tag == .div_floor) state: {
32403241
const frame_index = try self.allocFrameIndex(FrameAlloc.initType(Type.usize, mod));
@@ -3295,9 +3296,10 @@ fn airMulDivBinOp(self: *Self, inst: Air.Inst.Index) !void {
32953296
tmp_reg,
32963297
mat_rhs_mcv.register_pair[1],
32973298
);
3299+
const state = try self.saveState();
32983300
const reloc = try self.asmJccReloc(.ns, undefined);
32993301

3300-
break :state .{ .frame_index = frame_index, .reloc = reloc };
3302+
break :state .{ .frame_index = frame_index, .state = state, .reloc = reloc };
33013303
} else undefined;
33023304
const call_mcv = try self.genCall(
33033305
.{ .lib = .{
@@ -3328,6 +3330,12 @@ fn airMulDivBinOp(self: *Self, inst: Air.Inst.Index) !void {
33283330
.base = .{ .frame = signed_div_floor_state.frame_index },
33293331
.mod = .{ .rm = .{ .size = .byte } },
33303332
});
3333+
try self.restoreState(signed_div_floor_state.state, &.{}, .{
3334+
.emit_instructions = true,
3335+
.update_tracking = true,
3336+
.resurrect = true,
3337+
.close_scope = true,
3338+
});
33313339
try self.performReloc(signed_div_floor_state.reloc);
33323340
const dst_mcv = try self.genCall(
33333341
.{ .lib = .{

0 commit comments

Comments
 (0)