[Mesa-dev] [PATCH 02/22] nir/algebraic: Add more extract_[iu](8|16) optimizations

Bas Nieuwenhuizen bas at basnieuwenhuizen.nl
Fri Aug 17 22:31:09 UTC 2018


On Fri, Aug 17, 2018 at 10:06 PM, Jason Ekstrand <jason at jlekstrand.net> wrote:
> This adds the "(a << N) >> M" family of mask or sign-extensions.  Not a
> huge win right now but this pattern will soon be generated by NIR format
> lowering code.
>
> Shader-db results on Kaby Lake:
>
>     total instructions in shared programs: 15166918 -> 15166916 (<.01%)
>     instructions in affected programs: 36 -> 34 (-5.56%)
>     helped: 2
>     HURT: 0
> ---
>  src/compiler/nir/nir_opt_algebraic.py | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
> index 28090d069cd..07fbb161a4e 100644
> --- a/src/compiler/nir/nir_opt_algebraic.py
> +++ b/src/compiler/nir/nir_opt_algebraic.py
> @@ -543,13 +543,23 @@ optimizations = [
>                             ('unpack_64_2x32_split_y', a)), a),
>
>     # Byte extraction
> +   (('ushr', ('ishl', 'a at 32', 24), 24), ('extract_u8', a, 0), '!options->lower_extract_byte'),
> +   (('ushr', ('ishl', 'a at 32', 16), 24), ('extract_u8', a, 1), '!options->lower_extract_byte'),
> +   (('ushr', ('ishl', 'a at 32', 8), 24), ('extract_u8', a, 2), '!options->lower_extract_byte'),
>     (('ushr', 'a at 32', 24), ('extract_u8', a, 3), '!options->lower_extract_byte'),
> +   (('ishr', ('ishl', 'a at 32', 24), 24), ('extract_i8', a, 0), '!options->lower_extract_byte'),
> +   (('ishr', ('ishl', 'a at 32', 16), 24), ('extract_i8', a, 1), '!options->lower_extract_byte'),
> +   (('ishr', ('ishl', 'a at 32', 8), 24), ('extract_i8', a, 2), '!options->lower_extract_byte'),
> +   (('ishr', 'a at 32', 24), ('extract_i8', a, 3), '!options->lower_extract_byte'),
>     (('iand', 0xff, ('ushr', a, 16)), ('extract_u8', a, 2), '!options->lower_extract_byte'),
>     (('iand', 0xff, ('ushr', a,  8)), ('extract_u8', a, 1), '!options->lower_extract_byte'),
>     (('iand', 0xff, a), ('extract_u8', a, 0), '!options->lower_extract_byte'),
>
>      # Word extraction
> +   (('ushr', ('ishl', 'a at 16', 16), 16), ('extract_u16', a, 0), '!options->lower_extract_word'),
>     (('ushr', 'a at 16', 16), ('extract_u16', a, 1), '!options->lower_extract_word'),
> +   (('ishr', ('ishl', 'a at 16', 16), 16), ('extract_i16', a, 0), '!options->lower_extract_word'),
> +   (('ishr', 'a at 16', 16), ('extract_i16', a, 1), '!options->lower_extract_word'),
>     (('iand', 0xffff, a), ('extract_u16', a, 0), '!options->lower_extract_word'),

I think this all should be @32 too. With that patch 1-2 are

Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>

>
>     # Subtracts
> --
> 2.17.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list