libclc: Fix -cl-denorms-are-zero for rtp and rtn conversions (#188148)

GitOrigin-RevId: 32c6a53b767850183208aff8b783e6bc08f21515
diff --git a/clc/lib/generic/conversion/clc_convert_float.inc b/clc/lib/generic/conversion/clc_convert_float.inc
index 52244b2..2e2d60d 100644
--- a/clc/lib/generic/conversion/clc_convert_float.inc
+++ b/clc/lib/generic/conversion/clc_convert_float.inc
@@ -120,6 +120,12 @@
 #endif
   __CLC_GENTYPE sel =
       __clc_select(r, __clc_nextup(r), __CLC_CONVERT_S_GENTYPE(y < x));
+
+#ifndef __CLC_I2F
+  if (__CLC_GENTYPE_DENORMS_ARE_ZERO)
+    sel = __clc_select(sel, r, __CLC_CONVERT_S_GENTYPE(r == __CLC_FP_LIT(0.0)));
+#endif
+
 #if defined(__CLC_I2F) && (__CLC_FPSIZE == 16) && (__CLC_GENSIZE_SRC >= 16)
   half dst_min = -0x1.ffcp+15h;
   sel = __clc_max(sel, (__CLC_GENTYPE)dst_min);
@@ -141,6 +147,12 @@
   c = c || __CLC_CONVERT_S_GENTYPE((__CLC_GENTYPE_SRC)__CLC_SRC_MAX == x);
 #endif
   __CLC_GENTYPE sel = __clc_select(r, __clc_nextdown(r), c);
+
+#ifndef __CLC_I2F
+  if (__CLC_GENTYPE_DENORMS_ARE_ZERO)
+    sel = __clc_select(sel, r, __CLC_CONVERT_S_GENTYPE(r == __CLC_FP_LIT(0.0)));
+#endif
+
 #if defined(__CLC_I2F) && (__CLC_FPSIZE == 16) && (__CLC_GENSIZE_SRC >= 16)
 #if defined(__CLC_GEN_S) && (__CLC_GENSIZE_SRC == 16)
   // short is 16 bits signed, so the maximum value rounded to negative infinity
diff --git a/clc/lib/generic/conversion/clc_convert_float2float.cl b/clc/lib/generic/conversion/clc_convert_float2float.cl
index 5280e52..2993a19 100644
--- a/clc/lib/generic/conversion/clc_convert_float2float.cl
+++ b/clc/lib/generic/conversion/clc_convert_float2float.cl
@@ -13,6 +13,7 @@
 #include "clc/math/clc_nextafter.h"
 #include "clc/math/clc_nextdown.h"
 #include "clc/math/clc_nextup.h"
+#include "clc/math/clc_subnormal_config.h"
 #include "clc/relational/clc_select.h"
 #include "clc/shared/clc_clamp.h"