<div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Feb 22, 2019 at 5:21 PM Timothy Arceri <<a href="mailto:tarceri@itsqueeze.com">tarceri@itsqueeze.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Rather than only lowering if all srcs are scalarizable we instead<br>
check that at least one src is scalarizable.<br>
<br>
We remove undef type from the is_phi_src_scalarizable() as using<br>
this as a check just cause regressions when it is the only<br>
scalarizable src.<br>
<br>
total instructions in shared programs: 13219105 -> 13024547 (-1.47%)<br>
instructions in affected programs: 1153797 -> 959239 (-16.86%)<br>
helped: 581<br>
HURT: 74<br>
<br>
total cycles in shared programs: 333968972 -> 324807922 (-2.74%)<br>
cycles in affected programs: 129809402 -> 120648352 (-7.06%)<br>
helped: 571<br>
HURT: 131<br>
<br>
total spills in shared programs: 57947 -> 29130 (-49.73%)<br>
spills in affected programs: 53364 -> 24547 (-54.00%)<br>
helped: 351<br>
HURT: 0<br>
<br>
total fills in shared programs: 51310 -> 25468 (-50.36%)<br>
fills in affected programs: 44882 -> 19040 (-57.58%)<br>
helped: 351<br>
HURT: 0<br>
---<br>
 src/compiler/nir/nir_lower_phis_to_scalar.c | 10 +++++++---<br>
 1 file changed, 7 insertions(+), 3 deletions(-)<br>
<br>
diff --git a/src/compiler/nir/nir_lower_phis_to_scalar.c b/src/compiler/nir/nir_lower_phis_to_scalar.c<br>
index 16001f73685..b2ca89d3513 100644<br>
--- a/src/compiler/nir/nir_lower_phis_to_scalar.c<br>
+++ b/src/compiler/nir/nir_lower_phis_to_scalar.c<br>
@@ -75,7 +75,6 @@ is_phi_src_scalarizable(nir_phi_src *src,<br>
       return should_lower_phi(nir_instr_as_phi(src_instr), state);<br>
<br>
    case nir_instr_type_load_const:<br>
-   case nir_instr_type_ssa_undef:<br></blockquote><div><br></div><div>Instead of removing it, would you mind handling it as</div><div><br></div><div>case nir_instr_type_ssa_undef:</div><div>    /* The caller of this function is going to OR the results and we don't want undefs to count so we return false. */</div><div>   return false;</div><div><br></div><div>With that,</div><div><br></div><div>Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
       /* These are trivially scalarizable */<br>
       return true;<br>
<br>
@@ -150,11 +149,16 @@ should_lower_phi(nir_phi_instr *phi, struct lower_phis_to_scalar_state *state)<br>
     */<br>
    entry = _mesa_hash_table_insert(state->phi_table, phi, (void *)(intptr_t)1);<br>
<br>
-   bool scalarizable = true;<br>
+   bool scalarizable = false;<br>
<br>
    nir_foreach_phi_src(src, phi) {<br>
+      /* This loop ignores srcs that are not scalarizable because its likely<br>
+       * still worth copying to temps if another phi source is scalarizable.<br>
+       * This reduces register spilling by a huge amount in the i965 driver for<br>
+       * Deus Ex: MD.<br>
+       */<br>
       scalarizable = is_phi_src_scalarizable(src, state);<br>
-      if (!scalarizable)<br>
+      if (scalarizable)<br>
          break;<br>
    }<br>
<br>
-- <br>
2.20.1<br>
<br>
</blockquote></div></div>