nir/opt_large_constants: set fp_math_ctrl for bit exact results

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33002>
This commit is contained in:
Georg Lehmann 2026-03-18 12:00:41 +01:00 committed by Marge Bot
parent e810382a1e
commit 568b96f8b2
2 changed files with 7 additions and 1 deletions

View file

@ -533,6 +533,12 @@ nir_opt_large_constants(nir_shader *shader,
nir_builder b = nir_builder_create(impl);
/* We must preserve signed zero and disallow e.g. fma fusion
* when we create new floating point instructions because it's not
* even clear the result is only used as float.
*/
b.fp_math_ctrl = nir_fp_exact | nir_fp_preserve_signed_zero;
nir_foreach_block(block, impl) {
nir_foreach_instr_safe(instr, block) {
if (instr->type == nir_instr_type_deref) {

View file

@ -208,7 +208,7 @@ TEST_F(nir_large_constants_test, small_float_natural_numbers_including_zero_arra
32 %4 = ushr %1 (0x76543210), %3
32 %5 = load_const (0x0000000f = 15)
32 %6 = iand %4, %5 (0xf)
32 %7 = u2f32 %6
32 %7 = u2f32 %6 // exact, preserve:sz
@use (%7)
// succs: b1
block b1: