[Mesa-dev] [PATCH 05/10] nir: Lower flrp with Boolean interpolator to bcsel
Matt Turner
mattst88 at gmail.com
Thu Mar 10 18:48:29 UTC 2016
On Thu, Mar 10, 2016 at 10:25 AM, Ian Romanick <idr at freedesktop.org> wrote:
> From: Ian Romanick <ian.d.romanick at intel.com>
>
> On Intel platforms that don't set lower_flrp, using bcsel instead of
> flrp seems to be a small amount worse.
Yep, that's my experience too. It's because bcsel turns into CMP+SEL,
and because of the flag register we can't schedule instructions well.
> On those platforms, the use of
> flrp, bcsel, and multiply of b2f is still an active area of research.
>
> shader-db results:
>
> G4X / Ironlake
> total instructions in shared programs: 4016538 -> 4012279 (-0.11%)
> instructions in affected programs: 161556 -> 157297 (-2.64%)
> helped: 1077
> HURT: 1
>
> total cycles in shared programs: 84328296 -> 84315862 (-0.01%)
> cycles in affected programs: 4174570 -> 4162136 (-0.30%)
> helped: 926
> HURT: 53
>
> Unsurprisingly, no changes on later platforms.
>
> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
> ---
> src/compiler/nir/nir_opt_algebraic.py | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
> index 39be85f..8a44a7a 100644
> --- a/src/compiler/nir/nir_opt_algebraic.py
> +++ b/src/compiler/nir/nir_opt_algebraic.py
> @@ -83,10 +83,13 @@ optimizations = [
> (('flrp', a, b, 1.0), b),
> (('flrp', a, a, b), a),
> (('flrp', 0.0, a, b), ('fmul', a, b)),
> + (('flrp', a, b, ('b2f', c)), ('bcsel', c, b, a), 'options->lower_flrp'),
> (('flrp', a, b, c), ('fadd', ('fmul', c, ('fsub', b, a)), a), 'options->lower_flrp'),
> (('ffract', a), ('fsub', a, ('ffloor', a)), 'options->lower_ffract'),
> - (('fadd', ('fmul', a, ('fadd', 1.0, ('fneg', c))), ('fmul', b, c)), ('flrp', a, b, c), '!options->lower_flrp'),
> - (('fadd', a, ('fmul', c, ('fadd', b, ('fneg', a)))), ('flrp', a, b, c), '!options->lower_flrp'),
> + (('fadd', ('fmul', a, ('fadd', 1.0, ('fneg', ('b2f', c)))), ('fmul', b, ('b2f', c))), ('bcsel', c, b, a), 'options->lower_flrp'),
> + (('fadd', ('fmul', a, ('fadd', 1.0, ('fneg', c ))), ('fmul', b, c )), ('flrp', a, b, c), '!options->lower_flrp'),
> + (('fadd', a, ('fmul', ('b2f', c), ('fadd', b, ('fneg', a)))), ('bcsel', c, b, a), 'options->lower_flrp'),
> + (('fadd', a, ('fmul', c , ('fadd', b, ('fneg', a)))), ('flrp', a, b, c), '!options->lower_flrp'),
Reviewed-by: Matt Turner <mattst88 at gmail.com>
More information about the mesa-dev
mailing list