Skip to content

Commit f5280c3

Browse files
lu-zeroAmanieu
authored andcommitted
Add vec_all_in
1 parent 920aac4 commit f5280c3

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

crates/core_arch/src/powerpc/altivec.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,8 @@ extern "C" {
272272
fn vcmpgefp_p(cr: i32, a: vector_float, b: vector_float) -> i32;
273273
#[link_name = "llvm.ppc.altivec.vcmpgtfp.p"]
274274
fn vcmpgtfp_p(cr: i32, a: vector_float, b: vector_float) -> i32;
275+
#[link_name = "llvm.ppc.altivec.vcmpbfp.p"]
276+
fn vcmpbfp_p(cr: i32, a: vector_float, b: vector_float) -> i32;
275277
}
276278

277279
macro_rules! s_t_l {
@@ -2182,6 +2184,14 @@ where
21822184
a.vec_any_gt(b)
21832185
}
21842186

2187+
/// Vector All In
2188+
#[inline]
2189+
#[target_feature(enable = "altivec")]
2190+
#[cfg_attr(test, assert_instr("vcmpbfp."))]
2191+
pub unsafe fn vec_all_in(a: vector_float, b: vector_float) -> bool {
2192+
vcmpbfp_p(0, a, b) != 0
2193+
}
2194+
21852195
#[cfg(target_endian = "big")]
21862196
mod endian {
21872197
use super::*;
@@ -2836,6 +2846,18 @@ mod tests {
28362846
true
28372847
}
28382848

2849+
test_vec_2! { test_vec_all_in_true, vec_all_in, f32x4 -> bool,
2850+
[0.0, -0.1, 0.0, 0.0],
2851+
[0.1, 0.2, 0.0, 0.0],
2852+
true
2853+
}
2854+
2855+
test_vec_2! { test_vec_all_in_false, vec_all_in, f32x4 -> bool,
2856+
[0.5, 0.4, -0.5, 0.8],
2857+
[0.1, 0.4, -0.5, 0.8],
2858+
false
2859+
}
2860+
28392861
#[simd_test(enable = "altivec")]
28402862
unsafe fn test_vec_cmpb() {
28412863
let a: vector_float = transmute(f32x4::new(0.1, 0.5, 0.6, 0.9));

0 commit comments

Comments
 (0)