From 87ea850d76577d52024ad322ba7336912f4fefcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Ondra=C4=8Dka?= Date: Mon, 17 Jul 2023 14:49:21 +0200 Subject: [PATCH] r300: move power of two multipliers down RV530 shader-db: total instructions in shared programs: 128864 -> 128840 (-0.02%) instructions in affected programs: 1260 -> 1236 (-1.90%) helped: 21 HURT: 2 total presub in shared programs: 7682 -> 7670 (-0.16%) presub in affected programs: 77 -> 65 (-15.58%) helped: 12 HURT: 0 total omod in shared programs: 386 -> 403 (4.40%) omod in affected programs: 3 -> 20 (566.67%) helped: 0 HURT: 14 total temps in shared programs: 16948 -> 16926 (-0.13%) temps in affected programs: 280 -> 258 (-7.86%) helped: 20 HURT: 2 total cycles in shared programs: 194101 -> 193751 (-0.18%) cycles in affected programs: 3422 -> 3072 (-10.23%) helped: 25 HURT: 5 Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6855 Reviewed-by: Filip Gawin Part-of: --- src/gallium/drivers/r300/compiler/r300_nir_algebraic.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gallium/drivers/r300/compiler/r300_nir_algebraic.py b/src/gallium/drivers/r300/compiler/r300_nir_algebraic.py index 485943e16f2..f03b8eaf6bc 100644 --- a/src/gallium/drivers/r300/compiler/r300_nir_algebraic.py +++ b/src/gallium/drivers/r300/compiler/r300_nir_algebraic.py @@ -82,6 +82,11 @@ r300_nir_prepare_presubtract = [ (('fmul', 'a(is_ubo_or_input)', 2.0), ('fadd', a, a)), ] +for multiplier in [2.0, 4.0, 8.0, 16.0, 0.5, 0.25, 0.125, 0.0625]: + r300_nir_prepare_presubtract.extend([ + (('fmul', a, ('fmul(is_used_once)', 'b(is_ubo_or_input)', multiplier)), ('fmul', multiplier, ('fmul', a, b))), +]) + # Previous prepare_presubtract pass can sometimes produce double fneg patterns. # The backend copy propagate could handle it, but the nir to tgsi translation # does not and blows up. Just run a simple pass to clean it up.