From 6f5f5ca4b293bb2316abdf845c494d66c3b3d7af Mon Sep 17 00:00:00 2001 From: Olivia Lee Date: Sun, 25 May 2025 20:25:48 -0700 Subject: [PATCH] pan/va: allow using both FAU and small constants in the same instruction MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Normally we aren't able to mix FAU srcs from different pages. We consider small constants (BIR_FAU_IMMEDIATE) to be page 0, and so were previously always pulling small constants out with a MOV in instructions that also use FAUs. This is not necessary. Message unit instructions have no restrictions on small constant use and execution unit instructions allow mixing small constants with FAU srcs as long as we don't use more than 64 bits. shader-db results on G610: total instrs in shared programs: 673595 -> 672719 (-0.13%) instrs in affected programs: 111294 -> 110418 (-0.79%) helped: 293 HURT: 9 helped stats (abs) min: 1.0 max: 27.0 x̄: 3.12 x̃: 2 helped stats (rel) min: 0.08% max: 10.53% x̄: 1.71% x̃: 1.02% HURT stats (abs) min: 1.0 max: 15.0 x̄: 4.33 x̃: 3 HURT stats (rel) min: 0.06% max: 12.20% x̄: 2.07% x̃: 0.49% 95% mean confidence interval for instrs value: -3.38 -2.42 95% mean confidence interval for instrs %-change: -1.80% -1.39% Instrs are helped. total cycles in shared programs: 34260.22 -> 34257.44 (<.01%) cycles in affected programs: 143.53 -> 140.75 (-1.94%) helped: 78 HURT: 1 helped stats (abs) min: 0.015625 max: 0.296875 x̄: 0.04 x̃: 0 helped stats (rel) min: 0.32% max: 5.71% x̄: 1.78% x̃: 1.32% HURT stats (abs) min: 0.046875 max: 0.046875 x̄: 0.05 x̃: 0 HURT stats (rel) min: 1.90% max: 1.90% x̄: 1.90% x̃: 1.90% 95% mean confidence interval for cycles value: -0.05 -0.02 95% mean confidence interval for cycles %-change: -1.98% -1.49% Cycles are helped. total cvt in shared programs: 4097.12 -> 4083.44 (-0.33%) cvt in affected programs: 706.75 -> 693.06 (-1.94%) helped: 293 HURT: 9 helped stats (abs) min: 0.015625 max: 0.421875 x̄: 0.05 x̃: 0 helped stats (rel) min: 0.19% max: 45.45% x̄: 6.38% x̃: 2.53% HURT stats (abs) min: 0.015625 max: 0.234375 x̄: 0.07 x̃: 0 HURT stats (rel) min: 0.15% max: 50.00% x̄: 7.85% x̃: 1.90% 95% mean confidence interval for cvt value: -0.05 -0.04 95% mean confidence interval for cvt %-change: -7.03% -4.89% Cvt are helped. total code size in shared programs: 6205824 -> 6198528 (-0.12%) code size in affected programs: 395648 -> 388352 (-1.84%) helped: 57 HURT: 2 helped stats (abs) min: 128.0 max: 256.0 x̄: 132.49 x̃: 128 helped stats (rel) min: 0.08% max: 25.00% x̄: 6.96% x̃: 5.26% HURT stats (abs) min: 128.0 max: 128.0 x̄: 128.00 x̃: 128 HURT stats (rel) min: 1.12% max: 2.86% x̄: 1.99% x̃: 1.99% 95% mean confidence interval for code size value: -137.46 -109.86 95% mean confidence interval for code size %-change: -8.19% -5.12% Code size are helped. total threads in shared programs: 22203 -> 22204 (<.01%) threads in affected programs: 1 -> 2 (100.00%) helped: 1 HURT: 0 Signed-off-by: Olivia Lee Reviewed-by: Boris Brezillon Reviewed-by: Mary Guillemard Part-of: --- src/panfrost/compiler/valhall/va_validate.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/panfrost/compiler/valhall/va_validate.c b/src/panfrost/compiler/valhall/va_validate.c index 3465ac086e5..5bba02315bc 100644 --- a/src/panfrost/compiler/valhall/va_validate.c +++ b/src/panfrost/compiler/valhall/va_validate.c @@ -137,6 +137,15 @@ valid_src(struct fau_state *fau, unsigned fau_page, bi_index src, if (src.type != BI_INDEX_FAU) return true; + if (src.value & BIR_FAU_IMMEDIATE) { + /* There are no small constant restrictions in message instructions */ + if (can_use_two_fau_indices(op)) + return true; + /* Otherwise we just need to ensure that we don't access more than a + * total of 64 bits of distinct FAU+small constant values */ + return fau_state_buffer(fau, src); + } + bool valid = (fau_page == va_fau_page(src.value)); valid &= fau_state_buffer(fau, src);