[Mesa-dev] [PATCH 08/16] glsl: Add abs to get_range
Ian Romanick
idr at freedesktop.org
Wed Nov 19 10:51:00 PST 2014
On 11/16/2014 05:51 PM, Thomas Helland wrote:
> ---
> src/glsl/opt_minmax.cpp | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/src/glsl/opt_minmax.cpp b/src/glsl/opt_minmax.cpp
> index b925aaa..a48d4d8 100644
> --- a/src/glsl/opt_minmax.cpp
> +++ b/src/glsl/opt_minmax.cpp
> @@ -283,6 +283,16 @@ get_range(ir_rvalue *rval)
> r1 = get_range(expr->operands[1]);
> return combine_range(r0, r1, expr->operation == ir_binop_min);
>
> + case ir_unop_abs:
> + r0 = get_range(expr->operands[0]);
> + if (is_greater_than_zero(r0.low))
> + low = r0.low;
> + else
> + low = new(mem_ctx) ir_constant(0.0f);
If both low and high are < 0, you can get a tighter range. In that
case, the new low is abs(old high) and the new high is abs(old low).
> + if (r0.high && r0.low)
> + high = larger_constant(r0.high, abs(r0.low)->constant_expression_value());
> + return minmax_range(low, high);
> +
> case ir_unop_sin:
> case ir_unop_sin_reduced:
> case ir_unop_cos:
>
More information about the mesa-dev
mailing list