-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow simd_shuffle to accept vectors of any length
- Loading branch information
1 parent
b69fe57
commit 1b3fe75
Showing
12 changed files
with
125 additions
and
33 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
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
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
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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
src/test/ui/simd-intrinsic/simd-intrinsic-generic-shuffle.rs
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,33 @@ | ||
// build-fail | ||
|
||
// Test that the simd_shuffle intrinsic produces ok-ish error | ||
// messages when misused. | ||
|
||
#![feature(repr_simd, platform_intrinsics)] | ||
|
||
#[repr(simd)] | ||
#[derive(Copy, Clone)] | ||
pub struct Simd<T, const N: usize>([T; N]); | ||
|
||
extern "platform-intrinsic" { | ||
fn simd_shuffle<T, I, U>(a: T, b: T, i: I) -> U; | ||
} | ||
|
||
fn main() { | ||
const I: [u32; 2] = [0; 2]; | ||
const I2: [f32; 2] = [0.; 2]; | ||
let v = Simd::<u32, 4>([0; 4]); | ||
|
||
unsafe { | ||
let _: Simd<u32, 2> = simd_shuffle(v, v, I); | ||
|
||
let _: Simd<u32, 4> = simd_shuffle(v, v, I); | ||
//~^ ERROR invalid monomorphization of `simd_shuffle` intrinsic | ||
|
||
let _: Simd<f32, 2> = simd_shuffle(v, v, I); | ||
//~^ ERROR invalid monomorphization of `simd_shuffle` intrinsic | ||
|
||
let _: Simd<u32, 2> = simd_shuffle(v, v, I2); | ||
//~^ ERROR invalid monomorphization of `simd_shuffle` intrinsic | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/test/ui/simd-intrinsic/simd-intrinsic-generic-shuffle.stderr
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,21 @@ | ||
error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return type of length 2, found `Simd<u32, 4_usize>` with length 4 | ||
--> $DIR/simd-intrinsic-generic-shuffle.rs:24:31 | ||
| | ||
LL | let _: Simd<u32, 4> = simd_shuffle(v, v, I); | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return element type `u32` (element of input `Simd<u32, 4_usize>`), found `Simd<f32, 2_usize>` with element type `f32` | ||
--> $DIR/simd-intrinsic-generic-shuffle.rs:27:31 | ||
| | ||
LL | let _: Simd<f32, 2> = simd_shuffle(v, v, I); | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: simd_shuffle index must be an array of `u32`, got `[f32; 2]` | ||
--> $DIR/simd-intrinsic-generic-shuffle.rs:30:31 | ||
| | ||
LL | let _: Simd<u32, 2> = simd_shuffle(v, v, I2); | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0511`. |
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
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
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,24 @@ | ||
//run-pass | ||
#![feature(repr_simd, platform_intrinsics)] | ||
|
||
extern "platform-intrinsic" { | ||
fn simd_shuffle<T, I, U>(a: T, b: T, i: I) -> U; | ||
} | ||
|
||
#[derive(Copy, Clone)] | ||
#[repr(simd)] | ||
struct Simd<T, const N: usize>([T; N]); | ||
|
||
fn main() { | ||
const I1: [u32; 4] = [0, 2, 4, 6]; | ||
const I2: [u32; 2] = [1, 5]; | ||
let a = Simd::<u8, 4>([0, 1, 2, 3]); | ||
let b = Simd::<u8, 4>([4, 5, 6, 7]); | ||
unsafe { | ||
let x: Simd<u8, 4> = simd_shuffle(a, b, I1); | ||
assert_eq!(x.0, [0, 2, 4, 6]); | ||
|
||
let y: Simd<u8, 2> = simd_shuffle(a, b, I2); | ||
assert_eq!(y.0, [1, 5]); | ||
} | ||
} |