mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 00:58:05 +02:00
nir/opt_if: Conditionally do not propagate constants through bcsel
In some cases propagating through a bcsel may be harmful. If the bcsel uses are unlikely to be eliminated in both branch of an if statement, propagating through it may result in extra moves for phi instructions and extended live ranges. v2: Fix missing parameter in call. Noticed by Rhys. I fixed this on the test machine, but I must have forgotten to propagate the change back to my dev machine. Reviewed-by: Rhys Perry <pendingchaos02@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38321>
This commit is contained in:
parent
a3b6d05a3b
commit
3e0c9ad316
1 changed files with 10 additions and 3 deletions
|
|
@ -958,8 +958,15 @@ propagate_condition_eval(nir_builder *b, nir_if *nif, nir_src *use_src,
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* In some cases propagating through a bcsel may be harmful. If the bcsel uses
|
||||
* are unlikely to be eliminated in both branch of an if statement,
|
||||
* propagating through it may result in extra moves for phi instructions and
|
||||
* extended live ranges. The \c ignore_bcsel flag can be used to avoid these
|
||||
* cases.
|
||||
*/
|
||||
static bool
|
||||
can_propagate_through_alu(nir_src *src)
|
||||
can_propagate_through_alu(nir_src *src, bool ignore_bcsel)
|
||||
{
|
||||
if (nir_src_parent_instr(src)->type != nir_instr_type_alu)
|
||||
return false;
|
||||
|
|
@ -972,7 +979,7 @@ can_propagate_through_alu(nir_src *src)
|
|||
case nir_op_b2i32:
|
||||
return true;
|
||||
case nir_op_bcsel:
|
||||
return src == &alu->src[0].src;
|
||||
return src == &alu->src[0].src && !ignore_bcsel;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
|
@ -993,7 +1000,7 @@ evaluate_condition_use(nir_builder *b, nir_if *nif, nir_src *use_src,
|
|||
progress = true;
|
||||
}
|
||||
|
||||
if (!nir_src_is_if(use_src) && can_propagate_through_alu(use_src)) {
|
||||
if (!nir_src_is_if(use_src) && can_propagate_through_alu(use_src), false) {
|
||||
nir_alu_instr *alu = nir_instr_as_alu(nir_src_parent_instr(use_src));
|
||||
|
||||
nir_foreach_use_including_if_safe(alu_use, &alu->def) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue