<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 10 March 2014 17:23, Ian Romanick <span dir="ltr"><<a href="mailto:idr@freedesktop.org" target="_blank">idr@freedesktop.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I had a pretty similar patch on the top of my pow-optimization branch.<br>
I also expand x**3 and x**4.  I had hoped that would enable some cases<br>
to expand then merge to MADs.  It should also be faster on older GENs<br>
where POW perf sucks.  I didn't send it out because I wanted to add a<br>
similar optimization in the back end that would turn x*x*x*x back into<br>
x**4 on GPUs where the POW would be faster.<br></blockquote><div><br></div><div>Be careful with that one, though: pow is undefined when x < 0, so x*x*x*x => pow(x, 4) isn't a valid conversion in general--it only works if you know the operation started off as a pow in the first place.  (Note: you can do x*x*x*x => pow(abs(x), 4), but that doesn't generalize to odd powers).</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
I also didn't have anything in shader-db that benefitted from x**2 or<br>
x**3.  It seems like there were a couple that would be modified by a<br>
x**5 flattening, but I think that would universally be slower....<br>
<div class="im HOEnZb"><br>
On 03/10/2014 03:54 PM, Matt Turner wrote:<br>
> Cuts two instructions out of SynMark's Gl32VSInstancing benchmark.<br>
> ---<br>
>  src/glsl/opt_algebraic.cpp | 8 ++++++++<br>
>  1 file changed, 8 insertions(+)<br>
><br>
> diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp<br>
> index 5c49a78..8494bd9 100644<br>
> --- a/src/glsl/opt_algebraic.cpp<br>
> +++ b/src/glsl/opt_algebraic.cpp<br>
> @@ -528,6 +528,14 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)<br>
>        if (is_vec_two(op_const[0]))<br>
>           return expr(ir_unop_exp2, ir->operands[1]);<br>
><br>
> +      if (is_vec_two(op_const[1])) {<br>
> +         ir_variable *x = new(ir) ir_variable(ir->operands[1]->type, "x",<br>
> +                                              ir_var_temporary);<br>
> +         base_ir->insert_before(x);<br>
> +         base_ir->insert_before(assign(x, ir->operands[0]));<br>
> +         return mul(x, x);<br>
> +      }<br>
> +<br>
>        break;<br>
><br>
>     case ir_unop_rcp:<br>
><br>
<br>
</div><div class="HOEnZb"><div class="h5">_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</div></div></blockquote></div><br></div></div>