]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/unchecked-float-casts.rs
Rollup merge of #45506 - ia0:mpsc_recv_error_from, r=alexcrichton
[rust.git] / src / test / codegen / unchecked-float-casts.rs
1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // compile-flags: -C no-prepopulate-passes
12
13 // This file tests that we don't generate any code for saturation if
14 // -Z saturating-float-casts is not enabled.
15
16 #![crate_type = "lib"]
17 #![feature(i128_type)]
18
19 // CHECK-LABEL: @f32_to_u32
20 #[no_mangle]
21 pub fn f32_to_u32(x: f32) -> u32 {
22     // CHECK: fptoui
23     // CHECK-NOT: fcmp
24     // CHECK-NOT: icmp
25     // CHECK-NOT: select
26     x as u32
27 }
28
29 // CHECK-LABEL: @f32_to_i32
30 #[no_mangle]
31 pub fn f32_to_i32(x: f32) -> i32 {
32     // CHECK: fptosi
33     // CHECK-NOT: fcmp
34     // CHECK-NOT: icmp
35     // CHECK-NOT: select
36     x as i32
37 }
38
39 #[no_mangle]
40 pub fn f64_to_u16(x: f64) -> u16 {
41     // CHECK: fptoui
42     // CHECK-NOT: fcmp
43     // CHECK-NOT: icmp
44     // CHECK-NOT: select
45     x as u16
46 }