Print this page
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libm/common/m9x/fminf.c
+++ new/usr/src/lib/libm/common/m9x/fminf.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
24 24 */
25 25 /*
26 26 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
27 27 * Use is subject to license terms.
28 28 */
29 29
30 30 #if defined(ELFOBJ)
31 31 #pragma weak fminf = __fminf
32 32 #endif
33 33
34 34 #include "libm.h" /* for islessequal macro */
35 35
36 36 float
37 37 __fminf(float x, float y) {
38 38 /*
39 39 * On SPARC v8plus/v9, this could be implemented as follows
40 40 * (assuming %f0 = x, %f1 = y, return value left in %f0):
41 41 *
42 42 * fcmps %fcc0,%f1,%f1
43 43 * fmovsu %fcc0,%f0,%f1
44 44 * fcmps %fcc0,%f0,%f1
45 45 * fmovsug %fcc0,%f1,%f0
46 46 * st %f0,[x]
47 47 * st %f1,[y]
48 48 * ld [x],%l0
49 49 * ld [y],%l1
50 50 * or %l0,%l1,%l2
51 51 * sethi %hi(0x80000000),%l3
52 52 * and %l3,%l2,%l2
53 53 * or %l0,%l2,%l0
54 54 * st %l0,[x]
55 55 * ld [x],%f0
56 56 *
57 57 * If VIS instructions are available, use this code instead:
58 58 *
59 59 * fcmps %fcc0,%f1,%f1
60 60 * fmovsu %fcc0,%f0,%f1
61 61 * fcmps %fcc0,%f0,%f1
62 62 * fmovsug %fcc0,%f1,%f0
63 63 * fors %f0,%f1,%f2
64 64 * fzeros %f3
65 65 * fnegs %f3,%f3
66 66 * fands %f3,%f2,%f2
67 67 * fors %f0,%f2,%f0
68 68 *
69 69 * If VIS 3.0 instructions are available, use this:
70 70 *
71 71 * flcmps %fcc0,%f0,%f1
72 72 * fmovsge %fcc0,%f1,%f0 ! move if %fcc0 is 0 or 2
73 73 */
74 74
75 75 union {
76 76 unsigned i;
77 77 float f;
78 78 } xx, yy;
↓ open down ↓ |
78 lines elided |
↑ open up ↑ |
79 79 unsigned s;
80 80
81 81 /* if y is nan, replace it by x */
82 82 if (y != y)
83 83 y = x;
84 84
85 85 /* if x is nan, replace it by y */
86 86 if (x != x)
87 87 x = y;
88 88
89 -/* if x is greater than y or x and y are unordered, replace x by y */
90 -#if defined(COMPARISON_MACRO_BUG)
91 - if (x > y)
92 -#else
93 - if (!islessequal(x, y))
94 -#endif
89 + /* At this point, x and y are either both numeric, or both NaN */
90 + if (!isnan(x) && !islessequal(x, y))
95 91 x = y;
96 92
97 93 /*
98 - * now x and y are either both NaN or both numeric; set the
99 - * sign of the result if either x or y has its sign set
94 + * set the sign of the result if either x or y has its sign set
100 95 */
101 96 xx.f = x;
102 97 yy.f = y;
103 98 s = (xx.i | yy.i) & 0x80000000;
104 99 xx.i |= s;
105 100
106 101 return (xx.f);
107 102 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX