From ef5e58e513f622a3acc5cb9b93a01a56482a3319 Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Mon, 2 Feb 2026 15:32:40 +0100 Subject: [PATCH] glsl: make fp (not) equal always nan/inf preserving Outside of isnan/isinf this shouldn't be needed, but at this point they were already lowered. Reviewed-by: Alyssa Rosenzweig Reviewed-by: Rhys Perry Part-of: --- src/compiler/glsl/glsl_to_nir.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp index ed13b37080d..8b302ce9735 100644 --- a/src/compiler/glsl/glsl_to_nir.cpp +++ b/src/compiler/glsl/glsl_to_nir.cpp @@ -2471,19 +2471,24 @@ nir_visitor::visit(ir_expression *ir) result = nir_uge(&b, srcs[0], srcs[1]); break; case ir_binop_equal: - if (type_is_float(types[0])) + if (type_is_float(types[0])) { + b.fp_math_ctrl |= nir_fp_preserve_nan | nir_fp_preserve_inf; result = nir_feq(&b, srcs[0], srcs[1]); - else + } else { result = nir_ieq(&b, srcs[0], srcs[1]); + } break; case ir_binop_nequal: - if (type_is_float(types[0])) + if (type_is_float(types[0])) { + b.fp_math_ctrl |= nir_fp_preserve_nan | nir_fp_preserve_inf; result = nir_fneu(&b, srcs[0], srcs[1]); - else + } else { result = nir_ine(&b, srcs[0], srcs[1]); + } break; case ir_binop_all_equal: if (type_is_float(types[0])) { + b.fp_math_ctrl |= nir_fp_preserve_nan | nir_fp_preserve_inf; switch (ir->operands[0]->type->vector_elements) { case 1: result = nir_feq(&b, srcs[0], srcs[1]); break; case 2: result = nir_ball_fequal2(&b, srcs[0], srcs[1]); break; @@ -2505,6 +2510,7 @@ nir_visitor::visit(ir_expression *ir) break; case ir_binop_any_nequal: if (type_is_float(types[0])) { + b.fp_math_ctrl |= nir_fp_preserve_nan | nir_fp_preserve_inf; switch (ir->operands[0]->type->vector_elements) { case 1: result = nir_fneu(&b, srcs[0], srcs[1]); break; case 2: result = nir_bany_fnequal2(&b, srcs[0], srcs[1]); break;