From 4a4d410ba771b4349d1e2da093d2a20d79c9a1f5 Mon Sep 17 00:00:00 2001 From: Job Noorman Date: Wed, 29 Apr 2026 15:31:29 +0200 Subject: [PATCH] ir3/shared_ra: insert reloads before tied dst pcopies The parallel copies use the reloaded values in their srcs so make sure reloads happen before them. Fixes a RA validation error in Windrose. Signed-off-by: Job Noorman Fixes: fa22b0901af ("ir3/ra: Add specialized shared register RA/spilling") (cherry picked from commit c67118a6ebef15657b725d2510e7605c06717403) Part-of: --- .pick_status.json | 2 +- src/freedreno/ir3/ir3_shared_ra.c | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 29160fb8106..d86967e0184 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -434,7 +434,7 @@ "description": "ir3/shared_ra: insert reloads before tied dst pcopies", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "fa22b0901af548d5e1433ad4cdbda314182137c5", "notes": null diff --git a/src/freedreno/ir3/ir3_shared_ra.c b/src/freedreno/ir3/ir3_shared_ra.c index ba25b752f8d..a5902a7c3a8 100644 --- a/src/freedreno/ir3/ir3_shared_ra.c +++ b/src/freedreno/ir3/ir3_shared_ra.c @@ -945,7 +945,7 @@ assign_src(struct ra_ctx *ctx, struct ir3_register *src) static void handle_dst(struct ra_ctx *ctx, struct ir3_instruction *instr, - struct ir3_register *dst) + struct ir3_register *dst, struct ir3_cursor *reload_cursor) { if (!(dst->flags & IR3_REG_SHARED)) return; @@ -1015,6 +1015,11 @@ handle_dst(struct ra_ctx *ctx, struct ir3_instruction *instr, mov->cat1.src_type = mov->cat1.dst_type = (dst->flags & IR3_REG_HALF) ? TYPE_U16 : TYPE_U32;; dst->tied->num = dst->num; + + /* If the tied src needs to be reloaded, this has to happen before the + * parallel copy we just inserted. + */ + *reload_cursor = ir3_before_instr(mov); } } @@ -1050,11 +1055,12 @@ handle_normal_instr(struct ra_ctx *ctx, struct ir3_instruction *instr) ra_foreach_src_rev (src, instr) assign_src(ctx, src); + struct ir3_cursor reload_cursor = ir3_before_instr(instr); ra_foreach_dst (dst, instr) - handle_dst(ctx, instr, dst); + handle_dst(ctx, instr, dst, &reload_cursor); ra_foreach_src (src, instr) - handle_src_late(ctx, ir3_before_instr(instr), src); + handle_src_late(ctx, reload_cursor, src); } static void