freedreno: Enable the nir_opt_algebraic_late() pass.
authorDaniel Schürmann <daniel@schuermann.dev>
Fri, 27 Sep 2019 10:49:06 +0000 (12:49 +0200)
committerDaniel Schürmann <daniel@schuermann.dev>
Mon, 30 Sep 2019 09:44:10 +0000 (09:44 +0000)
Reviewed-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
src/freedreno/ir3/ir3_nir.c

index 0a62523cccea99725015f94af35d11089061cd51..9342c9d299b103199ba6e708df7cce135360283c 100644 (file)
@@ -263,6 +263,20 @@ ir3_optimize_nir(struct ir3_shader *shader, nir_shader *s,
        if (ubo_progress || idiv_progress)
                ir3_optimize_loop(s);
 
+       /* Do late algebraic optimization to turn add(a, neg(b)) back into
+       * subs, then the mandatory cleanup after algebraic.  Note that it may
+       * produce fnegs, and if so then we need to keep running to squash
+       * fneg(fneg(a)).
+       */
+       bool more_late_algebraic = true;
+       while (more_late_algebraic) {
+               more_late_algebraic = OPT(s, nir_opt_algebraic_late);
+               OPT_V(s, nir_opt_constant_folding);
+               OPT_V(s, nir_copy_prop);
+               OPT_V(s, nir_opt_dce);
+               OPT_V(s, nir_opt_cse);
+       }
+
        OPT_V(s, nir_remove_dead_variables, nir_var_function_temp);
 
        OPT_V(s, nir_opt_sink, nir_move_const_undef);