From 7ebb215495b994a0f2f5f6a377a11e5ec89b30b6 Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Wed, 7 Apr 2021 10:04:28 +0100 Subject: [PATCH] nir_to_tgsi: run constant folding after nir_opt_algebraic Otherwise, an infinite loop can occur. The first nir_opt_algebraic in the loop can optimize: op(bcsel(a, #b, c), #d) to bcsel(a, op(b, d), op(c, d)) which (because op(b, d) is not constant folded), will be reverted by the second nir_opt_algebraic in the loop. Signed-off-by: Rhys Perry Reviewed-by: Neha Bhende Reviewed-by: Jason Ekstrand Part-of: --- src/gallium/auxiliary/nir/nir_to_tgsi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/auxiliary/nir/nir_to_tgsi.c b/src/gallium/auxiliary/nir/nir_to_tgsi.c index 80719580551..7cc163c7703 100644 --- a/src/gallium/auxiliary/nir/nir_to_tgsi.c +++ b/src/gallium/auxiliary/nir/nir_to_tgsi.c @@ -2411,6 +2411,7 @@ ntt_optimize_nir(struct nir_shader *s, struct pipe_screen *screen) NIR_PASS(progress, s, nir_copy_prop); NIR_PASS(progress, s, nir_opt_algebraic); + NIR_PASS(progress, s, nir_opt_constant_folding); NIR_PASS(progress, s, nir_opt_remove_phis); NIR_PASS(progress, s, nir_opt_conditional_discard); NIR_PASS(progress, s, nir_opt_dce);