make simd_insert and simd_extract const fns

This commit is contained in:
Folkert de Vries 2025-02-24 18:53:49 +01:00
parent a837e9966b
commit 4e961dc015
No known key found for this signature in database
GPG Key ID: 1F17F6FFD112B97C
3 changed files with 13 additions and 28 deletions

View File

@ -11,7 +11,7 @@
/// `idx` must be in-bounds of the vector.
#[rustc_intrinsic]
#[rustc_nounwind]
pub unsafe fn simd_insert<T, U>(_x: T, _idx: u32, _val: U) -> T;
pub const unsafe fn simd_insert<T, U>(_x: T, _idx: u32, _val: U) -> T;
/// Extracts an element from a vector.
///
@ -22,7 +22,7 @@ pub unsafe fn simd_insert<T, U>(_x: T, _idx: u32, _val: U) -> T;
/// `idx` must be in-bounds of the vector.
#[rustc_intrinsic]
#[rustc_nounwind]
pub unsafe fn simd_extract<T, U>(_x: T, _idx: u32) -> U;
pub const unsafe fn simd_extract<T, U>(_x: T, _idx: u32) -> U;
/// Adds two simd vectors elementwise.
///

View File

@ -5,22 +5,7 @@
#![stable(feature = "foo", since = "1.3.37")]
#![allow(non_camel_case_types)]
// FIXME these intrinsics are not marked as const fn
// use std::intrinsics::simd::{simd_extract, simd_insert};
#[stable(feature = "foo", since = "1.3.37")]
#[rustc_const_stable(feature = "foo", since = "1.3.37")]
#[rustc_intrinsic]
const unsafe fn simd_insert<T, U>(_x: T, _idx: u32, _val: U) -> T {
unimplemented!()
}
#[stable(feature = "foo", since = "1.3.37")]
#[rustc_const_stable(feature = "foo", since = "1.3.37")]
#[rustc_intrinsic]
const unsafe fn simd_extract<T, U>(_x: T, _idx: u32) -> U {
unimplemented!()
}
use std::intrinsics::simd::{simd_extract, simd_insert};
// repr(simd) now only supports array types
#[repr(simd)]

View File

@ -1,59 +1,59 @@
error[E0511]: invalid monomorphization of `simd_reduce_add_ordered` intrinsic: expected return type `f32` (element of input `f32x4`), found `i32`
--> $DIR/generic-reduction.rs:28:9
--> $DIR/generic-reduction.rs:25:9
|
LL | simd_reduce_add_ordered(z, 0);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_reduce_mul_ordered` intrinsic: expected return type `f32` (element of input `f32x4`), found `i32`
--> $DIR/generic-reduction.rs:30:9
--> $DIR/generic-reduction.rs:27:9
|
LL | simd_reduce_mul_ordered(z, 1);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_reduce_and` intrinsic: expected return type `u32` (element of input `u32x4`), found `f32`
--> $DIR/generic-reduction.rs:33:22
--> $DIR/generic-reduction.rs:30:22
|
LL | let _: f32 = simd_reduce_and(x);
| ^^^^^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_reduce_or` intrinsic: expected return type `u32` (element of input `u32x4`), found `f32`
--> $DIR/generic-reduction.rs:35:22
--> $DIR/generic-reduction.rs:32:22
|
LL | let _: f32 = simd_reduce_or(x);
| ^^^^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_reduce_xor` intrinsic: expected return type `u32` (element of input `u32x4`), found `f32`
--> $DIR/generic-reduction.rs:37:22
--> $DIR/generic-reduction.rs:34:22
|
LL | let _: f32 = simd_reduce_xor(x);
| ^^^^^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_reduce_and` intrinsic: unsupported simd_reduce_and from `f32x4` with element `f32` to `f32`
--> $DIR/generic-reduction.rs:40:22
--> $DIR/generic-reduction.rs:37:22
|
LL | let _: f32 = simd_reduce_and(z);
| ^^^^^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_reduce_or` intrinsic: unsupported simd_reduce_or from `f32x4` with element `f32` to `f32`
--> $DIR/generic-reduction.rs:42:22
--> $DIR/generic-reduction.rs:39:22
|
LL | let _: f32 = simd_reduce_or(z);
| ^^^^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_reduce_xor` intrinsic: unsupported simd_reduce_xor from `f32x4` with element `f32` to `f32`
--> $DIR/generic-reduction.rs:44:22
--> $DIR/generic-reduction.rs:41:22
|
LL | let _: f32 = simd_reduce_xor(z);
| ^^^^^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_reduce_all` intrinsic: unsupported simd_reduce_all from `f32x4` with element `f32` to `bool`
--> $DIR/generic-reduction.rs:47:23
--> $DIR/generic-reduction.rs:44:23
|
LL | let _: bool = simd_reduce_all(z);
| ^^^^^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_reduce_any` intrinsic: unsupported simd_reduce_any from `f32x4` with element `f32` to `bool`
--> $DIR/generic-reduction.rs:49:23
--> $DIR/generic-reduction.rs:46:23
|
LL | let _: bool = simd_reduce_any(z);
| ^^^^^^^^^^^^^^^^^^