Mesa (main): nir/algebraic: Pack various bitfields in the nir_search_value_union.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Dec 7 07:49:39 UTC 2021


Module: Mesa
Branch: main
Commit: 45a8d11b6e6e08866b3ae7c8c98fb2ca8b7c35ef
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=45a8d11b6e6e08866b3ae7c8c98fb2ca8b7c35ef

Author: Emma Anholt <emma at anholt.net>
Date:   Tue Nov 30 14:34:45 2021 -0800

nir/algebraic: Pack various bitfields in the nir_search_value_union.

This gets our union's size down to 22 bytes (now smaller than any of the
union's types were before we made the union!).  Cuts another 48kb off of
the drivers.

Reviewed-by: Adam Jackson <ajax at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13987>

---

 src/compiler/nir/nir_algebraic.py |  2 +-
 src/compiler/nir/nir_search.h     | 17 +++++++++--------
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/src/compiler/nir/nir_algebraic.py b/src/compiler/nir/nir_algebraic.py
index c9daccdc59c..47040d2b121 100644
--- a/src/compiler/nir/nir_algebraic.py
+++ b/src/compiler/nir/nir_algebraic.py
@@ -186,8 +186,8 @@ class Value(object):
       ${val.swizzle()},
 % elif isinstance(val, Expression):
       ${'true' if val.inexact else 'false'}, ${'true' if val.exact else 'false'},
-      ${val.comm_expr_idx}, ${val.comm_exprs},
       ${val.c_opcode()},
+      ${val.comm_expr_idx}, ${val.comm_exprs},
       { ${', '.join(src.array_index for src in val.sources)} },
       ${val.cond_index},
 % endif
diff --git a/src/compiler/nir/nir_search.h b/src/compiler/nir/nir_search.h
index 421ee5f4662..67fe7d0a516 100644
--- a/src/compiler/nir/nir_search.h
+++ b/src/compiler/nir/nir_search.h
@@ -36,7 +36,7 @@
 
 struct nir_builder;
 
-typedef enum {
+typedef enum PACKED {
    nir_search_value_expression,
    nir_search_value_variable,
    nir_search_value_constant,
@@ -60,21 +60,21 @@ typedef struct {
     * - If bit_size < 0, then the value is constructed with the same bit size
     *   as variable (-bit_size - 1).
     */
-   int bit_size;
+   int8_t bit_size;
 } nir_search_value;
 
 typedef struct {
    nir_search_value value;
 
    /** The variable index;  Must be less than NIR_SEARCH_MAX_VARIABLES */
-   unsigned variable;
+   uint8_t variable : 7;
 
    /** Indicates that the given variable must be a constant
     *
     * This is only allowed in search expressions and indicates that the
     * given variable is only allowed to match constant values.
     */
-   bool is_constant;
+   bool is_constant : 1;
 
    /** Indicates that the given variable must have a certain type
     *
@@ -137,10 +137,13 @@ typedef struct {
     * value that does *not* have the exact bit set.  If unset, the exact bit
     * on the SSA value is ignored.
     */
-   bool inexact;
+   bool inexact : 1;
 
    /** In a replacement, requests that the instruction be marked exact. */
-   bool exact;
+   bool exact : 1;
+
+   /* One of nir_op or nir_search_op */
+   uint16_t opcode : 14;
 
    /* Commutative expression index.  This is assigned by opt_algebraic.py when
     * search structures are constructed and is a unique (to this structure)
@@ -154,8 +157,6 @@ typedef struct {
     */
    uint8_t comm_exprs;
 
-   /* One of nir_op or nir_search_op */
-   uint16_t opcode;
    /* Index in table->values[] for the expression operands */
    uint16_t srcs[4];
 



More information about the mesa-commit mailing list