Created
December 26, 2017 15:45
-
-
Save yskszk63/0291d2b521456fa28196c655f9cc027c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate simd; | |
fn main() { | |
let (c1, c2, c3, c4) = (0b0011, 0b0101, 0b0001, 0b1001); | |
let val = simd::u8x16::new( | |
c1, c2, c3, c4, | |
c1, c2, c3, c4, | |
c1, c2, c3, c4, | |
c1, c2, c3, c4); | |
let mask = simd::u8x16::new( | |
0b0001, 0b0001, 0b0001, 0b0001, | |
0b0010, 0b0010, 0b0010, 0b0010, | |
0b0100, 0b0100, 0b0100, 0b0100, | |
0b1000, 0b1000, 0b1000, 0b1000); | |
let m = (val & mask).eq(mask); | |
let ok = | |
( | |
m.extract(0) && | |
m.extract(1) && | |
m.extract(2) && | |
m.extract(3) | |
) || ( | |
!m.extract(0) && | |
!m.extract(1) && | |
!m.extract(2) && | |
!m.extract(3) | |
) || ( | |
m.extract(4) && | |
m.extract(5) && | |
m.extract(6) && | |
m.extract(7) | |
) || ( | |
!m.extract(4) && | |
!m.extract(5) && | |
!m.extract(6) && | |
!m.extract(7) | |
) || ( | |
m.extract(8) && | |
m.extract(9) && | |
m.extract(10) && | |
m.extract(11) | |
) || ( | |
!m.extract(8) && | |
!m.extract(9) && | |
!m.extract(10) && | |
!m.extract(11) | |
) || ( | |
m.extract(12) && | |
m.extract(13) && | |
m.extract(14) && | |
m.extract(15) | |
) || ( | |
!m.extract(12) && | |
!m.extract(13) && | |
!m.extract(14) && | |
!m.extract(15) | |
); | |
println!("{:?}", ok) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment