lima/gpir: Do all lowerings before rsched

The scheduler assumes that load nodes are always duplicated so that they
can always be scheduled eventually and therefore they never need to be
spilled. But some lowerings were running after the pre-RA scheduler,
whereas duplication has to happen before then since it's needed for the
scheduler to do a better job reducing register pressure. This meant
that lowerings were introducing multiple uses of a load instruction,
which broke the scheduler's expectation and resulted in infinite loops
in situations where the only nodes available to spill were load nodes.
Spilling load nodes would be silly, so we want to fix the lowerings
rather than the scheduler. Just do all lowerings before the pre-RA
scheduler, which also helps with reducing pressure since the scheduler
can more accurately compute the pressure.

Fixes lima/mesa#104.

Reviewed-by: Vasily Khoruzhick <anarsoul@gmail.com>
Tested-by: Vasily Khoruzhick <anarsoul@gmail.com>
This commit is contained in:
Connor Abbott 2019-09-01 19:33:06 +02:00
parent ae5ac26dfa
commit ee8cc90e55
3 changed files with 3 additions and 24 deletions

View File

@ -442,7 +442,6 @@ void gpir_instr_print_prog(gpir_compiler *comp);
bool gpir_codegen_acc_same_op(gpir_op op1, gpir_op op2);
bool gpir_pre_rsched_lower_prog(gpir_compiler *comp);
bool gpir_post_rsched_lower_prog(gpir_compiler *comp);
bool gpir_reduce_reg_pressure_schedule_prog(gpir_compiler *comp);
bool gpir_regalloc_prog(gpir_compiler *comp);
bool gpir_schedule_prog(gpir_compiler *comp);

View File

@ -416,9 +416,6 @@ static bool gpir_lower_not(gpir_block *block, gpir_node *node)
static bool (*gpir_pre_rsched_lower_funcs[gpir_op_num])(gpir_block *, gpir_node *) = {
[gpir_op_not] = gpir_lower_not,
};
static bool (*gpir_post_rsched_lower_funcs[gpir_op_num])(gpir_block *, gpir_node *) = {
[gpir_op_neg] = gpir_lower_neg,
[gpir_op_rcp] = gpir_lower_complex,
[gpir_op_rsqrt] = gpir_lower_complex,
@ -445,25 +442,11 @@ bool gpir_pre_rsched_lower_prog(gpir_compiler *comp)
if (!gpir_lower_load(comp))
return false;
if (!gpir_lower_node_may_consume_two_slots(comp))
return false;
gpir_debug("pre rsched lower prog\n");
gpir_node_print_prog_seq(comp);
return true;
}
bool gpir_post_rsched_lower_prog(gpir_compiler *comp)
{
list_for_each_entry(gpir_block, block, &comp->block_list, list) {
list_for_each_entry_safe(gpir_node, node, &block->node_list, list) {
if (gpir_post_rsched_lower_funcs[node->op] &&
!gpir_post_rsched_lower_funcs[node->op](block, node))
return false;
}
}
if (!gpir_lower_node_may_consume_two_slots(comp))
return false;
gpir_debug("post rsched lower prog\n");
gpir_node_print_prog_seq(comp);
return true;
}

View File

@ -445,9 +445,6 @@ bool gpir_compile_nir(struct lima_vs_shader_state *prog, struct nir_shader *nir,
if (!gpir_reduce_reg_pressure_schedule_prog(comp))
goto err_out0;
if (!gpir_post_rsched_lower_prog(comp))
goto err_out0;
if (!gpir_regalloc_prog(comp))
goto err_out0;