]>
git.ipfire.org Git - people/ms/u-boot.git/blob - post/lib_ppc/fpu/compare-fp-1.c
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
24 * Test for correctness of composite floating-point comparisons.
25 * Written by Paolo Bonzini, 26th May 2004.
26 * This file is originally a part of the GCC testsuite.
33 #if CONFIG_POST & CFG_POST_FPU
37 #define TEST(c) if ((c) != ok) failed++
38 #define ORD(a, b) (!__builtin_isunordered ((a), (b)))
39 #define UNORD(a, b) (__builtin_isunordered ((a), (b)))
40 #define UNEQ(a, b) (__builtin_isunordered ((a), (b)) || ((a) == (b)))
41 #define UNLT(a, b) (__builtin_isunordered ((a), (b)) || ((a) < (b)))
42 #define UNLE(a, b) (__builtin_isunordered ((a), (b)) || ((a) <= (b)))
43 #define UNGT(a, b) (__builtin_isunordered ((a), (b)) || ((a) > (b)))
44 #define UNGE(a, b) (__builtin_isunordered ((a), (b)) || ((a) >= (b)))
45 #define LTGT(a, b) (__builtin_islessgreater ((a), (b)))
51 static void iuneq (float x
, float y
, int ok
)
55 TEST (UNLE (x
, y
) && UNGE (x
,y
));
58 static void ieq (float x
, float y
, int ok
)
60 TEST (ORD (x
, y
) && UNEQ (x
, y
));
63 static void iltgt (float x
, float y
, int ok
)
65 TEST (!UNEQ (x
, y
)); /* Not optimizable. */
66 TEST (LTGT (x
, y
)); /* Same, __builtin_islessgreater does not trap. */
67 TEST (ORD (x
, y
) && (UNLT (x
, y
) || UNGT (x
,y
)));
70 static void ine (float x
, float y
, int ok
)
72 TEST (UNLT (x
, y
) || UNGT (x
, y
));
75 static void iunlt (float x
, float y
, int ok
)
78 TEST (UNORD (x
, y
) || (x
< y
));
81 static void ilt (float x
, float y
, int ok
)
83 TEST (ORD (x
, y
) && UNLT (x
, y
)); /* Not optimized */
84 TEST ((x
<= y
) && (x
!= y
));
85 TEST ((x
<= y
) && (y
!= x
));
86 TEST ((x
!= y
) && (x
<= y
)); /* Not optimized */
87 TEST ((y
!= x
) && (x
<= y
)); /* Not optimized */
90 static void iunle (float x
, float y
, int ok
)
93 TEST (UNORD (x
, y
) || (x
<= y
));
96 static void ile (float x
, float y
, int ok
)
98 TEST (ORD (x
, y
) && UNLE (x
, y
)); /* Not optimized */
99 TEST ((x
< y
) || (x
== y
));
100 TEST ((y
> x
) || (x
== y
));
101 TEST ((x
== y
) || (x
< y
)); /* Not optimized */
102 TEST ((y
== x
) || (x
< y
)); /* Not optimized */
105 static void iungt (float x
, float y
, int ok
)
108 TEST (UNORD (x
, y
) || (x
> y
));
111 static void igt (float x
, float y
, int ok
)
113 TEST (ORD (x
, y
) && UNGT (x
, y
)); /* Not optimized */
114 TEST ((x
>= y
) && (x
!= y
));
115 TEST ((x
>= y
) && (y
!= x
));
116 TEST ((x
!= y
) && (x
>= y
)); /* Not optimized */
117 TEST ((y
!= x
) && (x
>= y
)); /* Not optimized */
120 static void iunge (float x
, float y
, int ok
)
123 TEST (UNORD (x
, y
) || (x
>= y
));
126 static void ige (float x
, float y
, int ok
)
128 TEST (ORD (x
, y
) && UNGE (x
, y
)); /* Not optimized */
129 TEST ((x
> y
) || (x
== y
));
130 TEST ((y
< x
) || (x
== y
));
131 TEST ((x
== y
) || (x
> y
)); /* Not optimized */
132 TEST ((y
== x
) || (x
> y
)); /* Not optimized */
135 int fpu_post_test_math6 (void)
137 pinf
= __builtin_inf ();
138 ninf
= -__builtin_inf ();
139 NaN
= __builtin_nan ("");
141 iuneq (ninf
, pinf
, 0);
143 iuneq (pinf
, ninf
, 0);
152 iltgt (ninf
, pinf
, 1);
154 iltgt (pinf
, ninf
, 1);
163 iunlt (NaN
, ninf
, 1);
164 iunlt (pinf
, NaN
, 1);
165 iunlt (pinf
, ninf
, 0);
166 iunlt (pinf
, pinf
, 0);
167 iunlt (ninf
, ninf
, 0);
176 iunle (NaN
, ninf
, 1);
177 iunle (pinf
, NaN
, 1);
178 iunle (pinf
, ninf
, 0);
179 iunle (pinf
, pinf
, 1);
180 iunle (ninf
, ninf
, 1);
189 iungt (NaN
, ninf
, 1);
190 iungt (pinf
, NaN
, 1);
191 iungt (pinf
, ninf
, 1);
192 iungt (pinf
, pinf
, 0);
193 iungt (ninf
, ninf
, 0);
202 iunge (NaN
, ninf
, 1);
203 iunge (pinf
, NaN
, 1);
204 iunge (ninf
, pinf
, 0);
205 iunge (pinf
, pinf
, 1);
206 iunge (ninf
, ninf
, 1);
216 post_log ("Error in FPU math6 test\n");
222 #endif /* CONFIG_POST & CFG_POST_FPU */