mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-29 18:50:10 +01:00
nir: Do peephole select on other instructions if the limit is ~0.
limit==0 is the signal for "don't peephole anything but a move that will be optimized aways." limit > 0 is "up to N alu instructions may be moved out." nir-to-tgsi uses ~0 as the indicator of "No, we really need to eliminate all if instructions" on hardware like i915 that doesn't have control flow. Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Reviewed-by: Adam Jackson <ajax@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11329>
This commit is contained in:
parent
aba8b6675a
commit
47804f53f9
1 changed files with 31 additions and 3 deletions
|
|
@ -61,9 +61,37 @@
|
|||
|
||||
static bool
|
||||
block_check_for_allowed_instrs(nir_block *block, unsigned *count,
|
||||
bool alu_ok, bool indirect_load_ok,
|
||||
unsigned limit, bool indirect_load_ok,
|
||||
bool expensive_alu_ok)
|
||||
{
|
||||
bool alu_ok = limit != 0;
|
||||
|
||||
/* Used on non-control-flow HW to flatten all IFs. */
|
||||
if (limit == ~0) {
|
||||
nir_foreach_instr(instr, block) {
|
||||
switch (instr->type) {
|
||||
case nir_instr_type_alu:
|
||||
case nir_instr_type_deref:
|
||||
case nir_instr_type_load_const:
|
||||
case nir_instr_type_phi:
|
||||
case nir_instr_type_ssa_undef:
|
||||
case nir_instr_type_tex:
|
||||
break;
|
||||
|
||||
case nir_instr_type_intrinsic:
|
||||
if (!nir_intrinsic_can_reorder(nir_instr_as_intrinsic(instr)))
|
||||
return false;
|
||||
break;
|
||||
|
||||
case nir_instr_type_call:
|
||||
case nir_instr_type_jump:
|
||||
case nir_instr_type_parallel_copy:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
nir_foreach_instr(instr, block) {
|
||||
switch (instr->type) {
|
||||
case nir_instr_type_intrinsic: {
|
||||
|
|
@ -379,9 +407,9 @@ nir_opt_peephole_select_block(nir_block *block, nir_shader *shader,
|
|||
|
||||
/* ... and those blocks must only contain "allowed" instructions. */
|
||||
unsigned count = 0;
|
||||
if (!block_check_for_allowed_instrs(then_block, &count, limit != 0,
|
||||
if (!block_check_for_allowed_instrs(then_block, &count, limit,
|
||||
indirect_load_ok, expensive_alu_ok) ||
|
||||
!block_check_for_allowed_instrs(else_block, &count, limit != 0,
|
||||
!block_check_for_allowed_instrs(else_block, &count, limit,
|
||||
indirect_load_ok, expensive_alu_ok))
|
||||
return false;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue