[Mesa-dev] [PATCH 1/3] SQUASH/i965/opt_move_comparisons: clean up move_comparison_source

Jason Ekstrand jason at jlekstrand.net
Wed Jan 11 20:48:26 UTC 2017


---
 src/compiler/nir/nir_opt_move_comparisons.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/compiler/nir/nir_opt_move_comparisons.c b/src/compiler/nir/nir_opt_move_comparisons.c
index 651b937..535009b 100644
--- a/src/compiler/nir/nir_opt_move_comparisons.c
+++ b/src/compiler/nir/nir_opt_move_comparisons.c
@@ -77,18 +77,22 @@ is_comparison(nir_op op)
 static bool
 move_comparison_source(nir_src *src, nir_block *block, nir_instr *before)
 {
-   if (src->is_ssa && src->ssa->parent_instr->block == block &&
-       src->ssa->parent_instr->type == nir_instr_type_alu &&
-       is_comparison(nir_instr_as_alu(src->ssa->parent_instr)->op) &&
+   if (!src->is_ssa)
+      return false;
+
+   nir_instr *src_instr = src->ssa->parent_instr;
+
+   if (src_instr->block == block &&
+       src_instr->type == nir_instr_type_alu &&
+       is_comparison(nir_instr_as_alu(src_instr)->op) &&
        (!before || before->type != nir_instr_type_phi)) {
 
-      struct exec_node *src_node = &src->ssa->parent_instr->node;
-      exec_node_remove(src_node);
+      exec_node_remove(&src_instr->node);
 
       if (before)
-         exec_node_insert_node_before(&before->node, src_node);
+         exec_node_insert_node_before(&before->node, &src_instr->node);
       else
-         exec_list_push_tail(&block->instr_list, src_node);
+         exec_list_push_tail(&block->instr_list, &src_instr->node);
 
       return true;
    }
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list