2020-04-17 20:42:22 -05:00
|
|
|
// This file tests that we don't generate any code for saturation when using the
|
|
|
|
// unchecked intrinsics.
|
2017-10-08 19:14:00 -05:00
|
|
|
|
2020-04-17 20:42:22 -05:00
|
|
|
// compile-flags: -C opt-level=3
|
2017-10-08 19:14:00 -05: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-17 20:42:22 -05:00
|
|
|
unsafe { x.to_int_unchecked() }
|
2017-10-08 19:14:00 -05: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-17 20:42:22 -05:00
|
|
|
unsafe { x.to_int_unchecked() }
|
2017-10-08 19:14:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[no_mangle]
|
2017-11-09 17:24:05 -06:00
|
|
|
pub fn f64_to_u16(x: f64) -> u16 {
|
|
|
|
// CHECK: fptoui
|
2017-10-08 19:14:00 -05:00
|
|
|
// CHECK-NOT: fcmp
|
|
|
|
// CHECK-NOT: icmp
|
|
|
|
// CHECK-NOT: select
|
2020-04-17 20:42:22 -05:00
|
|
|
unsafe { x.to_int_unchecked() }
|
2017-10-08 19:14:00 -05:00
|
|
|
}
|