brotli/enc/
vectorization.rs

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