[Mesa-dev] [PATCH 1/3] nir: add fceil lowering

Jason Ekstrand jason at jlekstrand.net
Mon Nov 12 19:43:52 UTC 2018


Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>

On Mon, Nov 12, 2018 at 12:17 PM Jonathan Marek <jonathan at marek.ca> wrote:

> lowers ceil(x) as -floor(-x)
>
> Signed-off-by: Jonathan Marek <jonathan at marek.ca>
> ---
>  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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20181112/0ba9ddff/attachment.html>


More information about the mesa-dev mailing list