From 11e8af19554310a8fffcbcd6219ed2d0d9de5ddd Mon Sep 17 00:00:00 2001 From: Connor Abbott Date: Mon, 15 Nov 2021 12:11:07 +0100 Subject: [PATCH] ir3/ra: Consider reg file size when swapping killed sources Don't swap a 2-component vector of half-regs with a full reg if that would result in the half regs going outside of the allowable half-reg space. Fixes: d4b5d2a0204 ("ir3/ra: Use killed sources in register eviction") Part-of: (cherry picked from commit 9d88b98b0820198c0050965cbd6f1909b9eb8fa5) --- .pick_status.json | 2 +- src/freedreno/ir3/ir3_ra.c | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 22e75752cd2..5620fc95e79 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -2065,7 +2065,7 @@ "description": "ir3/ra: Consider reg file size when swapping killed sources", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "d4b5d2a0204f8c09a2e8c4dc022f0f05adafa50b" }, diff --git a/src/freedreno/ir3/ir3_ra.c b/src/freedreno/ir3/ir3_ra.c index 1d8b81c0002..a282b033c5d 100644 --- a/src/freedreno/ir3/ir3_ra.c +++ b/src/freedreno/ir3/ir3_ra.c @@ -780,10 +780,12 @@ try_evict_regs(struct ra_ctx *ctx, struct ra_file *file, return false; } + unsigned conflicting_file_size = + reg_file_size(file, conflicting->interval.reg); unsigned avail_start, avail_end; bool evicted = false; BITSET_FOREACH_RANGE (avail_start, avail_end, available_to_evict, - reg_file_size(file, conflicting->interval.reg)) { + conflicting_file_size) { unsigned size = avail_end - avail_start; /* non-half registers must be aligned */ @@ -820,6 +822,10 @@ try_evict_regs(struct ra_ctx *ctx, struct ra_file *file, conflicting->physreg_end - conflicting->physreg_start) continue; + if (killed->physreg_end > conflicting_file_size || + conflicting->physreg_end > reg_file_size(file, killed->interval.reg)) + continue; + /* We can't swap the killed range if it partially/fully overlaps the * space we're trying to allocate or (in speculative mode) if it's * already been swapped and will overlap when we actually evict.