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.
This commit is contained in:
peterino2 2026-11-03 11:01:24 -08:00
parent 531b5c6227
commit 9bb4feb32b
1 changed files with 5 additions and 3 deletions

View File

@ -3109,9 +3109,11 @@ const Emitter = struct {
for (vals, 0..) |v, c| { for (vals, 0..) |v, c| {
if (ptr.offset_dyn == null) { if (ptr.offset_dyn == null) {
const key = .{ ptr.base, ptr.offset_const + @as(u32, @intCast(c)) }; const key = .{ ptr.base, ptr.offset_const + @as(u32, @intCast(c)) };
// (Constants too, in locals: ops such as linear algebra // (Every value stored to a local: later loads of it in the
// layouts need immediates passed through parameters.) // block need no instructions, and constants stay constants,
const forward = (v == .constant and ptr.addr_space == 0) or (e.status_vals.count() > 0 and e.status_vals.contains(v)); // 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) { if (forward) {
try e.forwarded.put(e.arena, key, .{ .v = v, .block = e.cur }); try e.forwarded.put(e.arena, key, .{ .v = v, .block = e.cur });
} else if (e.forwarded.count() > 0) _ = e.forwarded.remove(key); } else if (e.forwarded.count() > 0) _ = e.forwarded.remove(key);