[Mesa-dev] [PATCH] nir: optimise min/max fadd combos

Timothy Arceri timothy.arceri at collabora.com
Thu Jan 12 11:20:15 UTC 2017


shader-db results BDW:

total instructions in shared programs: 13039631 -> 13039536 (-0.00%)
instructions in affected programs: 24328 -> 24233 (-0.39%)
helped: 86
HURT: 0

total cycles in shared programs: 256345938 -> 256344020 (-0.00%)
cycles in affected programs: 643654 -> 641736 (-0.30%)
helped: 37
HURT: 29
---
 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 e5b183f..8d52e6d 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -529,6 +529,10 @@ late_optimizations = [
 
    (('b2f(is_used_more_than_once)', ('inot', a)), ('bcsel', a, 0.0, 1.0)),
    (('fneg(is_used_more_than_once)', ('b2f', ('inot', a))), ('bcsel', a, -0.0, -1.0)),
+
+   # we do these late so that we don't get in the way of creating of ffmas
+   (('fmin', ('fadd(is_used_once)', '#c', a), ('fadd(is_used_once)', "#c", b)), ('fadd', c, ('fmin', a, b))),
+   (('fmax', ('fadd(is_used_once)', '#c', a), ('fadd(is_used_once)', "#c", b)), ('fadd', c, ('fmax', a, b))),
 ]
 
 print nir_algebraic.AlgebraicPass("nir_opt_algebraic", optimizations).render()
-- 
2.9.3



More information about the mesa-dev mailing list