mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-02 18:10:17 +01:00
nir/search_helpers: handle bcsel in is_only_used_as_float
this lets algebraic see through chains of instructions. v2: Limit recursion depth (Georg). Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Marek Olšák <marek.olsak@amd.com> [v1] Reviewed-by: Georg Lehmann <dadschoorse@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32398>
This commit is contained in:
parent
ecc4d5da67
commit
be049e1c14
1 changed files with 21 additions and 1 deletions
|
|
@ -542,7 +542,7 @@ is_used_by_non_fsat(const nir_alu_instr *instr)
|
|||
}
|
||||
|
||||
static inline bool
|
||||
is_only_used_as_float(const nir_alu_instr *instr)
|
||||
is_only_used_as_float_impl(const nir_alu_instr *instr, unsigned depth)
|
||||
{
|
||||
nir_foreach_use(src, &instr->def) {
|
||||
const nir_instr *const user_instr = nir_src_parent_instr(src);
|
||||
|
|
@ -568,6 +568,20 @@ is_only_used_as_float(const nir_alu_instr *instr)
|
|||
assert(instr != user_alu);
|
||||
|
||||
unsigned index = (nir_alu_src *)container_of(src, nir_alu_src, src) - user_alu->src;
|
||||
|
||||
/* bcsel acts like a move: if the bcsel is only used by float
|
||||
* instructions, then the original value is (transitively) only used by
|
||||
* float too.
|
||||
*
|
||||
* The unbounded recursion would terminate because use chains are acyclic
|
||||
* in SSA. However, we limit the search depth regardless to avoid stack
|
||||
* overflows in patholgical shaders and to reduce the worst-case time.
|
||||
*/
|
||||
if (user_alu->op == nir_op_bcsel && index != 0 && depth < 8) {
|
||||
if (is_only_used_as_float_impl(user_alu, depth + 1))
|
||||
continue;
|
||||
}
|
||||
|
||||
nir_alu_type type = nir_op_infos[user_alu->op].input_types[index];
|
||||
if (nir_alu_type_get_base_type(type) != nir_type_float)
|
||||
return false;
|
||||
|
|
@ -576,6 +590,12 @@ is_only_used_as_float(const nir_alu_instr *instr)
|
|||
return true;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
is_only_used_as_float(const nir_alu_instr *instr)
|
||||
{
|
||||
return is_only_used_as_float_impl(instr, 0);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
is_only_used_by_fadd(const nir_alu_instr *instr)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue