summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarol Herbst <kherbst@redhat.com>2019-02-12 20:59:35 +0100
committerDylan Baker <dylan@pnwbakers.com>2019-02-13 14:14:35 -0800
commit7ac15d9e4248ddafba8189e5dfcacddc1af367e2 (patch)
tree4d68244ba07d03787c16d9d236025bb7cdb23978
parent6b484511104c5bddfd552cb83b1c7ee600004000 (diff)
nir/opt_if: don't mark progress if nothing changes
if we have something like this: loop { ... if x { break; } else { continue; } } opt_if_loop_last_continue returns true marking progress allthough nothing changes. Fixes: 5921a19d4b0c6 "nir: add if opt opt_if_loop_last_continue()" Signed-off-by: Karol Herbst <kherbst@redhat.com> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> (cherry picked from commit 7e08f22a72cfc379902feeca3673db6aa344f782)
-rw-r--r--src/compiler/nir/nir_opt_if.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_opt_if.c b/src/compiler/nir/nir_opt_if.c
index c2f945d4d59..ba94807bb20 100644
--- a/src/compiler/nir/nir_opt_if.c
+++ b/src/compiler/nir/nir_opt_if.c
@@ -313,6 +313,13 @@ opt_if_loop_last_continue(nir_loop *loop)
if (!then_ends_in_continue && !else_ends_in_continue)
return false;
+ /* if the block after the if/else is empty we bail, otherwise we might end
+ * up looping forever
+ */
+ if (&nif->cf_node == nir_cf_node_prev(&last_block->cf_node) &&
+ exec_list_is_empty(&last_block->instr_list))
+ return false;
+
/* Move the last block of the loop inside the last if-statement */
nir_cf_list tmp;
nir_cf_extract(&tmp, nir_after_cf_node(if_node),