2424#include <clc/clc_convert.h>
2525#include <clc/clcmacro.h>
2626#include <clc/math/clc_fabs.h>
27+ #include <clc/math/clc_fma.h>
2728#include <clc/math/clc_mad.h>
2829#include <clc/math/clc_subnormal_config.h>
2930#include <clc/math/math.h>
@@ -270,26 +271,29 @@ _CLC_DEF _CLC_OVERLOAD double __clc_powr(double x, double y) {
270271 double log_t = tv .s1 ;
271272 double f_inv = (log_h + log_t ) * f ;
272273 double r1 = __clc_as_double (__clc_as_long (f_inv ) & 0xfffffffff8000000L );
273- double r2 = fma (- F , r1 , f ) * (log_h + log_t );
274+ double r2 = __clc_fma (- F , r1 , f ) * (log_h + log_t );
274275 double r = r1 + r2 ;
275276
276- double poly = fma (
277- r , fma (r , fma (r , fma (r , 1.0 / 7.0 , 1.0 / 6.0 ), 1.0 / 5.0 ), 1.0 / 4.0 ),
277+ double poly = __clc_fma (
278+ r ,
279+ __clc_fma (r ,
280+ __clc_fma (r , __clc_fma (r , 1.0 / 7.0 , 1.0 / 6.0 ), 1.0 / 5.0 ),
281+ 1.0 / 4.0 ),
278282 1.0 / 3.0 );
279283 poly = poly * r * r * r ;
280284
281285 double hr1r1 = 0.5 * r1 * r1 ;
282286 double poly0h = r1 + hr1r1 ;
283287 double poly0t = r1 - poly0h + hr1r1 ;
284- poly = fma (r1 , r2 , fma (0.5 * r2 , r2 , poly )) + r2 + poly0t ;
288+ poly = __clc_fma (r1 , r2 , __clc_fma (0.5 * r2 , r2 , poly )) + r2 + poly0t ;
285289
286290 tv = USE_TABLE (powlog_tbl , index );
287291 log_h = tv .s0 ;
288292 log_t = tv .s1 ;
289293
290- double resT_t = fma (xexp , real_log2_tail , + log_t ) - poly ;
294+ double resT_t = __clc_fma (xexp , real_log2_tail , + log_t ) - poly ;
291295 double resT = resT_t - poly0h ;
292- double resH = fma (xexp , real_log2_lead , log_h );
296+ double resH = __clc_fma (xexp , real_log2_lead , log_h );
293297 double resT_h = poly0h ;
294298
295299 double H = resT + resH ;
@@ -300,9 +304,9 @@ _CLC_DEF _CLC_OVERLOAD double __clc_powr(double x, double y) {
300304 double y_head = __clc_as_double (uy & 0xfffffffff8000000L );
301305 double y_tail = y - y_head ;
302306
303- double temp = fma (y_tail , H , fma (y_head , T , y_tail * T ));
304- v = fma (y_head , H , temp );
305- vt = fma (y_head , H , - v ) + temp ;
307+ double temp = __clc_fma (y_tail , H , __clc_fma (y_head , T , y_tail * T ));
308+ v = __clc_fma (y_head , H , temp );
309+ vt = __clc_fma (y_head , H , - v ) + temp ;
306310 }
307311
308312 // Now calculate exp of (v,vt)
@@ -326,21 +330,22 @@ _CLC_DEF _CLC_OVERLOAD double __clc_powr(double x, double y) {
326330 double f2 = tv .s1 ;
327331 double f = f1 + f2 ;
328332
329- double r1 = fma (dn , - lnof2_by_64_head , v );
333+ double r1 = __clc_fma (dn , - lnof2_by_64_head , v );
330334 double r2 = dn * lnof2_by_64_tail ;
331335 double r = (r1 + r2 ) + vt ;
332336
333- double q = fma (
334- r ,
335- fma (r ,
336- fma (r ,
337- fma (r , 1.38889490863777199667e-03 , 8.33336798434219616221e-03 ),
338- 4.16666666662260795726e-02 ),
339- 1.66666666665260878863e-01 ),
340- 5.00000000000000008883e-01 );
341- q = fma (r * r , q , r );
342-
343- expv = fma (f , q , f2 ) + f1 ;
337+ double q =
338+ __clc_fma (r ,
339+ __clc_fma (r ,
340+ __clc_fma (r ,
341+ __clc_fma (r , 1.38889490863777199667e-03 ,
342+ 8.33336798434219616221e-03 ),
343+ 4.16666666662260795726e-02 ),
344+ 1.66666666665260878863e-01 ),
345+ 5.00000000000000008883e-01 );
346+ q = __clc_fma (r * r , q , r );
347+
348+ expv = __clc_fma (f , q , f2 ) + f1 ;
344349 expv = ldexp (expv , m );
345350
346351 expv = v > max_exp_arg ? __clc_as_double (0x7FF0000000000000L ) : expv ;
0 commit comments