From 1aa1c1aec2ab61e0fe0e7d32b371e85c96e3d6f4 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Tue, 10 Nov 2020 14:10:35 +0100 Subject: [PATCH] nir/algebraic: optimize bitfield_select(a, iand(a, b), c) fossils-db (Vega10): Totals from 242 (0.17% of 139517) affected shaders: CodeSize: 853752 -> 852752 (-0.12%) Instrs: 165944 -> 165694 (-0.15%) Cycles: 855720 -> 854528 (-0.14%) VMEM: 83772 -> 83668 (-0.12%); split: +0.13%, -0.25% SMEM: 12360 -> 12316 (-0.36%) SClause: 8222 -> 8238 (+0.19%) Only helps Control. Signed-off-by: Samuel Pitoiset Reviewed-by: Rhys Perry 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 3112623d9ff..cd52925972a 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -1401,6 +1401,7 @@ optimizations.extend([ # (src0 & src1) | (~src0 & src2). Constant fold if src2 is 0. (('bitfield_select', a, b, 0), ('iand', a, b)), + (('bitfield_select', a, ('iand', a, b), c), ('bitfield_select', a, b, c)), # Note that these opcodes are defined to only use the five least significant bits of 'offset' and 'bits' (('ubfe', 'value', 'offset', ('iand', 31, 'bits')), ('ubfe', 'value', 'offset', 'bits')),