[libclc] Use __clc_max in CLC functions

This commit is contained in:
Fraser Cormack 2024-11-05 09:35:34 +00:00
parent 7be30fd533
commit b4263ddbe7
5 changed files with 10 additions and 5 deletions

View File

@ -23,6 +23,7 @@
#include <clc/clc.h>
#include <clc/clcmacro.h>
#include <clc/integer/clc_abs.h>
#include <clc/shared/clc_max.h>
#include "config.h"
#include "math.h"
@ -98,7 +99,7 @@ _CLC_DEF _CLC_OVERLOAD float __clc_sw_fma(float a, float b, float c) {
struct fp st_fma;
st_fma.sign = st_mul.sign;
st_fma.exponent = max(st_mul.exponent, st_c.exponent);
st_fma.exponent = __clc_max(st_mul.exponent, st_c.exponent);
if (st_c.sign == st_mul.sign) {
st_fma.mantissa = st_mul.mantissa + st_c.mantissa;
} else {

View File

@ -24,6 +24,7 @@
#include <clc/clcmacro.h>
#include <clc/math/clc_floor.h>
#include <clc/math/clc_trunc.h>
#include <clc/shared/clc_max.h>
#include <math/clc_remainder.h>
#include "config.h"
@ -105,7 +106,7 @@ _CLC_DEF _CLC_OVERLOAD double __clc_fmod(double x, double y)
// less than the mantissa of y, ntimes will be one too large
// but it doesn't matter - it just means that we'll go round
// the loop below one extra time.
int ntimes = max(0, (xexp1 - yexp1) / 53);
int ntimes = __clc_max(0, (xexp1 - yexp1) / 53);
double w = ldexp(dy, ntimes * 53);
w = ntimes == 0 ? dy : w;
double scale = ntimes == 0 ? 1.0 : 0x1.0p-53;

View File

@ -24,6 +24,7 @@
#include <clc/clcmacro.h>
#include <clc/math/clc_floor.h>
#include <clc/math/clc_trunc.h>
#include <clc/shared/clc_max.h>
#include <math/clc_remainder.h>
#include "config.h"
@ -115,7 +116,7 @@ _CLC_DEF _CLC_OVERLOAD double __clc_remainder(double x, double y)
// less than the mantissa of y, ntimes will be one too large
// but it doesn't matter - it just means that we'll go round
// the loop below one extra time.
int ntimes = max(0, (xexp1 - yexp1) / 53);
int ntimes = __clc_max(0, (xexp1 - yexp1) / 53);
double w = ldexp(dy, ntimes * 53);
w = ntimes == 0 ? dy : w;
double scale = ntimes == 0 ? 1.0 : 0x1.0p-53;

View File

@ -24,6 +24,7 @@
#include <clc/clcmacro.h>
#include <clc/math/clc_floor.h>
#include <clc/math/clc_trunc.h>
#include <clc/shared/clc_max.h>
#include <math/clc_remainder.h>
#include "config.h"
@ -140,7 +141,7 @@ _CLC_DEF _CLC_OVERLOAD double __clc_remquo(double x, double y, __private int *pq
// less than the mantissa of y, ntimes will be one too large
// but it doesn't matter - it just means that we'll go round
// the loop below one extra time.
int ntimes = max(0, (xexp1 - yexp1) / 53);
int ntimes = __clc_max(0, (xexp1 - yexp1) / 53);
double w = ldexp(dy, ntimes * 53);
w = ntimes == 0 ? dy : w;
double scale = ntimes == 0 ? 1.0 : 0x1.0p-53;

View File

@ -21,6 +21,7 @@
*/
#include <clc/clc.h>
#include <clc/shared/clc_max.h>
#include "math.h"
#include "tables.h"
@ -372,7 +373,7 @@ _CLC_DEF void __clc_remainder_piby2_large(double x, double *r, double *rr, int *
long ux = as_long(x);
int e = (int)(ux >> 52) - 1023;
int i = max(23, (e >> 3) + 17);
int i = __clc_max(23, (e >> 3) + 17);
int j = 150 - i;
int j16 = j & ~0xf;
double fract_temp;