File tree 3 files changed +10
-4
lines changed
compiler/rustc_ty_utils/src
3 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -371,6 +371,8 @@ fn fn_abi_new_uncached<'tcx>(
371
371
let target = & cx. tcx . sess . target ;
372
372
let target_env_gnu_like = matches ! ( & target. env[ ..] , "gnu" | "musl" | "uclibc" ) ;
373
373
let win_x64_gnu = target. os == "windows" && target. arch == "x86_64" && target. env == "gnu" ;
374
+ let x86_sse2 =
375
+ target. arch == "x86" && ( target. features . contains ( "sse2" ) || target. cpu == "pentium4" ) ;
374
376
let linux_s390x_gnu_like =
375
377
target. os == "linux" && target. arch == "s390x" && target_env_gnu_like;
376
378
let linux_sparc64_gnu_like =
@@ -415,6 +417,10 @@ fn fn_abi_new_uncached<'tcx>(
415
417
is_return,
416
418
drop_target_pointee,
417
419
) ;
420
+ // Use XMM0 instead of FP0 to preserve NaN payloads
421
+ if x86_sse2 && rust_abi && is_return && matches ! ( scalar. primitive( ) , F32 | F64 ) {
422
+ attrs. set ( ArgAttribute :: InReg ) ;
423
+ }
418
424
attrs
419
425
} ) ;
420
426
Original file line number Diff line number Diff line change @@ -328,7 +328,7 @@ macro_rules! assert_f32_biteq {
328
328
329
329
// Ignore test on x87 floating point, these platforms do not guarantee NaN
330
330
// payloads are preserved and flush denormals to zero, failing the tests.
331
- #[ cfg( not( target_arch = "x86" ) ) ]
331
+ #[ cfg( not( all ( target_arch = "x86" , not ( target_feature = "sse2" ) ) ) ) ]
332
332
#[ test]
333
333
fn test_next_up ( ) {
334
334
let tiny = f32:: from_bits ( 1 ) ;
@@ -361,7 +361,7 @@ fn test_next_up() {
361
361
362
362
// Ignore test on x87 floating point, these platforms do not guarantee NaN
363
363
// payloads are preserved and flush denormals to zero, failing the tests.
364
- #[ cfg( not( target_arch = "x86" ) ) ]
364
+ #[ cfg( not( all ( target_arch = "x86" , not ( target_feature = "sse2" ) ) ) ) ]
365
365
#[ test]
366
366
fn test_next_down ( ) {
367
367
let tiny = f32:: from_bits ( 1 ) ;
Original file line number Diff line number Diff line change @@ -318,7 +318,7 @@ macro_rules! assert_f64_biteq {
318
318
319
319
// Ignore test on x87 floating point, these platforms do not guarantee NaN
320
320
// payloads are preserved and flush denormals to zero, failing the tests.
321
- #[ cfg( not( target_arch = "x86" ) ) ]
321
+ #[ cfg( not( all ( target_arch = "x86" , not ( target_feature = "sse2" ) ) ) ) ]
322
322
#[ test]
323
323
fn test_next_up ( ) {
324
324
let tiny = f64:: from_bits ( 1 ) ;
@@ -350,7 +350,7 @@ fn test_next_up() {
350
350
351
351
// Ignore test on x87 floating point, these platforms do not guarantee NaN
352
352
// payloads are preserved and flush denormals to zero, failing the tests.
353
- #[ cfg( not( target_arch = "x86" ) ) ]
353
+ #[ cfg( not( all ( target_arch = "x86" , not ( target_feature = "sse2" ) ) ) ) ]
354
354
#[ test]
355
355
fn test_next_down ( ) {
356
356
let tiny = f64:: from_bits ( 1 ) ;
You can’t perform that action at this time.
0 commit comments