authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-04-14 04:47:33-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-04-16 17:05:34-04:00
logc03771e1738dae25eccf7726dcc952ad5936ca15
tree66cb46d5aaf42d2b45d37424f85caacfc70dff05
parent08055f2942abe873283ec46f2656ecb932f915b3

x86_64: fix overflow of extended multiply


1 files changed, 3 insertions(+), 1 deletions(-)

src/arch/x86_64/CodeGen.zig+3-1
......@@ -2089,12 +2089,14 @@ fn airMulWithOverflow(self: *Self, inst: Air.Inst.Index) !void {
20892089 else => {},
20902090 }
20912091
2092 // For now, this is the only supported multiply that doesn't fit in a register.
2093 assert(dst_info.bits == 128 and src_pl.data == 64);
20922094 const dst_abi_size = @intCast(i32, dst_ty.abiSize(self.target.*));
20932095 const dst_mcv = try self.allocRegOrMem(inst, false);
20942096 try self.genSetStack(
20952097 Type.u1,
20962098 dst_mcv.stack_offset - dst_abi_size,
2097 .{ .eflags = cc },
2099 .{ .immediate = 0 }, // 64x64 -> 128 never overflows
20982100 .{},
20992101 );
21002102 try self.genSetStack(dst_ty, dst_mcv.stack_offset, partial_mcv, .{});