]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/simd-intrinsic-generic-gather.rs
Enable emission of alignment attrs for pointer params
[rust.git] / src / test / codegen / simd-intrinsic-generic-gather.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 // ignore-emscripten
12 // ignore-tidy-linelength
13
14 // compile-flags: -C no-prepopulate-passes
15
16 #![crate_type = "lib"]
17
18 #![feature(repr_simd, platform_intrinsics)]
19 #![allow(non_camel_case_types)]
20
21 #[repr(simd)]
22 #[derive(Copy, Clone, PartialEq, Debug)]
23 pub struct Vec2<T>(pub T, pub T);
24
25 #[repr(simd)]
26 #[derive(Copy, Clone, PartialEq, Debug)]
27 pub struct Vec4<T>(pub T, pub T, pub T, pub T);
28
29 extern "platform-intrinsic" {
30     fn simd_gather<T, P, M>(value: T, pointers: P, mask: M) -> T;
31 }
32
33 // CHECK-LABEL: @gather_f32x2
34 #[no_mangle]
35 pub unsafe fn gather_f32x2(pointers: Vec2<*const f32>, mask: Vec2<i32>,
36                            values: Vec2<f32>) -> Vec2<f32> {
37     // CHECK: call <2 x float> @llvm.masked.gather.v2f32.v2p0f32(<2 x float*> {{.*}}, i32 {{.*}}, <2 x i1> {{.*}}, <2 x float> {{.*}})
38     simd_gather(values, pointers, mask)
39 }
40
41 // CHECK-LABEL: @gather_pf32x2
42 #[no_mangle]
43 pub unsafe fn gather_pf32x2(pointers: Vec2<*const *const f32>, mask: Vec2<i32>,
44                            values: Vec2<*const f32>) -> Vec2<*const f32> {
45     // CHECK: call <2 x float*> @llvm.masked.gather.v2p0f32.v2p0p0f32(<2 x float**> {{.*}}, i32 {{.*}}, <2 x i1> {{.*}}, <2 x float*> {{.*}})
46     simd_gather(values, pointers, mask)
47 }