Mesa (master): nir: fix opt_if_loop_last_continue()

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Dec 14 06:21:49 UTC 2018


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

Author: Timothy Arceri <tarceri at itsqueeze.com>
Date:   Fri Dec 14 10:23:27 2018 +1100

nir: fix opt_if_loop_last_continue()

The pass did not correctly handle loops ending in:

	if ssa_7 {
		block block_8:
		/* preds: block_7 */
		continue
		/* succs: block_1 */
	} else {
		block block_9:
		/* preds: block_7 */
		break
		/* succs: block_11 */
	}

The break will get eliminated by another opt but if this pass gets
called first (as it does on RADV) we ended up inserting
instructions after the break.

Fixes: 5921a19d4b0c ("nir: add if opt opt_if_loop_last_continue()")
Reviewed-by: Dave Airlie <airlied at redhat.com>

---

 src/compiler/nir/nir_opt_if.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/compiler/nir/nir_opt_if.c b/src/compiler/nir/nir_opt_if.c
index 691448a96e..c21ac9219f 100644
--- a/src/compiler/nir/nir_opt_if.c
+++ b/src/compiler/nir/nir_opt_if.c
@@ -318,9 +318,13 @@ opt_if_loop_last_continue(nir_loop *loop)
    nir_cf_extract(&tmp, nir_after_cf_node(if_node),
                         nir_after_block(last_block));
    if (then_ends_in_continue) {
-      nir_cf_reinsert(&tmp, nir_after_cf_list(&nif->else_list));
+      nir_cursor last_blk_cursor = nir_after_cf_list(&nif->else_list);
+      nir_cf_reinsert(&tmp,
+                      nir_after_block_before_jump(last_blk_cursor.block));
    } else {
-      nir_cf_reinsert(&tmp, nir_after_cf_list(&nif->then_list));
+      nir_cursor last_blk_cursor = nir_after_cf_list(&nif->then_list);
+      nir_cf_reinsert(&tmp,
+                      nir_after_block_before_jump(last_blk_cursor.block));
    }
 
    /* In order to avoid running nir_lower_regs_to_ssa_impl() every time an if




More information about the mesa-commit mailing list