1 /* Pythagorean addition using floats
2 Copyright (C) 2011-2017 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Adhemerval Zanella <azanella@br.ibm.com>, 2011
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public License as
8 published by the Free Software Foundation; either version 2 of the
9 License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public
17 License along with the GNU C Library; see the file COPYING.LIB. If
18 not, see <http://www.gnu.org/licenses/>. */
21 #include <math_private.h>
24 /* __ieee754_hypotf(x,y)
26 This a FP only version without any FP->INT conversion.
27 It is similar to default C version, making appropriates
28 overflow and underflows checks as using double precision
29 instead of scaling. */
32 /* POWER7 isinf and isnan optimizations are fast. */
33 # define TEST_INF_NAN(x, y) \
34 if ((isinff(x) || isinff(y)) \
35 && !issignaling (x) && !issignaling (y)) \
37 if (isnanf(x) || isnanf(y)) \
40 /* For POWER6 and below isinf/isnan triggers LHS and PLT calls are
41 * costly (especially for POWER6). */
42 # define GET_TWO_FLOAT_WORD(f1,f2,i1,i2) \
44 ieee_float_shape_type gf_u1; \
45 ieee_float_shape_type gf_u2; \
48 (i1) = gf_u1.word & 0x7fffffff; \
49 (i2) = gf_u2.word & 0x7fffffff; \
52 # define TEST_INF_NAN(x, y) \
55 GET_TWO_FLOAT_WORD(x, y, hx, hy); \
57 uint32_t ht = hx; hx = hy; hy = ht; \
59 if (hx >= 0x7f800000) { \
60 if ((hx == 0x7f800000 || hy == 0x7f800000) \
61 && !issignaling (x) && !issignaling (y)) \
70 __ieee754_hypotf (float x
, float y
)
74 return __ieee754_sqrt ((double) x
* x
+ (double) y
* y
);
76 strong_alias (__ieee754_hypotf
, __hypotf_finite
)