From 31e1e98ae356d3efdb10d5e47b430796fb4361ce Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 26 May 2026 17:03:04 -0400 Subject: [PATCH] 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 Part-of: --- src/intel/compiler/jay/jay_register_allocate.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/intel/compiler/jay/jay_register_allocate.c b/src/intel/compiler/jay/jay_register_allocate.c index dd04344c77c..19c366107c2 100644 --- a/src/intel/compiler/jay/jay_register_allocate.c +++ b/src/intel/compiler/jay/jay_register_allocate.c @@ -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; }