]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/simd-intrinsic-generic-scatter.rs
Auto merge of #54720 - davidtwco:issue-51191, r=nikomatsakis
[rust.git] / src / test / codegen / simd-intrinsic-generic-scatter.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 // min-llvm-version 6.0
14
15 // compile-flags: -C no-prepopulate-passes
16
17 #![crate_type = "lib"]
18
19 #![feature(repr_simd, platform_intrinsics)]
20 #![allow(non_camel_case_types)]
21
22 #[repr(simd)]
23 #[derive(Copy, Clone, PartialEq, Debug)]
24 pub struct Vec2<T>(pub T, pub T);
25
26 #[repr(simd)]
27 #[derive(Copy, Clone, PartialEq, Debug)]
28 pub struct Vec4<T>(pub T, pub T, pub T, pub T);
29
30 extern "platform-intrinsic" {
31     fn simd_scatter<T, P, M>(value: T, pointers: P, mask: M);
32 }
33
34 // CHECK-LABEL: @scatter_f32x2
35 #[no_mangle]
36 pub unsafe fn scatter_f32x2(pointers: Vec2<*mut f32>, mask: Vec2<i32>,
37                             values: Vec2<f32>) {
38     // CHECK: call void @llvm.masked.scatter.v2f32.v2p0f32(<2 x float> {{.*}}, <2 x float*> {{.*}}, i32 {{.*}}, <2 x i1> {{.*}})
39     simd_scatter(values, pointers, mask)
40 }
41
42
43 // CHECK-LABEL: @scatter_pf32x2
44 #[no_mangle]
45 pub unsafe fn scatter_pf32x2(pointers: Vec2<*mut *const f32>, mask: Vec2<i32>,
46                              values: Vec2<*const f32>) {
47     // CHECK: call void @llvm.masked.scatter.v2p0f32.v2p0p0f32(<2 x float*> {{.*}}, <2 x float**> {{.*}}, i32 {{.*}}, <2 x i1> {{.*}})
48     simd_scatter(values, pointers, mask)
49 }