[Mesa-dev] [PATCH 1/3] nir: add fceil lowering
Christian Gmeiner
christian.gmeiner at gmail.com
Mon Nov 12 19:46:11 UTC 2018
Am Mo., 12. Nov. 2018 um 19:17 Uhr schrieb Jonathan Marek <jonathan at marek.ca>:
>
> lowers ceil(x) as -floor(-x)
>
> Signed-off-by: Jonathan Marek <jonathan at marek.ca>
Reviewed-by: Christian Gmeiner <christian.gmeiner at gmail.com>
> ---
> src/compiler/nir/nir.h | 3 +++
> src/compiler/nir/nir_opt_algebraic.py | 1 +
> 2 files changed, 4 insertions(+)
>
> diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
> index dc3c729dee..f9b32a5daf 100644
> --- a/src/compiler/nir/nir.h
> +++ b/src/compiler/nir/nir.h
> @@ -2086,6 +2086,9 @@ typedef struct nir_shader_compiler_options {
> /** lowers ffract to fsub+ffloor: */
> bool lower_ffract;
>
> + /** lowers fceil to fneg+ffloor+fneg: */
> + bool lower_fceil;
> +
> bool lower_ldexp;
>
> bool lower_pack_half_2x16;
> diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
> index 8b24daddfd..8f4df891b8 100644
> --- a/src/compiler/nir/nir_opt_algebraic.py
> +++ b/src/compiler/nir/nir_opt_algebraic.py
> @@ -124,6 +124,7 @@ optimizations = [
> (('flrp at 32', a, b, c), ('fadd', ('fmul', c, ('fsub', b, a)), a), 'options->lower_flrp32'),
> (('flrp at 64', a, b, c), ('fadd', ('fmul', c, ('fsub', b, a)), a), 'options->lower_flrp64'),
> (('ffract', a), ('fsub', a, ('ffloor', a)), 'options->lower_ffract'),
> + (('fceil', a), ('fneg', ('ffloor', ('fneg', a))), 'options->lower_fceil'),
> (('~fadd', ('fmul', a, ('fadd', 1.0, ('fneg', ('b2f', c)))), ('fmul', b, ('b2f', c))), ('bcsel', c, b, a), 'options->lower_flrp32'),
> (('~fadd at 32', ('fmul', a, ('fadd', 1.0, ('fneg', c ))), ('fmul', b, c )), ('flrp', a, b, c), '!options->lower_flrp32'),
> (('~fadd at 64', ('fmul', a, ('fadd', 1.0, ('fneg', c ))), ('fmul', b, c )), ('flrp', a, b, c), '!options->lower_flrp64'),
> --
> 2.17.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
--
greets
--
Christian Gmeiner, MSc
https://christian-gmeiner.info
More information about the mesa-dev
mailing list