From 7b9e482ed6aaf9c1ec25970f599ae8f7ef83ad47 Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Sat, 22 Mar 2025 04:28:44 -0400 Subject: [PATCH] x86_64: fix rare miscomp that clobbers memory --- src/arch/x86_64/CodeGen.zig | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/arch/x86_64/CodeGen.zig b/src/arch/x86_64/CodeGen.zig index fb1737f950..4a98dcc3ed 100644 --- a/src/arch/x86_64/CodeGen.zig +++ b/src/arch/x86_64/CodeGen.zig @@ -101703,10 +101703,19 @@ const Temp = struct { .dst_temps = .{ .{ .ref = .src0 }, .unused }, .each = .{ .once = &.{} }, }, .{ - .required_features = .{ .fast_imm16, null, null, null }, .src_constraints = .{ .{ .unsigned_int = .word }, .any, .any }, .patterns = &.{ .{ .src = .{ .mut_mem, .none, .none } }, + }, + .dst_temps = .{ .{ .ref = .src0 }, .unused }, + .clobbers = .{ .eflags = true }, + .each = .{ .once = &.{ + .{ ._, ._, .@"and", .dst0w, .ua(.src0, .add_umax), ._, ._ }, + } }, + }, .{ + .required_features = .{ .fast_imm16, null, null, null }, + .src_constraints = .{ .{ .unsigned_int = .word }, .any, .any }, + .patterns = &.{ .{ .src = .{ .to_mut_gpr, .none, .none } }, }, .dst_temps = .{ .{ .ref = .src0 }, .unused },