Skip to content

Commit 18a212c

Browse files
lu-zeroAmanieu
authored andcommitted
core_arch: Unbreak powerpc64 tests
1 parent b655243 commit 18a212c

File tree

2 files changed

+31
-19
lines changed

2 files changed

+31
-19
lines changed

crates/core_arch/src/powerpc/altivec.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -540,8 +540,10 @@ mod sealed {
540540
#[target_feature(enable = "altivec")]
541541
#[cfg_attr(all(test, not(target_feature = "vsx")), assert_instr(vandc))]
542542
#[cfg_attr(all(test, target_feature = "vsx"), assert_instr(xxlandc))]
543-
unsafe fn andc(a: u8x16, b: u8x16) -> u8x16 {
544-
simd_and(simd_xor(u8x16::splat(0xff), b), a)
543+
unsafe fn andc(a: vector_signed_char, b: vector_signed_char) -> vector_signed_char {
544+
let a = transmute(a);
545+
let b = transmute(b);
546+
transmute(simd_and(simd_xor(u8x16::splat(0xff), b), a))
545547
}
546548

547549
pub trait VectorAndc<Other> {
@@ -1423,8 +1425,15 @@ mod sealed {
14231425
#[inline]
14241426
#[target_feature(enable = "altivec")]
14251427
#[cfg_attr(test, assert_instr(vmladduhm))]
1426-
unsafe fn mladd(a: i16x8, b: i16x8, c: i16x8) -> i16x8 {
1427-
simd_add(simd_mul(a, b), c)
1428+
unsafe fn mladd(
1429+
a: vector_signed_short,
1430+
b: vector_signed_short,
1431+
c: vector_signed_short,
1432+
) -> vector_signed_short {
1433+
let a: i16x8 = transmute(a);
1434+
let b: i16x8 = transmute(b);
1435+
let c: i16x8 = transmute(c);
1436+
transmute(simd_add(simd_mul(a, b), c))
14281437
}
14291438

14301439
macro_rules! vector_mladd {
@@ -1434,9 +1443,9 @@ mod sealed {
14341443
#[inline]
14351444
#[target_feature(enable = "altivec")]
14361445
unsafe fn vec_mladd(self, b: $bc, c: $bc) -> Self::Result {
1437-
let a: i16x8 = transmute(self);
1438-
let b: i16x8 = transmute(b);
1439-
let c: i16x8 = transmute(c);
1446+
let a = transmute(self);
1447+
let b = transmute(b);
1448+
let c = transmute(c);
14401449

14411450
transmute(mladd(a, b, c))
14421451
}

crates/core_arch/src/powerpc/vsx.rs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::core_arch::simd_llvm::*;
1313
#[cfg(test)]
1414
use stdarch_test::assert_instr;
1515

16-
use crate::mem;
16+
use crate::mem::transmute;
1717

1818
types! {
1919
// pub struct vector_Float16 = f16x8;
@@ -45,13 +45,16 @@ mod sealed {
4545
#[target_feature(enable = "vsx")]
4646
#[cfg_attr(all(test, target_endian = "little"), assert_instr(xxmrgld, dm = 0x0))]
4747
#[cfg_attr(all(test, target_endian = "big"), assert_instr(xxspltd, dm = 0x0))]
48-
unsafe fn xxpermdi(a: i64x2, b: i64x2, dm: u8) -> i64x2 {
49-
match dm & 0b11 {
48+
unsafe fn xxpermdi(a: vector_signed_long, b: vector_signed_long, dm: u8) -> vector_signed_long {
49+
let a: i64x2 = transmute(a);
50+
let b: i64x2 = transmute(b);
51+
let r: i64x2 = match dm & 0b11 {
5052
0 => simd_shuffle!(a, b, [0b00, 0b10]),
5153
1 => simd_shuffle!(a, b, [0b01, 0b10]),
5254
2 => simd_shuffle!(a, b, [0b00, 0b11]),
5355
_ => simd_shuffle!(a, b, [0b01, 0b11]),
54-
}
56+
};
57+
transmute(r)
5558
}
5659

5760
macro_rules! vec_xxpermdi {
@@ -60,7 +63,7 @@ mod sealed {
6063
#[inline]
6164
#[target_feature(enable = "vsx")]
6265
unsafe fn vec_xxpermdi(self, b: Self, dm: u8) -> Self {
63-
mem::transmute(xxpermdi(mem::transmute(self), mem::transmute(b), dm))
66+
transmute(xxpermdi(transmute(self), transmute(b), dm))
6467
}
6568
}
6669
}
@@ -92,21 +95,21 @@ mod tests {
9295
#[cfg(target_arch = "powerpc64")]
9396
use crate::core_arch::arch::powerpc64::*;
9497

95-
use super::mem;
9698
use crate::core_arch::simd::*;
99+
use crate::mem::transmute;
97100
use stdarch_test::simd_test;
98101

99102
macro_rules! test_vec_xxpermdi {
100103
{$name:ident, $shorttype:ident, $longtype:ident, [$($a:expr),+], [$($b:expr),+], [$($c:expr),+], [$($d:expr),+]} => {
101104
#[simd_test(enable = "vsx")]
102105
unsafe fn $name() {
103-
let a: $longtype = mem::transmute($shorttype::new($($a),+, $($b),+));
104-
let b = mem::transmute($shorttype::new($($c),+, $($d),+));
106+
let a: $longtype = transmute($shorttype::new($($a),+, $($b),+));
107+
let b = transmute($shorttype::new($($c),+, $($d),+));
105108

106-
assert_eq!($shorttype::new($($a),+, $($c),+), mem::transmute(vec_xxpermdi::<_, 0>(a, b)));
107-
assert_eq!($shorttype::new($($b),+, $($c),+), mem::transmute(vec_xxpermdi::<_, 1>(a, b)));
108-
assert_eq!($shorttype::new($($a),+, $($d),+), mem::transmute(vec_xxpermdi::<_, 2>(a, b)));
109-
assert_eq!($shorttype::new($($b),+, $($d),+), mem::transmute(vec_xxpermdi::<_, 3>(a, b)));
109+
assert_eq!($shorttype::new($($a),+, $($c),+), transmute(vec_xxpermdi::<_, 0>(a, b)));
110+
assert_eq!($shorttype::new($($b),+, $($c),+), transmute(vec_xxpermdi::<_, 1>(a, b)));
111+
assert_eq!($shorttype::new($($a),+, $($d),+), transmute(vec_xxpermdi::<_, 2>(a, b)));
112+
assert_eq!($shorttype::new($($b),+, $($d),+), transmute(vec_xxpermdi::<_, 3>(a, b)));
110113
}
111114
}
112115
}

0 commit comments

Comments
 (0)