]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/powerpc/powerpc32/fpu/s_ceil.S
7f2f97ada1a14a52c9e543d9cc4e46a3730a306f
[thirdparty/glibc.git] / sysdeps / powerpc / powerpc32 / fpu / s_ceil.S
1 /* ceil function. PowerPC32 version.
2 Copyright (C) 2004-2018 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 <http://www.gnu.org/licenses/>. */
18
19 #include <sysdep.h>
20 #include <math_ldbl_opt.h>
21 #include <libm-alias-double.h>
22
23 .section .rodata.cst4,"aM",@progbits,4
24 .align 2
25 .LC0: /* 2**52 */
26 .long 0x59800000
27
28 .section ".text"
29 ENTRY (__ceil)
30 #ifdef SHARED
31 mflr r11
32 cfi_register(lr,r11)
33 SETUP_GOT_ACCESS(r9,got_label)
34 addis r9,r9,.LC0-got_label@ha
35 lfs fp13,.LC0-got_label@l(r9)
36 mtlr r11
37 cfi_same_value (lr)
38 #else
39 lis r9,.LC0@ha
40 lfs fp13,.LC0@l(r9)
41 #endif
42 fabs fp0,fp1
43 fsub fp12,fp13,fp13 /* generate 0.0 */
44 fcmpu cr7,fp0,fp13 /* if (fabs(x) > TWO52) */
45 mffs fp11 /* Save current FPU rounding mode and
46 "inexact" state. */
47 fcmpu cr6,fp1,fp12 /* if (x > 0.0) */
48 bnl- cr7,.L10
49 mtfsfi 7,2 /* Set rounding mode toward +inf. */
50 ble- cr6,.L4
51 fadd fp1,fp1,fp13 /* x+= TWO52; */
52 fsub fp1,fp1,fp13 /* x-= TWO52; */
53 fabs fp1,fp1 /* if (x == 0.0) */
54 /* x = 0.0; */
55 mtfsf 0xff,fp11 /* Restore previous rounding mode and
56 "inexact" state. */
57 blr
58 .L4:
59 bge- cr6,.L9 /* if (x < 0.0) */
60 fsub fp1,fp1,fp13 /* x-= TWO52; */
61 fadd fp1,fp1,fp13 /* x+= TWO52; */
62 fnabs fp1,fp1 /* if (x == 0.0) */
63 /* x = -0.0; */
64 .L9:
65 mtfsf 0xff,fp11 /* Restore previous rounding mode and
66 "inexact" state. */
67 blr
68 .L10:
69 /* Ensure sNaN input is converted to qNaN. */
70 fcmpu cr7,fp1,fp1
71 beqlr cr7
72 fadd fp1,fp1,fp1
73 blr
74 END (__ceil)
75
76 libm_alias_double (__ceil, ceil)