jay: generalize alignment heuristic

Totals:
Instrs: 2807560 -> 2805375 (-0.08%); split: -0.27%, +0.20%
CodeSize: 45051536 -> 45011488 (-0.09%); split: -0.28%, +0.19%

Totals from 1292 (48.81% of 2647) affected shaders:
Instrs: 2154123 -> 2151938 (-0.10%); split: -0.36%, +0.26%
CodeSize: 34658096 -> 34618048 (-0.12%); split: -0.36%, +0.25%

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40960>
This commit is contained in:
Alyssa Rosenzweig 2026-04-13 15:14:27 -04:00 committed by Marge Bot
parent e54898fdc8
commit dd6efffb47

View file

@ -189,9 +189,9 @@ struct affinity {
bool eot:1;
/** If true, this UGPR needs full GRF alignment */
bool grf_align :1;
unsigned align :5;
unsigned align_offs:4;
unsigned padding :22;
unsigned padding :18;
};
static_assert(sizeof(struct affinity) == 8, "packed");
@ -727,7 +727,6 @@ pick_regs(jay_ra_state *ra,
{
struct jay_partition *partition = &ra->bld.shader->partition;
unsigned first = 0, end = ra->num_regs[file];
unsigned ugpr_per_grf = jay_ugpr_per_grf(ra->bld.shader);
bool must_tie = I->op == JAY_OPCODE_LANE_ID_EXPAND;
must_tie &= !is_src;
@ -809,8 +808,8 @@ pick_regs(jay_ra_state *ra,
/* If there are stricter alignment requirements later, model the cost of
* inserting copies for that.
*/
if (affinity.grf_align &&
!util_is_aligned(r - affinity.align_offs, ugpr_per_grf))
if (affinity.align &&
!util_is_aligned(r - affinity.align_offs, affinity.align))
cost += size;
if (affinity.repr == jay_channel(var, 0)) {
@ -1637,8 +1636,8 @@ jay_register_allocate_function(jay_function *f)
ra.affinities[index].eot = true;
}
if (jay_src_alignment(shader, I, s) >= jay_ugpr_per_grf(shader)) {
ra.affinities[index].grf_align = true;
if (jay_src_alignment(shader, I, s) >= ra.affinities[index].align) {
ra.affinities[index].align = jay_src_alignment(shader, I, s);
ra.affinities[index].align_offs = c;
}