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

Author: Alyssa Rosenzweig <[email protected]>
Date:   Mon Nov  6 16:50:11 2023 -0400

nir: Simplify nir_alu_instr_channel_used definition

Deduplicates the "get # of channels" logic which was the same between the
helpers.

Signed-off-by: Alyssa Rosenzweig <[email protected]>
Reviewed-by: Rhys Perry <[email protected]>
Reviewed-by: Faith Ekstrand <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26084>

---

 src/compiler/nir/nir.c | 10 ----------
 src/compiler/nir/nir.h | 12 ++++++++----
 2 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c
index 6db4af17d4c..a5922284e2f 100644
--- a/src/compiler/nir/nir.c
+++ b/src/compiler/nir/nir.c
@@ -2848,16 +2848,6 @@ nir_op_is_vec(nir_op op)
    }
 }
 
-bool
-nir_alu_instr_channel_used(const nir_alu_instr *instr, unsigned src,
-                           unsigned channel)
-{
-   if (nir_op_infos[instr->op].input_sizes[src] > 0)
-      return channel < nir_op_infos[instr->op].input_sizes[src];
-
-   return channel < instr->def.num_components;
-}
-
 nir_component_mask_t
 nir_alu_instr_src_read_mask(const nir_alu_instr *instr, unsigned src)
 {
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index e1c7ca8ec17..554444f33ed 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -1575,10 +1575,6 @@ typedef struct nir_alu_instr {
 
 void nir_alu_src_copy(nir_alu_src *dest, const nir_alu_src *src);
 
-/* is this source channel used? */
-bool
-nir_alu_instr_channel_used(const nir_alu_instr *instr, unsigned src,
-                           unsigned channel);
 nir_component_mask_t
 nir_alu_instr_src_read_mask(const nir_alu_instr *instr, unsigned src);
 /**
@@ -1587,6 +1583,14 @@ nir_alu_instr_src_read_mask(const nir_alu_instr *instr, 
unsigned src);
 unsigned
 nir_ssa_alu_instr_src_components(const nir_alu_instr *instr, unsigned src);
 
+/* is this source channel used? */
+static inline bool
+nir_alu_instr_channel_used(const nir_alu_instr *instr, unsigned src,
+                           unsigned channel)
+{
+   return channel < nir_ssa_alu_instr_src_components(instr, src);
+}
+
 bool
 nir_alu_instr_is_comparison(const nir_alu_instr *instr);
 

Reply via email to