|
26 | 26 | #include "../clcmacro.h" |
27 | 27 | #include "tables.h" |
28 | 28 |
|
29 | | -_CLC_DEF _CLC_OVERLOAD float __clc_tan(float x) |
30 | | -{ |
31 | | - int ix = as_int(x); |
32 | | - int ax = ix & 0x7fffffff; |
33 | | - float dx = as_float(ax); |
| 29 | +_CLC_DEF _CLC_OVERLOAD float __clc_tan(float x) { |
| 30 | + int ix = as_int(x); |
| 31 | + int ax = ix & 0x7fffffff; |
| 32 | + float dx = as_float(ax); |
34 | 33 |
|
35 | | - float r0, r1; |
36 | | - int regn = __clc_argReductionS(&r0, &r1, dx); |
| 34 | + float r0, r1; |
| 35 | + int regn = __clc_argReductionS(&r0, &r1, dx); |
37 | 36 |
|
38 | | - float t = __clc_tanf_piby4(r0 + r1, regn); |
39 | | - t = as_float(as_int(t) ^ (ix ^ ax)); |
| 37 | + float t = __clc_tanf_piby4(r0 + r1, regn); |
| 38 | + t = as_float(as_int(t) ^ (ix ^ ax)); |
40 | 39 |
|
41 | | - t = ax >= PINFBITPATT_SP32 ? as_float(QNANBITPATT_SP32) : t; |
42 | | - //Take care of subnormals |
43 | | - t = (x == 0.0f) ? x : t; |
44 | | - return t; |
| 40 | + t = ax >= PINFBITPATT_SP32 ? as_float(QNANBITPATT_SP32) : t; |
| 41 | + // Take care of subnormals |
| 42 | + t = (x == 0.0f) ? x : t; |
| 43 | + return t; |
45 | 44 | } |
46 | 45 | _CLC_UNARY_VECTORIZE(_CLC_DEF _CLC_OVERLOAD, float, __clc_tan, float); |
47 | 46 |
|
48 | 47 | #ifdef cl_khr_fp64 |
49 | 48 | #include "sincosD_piby4.h" |
50 | 49 |
|
51 | | -_CLC_DEF _CLC_OVERLOAD double __clc_tan(double x) |
52 | | -{ |
53 | | - double y = fabs(x); |
| 50 | +_CLC_DEF _CLC_OVERLOAD double __clc_tan(double x) { |
| 51 | + double y = fabs(x); |
54 | 52 |
|
55 | | - double r, rr; |
56 | | - int regn; |
| 53 | + double r, rr; |
| 54 | + int regn; |
57 | 55 |
|
58 | | - if (y < 0x1.0p+30) |
59 | | - __clc_remainder_piby2_medium(y, &r, &rr, ®n); |
60 | | - else |
61 | | - __clc_remainder_piby2_large(y, &r, &rr, ®n); |
| 56 | + if (y < 0x1.0p+30) |
| 57 | + __clc_remainder_piby2_medium(y, &r, &rr, ®n); |
| 58 | + else |
| 59 | + __clc_remainder_piby2_large(y, &r, &rr, ®n); |
62 | 60 |
|
63 | | - double2 tt = __clc_tan_piby4(r, rr); |
| 61 | + double2 tt = __clc_tan_piby4(r, rr); |
64 | 62 |
|
65 | | - int2 t = as_int2(regn & 1 ? tt.y : tt.x); |
66 | | - t.hi ^= (x < 0.0) << 31; |
| 63 | + int2 t = as_int2(regn & 1 ? tt.y : tt.x); |
| 64 | + t.hi ^= (x < 0.0) << 31; |
67 | 65 |
|
68 | | - return isnan(x) || isinf(x) ? as_double(QNANBITPATT_DP64) : as_double(t); |
| 66 | + return isnan(x) || isinf(x) ? as_double(QNANBITPATT_DP64) : as_double(t); |
69 | 67 | } |
70 | 68 | _CLC_UNARY_VECTORIZE(_CLC_DEF _CLC_OVERLOAD, double, __clc_tan, double); |
71 | 69 | #endif |
0 commit comments