Home | History | Annotate | Line # | Download | only in rs6000
ibm-ldouble.c revision 1.1.1.7
      1      1.1  mrg /* 128-bit long double support routines for Darwin.
      2  1.1.1.7  mrg    Copyright (C) 1993-2018 Free Software Foundation, Inc.
      3      1.1  mrg 
      4      1.1  mrg This file is part of GCC.
      5      1.1  mrg 
      6      1.1  mrg GCC is free software; you can redistribute it and/or modify it under
      7      1.1  mrg the terms of the GNU General Public License as published by the Free
      8      1.1  mrg Software Foundation; either version 3, or (at your option) any later
      9      1.1  mrg version.
     10      1.1  mrg 
     11      1.1  mrg GCC is distributed in the hope that it will be useful, but WITHOUT ANY
     12      1.1  mrg WARRANTY; without even the implied warranty of MERCHANTABILITY or
     13      1.1  mrg FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     14      1.1  mrg for more details.
     15      1.1  mrg 
     16      1.1  mrg Under Section 7 of GPL version 3, you are granted additional
     17      1.1  mrg permissions described in the GCC Runtime Library Exception, version
     18      1.1  mrg 3.1, as published by the Free Software Foundation.
     19      1.1  mrg 
     20      1.1  mrg You should have received a copy of the GNU General Public License and
     21      1.1  mrg a copy of the GCC Runtime Library Exception along with this program;
     22      1.1  mrg see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
     23      1.1  mrg <http://www.gnu.org/licenses/>.  */
     24      1.1  mrg 
     25      1.1  mrg 
     26      1.1  mrg /* Implementations of floating-point long double basic arithmetic
     27      1.1  mrg    functions called by the IBM C compiler when generating code for
     28      1.1  mrg    PowerPC platforms.  In particular, the following functions are
     29      1.1  mrg    implemented: __gcc_qadd, __gcc_qsub, __gcc_qmul, and __gcc_qdiv.
     30      1.1  mrg    Double-double algorithms are based on the paper "Doubled-Precision
     31      1.1  mrg    IEEE Standard 754 Floating-Point Arithmetic" by W. Kahan, February 26,
     32      1.1  mrg    1987.  An alternative published reference is "Software for
     33      1.1  mrg    Doubled-Precision Floating-Point Computations", by Seppo Linnainmaa,
     34      1.1  mrg    ACM TOMS vol 7 no 3, September 1981, pages 272-283.  */
     35      1.1  mrg 
     36      1.1  mrg /* Each long double is made up of two IEEE doubles.  The value of the
     37      1.1  mrg    long double is the sum of the values of the two parts.  The most
     38      1.1  mrg    significant part is required to be the value of the long double
     39      1.1  mrg    rounded to the nearest double, as specified by IEEE.  For Inf
     40      1.1  mrg    values, the least significant part is required to be one of +0.0 or
     41      1.1  mrg    -0.0.  No other requirements are made; so, for example, 1.0 may be
     42      1.1  mrg    represented as (1.0, +0.0) or (1.0, -0.0), and the low part of a
     43      1.1  mrg    NaN is don't-care.
     44      1.1  mrg 
     45      1.1  mrg    This code currently assumes the most significant double is in
     46      1.1  mrg    the lower numbered register or lower addressed memory.  */
     47      1.1  mrg 
     48  1.1.1.4  mrg #if (defined (__MACH__) || defined (__powerpc__) || defined (_AIX)) \
     49  1.1.1.4  mrg     && !defined (__rtems__)
     50      1.1  mrg 
     51      1.1  mrg #define fabs(x) __builtin_fabs(x)
     52      1.1  mrg #define isless(x, y) __builtin_isless (x, y)
     53      1.1  mrg #define inf() __builtin_inf()
     54      1.1  mrg 
     55      1.1  mrg #define unlikely(x) __builtin_expect ((x), 0)
     56      1.1  mrg 
     57      1.1  mrg #define nonfinite(a) unlikely (! isless (fabs (a), inf ()))
     58      1.1  mrg 
     59  1.1.1.7  mrg /* If we have __float128/_Float128, use __ibm128 instead of long double.  On
     60  1.1.1.7  mrg    other systems, use long double, because __ibm128 might not have been
     61  1.1.1.7  mrg    created.  */
     62  1.1.1.7  mrg #ifdef __FLOAT128__
     63  1.1.1.7  mrg #define IBM128_TYPE __ibm128
     64  1.1.1.7  mrg #else
     65  1.1.1.7  mrg #define IBM128_TYPE long double
     66  1.1.1.7  mrg #endif
     67  1.1.1.7  mrg 
     68      1.1  mrg /* Define ALIASNAME as a strong alias for NAME.  */
     69      1.1  mrg # define strong_alias(name, aliasname) _strong_alias(name, aliasname)
     70      1.1  mrg # define _strong_alias(name, aliasname) \
     71      1.1  mrg   extern __typeof (name) aliasname __attribute__ ((alias (#name)));
     72      1.1  mrg 
     73      1.1  mrg /* All these routines actually take two long doubles as parameters,
     74      1.1  mrg    but GCC currently generates poor code when a union is used to turn
     75      1.1  mrg    a long double into a pair of doubles.  */
     76      1.1  mrg 
     77  1.1.1.7  mrg IBM128_TYPE __gcc_qadd (double, double, double, double);
     78  1.1.1.7  mrg IBM128_TYPE __gcc_qsub (double, double, double, double);
     79  1.1.1.7  mrg IBM128_TYPE __gcc_qmul (double, double, double, double);
     80  1.1.1.7  mrg IBM128_TYPE __gcc_qdiv (double, double, double, double);
     81      1.1  mrg 
     82      1.1  mrg #if defined __ELF__ && defined SHARED \
     83      1.1  mrg     && (defined __powerpc64__ || !(defined __linux__ || defined __gnu_hurd__))
     84      1.1  mrg /* Provide definitions of the old symbol names to satisfy apps and
     85      1.1  mrg    shared libs built against an older libgcc.  To access the _xlq
     86      1.1  mrg    symbols an explicit version reference is needed, so these won't
     87      1.1  mrg    satisfy an unadorned reference like _xlqadd.  If dot symbols are
     88      1.1  mrg    not needed, the assembler will remove the aliases from the symbol
     89      1.1  mrg    table.  */
     90      1.1  mrg __asm__ (".symver __gcc_qadd,_xlqadd (at) GCC_3.4\n\t"
     91      1.1  mrg 	 ".symver __gcc_qsub,_xlqsub (at) GCC_3.4\n\t"
     92      1.1  mrg 	 ".symver __gcc_qmul,_xlqmul (at) GCC_3.4\n\t"
     93      1.1  mrg 	 ".symver __gcc_qdiv,_xlqdiv (at) GCC_3.4\n\t"
     94      1.1  mrg 	 ".symver .__gcc_qadd,._xlqadd (at) GCC_3.4\n\t"
     95      1.1  mrg 	 ".symver .__gcc_qsub,._xlqsub (at) GCC_3.4\n\t"
     96      1.1  mrg 	 ".symver .__gcc_qmul,._xlqmul (at) GCC_3.4\n\t"
     97      1.1  mrg 	 ".symver .__gcc_qdiv,._xlqdiv (at) GCC_3.4");
     98      1.1  mrg #endif
     99      1.1  mrg 
    100  1.1.1.7  mrg /* Combine two 'double' values into one 'IBM128_TYPE' and return the result.  */
    101  1.1.1.7  mrg static inline IBM128_TYPE
    102  1.1.1.2  mrg pack_ldouble (double dh, double dl)
    103  1.1.1.2  mrg {
    104  1.1.1.7  mrg #if defined (__LONG_DOUBLE_128__) && defined (__LONG_DOUBLE_IBM128__)	\
    105  1.1.1.2  mrg     && !(defined (_SOFT_FLOAT) || defined (__NO_FPRS__))
    106  1.1.1.2  mrg   return __builtin_pack_longdouble (dh, dl);
    107  1.1.1.2  mrg #else
    108  1.1.1.2  mrg   union
    109  1.1.1.2  mrg   {
    110  1.1.1.7  mrg     IBM128_TYPE ldval;
    111  1.1.1.2  mrg     double dval[2];
    112  1.1.1.2  mrg   } x;
    113  1.1.1.2  mrg   x.dval[0] = dh;
    114  1.1.1.2  mrg   x.dval[1] = dl;
    115  1.1.1.2  mrg   return x.ldval;
    116  1.1.1.2  mrg #endif
    117  1.1.1.2  mrg }
    118      1.1  mrg 
    119  1.1.1.7  mrg /* Add two 'IBM128_TYPE' values and return the result.	*/
    120  1.1.1.7  mrg IBM128_TYPE
    121      1.1  mrg __gcc_qadd (double a, double aa, double c, double cc)
    122      1.1  mrg {
    123  1.1.1.2  mrg   double xh, xl, z, q, zz;
    124      1.1  mrg 
    125      1.1  mrg   z = a + c;
    126      1.1  mrg 
    127      1.1  mrg   if (nonfinite (z))
    128      1.1  mrg     {
    129  1.1.1.2  mrg       if (fabs (z) != inf())
    130  1.1.1.2  mrg 	return z;
    131      1.1  mrg       z = cc + aa + c + a;
    132      1.1  mrg       if (nonfinite (z))
    133      1.1  mrg 	return z;
    134  1.1.1.2  mrg       xh = z;  /* Will always be DBL_MAX.  */
    135      1.1  mrg       zz = aa + cc;
    136      1.1  mrg       if (fabs(a) > fabs(c))
    137  1.1.1.2  mrg 	xl = a - z + c + zz;
    138      1.1  mrg       else
    139  1.1.1.2  mrg 	xl = c - z + a + zz;
    140      1.1  mrg     }
    141      1.1  mrg   else
    142      1.1  mrg     {
    143      1.1  mrg       q = a - z;
    144      1.1  mrg       zz = q + c + (a - (q + z)) + aa + cc;
    145      1.1  mrg 
    146      1.1  mrg       /* Keep -0 result.  */
    147      1.1  mrg       if (zz == 0.0)
    148      1.1  mrg 	return z;
    149      1.1  mrg 
    150      1.1  mrg       xh = z + zz;
    151      1.1  mrg       if (nonfinite (xh))
    152      1.1  mrg 	return xh;
    153      1.1  mrg 
    154  1.1.1.2  mrg       xl = z - xh + zz;
    155      1.1  mrg     }
    156  1.1.1.2  mrg   return pack_ldouble (xh, xl);
    157      1.1  mrg }
    158      1.1  mrg 
    159  1.1.1.7  mrg IBM128_TYPE
    160      1.1  mrg __gcc_qsub (double a, double b, double c, double d)
    161      1.1  mrg {
    162      1.1  mrg   return __gcc_qadd (a, b, -c, -d);
    163      1.1  mrg }
    164      1.1  mrg 
    165      1.1  mrg #ifdef __NO_FPRS__
    166      1.1  mrg static double fmsub (double, double, double);
    167      1.1  mrg #endif
    168      1.1  mrg 
    169  1.1.1.7  mrg IBM128_TYPE
    170      1.1  mrg __gcc_qmul (double a, double b, double c, double d)
    171      1.1  mrg {
    172  1.1.1.2  mrg   double xh, xl, t, tau, u, v, w;
    173      1.1  mrg 
    174      1.1  mrg   t = a * c;			/* Highest order double term.  */
    175      1.1  mrg 
    176      1.1  mrg   if (unlikely (t == 0)		/* Preserve -0.  */
    177      1.1  mrg       || nonfinite (t))
    178      1.1  mrg     return t;
    179      1.1  mrg 
    180      1.1  mrg   /* Sum terms of two highest orders. */
    181      1.1  mrg 
    182      1.1  mrg   /* Use fused multiply-add to get low part of a * c.  */
    183      1.1  mrg #ifndef __NO_FPRS__
    184      1.1  mrg   asm ("fmsub %0,%1,%2,%3" : "=f"(tau) : "f"(a), "f"(c), "f"(t));
    185      1.1  mrg #else
    186      1.1  mrg   tau = fmsub (a, c, t);
    187      1.1  mrg #endif
    188      1.1  mrg   v = a*d;
    189      1.1  mrg   w = b*c;
    190      1.1  mrg   tau += v + w;	    /* Add in other second-order terms.	 */
    191      1.1  mrg   u = t + tau;
    192      1.1  mrg 
    193  1.1.1.7  mrg   /* Construct IBM128_TYPE result.  */
    194      1.1  mrg   if (nonfinite (u))
    195      1.1  mrg     return u;
    196  1.1.1.2  mrg   xh = u;
    197  1.1.1.2  mrg   xl = (t - u) + tau;
    198  1.1.1.2  mrg   return pack_ldouble (xh, xl);
    199      1.1  mrg }
    200      1.1  mrg 
    201  1.1.1.7  mrg IBM128_TYPE
    202      1.1  mrg __gcc_qdiv (double a, double b, double c, double d)
    203      1.1  mrg {
    204  1.1.1.2  mrg   double xh, xl, s, sigma, t, tau, u, v, w;
    205      1.1  mrg 
    206      1.1  mrg   t = a / c;                    /* highest order double term */
    207      1.1  mrg 
    208      1.1  mrg   if (unlikely (t == 0)		/* Preserve -0.  */
    209      1.1  mrg       || nonfinite (t))
    210      1.1  mrg     return t;
    211      1.1  mrg 
    212      1.1  mrg   /* Finite nonzero result requires corrections to the highest order
    213      1.1  mrg      term.  These corrections require the low part of c * t to be
    214      1.1  mrg      exactly represented in double.  */
    215      1.1  mrg   if (fabs (a) <= 0x1p-969)
    216      1.1  mrg     {
    217      1.1  mrg       a *= 0x1p106;
    218      1.1  mrg       b *= 0x1p106;
    219      1.1  mrg       c *= 0x1p106;
    220      1.1  mrg       d *= 0x1p106;
    221      1.1  mrg     }
    222      1.1  mrg 
    223      1.1  mrg   s = c * t;                    /* (s,sigma) = c*t exactly.  */
    224      1.1  mrg   w = -(-b + d * t);	/* Written to get fnmsub for speed, but not
    225      1.1  mrg 			   numerically necessary.  */
    226      1.1  mrg 
    227      1.1  mrg   /* Use fused multiply-add to get low part of c * t.	 */
    228      1.1  mrg #ifndef __NO_FPRS__
    229      1.1  mrg   asm ("fmsub %0,%1,%2,%3" : "=f"(sigma) : "f"(c), "f"(t), "f"(s));
    230      1.1  mrg #else
    231      1.1  mrg   sigma = fmsub (c, t, s);
    232      1.1  mrg #endif
    233      1.1  mrg   v = a - s;
    234      1.1  mrg 
    235      1.1  mrg   tau = ((v-sigma)+w)/c;   /* Correction to t.  */
    236      1.1  mrg   u = t + tau;
    237      1.1  mrg 
    238  1.1.1.7  mrg   /* Construct IBM128_TYPE result.  */
    239      1.1  mrg   if (nonfinite (u))
    240      1.1  mrg     return u;
    241  1.1.1.2  mrg   xh = u;
    242  1.1.1.2  mrg   xl = (t - u) + tau;
    243  1.1.1.2  mrg   return pack_ldouble (xh, xl);
    244      1.1  mrg }
    245      1.1  mrg 
    246      1.1  mrg #if defined (_SOFT_DOUBLE) && defined (__LONG_DOUBLE_128__)
    247      1.1  mrg 
    248  1.1.1.7  mrg IBM128_TYPE __gcc_qneg (double, double);
    249      1.1  mrg int __gcc_qeq (double, double, double, double);
    250      1.1  mrg int __gcc_qne (double, double, double, double);
    251      1.1  mrg int __gcc_qge (double, double, double, double);
    252      1.1  mrg int __gcc_qle (double, double, double, double);
    253  1.1.1.7  mrg IBM128_TYPE __gcc_stoq (float);
    254  1.1.1.7  mrg IBM128_TYPE __gcc_dtoq (double);
    255      1.1  mrg float __gcc_qtos (double, double);
    256      1.1  mrg double __gcc_qtod (double, double);
    257      1.1  mrg int __gcc_qtoi (double, double);
    258      1.1  mrg unsigned int __gcc_qtou (double, double);
    259  1.1.1.7  mrg IBM128_TYPE __gcc_itoq (int);
    260  1.1.1.7  mrg IBM128_TYPE __gcc_utoq (unsigned int);
    261      1.1  mrg 
    262      1.1  mrg extern int __eqdf2 (double, double);
    263      1.1  mrg extern int __ledf2 (double, double);
    264      1.1  mrg extern int __gedf2 (double, double);
    265      1.1  mrg 
    266  1.1.1.7  mrg /* Negate 'IBM128_TYPE' value and return the result.	*/
    267  1.1.1.7  mrg IBM128_TYPE
    268      1.1  mrg __gcc_qneg (double a, double aa)
    269      1.1  mrg {
    270  1.1.1.2  mrg   return pack_ldouble (-a, -aa);
    271      1.1  mrg }
    272      1.1  mrg 
    273  1.1.1.7  mrg /* Compare two 'IBM128_TYPE' values for equality.  */
    274      1.1  mrg int
    275      1.1  mrg __gcc_qeq (double a, double aa, double c, double cc)
    276      1.1  mrg {
    277      1.1  mrg   if (__eqdf2 (a, c) == 0)
    278      1.1  mrg     return __eqdf2 (aa, cc);
    279      1.1  mrg   return 1;
    280      1.1  mrg }
    281      1.1  mrg 
    282      1.1  mrg strong_alias (__gcc_qeq, __gcc_qne);
    283      1.1  mrg 
    284  1.1.1.7  mrg /* Compare two 'IBM128_TYPE' values for less than or equal.  */
    285      1.1  mrg int
    286      1.1  mrg __gcc_qle (double a, double aa, double c, double cc)
    287      1.1  mrg {
    288      1.1  mrg   if (__eqdf2 (a, c) == 0)
    289      1.1  mrg     return __ledf2 (aa, cc);
    290      1.1  mrg   return __ledf2 (a, c);
    291      1.1  mrg }
    292      1.1  mrg 
    293      1.1  mrg strong_alias (__gcc_qle, __gcc_qlt);
    294      1.1  mrg 
    295  1.1.1.7  mrg /* Compare two 'IBM128_TYPE' values for greater than or equal.  */
    296      1.1  mrg int
    297      1.1  mrg __gcc_qge (double a, double aa, double c, double cc)
    298      1.1  mrg {
    299      1.1  mrg   if (__eqdf2 (a, c) == 0)
    300      1.1  mrg     return __gedf2 (aa, cc);
    301      1.1  mrg   return __gedf2 (a, c);
    302      1.1  mrg }
    303      1.1  mrg 
    304      1.1  mrg strong_alias (__gcc_qge, __gcc_qgt);
    305      1.1  mrg 
    306  1.1.1.7  mrg /* Convert single to IBM128_TYPE.  */
    307  1.1.1.7  mrg IBM128_TYPE
    308      1.1  mrg __gcc_stoq (float a)
    309      1.1  mrg {
    310  1.1.1.2  mrg   return pack_ldouble ((double) a, 0.0);
    311      1.1  mrg }
    312      1.1  mrg 
    313  1.1.1.7  mrg /* Convert double to IBM128_TYPE.  */
    314  1.1.1.7  mrg IBM128_TYPE
    315      1.1  mrg __gcc_dtoq (double a)
    316      1.1  mrg {
    317  1.1.1.2  mrg   return pack_ldouble (a, 0.0);
    318      1.1  mrg }
    319      1.1  mrg 
    320  1.1.1.7  mrg /* Convert IBM128_TYPE to single.  */
    321      1.1  mrg float
    322      1.1  mrg __gcc_qtos (double a, double aa __attribute__ ((__unused__)))
    323      1.1  mrg {
    324      1.1  mrg   return (float) a;
    325      1.1  mrg }
    326      1.1  mrg 
    327  1.1.1.7  mrg /* Convert IBM128_TYPE to double.  */
    328      1.1  mrg double
    329      1.1  mrg __gcc_qtod (double a, double aa __attribute__ ((__unused__)))
    330      1.1  mrg {
    331      1.1  mrg   return a;
    332      1.1  mrg }
    333      1.1  mrg 
    334  1.1.1.7  mrg /* Convert IBM128_TYPE to int.  */
    335      1.1  mrg int
    336      1.1  mrg __gcc_qtoi (double a, double aa)
    337      1.1  mrg {
    338      1.1  mrg   double z = a + aa;
    339      1.1  mrg   return (int) z;
    340      1.1  mrg }
    341      1.1  mrg 
    342  1.1.1.7  mrg /* Convert IBM128_TYPE to unsigned int.  */
    343      1.1  mrg unsigned int
    344      1.1  mrg __gcc_qtou (double a, double aa)
    345      1.1  mrg {
    346      1.1  mrg   double z = a + aa;
    347      1.1  mrg   return (unsigned int) z;
    348      1.1  mrg }
    349      1.1  mrg 
    350  1.1.1.7  mrg /* Convert int to IBM128_TYPE.  */
    351  1.1.1.7  mrg IBM128_TYPE
    352      1.1  mrg __gcc_itoq (int a)
    353      1.1  mrg {
    354      1.1  mrg   return __gcc_dtoq ((double) a);
    355      1.1  mrg }
    356      1.1  mrg 
    357  1.1.1.7  mrg /* Convert unsigned int to IBM128_TYPE.  */
    358  1.1.1.7  mrg IBM128_TYPE
    359      1.1  mrg __gcc_utoq (unsigned int a)
    360      1.1  mrg {
    361      1.1  mrg   return __gcc_dtoq ((double) a);
    362      1.1  mrg }
    363      1.1  mrg 
    364      1.1  mrg #endif
    365      1.1  mrg 
    366      1.1  mrg #ifdef __NO_FPRS__
    367      1.1  mrg 
    368      1.1  mrg int __gcc_qunord (double, double, double, double);
    369      1.1  mrg 
    370      1.1  mrg extern int __eqdf2 (double, double);
    371      1.1  mrg extern int __unorddf2 (double, double);
    372      1.1  mrg 
    373  1.1.1.7  mrg /* Compare two 'IBM128_TYPE' values for unordered.  */
    374      1.1  mrg int
    375      1.1  mrg __gcc_qunord (double a, double aa, double c, double cc)
    376      1.1  mrg {
    377      1.1  mrg   if (__eqdf2 (a, c) == 0)
    378      1.1  mrg     return __unorddf2 (aa, cc);
    379      1.1  mrg   return __unorddf2 (a, c);
    380      1.1  mrg }
    381      1.1  mrg 
    382      1.1  mrg #include "soft-fp/soft-fp.h"
    383      1.1  mrg #include "soft-fp/double.h"
    384      1.1  mrg #include "soft-fp/quad.h"
    385      1.1  mrg 
    386      1.1  mrg /* Compute floating point multiply-subtract with higher (quad) precision.  */
    387      1.1  mrg static double
    388      1.1  mrg fmsub (double a, double b, double c)
    389      1.1  mrg {
    390      1.1  mrg     FP_DECL_EX;
    391      1.1  mrg     FP_DECL_D(A);
    392      1.1  mrg     FP_DECL_D(B);
    393      1.1  mrg     FP_DECL_D(C);
    394      1.1  mrg     FP_DECL_Q(X);
    395      1.1  mrg     FP_DECL_Q(Y);
    396      1.1  mrg     FP_DECL_Q(Z);
    397      1.1  mrg     FP_DECL_Q(U);
    398      1.1  mrg     FP_DECL_Q(V);
    399      1.1  mrg     FP_DECL_D(R);
    400      1.1  mrg     double r;
    401  1.1.1.7  mrg     IBM128_TYPE u, x, y, z;
    402      1.1  mrg 
    403      1.1  mrg     FP_INIT_ROUNDMODE;
    404      1.1  mrg     FP_UNPACK_RAW_D (A, a);
    405      1.1  mrg     FP_UNPACK_RAW_D (B, b);
    406      1.1  mrg     FP_UNPACK_RAW_D (C, c);
    407      1.1  mrg 
    408      1.1  mrg     /* Extend double to quad.  */
    409      1.1  mrg #if (2 * _FP_W_TYPE_SIZE) < _FP_FRACBITS_Q
    410      1.1  mrg     FP_EXTEND(Q,D,4,2,X,A);
    411      1.1  mrg     FP_EXTEND(Q,D,4,2,Y,B);
    412      1.1  mrg     FP_EXTEND(Q,D,4,2,Z,C);
    413      1.1  mrg #else
    414      1.1  mrg     FP_EXTEND(Q,D,2,1,X,A);
    415      1.1  mrg     FP_EXTEND(Q,D,2,1,Y,B);
    416      1.1  mrg     FP_EXTEND(Q,D,2,1,Z,C);
    417      1.1  mrg #endif
    418      1.1  mrg     FP_PACK_RAW_Q(x,X);
    419      1.1  mrg     FP_PACK_RAW_Q(y,Y);
    420      1.1  mrg     FP_PACK_RAW_Q(z,Z);
    421      1.1  mrg     FP_HANDLE_EXCEPTIONS;
    422      1.1  mrg 
    423      1.1  mrg     /* Multiply.  */
    424      1.1  mrg     FP_INIT_ROUNDMODE;
    425      1.1  mrg     FP_UNPACK_Q(X,x);
    426      1.1  mrg     FP_UNPACK_Q(Y,y);
    427      1.1  mrg     FP_MUL_Q(U,X,Y);
    428      1.1  mrg     FP_PACK_Q(u,U);
    429      1.1  mrg     FP_HANDLE_EXCEPTIONS;
    430      1.1  mrg 
    431      1.1  mrg     /* Subtract.  */
    432      1.1  mrg     FP_INIT_ROUNDMODE;
    433      1.1  mrg     FP_UNPACK_SEMIRAW_Q(U,u);
    434      1.1  mrg     FP_UNPACK_SEMIRAW_Q(Z,z);
    435      1.1  mrg     FP_SUB_Q(V,U,Z);
    436      1.1  mrg 
    437      1.1  mrg     /* Truncate quad to double.  */
    438      1.1  mrg #if (2 * _FP_W_TYPE_SIZE) < _FP_FRACBITS_Q
    439      1.1  mrg     V_f[3] &= 0x0007ffff;
    440      1.1  mrg     FP_TRUNC(D,Q,2,4,R,V);
    441      1.1  mrg #else
    442      1.1  mrg     V_f1 &= 0x0007ffffffffffffL;
    443      1.1  mrg     FP_TRUNC(D,Q,1,2,R,V);
    444      1.1  mrg #endif
    445      1.1  mrg     FP_PACK_SEMIRAW_D(r,R);
    446      1.1  mrg     FP_HANDLE_EXCEPTIONS;
    447      1.1  mrg 
    448      1.1  mrg     return r;
    449      1.1  mrg }
    450      1.1  mrg 
    451      1.1  mrg #endif
    452      1.1  mrg 
    453      1.1  mrg #endif
    454