From 5c0fe1107291939cfc14baadb49d21045dd90f6d Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Thu, 2 Dec 2021 13:14:22 +0000 Subject: [PATCH] nir/opt_offsets: fix try_extract_const_addition recursion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This initially looks like a miscompilation bug, but I don't think it's actually possible for it to create incorrect code. fossil-db (Sienna Cichlid): Totals from 32 (0.02% of 134572) affected shaders: VGPRs: 1336 -> 1320 (-1.20%) CodeSize: 90552 -> 89468 (-1.20%) Instrs: 17007 -> 16852 (-0.91%); split: -0.92%, +0.01% Latency: 429040 -> 428136 (-0.21%); split: -0.21%, +0.00% InvThroughput: 84966 -> 84572 (-0.46%); split: -0.47%, +0.00% Copies: 1458 -> 1468 (+0.69%); split: -0.07%, +0.75% Branches: 382 -> 384 (+0.52%) PreSGPRs: 970 -> 968 (-0.21%) PreVGPRs: 1029 -> 1011 (-1.75%) Signed-off-by: Rhys Perry Reviewed-by: Emma Anholt Reviewed-by: Timur Kristóf Part-of: --- src/compiler/nir/nir_opt_offsets.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/nir/nir_opt_offsets.c b/src/compiler/nir/nir_opt_offsets.c index 88b7b2a2862..9e1ae252897 100644 --- a/src/compiler/nir/nir_opt_offsets.c +++ b/src/compiler/nir/nir_opt_offsets.c @@ -70,7 +70,7 @@ try_extract_const_addition(nir_builder *b, nir_instr *instr, opt_offsets_state * return alu->src[1 - i].src.ssa; } - nir_ssa_def *replace_src = try_extract_const_addition(b, alu->src[0].src.ssa->parent_instr, state, out_const); + nir_ssa_def *replace_src = try_extract_const_addition(b, alu->src[i].src.ssa->parent_instr, state, out_const); if (replace_src) { b->cursor = nir_before_instr(&alu->instr); return nir_iadd(b, replace_src, alu->src[1 - i].src.ssa);