diff options
| author | bors <bors@rust-lang.org> | 2018-03-25 00:02:48 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-03-25 00:02:48 +0000 |
| commit | 77e2bcb613c58ed2aeb86fdb07f470440f94f205 (patch) | |
| tree | 438d72590cd19b2f68363d305303edd48b90a90e /src/test/codegen | |
| parent | f5631d9ac7745dd6eaea2bc6c236d5f8e54e9a18 (diff) | |
| parent | 4eff4d9500968e8a6275185eac153e102996edb5 (diff) | |
| download | rust-77e2bcb613c58ed2aeb86fdb07f470440f94f205.tar.gz rust-77e2bcb613c58ed2aeb86fdb07f470440f94f205.zip | |
Auto merge of #49141 - gnzlbg:simd_select, r=alexcrichton
adds simd_select intrinsic The select SIMD intrinsic is used to select elements from two SIMD vectors using a mask: ```rust let mask = b8x4::new(true, false, false, true); let a = f32x4::new(1., 2., 3., 4.); let b = f32x4::new(5., 6., 7., 8.); assert_eq!(simd_select(mask, a, b), f32x4::new(1., 6., 7., 4.)); ``` The number of lanes between the mask and the vectors must match, but the vector width of the mask does not need to match that of the vectors. The mask is required to be a vector of signed integers. Note: this intrinsic will be exposed via `std::simd`'s vector masks - users are not expected to use it directly.
Diffstat (limited to 'src/test/codegen')
| -rw-r--r-- | src/test/codegen/simd-intrinsic-generic-select.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/test/codegen/simd-intrinsic-generic-select.rs b/src/test/codegen/simd-intrinsic-generic-select.rs new file mode 100644 index 00000000000..8a64d7437d8 --- /dev/null +++ b/src/test/codegen/simd-intrinsic-generic-select.rs @@ -0,0 +1,35 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -C no-prepopulate-passes + +#![crate_type = "lib"] + +#![feature(repr_simd, platform_intrinsics)] +#[allow(non_camel_case_types)] + +#[repr(simd)] +#[derive(Copy, Clone, PartialEq, Debug)] +pub struct f32x4(pub f32, pub f32, pub f32, pub f32); + +#[repr(simd)] +#[derive(Copy, Clone, PartialEq, Debug)] +pub struct b8x4(pub i8, pub i8, pub i8, pub i8); + +extern "platform-intrinsic" { + fn simd_select<T, U>(x: T, a: U, b: U) -> U; +} + +// CHECK-LABEL: @select +#[no_mangle] +pub unsafe fn select(m: b8x4, a: f32x4, b: f32x4) -> f32x4 { + // CHECK: select <4 x i1> + simd_select(m, a, b) +} |
