Skip to content

Commit 498020f

Browse files
committed
[libclc] fix clspv/shared/vstore_half.cl
Update as_type functions
1 parent 8dee997 commit 498020f

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

libclc/opencl/lib/clspv/shared/vstore_half.cl

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//===----------------------------------------------------------------------===//
88

99
#include <clc/float/definitions.h>
10+
#include <clc/clc_as_type.h>
1011
#include <clc/opencl/math/copysign.h>
1112
#include <clc/opencl/math/fabs.h>
1213
#include <clc/opencl/math/nextafter.h>
@@ -59,7 +60,7 @@ _CLC_DEF _CLC_OVERLOAD float __clc_rtz(float x) {
5960
if (fabs(x) > 65504.0f && !isinf(x))
6061
return copysign(65504.0f, x);
6162

62-
const int exp = (as_uint(x) >> 23 & 0xff) - 127;
63+
const int exp = (__clc_as_uint(x) >> 23 & 0xff) - 127;
6364
/* Manage range rounded to +- zero explicitely */
6465
if (exp < -24)
6566
return copysign(0.0f, x);
@@ -70,7 +71,7 @@ _CLC_DEF _CLC_OVERLOAD float __clc_rtz(float x) {
7071
if (exp < -14)
7172
mask <<= min(-(exp + 14), 10);
7273

73-
return as_float(as_uint(x) & mask);
74+
return __clc_as_float(__clc_as_uint(x) & mask);
7475
}
7576

7677
_CLC_DEF _CLC_OVERLOAD float __clc_rti(float x) {
@@ -79,18 +80,18 @@ _CLC_DEF _CLC_OVERLOAD float __clc_rti(float x) {
7980
return x;
8081

8182
const float inf = copysign(INFINITY, x);
82-
uint ux = as_uint(x);
83+
uint ux = __clc_as_uint(x);
8384

8485
/* Manage +- infinity explicitely */
85-
if (as_float(ux & 0x7fffffff) > 0x1.ffcp+15f) {
86+
if (__clc_as_float(ux & 0x7fffffff) > 0x1.ffcp+15f) {
8687
return inf;
8788
}
8889
/* Manage +- zero explicitely */
8990
if ((ux & 0x7fffffff) == 0) {
9091
return copysign(0.0f, x);
9192
}
9293

93-
const int exp = (as_uint(x) >> 23 & 0xff) - 127;
94+
const int exp = (__clc_as_uint(x) >> 23 & 0xff) - 127;
9495
/* Manage range rounded to smallest half denormal explicitely */
9596
if (exp < -24) {
9697
return copysign(0x1.0p-24f, x);
@@ -103,19 +104,19 @@ _CLC_DEF _CLC_OVERLOAD float __clc_rti(float x) {
103104
mask = (1 << (13 + min(-(exp + 14), 10))) - 1;
104105
}
105106

106-
const float next = nextafter(as_float(ux | mask), inf);
107-
return ((ux & mask) == 0) ? as_float(ux) : next;
107+
const float next = nextafter(__clc_as_float(ux | mask), inf);
108+
return ((ux & mask) == 0) ? __clc_as_float(ux) : next;
108109
}
109110
_CLC_DEF _CLC_OVERLOAD float __clc_rtn(float x) {
110-
return ((as_uint(x) & 0x80000000) == 0) ? __clc_rtz(x) : __clc_rti(x);
111+
return ((__clc_as_uint(x) & 0x80000000) == 0) ? __clc_rtz(x) : __clc_rti(x);
111112
}
112113
_CLC_DEF _CLC_OVERLOAD float __clc_rtp(float x) {
113-
return ((as_uint(x) & 0x80000000) == 0) ? __clc_rti(x) : __clc_rtz(x);
114+
return ((__clc_as_uint(x) & 0x80000000) == 0) ? __clc_rti(x) : __clc_rtz(x);
114115
}
115116
_CLC_DEF _CLC_OVERLOAD float __clc_rte(float x) {
116117
/* Mantisa + implicit bit */
117-
const uint mantissa = (as_uint(x) & 0x7fffff) | (1u << 23);
118-
const int exp = (as_uint(x) >> 23 & 0xff) - 127;
118+
const uint mantissa = (__clc_as_uint(x) & 0x7fffff) | (1u << 23);
119+
const int exp = (__clc_as_uint(x) >> 23 & 0xff) - 127;
119120
int shift = 13;
120121
if (exp < -14) {
121122
/* The default assumes lower 13 bits are rounded,

0 commit comments

Comments
 (0)