Skip to content

Commit 29b9205

Browse files
committed
Fix ABI issue with f128 to small integer cast
1 parent 1ae2edd commit 29b9205

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

example/std_example.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1-
#![feature(core_intrinsics, coroutines, coroutine_trait, repr_simd, tuple_trait, unboxed_closures)]
21
#![allow(internal_features)]
2+
#![feature(cfg_target_has_reliable_f16_f128)]
3+
#![feature(core_intrinsics)]
4+
#![feature(coroutine_trait)]
5+
#![feature(coroutines)]
6+
#![feature(f128)]
7+
#![feature(repr_simd)]
8+
#![feature(tuple_trait)]
9+
#![feature(unboxed_closures)]
310

411
#[cfg(target_arch = "x86_64")]
512
use std::arch::x86_64::*;
@@ -91,6 +98,8 @@ fn main() {
9198
assert_eq!(houndred_f32 as i128, 100);
9299
assert_eq!(houndred_f64 as i128, 100);
93100
assert_eq!(1u128.rotate_left(2), 4);
101+
#[cfg(target_has_reliable_f128)]
102+
assert_eq!(std::hint::black_box(300.0f128) as u8, 255);
94103

95104
assert_eq!(black_box(f32::NAN) as i128, 0);
96105
assert_eq!(black_box(f32::NAN) as u128, 0);

src/codegen_f16_f128.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ pub(crate) fn codegen_cast(
259259
},
260260
);
261261
let ret =
262-
fx.lib_call(&name, vec![AbiParam::new(from_ty)], vec![AbiParam::new(to_ty)], &[from])
262+
fx.lib_call(&name, vec![AbiParam::new(from_ty)], vec![AbiParam::new(ret_ty)], &[from])
263263
[0];
264264
let val = if ret_ty == to_ty {
265265
ret

0 commit comments

Comments
 (0)