Allow isize/usize in simd_cast
This commit is contained in:
parent
399ba6bb37
commit
d32ca64692
@ -1715,14 +1715,26 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#,
|
|||||||
let (in_style, in_width) = match in_elem.kind() {
|
let (in_style, in_width) = match in_elem.kind() {
|
||||||
// vectors of pointer-sized integers should've been
|
// vectors of pointer-sized integers should've been
|
||||||
// disallowed before here, so this unwrap is safe.
|
// disallowed before here, so this unwrap is safe.
|
||||||
ty::Int(i) => (Style::Int(true), i.bit_width().unwrap()),
|
ty::Int(i) => (
|
||||||
ty::Uint(u) => (Style::Int(false), u.bit_width().unwrap()),
|
Style::Int(true),
|
||||||
|
i.normalize(bx.tcx().sess.target.pointer_width).bit_width().unwrap(),
|
||||||
|
),
|
||||||
|
ty::Uint(u) => (
|
||||||
|
Style::Int(false),
|
||||||
|
u.normalize(bx.tcx().sess.target.pointer_width).bit_width().unwrap(),
|
||||||
|
),
|
||||||
ty::Float(f) => (Style::Float, f.bit_width()),
|
ty::Float(f) => (Style::Float, f.bit_width()),
|
||||||
_ => (Style::Unsupported, 0),
|
_ => (Style::Unsupported, 0),
|
||||||
};
|
};
|
||||||
let (out_style, out_width) = match out_elem.kind() {
|
let (out_style, out_width) = match out_elem.kind() {
|
||||||
ty::Int(i) => (Style::Int(true), i.bit_width().unwrap()),
|
ty::Int(i) => (
|
||||||
ty::Uint(u) => (Style::Int(false), u.bit_width().unwrap()),
|
Style::Int(true),
|
||||||
|
i.normalize(bx.tcx().sess.target.pointer_width).bit_width().unwrap(),
|
||||||
|
),
|
||||||
|
ty::Uint(u) => (
|
||||||
|
Style::Int(false),
|
||||||
|
u.normalize(bx.tcx().sess.target.pointer_width).bit_width().unwrap(),
|
||||||
|
),
|
||||||
ty::Float(f) => (Style::Float, f.bit_width()),
|
ty::Float(f) => (Style::Float, f.bit_width()),
|
||||||
_ => (Style::Unsupported, 0),
|
_ => (Style::Unsupported, 0),
|
||||||
};
|
};
|
||||||
|
21
src/test/ui/simd/intrinsic/generic-cast-pointer-width.rs
Normal file
21
src/test/ui/simd/intrinsic/generic-cast-pointer-width.rs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
// run-pass
|
||||||
|
#![feature(repr_simd, platform_intrinsics)]
|
||||||
|
|
||||||
|
extern "platform-intrinsic" {
|
||||||
|
fn simd_cast<T, U>(x: T) -> U;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
|
#[repr(simd)]
|
||||||
|
struct V<T>([T; 4]);
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let u = V::<usize>([0, 1, 2, 3]);
|
||||||
|
let uu32: V<u32> = unsafe { simd_cast(u) };
|
||||||
|
let ui64: V<i64> = unsafe { simd_cast(u) };
|
||||||
|
|
||||||
|
for (u, (uu32, ui64)) in u.0.iter().zip(uu32.0.iter().zip(ui64.0.iter())) {
|
||||||
|
assert_eq!(*u as u32, *uu32);
|
||||||
|
assert_eq!(*u as i64, *ui64);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user