Home | History | Annotate | Line # | Download | only in rs6000
ibm-ldouble.c revision 1.1.1.9
      1      1.1  mrg /* 128-bit long double support routines for Darwin.
      2  1.1.1.9  mrg    Copyright (C) 1993-2020 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.8  mrg   && !defined (__rtems__) \
     50  1.1.1.8  mrg   && (defined (__LONG_DOUBLE_128__) || defined (__FLOAT128_TYPE__))
     51      1.1  mrg 
     52      1.1  mrg #define fabs(x) __builtin_fabs(x)
     53      1.1  mrg #define isless(x, y) __builtin_isless (x, y)
     54      1.1  mrg #define inf() __builtin_inf()
     55      1.1  mrg 
     56      1.1  mrg #define unlikely(x) __builtin_expect ((x), 0)
     57      1.1  mrg 
     58      1.1  mrg #define nonfinite(a) unlikely (! isless (fabs (a), inf ()))
     59      1.1  mrg 
     60  1.1.1.7  mrg /* If we have __float128/_Float128, use __ibm128 instead of long double.  On
     61  1.1.1.7  mrg    other systems, use long double, because __ibm128 might not have been
     62  1.1.1.7  mrg    created.  */
     63  1.1.1.7  mrg #ifdef __FLOAT128__
     64  1.1.1.7  mrg #define IBM128_TYPE __ibm128
     65  1.1.1.7  mrg #else
     66  1.1.1.7  mrg #define IBM128_TYPE long double
     67  1.1.1.7  mrg #endif
     68  1.1.1.7  mrg 
     69      1.1  mrg /* Define ALIASNAME as a strong alias for NAME.  */
     70      1.1  mrg # define strong_alias(name, aliasname) _strong_alias(name, aliasname)
     71      1.1  mrg # define _strong_alias(name, aliasname) \
     72      1.1  mrg   extern __typeof (name) aliasname __attribute__ ((alias (#name)));
     73      1.1  mrg 
     74      1.1  mrg /* All these routines actually take two long doubles as parameters,
     75      1.1  mrg    but GCC currently generates poor code when a union is used to turn
     76      1.1  mrg    a long double into a pair of doubles.  */
     77      1.1  mrg 
     78  1.1.1.7  mrg IBM128_TYPE __gcc_qadd (double, double, double, double);
     79  1.1.1.7  mrg IBM128_TYPE __gcc_qsub (double, double, double, double);
     80  1.1.1.7  mrg IBM128_TYPE __gcc_qmul (double, double, double, double);
     81  1.1.1.7  mrg IBM128_TYPE __gcc_qdiv (double, double, double, double);
     82      1.1  mrg 
     83      1.1  mrg #if defined __ELF__ && defined SHARED \
     84      1.1  mrg     && (defined __powerpc64__ || !(defined __linux__ || defined __gnu_hurd__))
     85      1.1  mrg /* Provide definitions of the old symbol names to satisfy apps and
     86      1.1  mrg    shared libs built against an older libgcc.  To access the _xlq
     87      1.1  mrg    symbols an explicit version reference is needed, so these won't
     88      1.1  mrg    satisfy an unadorned reference like _xlqadd.  If dot symbols are
     89      1.1  mrg    not needed, the assembler will remove the aliases from the symbol
     90      1.1  mrg    table.  */
     91      1.1  mrg __asm__ (".symver __gcc_qadd,_xlqadd (at) GCC_3.4\n\t"
     92      1.1  mrg 	 ".symver __gcc_qsub,_xlqsub (at) GCC_3.4\n\t"
     93      1.1  mrg 	 ".symver __gcc_qmul,_xlqmul (at) GCC_3.4\n\t"
     94      1.1  mrg 	 ".symver __gcc_qdiv,_xlqdiv (at) GCC_3.4\n\t"
     95      1.1  mrg 	 ".symver .__gcc_qadd,._xlqadd (at) GCC_3.4\n\t"
     96      1.1  mrg 	 ".symver .__gcc_qsub,._xlqsub (at) GCC_3.4\n\t"
     97      1.1  mrg 	 ".symver .__gcc_qmul,._xlqmul (at) GCC_3.4\n\t"
     98      1.1  mrg 	 ".symver .__gcc_qdiv,._xlqdiv (at) GCC_3.4");
     99      1.1  mrg #endif
    100      1.1  mrg 
    101  1.1.1.7  mrg /* Combine two 'double' values into one 'IBM128_TYPE' and return the result.  */
    102  1.1.1.7  mrg static inline IBM128_TYPE
    103  1.1.1.2  mrg pack_ldouble (double dh, double dl)
    104  1.1.1.2  mrg {
    105  1.1.1.7  mrg #if defined (__LONG_DOUBLE_128__) && defined (__LONG_DOUBLE_IBM128__)	\
    106  1.1.1.2  mrg     && !(defined (_SOFT_FLOAT) || defined (__NO_FPRS__))
    107  1.1.1.2  mrg   return __builtin_pack_longdouble (dh, dl);
    108  1.1.1.2  mrg #else
    109  1.1.1.2  mrg   union
    110  1.1.1.2  mrg   {
    111  1.1.1.7  mrg     IBM128_TYPE ldval;
    112  1.1.1.2  mrg     double dval[2];
    113  1.1.1.2  mrg   } x;
    114  1.1.1.2  mrg   x.dval[0] = dh;
    115  1.1.1.2  mrg   x.dval[1] = dl;
    116  1.1.1.2  mrg   return x.ldval;
    117  1.1.1.2  mrg #endif
    118  1.1.1.2  mrg }
    119      1.1  mrg 
    120  1.1.1.7  mrg /* Add two 'IBM128_TYPE' values and return the result.	*/
    121  1.1.1.7  mrg IBM128_TYPE
    122      1.1  mrg __gcc_qadd (double a, double aa, double c, double cc)
    123      1.1  mrg {
    124  1.1.1.2  mrg   double xh, xl, z, q, zz;
    125      1.1  mrg 
    126      1.1  mrg   z = a + c;
    127      1.1  mrg 
    128      1.1  mrg   if (nonfinite (z))
    129      1.1  mrg     {
    130  1.1.1.2  mrg       if (fabs (z) != inf())
    131  1.1.1.2  mrg 	return z;
    132      1.1  mrg       z = cc + aa + c + a;
    133      1.1  mrg       if (nonfinite (z))
    134      1.1  mrg 	return z;
    135  1.1.1.2  mrg       xh = z;  /* Will always be DBL_MAX.  */
    136      1.1  mrg       zz = aa + cc;
    137      1.1  mrg       if (fabs(a) > fabs(c))
    138  1.1.1.2  mrg 	xl = a - z + c + zz;
    139      1.1  mrg       else
    140  1.1.1.2  mrg 	xl = c - z + a + zz;
    141      1.1  mrg     }
    142      1.1  mrg   else
    143      1.1  mrg     {
    144      1.1  mrg       q = a - z;
    145      1.1  mrg       zz = q + c + (a - (q + z)) + aa + cc;
    146      1.1  mrg 
    147      1.1  mrg       /* Keep -0 result.  */
    148      1.1  mrg       if (zz == 0.0)
    149      1.1  mrg 	return z;
    150      1.1  mrg 
    151      1.1  mrg       xh = z + zz;
    152      1.1  mrg       if (nonfinite (xh))
    153      1.1  mrg 	return xh;
    154      1.1  mrg 
    155  1.1.1.2  mrg       xl = z - xh + zz;
    156      1.1  mrg     }
    157  1.1.1.2  mrg   return pack_ldouble (xh, xl);
    158      1.1  mrg }
    159      1.1  mrg 
    160  1.1.1.7  mrg IBM128_TYPE
    161      1.1  mrg __gcc_qsub (double a, double b, double c, double d)
    162      1.1  mrg {
    163      1.1  mrg   return __gcc_qadd (a, b, -c, -d);
    164      1.1  mrg }
    165      1.1  mrg 
    166      1.1  mrg #ifdef __NO_FPRS__
    167      1.1  mrg static double fmsub (double, double, double);
    168      1.1  mrg #endif
    169      1.1  mrg 
    170  1.1.1.7  mrg IBM128_TYPE
    171      1.1  mrg __gcc_qmul (double a, double b, double c, double d)
    172      1.1  mrg {
    173  1.1.1.2  mrg   double xh, xl, t, tau, u, v, w;
    174      1.1  mrg 
    175      1.1  mrg   t = a * c;			/* Highest order double term.  */
    176      1.1  mrg 
    177      1.1  mrg   if (unlikely (t == 0)		/* Preserve -0.  */
    178      1.1  mrg       || nonfinite (t))
    179      1.1  mrg     return t;
    180      1.1  mrg 
    181      1.1  mrg   /* Sum terms of two highest orders. */
    182      1.1  mrg 
    183      1.1  mrg   /* Use fused multiply-add to get low part of a * c.  */
    184      1.1  mrg #ifndef __NO_FPRS__
    185      1.1  mrg   asm ("fmsub %0,%1,%2,%3" : "=f"(tau) : "f"(a), "f"(c), "f"(t));
    186      1.1  mrg #else
    187      1.1  mrg   tau = fmsub (a, c, t);
    188      1.1  mrg #endif
    189      1.1  mrg   v = a*d;
    190      1.1  mrg   w = b*c;
    191      1.1  mrg   tau += v + w;	    /* Add in other second-order terms.	 */
    192      1.1  mrg   u = t + tau;
    193      1.1  mrg 
    194  1.1.1.7  mrg   /* Construct IBM128_TYPE result.  */
    195      1.1  mrg   if (nonfinite (u))
    196      1.1  mrg     return u;
    197  1.1.1.2  mrg   xh = u;
    198  1.1.1.2  mrg   xl = (t - u) + tau;
    199  1.1.1.2  mrg   return pack_ldouble (xh, xl);
    200      1.1  mrg }
    201      1.1  mrg 
    202  1.1.1.7  mrg IBM128_TYPE
    203      1.1  mrg __gcc_qdiv (double a, double b, double c, double d)
    204      1.1  mrg {
    205  1.1.1.2  mrg   double xh, xl, s, sigma, t, tau, u, v, w;
    206      1.1  mrg 
    207      1.1  mrg   t = a / c;                    /* highest order double term */
    208      1.1  mrg 
    209      1.1  mrg   if (unlikely (t == 0)		/* Preserve -0.  */
    210      1.1  mrg       || nonfinite (t))
    211      1.1  mrg     return t;
    212      1.1  mrg 
    213      1.1  mrg   /* Finite nonzero result requires corrections to the highest order
    214      1.1  mrg      term.  These corrections require the low part of c * t to be
    215      1.1  mrg      exactly represented in double.  */
    216      1.1  mrg   if (fabs (a) <= 0x1p-969)
    217      1.1  mrg     {
    218      1.1  mrg       a *= 0x1p106;
    219      1.1  mrg       b *= 0x1p106;
    220      1.1  mrg       c *= 0x1p106;
    221      1.1  mrg       d *= 0x1p106;
    222      1.1  mrg     }
    223      1.1  mrg 
    224      1.1  mrg   s = c * t;                    /* (s,sigma) = c*t exactly.  */
    225      1.1  mrg   w = -(-b + d * t);	/* Written to get fnmsub for speed, but not
    226      1.1  mrg 			   numerically necessary.  */
    227      1.1  mrg 
    228      1.1  mrg   /* Use fused multiply-add to get low part of c * t.	 */
    229      1.1  mrg #ifndef __NO_FPRS__
    230      1.1  mrg   asm ("fmsub %0,%1,%2,%3" : "=f"(sigma) : "f"(c), "f"(t), "f"(s));
    231      1.1  mrg #else
    232      1.1  mrg   sigma = fmsub (c, t, s);
    233      1.1  mrg #endif
    234      1.1  mrg   v = a - s;
    235      1.1  mrg 
    236      1.1  mrg   tau = ((v-sigma)+w)/c;   /* Correction to t.  */
    237      1.1  mrg   u = t + tau;
    238      1.1  mrg 
    239  1.1.1.7  mrg   /* Construct IBM128_TYPE result.  */
    240      1.1  mrg   if (nonfinite (u))
    241      1.1  mrg     return u;
    242  1.1.1.2  mrg   xh = u;
    243  1.1.1.2  mrg   xl = (t - u) + tau;
    244  1.1.1.2  mrg   return pack_ldouble (xh, xl);
    245      1.1  mrg }
    246      1.1  mrg 
    247      1.1  mrg #if defined (_SOFT_DOUBLE) && defined (__LONG_DOUBLE_128__)
    248      1.1  mrg 
    249  1.1.1.7  mrg IBM128_TYPE __gcc_qneg (double, double);
    250      1.1  mrg int __gcc_qeq (double, double, double, double);
    251      1.1  mrg int __gcc_qne (double, double, double, double);
    252      1.1  mrg int __gcc_qge (double, double, double, double);
    253      1.1  mrg int __gcc_qle (double, double, double, double);
    254  1.1.1.7  mrg IBM128_TYPE __gcc_stoq (float);
    255  1.1.1.7  mrg IBM128_TYPE __gcc_dtoq (double);
    256      1.1  mrg float __gcc_qtos (double, double);
    257      1.1  mrg double __gcc_qtod (double, double);
    258      1.1  mrg int __gcc_qtoi (double, double);
    259      1.1  mrg unsigned int __gcc_qtou (double, double);
    260  1.1.1.7  mrg IBM128_TYPE __gcc_itoq (int);
    261  1.1.1.7  mrg IBM128_TYPE __gcc_utoq (unsigned int);
    262      1.1  mrg 
    263      1.1  mrg extern int __eqdf2 (double, double);
    264      1.1  mrg extern int __ledf2 (double, double);
    265      1.1  mrg extern int __gedf2 (double, double);
    266      1.1  mrg 
    267  1.1.1.7  mrg /* Negate 'IBM128_TYPE' value and return the result.	*/
    268  1.1.1.7  mrg IBM128_TYPE
    269      1.1  mrg __gcc_qneg (double a, double aa)
    270      1.1  mrg {
    271  1.1.1.2  mrg   return pack_ldouble (-a, -aa);
    272      1.1  mrg }
    273      1.1  mrg 
    274  1.1.1.7  mrg /* Compare two 'IBM128_TYPE' values for equality.  */
    275      1.1  mrg int
    276      1.1  mrg __gcc_qeq (double a, double aa, double c, double cc)
    277      1.1  mrg {
    278      1.1  mrg   if (__eqdf2 (a, c) == 0)
    279      1.1  mrg     return __eqdf2 (aa, cc);
    280      1.1  mrg   return 1;
    281      1.1  mrg }
    282      1.1  mrg 
    283      1.1  mrg strong_alias (__gcc_qeq, __gcc_qne);
    284      1.1  mrg 
    285  1.1.1.7  mrg /* Compare two 'IBM128_TYPE' values for less than or equal.  */
    286      1.1  mrg int
    287      1.1  mrg __gcc_qle (double a, double aa, double c, double cc)
    288      1.1  mrg {
    289      1.1  mrg   if (__eqdf2 (a, c) == 0)
    290      1.1  mrg     return __ledf2 (aa, cc);
    291      1.1  mrg   return __ledf2 (a, c);
    292      1.1  mrg }
    293      1.1  mrg 
    294      1.1  mrg strong_alias (__gcc_qle, __gcc_qlt);
    295      1.1  mrg 
    296  1.1.1.7  mrg /* Compare two 'IBM128_TYPE' values for greater than or equal.  */
    297      1.1  mrg int
    298      1.1  mrg __gcc_qge (double a, double aa, double c, double cc)
    299      1.1  mrg {
    300      1.1  mrg   if (__eqdf2 (a, c) == 0)
    301      1.1  mrg     return __gedf2 (aa, cc);
    302      1.1  mrg   return __gedf2 (a, c);
    303      1.1  mrg }
    304      1.1  mrg 
    305      1.1  mrg strong_alias (__gcc_qge, __gcc_qgt);
    306      1.1  mrg 
    307  1.1.1.7  mrg /* Convert single to IBM128_TYPE.  */
    308  1.1.1.7  mrg IBM128_TYPE
    309      1.1  mrg __gcc_stoq (float a)
    310      1.1  mrg {
    311  1.1.1.2  mrg   return pack_ldouble ((double) a, 0.0);
    312      1.1  mrg }
    313      1.1  mrg 
    314  1.1.1.7  mrg /* Convert double to IBM128_TYPE.  */
    315  1.1.1.7  mrg IBM128_TYPE
    316      1.1  mrg __gcc_dtoq (double a)
    317      1.1  mrg {
    318  1.1.1.2  mrg   return pack_ldouble (a, 0.0);
    319      1.1  mrg }
    320      1.1  mrg 
    321  1.1.1.7  mrg /* Convert IBM128_TYPE to single.  */
    322      1.1  mrg float
    323      1.1  mrg __gcc_qtos (double a, double aa __attribute__ ((__unused__)))
    324      1.1  mrg {
    325      1.1  mrg   return (float) a;
    326      1.1  mrg }
    327      1.1  mrg 
    328  1.1.1.7  mrg /* Convert IBM128_TYPE to double.  */
    329      1.1  mrg double
    330      1.1  mrg __gcc_qtod (double a, double aa __attribute__ ((__unused__)))
    331      1.1  mrg {
    332      1.1  mrg   return a;
    333      1.1  mrg }
    334      1.1  mrg 
    335  1.1.1.7  mrg /* Convert IBM128_TYPE to int.  */
    336      1.1  mrg int
    337      1.1  mrg __gcc_qtoi (double a, double aa)
    338      1.1  mrg {
    339      1.1  mrg   double z = a + aa;
    340      1.1  mrg   return (int) z;
    341      1.1  mrg }
    342      1.1  mrg 
    343  1.1.1.7  mrg /* Convert IBM128_TYPE to unsigned int.  */
    344      1.1  mrg unsigned int
    345      1.1  mrg __gcc_qtou (double a, double aa)
    346      1.1  mrg {
    347      1.1  mrg   double z = a + aa;
    348      1.1  mrg   return (unsigned int) z;
    349      1.1  mrg }
    350      1.1  mrg 
    351  1.1.1.7  mrg /* Convert int to IBM128_TYPE.  */
    352  1.1.1.7  mrg IBM128_TYPE
    353      1.1  mrg __gcc_itoq (int a)
    354      1.1  mrg {
    355      1.1  mrg   return __gcc_dtoq ((double) a);
    356      1.1  mrg }
    357      1.1  mrg 
    358  1.1.1.7  mrg /* Convert unsigned int to IBM128_TYPE.  */
    359  1.1.1.7  mrg IBM128_TYPE
    360      1.1  mrg __gcc_utoq (unsigned int a)
    361      1.1  mrg {
    362      1.1  mrg   return __gcc_dtoq ((double) a);
    363      1.1  mrg }
    364      1.1  mrg 
    365      1.1  mrg #endif
    366      1.1  mrg 
    367      1.1  mrg #ifdef __NO_FPRS__
    368      1.1  mrg 
    369      1.1  mrg int __gcc_qunord (double, double, double, double);
    370      1.1  mrg 
    371      1.1  mrg extern int __eqdf2 (double, double);
    372      1.1  mrg extern int __unorddf2 (double, double);
    373      1.1  mrg 
    374  1.1.1.7  mrg /* Compare two 'IBM128_TYPE' values for unordered.  */
    375      1.1  mrg int
    376      1.1  mrg __gcc_qunord (double a, double aa, double c, double cc)
    377      1.1  mrg {
    378      1.1  mrg   if (__eqdf2 (a, c) == 0)
    379      1.1  mrg     return __unorddf2 (aa, cc);
    380      1.1  mrg   return __unorddf2 (a, c);
    381      1.1  mrg }
    382      1.1  mrg 
    383      1.1  mrg #include "soft-fp/soft-fp.h"
    384      1.1  mrg #include "soft-fp/double.h"
    385      1.1  mrg #include "soft-fp/quad.h"
    386      1.1  mrg 
    387      1.1  mrg /* Compute floating point multiply-subtract with higher (quad) precision.  */
    388      1.1  mrg static double
    389      1.1  mrg fmsub (double a, double b, double c)
    390      1.1  mrg {
    391      1.1  mrg     FP_DECL_EX;
    392      1.1  mrg     FP_DECL_D(A);
    393      1.1  mrg     FP_DECL_D(B);
    394      1.1  mrg     FP_DECL_D(C);
    395      1.1  mrg     FP_DECL_Q(X);
    396      1.1  mrg     FP_DECL_Q(Y);
    397      1.1  mrg     FP_DECL_Q(Z);
    398      1.1  mrg     FP_DECL_Q(U);
    399      1.1  mrg     FP_DECL_Q(V);
    400      1.1  mrg     FP_DECL_D(R);
    401      1.1  mrg     double r;
    402  1.1.1.7  mrg     IBM128_TYPE u, x, y, z;
    403      1.1  mrg 
    404      1.1  mrg     FP_INIT_ROUNDMODE;
    405      1.1  mrg     FP_UNPACK_RAW_D (A, a);
    406      1.1  mrg     FP_UNPACK_RAW_D (B, b);
    407      1.1  mrg     FP_UNPACK_RAW_D (C, c);
    408      1.1  mrg 
    409      1.1  mrg     /* Extend double to quad.  */
    410  1.1.1.9  mrg #if _FP_W_TYPE_SIZE < 64
    411      1.1  mrg     FP_EXTEND(Q,D,4,2,X,A);
    412      1.1  mrg     FP_EXTEND(Q,D,4,2,Y,B);
    413      1.1  mrg     FP_EXTEND(Q,D,4,2,Z,C);
    414      1.1  mrg #else
    415      1.1  mrg     FP_EXTEND(Q,D,2,1,X,A);
    416      1.1  mrg     FP_EXTEND(Q,D,2,1,Y,B);
    417      1.1  mrg     FP_EXTEND(Q,D,2,1,Z,C);
    418      1.1  mrg #endif
    419      1.1  mrg     FP_PACK_RAW_Q(x,X);
    420      1.1  mrg     FP_PACK_RAW_Q(y,Y);
    421      1.1  mrg     FP_PACK_RAW_Q(z,Z);
    422      1.1  mrg     FP_HANDLE_EXCEPTIONS;
    423      1.1  mrg 
    424      1.1  mrg     /* Multiply.  */
    425      1.1  mrg     FP_INIT_ROUNDMODE;
    426      1.1  mrg     FP_UNPACK_Q(X,x);
    427      1.1  mrg     FP_UNPACK_Q(Y,y);
    428      1.1  mrg     FP_MUL_Q(U,X,Y);
    429      1.1  mrg     FP_PACK_Q(u,U);
    430      1.1  mrg     FP_HANDLE_EXCEPTIONS;
    431      1.1  mrg 
    432      1.1  mrg     /* Subtract.  */
    433      1.1  mrg     FP_INIT_ROUNDMODE;
    434      1.1  mrg     FP_UNPACK_SEMIRAW_Q(U,u);
    435      1.1  mrg     FP_UNPACK_SEMIRAW_Q(Z,z);
    436      1.1  mrg     FP_SUB_Q(V,U,Z);
    437      1.1  mrg 
    438      1.1  mrg     /* Truncate quad to double.  */
    439  1.1.1.9  mrg #if _FP_W_TYPE_SIZE < 64
    440      1.1  mrg     V_f[3] &= 0x0007ffff;
    441      1.1  mrg     FP_TRUNC(D,Q,2,4,R,V);
    442      1.1  mrg #else
    443      1.1  mrg     V_f1 &= 0x0007ffffffffffffL;
    444      1.1  mrg     FP_TRUNC(D,Q,1,2,R,V);
    445      1.1  mrg #endif
    446      1.1  mrg     FP_PACK_SEMIRAW_D(r,R);
    447      1.1  mrg     FP_HANDLE_EXCEPTIONS;
    448      1.1  mrg 
    449      1.1  mrg     return r;
    450      1.1  mrg }
    451      1.1  mrg 
    452      1.1  mrg #endif
    453      1.1  mrg 
    454      1.1  mrg #endif
    455