nir: keep the phi order when splitting blocks
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Sat, 26 Jan 2019 09:05:14 +0000 (01:05 -0800)
committerCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Tue, 5 Feb 2019 04:41:13 +0000 (20:41 -0800)
All things being equal is better to keep the original order.  Since
the new block is empty, push the phis in order to tail.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Daniel Schürmann <daniel.schuermann@campus.tu-berlin.de>
src/compiler/nir/nir_control_flow.c

index ddba2e55b45c9433d3064eaee915249b2debd7eb..252aaf335ad3dfb0eca21cedbc6e35e2a40febbe 100644 (file)
@@ -195,8 +195,7 @@ split_block_beginning(nir_block *block)
    }
 
    /* Any phi nodes must stay part of the new block, or else their
-    * sourcse will be messed up. This will reverse the order of the phis, but
-    * order shouldn't matter.
+    * sources will be messed up.
     */
    nir_foreach_instr_safe(instr, block) {
       if (instr->type != nir_instr_type_phi)
@@ -204,7 +203,7 @@ split_block_beginning(nir_block *block)
 
       exec_node_remove(&instr->node);
       instr->block = new_block;
-      exec_list_push_head(&new_block->instr_list, &instr->node);
+      exec_list_push_tail(&new_block->instr_list, &instr->node);
    }
 
    return new_block;