nir/algebraic: Add a seperate section for "late" optimizations
authorJason Ekstrand <jason.ekstrand@intel.com>
Tue, 24 Mar 2015 00:11:49 +0000 (17:11 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Wed, 1 Apr 2015 19:51:03 +0000 (12:51 -0700)
i965/nir: Use the late optimizations

Reviewed-by: Matt Turner <mattst88@gmail.com>
src/glsl/nir/nir.h
src/glsl/nir/nir_opt_algebraic.py
src/mesa/drivers/dri/i965/brw_fs_nir.cpp

index 7b886e3..24deb82 100644 (file)
@@ -1613,6 +1613,7 @@ void nir_convert_to_ssa(nir_shader *shader);
 void nir_convert_from_ssa(nir_shader *shader);
 
 bool nir_opt_algebraic(nir_shader *shader);
+bool nir_opt_algebraic_late(nir_shader *shader);
 bool nir_opt_constant_folding(nir_shader *shader);
 
 bool nir_opt_global_to_local(nir_shader *shader);
index ddf78be..2079235 100644 (file)
@@ -195,4 +195,13 @@ for op in ['flt', 'fge', 'feq', 'fne',
        ('bcsel', 'a', (op, 'd', 'b'), (op, 'd', 'c'))),
    ]
 
+# This section contains "late" optimizations that should be run after the
+# regular optimizations have finished.  Optimizations should go here if
+# they help code generation but do not necessarily produce code that is
+# more easily optimizable.
+late_optimizations = [
+]
+
 print nir_algebraic.AlgebraicPass("nir_opt_algebraic", optimizations).render()
+print nir_algebraic.AlgebraicPass("nir_opt_algebraic_late",
+                                  late_optimizations).render()
index 21e52fe..204e713 100644 (file)
@@ -147,6 +147,9 @@ fs_visitor::emit_nir_code()
 
    nir_optimize(nir);
 
+   nir_opt_algebraic_late(nir);
+   nir_validate_shader(nir);
+
    nir_lower_locals_to_regs(nir);
    nir_validate_shader(nir);