]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/unchecked-float-casts.rs
Enable emission of alignment attrs for pointer params
[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
18 // CHECK-LABEL: @f32_to_u32
19 #[no_mangle]
20 pub fn f32_to_u32(x: f32) -> u32 {
21     // CHECK: fptoui
22     // CHECK-NOT: fcmp
23     // CHECK-NOT: icmp
24     // CHECK-NOT: select
25     x as u32
26 }
27
28 // CHECK-LABEL: @f32_to_i32
29 #[no_mangle]
30 pub fn f32_to_i32(x: f32) -> i32 {
31     // CHECK: fptosi
32     // CHECK-NOT: fcmp
33     // CHECK-NOT: icmp
34     // CHECK-NOT: select
35     x as i32
36 }
37
38 #[no_mangle]
39 pub fn f64_to_u16(x: f64) -> u16 {
40     // CHECK: fptoui
41     // CHECK-NOT: fcmp
42     // CHECK-NOT: icmp
43     // CHECK-NOT: select
44     x as u16
45 }