From 743fd60bea06591c9fc1343aa97077a05336a0b9 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 15 Aug 2023 01:15:17 -0700 Subject: [PATCH] intel/fs: Account for payload GRFs when calculating register pressure The register pressure analysis I wrote in 2013 only considered VGRFs, and not other GRFs, such as payload registers and push constants. We need to consider those too, because payload registers definitely occupy space and add to pressure. In 2015, Connor already made the scheduler account for this, so the only real use for this is in shader statistic dumps and optimizer printouts. But we should make it more accurate. (We will use it in more places shortly, a few commits from now.) Reviewed-by: Emma Anholt Part-of: --- src/intel/compiler/brw_fs.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/intel/compiler/brw_fs.cpp b/src/intel/compiler/brw_fs.cpp index 651b31c50b4..fbc94f0dcfe 100644 --- a/src/intel/compiler/brw_fs.cpp +++ b/src/intel/compiler/brw_fs.cpp @@ -6177,6 +6177,18 @@ brw::register_pressure::register_pressure(const fs_visitor *v) for (int ip = live.vgrf_start[reg]; ip <= live.vgrf_end[reg]; ip++) regs_live_at_ip[ip] += v->alloc.sizes[reg]; } + + const unsigned payload_count = v->first_non_payload_grf; + + int *payload_last_use_ip = new int[payload_count]; + v->calculate_payload_ranges(payload_count, payload_last_use_ip); + + for (unsigned reg = 0; reg < payload_count; reg++) { + for (int ip = 0; ip < payload_last_use_ip[reg]; ip++) + ++regs_live_at_ip[ip]; + } + + delete[] payload_last_use_ip; } brw::register_pressure::~register_pressure()