summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Ekstrand <jason.ekstrand@intel.com>2018-09-11 12:55:45 -0500
committerJuan A. Suarez Romero <jasuarez@igalia.com>2018-09-19 11:57:29 +0200
commitcc622c08152f0bb92567c953640bf1b796ecae08 (patch)
treeb5d885f951d4bc42f5553ee5763b528cd49199e1
parent36aa46c2ecb1860a0029cb567310db5007f1c72a (diff)
nir/opt_if: Re-materialize derefs in use blocks before peeling loops
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107879 Cc: "18.2" <mesa-stable@lists.freedesktop.org> (cherry picked from commit 864c780566b8782c4fc69b4337db768223717bd8)
-rw-r--r--src/compiler/nir/nir_opt_if.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/compiler/nir/nir_opt_if.c b/src/compiler/nir/nir_opt_if.c
index b3d0bf1decb..d8e03d6ccbb 100644
--- a/src/compiler/nir/nir_opt_if.c
+++ b/src/compiler/nir/nir_opt_if.c
@@ -180,6 +180,13 @@ opt_peel_loop_initial_if(nir_loop *loop)
}
}
+ /* We're about to re-arrange a bunch of blocks so make sure that we don't
+ * have deref uses which cross block boundaries. We don't want a deref
+ * accidentally ending up in a phi.
+ */
+ nir_rematerialize_derefs_in_use_blocks_impl(
+ nir_cf_node_get_function(&loop->cf_node));
+
/* Before we do anything, convert the loop to LCSSA. We're about to
* replace a bunch of SSA defs with registers and this will prevent any of
* it from leaking outside the loop.
@@ -423,12 +430,6 @@ nir_opt_if(nir_shader *shader)
*/
nir_lower_regs_to_ssa_impl(function->impl);
- /* Calling nir_convert_loop_to_lcssa() in opt_peel_loop_initial_if()
- * adds extra phi nodes which may not be valid if they're used for
- * something such as a deref. Remove any unneeded phis.
- */
- nir_opt_remove_phis_impl(function->impl);
-
progress = true;
}
}