From ad92c2b253d8e122d0f01ab72ccbdfa37efde538 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Fri, 6 Aug 2021 07:19:27 +1000 Subject: [PATCH] nir: add fisnormal lowering just lower the 32-bit version for now. Thanks to alyssa for this suggested lowering. Reviewed-by: Jesse Natalie Part-of: --- src/compiler/nir/nir.h | 2 ++ src/compiler/nir/nir_opt_algebraic.py | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 2789080d1df..006a25debc9 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -3427,6 +3427,8 @@ typedef struct nir_shader_compiler_options { bool lower_fneg; /** lowers ineg to isub. Driver must call nir_opt_algebraic_late(). */ bool lower_ineg; + /** lowers fisnormal to alu ops. */ + bool lower_fisnormal; /* lower {slt,sge,seq,sne} to {flt,fge,feq,fneu} + b2f: */ bool lower_scmp; diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index 6bb9884acbd..f2bf852ea8b 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -2143,6 +2143,10 @@ for op in ['ineg', 'iabs', 'inot', 'isign']: ((op, ('bcsel', c, '#a', '#b')), ('bcsel', c, (op, a), (op, b))), ] +optimizations.extend([ + (('fisnormal', 'a@32'), ('ult', 0x1ffffff, ('iadd', ('ishl', a, 1), 0x1000000)), 'options->lower_fisnormal') + ]) + # This section contains optimizations to propagate downsizing conversions of # constructed vectors into vectors of downsized components. Whether this is # useful depends on the SIMD semantics of the backend. On a true SIMD machine,