From de0ebaf09d43cc1e530f11511441cab7266b7f20 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Sch=C3=BCrmann?= Date: Tue, 28 Apr 2020 11:45:07 +0100 Subject: [PATCH] nir/algebraic: optimize bcsel(a, 0, 1) to b2i MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This avoids combination with other bcsel operations, and as b2i is often a no-op (when used for iadd and such), the resulting pattern is preferable. Totals from affected shaders: (VEGA) SGPRS: 598448 -> 598448 (0.00 %) VGPRS: 457940 -> 457352 (-0.13 %) Spilled SGPRs: 127154 -> 127154 (0.00 %) Spilled VGPRs: 0 -> 0 (0.00 %) Private memory VGPRs: 0 -> 0 (0.00 %) Scratch size: 0 -> 0 (0.00 %) dwords per thread Code Size: 64836352 -> 64802728 (-0.05 %) bytes LDS: 781 -> 781 (0.00 %) blocks Max Waves: 22931 -> 22931 (0.00 %) Reviewed-by: Alyssa Rosenzweig Reviewed-by: Rhys Perry Reviewed-by: Marek Olšák Part-of: --- src/compiler/nir/nir_opt_algebraic.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index 4b5fc5ecc9a..507a4d397b7 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -859,6 +859,8 @@ optimizations.extend([ # D3D Boolean emulation (('bcsel', a, -1, 0), ('ineg', ('b2i', 'a@1'))), (('bcsel', a, 0, -1), ('ineg', ('b2i', ('inot', a)))), + (('bcsel', a, 1, 0), ('b2i', 'a@1')), + (('bcsel', a, 0, 1), ('b2i', ('inot', a))), (('iand', ('ineg', ('b2i', 'a@1')), ('ineg', ('b2i', 'b@1'))), ('ineg', ('b2i', ('iand', a, b)))), (('ior', ('ineg', ('b2i','a@1')), ('ineg', ('b2i', 'b@1'))), -- 2.30.2