[Mesa-dev] [PATCH] nir: add some comparison simplifications

Ian Romanick idr at freedesktop.org
Fri Mar 16 14:37:08 UTC 2018


I have basically the same patch setting in my simple-range-analysis tree.

https://cgit.freedesktop.org/~idr/mesa/commit/?h=simple-range-analysis&id=e9d29d71304347f8ff904294450a398e5838f49a

As Jason mentions, you don't need to explicitly mention the compares.
You don't need the @bool either... the source of b2[fi] is always bool.

IIRC, adding the b2f versions helps some other shaders too.  I'm
(re-)gathering shader-db stats right now...

On 03/15/2018 08:53 PM, Timothy Arceri wrote:
> These can be found in the Tomb Raider shaders, eliminating them
> helps unroll more loops.
> ---
>  src/compiler/nir/nir_opt_algebraic.py | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
> index c9575e6be4..56dfc53043 100644
> --- a/src/compiler/nir/nir_opt_algebraic.py
> +++ b/src/compiler/nir/nir_opt_algebraic.py
> @@ -152,6 +152,10 @@ optimizations = [
>     (('inot', ('ige', a, b)), ('ilt', a, b)),
>     (('inot', ('ieq', a, b)), ('ine', a, b)),
>     (('inot', ('ine', a, b)), ('ieq', a, b)),
> +   (('ine', ('b2i', ('ige', a, b)), 0), ('ige', a, b)),
> +   (('ine', ('b2i', ('ilt', a, b)), 0), ('ilt', a, b)),
> +   (('ine', ('b2i', ('ult', a, b)), 0), ('ult', a, b)),
> +   (('ine', ('b2i', ('ine', a, b)), 0), ('ine', a, b)),
>  
>     # 0.0 >= b2f(a)
>     # b2f(a) <= 0.0
> 



More information about the mesa-dev mailing list