Mesa (master): nir: Remove unnecessary subtraction optimizations

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Sep 30 10:02:35 UTC 2019


Module: Mesa
Branch: master
Commit: 239423d23451537c3a0fdb3b08a857d03a21cce5
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=239423d23451537c3a0fdb3b08a857d03a21cce5

Author: Daniel Schürmann <daniel at schuermann.dev>
Date:   Wed Sep 25 16:33:10 2019 +0200

nir: Remove unnecessary subtraction optimizations

These optimizations are already covered after lowering.

Reviewed-by: Eric Anholt <eric at anholt.net>
Reviewed-by: Connor Abbott <cwabbott0 at gmail.com>

---

 src/compiler/nir/nir_opt_algebraic.py | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
index bf448303437..2e4d7921b72 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -204,7 +204,6 @@ optimizations = [
    # If x < 0: 1 - fsat(x) => 1 - 0 => 1 and fsat(1 - x) => fsat(> 1) => 1
    # If x > 1: 1 - fsat(x) => 1 - 1 => 0 and fsat(1 - x) => fsat(< 0) => 0
    (('~fadd', ('fneg(is_used_once)', ('fsat(is_used_once)', 'a(is_not_fmul)')), 1.0), ('fsat', ('fadd', 1.0, ('fneg', a)))),
-   (('~fsub', 1.0, ('fsat', a)), ('fsat', ('fsub', 1.0, a))),
 
    # 1 - ((1 - a) * (1 - b))
    # 1 - (1 - a - b + a*b)
@@ -668,7 +667,6 @@ optimizations.extend([
    # True/False are ~0 and 0 in NIR.  b2i of True is 1, and -1 is ~0 (True).
    (('ineg', ('b2i32', 'a at 32')), a),
    (('flt', ('fneg', ('b2f', 'a at 1')), 0), a), # Generated by TGSI KILL_IF.
-   (('flt', ('fsub', 0.0, ('b2f', 'a at 1')), 0), a), # Generated by TGSI KILL_IF.
    # Comparison with the same args.  Note that these are not done for
    # the float versions because NaN always returns false on float
    # inequalities.
@@ -934,16 +932,8 @@ optimizations.extend([
    (('iand', 0xffff, a), ('extract_u16', a, 0), '!options->lower_extract_word'),
 
    # Subtracts
-   (('~fsub', a, ('fsub', 0.0, b)), ('fadd', a, b)),
-   (('isub', a, ('isub', 0, b)), ('iadd', a, b)),
-   (('isub', ('iadd', a, b), b), a),
-   (('~fsub', ('fadd', a, b), b), a),
    (('ussub_4x8', a, 0), a),
    (('ussub_4x8', a, ~0), 0),
-   (('~fadd', a, ('fsub', 0.0, b)), ('fsub', a, b)),
-   (('iadd', a, ('isub', 0, b)), ('isub', a, b)),
-   (('fabs', ('fsub', 0.0, a)), ('fabs', a)),
-   (('iabs', ('isub', 0, a)), ('iabs', a)),
    # Lower all Subtractions first - they can get recombined later
    (('fsub', a, b), ('fadd', a, ('fneg', b))),
    (('isub', a, b), ('iadd', a, ('ineg', b))),




More information about the mesa-commit mailing list