ir3/ra: try to allocate subreg movs earlier

Successful subreg allocations allow us to remove the instruction so it
makes sense to try this first before trying other allocation strategies.

Totals from 72 (0.04% of 176279) affected shaders:
Instrs: 144346 -> 144277 (-0.05%); split: -0.06%, +0.01%
CodeSize: 312174 -> 312182 (+0.00%); split: -0.01%, +0.01%
NOPs: 32438 -> 32443 (+0.02%); split: -0.07%, +0.09%
MOVs: 5923 -> 5934 (+0.19%)
COVs: 3039 -> 3000 (-1.28%)
(ss): 2967 -> 2968 (+0.03%)
(sy): 1831 -> 1830 (-0.05%)
(ss)-stall: 9113 -> 9128 (+0.16%)
(sy)-stall: 45844 -> 45858 (+0.03%); split: -0.03%, +0.06%
Cat0: 36136 -> 36141 (+0.01%); split: -0.06%, +0.08%
Cat1: 9010 -> 8982 (-0.31%); split: -0.37%, +0.06%
Cat2: 53533 -> 53487 (-0.09%)

Signed-off-by: Job Noorman <jnoorman@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38573>
This commit is contained in:
Job Noorman 2025-11-21 10:49:49 +01:00 committed by Marge Bot
parent 5fd7af9e42
commit 1fc49eb120

View file

@ -1477,6 +1477,16 @@ ir3_ra_handle_unavailable_merge_set(struct ir3_register *reg)
static physreg_t
get_reg(struct ra_ctx *ctx, struct ra_file *file, struct ir3_register *reg)
{
/* For subreg moves (see ir3_is_subreg_move), try to allocate half of their
* full src for their dst. If this succeeds, the instruction can be removed.
*/
enum ir3_subreg_move subreg_move = ir3_is_subreg_move(reg->instr);
if (subreg_move != IR3_SUBREG_MOVE_NONE) {
physreg_t src_reg = try_allocate_src_subreg(ctx, file, reg, subreg_move);
if (src_reg != (physreg_t)~0)
return src_reg;
}
unsigned file_size = reg_file_size(file, reg);
if (reg->merge_set && reg->merge_set->preferred_reg != (physreg_t)~0) {
physreg_t preferred_reg =
@ -1517,16 +1527,6 @@ get_reg(struct ra_ctx *ctx, struct ra_file *file, struct ir3_register *reg)
}
}
/* For subreg moves (see ir3_is_subreg_move), try to allocate half of their
* full src for their dst. If this succeeds, the instruction can be removed.
*/
enum ir3_subreg_move subreg_move = ir3_is_subreg_move(reg->instr);
if (subreg_move != IR3_SUBREG_MOVE_NONE) {
physreg_t src_reg = try_allocate_src_subreg(ctx, file, reg, subreg_move);
if (src_reg != (physreg_t)~0)
return src_reg;
}
/* For ALU and SFU instructions, if the src reg is avail to pick, use it.
* Because this doesn't introduce unnecessary dependencies, and it
* potentially avoids needing (ss) syncs for write after read hazards for