[Mesa-dev] [PATCH 03/10] nir: Turn -(b2f(a) + b2f(b)) >= 0 into !(a || b).

Timothy Arceri timothy.arceri at collabora.com
Sat Jan 7 11:58:33 UTC 2017


From: Kenneth Graunke <kenneth at whitecape.org>

On BDW:

total instructions in shared programs: 13078708 -> 13078787 (0.00%)
instructions in affected programs: 15926 -> 16005 (0.50%)
helped: 19
HURT: 43

total cycles in shared programs: 256561142 -> 256562762 (0.00%)
cycles in affected programs: 126122 -> 127742 (1.28%)
helped: 21
HURT: 37

v2: Rely on b2f's operands being a well-formed boolean (Connor, Eric).
    Fix typo in commit title (Patrick).

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com> [v1]
Reviewed-by: Timothy Arceri <timothy.arceri at collabora.com>
---
 src/compiler/nir/nir_opt_algebraic.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
index 434881f..fa9f3f1 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -150,6 +150,9 @@ optimizations = [
    # inot(a)
    (('fge', 0.0, ('b2f', a)), ('inot', a)),
 
+   # -(b2f(a) + b2f(b)) >= 0 becomes !(a || b)
+   (('fge', ('fneg', ('fadd', ('b2f', a), ('b2f', b))), 0.0), ('inot', ('ior', a, b))),
+
    # 0.0 < fabs(a)
    # fabs(a) > 0.0
    # fabs(a) != 0.0 because fabs(a) must be >= 0
-- 
2.9.3



More information about the mesa-dev mailing list