From 6378bbaa82d7c26e4865b5e759dbb54564015f03 Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Wed, 4 Sep 2024 10:19:40 +0200 Subject: [PATCH] nir/opt_algebraic: reassociate constants in ior(iand) chains Mostly affects one F1_23 shader that packs bitfields bit by bit. Totals from 3 (0.00% of 79395) affected shaders: Instrs: 5004 -> 4202 (-16.03%) CodeSize: 30992 -> 23952 (-22.72%) Latency: 28894 -> 28464 (-1.49%) InvThroughput: 4095 -> 3934 (-3.93%) Copies: 363 -> 376 (+3.58%) PreVGPRs: 110 -> 109 (-0.91%) VALU: 3035 -> 2504 (-17.50%) SALU: 463 -> 459 (-0.86%) Reviewed-by: Konstantin Seurer Part-of: --- src/compiler/nir/nir_opt_algebraic.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index 2a8f01dc7e2..86a4ae9590f 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -2003,6 +2003,7 @@ optimizations.extend([ (('iand', '#a', ('iand', 'b(is_not_const)', '#c')), ('iand', ('iand', a, c), b)), (('ior', '#a', ('ior', 'b(is_not_const)', '#c')), ('ior', ('ior', a, c), b)), (('ixor', '#a', ('ixor', 'b(is_not_const)', '#c')), ('ixor', ('ixor', a, c), b)), + (('ior', ('iand', a, '#c'), ('ior', b, ('iand', a, '#d'))), ('ior', b, ('iand', a, ('ior', c, d)))), # Reassociate add chains for more MAD/FMA-friendly code (('~fadd', ('fadd(is_used_once)', 'a(is_fmul)', 'b(is_fmul)'), 'c(is_not_fmul)'), ('fadd', ('fadd', a, c), b)),