Mesa (main): nir/algebraic: Small optimizations for SpvOpFOrdNotEqual and SpvOpFUnordEqual
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Oct 6 02:17:30 UTC 2021
Module: Mesa
Branch: main
Commit: cb2836164251c9813469345c79a71c222a54f233
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=cb2836164251c9813469345c79a71c222a54f233
Author: Ian Romanick <ian.d.romanick at intel.com>
Date: Thu Mar 11 16:20:06 2021 -0800
nir/algebraic: Small optimizations for SpvOpFOrdNotEqual and SpvOpFUnordEqual
No shader-db changes on any Intel platform.
Fossil-db results:
All Intel platforms had similar results. (Ice Lake shown)
Instructions in all programs: 144380118 -> 143692823 (-0.5%)
SENDs in all programs: 6920822 -> 6920822 (+0.0%)
Loops in all programs: 38299 -> 38299 (+0.0%)
Cycles in all programs: 8434782176 -> 8423078994 (-0.1%)
Spills in all programs: 206830 -> 204469 (-1.1%)
Fills in all programs: 318737 -> 313660 (-1.6%)
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12320>
---
src/compiler/nir/nir_opt_algebraic.py | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
index cf7f85e8dc6..8c238c208da 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -804,6 +804,10 @@ optimizations.extend([
(('ior', ('ior(is_used_once)', ('flt', a, c), d), ('flt(is_used_once)', b, c)), ('ior', ('flt', ('!fmin', a, b), c), d)),
(('ior', ('ior(is_used_once)', ('flt(is_used_once)', a, b), d), ('flt', a, c)), ('ior', ('flt', a, ('!fmax', b, c)), d)),
(('ior', ('ior(is_used_once)', ('flt', a, b), d), ('flt(is_used_once)', a, c)), ('ior', ('flt', a, ('!fmax', b, c)), d)),
+
+ # 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
@@ -2414,6 +2418,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),
More information about the mesa-commit
mailing list