Prefer https to http for gnu.org and fsf.org URLs
[platform/upstream/glibc.git] / sysdeps / x86_64 / fpu / s_fminl.S
1 /* Compute minimum of two numbers, regarding NaN as missing argument.
2    Copyright (C) 1997-2019 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
5
6    The GNU C Library is free software; you can redistribute it and/or
7    modify it under the terms of the GNU Lesser General Public
8    License as published by the Free Software Foundation; either
9    version 2.1 of the License, or (at your option) any later version.
10
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    Lesser General Public License for more details.
15
16    You should have received a copy of the GNU Lesser General Public
17    License along with the GNU C Library; if not, see
18    <https://www.gnu.org/licenses/>.  */
19
20 #include <sysdep.h>
21 #include <libm-alias-ldouble.h>
22
23         .text
24 ENTRY(__fminl)
25         fldt    8(%rsp)         // x
26         fldt    24(%rsp)        // x : y
27
28         fucomi  %st(1), %st
29         jp      2f
30         fcmovnb %st(1), %st
31
32         fstp    %st(1)
33
34         ret
35
36 2:      // Unordered.
37         fucomi  %st(0), %st
38         jp      3f
39         // st(1) is a NaN; st(0) is not.  Test if st(1) is signaling.
40         testb   $0x40, 15(%rsp)
41         jz      4f
42         fstp    %st(1)
43         ret
44
45 3:      // st(0) is a NaN; st(1) may or may not be.
46         fxch
47         fucomi  %st(0), %st
48         jp      4f
49         // st(1) is a NaN; st(0) is not.  Test if st(1) is signaling.
50         testb   $0x40, 31(%rsp)
51         jz      4f
52         fstp    %st(1)
53         ret
54
55 4:      // Both arguments are NaNs, or one is a signaling NaN.
56         faddp
57         ret
58 END(__fminl)
59 libm_alias_ldouble (__fmin, fmin)