jay/register_allocate: tweak roundrobin heuristic

Totals:
Instrs: 4706214 -> 4700132 (-0.13%); split: -1.03%, +0.90%
CodeSize: 70628880 -> 70540336 (-0.13%); split: -1.02%, +0.89%

Totals from 2084 (78.73% of 2647) affected shaders:
Instrs: 4515981 -> 4509899 (-0.13%); split: -1.08%, +0.94%
CodeSize: 67822800 -> 67734256 (-0.13%); split: -1.06%, +0.93%

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41510>
This commit is contained in:
Alyssa Rosenzweig 2026-05-11 12:49:34 -04:00 committed by Marge Bot
parent 37e4144693
commit 5cbf0002c4

View file

@ -191,7 +191,8 @@ struct affinity {
/** If true, this UGPR needs full GRF alignment */
unsigned align :5;
unsigned align_offs:4;
unsigned padding :18;
unsigned nr :4;
unsigned padding :14;
};
static_assert(sizeof(struct affinity) == 8, "packed");
@ -792,7 +793,12 @@ pick_regs(jay_ra_state *ra,
unsigned nr = DIV_ROUND_UP((end + 1 - size - first), alignment);
unsigned roundrobin = (ra->roundrobin[file]) % nr;
unsigned rr_al = roundrobin * alignment, nr_al = nr * alignment;
ra->roundrobin[file] += size;
/* Heuristic: Advance the roundrobin by a whole vector if we are the
* representative. This leaves us registers for the rest of the vector.
*/
ra->roundrobin[file] +=
affinity.repr == jay_channel(var, 0) ? MAX2(size, affinity.nr) : size;
for (unsigned i = rr_al; i < rr_al + nr_al; i += alignment) {
/* We select registers roundrobin. This has several benefits:
@ -1664,6 +1670,7 @@ jay_register_allocate_function(jay_function *f)
ra.affinities[index].repr = repr;
ra.affinities[index].offset = repr == index ? c : c - repr_c;
ra.affinities[index].nr = MIN2(jay_num_values(I->src[s]), 15);
}
if (I->op == JAY_OPCODE_SEND && jay_send_eot(I)) {