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

Kenneth Graunke kenneth at whitecape.org
Wed Aug 10 02:30:16 UTC 2016


On Haswell (GL 3.3):

total instructions in shared programs: 6211485 -> 6211427 (-0.00%)
instructions in affected programs: 16260 -> 16202 (-0.36%)
helped: 25
HURT: 37

On Broadwell (GL 4.4):

total instructions in shared programs: 11640288 -> 11640218 (-0.00%)
instructions in affected programs: 16313 -> 16243 (-0.43%)
helped: 27
HURT: 37

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 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 4e9896f..ef87d4d 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -135,6 +135,9 @@ optimizations = [
    # inot(a)
    (('fge', 0.0, ('b2f', a)), ('inot', a)),
 
+   # -(b2f(a) + b2f(b)) >= 0 becomes !(a || b)
+   (('fge', ('fneg', ('fadd', ('b2f', 'a at bool'), ('b2f', 'b at bool'))), 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.0



More information about the mesa-dev mailing list