[Mesa-dev] [PATCH] nir: add some comparison simplifications

Timothy Arceri tarceri at itsqueeze.com
Fri Mar 16 03:53:05 UTC 2018


These can be found in the Tomb Raider shaders, eliminating them
helps unroll more loops.
---
 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 c9575e6be4..56dfc53043 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -152,6 +152,10 @@ optimizations = [
    (('inot', ('ige', a, b)), ('ilt', a, b)),
    (('inot', ('ieq', a, b)), ('ine', a, b)),
    (('inot', ('ine', a, b)), ('ieq', a, b)),
+   (('ine', ('b2i', ('ige', a, b)), 0), ('ige', a, b)),
+   (('ine', ('b2i', ('ilt', a, b)), 0), ('ilt', a, b)),
+   (('ine', ('b2i', ('ult', a, b)), 0), ('ult', a, b)),
+   (('ine', ('b2i', ('ine', a, b)), 0), ('ine', a, b)),
 
    # 0.0 >= b2f(a)
    # b2f(a) <= 0.0
-- 
2.14.3



More information about the mesa-dev mailing list