1
Fork 0

rename simd_shuffle_generic → simd_shuffle_const_generic

This commit is contained in:
Ralf Jung 2025-02-24 19:10:55 +01:00
parent 617aad8c2e
commit 0362775fb5
10 changed files with 55 additions and 55 deletions

View file

@ -116,8 +116,8 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
}); });
} }
// simd_shuffle_generic<T, U, const I: &[u32]>(x: T, y: T) -> U // simd_shuffle_const_generic<T, U, const I: &[u32]>(x: T, y: T) -> U
sym::simd_shuffle_generic => { sym::simd_shuffle_const_generic => {
let [x, y] = args else { let [x, y] = args else {
bug!("wrong number of args for intrinsic {intrinsic}"); bug!("wrong number of args for intrinsic {intrinsic}");
}; };

View file

@ -1329,7 +1329,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
)); ));
} }
if name == sym::simd_shuffle_generic { if name == sym::simd_shuffle_const_generic {
let idx = fn_args[2].expect_const().to_value().valtree.unwrap_branch(); let idx = fn_args[2].expect_const().to_value().valtree.unwrap_branch();
let n = idx.len() as u64; let n = idx.len() as u64;

View file

@ -699,7 +699,7 @@ pub fn check_intrinsic_type(
| sym::simd_reduce_min | sym::simd_reduce_min
| sym::simd_reduce_max => (2, 0, vec![param(0)], param(1)), | sym::simd_reduce_max => (2, 0, vec![param(0)], param(1)),
sym::simd_shuffle => (3, 0, vec![param(0), param(0), param(1)], param(2)), sym::simd_shuffle => (3, 0, vec![param(0), param(0), param(1)], param(2)),
sym::simd_shuffle_generic => (2, 1, vec![param(0), param(0)], param(1)), sym::simd_shuffle_const_generic => (2, 1, vec![param(0), param(0)], param(1)),
other => { other => {
tcx.dcx().emit_err(UnrecognizedIntrinsicFunction { span, name: other }); tcx.dcx().emit_err(UnrecognizedIntrinsicFunction { span, name: other });

View file

@ -1916,7 +1916,7 @@ symbols! {
simd_shl, simd_shl,
simd_shr, simd_shr,
simd_shuffle, simd_shuffle,
simd_shuffle_generic, simd_shuffle_const_generic,
simd_sub, simd_sub,
simd_trunc, simd_trunc,
simd_with_exposed_provenance, simd_with_exposed_provenance,

View file

@ -633,7 +633,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
this.write_immediate(*val, &dest)?; this.write_immediate(*val, &dest)?;
} }
} }
"shuffle_generic" => { "shuffle_const_generic" => {
let [left, right] = check_arg_count(args)?; let [left, right] = check_arg_count(args)?;
let (left, left_len) = this.project_to_simd(left)?; let (left, left_len) = this.project_to_simd(left)?;
let (right, right_len) = this.project_to_simd(right)?; let (right, right_len) = this.project_to_simd(right)?;
@ -657,7 +657,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
this.read_immediate(&this.project_index(&right, right_idx)?)? this.read_immediate(&this.project_index(&right, right_idx)?)?
} else { } else {
throw_ub_format!( throw_ub_format!(
"`simd_shuffle_generic` index {src_index} is out-of-bounds for 2 vectors with length {dest_len}" "`simd_shuffle_const_generic` index {src_index} is out-of-bounds for 2 vectors with length {dest_len}"
); );
}; };
this.write_immediate(*val, &dest)?; this.write_immediate(*val, &dest)?;

View file

@ -16,7 +16,7 @@ use std::simd::prelude::*;
#[rustc_intrinsic] #[rustc_intrinsic]
#[rustc_nounwind] #[rustc_nounwind]
pub unsafe fn simd_shuffle_generic<T, U, const IDX: &'static [u32]>(_x: T, _y: T) -> U; pub unsafe fn simd_shuffle_const_generic<T, U, const IDX: &'static [u32]>(_x: T, _y: T) -> U;
fn simd_ops_f32() { fn simd_ops_f32() {
let a = f32x4::splat(10.0); let a = f32x4::splat(10.0);
@ -619,13 +619,13 @@ fn simd_intrinsics() {
simd_select(i8x4::from_array([0, -1, -1, 0]), b, a), simd_select(i8x4::from_array([0, -1, -1, 0]), b, a),
i32x4::from_array([10, 2, 10, 10]) i32x4::from_array([10, 2, 10, 10])
); );
assert_eq!(simd_shuffle_generic::<_, i32x4, { &[3, 1, 0, 2] }>(a, b), a,); assert_eq!(simd_shuffle_const_generic::<_, i32x4, { &[3, 1, 0, 2] }>(a, b), a,);
assert_eq!( assert_eq!(
simd_shuffle::<_, _, i32x4>(a, b, const { u32x4::from_array([3u32, 1, 0, 2]) }), simd_shuffle::<_, _, i32x4>(a, b, const { u32x4::from_array([3u32, 1, 0, 2]) }),
a, a,
); );
assert_eq!( assert_eq!(
simd_shuffle_generic::<_, i32x4, { &[7, 5, 4, 6] }>(a, b), simd_shuffle_const_generic::<_, i32x4, { &[7, 5, 4, 6] }>(a, b),
i32x4::from_array([4, 2, 1, 10]), i32x4::from_array([4, 2, 1, 10]),
); );
assert_eq!( assert_eq!(

View file

@ -41,7 +41,7 @@ unsafe fn simd_extract<T, E>(x: T, idx: u32) -> E;
unsafe fn simd_shuffle<T, I, U>(x: T, y: T, idx: I) -> U; unsafe fn simd_shuffle<T, I, U>(x: T, y: T, idx: I) -> U;
#[rustc_intrinsic] #[rustc_intrinsic]
unsafe fn simd_shuffle_generic<T, U, const IDX: &'static [u32]>(x: T, y: T) -> U; unsafe fn simd_shuffle_const_generic<T, U, const IDX: &'static [u32]>(x: T, y: T) -> U;
#[repr(simd)] #[repr(simd)]
@ -83,27 +83,27 @@ fn main() {
//~^ ERROR expected return type of length 8, found `i32x2` with length 2 //~^ ERROR expected return type of length 8, found `i32x2` with length 2
const I2: &[u32] = &[0; 2]; const I2: &[u32] = &[0; 2];
simd_shuffle_generic::<i32, i32, I2>(0, 0); simd_shuffle_const_generic::<i32, i32, I2>(0, 0);
//~^ ERROR expected SIMD input type, found non-SIMD `i32` //~^ ERROR expected SIMD input type, found non-SIMD `i32`
const I4: &[u32] = &[0; 4]; const I4: &[u32] = &[0; 4];
simd_shuffle_generic::<i32, i32, I4>(0, 0); simd_shuffle_const_generic::<i32, i32, I4>(0, 0);
//~^ ERROR expected SIMD input type, found non-SIMD `i32` //~^ ERROR expected SIMD input type, found non-SIMD `i32`
const I8: &[u32] = &[0; 8]; const I8: &[u32] = &[0; 8];
simd_shuffle_generic::<i32, i32, I8>(0, 0); simd_shuffle_const_generic::<i32, i32, I8>(0, 0);
//~^ ERROR expected SIMD input type, found non-SIMD `i32` //~^ ERROR expected SIMD input type, found non-SIMD `i32`
simd_shuffle_generic::<_, f32x2, I2>(x, x); simd_shuffle_const_generic::<_, f32x2, I2>(x, x);
//~^ ERROR element type `i32` (element of input `i32x4`), found `f32x2` with element type `f32` //~^ ERROR element type `i32` (element of input `i32x4`), found `f32x2` with element type `f32`
simd_shuffle_generic::<_, f32x4, I4>(x, x); simd_shuffle_const_generic::<_, f32x4, I4>(x, x);
//~^ ERROR element type `i32` (element of input `i32x4`), found `f32x4` with element type `f32` //~^ ERROR element type `i32` (element of input `i32x4`), found `f32x4` with element type `f32`
simd_shuffle_generic::<_, f32x8, I8>(x, x); simd_shuffle_const_generic::<_, f32x8, I8>(x, x);
//~^ ERROR element type `i32` (element of input `i32x4`), found `f32x8` with element type `f32` //~^ ERROR element type `i32` (element of input `i32x4`), found `f32x8` with element type `f32`
simd_shuffle_generic::<_, i32x8, I2>(x, x); simd_shuffle_const_generic::<_, i32x8, I2>(x, x);
//~^ ERROR expected return type of length 2, found `i32x8` with length 8 //~^ ERROR expected return type of length 2, found `i32x8` with length 8
simd_shuffle_generic::<_, i32x8, I4>(x, x); simd_shuffle_const_generic::<_, i32x8, I4>(x, x);
//~^ ERROR expected return type of length 4, found `i32x8` with length 8 //~^ ERROR expected return type of length 4, found `i32x8` with length 8
simd_shuffle_generic::<_, i32x2, I8>(x, x); simd_shuffle_const_generic::<_, i32x2, I8>(x, x);
//~^ ERROR expected return type of length 8, found `i32x2` with length 2 //~^ ERROR expected return type of length 8, found `i32x2` with length 2
} }
} }

View file

@ -70,59 +70,59 @@ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected ret
LL | simd_shuffle::<_, _, i32x2>(x, x, IDX8); LL | simd_shuffle::<_, _, i32x2>(x, x, IDX8);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected SIMD input type, found non-SIMD `i32` error[E0511]: invalid monomorphization of `simd_shuffle_const_generic` intrinsic: expected SIMD input type, found non-SIMD `i32`
--> $DIR/generic-elements.rs:86:9 --> $DIR/generic-elements.rs:86:9
| |
LL | simd_shuffle_generic::<i32, i32, I2>(0, 0); LL | simd_shuffle_const_generic::<i32, i32, I2>(0, 0);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected SIMD input type, found non-SIMD `i32` error[E0511]: invalid monomorphization of `simd_shuffle_const_generic` intrinsic: expected SIMD input type, found non-SIMD `i32`
--> $DIR/generic-elements.rs:89:9 --> $DIR/generic-elements.rs:89:9
| |
LL | simd_shuffle_generic::<i32, i32, I4>(0, 0); LL | simd_shuffle_const_generic::<i32, i32, I4>(0, 0);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected SIMD input type, found non-SIMD `i32` error[E0511]: invalid monomorphization of `simd_shuffle_const_generic` intrinsic: expected SIMD input type, found non-SIMD `i32`
--> $DIR/generic-elements.rs:92:9 --> $DIR/generic-elements.rs:92:9
| |
LL | simd_shuffle_generic::<i32, i32, I8>(0, 0); LL | simd_shuffle_const_generic::<i32, i32, I8>(0, 0);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x2` with element type `f32` error[E0511]: invalid monomorphization of `simd_shuffle_const_generic` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x2` with element type `f32`
--> $DIR/generic-elements.rs:95:9 --> $DIR/generic-elements.rs:95:9
| |
LL | simd_shuffle_generic::<_, f32x2, I2>(x, x); LL | simd_shuffle_const_generic::<_, f32x2, I2>(x, x);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x4` with element type `f32` error[E0511]: invalid monomorphization of `simd_shuffle_const_generic` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x4` with element type `f32`
--> $DIR/generic-elements.rs:97:9 --> $DIR/generic-elements.rs:97:9
| |
LL | simd_shuffle_generic::<_, f32x4, I4>(x, x); LL | simd_shuffle_const_generic::<_, f32x4, I4>(x, x);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x8` with element type `f32` error[E0511]: invalid monomorphization of `simd_shuffle_const_generic` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x8` with element type `f32`
--> $DIR/generic-elements.rs:99:9 --> $DIR/generic-elements.rs:99:9
| |
LL | simd_shuffle_generic::<_, f32x8, I8>(x, x); LL | simd_shuffle_const_generic::<_, f32x8, I8>(x, x);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected return type of length 2, found `i32x8` with length 8 error[E0511]: invalid monomorphization of `simd_shuffle_const_generic` intrinsic: expected return type of length 2, found `i32x8` with length 8
--> $DIR/generic-elements.rs:102:9 --> $DIR/generic-elements.rs:102:9
| |
LL | simd_shuffle_generic::<_, i32x8, I2>(x, x); LL | simd_shuffle_const_generic::<_, i32x8, I2>(x, x);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected return type of length 4, found `i32x8` with length 8 error[E0511]: invalid monomorphization of `simd_shuffle_const_generic` intrinsic: expected return type of length 4, found `i32x8` with length 8
--> $DIR/generic-elements.rs:104:9 --> $DIR/generic-elements.rs:104:9
| |
LL | simd_shuffle_generic::<_, i32x8, I4>(x, x); LL | simd_shuffle_const_generic::<_, i32x8, I4>(x, x);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected return type of length 8, found `i32x2` with length 2 error[E0511]: invalid monomorphization of `simd_shuffle_const_generic` intrinsic: expected return type of length 8, found `i32x2` with length 2
--> $DIR/generic-elements.rs:106:9 --> $DIR/generic-elements.rs:106:9
| |
LL | simd_shuffle_generic::<_, i32x2, I8>(x, x); LL | simd_shuffle_const_generic::<_, i32x2, I8>(x, x);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 21 previous errors error: aborting due to 21 previous errors

View file

@ -1,10 +1,10 @@
error: overly complex generic constant error: overly complex generic constant
--> $DIR/monomorphize-shuffle-index.rs:32:45 --> $DIR/monomorphize-shuffle-index.rs:32:51
| |
LL | return simd_shuffle_generic::<_, _, { &Self::I.0 }>(a, b); LL | return simd_shuffle_const_generic::<_, _, { &Self::I.0 }>(a, b);
| ^^----------^^ | ^^----------^^
| | | |
| pointer casts are not allowed in generic constants | pointer casts are not allowed in generic constants
| |
= help: consider moving this anonymous constant into a `const` function = help: consider moving this anonymous constant into a `const` function

View file

@ -11,7 +11,7 @@ unsafe fn simd_shuffle<T, I, U>(a: T, b: T, i: I) -> U;
#[rustc_intrinsic] #[rustc_intrinsic]
#[cfg(any(generic, generic_with_fn))] #[cfg(any(generic, generic_with_fn))]
unsafe fn simd_shuffle_generic<T, U, const I: &'static [u32]>(a: T, b: T) -> U; unsafe fn simd_shuffle_const_generic<T, U, const I: &'static [u32]>(a: T, b: T) -> U;
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
@ -29,10 +29,10 @@ trait Shuffle<const N: usize> {
#[cfg(old)] #[cfg(old)]
return simd_shuffle(a, b, Self::I); return simd_shuffle(a, b, Self::I);
#[cfg(generic)] #[cfg(generic)]
return simd_shuffle_generic::<_, _, { &Self::I.0 }>(a, b); return simd_shuffle_const_generic::<_, _, { &Self::I.0 }>(a, b);
//[generic]~^ overly complex generic constant //[generic]~^ overly complex generic constant
#[cfg(generic_with_fn)] #[cfg(generic_with_fn)]
return simd_shuffle_generic::<_, _, { Self::J }>(a, b); return simd_shuffle_const_generic::<_, _, { Self::J }>(a, b);
} }
} }