brotli/enc/
vectorization.rs

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