File tree 1 file changed +20
-2
lines changed
1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -429,8 +429,26 @@ where
429
429
{
430
430
#[ inline]
431
431
fn eq ( & self , other : & Self ) -> bool {
432
- // TODO use SIMD equality
433
- self . to_array ( ) == other. to_array ( )
432
+ // Safety: All SIMD vectors are SimdPartialEq, and the comparison produces a valid mask.
433
+ let mask = unsafe {
434
+ let tfvec: Simd < <T as SimdElement >:: Mask , LANES > = intrinsics:: simd_eq ( * self , * other) ;
435
+ Mask :: from_int_unchecked ( tfvec)
436
+ } ;
437
+
438
+ // Two vectors are equal if all lanes tested true for vertical equality.
439
+ mask. all ( )
440
+ }
441
+
442
+ #[ inline]
443
+ fn ne ( & self , other : & Self ) -> bool {
444
+ // Safety: All SIMD vectors are SimdPartialEq, and the comparison produces a valid mask.
445
+ let mask = unsafe {
446
+ let tfvec: Simd < <T as SimdElement >:: Mask , LANES > = intrinsics:: simd_ne ( * self , * other) ;
447
+ Mask :: from_int_unchecked ( tfvec)
448
+ } ;
449
+
450
+ // Two vectors are non-equal if any lane tested true for vertical non-equality.
451
+ mask. any ( )
434
452
}
435
453
}
436
454
You can’t perform that action at this time.
0 commit comments