From 5c31ce84b8ffc88b85e60be7c030de48f779416c Mon Sep 17 00:00:00 2001 From: peterino2 Date: Tue, 3 Nov 2026 09:36:45 -0800 Subject: [PATCH] dxil: storePtr skips forwarding-map lookups that cannot match Each stored component looked itself up in the status values and removed its key from the forwarding map, both hash operations, though the first is usually empty and the second often. Both are now skipped when empty. The hill-climbing set: -0.8% (A/B, near noise); output unchanged on the verify corpus. --- src/dxil/emit.zig | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/dxil/emit.zig b/src/dxil/emit.zig index b532ee4..c3c1bd3 100644 --- a/src/dxil/emit.zig +++ b/src/dxil/emit.zig @@ -2912,8 +2912,10 @@ const Emitter = struct { const key = .{ ptr.base, ptr.offset_const + @as(u32, @intCast(c)) }; // (Constants too, in locals: ops such as linear algebra // layouts need immediates passed through parameters.) - const forward = e.status_vals.contains(v) or (v == .constant and ptr.addr_space == 0); - if (forward) try e.forwarded.put(e.arena, key, .{ .v = v, .block = e.cur }) else _ = e.forwarded.remove(key); + const forward = (v == .constant and ptr.addr_space == 0) or (e.status_vals.count() > 0 and e.status_vals.contains(v)); + if (forward) { + try e.forwarded.put(e.arena, key, .{ .v = v, .block = e.cur }); + } else if (e.forwarded.count() > 0) _ = e.forwarded.remove(key); } else e.forwarded.clearRetainingCapacity(); const p = try e.elementPtr(ptr, @intCast(c)); const ct = e.compOf(try e.componentType(ty, @intCast(c)));