1 /* lround function. POWER5+, PowerPC32 version.
2 Copyright (C) 2006-2015 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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.
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.
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/>. */
19 #include <math_ldbl_opt.h>
21 /* long [r3] lround (float x [fp1])
22 IEEE 1003.1 lround function. IEEE specifies "round to the nearest
23 integer value, rounding halfway cases away from zero, regardless of
24 the current rounding mode." However PowerPC Architecture defines
25 "round to Nearest" as "Choose the best approximation. In case of a
26 tie, choose the one that is even (least significant bit o).".
27 So we pre-round using the V2.02 Floating Round to Integer Nearest
28 instruction before we use the Floating Convert to Integer Word with
29 round to zero instruction. */
34 cfi_adjust_cfa_offset (16)
36 fctiwz fp3,fp2 /* Convert To Integer Word lround toward 0. */
38 nop /* Ensure the following load is in a different dispatch */
39 nop /* group to avoid pipe stall on POWER4&5. */
46 weak_alias (__lround, lround)
48 strong_alias (__lround, __lroundf)
49 weak_alias (__lround, lroundf)
52 weak_alias (__lround, lroundl)
53 strong_alias (__lround, __lroundl)
55 #if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)
56 compat_symbol (libm, __lround, lroundl, GLIBC_2_1)