From a8c947df9a1ff710f66b8e1d5fb4df05f502ab38 Mon Sep 17 00:00:00 2001 From: Job Noorman Date: Wed, 27 Nov 2024 17:32:56 +0100 Subject: [PATCH] nir/search: make is_only_used_by_iadd reusable The algorithm is exactly the same for other opcodes so we don't have to have to copy paste it. Signed-off-by: Job Noorman Reviewed-by: Ian Romanick Reviewed-by: Rob Clark Part-of: --- src/compiler/nir/nir_search_helpers.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/compiler/nir/nir_search_helpers.h b/src/compiler/nir/nir_search_helpers.h index 45b3b482c10..d9de567565c 100644 --- a/src/compiler/nir/nir_search_helpers.h +++ b/src/compiler/nir/nir_search_helpers.h @@ -599,7 +599,7 @@ is_only_used_by_fadd(const nir_alu_instr *instr) } static inline bool -is_only_used_by_iadd(const nir_alu_instr *instr) +is_only_used_by_alu_op(const nir_alu_instr *instr, nir_op op) { nir_foreach_use(src, &instr->def) { const nir_instr *const user_instr = nir_src_parent_instr(src); @@ -609,13 +609,19 @@ is_only_used_by_iadd(const nir_alu_instr *instr) const nir_alu_instr *const user_alu = nir_instr_as_alu(user_instr); assert(instr != user_alu); - if (user_alu->op != nir_op_iadd) + if (user_alu->op != op) return false; } return true; } +static inline bool +is_only_used_by_iadd(const nir_alu_instr *instr) +{ + return is_only_used_by_alu_op(instr, nir_op_iadd); +} + static inline bool only_lower_8_bits_used(const nir_alu_instr *instr) {