forked from rust-lang/rust
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test and reject out-of-bounds shuffle vectors
- Loading branch information
1 parent
07ece44
commit ac96f5b
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// build-fail | ||
#![allow(non_camel_case_types)] | ||
#![feature(repr_simd, platform_intrinsics)] | ||
|
||
// Test for #73542 to verify out-of-bounds shuffle vectors do not compile. | ||
|
||
#[repr(simd)] | ||
#[derive(Copy, Clone)] | ||
struct f32x4(f32, f32, f32, f32); | ||
|
||
extern "platform-intrinsic" { | ||
pub fn simd_shuffle4<T, U>(x: T, y: T, idx: [u32; 4]) -> U; | ||
} | ||
|
||
|
||
fn main() { | ||
unsafe { | ||
let vec1 = f32x4(1.0, 2.0, 3.0, 4.0); | ||
let vec2 = f32x4(10_000.0, 20_000.0, 30_000.0, 40_000.0); | ||
let shuffled: f32x4 = simd_shuffle4(vec1, vec2, [0, 4, 7, 9]); | ||
//~^ ERROR: invalid monomorphization of `simd_shuffle4` intrinsic: shuffle index #3 is out | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
error[E0511]: invalid monomorphization of `simd_shuffle4` intrinsic: shuffle index #3 is out of bounds (limit 8) | ||
--> $DIR/shuffle-not-out-of-bounds.rs:20:31 | ||
| | ||
LL | let shuffled: f32x4 = simd_shuffle4(vec1, vec2, [0, 4, 7, 9]); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0511`. |