Commit cc45239f authored by Timothy Arceri's avatar Timothy Arceri

wip be less destructive with instruction scheduling when a block contains pinned instructions

total instructions in shared programs: 15422340 -> 15015725 (-2.64%)
instructions in affected programs: 2744968 -> 2338353 (-14.81%)
helped: 4402
HURT: 465

total cycles in shared programs: 358373791 -> 243554152 (-32.04%)
cycles in affected programs: 213519287 -> 98699648 (-53.77%)
helped: 3930
HURT: 1034

total loops in shared programs: 4366 -> 4362 (-0.09%)
loops in affected programs: 8 -> 4 (-50.00%)
helped: 4
HURT: 0

total spills in shared programs: 23673 -> 16143 (-31.81%)
spills in affected programs: 18904 -> 11374 (-39.83%)
helped: 343
HURT: 65

total fills in shared programs: 32036 -> 29845 (-6.84%)
fills in affected programs: 18381 -> 16190 (-11.92%)
helped: 345
HURT: 65

LOST:   10
GAINED: 6

No uber shaders:

total instructions in shared programs: 15239852 -> 14811490 (-2.81%)
instructions in affected programs: 2562485 -> 2134123 (-16.72%)
helped: 4387
HURT: 425

total cycles in shared programs: 291098452 -> 203050594 (-30.25%)
cycles in affected programs: 146243972 -> 58196114 (-60.21%)
helped: 3875
HURT: 1034

total loops in shared programs: 3666 -> 3662 (-0.11%)
loops in affected programs: 8 -> 4 (-50.00%)
helped: 4
HURT: 0

total spills in shared programs: 21099 -> 5755 (-72.72%)
spills in affected programs: 16330 -> 986 (-93.96%)
helped: 343
HURT: 10

total fills in shared programs: 28481 -> 15614 (-45.18%)
fills in affected programs: 14826 -> 1959 (-86.79%)
helped: 345
HURT: 10

LOST:   11
GAINED: 6

No deus-ex shaders:

total instructions in shared programs: 13596456 -> 13545174 (-0.38%)
instructions in affected programs: 1538081 -> 1486799 (-3.33%)
helped: 3736
HURT: 422

total cycles in shared programs: 154429067 -> 153949773 (-0.31%)
cycles in affected programs: 18702937 -> 18223643 (-2.56%)
helped: 3251
HURT: 985

total loops in shared programs: 2381 -> 2377 (-0.17%)
loops in affected programs: 8 -> 4 (-50.00%)
helped: 4
HURT: 0

total spills in shared programs: 3914 -> 4163 (6.36%)
spills in affected programs: 597 -> 846 (41.71%)
helped: 1
HURT: 10

total fills in shared programs: 13618 -> 13745 (0.93%)
fills in affected programs: 1421 -> 1548 (8.94%)
helped: 3
HURT: 8

LOST:   11
GAINED: 5
parent 0c8b394d
......@@ -248,14 +248,14 @@ gcm_pin_instructions(nir_function_impl *impl, struct gcm_state *state)
case nir_instr_type_jump:
case nir_instr_type_ssa_undef:
case nir_instr_type_phi:
instr->pass_flags = GCM_INSTR_PINNED;
instr->pass_flags = GCM_INSTR_PLACED;
break;
default:
unreachable("Invalid instruction type in GCM");
}
if (!(instr->pass_flags & GCM_INSTR_PINNED)) {
if (!(instr->pass_flags & GCM_INSTR_PLACED)) {
/* If this is an unpinned instruction, go ahead and pull it out of
* the program and put it on the instrs list. This has a couple
* of benifits. First, it makes the scheduling algorithm more
......@@ -337,7 +337,8 @@ gcm_schedule_early_instr(nir_instr *instr, struct gcm_state *state)
* don't need to do anything. Also, bailing here keeps us from ever
* following the sources of phi nodes which can be back-edges.
*/
if (instr->pass_flags & GCM_INSTR_PINNED) {
if (instr->pass_flags & GCM_INSTR_PINNED ||
instr->pass_flags & GCM_INSTR_PLACED) {
state->instr_infos[instr->index].early_block = instr->block;
return;
}
......@@ -497,7 +498,8 @@ gcm_schedule_late_instr(nir_instr *instr, struct gcm_state *state)
* anything. Also, bailing here keeps us from ever following phi nodes
* which can be back-edges.
*/
if (instr->pass_flags & GCM_INSTR_PINNED)
if (instr->pass_flags & GCM_INSTR_PLACED ||
instr->pass_flags & GCM_INSTR_PINNED)
return;
nir_foreach_ssa_def(instr, gcm_schedule_late_def, state);
......@@ -561,48 +563,21 @@ gcm_place_instr(nir_instr *instr, struct gcm_state *state)
return;
}
/* Phi nodes are our once source of back-edges. Since right now we are
* only doing scheduling within blocks, we don't need to worry about
* them since they are always at the top. Just skip them completely.
*/
if (instr->type == nir_instr_type_phi) {
assert(instr->pass_flags & GCM_INSTR_PINNED);
return;
}
nir_foreach_ssa_def(instr, gcm_place_instr_def, state);
if (instr->pass_flags & GCM_INSTR_PINNED) {
/* Pinned instructions have an implicit dependence on the pinned
* instructions that come after them in the block. Since the pinned
* instructions will naturally "chain" together, we only need to
* explicitly visit one of them.
*/
for (nir_instr *after = nir_instr_next(instr);
after;
after = nir_instr_next(after)) {
if (after->pass_flags & GCM_INSTR_PINNED) {
gcm_place_instr(after, state);
break;
}
}
}
struct gcm_block_info *block_info = &state->blocks[instr->block->index];
if (!(instr->pass_flags & GCM_INSTR_PINNED)) {
exec_node_remove(&instr->node);
if (block_info->last_instr) {
exec_node_insert_node_before(&block_info->last_instr->node,
&instr->node);
exec_node_remove(&instr->node);
if (block_info->last_instr) {
exec_node_insert_node_before(&block_info->last_instr->node,
&instr->node);
} else {
/* Schedule it at the end of the block */
nir_instr *jump_instr = nir_block_last_instr(instr->block);
if (jump_instr && jump_instr->type == nir_instr_type_jump) {
exec_node_insert_node_before(&jump_instr->node, &instr->node);
} else {
/* Schedule it at the end of the block */
nir_instr *jump_instr = nir_block_last_instr(instr->block);
if (jump_instr && jump_instr->type == nir_instr_type_jump) {
exec_node_insert_node_before(&jump_instr->node, &instr->node);
} else {
exec_list_push_tail(&instr->block->instr_list, &instr->node);
}
exec_list_push_tail(&instr->block->instr_list, &instr->node);
}
}
......@@ -633,6 +608,9 @@ opt_gcm_impl(nir_function_impl *impl, bool value_number)
if (value_number) {
struct set *gvn_set = nir_instr_set_create(NULL);
foreach_list_typed_safe(nir_instr, instr, node, &state.instrs) {
if (instr->pass_flags & GCM_INSTR_PINNED)
continue;
if (nir_instr_set_add_or_rewrite(gvn_set, instr)) {
nir_instr_remove(instr);
state.progress = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment