ir3/ra: fix killed src detection while spilling
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

For a src to be killed, not only does its SSA value need to be killed,
it also shouldn't be part of or contain an interval that isn't killed
yet.

Fixes a RA assert in Windrose: "reg pressure calculation was wrong!".

Signed-off-by: Job Noorman <jnoorman@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41154>
This commit is contained in:
Job Noorman 2026-04-24 14:29:37 +02:00 committed by Marge Bot
parent bfb6c41b64
commit 5bfbb7b1a7

View file

@ -1032,6 +1032,18 @@ update_max_pressure(struct ra_spill_ctx *ctx)
MAX2(ctx->max_pressure.shared_half, ctx->cur_pressure.shared_half);
}
/* True if src is killed and its register can be used to allocate a dst. A src
* is killed iff its SSA value is killed and it isn't part of or contains an
* interval that isn't killed yet.
*/
static bool
is_killed(struct ra_spill_ctx *ctx, struct ir3_register *src)
{
struct ra_spill_interval *interval = ctx->intervals[src->def->name];
return (src->flags & IR3_REG_FIRST_KILL) && !interval->interval.parent &&
rb_tree_is_empty(&interval->interval.children);
}
static void
handle_instr(struct ra_spill_ctx *ctx, struct ir3_instruction *instr)
{
@ -1064,7 +1076,7 @@ handle_instr(struct ra_spill_ctx *ctx, struct ir3_instruction *instr)
ra_foreach_dst (dst, instr) {
struct ir3_register *tied_src = dst->tied;
if ((tied_src && !(tied_src->flags & IR3_REG_FIRST_KILL)) ||
if ((tied_src && !is_killed(ctx, tied_src)) ||
(dst->flags & IR3_REG_EARLY_CLOBBER))
insert_dst(ctx, dst);
}