Mesa (master): nir: add nir_phi_get_src_from_block() helper
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Nov 20 13:04:06 UTC 2020
Module: Mesa
Branch: master
Commit: fb01882ddbbf9eedc646259f24917f06766465b4
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=fb01882ddbbf9eedc646259f24917f06766465b4
Author: Daniel Schürmann <daniel at schuermann.dev>
Date: Wed Nov 11 16:34:06 2020 +0100
nir: add nir_phi_get_src_from_block() helper
Returns the phi_src corresponding to a given nir_block.
Reviewed-by: Rhys Perry <pendingchaos02 at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2804>
---
src/compiler/nir/nir.h | 12 ++++++++++++
src/compiler/nir/nir_opt_if.c | 23 ++++-------------------
2 files changed, 16 insertions(+), 19 deletions(-)
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 1c3292268df..e732efaaa7a 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -2615,6 +2615,18 @@ typedef struct {
nir_dest dest;
} nir_phi_instr;
+static inline nir_phi_src *
+nir_phi_get_src_from_block(nir_phi_instr *phi, struct nir_block *block)
+{
+ nir_foreach_phi_src(src, phi) {
+ if (src->pred == block)
+ return src;
+ }
+
+ assert(!"Block is not a predecessor of phi.");
+ return NULL;
+}
+
typedef struct {
struct exec_node node;
nir_src src;
diff --git a/src/compiler/nir/nir_opt_if.c b/src/compiler/nir/nir_opt_if.c
index 31195b12bb7..7b0a91e47d2 100644
--- a/src/compiler/nir/nir_opt_if.c
+++ b/src/compiler/nir/nir_opt_if.c
@@ -509,21 +509,6 @@ opt_split_alu_of_phi(nir_builder *b, nir_loop *loop)
return progress;
}
-/**
- * Get the SSA value from a phi node that corresponds to a specific block
- */
-static nir_ssa_def *
-ssa_for_phi_from_block(nir_phi_instr *phi, nir_block *block)
-{
- nir_foreach_phi_src(src, phi) {
- if (src->pred == block)
- return src->src.ssa;
- }
-
- assert(!"Block is not a predecessor of phi.");
- return NULL;
-}
-
/**
* Simplify a bcsel whose sources are all phi nodes from the loop header block
*
@@ -681,15 +666,15 @@ opt_simplify_bcsel_of_phi(nir_builder *b, nir_loop *loop)
phi_src = ralloc(phi, nir_phi_src);
phi_src->pred = prev_block;
phi_src->src =
- nir_src_for_ssa(ssa_for_phi_from_block(nir_instr_as_phi(bcsel->src[entry_src].src.ssa->parent_instr),
- prev_block));
+ nir_phi_get_src_from_block(nir_instr_as_phi(bcsel->src[entry_src].src.ssa->parent_instr),
+ prev_block)->src;
exec_list_push_tail(&phi->srcs, &phi_src->node);
phi_src = ralloc(phi, nir_phi_src);
phi_src->pred = continue_block;
phi_src->src =
- nir_src_for_ssa(ssa_for_phi_from_block(nir_instr_as_phi(bcsel->src[continue_src].src.ssa->parent_instr),
- continue_block));
+ nir_phi_get_src_from_block(nir_instr_as_phi(bcsel->src[continue_src].src.ssa->parent_instr),
+ continue_block)->src;
exec_list_push_tail(&phi->srcs, &phi_src->node);
nir_ssa_dest_init(&phi->instr,
More information about the mesa-commit
mailing list