nir/move_vec_src_uses_to_dest: skip reuse if vec is used only once in store_output

lima and etnaviv show no change in shader-db.

crocus HSW:
total instructions in shared programs: 1576762 -> 1576736 (<.01%)
instructions in affected programs: 485 -> 459 (-5.36%)
helped: 28
HURT: 1
total cycles in shared programs: 111025898 -> 111025838 (<.01%)
cycles in affected programs: 1248 -> 1188 (-4.81%)
helped: 29
HURT: 0

RV370:
total instructions in shared programs: 63889 -> 63558 (-0.52%)
instructions in affected programs: 9116 -> 8785 (-3.63%)
helped: 129
HURT: 0
total temps in shared programs: 10071 -> 10016 (-0.55%)
temps in affected programs: 285 -> 230 (-19.30%)
helped: 51
HURT: 0
total cycles in shared programs: 101344 -> 100997 (-0.34%)
cycles in affected programs: 9326 -> 8979 (-3.72%)
helped: 129
HURT: 0

RV530:
total instructions in shared programs: 93597 -> 93267 (-0.35%)
instructions in affected programs: 10309 -> 9979 (-3.20%)
helped: 166
HURT: 0
total temps in shared programs: 13019 -> 12955 (-0.49%)
temps in affected programs: 337 -> 273 (-18.99%)
helped: 61
HURT: 1
total cycles in shared programs: 144506 -> 144159 (-0.24%)
cycles in affected programs: 10662 -> 10315 (-3.25%)
helped: 165
HURT: 0

Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24932>
This commit is contained in:
Pavel Ondračka 2023-08-29 08:06:24 +02:00
parent 8ac975fa5e
commit dc60194599

View file

@ -77,6 +77,19 @@ move_vec_src_uses_to_dest_block(nir_block *block)
continue; /* The loop */
}
/* If the vec is used only in single store output than by reusing it
* we lose the ability to write it to the output directly.
*/
if (list_is_singular(&vec->def.uses)) {
nir_src *src = list_first_entry(&vec->def.uses, nir_src, use_link);
nir_instr *use_instr = src->parent_instr;
if (use_instr->type == nir_instr_type_intrinsic) {
nir_intrinsic_instr *intr = nir_instr_as_intrinsic(use_instr);
if (intr->intrinsic == nir_intrinsic_store_output)
return false;
}
}
/* First, mark all of the sources we are going to consider for rewriting
* to the destination
*/