<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Thanks a lot for fixing this,<br>
</p>
<p>Reviewed-by: Samuel Iglesias Gonsálvez <a
class="moz-txt-link-rfc2396E" href="mailto:siglesias@igalia.com"><siglesias@igalia.com></a></p>
<div class="moz-cite-prefix">Sam<br>
<br>
On 26/06/18 01:47, Jason Ekstrand wrote:<br>
</div>
<blockquote type="cite"
cite="mid:20180625234707.17546-1-jason.ekstrand@intel.com">
<pre wrap="">Now that SSA values can be derefs and they have special rules, we have
to be a bit more careful about our LCSSA phis. In particular, we need
to clean up in case LCSSA ended up creating a phi node for a deref.
This fixes validation issues with some Vulkan CTS tests with the new
deref instructions.
Cc: Samuel Iglesias Gonsálvez <a class="moz-txt-link-rfc2396E" href="mailto:siglesias@igalia.com"><siglesias@igalia.com></a>
---
src/compiler/nir/nir.h | 1 +
src/compiler/nir/nir_opt_if.c | 7 +++++++
src/compiler/nir/nir_opt_remove_phis.c | 6 +++---
3 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index be7b92dd7d2..c16ce547642 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -2903,6 +2903,7 @@ bool nir_opt_move_load_ubo(nir_shader *shader);
bool nir_opt_peephole_select(nir_shader *shader, unsigned limit);
+bool nir_opt_remove_phis_impl(nir_function_impl *impl);
bool nir_opt_remove_phis(nir_shader *shader);
bool nir_opt_shrink_load(nir_shader *shader);
diff --git a/src/compiler/nir/nir_opt_if.c b/src/compiler/nir/nir_opt_if.c
index 863ca630fbd..ec5bf1c9027 100644
--- a/src/compiler/nir/nir_opt_if.c
+++ b/src/compiler/nir/nir_opt_if.c
@@ -403,6 +403,13 @@ nir_opt_if(nir_shader *shader)
* that don't dominate their uses.
*/
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;
}
}
diff --git a/src/compiler/nir/nir_opt_remove_phis.c b/src/compiler/nir/nir_opt_remove_phis.c
index b20ff729156..e2d3994c49e 100644
--- a/src/compiler/nir/nir_opt_remove_phis.c
+++ b/src/compiler/nir/nir_opt_remove_phis.c
@@ -139,8 +139,8 @@ remove_phis_block(nir_block *block, nir_builder *b)
return progress;
}
-static bool
-remove_phis_impl(nir_function_impl *impl)
+bool
+nir_opt_remove_phis_impl(nir_function_impl *impl)
{
bool progress = false;
nir_builder bld;
@@ -165,7 +165,7 @@ nir_opt_remove_phis(nir_shader *shader)
nir_foreach_function(function, shader)
if (function->impl)
- progress = remove_phis_impl(function->impl) || progress;
+ progress = nir_opt_remove_phis_impl(function->impl) || progress;
return progress;
}
</pre>
</blockquote>
<br>
</body>
</html>