|
| 1 | +//@ run-pass |
| 2 | +#![feature(repr_simd, core_intrinsics)] |
| 3 | + |
| 4 | +#[path = "../../../auxiliary/minisimd.rs"] |
| 5 | +mod minisimd; |
| 6 | +use minisimd::*; |
| 7 | + |
| 8 | +use std::intrinsics::simd::simd_splat; |
| 9 | + |
| 10 | +fn main() { |
| 11 | + unsafe { |
| 12 | + let x: Simd<u32, 1> = simd_splat(123u32); |
| 13 | + let y: Simd<u32, 1> = const { simd_splat(123u32) }; |
| 14 | + assert_eq!(x.into_array(), [123; 1]); |
| 15 | + assert_eq!(x.into_array(), y.into_array()); |
| 16 | + |
| 17 | + let x: u16x2 = simd_splat(42u16); |
| 18 | + let y: u16x2 = const { simd_splat(42u16) }; |
| 19 | + assert_eq!(x.into_array(), [42; 2]); |
| 20 | + assert_eq!(x.into_array(), y.into_array()); |
| 21 | + |
| 22 | + let x: u128x4 = simd_splat(42u128); |
| 23 | + let y: u128x4 = const { simd_splat(42u128) }; |
| 24 | + assert_eq!(x.into_array(), [42; 4]); |
| 25 | + assert_eq!(x.into_array(), y.into_array()); |
| 26 | + |
| 27 | + let x: i32x4 = simd_splat(-7i32); |
| 28 | + let y: i32x4 = const { simd_splat(-7i32) }; |
| 29 | + assert_eq!(x.into_array(), [-7; 4]); |
| 30 | + assert_eq!(x.into_array(), y.into_array()); |
| 31 | + |
| 32 | + let x: f32x4 = simd_splat(42.0f32); |
| 33 | + let y: f32x4 = const { simd_splat(42.0f32) }; |
| 34 | + assert_eq!(x.into_array(), [42.0; 4]); |
| 35 | + assert_eq!(x.into_array(), y.into_array()); |
| 36 | + |
| 37 | + let x: f64x2 = simd_splat(42.0f64); |
| 38 | + let y: f64x2 = const { simd_splat(42.0f64) }; |
| 39 | + assert_eq!(x.into_array(), [42.0; 2]); |
| 40 | + assert_eq!(x.into_array(), y.into_array()); |
| 41 | + |
| 42 | + static ZERO: u8 = 0u8; |
| 43 | + let x: Simd<*const u8, 2> = simd_splat(&raw const ZERO); |
| 44 | + assert_eq!(x.into_array(), [&raw const ZERO; 2]); |
| 45 | + |
| 46 | + // FIXME: this hits "could not evaluate shuffle_indices at compile time", |
| 47 | + // emitted in `immediate_const_vector`. const-eval should be able to handle |
| 48 | + // this though I think? `const { [&raw const ZERO; 2] }` appears to work. |
| 49 | + // let y: Simd<*const u8, 2> = const { simd_splat(&raw const ZERO) }; |
| 50 | + // assert_eq!(x.into_array(), y.into_array()); |
| 51 | + } |
| 52 | +} |
0 commit comments