Skip to content

Commit b4263dd

Browse files
committed
[libclc] Use __clc_max in CLC functions
1 parent 7be30fd commit b4263dd

File tree

5 files changed

+10
-5
lines changed

5 files changed

+10
-5
lines changed

libclc/generic/lib/math/clc_fma.cl

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <clc/clc.h>
2424
#include <clc/clcmacro.h>
2525
#include <clc/integer/clc_abs.h>
26+
#include <clc/shared/clc_max.h>
2627

2728
#include "config.h"
2829
#include "math.h"
@@ -98,7 +99,7 @@ _CLC_DEF _CLC_OVERLOAD float __clc_sw_fma(float a, float b, float c) {
9899

99100
struct fp st_fma;
100101
st_fma.sign = st_mul.sign;
101-
st_fma.exponent = max(st_mul.exponent, st_c.exponent);
102+
st_fma.exponent = __clc_max(st_mul.exponent, st_c.exponent);
102103
if (st_c.sign == st_mul.sign) {
103104
st_fma.mantissa = st_mul.mantissa + st_c.mantissa;
104105
} else {

libclc/generic/lib/math/clc_fmod.cl

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <clc/clcmacro.h>
2525
#include <clc/math/clc_floor.h>
2626
#include <clc/math/clc_trunc.h>
27+
#include <clc/shared/clc_max.h>
2728

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

libclc/generic/lib/math/clc_remainder.cl

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <clc/clcmacro.h>
2525
#include <clc/math/clc_floor.h>
2626
#include <clc/math/clc_trunc.h>
27+
#include <clc/shared/clc_max.h>
2728

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

libclc/generic/lib/math/clc_remquo.cl

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <clc/clcmacro.h>
2525
#include <clc/math/clc_floor.h>
2626
#include <clc/math/clc_trunc.h>
27+
#include <clc/shared/clc_max.h>
2728

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

libclc/generic/lib/math/sincos_helpers.cl

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
*/
2222

2323
#include <clc/clc.h>
24+
#include <clc/shared/clc_max.h>
2425

2526
#include "math.h"
2627
#include "tables.h"
@@ -372,7 +373,7 @@ _CLC_DEF void __clc_remainder_piby2_large(double x, double *r, double *rr, int *
372373

373374
long ux = as_long(x);
374375
int e = (int)(ux >> 52) - 1023;
375-
int i = max(23, (e >> 3) + 17);
376+
int i = __clc_max(23, (e >> 3) + 17);
376377
int j = 150 - i;
377378
int j16 = j & ~0xf;
378379
double fract_temp;

0 commit comments

Comments
 (0)