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 {...@@ -2089,12 +2089,14 @@ fn airMulWithOverflow(self: *Self, inst: Air.Inst.Index) !void {
2089 else => {},2089 else => {},
2090 }2090 }
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);
2092 const dst_abi_size = @intCast(i32, dst_ty.abiSize(self.target.*));2094 const dst_abi_size = @intCast(i32, dst_ty.abiSize(self.target.*));
2093 const dst_mcv = try self.allocRegOrMem(inst, false);2095 const dst_mcv = try self.allocRegOrMem(inst, false);
2094 try self.genSetStack(2096 try self.genSetStack(
2095 Type.u1,2097 Type.u1,
2096 dst_mcv.stack_offset - dst_abi_size,2098 dst_mcv.stack_offset - dst_abi_size,
2097 .{ .eflags = cc },2099 .{ .immediate = 0 }, // 64x64 -> 128 never overflows
2098 .{},2100 .{},
2099 );2101 );
2100 try self.genSetStack(dst_ty, dst_mcv.stack_offset, partial_mcv, .{});2102 try self.genSetStack(dst_ty, dst_mcv.stack_offset, partial_mcv, .{});