agx: Add iterators for phi/non-phi instructions
We know that phi nodes are always at the start (this is asserted in agx_validate and a fundamental invariant of SSA form). That means we can cheaply iterate all n phi nodes forward (or n non-phi nodes backwards) in O(n) time. We already open code this idiom in a few places, use common iterators instead so we don't need to justify in random places. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18804>
This commit is contained in:

committed by
Marge Bot

parent
d3880a6324
commit
6a183a9ffd
@@ -536,6 +536,20 @@ agx_vec_for_intr(agx_context *ctx, nir_intrinsic_instr *instr)
|
||||
#define agx_foreach_dest(ins, v) \
|
||||
for (unsigned v = 0; v < ARRAY_SIZE(ins->dest); ++v)
|
||||
|
||||
/* Phis only come at the start so we stop as soon as we hit a non-phi */
|
||||
#define agx_foreach_phi_in_block(block, v) \
|
||||
agx_foreach_instr_in_block(block, v) \
|
||||
if (v->op != AGX_OPCODE_PHI) \
|
||||
break; \
|
||||
else
|
||||
|
||||
/* Everything else comes after, so we stop as soon as we hit a phi in reverse */
|
||||
#define agx_foreach_non_phi_in_block_rev(block, v) \
|
||||
agx_foreach_instr_in_block_rev(block, v) \
|
||||
if (v->op == AGX_OPCODE_PHI) \
|
||||
break; \
|
||||
else
|
||||
|
||||
/*
|
||||
* Find the index of a predecessor, used as the implicit order of phi sources.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user