[Mesa-dev] [PATCH 1/6] nir: Convert ineg(b2i(a)) to a if it's a boolean.

Erik Faye-Lund kusmabite at gmail.com
Wed Aug 10 08:00:02 UTC 2016


On Wed, Aug 10, 2016 at 4:30 AM, Kenneth Graunke <kenneth at whitecape.org> wrote:
> On Haswell (GL 3.3):
>
> total instructions in shared programs: 6211678 -> 6211584 (-0.00%)
> instructions in affected programs: 18968 -> 18874 (-0.50%)
> helped: 62
> HURT: 0
> LOST:   0
> GAINED: 4
>
> On Broadwell (GL 4.4):
>
> total instructions in shared programs: 11638930 -> 11638181 (-0.01%)
> instructions in affected programs: 84768 -> 84019 (-0.88%)
> helped: 505
> HURT: 45
>
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> ---
>  src/compiler/nir/nir_opt_algebraic.py | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
> index 0f0896b..1cf614c 100644
> --- a/src/compiler/nir/nir_opt_algebraic.py
> +++ b/src/compiler/nir/nir_opt_algebraic.py
> @@ -180,6 +180,7 @@ optimizations = [
>     (('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)),
> +   (('ineg', ('b2i', 'a at bool')), 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

Are you sure this shouldn't be conditional? This being an improvement
sounds like an intel-ism, and not something that applies to most
hardware...


More information about the mesa-dev mailing list