title: Are HLSL loops broken?
body: <p>I've been messing around with HLSL and Direct3D12 and encountered something strange. Here's a minimal reproducible example:</p>
  <pre><code>float4 main() : SV_TARGET
  {
      uint indices[3];
      indices[0] = 0;
      uint l = 0;
  
      [loop] while (true) {
          if (indices[l] == 1)
              return float4(1.0f, 0.0f, 0.0f, 1.0f);
          indices[l + 1] = 1;
          if (++l == 2)
              break;
      }
      return float4(0.0f, 1.0f, 0.0f, 1.0f);
  }
  </code></pre>
  <p>The code is completely pointless, but at least in my eyes, there shouldn't be a problem with it, and it should return a red color. However, compiling and running this (with HLSL version 5_0, with and without optimizations) does strangely enough <em>neither</em> return red nor green; it doesn't seem to return anything at all, as even though I have all blending disabled, nothing is being drawn.</p>
  <p>Changing seemingly meaningless things, like removing the <code>[loop]</code>  tag or changing the size of <code>indices</code> to 2, gets rid of the strange behavior.</p>
  <p>Does anyone know what's going on here? Are HLSL loops simply broken?</p>