diff options
author | Ian Romanick <ian.d.romanick@intel.com> | 2021-03-11 16:20:06 -0800 |
---|---|---|
committer | Ian Romanick <ian.d.romanick@intel.com> | 2021-04-02 12:56:18 -0700 |
commit | 7ccf7ae7f6b1d4fbd4afbbd81a22b58037d83536 (patch) | |
tree | f47bb46c348c7e4a6de511a51df372a2e8493347 | |
parent | c72858ab070e01213523dd371d6b28304c8ef7a4 (diff) |
nir/algebraic: Small optimizations for SpvOpFOrdNotEqual and SpvOpFUnordEqual
-rw-r--r-- | src/compiler/nir/nir_opt_algebraic.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index bf5af283a29..003c6c714bc 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -692,6 +692,10 @@ optimizations.extend([ (('iand', ('ult(is_used_once)', a, c), ('ult', b, c)), ('ult', ('umax', a, b), c)), (('iand', ('uge(is_used_once)', a, b), ('uge', a, c)), ('uge', a, ('umax', b, c))), (('iand', ('uge(is_used_once)', a, c), ('uge', b, c)), ('uge', ('umin', a, b), c)), + + # This is how SpvOpFOrdNotEqual might be implemented. If both values are + # numbers, then it can be replaced with fneu. + (('ior', ('flt', 'a(is_a_number)', 'b(is_a_number)'), ('flt', b, a)), ('fneu', a, b)), ]) # Float sizes @@ -2247,6 +2251,16 @@ late_optimizations = [ (('feq', ('fadd(is_used_once)', 'a(is_finite)', b), 0.0), ('feq', a, ('fneg', b))), (('fneu', ('fadd(is_used_once)', 'a(is_finite)', b), 0.0), ('fneu', a, ('fneg', b))), + # This is how SpvOpFOrdNotEqual might be implemented. Replace it with + # SpvOpLessOrGreater. + (('iand', ('fneu', a, b), ('iand', ('feq', a, a), ('feq', b, b))), ('ior', ('!flt', a, b), ('!flt', b, a))), + (('iand', ('fneu', a, 0.0), ('feq', a, a) ), ('!flt', 0.0, ('fabs', a))), + + # This is how SpvOpFUnordEqual might be implemented. Replace it with + # !SpvOpLessOrGreater. + (('ior', ('feq', a, b), ('ior', ('fneu', a, a), ('fneu', b, b))), ('inot', ('ior', ('!flt', a, b), ('!flt', b, a)))), + (('ior', ('feq', a, 0.0), ('fneu', a, a), ), ('inot', ('!flt', 0.0, ('fabs', a)))), + # nir_lower_to_source_mods will collapse this, but its existence during the # optimization loop can prevent other optimizations. (('fneg', ('fneg', a)), a), |