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

This commit is contained in:
Matt Arsenault 2026-03-24 08:27:11 +01:00 committed by GitHub
parent 2e39b1e560
commit 32c6a53b76
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 0 deletions

View File

@ -120,6 +120,12 @@ _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __CLC_XCONCAT(__CLC_FUNCTION,
#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 @@ _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __CLC_XCONCAT(__CLC_FUNCTION,
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

View File

@ -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"