From 9bb4feb32b973f312b024e684eff006ee8a13975 Mon Sep 17 00:00:00 2001 From: peterino2 Date: Tue, 3 Nov 2026 11:01:24 -0800 Subject: [PATCH] dxil: forward every value stored to a local to loads in its block Values stored to locals were forwarded to later loads in the same block only when constants (or status values); every value now is. Such loads need no getelementptr, load or conversion back from i32 storage. - The hill-climbing set: -2.4% (A/B). - Output: 1,349 of 19,624 verify compiles change (loads from locals that stay in memory, such as arrays also indexed at run time, read the stored value directly). - Validator 1.8: 11,488 Unreal compiles, 0 invalid; Glide's the same 12 invalid as before. --- src/dxil/emit.zig | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/dxil/emit.zig b/src/dxil/emit.zig index e9ed7d6..b5aca32 100644 --- a/src/dxil/emit.zig +++ b/src/dxil/emit.zig @@ -3109,9 +3109,11 @@ const Emitter = struct { for (vals, 0..) |v, c| { if (ptr.offset_dyn == null) { 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 = (v == .constant and ptr.addr_space == 0) or (e.status_vals.count() > 0 and e.status_vals.contains(v)); + // (Every value stored to a local: later loads of it in the + // block need no instructions, and constants stay constants, + // as ops such as linear algebra layouts need immediates + // passed through parameters.) + const forward = 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);