summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/compiler/nir/nir_opt_algebraic.py4
-rw-r--r--src/intel/compiler/brw_nir.c17
2 files changed, 20 insertions, 1 deletions
diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
index 00750fff08a..b984df0b1c7 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -1118,6 +1118,10 @@ late_optimizations = [
(('~feq', ('fadd', a, b), 0.0), ('feq', a, ('fneg', b))),
(('~fne', ('fadd', a, b), 0.0), ('fne', a, ('fneg', b))),
+ # nir_lower_to_source_mods will collapse this, but its existence during the
+ # optimization loop can prevent other optimizations.
+ (('fneg', ('fneg', a)), a),
+
(('~fge', ('fmin(is_used_once)', ('fadd(is_used_once)', a, b), ('fadd', c, d)), 0.0), ('iand', ('fge', a, ('fneg', b)), ('fge', c, ('fneg', d)))),
(('fdot2', a, b), ('fdot_replicated2', a, b), 'options->fdot_replicates'),
diff --git a/src/intel/compiler/brw_nir.c b/src/intel/compiler/brw_nir.c
index a057f286ea8..9a4afb4b778 100644
--- a/src/intel/compiler/brw_nir.c
+++ b/src/intel/compiler/brw_nir.c
@@ -912,7 +912,22 @@ brw_postprocess_nir(nir_shader *nir, const struct brw_compiler *compiler,
compiler->devinfo->gen >= 6);
}
- OPT(nir_opt_algebraic_late);
+ do {
+ progress = false;
+ if (OPT(nir_opt_algebraic_late)) {
+ /* At this late stage, anything that makes more constants will wreak
+ * havok on the vec4 backend. The handling of constants in the vec4
+ * backend is not good.
+ */
+ if (is_scalar) {
+ OPT(nir_opt_constant_folding);
+ OPT(nir_copy_prop);
+ }
+ OPT(nir_opt_dce);
+ OPT(nir_opt_cse);
+ }
+ } while (progress);
+
OPT(brw_nir_lower_conversions);