Skip to content

Commit d633f07

Browse files
committed
powerpc: use llvm.fshl for vec_rl
1 parent c114d39 commit d633f07

File tree

1 file changed

+45
-16
lines changed

1 file changed

+45
-16
lines changed

crates/core_arch/src/powerpc/altivec.rs

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -362,12 +362,24 @@ unsafe extern "C" {
362362
#[link_name = "llvm.ppc.altivec.srv"]
363363
fn vsrv(a: vector_unsigned_char, b: vector_unsigned_char) -> vector_unsigned_char;
364364

365-
#[link_name = "llvm.ppc.altivec.vrlb"]
366-
fn vrlb(a: vector_signed_char, b: vector_unsigned_char) -> vector_signed_char;
367-
#[link_name = "llvm.ppc.altivec.vrlh"]
368-
fn vrlh(a: vector_signed_short, b: vector_unsigned_short) -> vector_signed_short;
369-
#[link_name = "llvm.ppc.altivec.vrlw"]
370-
fn vrlw(a: vector_signed_int, c: vector_unsigned_int) -> vector_signed_int;
365+
#[link_name = "llvm.fshl.v16i8"]
366+
fn fshlb(
367+
a: vector_unsigned_char,
368+
b: vector_unsigned_char,
369+
c: vector_unsigned_char,
370+
) -> vector_unsigned_char;
371+
#[link_name = "llvm.fshl.v8i16"]
372+
fn fshlh(
373+
a: vector_unsigned_short,
374+
b: vector_unsigned_short,
375+
c: vector_unsigned_short,
376+
) -> vector_unsigned_short;
377+
#[link_name = "llvm.fshl.v4i32"]
378+
fn fshlw(
379+
a: vector_unsigned_int,
380+
b: vector_unsigned_int,
381+
c: vector_unsigned_int,
382+
) -> vector_unsigned_int;
371383

372384
#[link_name = "llvm.nearbyint.v4f32"]
373385
fn vrfin(a: vector_float) -> vector_float;
@@ -3182,6 +3194,21 @@ mod sealed {
31823194
impl_vec_cntlz! { vec_vcntlzw(vector_signed_int) }
31833195
impl_vec_cntlz! { vec_vcntlzw(vector_unsigned_int) }
31843196

3197+
macro_rules! impl_vrl {
3198+
($fun:ident $intr:ident $ty:ident) => {
3199+
#[inline]
3200+
#[target_feature(enable = "altivec")]
3201+
#[cfg_attr(test, assert_instr($fun))]
3202+
unsafe fn $fun(a: t_t_l!($ty), b: t_t_l!($ty)) -> t_t_l!($ty) {
3203+
transmute($intr(transmute(a), transmute(a), transmute(b)))
3204+
}
3205+
};
3206+
}
3207+
3208+
impl_vrl! { vrlb fshlb u8 }
3209+
impl_vrl! { vrlh fshlh u16 }
3210+
impl_vrl! { vrlw fshlw u32 }
3211+
31853212
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
31863213
pub trait VectorRl {
31873214
type Shift;
@@ -3202,16 +3229,12 @@ mod sealed {
32023229
};
32033230
}
32043231

3205-
test_impl! { vec_vrlb(a: vector_signed_char, b: vector_unsigned_char) -> vector_signed_char [vrlb, vrlb] }
3206-
test_impl! { vec_vrlh(a: vector_signed_short, b: vector_unsigned_short) -> vector_signed_short [vrlh, vrlh] }
3207-
test_impl! { vec_vrlw(a: vector_signed_int, b: vector_unsigned_int) -> vector_signed_int [vrlw, vrlw] }
3208-
3209-
impl_vec_rl! { vec_vrlb(vector_signed_char) }
3210-
impl_vec_rl! { vec_vrlh(vector_signed_short) }
3211-
impl_vec_rl! { vec_vrlw(vector_signed_int) }
3212-
impl_vec_rl! { vec_vrlb(vector_unsigned_char) }
3213-
impl_vec_rl! { vec_vrlh(vector_unsigned_short) }
3214-
impl_vec_rl! { vec_vrlw(vector_unsigned_int) }
3232+
impl_vec_rl! { vrlb(vector_signed_char) }
3233+
impl_vec_rl! { vrlh(vector_signed_short) }
3234+
impl_vec_rl! { vrlw(vector_signed_int) }
3235+
impl_vec_rl! { vrlb(vector_unsigned_char) }
3236+
impl_vec_rl! { vrlh(vector_unsigned_short) }
3237+
impl_vec_rl! { vrlw(vector_unsigned_int) }
32153238

32163239
#[unstable(feature = "stdarch_powerpc", issue = "111145")]
32173240
pub trait VectorRound {
@@ -6662,4 +6685,10 @@ mod tests {
66626685
assert_eq!(v4, v);
66636686
assert_eq!(v8, v);
66646687
}
6688+
6689+
test_vec_2! { test_vec_rl, vec_rl, u32x4,
6690+
[0x12345678, 0x9ABCDEF0, 0x0F0F0F0F, 0x12345678],
6691+
[4, 8, 12, 68],
6692+
[0x23456781, 0xBCDEF09A, 0xF0F0F0F0, 0x23456781]
6693+
}
66656694
}

0 commit comments

Comments
 (0)