From 9a9365ff9bdf6db715bdba8d15a4485c6faa9c83 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 10 Apr 2026 11:21:11 -0400 Subject: [PATCH] jay: fix W-entry calcs Signed-off-by: Alyssa Rosenzweig Part-of: --- src/intel/compiler/jay/jay_spill.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/intel/compiler/jay/jay_spill.c b/src/intel/compiler/jay/jay_spill.c index f4c3b85789c..9654a5b986f 100644 --- a/src/intel/compiler/jay/jay_spill.c +++ b/src/intel/compiler/jay/jay_spill.c @@ -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)],