]> git.lizzy.rs Git - rust.git/blob - tests/codegen/unchecked-float-casts.rs
Auto merge of #107778 - weihanglo:update-cargo, r=weihanglo
[rust.git] / tests / codegen / unchecked-float-casts.rs
1 // This file tests that we don't generate any code for saturation when using the
2 // unchecked intrinsics.
3
4 // compile-flags: -C opt-level=3
5 // ignore-wasm32 the wasm target is tested in `wasm_casts_*`
6
7 #![crate_type = "lib"]
8
9 // CHECK-LABEL: @f32_to_u32
10 #[no_mangle]
11 pub fn f32_to_u32(x: f32) -> u32 {
12     // CHECK: fptoui
13     // CHECK-NOT: fcmp
14     // CHECK-NOT: icmp
15     // CHECK-NOT: select
16     unsafe { x.to_int_unchecked() }
17 }
18
19 // CHECK-LABEL: @f32_to_i32
20 #[no_mangle]
21 pub fn f32_to_i32(x: f32) -> i32 {
22     // CHECK: fptosi
23     // CHECK-NOT: fcmp
24     // CHECK-NOT: icmp
25     // CHECK-NOT: select
26     unsafe { x.to_int_unchecked() }
27 }
28
29 #[no_mangle]
30 pub fn f64_to_u16(x: f64) -> u16 {
31     // CHECK: fptoui
32     // CHECK-NOT: fcmp
33     // CHECK-NOT: icmp
34     // CHECK-NOT: select
35     unsafe { x.to_int_unchecked() }
36 }