[Mesa-dev] [PATCH 14/31] nir/algebraic: Disable b2f lowering and two optimizations

Ian Romanick idr at freedesktop.org
Mon Oct 22 23:26:13 UTC 2018


On 10/22/2018 03:13 PM, Jason Ekstrand wrote:
> These all assume the 0/~0 representation of booleans.  We'll turn them
> back on before too long.
> ---
>  src/compiler/nir/nir_opt_algebraic.py | 5 -----
>  1 file changed, 5 deletions(-)
> 
> diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
> index 8b24daddfdc..5a4e78e8e0e 100644
> --- a/src/compiler/nir/nir_opt_algebraic.py
> +++ b/src/compiler/nir/nir_opt_algebraic.py
> @@ -436,9 +436,7 @@ optimizations = [
>     (('imul', ('b2i', a), ('b2i', b)), ('b2i', ('iand', a, b))),
>     (('fmul', ('b2f', a), ('b2f', b)), ('b2f', ('iand', a, b))),
>     (('fsat', ('fadd', ('b2f', a), ('b2f', b))), ('b2f', ('ior', a, b))),
> -   (('iand', 'a at bool', 1.0), ('b2f', a), '!options->lower_b2f'),
>     # True/False are ~0 and 0 in NIR.  b2i of True is 1, and -1 is ~0 (True).

Is this comment still true at the end of the series?  Should it also change?

> -   (('ineg', ('b2i at 32', a)), a),
>     (('flt', ('fneg', ('b2f', a)), 0), a), # Generated by TGSI KILL_IF.
>     (('flt', ('fsub', 0.0, ('b2f', a)), 0), a), # Generated by TGSI KILL_IF.
>     # Comparison with the same args.  Note that these are not done for
> @@ -917,9 +915,6 @@ late_optimizations = [
>     # we do these late so that we don't get in the way of creating ffmas
>     (('fmin', ('fadd(is_used_once)', '#c', a), ('fadd(is_used_once)', '#c', b)), ('fadd', c, ('fmin', a, b))),
>     (('fmax', ('fadd(is_used_once)', '#c', a), ('fadd(is_used_once)', '#c', b)), ('fadd', c, ('fmax', a, b))),
> -
> -   # Lowered for backends without a dedicated b2f instruction
> -   (('b2f at 32', a), ('iand', a, 1.0), 'options->lower_b2f'),

I've never understood the point of this.  The backend should just
generate the iand instruction as it's implementation of b2f.  This is
what i965 does.  Converting the b2f at the late hour doesn't give any
opportunities to enable other optimizations, so it seems pretty useless.

>  ]
>  
>  print(nir_algebraic.AlgebraicPass("nir_opt_algebraic", optimizations).render())
> 



More information about the mesa-dev mailing list