/src/rust-brotli/src/enc/vectorization.rs
Line | Count | Source |
1 | | #![allow(unknown_lints)] |
2 | | #![allow(unused_macros)] |
3 | | |
4 | | use crate::enc::util::FastLog2; |
5 | | use crate::enc::{s8, v8}; |
6 | | pub type Mem256f = v8; |
7 | | pub type Mem256i = s8; |
8 | | pub type v256 = v8; |
9 | | pub type v256i = s8; |
10 | 0 | pub fn sum8(x: v256) -> f32 { |
11 | 0 | x[0] + x[1] + x[2] + x[3] + x[4] + x[5] + x[6] + x[7] |
12 | 0 | } |
13 | | |
14 | 0 | pub fn sum8i(x: v256i) -> i32 { |
15 | 0 | x[0].wrapping_add(x[1]) |
16 | 0 | .wrapping_add(x[2]) |
17 | 0 | .wrapping_add(x[3]) |
18 | 0 | .wrapping_add(x[4]) |
19 | 0 | .wrapping_add(x[5]) |
20 | 0 | .wrapping_add(x[6]) |
21 | 0 | .wrapping_add(x[7]) |
22 | 0 | } |
23 | | |
24 | 0 | pub fn log2i(x: v256i) -> v256 { |
25 | 0 | [ |
26 | 0 | FastLog2(x[0] as u64), |
27 | 0 | FastLog2(x[1] as u64), |
28 | 0 | FastLog2(x[2] as u64), |
29 | 0 | FastLog2(x[3] as u64), |
30 | 0 | FastLog2(x[4] as u64), |
31 | 0 | FastLog2(x[5] as u64), |
32 | 0 | FastLog2(x[6] as u64), |
33 | 0 | FastLog2(x[7] as u64), |
34 | 0 | ] |
35 | 0 | .into() |
36 | 0 | } |
37 | 0 | pub fn cast_i32_to_f32(x: v256i) -> v256 { |
38 | 0 | [ |
39 | 0 | x[0] as f32, |
40 | 0 | x[1] as f32, |
41 | 0 | x[2] as f32, |
42 | 0 | x[3] as f32, |
43 | 0 | x[4] as f32, |
44 | 0 | x[5] as f32, |
45 | 0 | x[6] as f32, |
46 | 0 | x[7] as f32, |
47 | 0 | ] |
48 | 0 | .into() |
49 | 0 | } |
50 | 0 | pub fn cast_f32_to_i32(x: v256) -> v256i { |
51 | 0 | [ |
52 | 0 | x[0] as i32, |
53 | 0 | x[1] as i32, |
54 | 0 | x[2] as i32, |
55 | 0 | x[3] as i32, |
56 | 0 | x[4] as i32, |
57 | 0 | x[5] as i32, |
58 | 0 | x[6] as i32, |
59 | 0 | x[7] as i32, |
60 | 0 | ] |
61 | 0 | .into() |
62 | 0 | } |