From c906f565b6e6d628fdfd46ca13ddae5f155f13b7 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 9 Apr 2025 16:02:25 -0700 Subject: [PATCH] brw: Track the largest VGRF size in liveness analysis We're already looking at this data to calculate the per-component vars_from_vgrf[] and vgrf_from_vars[] mappings, so just record the largest VGRF size while we're here. This will allow passes to size arrays based on the actual size needed, rather than hardcoding some fixed size. In many cases, MAX_VGRF_SIZE(devinfo) is larger than necessary, because e.g. vec5 sparse sampling results aren't used. Not hardcoding this means we can also temporarily handle very large VGRFs which we know will be split eventually, without having to increase the maximum which is ultimately used for RA classes. Cc: mesa-stable Reviewed-by: Matt Turner Part-of: (cherry picked from commit ea468412f672b07d498af9a910bf5047106f6d84) --- .pick_status.json | 2 +- src/intel/compiler/brw_fs_live_variables.cpp | 3 +++ src/intel/compiler/brw_fs_live_variables.h | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.pick_status.json b/.pick_status.json index 957f89b4dac..e4f742b79a5 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1404,7 +1404,7 @@ "description": "brw: Track the largest VGRF size in liveness analysis", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/intel/compiler/brw_fs_live_variables.cpp b/src/intel/compiler/brw_fs_live_variables.cpp index 6197fa59d97..1e09476aef2 100644 --- a/src/intel/compiler/brw_fs_live_variables.cpp +++ b/src/intel/compiler/brw_fs_live_variables.cpp @@ -254,10 +254,13 @@ fs_live_variables::fs_live_variables(const fs_visitor *s) num_vgrfs = s->alloc.count; num_vars = 0; + max_vgrf_size = 0; var_from_vgrf = linear_alloc_array(lin_ctx, int, num_vgrfs); for (int i = 0; i < num_vgrfs; i++) { var_from_vgrf[i] = num_vars; num_vars += s->alloc.sizes[i]; + + max_vgrf_size = MAX2(max_vgrf_size, s->alloc.sizes[i]); } vgrf_from_var = linear_alloc_array(lin_ctx, int, num_vars); diff --git a/src/intel/compiler/brw_fs_live_variables.h b/src/intel/compiler/brw_fs_live_variables.h index 60ecca43c96..8b64290b0a8 100644 --- a/src/intel/compiler/brw_fs_live_variables.h +++ b/src/intel/compiler/brw_fs_live_variables.h @@ -111,6 +111,8 @@ public: int num_vgrfs; int bitset_words; + unsigned max_vgrf_size; + /** @{ * Final computed live ranges for each var (each component of each virtual * GRF).