@@ -131,154 +131,6 @@ fn test_float_bits_conv() {
131131 assert_eq ! ( f16:: from_bits( masked_nan2) . to_bits( ) , masked_nan2) ;
132132}
133133
134- #[ test]
135- #[ cfg( not( miri) ) ]
136- #[ cfg( target_has_reliable_f16_math) ]
137- fn test_total_cmp ( ) {
138- use core:: cmp:: Ordering ;
139-
140- fn quiet_bit_mask ( ) -> u16 {
141- 1 << ( f16:: MANTISSA_DIGITS - 2 )
142- }
143-
144- fn min_subnorm ( ) -> f16 {
145- f16:: MIN_POSITIVE / f16:: powf ( 2.0 , f16:: MANTISSA_DIGITS as f16 - 1.0 )
146- }
147-
148- fn max_subnorm ( ) -> f16 {
149- f16:: MIN_POSITIVE - min_subnorm ( )
150- }
151-
152- fn q_nan ( ) -> f16 {
153- f16:: from_bits ( f16:: NAN . to_bits ( ) | quiet_bit_mask ( ) )
154- }
155-
156- // FIXME(f16_f128): Tests involving sNaN are disabled because without optimizations,
157- // `total_cmp` is getting incorrectly lowered to code that includes a `extend`/`trunc` round
158- // trip, which quiets sNaNs. See: https://github.com/llvm/llvm-project/issues/104915
159- // fn s_nan() -> f16 {
160- // f16::from_bits((f16::NAN.to_bits() & !quiet_bit_mask()) + 42)
161- // }
162-
163- assert_eq ! ( Ordering :: Equal , ( -q_nan( ) ) . total_cmp( & -q_nan( ) ) ) ;
164- // assert_eq!(Ordering::Equal, (-s_nan()).total_cmp(&-s_nan()));
165- assert_eq ! ( Ordering :: Equal , ( -f16:: INFINITY ) . total_cmp( & -f16:: INFINITY ) ) ;
166- assert_eq ! ( Ordering :: Equal , ( -f16:: MAX ) . total_cmp( & -f16:: MAX ) ) ;
167- assert_eq ! ( Ordering :: Equal , ( -2.5_f16 ) . total_cmp( & -2.5 ) ) ;
168- assert_eq ! ( Ordering :: Equal , ( -1.0_f16 ) . total_cmp( & -1.0 ) ) ;
169- assert_eq ! ( Ordering :: Equal , ( -1.5_f16 ) . total_cmp( & -1.5 ) ) ;
170- assert_eq ! ( Ordering :: Equal , ( -0.5_f16 ) . total_cmp( & -0.5 ) ) ;
171- assert_eq ! ( Ordering :: Equal , ( -f16:: MIN_POSITIVE ) . total_cmp( & -f16:: MIN_POSITIVE ) ) ;
172- assert_eq ! ( Ordering :: Equal , ( -max_subnorm( ) ) . total_cmp( & -max_subnorm( ) ) ) ;
173- assert_eq ! ( Ordering :: Equal , ( -min_subnorm( ) ) . total_cmp( & -min_subnorm( ) ) ) ;
174- assert_eq ! ( Ordering :: Equal , ( -0.0_f16 ) . total_cmp( & -0.0 ) ) ;
175- assert_eq ! ( Ordering :: Equal , 0.0_f16 . total_cmp( & 0.0 ) ) ;
176- assert_eq ! ( Ordering :: Equal , min_subnorm( ) . total_cmp( & min_subnorm( ) ) ) ;
177- assert_eq ! ( Ordering :: Equal , max_subnorm( ) . total_cmp( & max_subnorm( ) ) ) ;
178- assert_eq ! ( Ordering :: Equal , f16:: MIN_POSITIVE . total_cmp( & f16:: MIN_POSITIVE ) ) ;
179- assert_eq ! ( Ordering :: Equal , 0.5_f16 . total_cmp( & 0.5 ) ) ;
180- assert_eq ! ( Ordering :: Equal , 1.0_f16 . total_cmp( & 1.0 ) ) ;
181- assert_eq ! ( Ordering :: Equal , 1.5_f16 . total_cmp( & 1.5 ) ) ;
182- assert_eq ! ( Ordering :: Equal , 2.5_f16 . total_cmp( & 2.5 ) ) ;
183- assert_eq ! ( Ordering :: Equal , f16:: MAX . total_cmp( & f16:: MAX ) ) ;
184- assert_eq ! ( Ordering :: Equal , f16:: INFINITY . total_cmp( & f16:: INFINITY ) ) ;
185- // assert_eq!(Ordering::Equal, s_nan().total_cmp(&s_nan()));
186- assert_eq ! ( Ordering :: Equal , q_nan( ) . total_cmp( & q_nan( ) ) ) ;
187-
188- // assert_eq!(Ordering::Less, (-q_nan()).total_cmp(&-s_nan()));
189- // assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&-f16::INFINITY));
190- assert_eq ! ( Ordering :: Less , ( -f16:: INFINITY ) . total_cmp( & -f16:: MAX ) ) ;
191- assert_eq ! ( Ordering :: Less , ( -f16:: MAX ) . total_cmp( & -2.5 ) ) ;
192- assert_eq ! ( Ordering :: Less , ( -2.5_f16 ) . total_cmp( & -1.5 ) ) ;
193- assert_eq ! ( Ordering :: Less , ( -1.5_f16 ) . total_cmp( & -1.0 ) ) ;
194- assert_eq ! ( Ordering :: Less , ( -1.0_f16 ) . total_cmp( & -0.5 ) ) ;
195- assert_eq ! ( Ordering :: Less , ( -0.5_f16 ) . total_cmp( & -f16:: MIN_POSITIVE ) ) ;
196- assert_eq ! ( Ordering :: Less , ( -f16:: MIN_POSITIVE ) . total_cmp( & -max_subnorm( ) ) ) ;
197- assert_eq ! ( Ordering :: Less , ( -max_subnorm( ) ) . total_cmp( & -min_subnorm( ) ) ) ;
198- assert_eq ! ( Ordering :: Less , ( -min_subnorm( ) ) . total_cmp( & -0.0 ) ) ;
199- assert_eq ! ( Ordering :: Less , ( -0.0_f16 ) . total_cmp( & 0.0 ) ) ;
200- assert_eq ! ( Ordering :: Less , 0.0_f16 . total_cmp( & min_subnorm( ) ) ) ;
201- assert_eq ! ( Ordering :: Less , min_subnorm( ) . total_cmp( & max_subnorm( ) ) ) ;
202- assert_eq ! ( Ordering :: Less , max_subnorm( ) . total_cmp( & f16:: MIN_POSITIVE ) ) ;
203- assert_eq ! ( Ordering :: Less , f16:: MIN_POSITIVE . total_cmp( & 0.5 ) ) ;
204- assert_eq ! ( Ordering :: Less , 0.5_f16 . total_cmp( & 1.0 ) ) ;
205- assert_eq ! ( Ordering :: Less , 1.0_f16 . total_cmp( & 1.5 ) ) ;
206- assert_eq ! ( Ordering :: Less , 1.5_f16 . total_cmp( & 2.5 ) ) ;
207- assert_eq ! ( Ordering :: Less , 2.5_f16 . total_cmp( & f16:: MAX ) ) ;
208- assert_eq ! ( Ordering :: Less , f16:: MAX . total_cmp( & f16:: INFINITY ) ) ;
209- // assert_eq!(Ordering::Less, f16::INFINITY.total_cmp(&s_nan()));
210- // assert_eq!(Ordering::Less, s_nan().total_cmp(&q_nan()));
211-
212- // assert_eq!(Ordering::Greater, (-s_nan()).total_cmp(&-q_nan()));
213- // assert_eq!(Ordering::Greater, (-f16::INFINITY).total_cmp(&-s_nan()));
214- assert_eq ! ( Ordering :: Greater , ( -f16:: MAX ) . total_cmp( & -f16:: INFINITY ) ) ;
215- assert_eq ! ( Ordering :: Greater , ( -2.5_f16 ) . total_cmp( & -f16:: MAX ) ) ;
216- assert_eq ! ( Ordering :: Greater , ( -1.5_f16 ) . total_cmp( & -2.5 ) ) ;
217- assert_eq ! ( Ordering :: Greater , ( -1.0_f16 ) . total_cmp( & -1.5 ) ) ;
218- assert_eq ! ( Ordering :: Greater , ( -0.5_f16 ) . total_cmp( & -1.0 ) ) ;
219- assert_eq ! ( Ordering :: Greater , ( -f16:: MIN_POSITIVE ) . total_cmp( & -0.5 ) ) ;
220- assert_eq ! ( Ordering :: Greater , ( -max_subnorm( ) ) . total_cmp( & -f16:: MIN_POSITIVE ) ) ;
221- assert_eq ! ( Ordering :: Greater , ( -min_subnorm( ) ) . total_cmp( & -max_subnorm( ) ) ) ;
222- assert_eq ! ( Ordering :: Greater , ( -0.0_f16 ) . total_cmp( & -min_subnorm( ) ) ) ;
223- assert_eq ! ( Ordering :: Greater , 0.0_f16 . total_cmp( & -0.0 ) ) ;
224- assert_eq ! ( Ordering :: Greater , min_subnorm( ) . total_cmp( & 0.0 ) ) ;
225- assert_eq ! ( Ordering :: Greater , max_subnorm( ) . total_cmp( & min_subnorm( ) ) ) ;
226- assert_eq ! ( Ordering :: Greater , f16:: MIN_POSITIVE . total_cmp( & max_subnorm( ) ) ) ;
227- assert_eq ! ( Ordering :: Greater , 0.5_f16 . total_cmp( & f16:: MIN_POSITIVE ) ) ;
228- assert_eq ! ( Ordering :: Greater , 1.0_f16 . total_cmp( & 0.5 ) ) ;
229- assert_eq ! ( Ordering :: Greater , 1.5_f16 . total_cmp( & 1.0 ) ) ;
230- assert_eq ! ( Ordering :: Greater , 2.5_f16 . total_cmp( & 1.5 ) ) ;
231- assert_eq ! ( Ordering :: Greater , f16:: MAX . total_cmp( & 2.5 ) ) ;
232- assert_eq ! ( Ordering :: Greater , f16:: INFINITY . total_cmp( & f16:: MAX ) ) ;
233- // assert_eq!(Ordering::Greater, s_nan().total_cmp(&f16::INFINITY));
234- // assert_eq!(Ordering::Greater, q_nan().total_cmp(&s_nan()));
235-
236- // assert_eq!(Ordering::Less, (-q_nan()).total_cmp(&-s_nan()));
237- assert_eq ! ( Ordering :: Less , ( -q_nan( ) ) . total_cmp( & -f16:: INFINITY ) ) ;
238- assert_eq ! ( Ordering :: Less , ( -q_nan( ) ) . total_cmp( & -f16:: MAX ) ) ;
239- assert_eq ! ( Ordering :: Less , ( -q_nan( ) ) . total_cmp( & -2.5 ) ) ;
240- assert_eq ! ( Ordering :: Less , ( -q_nan( ) ) . total_cmp( & -1.5 ) ) ;
241- assert_eq ! ( Ordering :: Less , ( -q_nan( ) ) . total_cmp( & -1.0 ) ) ;
242- assert_eq ! ( Ordering :: Less , ( -q_nan( ) ) . total_cmp( & -0.5 ) ) ;
243- assert_eq ! ( Ordering :: Less , ( -q_nan( ) ) . total_cmp( & -f16:: MIN_POSITIVE ) ) ;
244- assert_eq ! ( Ordering :: Less , ( -q_nan( ) ) . total_cmp( & -max_subnorm( ) ) ) ;
245- assert_eq ! ( Ordering :: Less , ( -q_nan( ) ) . total_cmp( & -min_subnorm( ) ) ) ;
246- assert_eq ! ( Ordering :: Less , ( -q_nan( ) ) . total_cmp( & -0.0 ) ) ;
247- assert_eq ! ( Ordering :: Less , ( -q_nan( ) ) . total_cmp( & 0.0 ) ) ;
248- assert_eq ! ( Ordering :: Less , ( -q_nan( ) ) . total_cmp( & min_subnorm( ) ) ) ;
249- assert_eq ! ( Ordering :: Less , ( -q_nan( ) ) . total_cmp( & max_subnorm( ) ) ) ;
250- assert_eq ! ( Ordering :: Less , ( -q_nan( ) ) . total_cmp( & f16:: MIN_POSITIVE ) ) ;
251- assert_eq ! ( Ordering :: Less , ( -q_nan( ) ) . total_cmp( & 0.5 ) ) ;
252- assert_eq ! ( Ordering :: Less , ( -q_nan( ) ) . total_cmp( & 1.0 ) ) ;
253- assert_eq ! ( Ordering :: Less , ( -q_nan( ) ) . total_cmp( & 1.5 ) ) ;
254- assert_eq ! ( Ordering :: Less , ( -q_nan( ) ) . total_cmp( & 2.5 ) ) ;
255- assert_eq ! ( Ordering :: Less , ( -q_nan( ) ) . total_cmp( & f16:: MAX ) ) ;
256- assert_eq ! ( Ordering :: Less , ( -q_nan( ) ) . total_cmp( & f16:: INFINITY ) ) ;
257- // assert_eq!(Ordering::Less, (-q_nan()).total_cmp(&s_nan()));
258-
259- // assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&-f16::INFINITY));
260- // assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&-f16::MAX));
261- // assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&-2.5));
262- // assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&-1.5));
263- // assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&-1.0));
264- // assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&-0.5));
265- // assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&-f16::MIN_POSITIVE));
266- // assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&-max_subnorm()));
267- // assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&-min_subnorm()));
268- // assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&-0.0));
269- // assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&0.0));
270- // assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&min_subnorm()));
271- // assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&max_subnorm()));
272- // assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&f16::MIN_POSITIVE));
273- // assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&0.5));
274- // assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&1.0));
275- // assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&1.5));
276- // assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&2.5));
277- // assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&f16::MAX));
278- // assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&f16::INFINITY));
279- // assert_eq!(Ordering::Less, (-s_nan()).total_cmp(&s_nan()));
280- }
281-
282134#[ test]
283135fn test_algebraic ( ) {
284136 let a: f16 = 123.0 ;
0 commit comments