From: Daniel Schürmann Date: Tue, 28 Apr 2020 10:45:07 +0000 (+0100) Subject: nir/algebraic: optimize bcsel(a, 0, 1) to b2i X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=de0ebaf09d43cc1e530f11511441cab7266b7f20;p=mesa.git nir/algebraic: optimize bcsel(a, 0, 1) to b2i 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: --- 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'))),