Skip to content

Commit 96f0b52

Browse files
lu-zeroAmanieu
authored andcommitted
Add vec_all_le and vec_any_le
1 parent f5280c3 commit 96f0b52

File tree

1 file changed

+164
-0
lines changed

1 file changed

+164
-0
lines changed

crates/core_arch/src/powerpc/altivec.rs

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2192,6 +2192,26 @@ pub unsafe fn vec_all_in(a: vector_float, b: vector_float) -> bool {
21922192
vcmpbfp_p(0, a, b) != 0
21932193
}
21942194

2195+
/// Vector All Elements Less Than or Equal
2196+
#[inline]
2197+
#[target_feature(enable = "altivec")]
2198+
pub unsafe fn vec_all_le<T, U>(a: U, b: T) -> <T as sealed::VectorAllGe<U>>::Result
2199+
where
2200+
T: sealed::VectorAllGe<U>,
2201+
{
2202+
b.vec_all_ge(a)
2203+
}
2204+
2205+
/// Vector Any Element Less Than or Equal
2206+
#[inline]
2207+
#[target_feature(enable = "altivec")]
2208+
pub unsafe fn vec_any_le<T, U>(a: U, b: T) -> <T as sealed::VectorAnyGe<U>>::Result
2209+
where
2210+
T: sealed::VectorAnyGe<U>,
2211+
{
2212+
b.vec_any_ge(a)
2213+
}
2214+
21952215
#[cfg(target_endian = "big")]
21962216
mod endian {
21972217
use super::*;
@@ -2858,6 +2878,150 @@ mod tests {
28582878
false
28592879
}
28602880

2881+
test_vec_2! { test_vec_all_le_i8_false, vec_all_le, i8x16 -> bool,
2882+
[0, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
2883+
[1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
2884+
false
2885+
}
2886+
2887+
test_vec_2! { test_vec_all_le_u8_false, vec_all_le, u8x16 -> bool,
2888+
[0, 0, 255, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
2889+
[1, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
2890+
false
2891+
}
2892+
2893+
test_vec_2! { test_vec_all_le_i16_false, vec_all_le, i16x8 -> bool,
2894+
[0, 0, -1, 1, 0, 0, 0, 0],
2895+
[1, -1, 0, 0, 0, 0, 0, 0],
2896+
false
2897+
}
2898+
2899+
test_vec_2! { test_vec_all_le_u16_false, vec_all_le, u16x8 -> bool,
2900+
[0, 0, 255, 1, 0, 0, 0, 0],
2901+
[1, 255, 0, 0, 0, 0, 0, 0],
2902+
false
2903+
}
2904+
2905+
test_vec_2! { test_vec_all_le_i32_false, vec_all_le, i32x4 -> bool,
2906+
[0, -1, 0, 1],
2907+
[1, -1, 0, 0],
2908+
false
2909+
}
2910+
2911+
test_vec_2! { test_vec_all_le_u32_false, vec_all_le, u32x4 -> bool,
2912+
[0, 255, 1, 1],
2913+
[1, 255, 0, 0],
2914+
false
2915+
}
2916+
2917+
test_vec_2! { test_vec_all_le_i8_true, vec_all_le, i8x16 -> bool,
2918+
[0, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
2919+
[0, 0, -1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
2920+
true
2921+
}
2922+
2923+
test_vec_2! { test_vec_all_le_u8_true, vec_all_le, u8x16 -> bool,
2924+
[1, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
2925+
[1, 255, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
2926+
true
2927+
}
2928+
2929+
test_vec_2! { test_vec_all_le_i16_true, vec_all_le, i16x8 -> bool,
2930+
[1, -5, 2, 0, 0, 0, 0, 0],
2931+
[1, -1, 42, 0, 0, 0, 0, 0],
2932+
true
2933+
}
2934+
2935+
test_vec_2! { test_vec_all_le_u16_true, vec_all_le, u16x8 -> bool,
2936+
[2, 255, 1, 0, 0, 0, 0, 0],
2937+
[42, 255, 1, 0, 0, 0, 0, 0],
2938+
true
2939+
}
2940+
2941+
test_vec_2! { test_vec_all_le_i32_true, vec_all_le, i32x4 -> bool,
2942+
[0, -1, 0, 1],
2943+
[1, -1, 0, 1],
2944+
true
2945+
}
2946+
2947+
test_vec_2! { test_vec_all_le_u32_true, vec_all_le, u32x4 -> bool,
2948+
[1, 254, 0, 0],
2949+
[1, 255, 0, 1],
2950+
true
2951+
}
2952+
2953+
test_vec_2! { test_vec_any_le_i8_false, vec_any_le, i8x16 -> bool,
2954+
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
2955+
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
2956+
false
2957+
}
2958+
2959+
test_vec_2! { test_vec_any_le_u8_false, vec_any_le, u8x16 -> bool,
2960+
[42, 255, 255, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
2961+
[1, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
2962+
false
2963+
}
2964+
2965+
test_vec_2! { test_vec_any_le_i16_false, vec_any_le, i16x8 -> bool,
2966+
[2, 0, -1, 1, 1, 1, 1, 1],
2967+
[1, -1, -2, 0, 0, 0, 0, 0],
2968+
false
2969+
}
2970+
2971+
test_vec_2! { test_vec_any_le_u16_false, vec_any_le, u16x8 -> bool,
2972+
[2, 42, 255, 1, 1, 1, 1, 1],
2973+
[1, 2, 0, 0, 0, 0, 0, 0],
2974+
false
2975+
}
2976+
2977+
test_vec_2! { test_vec_any_le_i32_false, vec_any_le, i32x4 -> bool,
2978+
[2, 0, 1, 1],
2979+
[1, -1, 0, 0],
2980+
false
2981+
}
2982+
2983+
test_vec_2! { test_vec_any_le_u32_false, vec_any_le, u32x4 -> bool,
2984+
[4, 255, 4, 1],
2985+
[1, 2, 1, 0],
2986+
false
2987+
}
2988+
2989+
test_vec_2! { test_vec_any_le_i8_true, vec_any_le, i8x16 -> bool,
2990+
[0, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
2991+
[1, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
2992+
true
2993+
}
2994+
2995+
test_vec_2! { test_vec_any_le_u8_true, vec_any_le, u8x16 -> bool,
2996+
[1, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
2997+
[0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
2998+
true
2999+
}
3000+
3001+
test_vec_2! { test_vec_any_le_i16_true, vec_any_le, i16x8 -> bool,
3002+
[1, -1, 1, 0, 0, 0, 0, 0],
3003+
[0, -1, 1, 0, 0, 0, 0, 0],
3004+
true
3005+
}
3006+
3007+
test_vec_2! { test_vec_any_le_u16_true, vec_any_le, u16x8 -> bool,
3008+
[1, 255, 1, 0, 0, 0, 0, 0],
3009+
[0, 255, 1, 0, 0, 0, 0, 0],
3010+
true
3011+
}
3012+
3013+
test_vec_2! { test_vec_any_le_i32_true, vec_any_le, i32x4 -> bool,
3014+
[1, -1, 0, 1],
3015+
[0, -1, 0, 1],
3016+
true
3017+
}
3018+
3019+
test_vec_2! { test_vec_any_le_u32_true, vec_any_le, u32x4 -> bool,
3020+
[1, 255, 0, 1],
3021+
[0, 255, 0, 1],
3022+
true
3023+
}
3024+
28613025
#[simd_test(enable = "altivec")]
28623026
unsafe fn test_vec_cmpb() {
28633027
let a: vector_float = transmute(f32x4::new(0.1, 0.5, 0.6, 0.9));

0 commit comments

Comments
 (0)