summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2020-07-07 17:36:09 -0700
committerIan Romanick <ian.d.romanick@intel.com>2021-04-02 12:56:19 -0700
commit3966e3c94d141618d39bb9962c0f9b705ea736de (patch)
tree11cced7e112a06a2eb2424c505eed7c0888c1f33
parent20ca2cf36a441e885cfa087a07c89066d8f9ca6d (diff)
nir/algebraic: Duplicate patterns to recognize open-coded fmin / fmax in late_optimizations
-rw-r--r--src/compiler/nir/nir_opt_algebraic.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
index 7b48bccd8cf..5cd25eaa185 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -2393,6 +2393,14 @@ late_optimizations = [
(('ior', a, a), a),
(('iand', a, a), a),
+ # Various optimizations above that rearrange comparisons can create
+ # additional opportunities for these patterns (which are copied from the
+ # main optimization block).
+ (('~bcsel', ('flt', b, a), b, a), ('fmin', a, b)),
+ (('~bcsel', ('flt', a, b), b, a), ('fmax', a, b)),
+ (('~bcsel', ('fge', a, b), b, a), ('fmin', a, b)),
+ (('~bcsel', ('fge', b, a), b, a), ('fmax', a, b)),
+
# Eliminate a constant if both choices are constants.
(('bcsel', ('feq', 'a@32', 0.0), 0.0, '#b@32'), ('bcsel', ('feq', a, 0.0), ('fabs', a), b)),
(('bcsel', ('fneu', 'a@32', 0.0), '#b@32', 0.0), ('bcsel', ('feq', a, 0.0), ('fabs', a), b)),