nir: add an option to lower bf2f and f2bf

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34768>
This commit is contained in:
Georg Lehmann 2025-04-30 12:16:44 +02:00 committed by Marge Bot
parent 7716e63cd6
commit 02e743c99e
2 changed files with 10 additions and 0 deletions

View file

@ -1450,6 +1450,11 @@ optimizations.extend([
(('fany_nequal4', a, b), ('fsat', ('fdot4', ('sne', a, b), ('sne', a, b))), 'options->lower_vector_cmp'),
(('fany_nequal8', a, b), ('fsat', ('fdot8', ('sne', a, b), ('sne', a, b))), 'options->lower_vector_cmp'),
(('fany_nequal16', a, b), ('fsat', ('fdot16', ('sne', a, b), ('sne', a, b))), 'options->lower_vector_cmp'),
# Vulkan allows us to use any rounding mode, so choose rtz because it's simple.
# Avoid some NaNs being converted to Inf if the lsb are cut off.
(('f2bf', a), ('bcsel', ('!fneu', a, a), -1, ('unpack_32_2x16_split_y', a)), 'options->lower_bfloat16_conversions'),
(('bf2f', a), ('pack_32_2x16', ('vec2', 0, a)), 'options->lower_bfloat16_conversions'),
])
def vector_cmp(reduce_op, cmp_op, comps):

View file

@ -456,6 +456,11 @@ typedef struct nir_shader_compiler_options {
*/
bool lower_mul_32x16;
/**
* Set if bf2f and f2bf should be lowered to arithmetic.
*/
bool lower_bfloat16_conversions;
bool vectorize_tess_levels;
bool lower_to_scalar;
nir_instr_filter_cb lower_to_scalar_filter;