Skip to content

Commit b7a74a8

Browse files
committed
restore old constants; fix min val
1 parent e577b17 commit b7a74a8

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

libclc/clc/lib/generic/geometric/clc_normalize.inc

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//===----------------------------------------------------------------------===//
22
//
3+
34
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
45
// See https://llvm.org/LICENSE.txt for license information.
56
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
@@ -27,11 +28,25 @@ _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_normalize(__CLC_GENTYPE p) {
2728
#else
2829

2930
#if __CLC_FPSIZE == 32
31+
32+
#define MIN_VAL FLT_MIN
3033
#define MAX_SQRT 0x1.0p+86F
34+
#if __CLC_VECSIZE_OR_1 == 2
3135
#define MIN_SQRT 0x1.0p-65F
36+
#else
37+
#define MIN_SQRT 0x1.0p-66F
38+
#endif
39+
3240
#elif __CLC_FPSIZE == 64
41+
42+
#define MIN_VAL DBL_MIN
3343
#define MAX_SQRT 0x1.0p+563
44+
#if __CLC_VECSIZE_OR_1 == 2
3445
#define MIN_SQRT 0x1.0p-513
46+
#else
47+
#define MIN_SQRT 0x1.0p-514
48+
#endif
49+
3550
#else
3651
#error "Invalid FP size"
3752
#endif
@@ -43,7 +58,7 @@ _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_normalize(__CLC_GENTYPE p) {
4358

4459
__CLC_SCALAR_GENTYPE l2 = __clc_dot(p, p);
4560

46-
if (l2 < FLT_MIN) {
61+
if (l2 < MIN_VAL) {
4762
p *= MAX_SQRT;
4863
l2 = __clc_dot(p, p);
4964
} else if (l2 == INFINITY) {
@@ -60,6 +75,7 @@ _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_normalize(__CLC_GENTYPE p) {
6075
return p * __clc_rsqrt(l2);
6176
}
6277

78+
#undef MIN_VAL
6379
#undef MIN_SQRT
6480
#undef MAX_SQRT
6581

0 commit comments

Comments
 (0)