From 3d8ff40d582d84ea8c351dbab3a335fdcb83a5bc Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Mon, 2 Mar 2026 01:40:42 +0100 Subject: [PATCH] nir: fix nir_alu_type_range_contains_type_range for fp16 to int The special value "Inf" doesn't fit into an int and therefore we have to clamp regardless of whether all the other values would fit. And because f2u32 and f2u64 define out-of-range conversions as UB in nir, we need to clamp. This change should have no effect for non saturating conversions. Fixes "conversions long_sat_*half" CL CTS tests Cc: mesa-stable Suggested-by: Rob Clark Reviewed-by: Rob Clark Reviewed-by: Erik Faye-Lund (cherry picked from commit 8e8fb2ebaa3677352ad7dac0ff8b9e42aa18d2ea) Part-of: --- .pick_status.json | 2 +- src/compiler/nir/nir_conversion_builder.h | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 792cd6d0919..e8c2f7d7838 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -3454,7 +3454,7 @@ "description": "nir: fix nir_alu_type_range_contains_type_range for fp16 to int", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/compiler/nir/nir_conversion_builder.h b/src/compiler/nir/nir_conversion_builder.h index b0f070a5c07..e24dd1cbb18 100644 --- a/src/compiler/nir/nir_conversion_builder.h +++ b/src/compiler/nir/nir_conversion_builder.h @@ -207,11 +207,6 @@ nir_alu_type_range_contains_type_range(nir_alu_type a, nir_alu_type b) a_bit_size > b_bit_size) return true; - /* 16-bit floats fit in 32-bit integers */ - if (a_base_type == nir_type_int && a_bit_size >= 32 && - b == nir_type_float16) - return true; - /* All signed or unsigned ints can fit in float or above. A uint8 can fit * in a float16. */