2020-04-18 01:42:22 +00:00
|
|
|
// This file tests that we don't generate any code for saturation when using the
|
|
|
|
// unchecked intrinsics.
|
2017-10-09 00:14:00 +00:00
|
|
|
|
2020-04-18 01:42:22 +00:00
|
|
|
//@ compile-flags: -C opt-level=3
|
2020-07-22 21:51:12 +00:00
|
|
|
//@ ignore-wasm32 the wasm target is tested in `wasm_casts_*`
|
2017-10-09 00:14:00 +00:00
|
|
|
|
|
|
|
#![crate_type = "lib"]
|
|
|
|
|
|
|
|
// CHECK-LABEL: @f32_to_u32
|
|
|
|
#[no_mangle]
|
|
|
|
pub fn f32_to_u32(x: f32) -> u32 {
|
|
|
|
// CHECK: fptoui
|
|
|
|
// CHECK-NOT: fcmp
|
|
|
|
// CHECK-NOT: icmp
|
|
|
|
// CHECK-NOT: select
|
2020-04-18 01:42:22 +00:00
|
|
|
unsafe { x.to_int_unchecked() }
|
2017-10-09 00:14:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL: @f32_to_i32
|
|
|
|
#[no_mangle]
|
|
|
|
pub fn f32_to_i32(x: f32) -> i32 {
|
|
|
|
// CHECK: fptosi
|
|
|
|
// CHECK-NOT: fcmp
|
|
|
|
// CHECK-NOT: icmp
|
|
|
|
// CHECK-NOT: select
|
2020-04-18 01:42:22 +00:00
|
|
|
unsafe { x.to_int_unchecked() }
|
2017-10-09 00:14:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[no_mangle]
|
2017-11-09 23:24:05 +00:00
|
|
|
pub fn f64_to_u16(x: f64) -> u16 {
|
|
|
|
// CHECK: fptoui
|
2017-10-09 00:14:00 +00:00
|
|
|
// CHECK-NOT: fcmp
|
|
|
|
// CHECK-NOT: icmp
|
|
|
|
// CHECK-NOT: select
|
2020-04-18 01:42:22 +00:00
|
|
|
unsafe { x.to_int_unchecked() }
|
2017-10-09 00:14:00 +00:00
|
|
|
}
|