Skip to content

Commit 6df722d

Browse files
lu-zerognzlbg
authored andcommitted
Add Altivec vec_cmpb
1 parent eaaef22 commit 6df722d

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

crates/core_arch/src/powerpc/altivec.rs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ extern "C" {
209209

210210
#[link_name = "llvm.ceil.v4f32"]
211211
fn vceil(a: vector_float) -> vector_float;
212+
213+
#[link_name = "llvm.ppc.altivec.vcmpbfp"]
214+
fn vcmpbfp(a: vector_float, b: vector_float) -> vector_signed_int;
212215
}
213216

214217
macro_rules! s_t_l {
@@ -365,6 +368,8 @@ mod sealed {
365368
}
366369
}
367370

371+
test_impl! { vec_vcmpbfp(a: vector_float, b: vector_float) -> vector_signed_int [vcmpbfp, vcmpbfp] }
372+
368373
test_impl! { vec_vceil(a: vector_float) -> vector_float [vceil, vrfip / xvrspip ] }
369374

370375
test_impl! { vec_vavgsb(a: vector_signed_char, b: vector_signed_char) -> vector_signed_char [ vavgsb, vavgsb ] }
@@ -1284,7 +1289,14 @@ mod sealed {
12841289
vector_mladd! { vector_signed_short, vector_signed_short, vector_signed_short }
12851290
}
12861291

1287-
/// Vector ceil.
1292+
/// Vector cmpb.
1293+
#[inline]
1294+
#[target_feature(enable = "altivec")]
1295+
pub unsafe fn vec_cmpb(a: vector_float, b: vector_float) -> vector_signed_int {
1296+
sealed::vec_vcmpbfp(a, b)
1297+
}
1298+
1299+
/// Vector cmpb.
12881300
#[inline]
12891301
#[target_feature(enable = "altivec")]
12901302
pub unsafe fn vec_ceil(a: vector_float) -> vector_float {
@@ -1625,6 +1637,20 @@ mod tests {
16251637
}
16261638
}
16271639

1640+
#[simd_test(enable = "altivec")]
1641+
unsafe fn test_vec_cmpb() {
1642+
let a: vector_float = transmute(f32x4::new(0.1, 0.5, 0.6, 0.9));
1643+
let b: vector_float = transmute(f32x4::new(-0.1, 0.5, -0.6, 0.9));
1644+
let d = i32x4::new(
1645+
-0b10000000000000000000000000000000,
1646+
0,
1647+
-0b10000000000000000000000000000000,
1648+
0,
1649+
);
1650+
1651+
assert_eq!(d, transmute(vec_cmpb(a, b)));
1652+
}
1653+
16281654
#[simd_test(enable = "altivec")]
16291655
unsafe fn test_vec_ceil() {
16301656
let a: vector_float = transmute(f32x4::new(0.1, 0.5, 0.6, 0.9));

0 commit comments

Comments
 (0)