[Mesa-dev] [PATCH 1/4] nir: add option to lower slt/sge/seq/sne

Kenneth Graunke kenneth at whitecape.org
Tue Mar 31 17:54:49 PDT 2015


On Tuesday, March 31, 2015 06:57:30 PM Rob Clark wrote:
> From: Rob Clark <robclark at freedesktop.org>
> 
> In freedreno these get implemented as the matching f* instruction plus a
> u2f to convert the result to float 1.0/0.0.  But less lines of code to
> just let nir_opt_algebraic handle this for us, plus opens up some small
> window for other opt passes to improve (ie. if some shader ended up with
> both a flt and slt with same src args, for example).
> 
> v2: use b2f rather than u2f
> 
> Signed-off-by: Rob Clark <robclark at freedesktop.org>
> ---
>  src/glsl/nir/nir.h                | 3 +++
>  src/glsl/nir/nir_opt_algebraic.py | 4 ++++
>  2 files changed, 7 insertions(+)
> 
> diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
> index e980635..74927e5 100644
> --- a/src/glsl/nir/nir.h
> +++ b/src/glsl/nir/nir.h
> @@ -1372,6 +1372,9 @@ typedef struct nir_shader_compiler_options {
>     /** lowers fneg and ineg to fsub and isub. */
>     bool lower_negate;
>  

                                              should be b2f
                                                        |||
                                                        vvv
> +   /* lower {slt,sge,seq,sne} to {flt,fge,feq,fne} + u2f: */
> +   bool lower_scmp;
> +

Patches 1-2 are:
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

>     /**
>      * Does the driver support real 32-bit integers?  (Otherwise, integers
>      * are simulated by floats.)
> diff --git a/src/glsl/nir/nir_opt_algebraic.py b/src/glsl/nir/nir_opt_algebraic.py
> index 20ec4d3..506d4df 100644
> --- a/src/glsl/nir/nir_opt_algebraic.py
> +++ b/src/glsl/nir/nir_opt_algebraic.py
> @@ -96,6 +96,10 @@ optimizations = [
>     (('fsat', a), ('fmin', ('fmax', a, 0.0), 1.0), 'options->lower_fsat'),
>     (('fsat', ('fsat', a)), ('fsat', a)),
>     (('fmin', ('fmax', ('fmin', ('fmax', a, 0.0), 1.0), 0.0), 1.0), ('fmin', ('fmax', a, 0.0), 1.0)),
> +   (('slt', a, b), ('b2f', ('flt', a, b)), 'options->lower_scmp'),
> +   (('sge', a, b), ('b2f', ('fge', a, b)), 'options->lower_scmp'),
> +   (('seq', a, b), ('b2f', ('feq', a, b)), 'options->lower_scmp'),
> +   (('sne', a, b), ('b2f', ('fne', a, b)), 'options->lower_scmp'),
>     # Emulating booleans
>     (('fmul', ('b2f', a), ('b2f', b)), ('b2f', ('iand', a, b))),
>     (('fsat', ('fadd', ('b2f', a), ('b2f', b))), ('b2f', ('ior', a, b))),
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150331/5d5374fd/attachment.sig>


More information about the mesa-dev mailing list