libclc: Replace flush_if_daz implementation (#187569)

The fallback non-canonicalize path didn't work. Use a more
straightforward implementation. Eventually this should use
the pattern from #172998
This commit is contained in:
Matt Arsenault 2026-03-20 08:09:16 +01:00 committed by GitHub
parent 5599d60187
commit 090c40545f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 7 deletions

View File

@ -6,10 +6,14 @@
//
//===----------------------------------------------------------------------===//
#include "clc/clc_convert.h"
#include "clc/float/definitions.h"
#include "clc/math/clc_canonicalize.h"
#include "clc/math/clc_copysign.h"
#include "clc/math/clc_fabs.h"
#include "clc/math/clc_flush_if_daz.h"
#include "clc/math/clc_subnormal_config.h"
#include "clc/math/math.h"
#include "clc/relational/clc_select.h"
#define __CLC_BODY "clc_flush_if_daz.inc"
#include "clc/math/gentype.inc"

View File

@ -26,13 +26,9 @@ _CLC_DEF _CLC_OVERLOAD __CLC_GENTYPE __clc_flush_if_daz(__CLC_GENTYPE x) {
// Hack around canonicalize not working on spirv.
#if defined(CLC_SPIRV) || defined(CLC_CLSPV)
__CLC_S_GENTYPE ix = __CLC_AS_S_GENTYPE(x);
__CLC_S_GENTYPE should_flush =
((ix & __CLC_GENTYPE_EXPBITS) == (__CLC_S_GENTYPE)0) &&
((ix & __CLC_GENTYPE_MANTBITS) != (__CLC_S_GENTYPE)0);
__CLC_S_GENTYPE signbit = ix &= __CLC_GENTYPE_SIGNBIT;
__CLC_S_GENTYPE result = should_flush ? signbit : ix;
return __CLC_AS_GENTYPE(result);
__CLC_S_GENTYPE is_denorm_or_zero = __clc_fabs(x) < __CLC_GENTYPE_MIN;
return __clc_select(x, __clc_copysign(__CLC_FP_LIT(0.0), x),
is_denorm_or_zero);
#else
return __clc_canonicalize(x);
#endif