[Mesa-dev] [PATCH 11/11] glsl: Optimize X / X == 1
Roland Scheidegger
sroland at vmware.com
Thu Aug 7 14:47:04 PDT 2014
It also doesn't hold true for inf and nan inputs with ieee754 math (just
like 0 should be all nan, and in particular making a 1.0 out of a nan
that way sounds sort of broken). Earlier glsl versions though had pretty
much undefined behavior for infs/nans. Newer versions have more clearly
defined behavior, but still say "NaNs or not required to be generated"
and "operations and built-in functions that operate on a NaN are not
required to return a NaN as the result". Thus my guess is that this is ok.
Roland
Am 07.08.2014 23:13, schrieb Patrick Baggett:
> 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
> <mailto:thomashelland90 at gmail.com>> wrote:
>
> From: Thomas Helland <thomashelland90 at gmail.com
> <mailto:thomashelland90 at gmail.com>>
>
> Shows no changes for shader-db.
>
> Signed-off-by: Thomas Helland <thomashelland90 at gmail.com
> <https://urldefense.proofpoint.com/v1/url?u=http://gmail.com&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=F4msKE2WxRzA%2BwN%2B25muztFm5TSPwE8HKJfWfR2NgfY%3D%0A&m=024s8S3qVXdOk1UaX8WU6nPiFZ1b0BcBbWJOFGPgJFM%3D%0A&s=57d5e398c7b48e96a78b2903fd2a9b3310fb2ff07b32213a434528a43bfbb1e2>>
> ---
> 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 <mailto:mesa-dev at lists.freedesktop.org>
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
> <https://urldefense.proofpoint.com/v1/url?u=http://lists.freedesktop.org/mailman/listinfo/mesa-dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=F4msKE2WxRzA%2BwN%2B25muztFm5TSPwE8HKJfWfR2NgfY%3D%0A&m=024s8S3qVXdOk1UaX8WU6nPiFZ1b0BcBbWJOFGPgJFM%3D%0A&s=075157b65ef32d58d0596ad07524450cd8f32351f15292269ee125be3031acde>
>
>
>
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://urldefense.proofpoint.com/v1/url?u=http://lists.freedesktop.org/mailman/listinfo/mesa-dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=F4msKE2WxRzA%2BwN%2B25muztFm5TSPwE8HKJfWfR2NgfY%3D%0A&m=024s8S3qVXdOk1UaX8WU6nPiFZ1b0BcBbWJOFGPgJFM%3D%0A&s=075157b65ef32d58d0596ad07524450cd8f32351f15292269ee125be3031acde
>
More information about the mesa-dev
mailing list