[Mesa-dev] [PATCH 11/11] glsl: Optimize X / X == 1

Patrick Baggett baggett.patrick at gmail.com
Thu Aug 7 14:13:11 PDT 2014


Would this be conformant to GLSL spec if X had a runtime value of 0? Seems
unsafe to replace X / X with 1 without a runtime test...maybe GLSL spec
allows such optimizations.


On Thu, Aug 7, 2014 at 3:51 PM, <thomashelland90 at gmail.com> wrote:

> From: Thomas Helland <thomashelland90 at gmail.com>
>
> Shows no changes for shader-db.
>
> Signed-off-by: Thomas Helland <thomashelland90 at gmail.com>
> ---
>  src/glsl/opt_algebraic.cpp | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp
> index 21bf332..a49752d 100644
> --- a/src/glsl/opt_algebraic.cpp
> +++ b/src/glsl/opt_algebraic.cpp
> @@ -513,6 +513,8 @@ ir_algebraic_visitor::handle_expression(ir_expression
> *ir)
>        }
>        if (is_vec_one(op_const[1]))
>          return ir->operands[0];
> +      if(ir->operands[0]->equals(ir->operands[1]))
> +         return new(mem_ctx) ir_constant(1.0f, 1);
>        break;
>
>     case ir_binop_dot:
> --
> 2.0.3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140807/88979efd/attachment-0001.html>


More information about the mesa-dev mailing list