summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir/nir_control_flow.c
diff options
context:
space:
mode:
authorJason Ekstrand <jason.ekstrand@intel.com>2015-12-23 18:10:08 -0800
committerJason Ekstrand <jason.ekstrand@intel.com>2016-03-24 15:20:44 -0700
commit97b663481c8c83fda06246860708530cff755a05 (patch)
treec372bf4949ad535cd8c6c190d550556eb7f1baae /src/compiler/nir/nir_control_flow.c
parent7022a673cd6b9e4bdd4c55fe1d7c76c04d27d4e6 (diff)
downloadexternal_mesa3d-97b663481c8c83fda06246860708530cff755a05.zip
external_mesa3d-97b663481c8c83fda06246860708530cff755a05.tar.gz
external_mesa3d-97b663481c8c83fda06246860708530cff755a05.tar.bz2
nir/cf: Make extracting or re-inserting nothing a no-op
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com> Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
Diffstat (limited to 'src/compiler/nir/nir_control_flow.c')
-rw-r--r--src/compiler/nir/nir_control_flow.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_control_flow.c b/src/compiler/nir/nir_control_flow.c
index ecd9cbd..33b06d0 100644
--- a/src/compiler/nir/nir_control_flow.c
+++ b/src/compiler/nir/nir_control_flow.c
@@ -749,6 +749,12 @@ nir_cf_extract(nir_cf_list *extracted, nir_cursor begin, nir_cursor end)
{
nir_block *block_begin, *block_end, *block_before, *block_after;
+ if (nir_cursors_equal(begin, end)) {
+ exec_list_make_empty(&extracted->list);
+ extracted->impl = NULL; /* we shouldn't need this */
+ return;
+ }
+
/* In the case where begin points to an instruction in some basic block and
* end points to the end of the same basic block, we rely on the fact that
* splitting on an instruction moves earlier instructions into a new basic
@@ -788,6 +794,9 @@ nir_cf_reinsert(nir_cf_list *cf_list, nir_cursor cursor)
{
nir_block *before, *after;
+ if (exec_list_is_empty(&cf_list->list))
+ return;
+
split_block_cursor(cursor, &before, &after);
foreach_list_typed_safe(nir_cf_node, node, node, &cf_list->list) {