<html>
<head>
<base href="https://bugs.freedesktop.org/">
</head>
<body><span class="vcard"><a class="email" href="mailto:jason@jlekstrand.net" title="Jason Ekstrand <jason@jlekstrand.net>"> <span class="fn">Jason Ekstrand</span></a>
</span> changed
<a class="bz_bug_link
bz_status_NEW "
title="NEW - Assertion fails in nir_opt_remove_phis.c during compilation of SPIR-V shader"
href="https://bugs.freedesktop.org/show_bug.cgi?id=111069">bug 111069</a>
<br>
<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>What</th>
<th>Removed</th>
<th>Added</th>
</tr>
<tr>
<td style="text-align:right;">CC</td>
<td>
</td>
<td>caio.oliveira@intel.com, cwabbott0@gmail.com, t_arceri@yahoo.com.au
</td>
</tr></table>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW - Assertion fails in nir_opt_remove_phis.c during compilation of SPIR-V shader"
href="https://bugs.freedesktop.org/show_bug.cgi?id=111069#c2">Comment # 2</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW - Assertion fails in nir_opt_remove_phis.c during compilation of SPIR-V shader"
href="https://bugs.freedesktop.org/show_bug.cgi?id=111069">bug 111069</a>
from <span class="vcard"><a class="email" href="mailto:jason@jlekstrand.net" title="Jason Ekstrand <jason@jlekstrand.net>"> <span class="fn">Jason Ekstrand</span></a>
</span></b>
<pre>Ugh... This one gets sticky. The problem is a rather strange sequence of
events:
1. nir_opt_dead_cf cleans up the outer `if (true) {`.
2. nir_opt_if figures out the condition inside condition and turns `while
(gl_FragCoord.x < 0.0)` into `while (1)`.
3. nir_opt_dead_cf cleans up an if statement with the break that was the only
exit from a loop.
4. Because the deleted break was the only exit of the loop, now unreachable
code later in the shader still consumes values generated by the loop (dead_cf
only cleans up phis, not things which exit the dead code without a phi).
5. Loop unrolling comes along and attempts to partially unroll the loop (I
think? I'm not actually sure on this one.) and inserts LCSSA phis which have
no sources.
6. nir_opt_remove_phis dies on the existence of phis with zero sources.
So what do we do about it? Technically, 4. is ok because the way dominance is
defined, unreachable code is vacuously dominated by all other code in the
shader. I see a few options:
1. Detect when we've deleted the last exit of a loop and simply delete the
entire loop immediately in nir_opt_dead_cf.
2. Don't generate LCSSA phis if the loop exit is unreachable
3. Make nir_opt_remove_phis replace phis with zero sources with ssa_undef
instructions
4. All of the above?
Thoughs?</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the QA Contact for the bug.</li>
</ul>
</body>
</html>