From 34f41abe24726c4a4cff095f9a5b86dbff784769 Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Fri, 25 Oct 2024 15:39:30 +0200 Subject: [PATCH] nir: add nir_def_all_uses_ignore_sign_bit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Alyssa Rosenzweig Reviewed-by: Daniel Schürmann Part-of: --- src/compiler/nir/nir.c | 15 +++++++++++++++ src/compiler/nir/nir.h | 1 + 2 files changed, 16 insertions(+) diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c index c76a43996ea..2946a515dc7 100644 --- a/src/compiler/nir/nir.c +++ b/src/compiler/nir/nir.c @@ -1706,6 +1706,21 @@ nir_def_all_uses_are_fsat(const nir_def *def) return true; } +bool +nir_def_all_uses_ignore_sign_bit(const nir_def *def) +{ + nir_foreach_use(use, def) { + if (nir_src_is_if(use)) + return false; + nir_instr *instr = nir_src_parent_instr(use); + + if (instr->type != nir_instr_type_alu || + nir_instr_as_alu(instr)->op != nir_op_fabs) + return false; + } + return true; +} + nir_block * nir_block_unstructured_next(nir_block *block) { diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 79a807278e1..96484cc69f7 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -5084,6 +5084,7 @@ nir_def_replace(nir_def *def, nir_def *new_ssa) nir_component_mask_t nir_src_components_read(const nir_src *src); nir_component_mask_t nir_def_components_read(const nir_def *def); bool nir_def_all_uses_are_fsat(const nir_def *def); +bool nir_def_all_uses_ignore_sign_bit(const nir_def *def); static inline int nir_def_last_component_read(nir_def *def)