jay: fix W-entry calcs

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-10 11:21:11 -04:00 committed by Marge Bot
parent 7067b66846
commit 9a9365ff9b

View file

@ -549,12 +549,20 @@ static ATTRIBUTE_NOINLINE void
compute_w_entry_loop_header(struct spill_ctx *ctx, jay_block *block)
{
unsigned j = 0;
/* TODO: Account for phis too! */
foreach_next_use(&ctx->blocks[block->index].next_use_in, it) {
assert(j < ctx->n);
ctx->candidates[j++] = *it;
}
jay_foreach_phi_dst_in_block(block, I) {
if (I->dst.file == ctx->file) {
ctx->candidates[j++] = (struct next_use) {
.index = jay_index(I->dst),
.dist = ctx->next_uses[jay_index(I->dst)],
};
}
}
/* Take the best candidates sorted by next-use distance */
unsigned n = MIN2(j, ctx->k - ctx->nW);
if (n < j) {
@ -608,7 +616,8 @@ compute_w_entry(struct spill_ctx *ctx, jay_block *block)
* this reduces pointless spills/fills with massive phi webs.
*/
jay_foreach_phi_dst_in_block(block, I) {
if (!u_sparse_bitset_test(&ctx->phi_set, jay_index(I->dst))) {
if (I->dst.file == ctx->file &&
!u_sparse_bitset_test(&ctx->phi_set, jay_index(I->dst))) {
ctx->candidates[j++] = (struct next_use) {
.index = jay_index(I->dst),
.dist = ctx->next_uses[jay_index(I->dst)],