lima/gpir: Fix some bugs in instruction handling
authorConnor Abbott <cwabbott0@gmail.com>
Tue, 16 Jan 2018 00:38:17 +0000 (19:38 -0500)
committerConnor Abbott <cwabbott0@gmail.com>
Thu, 18 Jul 2019 12:33:23 +0000 (14:33 +0200)
Reviewed-by: Qiang Yu <yuq825@gmail.com>
src/gallium/drivers/lima/ir/gp/instr.c

index 158a9a93fd45223a2eb0ec72987248a00de1184b..d3190d39d4ccb206ecb10e201d09b3913ce51f2d 100644 (file)
@@ -408,6 +408,15 @@ bool gpir_instr_try_insert_node(gpir_instr *instr, gpir_node *node)
 
 void gpir_instr_remove_node(gpir_instr *instr, gpir_node *node)
 {
+   assert(node->sched.pos >= 0);
+
+   /* This can happen if we merge duplicate loads in the scheduler. */
+   if (instr->slots[node->sched.pos] != node) {
+      node->sched.pos = -1;
+      node->sched.instr = -1;
+      return;
+   }
+
    if (node->sched.pos >= GPIR_INSTR_SLOT_ALU_BEGIN &&
        node->sched.pos <= GPIR_INSTR_SLOT_ALU_END)
       gpir_instr_remove_alu(instr, node);
@@ -428,6 +437,9 @@ void gpir_instr_remove_node(gpir_instr *instr, gpir_node *node)
 
    if (node->op == gpir_op_complex1 || node->op == gpir_op_select)
       instr->slots[GPIR_INSTR_SLOT_MUL1] = NULL;
+
+   node->sched.pos = -1;
+   node->sched.instr = -1;
 }
 
 void gpir_instr_print_prog(gpir_compiler *comp)