Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add const-eval support for SIMD types, insert, and extract
- Loading branch information
Showing
6 changed files
with
143 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// run-pass | ||
// compile-flags: -Zunleash-the-miri-inside-of-you | ||
#![feature(repr_simd)] | ||
#![feature(platform_intrinsics)] | ||
#![allow(non_camel_case_types)] | ||
|
||
#[repr(simd)] struct i8x1(i8); | ||
|
||
extern "platform-intrinsic" { | ||
fn simd_insert<T, U>(x: T, idx: u32, val: U) -> T; | ||
fn simd_extract<T, U>(x: T, idx: u32) -> U; | ||
} | ||
|
||
const fn foo(x: i8x1) -> i8 { | ||
unsafe { simd_insert(x, 0_u32, 42_i8) }.0 | ||
} | ||
|
||
fn main() { | ||
const V: i8x1 = i8x1(13); | ||
const X: i8 = foo(V); | ||
const Y: i8 = unsafe { simd_extract(V, 0) }; | ||
assert_eq!(X, 42); | ||
assert_eq!(Y, 13); | ||
} |
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,48 @@ | ||
warning: skipping const checks | ||
--> $DIR/const_eval-simd.rs:22:5 | ||
| | ||
LL | assert_eq!(X, 42); | ||
| ^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) | ||
|
||
warning: skipping const checks | ||
--> $DIR/const_eval-simd.rs:22:5 | ||
| | ||
LL | assert_eq!(X, 42); | ||
| ^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) | ||
|
||
warning: skipping const checks | ||
--> $DIR/const_eval-simd.rs:22:5 | ||
| | ||
LL | assert_eq!(X, 42); | ||
| ^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) | ||
|
||
warning: skipping const checks | ||
--> $DIR/const_eval-simd.rs:23:5 | ||
| | ||
LL | assert_eq!(Y, 13); | ||
| ^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) | ||
|
||
warning: skipping const checks | ||
--> $DIR/const_eval-simd.rs:23:5 | ||
| | ||
LL | assert_eq!(Y, 13); | ||
| ^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) | ||
|
||
warning: skipping const checks | ||
--> $DIR/const_eval-simd.rs:23:5 | ||
| | ||
LL | assert_eq!(Y, 13); | ||
| ^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) | ||
|