libclc: Fix signed 0 handling in sincospi (#211260)

This commit is contained in:
Matt Arsenault 2026-07-23 06:24:44 +02:00 committed by GitHub
parent 90d75e9dde
commit 55df598539
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 2 deletions

View file

@ -9,6 +9,7 @@
#include "clc/clc_convert.h"
#include "clc/float/definitions.h"
#include "clc/internal/clc.h"
#include "clc/math/clc_copysign.h"
#include "clc/math/clc_cos.h"
#include "clc/math/clc_fabs.h"
#include "clc/math/clc_sin.h"

View file

@ -29,8 +29,12 @@ __clc_sincospi(__CLC_GENTYPE x, __private __CLC_GENTYPE *cos_out) {
__CLC_GENTYPE c = odd ? -eval.sin : eval.cos;
*cos_out =
__CLC_AS_GENTYPE(__CLC_CONVERT_S_GENTYPE(__CLC_AS_S_GENTYPE(c) ^ flip));
return __CLC_AS_GENTYPE(sin_val);
__CLC_AS_GENTYPE(__CLC_CONVERT_S_GENTYPE(__CLC_AS_S_GENTYPE(c) ^ flip)) +
__CLC_FP_LIT(0.0);
__CLC_GENTYPE sin_result = __CLC_AS_GENTYPE(sin_val);
return __clc_select(sin_result, __clc_copysign(__CLC_FP_LIT(0.0), x),
__CLC_CONVERT_S_GENTYPE(sin_result == __CLC_FP_LIT(0.0)));
}
#define __CLC_SINCOSPI_DEF(addrspace) \