From 18e464cfc05cdae59af8d00f214a6477a72b8ac7 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Tue, 21 Apr 2020 04:41:41 -0700 Subject: [PATCH] compiler/nir: Add new flags to lower pack/unpack split instructions And add new rules to do this lowering in nir_opt_algebraic.py. Signed-off-by: Boris Brezillon Reviewed-by: Eric Anholt Part-of: --- src/compiler/nir/nir.h | 4 ++++ src/compiler/nir/nir_opt_algebraic.py | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 79a6108be73..083bdf207f4 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -3064,11 +3064,15 @@ typedef struct nir_shader_compiler_options { bool lower_pack_snorm_2x16; bool lower_pack_unorm_4x8; bool lower_pack_snorm_4x8; + bool lower_pack_64_2x32_split; + bool lower_pack_32_2x16_split; bool lower_unpack_half_2x16; bool lower_unpack_unorm_2x16; bool lower_unpack_snorm_2x16; bool lower_unpack_unorm_4x8; bool lower_unpack_snorm_4x8; + bool lower_unpack_64_2x32_split; + bool lower_unpack_32_2x16_split; bool lower_pack_split; diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index 1762591bd12..14e7f30d976 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -1045,6 +1045,14 @@ optimizations.extend([ (('ibfe', a, 0, 16), ('extract_i16', a, 0), '!options->lower_extract_word'), (('ibfe', a, 16, 16), ('extract_i16', a, 1), '!options->lower_extract_word'), + # Lower pack/unpack + (('pack_64_2x32_split', a, b), ('ior', ('u2u64', a), ('ishl', ('u2u64', b), 32)), 'options->lower_pack_64_2x32_split'), + (('pack_32_2x16_split', a, b), ('ior', ('u2u32', a), ('ishl', ('u2u32', b), 16)), 'options->lower_pack_32_2x16_split'), + (('unpack_64_2x32_split_x', a), ('u2u32', a), 'options->lower_unpack_64_2x32_split'), + (('unpack_64_2x32_split_y', a), ('u2u32', ('ushr', a, 32)), 'options->lower_unpack_64_2x32_split'), + (('unpack_32_2x16_split_x', a), ('u2u16', a), 'options->lower_unpack_32_2x16_split'), + (('unpack_32_2x16_split_y', a), ('u2u16', ('ushr', a, 16)), 'options->lower_unpack_32_2x16_split'), + # Useless masking before unpacking (('unpack_half_2x16_split_x', ('iand', a, 0xffff)), ('unpack_half_2x16_split_x', a)), (('unpack_32_2x16_split_x', ('iand', a, 0xffff)), ('unpack_32_2x16_split_x', a)), -- 2.30.2