]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/float_math.rs
Enable emission of alignment attrs for pointer params
[rust.git] / src / test / codegen / float_math.rs
1 // Copyright 2016 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 #![crate_type = "lib"]
14 #![feature(core_intrinsics)]
15
16 use std::intrinsics::{fadd_fast, fsub_fast, fmul_fast, fdiv_fast, frem_fast};
17
18 // CHECK-LABEL: @add
19 #[no_mangle]
20 pub fn add(x: f32, y: f32) -> f32 {
21 // CHECK: fadd float
22 // CHECK-NOT: fast
23     x + y
24 }
25
26 // CHECK-LABEL: @addition
27 #[no_mangle]
28 pub fn addition(x: f32, y: f32) -> f32 {
29 // CHECK: fadd fast float
30     unsafe {
31         fadd_fast(x, y)
32     }
33 }
34
35 // CHECK-LABEL: @subtraction
36 #[no_mangle]
37 pub fn subtraction(x: f32, y: f32) -> f32 {
38 // CHECK: fsub fast float
39     unsafe {
40         fsub_fast(x, y)
41     }
42 }
43
44 // CHECK-LABEL: @multiplication
45 #[no_mangle]
46 pub fn multiplication(x: f32, y: f32) -> f32 {
47 // CHECK: fmul fast float
48     unsafe {
49         fmul_fast(x, y)
50     }
51 }
52
53 // CHECK-LABEL: @division
54 #[no_mangle]
55 pub fn division(x: f32, y: f32) -> f32 {
56 // CHECK: fdiv fast float
57     unsafe {
58         fdiv_fast(x, y)
59     }
60 }