1 // This test check that even if we mixup target feature of function with homogenous floats,
2 // the abi is sound and still produce the right answer.
4 // This is basically the same test as src/test/ui/simd/target-feature-mixup.rs but for floats and
5 // without #[repr(simd)]
9 // ignore-sgx no processes
11 #![feature(avx512_target_feature)]
13 #![allow(overflowing_literals)]
14 #![allow(unused_variables)]
16 use std::process::{Command, ExitStatus};
20 if let Some(level) = env::args().nth(1) {
21 return test::main(&level)
24 match std::env::var("TARGET") {
26 // Skip this tests on i586-unknown-linux-gnu where sse2 is disabled
27 if s.contains("i586") {
34 let me = env::current_exe().unwrap();
35 for level in ["sse", "avx", "avx512"].iter() {
36 let status = Command::new(&me).arg(level).status().unwrap();
38 println!("success with {}", level);
42 // We don't actually know if our computer has the requisite target features
43 // for the test below. Testing for that will get added to libstd later so
44 // for now just assume sigill means this is a machine that can't run this test.
45 if is_sigill(status) {
46 println!("sigill with {}, assuming spurious", level);
49 panic!("invalid status at {}: {}", level, status);
54 fn is_sigill(status: ExitStatus) -> bool {
55 use std::os::unix::prelude::*;
56 status.signal() == Some(4)
60 fn is_sigill(status: ExitStatus) -> bool {
61 status.code() == Some(0xc000001d)
64 #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
65 #[allow(nonstandard_style)]
67 #[derive(PartialEq, Debug, Clone, Copy)]
68 struct f32x2(f32, f32);
70 #[derive(PartialEq, Debug, Clone, Copy)]
71 struct f32x4(f32, f32, f32, f32);
73 #[derive(PartialEq, Debug, Clone, Copy)]
74 struct f32x8(f32, f32, f32, f32, f32, f32, f32, f32);
76 pub fn main(level: &str) {
94 unsafe fn $main:ident(level: &str) {
99 unsafe fn $main(level: &str) {
100 let m128 = f32x2(1., 2.);
101 let m256 = f32x4(3., 4., 5., 6.);
102 let m512 = f32x8(7., 8., 9., 10., 11., 12., 13., 14.);
103 assert_eq!(id_sse_128(m128), m128);
104 assert_eq!(id_sse_256(m256), m256);
105 assert_eq!(id_sse_512(m512), m512);
110 assert_eq!(id_avx_128(m128), m128);
111 assert_eq!(id_avx_256(m256), m256);
112 assert_eq!(id_avx_512(m512), m512);
117 assert_eq!(id_avx512_128(m128), m128);
118 assert_eq!(id_avx512_256(m256), m256);
119 assert_eq!(id_avx512_512(m512), m512);
125 unsafe fn main_normal(level: &str) { ... }
126 #[target_feature(enable = "sse2")]
127 unsafe fn main_sse(level: &str) { ... }
128 #[target_feature(enable = "avx")]
129 unsafe fn main_avx(level: &str) { ... }
130 #[target_feature(enable = "avx512bw")]
131 unsafe fn main_avx512(level: &str) { ... }
134 #[target_feature(enable = "sse2")]
135 unsafe fn id_sse_128(a: f32x2) -> f32x2 {
136 assert_eq!(a, f32x2(1., 2.));
140 #[target_feature(enable = "sse2")]
141 unsafe fn id_sse_256(a: f32x4) -> f32x4 {
142 assert_eq!(a, f32x4(3., 4., 5., 6.));
146 #[target_feature(enable = "sse2")]
147 unsafe fn id_sse_512(a: f32x8) -> f32x8 {
148 assert_eq!(a, f32x8(7., 8., 9., 10., 11., 12., 13., 14.));
152 #[target_feature(enable = "avx")]
153 unsafe fn id_avx_128(a: f32x2) -> f32x2 {
154 assert_eq!(a, f32x2(1., 2.));
158 #[target_feature(enable = "avx")]
159 unsafe fn id_avx_256(a: f32x4) -> f32x4 {
160 assert_eq!(a, f32x4(3., 4., 5., 6.));
164 #[target_feature(enable = "avx")]
165 unsafe fn id_avx_512(a: f32x8) -> f32x8 {
166 assert_eq!(a, f32x8(7., 8., 9., 10., 11., 12., 13., 14.));
170 #[target_feature(enable = "avx512bw")]
171 unsafe fn id_avx512_128(a: f32x2) -> f32x2 {
172 assert_eq!(a, f32x2(1., 2.));
176 #[target_feature(enable = "avx512bw")]
177 unsafe fn id_avx512_256(a: f32x4) -> f32x4 {
178 assert_eq!(a, f32x4(3., 4., 5., 6.));
182 #[target_feature(enable = "avx512bw")]
183 unsafe fn id_avx512_512(a: f32x8) -> f32x8 {
184 assert_eq!(a, f32x8(7., 8., 9., 10., 11., 12., 13., 14.));
189 #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
191 pub fn main(level: &str) {}