From cc3ef3643a6d05f2f08b20828934807e3c49f5af Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Tue, 10 Dec 2019 16:20:56 +0000 Subject: [PATCH] nir/algebraic: a & ~(a >> 31) -> imax(a, 0) Found in some Doom shaders Totals from affected shaders: SGPRS: 30056 -> 30064 (0.03 %) VGPRS: 28024 -> 28024 (0.00 %) Spilled SGPRs: 0 -> 0 (0.00 %) Spilled VGPRs: 0 -> 0 (0.00 %) Code Size: 4278648 -> 4270852 (-0.18 %) bytes Max Waves: 1476 -> 1476 (0.00 %) Instructions: 835287 -> 833338 (-0.23 %) Signed-off-by: Rhys Perry Reviewed-by: Alyssa Rosenzweig Tested-by: Marge Bot 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 633ee8792d9..fbf0f694430 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -480,6 +480,7 @@ optimizations.extend([ (('fmin', ('fmin', a, b), b), ('fmin', a, b)), (('umin', ('umin', a, b), b), ('umin', a, b)), (('imin', ('imin', a, b), b), ('imin', a, b)), + (('iand@32', a, ('inot', ('ishr', a, 31))), ('imax', a, 0)), (('fmax', a, ('fneg', a)), ('fabs', a)), (('imax', a, ('ineg', a)), ('iabs', a)), (('fmin', a, ('fneg', a)), ('fneg', ('fabs', a))), -- 2.30.2