From 2f334e8baf7fef57577a974750ebe679787e9d61 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 27 Dec 2024 02:59:54 -0800 Subject: [PATCH] nir: Add a nir_def_first_component_read() helper Similar to nir_def_last_component_read(). Just a little nicer than prodding at the bitmask of components read directly. Reviewed-by: Lionel Landwerlin Part-of: --- src/compiler/nir/nir.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index a53a0a2b888..756ca610852 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -5102,6 +5102,12 @@ 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_first_component_read(nir_def *def) +{ + return (int)ffs(nir_def_components_read(def)) - 1; +} + static inline int nir_def_last_component_read(nir_def *def) {