From 821dc611c5d8cf008c681a9845143f1af9de6da9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Thu, 26 Jun 2025 14:58:48 -0400 Subject: [PATCH] nir/group_loads: use nir_instr_next/prev Reviewed-by: Alyssa Rosenzweig Part-of: --- src/compiler/nir/nir_group_loads.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/compiler/nir/nir_group_loads.c b/src/compiler/nir/nir_group_loads.c index 765f2d9feb5..dc40d6c0f46 100644 --- a/src/compiler/nir/nir_group_loads.c +++ b/src/compiler/nir/nir_group_loads.c @@ -153,13 +153,14 @@ has_only_sources_less_than(nir_src *src, void *data) static void group_loads(nir_instr *first, nir_instr *last) { + assert(nir_is_grouped_load(first)); + assert(nir_is_grouped_load(last)); + /* Walk the instruction range between the first and last backward, and * move those that have no uses within the range after the last one. */ - for (nir_instr *instr = exec_node_data_backward(nir_instr, - last->node.prev, node); - instr != first; - instr = exec_node_data_backward(nir_instr, instr->node.prev, node)) { + for (nir_instr *instr = nir_instr_prev(last); instr != first; + instr = nir_instr_prev(instr)) { if (is_part_of_group(instr, first->pass_flags)) continue; @@ -181,7 +182,7 @@ group_loads(nir_instr *first, nir_instr *last) /* Set the iterator to the next instruction because we'll move * the current one. */ - instr = exec_node_data_forward(nir_instr, instr->node.next, node); + instr = nir_instr_next(instr); /* Move the instruction after the last and update its index to * indicate that it's after it. @@ -198,10 +199,8 @@ group_loads(nir_instr *first, nir_instr *last) /* Walk the instruction range between the first and last forward, and move * those that have no sources within the range before the first one. */ - for (nir_instr *instr = exec_node_data_forward(nir_instr, - first->node.next, node); - instr != last; - instr = exec_node_data_forward(nir_instr, instr->node.next, node)) { + for (nir_instr *instr = nir_instr_next(first); instr != last; + instr = nir_instr_next(instr)) { /* Only move instructions without side effects. */ if (is_part_of_group(instr, first->pass_flags)) continue; @@ -209,7 +208,7 @@ group_loads(nir_instr *first, nir_instr *last) if (nir_foreach_src(instr, has_only_sources_less_than, &state)) { nir_instr *move_instr = instr; /* Set the last instruction because we'll delete the current one. */ - instr = exec_node_data_backward(nir_instr, instr->node.prev, node); + instr = nir_instr_prev(instr); /* Move the instruction before the first and update its index * to indicate that it's before it.