Mesa (master): compiler/nir: Add new flags to lower pack/unpack split instructions
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Aug 17 20:11:40 UTC 2020
Module: Mesa
Branch: master
Commit: 18e464cfc05cdae59af8d00f214a6477a72b8ac7
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=18e464cfc05cdae59af8d00f214a6477a72b8ac7
Author: Boris Brezillon <boris.brezillon at collabora.com>
Date: Tue Apr 21 04:41:41 2020 -0700
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 <boris.brezillon at collabora.com>
Reviewed-by: Eric Anholt <eric at anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6309>
---
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)),
More information about the mesa-commit
mailing list