aco: fix rebase error from GS copy shader support
authorRhys Perry <pendingchaos02@gmail.com>
Tue, 28 Jan 2020 13:29:14 +0000 (13:29 +0000)
committerMarge Bot <eric+marge@anholt.net>
Tue, 28 Jan 2020 13:50:53 +0000 (13:50 +0000)
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Fixes: f8f7712666b ('aco: implement GS copy shaders')
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3601>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3601>

src/amd/compiler/aco_instruction_selection_setup.cpp

index 3aef36e91beaf84e994b9c471ec6d56b0ab99bf7..c23f59e30a9cf51b355ce37dbd2460acf87acb01 100644 (file)
@@ -884,6 +884,21 @@ setup_nir(isel_context *ctx, nir_shader *nir)
       NIR_PASS(more_algebraic, nir, nir_opt_algebraic);
    }
 
+   /* 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 = false;
+      NIR_PASS(more_late_algebraic, nir, nir_opt_algebraic_late);
+      NIR_PASS_V(nir, nir_opt_constant_folding);
+      NIR_PASS_V(nir, nir_copy_prop);
+      NIR_PASS_V(nir, nir_opt_dce);
+      NIR_PASS_V(nir, nir_opt_cse);
+   }
+
    /* cleanup passes */
    nir_lower_load_const_to_scalar(nir);
    nir_opt_shrink_load(nir);