nir/opt_algebraic: optimize bcsel to hi 16bits with undef lo

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39412>
This commit is contained in:
Georg Lehmann 2026-01-20 19:21:32 +01:00 committed by Marge Bot
parent d06b627d23
commit b2d9615000
2 changed files with 14 additions and 0 deletions

View file

@ -3130,6 +3130,13 @@ optimizations += [
('bcsel', a, ('pack_half_2x16_rtz_split', b, d), ('pack_half_2x16_rtz_split', c, e))),
(('pack_half_2x16_rtz_split', ('b2f', 'a@1'), ('b2f', a)), ('bcsel', a, 0x3c003c00, 0)),
(('pack_32_2x16_split', 'a(is_undef)', ('bcsel', b, '#c', d)),
('bcsel', b, ('pack_32_2x16_split', 0, c), ('pack_32_2x16_split', a, d)),
'true', TestStatus.UNSUPPORTED),
(('pack_32_2x16_split', 'a(is_undef)', ('bcsel', b, c, '#d')),
('bcsel', b, ('pack_32_2x16_split', a, c), ('pack_32_2x16_split', 0, d)),
'true', TestStatus.UNSUPPORTED),
]
# Some operations such as iadd have the property that the bottom N bits of the

View file

@ -1079,4 +1079,11 @@ is_created_as_float(const nir_search_state *state, const nir_alu_instr *instr, u
return nir_alu_type_get_base_type(output_type) == nir_type_float;
}
static inline bool
is_undef(const nir_search_state *state, const nir_alu_instr *instr, unsigned src,
UNUSED unsigned num_components, UNUSED const uint8_t *swizzle)
{
return nir_src_is_undef(instr->src[src].src);
}
#endif /* _NIR_SEARCH_ */