diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2023-11-14 18:10:29 -0500 |
|---|---|---|
| committer | Jacob Young <jacobly0@users.noreply.github.com> | 2023-11-14 22:50:05 -0500 |
| commit | 0c6cb8d8c80f0a316a77eddfebaa42cb77c8bf7d (patch) | |
| tree | 62180725bccf579b7e33bc8dfdc7983ff0f1d85a /src/arch | |
| parent | 6fd1c64f23807993246515b93eb14978cff0e5da (diff) | |
| download | zig-0c6cb8d8c80f0a316a77eddfebaa42cb77c8bf7d.tar.gz zig-0c6cb8d8c80f0a316a77eddfebaa42cb77c8bf7d.zip | |
x86_64: actually track state during `@divFloor` of `i128`
Closes #17998
Diffstat (limited to 'src/arch')
| -rw-r--r-- | src/arch/x86_64/CodeGen.zig | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/arch/x86_64/CodeGen.zig b/src/arch/x86_64/CodeGen.zig index 2e3209f64a..822ff0ec2d 100644 --- a/src/arch/x86_64/CodeGen.zig +++ b/src/arch/x86_64/CodeGen.zig @@ -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 = .{ |
