Mesa (master): nir: Lower subtraction to add with negation when !lower_negate.

Kenneth Graunke kwg at kemper.freedesktop.org
Sat Mar 28 04:21:17 UTC 2015


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

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Wed Mar 25 15:22:12 2015 -0700

nir: Lower subtraction to add with negation when !lower_negate.

prog->nir will generate fsub opcodes, but i965 doesn't implement them.
We may as well lower them at the NIR level, since it's trivial to do.

Suggested by Connor Abbott.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Connor Abbott <cwabbott0 at gmail.com>
Reviewed-by: Eric Anholt <eric at anholt.net>

---

 src/glsl/nir/nir_opt_algebraic.py |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/glsl/nir/nir_opt_algebraic.py b/src/glsl/nir/nir_opt_algebraic.py
index 20ec4d3..66b456d 100644
--- a/src/glsl/nir/nir_opt_algebraic.py
+++ b/src/glsl/nir/nir_opt_algebraic.py
@@ -161,6 +161,8 @@ optimizations = [
    # Subtracts
    (('fsub', a, ('fsub', 0.0, b)), ('fadd', a, b)),
    (('isub', a, ('isub', 0, b)), ('iadd', a, b)),
+   (('fsub', a, b), ('fadd', a, ('fneg', b)), '!options->lower_negate'),
+   (('isub', a, b), ('iadd', a, ('ineg', b)), '!options->lower_negate'),
    (('fneg', a), ('fsub', 0.0, a), 'options->lower_negate'),
    (('ineg', a), ('isub', 0, a), 'options->lower_negate'),
    (('fadd', a, ('fsub', 0.0, b)), ('fsub', a, b)),




More information about the mesa-commit mailing list