]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/unchecked-float-casts.rs
Auto merge of #69030 - Dylan-DPC:rollup-t9uk7vc, r=Dylan-DPC
[rust.git] / src / test / codegen / unchecked-float-casts.rs
1 // compile-flags: -C no-prepopulate-passes
2
3 // This file tests that we don't generate any code for saturation if
4 // -Z saturating-float-casts is not enabled.
5
6 #![crate_type = "lib"]
7
8 // CHECK-LABEL: @f32_to_u32
9 #[no_mangle]
10 pub fn f32_to_u32(x: f32) -> u32 {
11     // CHECK: fptoui
12     // CHECK-NOT: fcmp
13     // CHECK-NOT: icmp
14     // CHECK-NOT: select
15     x as u32
16 }
17
18 // CHECK-LABEL: @f32_to_i32
19 #[no_mangle]
20 pub fn f32_to_i32(x: f32) -> i32 {
21     // CHECK: fptosi
22     // CHECK-NOT: fcmp
23     // CHECK-NOT: icmp
24     // CHECK-NOT: select
25     x as i32
26 }
27
28 #[no_mangle]
29 pub fn f64_to_u16(x: f64) -> u16 {
30     // CHECK: fptoui
31     // CHECK-NOT: fcmp
32     // CHECK-NOT: icmp
33     // CHECK-NOT: select
34     x as u16
35 }