From ee15d893224c1eee5c239e54f7aa5191bec55377 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 15 Feb 2022 15:32:00 -0800 Subject: [PATCH] nir/algebraic: Simplify min and max of b2i MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This prevents ~400 shader-db regresssions and a handful of fossil-db regressions after i2b is always lowered. All Ivy Bridge and newer Intel platforms had similar results. (Ice Lake shown) total cycles in shared programs: 855301494 -> 855302118 (<.01%) cycles in affected programs: 52787 -> 53411 (1.18%) helped: 4 / HURT: 5 All Intel platforms had similar results. (Ice Lake shown) Instructions in all programs: 141206055 -> 141205979 (-0.0%) Instructions helped: 14 Cycles in all programs: 9133376616 -> 9133387327 (+0.0%) Cycles helped: 13 Cycles hurt: 3 Acked-by: Jesse Natalie Acked-by: Alyssa Rosenzweig Tested-by: Daniel Schürmann Part-of: --- src/compiler/nir/nir_opt_algebraic.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index 77fa16b..f3612a2 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -1429,6 +1429,11 @@ optimizations.extend([ ('ineg', ('b2i', ('ior', a, b)))), (('umin', ('ineg', ('b2i', 'a@1')), ('ineg', ('b2i', 'b@1'))), ('ineg', ('b2i', ('iand', a, b)))), + (('umax', ('b2i', 'a@1'), ('b2i', 'b@1')), ('b2i', ('ior', a, b))), + (('umin', ('b2i', 'a@1'), ('b2i', 'b@1')), ('b2i', ('iand', a, b))), + + (('ine', ('umin', ('ineg', ('b2i', 'a@1')), b), 0), ('iand', a, ('ine', b, 0))), + (('ine', ('umax', ('ineg', ('b2i', 'a@1')), b), 0), ('ior' , a, ('ine', b, 0))), # Conversions (('f2i', ('ftrunc', a)), ('f2i', a)), -- 2.7.4