]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/simd-binop.rs
auto merge of #11832 : jfager/rust/r5900, r=alexcrichton
[rust.git] / src / test / run-pass / simd-binop.rs
1 // Copyright 2013 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 #[allow(experimental)];
12
13 use std::unstable::simd::{i32x4, f32x4, u32x4};
14
15 fn test_int(e: i32) -> i32 {
16     let v = i32x4(e, 0i32, 0i32, 0i32);
17     let i32x4(e2, _, _, _) = v * v + v - v;
18     e2
19 }
20
21 fn test_float(e: f32) -> f32 {
22     let v = f32x4(e, 0f32, 0f32, 0f32);
23     let f32x4(e2, _, _, _) = v * v + v - v;
24     e2
25 }
26
27 pub fn test_shift(e: u32) -> u32 {
28     let v = u32x4(e, 0u32, 0u32, 0u32);
29     let one = u32x4(1u32, 0u32, 0u32, 0u32);
30     let u32x4(e2, _, _, _) = v << one >> one;
31     e2
32 }
33
34 pub fn main() {
35     assert_eq!(test_int(3i32), 9i32);
36     assert_eq!(test_float(3f32), 9f32);
37     assert_eq!(test_shift(3u32), 3u32);
38 }