Skip to content

rename simd_shuffle_generic → simd_shuffle_const_generic #137556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
sym::simd_shuffle_generic => {
// simd_shuffle_const_generic<T, U, const I: &[u32]>(x: T, y: T) -> U
sym::simd_shuffle_const_generic => {
let [x, y] = args else {
bug!("wrong number of args for intrinsic {intrinsic}");
};
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 n = idx.len() as u64;

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/check/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ pub fn check_intrinsic_type(
| sym::simd_reduce_min
| 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_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 => {
tcx.dcx().emit_err(UnrecognizedIntrinsicFunction { span, name: other });
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1916,7 +1916,7 @@ symbols! {
simd_shl,
simd_shr,
simd_shuffle,
simd_shuffle_generic,
simd_shuffle_const_generic,
simd_sub,
simd_trunc,
simd_with_exposed_provenance,
Expand Down
4 changes: 2 additions & 2 deletions src/tools/miri/src/intrinsics/simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
this.write_immediate(*val, &dest)?;
}
}
"shuffle_generic" => {
"shuffle_const_generic" => {
let [left, right] = check_arg_count(args)?;
let (left, left_len) = this.project_to_simd(left)?;
let (right, right_len) = this.project_to_simd(right)?;
Expand All @@ -657,7 +657,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
this.read_immediate(&this.project_index(&right, right_idx)?)?
} else {
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)?;
Expand Down
6 changes: 3 additions & 3 deletions src/tools/miri/tests/pass/intrinsics/portable-simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::simd::prelude::*;

#[rustc_intrinsic]
#[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() {
let a = f32x4::splat(10.0);
Expand Down Expand Up @@ -619,13 +619,13 @@ fn simd_intrinsics() {
simd_select(i8x4::from_array([0, -1, -1, 0]), b, a),
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!(
simd_shuffle::<_, _, i32x4>(a, b, const { u32x4::from_array([3u32, 1, 0, 2]) }),
a,
);
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]),
);
assert_eq!(
Expand Down
20 changes: 10 additions & 10 deletions tests/ui/simd/intrinsic/generic-elements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

#[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)]
Expand Down Expand Up @@ -83,27 +83,27 @@ fn main() {
//~^ ERROR expected return type of length 8, found `i32x2` with length 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`
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`
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`

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`
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`
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`

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
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
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
}
}
54 changes: 27 additions & 27 deletions tests/ui/simd/intrinsic/generic-elements.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -70,59 +70,59 @@ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected ret
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
LL | simd_shuffle_generic::<_, i32x2, I8>(x, x);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | simd_shuffle_const_generic::<_, i32x2, I8>(x, x);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 21 previous errors

Expand Down
10 changes: 5 additions & 5 deletions tests/ui/simd/monomorphize-shuffle-index.generic.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
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);
| ^^----------^^
| |
| pointer casts are not allowed in generic constants
LL | return simd_shuffle_const_generic::<_, _, { &Self::I.0 }>(a, b);
| ^^----------^^
| |
| pointer casts are not allowed in generic constants
|
= help: consider moving this anonymous constant into a `const` function

Expand Down
6 changes: 3 additions & 3 deletions tests/ui/simd/monomorphize-shuffle-index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ unsafe fn simd_shuffle<T, I, U>(a: T, b: T, i: I) -> U;

#[rustc_intrinsic]
#[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)]
Expand All @@ -29,10 +29,10 @@ trait Shuffle<const N: usize> {
#[cfg(old)]
return simd_shuffle(a, b, Self::I);
#[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
#[cfg(generic_with_fn)]
return simd_shuffle_generic::<_, _, { Self::J }>(a, b);
return simd_shuffle_const_generic::<_, _, { Self::J }>(a, b);
}
}

Expand Down
Loading