[Mesa-dev] [PATCH 5/5] nir: Generalize the optimization of subs of subs from 0.
Eric Anholt
eric at anholt.net
Fri Feb 20 12:04:53 PST 2015
I initially wrote this based on the "(('fneg', ('fneg', a)), a)" above,
but we can generalize it and make it more potentially useful. In the
specific original case of a 0 for our new 'a' argument, it'll get further
algebraic optimization once the 0 is an argument to the new add.
No shader-db effects.
---
src/glsl/nir/nir_opt_algebraic.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/glsl/nir/nir_opt_algebraic.py b/src/glsl/nir/nir_opt_algebraic.py
index 8b08e9e..6d09120 100644
--- a/src/glsl/nir/nir_opt_algebraic.py
+++ b/src/glsl/nir/nir_opt_algebraic.py
@@ -152,8 +152,8 @@ optimizations = [
(('fcsel', a, b, b), b),
# Subtracts
- (('fsub', 0.0, ('fsub', 0.0, a)), a),
- (('isub', 0, ('isub', 0, a)), a),
+ (('fsub', a, ('fsub', 0.0, b)), ('fadd', a, b)),
+ (('isub', a, ('isub', 0, b)), ('iadd', a, b)),
(('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)),
--
2.1.4
More information about the mesa-dev
mailing list