[Mesa-dev] [PATCH 5/5] nir: Propagate negates up multiplication chains.

Matt Turner mattst88 at gmail.com
Tue Feb 23 00:13:55 UTC 2016


total instructions in shared programs: 7127270 -> 7103195 (-0.34%)
instructions in affected programs: 1376832 -> 1352757 (-1.75%)
helped: 7394
HURT: 622

GAINED: 4
LOST:   2
---
 src/compiler/nir/nir_opt_algebraic.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
index cc2c229..1863033 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -227,6 +227,10 @@ optimizations = [
    (('fabs', ('fsub', 0.0, a)), ('fabs', a)),
    (('iabs', ('isub', 0, a)), ('iabs', a)),
 
+   # Propagate negation up multiplication chains
+   (('fmul', ('fneg', a), b), ('fneg', ('fmul', a, b))),
+   (('imul', ('ineg', a), b), ('ineg', ('fmul', a, b))),
+
    # Misc. lowering
    (('fmod', a, b), ('fsub', a, ('fmul', b, ('ffloor', ('fdiv', a, b)))), 'options->lower_fmod'),
    (('uadd_carry', a, b), ('b2i', ('ult', ('iadd', a, b), a)), 'options->lower_uadd_carry'),
-- 
2.4.10



More information about the mesa-dev mailing list