<html>
    <head>
      <base href="https://bugs.freedesktop.org/">
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [GLSL] lower_jumps with continue-statements in for-loops prevents loop unrolling"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=32211#c13">Comment # 13</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [GLSL] lower_jumps with continue-statements in for-loops prevents loop unrolling"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=32211">bug 32211</a>
              from <span class="vcard"><a class="email" href="mailto:t_arceri@yahoo.com.au" title="Timothy Arceri <t_arceri@yahoo.com.au>"> <span class="fn">Timothy Arceri</span></a>
</span></b>
        <pre>(In reply to Danylo from <a href="show_bug.cgi?id=32211#c12">comment #12</a>)
<span class="quote">> (In reply to Timothy Arceri from <a href="show_bug.cgi?id=32211#c11">comment #11</a>)
> > 
> > So all we need to do is move everything after the if into the else block and
> > remove the continue. Removing myself as assignee, this would probably be a
> > good beginners task.
> Hi,

> I've tried to do this and it works for me however it alone doesn't solve the
> problem.

> Consider the resulting nir:

>         loop {
>                 block block_1:
>                 /* preds: block_0 block_7 */
>                 vec1 32 ssa_8 = phi block_0: ssa_4, block_7: ssa_20
>                 vec1 32 ssa_9 = phi block_0: ssa_0, block_7: ssa_4
>                 vec1 32 ssa_10 = phi block_0: ssa_1, block_7: ssa_4
>                 vec1 32 ssa_11 = phi block_0: ssa_2, block_7: ssa_21
>                 vec1 32 ssa_12 = phi block_0: ssa_3, block_7: ssa_22
>                 vec4 32 ssa_13 = vec4 ssa_12, ssa_11, ssa_10, ssa_9
>                 vec1 32 ssa_14 = ige ssa_8, ssa_5
>                 /* succs: block_2 block_3 */
>                 if ssa_14 {
>                         block block_2:
>                         /* preds: block_1 */
>                         break
>                         /* succs: block_8 */
>                 } else {
>                         block block_3:
>                         /* preds: block_1 */
>                         /* succs: block_4 */
>                 }
>                 block block_4:
>                 /* preds: block_3 */
>                 vec1 32 ssa_15 = ilt ssa_6, ssa_8
>                 /* succs: block_5 block_6 */
>                 if ssa_15 {
>                         block block_5:
>                         /* preds: block_4 */
>                         vec1 32 ssa_16 = iadd ssa_8, ssa_7
>                         vec1 32 ssa_17 = load_const (0x3f800000 /* 1.000000
> */)
>                         /* succs: block_7 */
>                 } else {
>                         block block_6:
>                         /* preds: block_4 */
>                         vec1 32 ssa_18 = iadd ssa_8, ssa_7
>                         vec1 32 ssa_19 = load_const (0x3f800000 /* 1.000000
> */)
>                         /* succs: block_7 */
>                 }
>                 block block_7:
>                 /* preds: block_5 block_6 */
>                 vec1 32 ssa_20 = phi block_5: ssa_16, block_6: ssa_18
>                 vec1 32 ssa_21 = phi block_5: ssa_17, block_6: ssa_4
>                 vec1 32 ssa_22 = phi block_5: ssa_4, block_6: ssa_19
>                 /* succs: block_1 */
>         }

> Now in both "if" (block_5) and "else" (block_6) blocks there are identical
> expressions and no continue. 
> However there is no optimization to pull these identical expressions out -
> CSE pass won't do this since it's a local CSE, only global CSE would help.
> And there is no active global CSE pass, there is only Global Code Motion
> pass with Global Value Numbering and it is not enabled, enabling it
> optimizes the condition in question and in the end whole loop disappears as
> expected, however this pass doesn't look something we want since in other
> cases it hurts shaders and it is more than just global CSE.

> Any opinions on this?</span >

None of that should matter. If the continue if removed there should be nothing
stopping the loop from unrolling, and if the loop is unrolled the both ifs
should be able to be optimised away (assuming I'm reading the IR correctly). Is
this not what you are seeing?</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>