From 5fad6bca72eb474b616eccb3e71c6427d4977bb9 Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Tue, 12 Apr 2022 10:33:14 -0700 Subject: [PATCH] nir_to_tgsi: Do the required cleanup for nir_opt_find_array_copies(). If we made a copy deref, then we need to do dead-write elimination for the pervious writes or we'll just emit the same copy deref again next time around. And, at the end of the opt loop, we need to lower copy derefs because later passes (locals_to_regs, notably) depend on it. Fixes infinite opt loop on fs-function-inout-array with virgl on NTT. Reviewed-by: Gert Wollny Part-of: --- src/gallium/auxiliary/nir/nir_to_tgsi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/nir/nir_to_tgsi.c b/src/gallium/auxiliary/nir/nir_to_tgsi.c index 20c3d7f..ffbaaae 100644 --- a/src/gallium/auxiliary/nir/nir_to_tgsi.c +++ b/src/gallium/auxiliary/nir/nir_to_tgsi.c @@ -3153,6 +3153,9 @@ ntt_optimize_nir(struct nir_shader *s, struct pipe_screen *screen) NIR_PASS(progress, s, nir_opt_dead_cf); NIR_PASS(progress, s, nir_opt_cse); NIR_PASS(progress, s, nir_opt_find_array_copies); + NIR_PASS(progress, s, nir_opt_copy_prop_vars); + NIR_PASS(progress, s, nir_opt_dead_write_vars); + NIR_PASS(progress, s, nir_opt_if, true); NIR_PASS(progress, s, nir_opt_peephole_select, control_flow_depth == 0 ? ~0 : 8, true, true); @@ -3185,8 +3188,9 @@ ntt_optimize_nir(struct nir_shader *s, struct pipe_screen *screen) .buffer_max = 0, }; NIR_PASS(progress, s, nir_opt_offsets, &offset_options); - } while (progress); + + NIR_PASS_V(s, nir_lower_var_copies); } /* Scalarizes all 64-bit ALU ops. Note that we only actually need to -- 2.7.4