Mesa (master): nir_to_tgsi: run constant folding after nir_opt_algebraic

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Apr 7 14:21:17 UTC 2021


Module: Mesa
Branch: master
Commit: 7ebb215495b994a0f2f5f6a377a11e5ec89b30b6
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=7ebb215495b994a0f2f5f6a377a11e5ec89b30b6

Author: Rhys Perry <pendingchaos02 at gmail.com>
Date:   Wed Apr  7 10:04:28 2021 +0100

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 <pendingchaos02 at gmail.com>
Reviewed-by: Neha Bhende <bhenden at vmware.com>
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10071>

---

 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);



More information about the mesa-commit mailing list