Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
Used intrinsic for to_bitmask
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgecarleitao committed Mar 5, 2022
1 parent ede1db6 commit 2990e98
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions src/compute/comparison/simd/packed.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::convert::TryInto;
use std::simd::ToBitMask;

use crate::types::simd::*;

use crate::types::{days_ms, months_days_ns};

use super::*;
Expand Down Expand Up @@ -29,34 +29,34 @@ macro_rules! simd8 {
impl Simd8PartialEq for $md {
#[inline]
fn eq(self, other: Self) -> u8 {
to_bitmask(self.lanes_eq(other))
self.lanes_eq(other).to_bitmask()
}

#[inline]
fn neq(self, other: Self) -> u8 {
to_bitmask(self.lanes_ne(other))
self.lanes_ne(other).to_bitmask()
}
}

impl Simd8PartialOrd for $md {
#[inline]
fn lt_eq(self, other: Self) -> u8 {
to_bitmask(self.lanes_le(other))
self.lanes_le(other).to_bitmask()
}

#[inline]
fn lt(self, other: Self) -> u8 {
to_bitmask(self.lanes_lt(other))
self.lanes_lt(other).to_bitmask()
}

#[inline]
fn gt_eq(self, other: Self) -> u8 {
to_bitmask(self.lanes_ge(other))
self.lanes_ge(other).to_bitmask()
}

#[inline]
fn gt(self, other: Self) -> u8 {
to_bitmask(self.lanes_gt(other))
self.lanes_gt(other).to_bitmask()
}
}
};
Expand All @@ -77,14 +77,3 @@ simd8_native!(days_ms);
simd8_native_partial_eq!(days_ms);
simd8_native!(months_days_ns);
simd8_native_partial_eq!(months_days_ns);

fn to_bitmask<T: std::simd::MaskElement>(mask: std::simd::Mask<T, 8>) -> u8 {
mask.test(0) as u8
| ((mask.test(1) as u8) << 1)
| ((mask.test(2) as u8) << 2)
| ((mask.test(3) as u8) << 3)
| ((mask.test(4) as u8) << 4)
| ((mask.test(5) as u8) << 5)
| ((mask.test(6) as u8) << 6)
| ((mask.test(7) as u8) << 7)
}

0 comments on commit 2990e98

Please sign in to comment.