From 0d05d1226e0f51f703e0dcbf736375ee4f252473 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Wed, 14 Jan 2015 19:08:32 -0800 Subject: [PATCH] nir/algebraic: Only replace an instruction once 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 --- src/glsl/nir/nir_algebraic.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/glsl/nir/nir_algebraic.py b/src/glsl/nir/nir_algebraic.py index 72703beea8a..f9b246dd865 100644 --- a/src/glsl/nir/nir_algebraic.py +++ b/src/glsl/nir/nir_algebraic.py @@ -192,8 +192,10 @@ ${pass_name}_block(nir_block *block, void *void_state) 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 -- 2.30.2