From d7e88c0ccdb516edcafa4df6f8dc4b1294f67733 Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Wed, 14 Jan 2026 14:52:28 +0100 Subject: [PATCH] nir/constant_expressions: flush input denorms if denorms have to be flushed Reviewed-by: Alyssa Rosenzweig Part-of: --- src/compiler/nir/nir_constant_expressions.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/compiler/nir/nir_constant_expressions.py b/src/compiler/nir/nir_constant_expressions.py index 007a0030f49..f177a77aabd 100644 --- a/src/compiler/nir/nir_constant_expressions.py +++ b/src/compiler/nir/nir_constant_expressions.py @@ -91,6 +91,15 @@ constant_denorm_flush_to_zero(nir_const_value *value, unsigned bit_size) } } +static double +get_float_source(nir_const_value value, unsigned execution_mode, unsigned bit_size) +{ + if (nir_is_denorm_flush_to_zero(execution_mode, bit_size)) + constant_denorm_flush_to_zero(&value, bit_size); + + return nir_const_value_as_float(value, bit_size); +} + /** * Evaluate one component of packSnorm4x8. */ @@ -455,8 +464,8 @@ struct ${type}${width}_vec { % if input_types[j] == "int1": /* 1-bit integers use a 0/-1 convention */ -(int1_t)_src[${j}][${k}].b, - % elif input_types[j] == "float16": - _mesa_half_to_float(_src[${j}][${k}].u16), + % elif type_base_type(input_types[j]) == "float": + get_float_source(_src[${j}][${k}], execution_mode, ${type_size(input_types[j])}), % else: _src[${j}][${k}].${get_const_field(input_types[j])}, % endif @@ -481,9 +490,9 @@ struct ${type}${width}_vec { % elif input_types[j] == "int1": /* 1-bit integers use a 0/-1 convention */ const int1_t src${j} = -(int1_t)_src[${j}][_i].b; - % elif input_types[j] == "float16": - const float src${j} = - _mesa_half_to_float(_src[${j}][_i].u16); + % elif type_base_type(input_types[j]) == "float": + const ${input_types[j]}_t src${j} = + get_float_source(_src[${j}][_i], execution_mode, ${type_size(input_types[j])}); % else: const ${input_types[j]}_t src${j} = _src[${j}][_i].${get_const_field(input_types[j])};