File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
libclc/clc/lib/generic/geometric Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change 1
1
// ===----------------------------------------------------------------------===//
2
2
//
3
+
3
4
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
5
// See https://llvm.org/LICENSE.txt for license information.
5
6
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
@@ -27,11 +28,25 @@ _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_normalize(__CLC_GENTYPE p) {
27
28
#else
28
29
29
30
#if __CLC_FPSIZE == 32
31
+
32
+ # define MIN_VAL FLT_MIN
30
33
# define MAX_SQRT 0x 1.0p +86F
34
+ #if __CLC_VECSIZE_OR_1 == 2
31
35
# define MIN_SQRT 0x 1.0p -65F
36
+ #else
37
+ # define MIN_SQRT 0x 1.0p -66F
38
+ #endif
39
+
32
40
# elif __CLC_FPSIZE == 64
41
+
42
+ # define MIN_VAL DBL_MIN
33
43
# define MAX_SQRT 0x 1.0p +563
44
+ #if __CLC_VECSIZE_OR_1 == 2
34
45
# define MIN_SQRT 0x 1.0p -513
46
+ #else
47
+ # define MIN_SQRT 0x 1.0p -514
48
+ #endif
49
+
35
50
#else
36
51
#error "Invalid FP size"
37
52
#endif
@@ -43,7 +58,7 @@ _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_normalize(__CLC_GENTYPE p) {
43
58
44
59
__CLC_SCALAR_GENTYPE l2 = __clc_dot (p, p);
45
60
46
- if (l2 < FLT_MIN ) {
61
+ if (l2 < MIN_VAL ) {
47
62
p *= MAX_SQRT;
48
63
l2 = __clc_dot (p, p);
49
64
} else if (l2 == INFINITY) {
@@ -60,6 +75,7 @@ _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_normalize(__CLC_GENTYPE p) {
60
75
return p * __clc_rsqrt (l2);
61
76
}
62
77
78
+ #undef MIN_VAL
63
79
#undef MIN_SQRT
64
80
#undef MAX_SQRT
65
81
You can’t perform that action at this time.
0 commit comments