nir/lower_alu: fix lower_fminmax_signed_zero for denorms

When both inputs are denorms, the bcsel picks the integer min/max result,
which does not flush denorms and therefore might return the wrong result.

Fixes OpenCL fmin/fmax on asahi.

Fixes: d238d766c6 ("nir: add lower_fminmax_signed_zero")

Reviewed-by: Mary Guillemard <mary@mary.zone>
Reviewed-by Janne Grunau <j@jannau.net>

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41386>
This commit is contained in:
Karol Herbst 2026-05-06 08:59:50 +02:00 committed by Marge Bot
parent 641d9f35ae
commit d25e7e330f

View file

@ -213,6 +213,7 @@ lower_alu_instr(nir_builder *b, nir_alu_instr *instr, UNUSED void *cb_data)
/* Fallback on the emulation */
if (!lowered) {
nir_def *iminmax = max ? nir_imax(b, s0, s1) : nir_imin(b, s0, s1);
iminmax = nir_fcanonicalize(b, iminmax);
lowered = nir_bcsel(b, nir_feq(b, s0, s1), iminmax, fminmax);
}