<html>
    <head>
      <base href="https://bugs.freedesktop.org/">
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - GEN7: rendering issue on citra"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=105440#c2">Comment # 2</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - GEN7: rendering issue on citra"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=105440">bug 105440</a>
              from <span class="vcard"><a class="email" href="mailto:vadym.shovkoplias@globallogic.com" title="vadym <vadym.shovkoplias@globallogic.com>"> <span class="fn">vadym</span></a>
</span></b>
        <pre>Bisected:

2458ea95c5676807a064f24ec720f12506975402 is the first bad commit
commit 2458ea95c5676807a064f24ec720f12506975402
Author: Jason Ekstrand <<a href="mailto:jason.ekstrand@intel.com">jason.ekstrand@intel.com</a>>
Date:   Wed Sep 9 14:40:06 2015 -0700

    nir/lower_vec_to_movs: Coalesce movs on-the-fly when possible

    The old pass blindly inserted a bunch of moves into the shader with no
    concern for whether or not it was really needed.  This adds code to try and
    coalesce into the destination of the instruction providing the value.

    Shader-db results for vec4 shaders on Haswell:

       total instructions in shared programs: 1754420 -> 1747753 (-0.38%)
       instructions in affected programs:     231230 -> 224563 (-2.88%)
       helped:                                1017
       HURT:                                  2

    This approach is heavily based on a different patch by Eduardo Lima Mitev
    <<a href="mailto:elima@igalia.com">elima@igalia.com</a>>.  Eduardo's patch did this in a separate pass as opposed
    to integrating it into nir_lower_vec_to_movs.

    Reviewed-by: Eduardo Lima Mitev <<a href="mailto:elima@igalia.com">elima@igalia.com</a>>

Issue is related to optimizations in try_coalesce() function. With the simple
change bug is no longer reproducible:

diff --git a/src/compiler/nir/nir_lower_vec_to_movs.c
b/src/compiler/nir/nir_lower_vec_to_movs.c
index 711ddd3..73efa0e 100644
--- a/src/compiler/nir/nir_lower_vec_to_movs.c
+++ b/src/compiler/nir/nir_lower_vec_to_movs.c
@@ -263,8 +263,8 @@ lower_vec_to_movs_block(nir_block *block, nir_function_impl
*impl)
          if (!(vec->dest.write_mask & (1 << i)))
             continue;

-         if (!(finished_write_mask & (1 << i)))
-            finished_write_mask |= try_coalesce(vec, i);
+         //if (!(finished_write_mask & (1 << i)))
+         //   finished_write_mask |= try_coalesce(vec, i);

          if (!(finished_write_mask & (1 << i)))
             finished_write_mask |= insert_mov(vec, i, shader);

Below are the results of Shader-db on Haswell with this patch:

total instructions in shared programs: 241498 -> 241599 (0.04%)
instructions in affected programs: 25728 -> 25829 (0.39%)
helped: 14
HURT: 29

total cycles in shared programs: 142924052 -> 143021242 (0.07%)
cycles in affected programs: 85446208 -> 85543398 (0.11%)
helped: 16
HURT: 64</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>