Remove unused variables
[glibc.git] / sysdeps / powerpc / fpu / e_hypotf.c
blob48360828c36b771c151eb5e38170bbf69c163e51
1 /* Pythagorean addition using floats
2 Copyright (C) 2011-2016 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/>. */
20 #include <math.h>
21 #include <math_private.h>
22 #include <stdint.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. */
31 #ifdef _ARCH_PWR7
32 /* POWER7 isinf and isnan optimizations are fast. */
33 # define TEST_INF_NAN(x, y) \
34 if (isinff(x) || isinff(y)) \
35 return INFINITY; \
36 if (isnanf(x) || isnanf(y)) \
37 return NAN;
38 # else
39 /* For POWER6 and below isinf/isnan triggers LHS and PLT calls are
40 * costly (especially for POWER6). */
41 # define GET_TWO_FLOAT_WORD(f1,f2,i1,i2) \
42 do { \
43 ieee_float_shape_type gf_u1; \
44 ieee_float_shape_type gf_u2; \
45 gf_u1.value = (f1); \
46 gf_u2.value = (f2); \
47 (i1) = gf_u1.word & 0x7fffffff; \
48 (i2) = gf_u2.word & 0x7fffffff; \
49 } while (0)
51 # define TEST_INF_NAN(x, y) \
52 do { \
53 uint32_t hx, hy; \
54 GET_TWO_FLOAT_WORD(x, y, hx, hy); \
55 if (hy > hx) { \
56 uint32_t ht = hx; hx = hy; hy = ht; \
57 } \
58 if (hx >= 0x7f800000) { \
59 if (hx == 0x7f800000 || hy == 0x7f800000) \
60 return INFINITY; \
61 return NAN; \
62 } \
63 } while (0)
64 #endif
67 float
68 __ieee754_hypotf (float x, float y)
70 TEST_INF_NAN (x, y);
72 return __ieee754_sqrt ((double) x * x + (double) y * y);
74 strong_alias (__ieee754_hypotf, __hypotf_finite)