<html>
    <head>
      <base href="https://bugs.freedesktop.org/">
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Adding a single-iteration do-while loop in a GLSL shader leads to a different image"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=101648#c2">Comment # 2</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Adding a single-iteration do-while loop in a GLSL shader leads to a different image"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=101648">bug 101648</a>
              from <span class="vcard"><a class="email" href="mailto:imirkin@alum.mit.edu" title="Ilia Mirkin <imirkin@alum.mit.edu>"> <span class="fn">Ilia Mirkin</span></a>
</span></b>
        <pre>[Just some musings, figured I'd take a closer look... feel free to ignore.]

GLSL seems fine (note use of return_flag):

        (loop (
          (if (expression bool >= (expression float i2f (var_ref i@2) ) (swiz x
(var_ref gl_FragCoord) )) (
            (assign  (x) (var_ref return_value)  (var_ref s) ) 
            (assign  (x) (var_ref return_flag)  (constant bool (1)) ) 
            break
          )
          ())

          (if (expression bool >= (swiz x (var_ref gl_FragCoord) )(constant
float (0.000000)) ) (
            break
          )
          ())

        ))

        (if (var_ref return_flag) (
          break
        )

And the NIR seems OK:

(return_flag)
                vec1 32 ssa_39 = phi block_9: ssa_7, block_12: ssa_19
                /* succs: block_16 block_17 */
                if ssa_39 {
                        block block_16:
                        /* preds: block_15 */
                        break

And ssa_7 is 0xffffffff as expected (from block_9 which is the one where
return_flag is set to 1)

ssa_19 is defined in the outer loop:

                vec1 32 ssa_19 = phi block_0: ssa_1, block_18: ssa_39

Where ssa_1 == 0, and ssa_39 is defined above.

And the register-ized NIR seems fine too at first glance, at least as far as
this return business is concerned.

However looking at the SIMD8 shader, the control flow seems off. This is where
I get a lot weaker, but I believe that I've found the register for the
return_flag, but I don't see any control flow that depends on it. There's also
only 1 while loop, rather than nested (it seems).</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the QA Contact for the bug.</li>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>