jay: avoid overflow affinities with large UGPR vecs

Totals:
Instrs: 2759295 -> 2759035 (-0.01%); split: -0.01%, +0.00%
CodeSize: 41189376 -> 41185024 (-0.01%); split: -0.01%, +0.00%

Totals from 186 (7.03% of 2647) affected shaders:
Instrs: 422705 -> 422445 (-0.06%); split: -0.09%, +0.03%
CodeSize: 6313712 -> 6309360 (-0.07%); split: -0.09%, +0.03%

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41808>
This commit is contained in:
Alyssa Rosenzweig 2026-05-26 17:03:04 -04:00 committed by Marge Bot
parent 67e3ee6fa9
commit 31e1e98ae3

View file

@ -174,7 +174,7 @@ struct affinity {
/** If the representative: offset in registers from the base.
*
* If not the representative: offset in registers from the representative. */
signed offset:4;
signed offset:7;
/**
* If true, this value is used in an end-of-thread SEND and requires high
@ -187,10 +187,10 @@ struct affinity {
* form (k * align) + align_offs for some integer k. In other words, align is
* the alignment of the whole vector and align_offs is this def's channel.
*/
unsigned align :5;
unsigned align_offs:4;
unsigned align :7;
unsigned align_offs:7;
unsigned nr :4;
unsigned padding :14;
unsigned padding :6;
};
static_assert(sizeof(struct affinity) == 8, "packed");
@ -1469,8 +1469,11 @@ jay_register_allocate_function(jay_function *f)
ra.affinities[index].eot = true;
}
if (jay_src_alignment(shader, I, s) >= ra.affinities[index].align) {
ra.affinities[index].align = jay_src_alignment(shader, I, s);
unsigned al = jay_src_alignment(shader, I, s);
al = MAX2(al, util_next_power_of_two(jay_num_values(I->src[s])));
if (al >= ra.affinities[index].align) {
ra.affinities[index].align = al;
ra.affinities[index].align_offs = c;
}