jay/register_allocate: make phi webs conservative

Noticed in a bunch of vkpeak shaders which had extra moves in the loop.

SIMD16:
   Totals from 547 (20.66% of 2647) affected shaders:
   Instrs: 1139024 -> 1131482 (-0.66%); split: -0.68%, +0.02%
   CodeSize: 15919528 -> 15834088 (-0.54%); split: -0.56%, +0.02%

SIMD32:
   Totals from 523 (19.76% of 2647) affected shaders:
   Instrs: 1271749 -> 1263534 (-0.65%); split: -0.75%, +0.10%
   CodeSize: 18180076 -> 18091180 (-0.49%); split: -0.60%, +0.11%

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/42056>
This commit is contained in:
Alyssa Rosenzweig 2026-06-03 11:27:28 -04:00 committed by Marge Bot
parent 62e8998e39
commit ce4d2d7faa

View file

@ -1198,6 +1198,12 @@ local_ra(jay_ra_state *ra, jay_block *block)
* Record all phi webs. First initialize the union-find data structure
* with all SSA defs in their own singletons, then union together anything
* related by a phi. The resulting union-find structure will be the webs.
*
* As a heuristic, we skip the union if the phi source interferes with the phi
* destination (equivalently: the phi source is live-out of the source block).
* These phis could never be coalesced, so the union can only hurt (and it does
* in practice in complex web scenarios). Note this case is only possible
* because we do not lower the input program to conventional SSA (CSSA) form.
*/
static void
construct_phi_webs(struct phi_web_node *web, jay_function *f)
@ -1208,7 +1214,9 @@ construct_phi_webs(struct phi_web_node *web, jay_function *f)
jay_foreach_block(f, block) {
jay_foreach_phi_src_in_block(block, phi) {
phi_web_union(web, jay_index(phi->src[0]), jay_phi_src_index(phi));
if (!u_sparse_bitset_test(&block->live_out, jay_index(phi->src[0]))) {
phi_web_union(web, jay_index(phi->src[0]), jay_phi_src_index(phi));
}
}
}
}