Skip to content

Commit 01352d2

Browse files
lu-zeroAmanieu
authored andcommitted
Add vec_all_lt and vec_any_lt
1 parent 96f0b52 commit 01352d2

File tree

1 file changed

+163
-0
lines changed

1 file changed

+163
-0
lines changed

crates/core_arch/src/powerpc/altivec.rs

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2212,6 +2212,25 @@ where
22122212
b.vec_any_ge(a)
22132213
}
22142214

2215+
/// Vector All Elements Less Than
2216+
#[inline]
2217+
#[target_feature(enable = "altivec")]
2218+
pub unsafe fn vec_all_lt<T, U>(a: U, b: T) -> <T as sealed::VectorAllGt<U>>::Result
2219+
where
2220+
T: sealed::VectorAllGt<U>,
2221+
{
2222+
b.vec_all_gt(a)
2223+
}
2224+
2225+
/// Vector Any Element Less Than
2226+
#[inline]
2227+
#[target_feature(enable = "altivec")]
2228+
pub unsafe fn vec_any_lt<T, U>(a: U, b: T) -> <T as sealed::VectorAnyGt<U>>::Result
2229+
where
2230+
T: sealed::VectorAnyGt<U>,
2231+
{
2232+
b.vec_any_gt(a)
2233+
}
22152234
#[cfg(target_endian = "big")]
22162235
mod endian {
22172236
use super::*;
@@ -3022,6 +3041,150 @@ mod tests {
30223041
true
30233042
}
30243043

3044+
test_vec_2! { test_vec_all_lt_i8_false, vec_all_lt, i8x16 -> bool,
3045+
[0, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
3046+
[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
3047+
false
3048+
}
3049+
3050+
test_vec_2! { test_vec_all_lt_u8_false, vec_all_lt, u8x16 -> bool,
3051+
[0, 0, 255, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
3052+
[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
3053+
false
3054+
}
3055+
3056+
test_vec_2! { test_vec_all_lt_i16_false, vec_all_lt, i16x8 -> bool,
3057+
[0, 0, -1, 1, 0, 0, 0, 0],
3058+
[1, 0, 0, 0, 0, 0, 0, 0],
3059+
false
3060+
}
3061+
3062+
test_vec_2! { test_vec_all_lt_u16_false, vec_all_lt, u16x8 -> bool,
3063+
[0, 0, 255, 1, 0, 0, 0, 0],
3064+
[1, 0, 0, 0, 0, 0, 0, 0],
3065+
false
3066+
}
3067+
3068+
test_vec_2! { test_vec_all_lt_i32_false, vec_all_lt, i32x4 -> bool,
3069+
[0, -1, 0, 1],
3070+
[1, -1, 0, 0],
3071+
false
3072+
}
3073+
3074+
test_vec_2! { test_vec_all_lt_u32_false, vec_all_lt, u32x4 -> bool,
3075+
[0, 255, 1, 1],
3076+
[1, 255, 0, 0],
3077+
false
3078+
}
3079+
3080+
test_vec_2! { test_vec_all_lt_i8_true, vec_all_lt, i8x16 -> bool,
3081+
[0, 0, -2, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
3082+
[2, 1, -1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
3083+
true
3084+
}
3085+
3086+
test_vec_2! { test_vec_all_lt_u8_true, vec_all_lt, u8x16 -> bool,
3087+
[0, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
3088+
[1, 255, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
3089+
true
3090+
}
3091+
3092+
test_vec_2! { test_vec_all_lt_i16_true, vec_all_lt, i16x8 -> bool,
3093+
[0, -5, 2, 0, 0, 0, 0, 0],
3094+
[1, -1, 42, 1, 1, 1, 1, 1],
3095+
true
3096+
}
3097+
3098+
test_vec_2! { test_vec_all_lt_u16_true, vec_all_lt, u16x8 -> bool,
3099+
[2, 254, 0, 0, 0, 0, 0, 0],
3100+
[42, 255, 1, 1, 1, 1, 1, 1],
3101+
true
3102+
}
3103+
3104+
test_vec_2! { test_vec_all_lt_i32_true, vec_all_lt, i32x4 -> bool,
3105+
[0, -2, 0, 0],
3106+
[1, -1, 1, 1],
3107+
true
3108+
}
3109+
3110+
test_vec_2! { test_vec_all_lt_u32_true, vec_all_lt, u32x4 -> bool,
3111+
[0, 254, 0, 0],
3112+
[1, 255, 1, 1],
3113+
true
3114+
}
3115+
3116+
test_vec_2! { test_vec_any_lt_i8_false, vec_any_lt, i8x16 -> bool,
3117+
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
3118+
[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
3119+
false
3120+
}
3121+
3122+
test_vec_2! { test_vec_any_lt_u8_false, vec_any_lt, u8x16 -> bool,
3123+
[42, 255, 255, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
3124+
[1, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
3125+
false
3126+
}
3127+
3128+
test_vec_2! { test_vec_any_lt_i16_false, vec_any_lt, i16x8 -> bool,
3129+
[2, 0, -1, 1, 1, 1, 1, 1],
3130+
[1, -1, -2, 0, 0, 0, 0, 0],
3131+
false
3132+
}
3133+
3134+
test_vec_2! { test_vec_any_lt_u16_false, vec_any_lt, u16x8 -> bool,
3135+
[2, 42, 255, 1, 1, 1, 1, 1],
3136+
[1, 2, 0, 0, 0, 0, 0, 0],
3137+
false
3138+
}
3139+
3140+
test_vec_2! { test_vec_any_lt_i32_false, vec_any_lt, i32x4 -> bool,
3141+
[2, 0, 1, 1],
3142+
[1, -1, 0, 0],
3143+
false
3144+
}
3145+
3146+
test_vec_2! { test_vec_any_lt_u32_false, vec_any_lt, u32x4 -> bool,
3147+
[4, 255, 4, 1],
3148+
[1, 2, 1, 0],
3149+
false
3150+
}
3151+
3152+
test_vec_2! { test_vec_any_lt_i8_true, vec_any_lt, i8x16 -> bool,
3153+
[0, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
3154+
[1, 0, -1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
3155+
true
3156+
}
3157+
3158+
test_vec_2! { test_vec_any_lt_u8_true, vec_any_lt, u8x16 -> bool,
3159+
[0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
3160+
[1, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
3161+
true
3162+
}
3163+
3164+
test_vec_2! { test_vec_any_lt_i16_true, vec_any_lt, i16x8 -> bool,
3165+
[0, -1, 1, 0, 0, 0, 0, 0],
3166+
[1, -1, 1, 0, 0, 0, 0, 0],
3167+
true
3168+
}
3169+
3170+
test_vec_2! { test_vec_any_lt_u16_true, vec_any_lt, u16x8 -> bool,
3171+
[0, 255, 1, 0, 0, 0, 0, 0],
3172+
[1, 255, 1, 0, 0, 0, 0, 0],
3173+
true
3174+
}
3175+
3176+
test_vec_2! { test_vec_any_lt_i32_true, vec_any_lt, i32x4 -> bool,
3177+
[0, -1, 0, 1],
3178+
[1, -1, 0, 1],
3179+
true
3180+
}
3181+
3182+
test_vec_2! { test_vec_any_lt_u32_true, vec_any_lt, u32x4 -> bool,
3183+
[0, 255, 0, 1],
3184+
[1, 255, 0, 1],
3185+
true
3186+
}
3187+
30253188
#[simd_test(enable = "altivec")]
30263189
unsafe fn test_vec_cmpb() {
30273190
let a: vector_float = transmute(f32x4::new(0.1, 0.5, 0.6, 0.9));

0 commit comments

Comments
 (0)