[Mesa-dev] [PATCH] glsl: skip mul by zero opt for floating point expression
Ilia Mirkin
imirkin at alum.mit.edu
Mon Jul 2 15:32:04 UTC 2018
On Mon, Jul 2, 2018 at 11:22 AM, vadym.shovkoplias
<vadim.shovkoplias at gmail.com> wrote:
> From: Vadym Shovkoplias <vadym.shovkoplias at globallogic.com>
>
> One of the operands can be NaN and multiplication by zero
> should also result to NaN value. E.g:
See my comment in https://bugs.freedesktop.org/show_bug.cgi?id=107089#c1
>
> float Temp = 0.0;
> void main()
> {
> Temp = log2(Temp);
> Temp = Temp * 0.0;
> isnan(Temp);
> ...
> }
>
> here Temp should be NaN and isnan() should return true.
>
> Signed-off-by: Vadym Shovkoplias <vadym.shovkoplias at globallogic.com>
> ---
> src/compiler/glsl/opt_algebraic.cpp | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/compiler/glsl/opt_algebraic.cpp b/src/compiler/glsl/opt_algebraic.cpp
> index ff4be26957..2d01575bb3 100644
> --- a/src/compiler/glsl/opt_algebraic.cpp
> +++ b/src/compiler/glsl/opt_algebraic.cpp
> @@ -590,7 +590,8 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
> if (is_vec_one(op_const[1]))
> return ir->operands[0];
>
> - if (is_vec_zero(op_const[0]) || is_vec_zero(op_const[1]))
> + if ((is_vec_zero(op_const[0]) || is_vec_zero(op_const[1])) &&
> + !ir->type->is_float() && !ir->type->is_double())
> return ir_constant::zero(ir, ir->type);
>
> if (is_vec_negative_one(op_const[0]))
> --
> 2.18.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list