1 /* Subtract _Float64 values, converting the result to _Float32x. i386 version.
2 Copyright (C) 2018-2022 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19 #include <math.h>
20 #include <fpu_control.h>
21 #include <math-narrow-eval.h>
22 #include <math-narrow.h>
23
24 _Float32x
__f32xsubf64(_Float64 x,_Float64 y)25 __f32xsubf64 (_Float64 x, _Float64 y)
26 {
27 /* To avoid double rounding, set double precision for the subtraction.
28 math_narrow_eval is still needed to eliminate excess range in the
29 case of overflow. If the result of the subtraction is in the
30 subnormal range for double, it is exact, so no issues of double
31 rounding for subnormals arise. */
32 fpu_control_t cw, cw_double;
33 _FPU_GETCW (cw);
34 cw_double = (cw & ~_FPU_EXTENDED) | _FPU_DOUBLE;
35 _FPU_SETCW (cw_double);
36 _Float32x ret = math_narrow_eval (x - y);
37 _FPU_SETCW (cw);
38 CHECK_NARROW_SUB (ret, x, y);
39 return ret;
40 }
41 libm_alias_float32x_float64 (sub)
42