<p dir="ltr"><br>
On Mar 30, 2016 4:24 PM, "Ian Romanick" <<a href="mailto:idr@freedesktop.org">idr@freedesktop.org</a>> wrote:<br>
><br>
> From: Ian Romanick <<a href="mailto:ian.d.romanick@intel.com">ian.d.romanick@intel.com</a>><br>
><br>
> Oddly, this did not affect the shader where I first noticed the pattern.<br>
> That particular shader doesn't get its if-statement converted to a bcsel<br>
> because there are two assignments in the else-statement. This led to me<br>
> submitting <a href="https://bugs.freedesktop.org/show_bug.cgi?id=94747">https://bugs.freedesktop.org/show_bug.cgi?id=94747</a>.</p>
<p dir="ltr">We have code for this. It's called nir_opt_peephole_select. We just need to make it more aggressive.</p>
<p dir="ltr">> shader-db results:<br>
><br>
> Sandy Bridge<br>
> total instructions in shared programs: 8467384 -> 8467069 (-0.00%)<br>
> instructions in affected programs: 36594 -> 36279 (-0.86%)<br>
> helped: 46<br>
> HURT: 0<br>
><br>
> total cycles in shared programs: 117573448 -> 117568518 (-0.00%)<br>
> cycles in affected programs: 339114 -> 334184 (-1.45%)<br>
> helped: 46<br>
> HURT: 0<br>
><br>
> Ivy Bridge / Haswell / Broadwell / Skylake:<br>
> total instructions in shared programs: 7774258 -> 7773999 (-0.00%)<br>
> instructions in affected programs: 30874 -> 30615 (-0.84%)<br>
> helped: 46<br>
> HURT: 0<br>
><br>
> total cycles in shared programs: 65739190 -> 65734530 (-0.01%)<br>
> cycles in affected programs: 180380 -> 175720 (-2.58%)<br>
> helped: 45<br>
> HURT: 1<br>
><br>
> No change on G45 or Ironlake.<br>
><br>
> I also tried these expressions, but none of them affected any shaders in<br>
> shader-db:<br>
><br>
> (('bcsel', a, 'a@bool', 'b@bool'), ('ior', a, b)),<br>
> (('bcsel', a, 'b@bool', False), ('iand', a, b)),<br>
> (('bcsel', a, 'b@bool', 'a@bool'), ('iand', a, b)),<br>
><br>
> Signed-off-by: Ian Romanick <<a href="mailto:ian.d.romanick@intel.com">ian.d.romanick@intel.com</a>><br>
> ---<br>
> src/compiler/nir/nir_opt_algebraic.py | 1 +<br>
> 1 file changed, 1 insertion(+)<br>
><br>
> diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py<br>
> index 5363323..59c3c36 100644<br>
> --- a/src/compiler/nir/nir_opt_algebraic.py<br>
> +++ b/src/compiler/nir/nir_opt_algebraic.py<br>
> @@ -126,6 +126,7 @@ optimizations = [<br>
> (('bcsel', ('flt', a, b), b, a), ('fmax', a, b)),<br>
> (('bcsel', ('inot', 'a@bool'), b, c), ('bcsel', a, c, b)),<br>
> (('bcsel', a, ('bcsel', a, b, c), d), ('bcsel', a, b, d)),<br>
> + (('bcsel', a, True, 'b@bool'), ('ior', a, b)),</p>
<p dir="ltr">Seems reasonable</p>
<p dir="ltr">Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>></p>
<p dir="ltr">> (('fmin', a, a), a),<br>
> (('fmax', a, a), a),<br>
> (('imin', a, a), a),<br>
> --<br>
> 2.5.5<br>
><br>
> _______________________________________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</p>