Without the break, it was possible that an instruction would match multiple
expressions. If this happened, you could end up trying to replace it
multiple times and get a segfault. This makes it so that, after a
successful replacement, it moves on to the next instruction.
Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
for (unsigned i = 0; i < ARRAY_SIZE(${pass_name}_${opcode}_xforms); i++) {
if (nir_replace_instr(alu, ${pass_name}_${opcode}_xforms[i].search,
${pass_name}_${opcode}_xforms[i].replace,
- state->mem_ctx))
+ state->mem_ctx)) {
state->progress = true;
+ break;
+ }
}
break;
% endfor