Coverage Report

Created: 2026-04-01 07:49

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libjxl/lib/jxl/enc_ans_simd.cc
Line
Count
Source
1
// Copyright (c) the JPEG XL Project Authors. All rights reserved.
2
//
3
// Use of this source code is governed by a BSD-style
4
// license that can be found in the LICENSE file.
5
6
#include "lib/jxl/enc_ans_simd.h"
7
8
#include <cstdint>
9
10
#include "lib/jxl/base/status.h"
11
#include "lib/jxl/dec_ans.h"
12
#include "lib/jxl/memory_manager_internal.h"
13
14
#undef HWY_TARGET_INCLUDE
15
#define HWY_TARGET_INCLUDE "lib/jxl/enc_ans_simd.cc"
16
#include <hwy/foreach_target.h>
17
#include <hwy/highway.h>
18
19
HWY_BEFORE_NAMESPACE();
20
namespace jxl {
21
namespace HWY_NAMESPACE {
22
23
// These templates are not found via ADL.
24
using hwy::HWY_NAMESPACE::Add;
25
using hwy::HWY_NAMESPACE::And;
26
using hwy::HWY_NAMESPACE::Ge;
27
using hwy::HWY_NAMESPACE::GetLane;
28
using hwy::HWY_NAMESPACE::Gt;
29
using hwy::HWY_NAMESPACE::IfThenElse;
30
using hwy::HWY_NAMESPACE::IfThenElseZero;
31
using hwy::HWY_NAMESPACE::Iota;
32
using hwy::HWY_NAMESPACE::LoadU;
33
using hwy::HWY_NAMESPACE::Lt;
34
using hwy::HWY_NAMESPACE::Mul;
35
using hwy::HWY_NAMESPACE::Or;
36
using hwy::HWY_NAMESPACE::Set;
37
using hwy::HWY_NAMESPACE::ShiftRight;
38
using hwy::HWY_NAMESPACE::Store;
39
using hwy::HWY_NAMESPACE::Sub;
40
using hwy::HWY_NAMESPACE::Zero;
41
42
template <size_t E, size_t M, size_t L>
43
uint32_t EstimateTokenCostImpl(uint32_t* JXL_RESTRICT values, size_t len,
44
831k
                               uint32_t* JXL_RESTRICT out) {
45
831k
  const HWY_FULL(uint32_t) du;
46
831k
  const HWY_FULL(float) df;
47
831k
  const auto kZero = Zero(du);
48
831k
  const auto kSplit = Set(du, 1 << E);
49
831k
  const auto kExpOffset = Set(du, 127);
50
831k
  const auto kEBOffset = Set(du, 127 + M + L);
51
831k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
831k
  const auto kMulN = Set(du, 1 << (M + L));
53
831k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
831k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
831k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
831k
  constexpr size_t kLargeShiftVal = 10;
57
831k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
831k
  auto extra_bits = kZero;
60
831k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
54.0M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
53.2M
    const auto val = LoadU(du, values + i);
63
53.2M
    const auto is_large = Gt(val, kLargeThreshold);
64
53.2M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
53.2M
    const auto not_literal = Ge(val, kSplit);
66
53.2M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
53.2M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
53.2M
    const auto l = And(val, kMaskL);
69
53.2M
    const auto exp = ShiftRight<23>(b);
70
53.2M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
53.2M
    const auto n = Sub(exp_fixed, kExpOffset);
72
53.2M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
53.2M
    const auto m = ShiftRight<23 - M - L>(b);
74
53.2M
    const auto a = Add(kBase, Mul(n, kMulN));
75
53.2M
    const auto d = And(m, kMaskM);
76
53.2M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
53.2M
    const auto c = Or(a, l);
78
53.2M
    extra_bits = Add(extra_bits, eb_fixed);
79
53.2M
    const auto t = Or(c, d);
80
53.2M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
53.2M
    Store(t_fixed, du, out + i);
82
53.2M
  }
83
831k
  if (last_full < len) {
84
723k
    const auto stop = Set(du, len);
85
723k
    const auto fence = Iota(du, last_full);
86
723k
    const auto take = Lt(fence, stop);
87
723k
    const auto val = LoadU(du, values + last_full);
88
723k
    const auto is_large = Gt(val, kLargeThreshold);
89
723k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
723k
    const auto not_literal = Ge(val, kSplit);
91
723k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
723k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
723k
    const auto l = And(val, kMaskL);
94
723k
    const auto exp = ShiftRight<23>(b);
95
723k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
723k
    const auto n = Sub(exp_fixed, kExpOffset);
97
723k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
723k
    const auto m = ShiftRight<23 - M - L>(b);
99
723k
    const auto a = Add(kBase, Mul(n, kMulN));
100
723k
    const auto d = And(m, kMaskM);
101
723k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
723k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
723k
    const auto c = Or(a, l);
104
723k
    extra_bits = Add(extra_bits, eb_masked);
105
723k
    const auto t = Or(c, d);
106
723k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
723k
    Store(t_fixed, du, out + last_full);
108
723k
  }
109
831k
  return GetLane(SumOfLanes(du, extra_bits));
110
831k
}
Unexecuted instantiation: unsigned int jxl::N_SSE4::EstimateTokenCostImpl<0ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE4::EstimateTokenCostImpl<2ul, 0ul, 1ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE4::EstimateTokenCostImpl<3ul, 1ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE4::EstimateTokenCostImpl<3ul, 1ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE4::EstimateTokenCostImpl<3ul, 2ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE4::EstimateTokenCostImpl<3ul, 2ul, 1ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE4::EstimateTokenCostImpl<4ul, 1ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE4::EstimateTokenCostImpl<4ul, 1ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE4::EstimateTokenCostImpl<4ul, 1ul, 3ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE4::EstimateTokenCostImpl<4ul, 2ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE4::EstimateTokenCostImpl<4ul, 2ul, 1ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE4::EstimateTokenCostImpl<4ul, 2ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE4::EstimateTokenCostImpl<5ul, 1ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE4::EstimateTokenCostImpl<5ul, 1ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE4::EstimateTokenCostImpl<5ul, 1ul, 4ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE4::EstimateTokenCostImpl<5ul, 2ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE4::EstimateTokenCostImpl<5ul, 2ul, 1ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE4::EstimateTokenCostImpl<5ul, 2ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE4::EstimateTokenCostImpl<5ul, 2ul, 3ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE4::EstimateTokenCostImpl<6ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE4::EstimateTokenCostImpl<6ul, 1ul, 5ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE4::EstimateTokenCostImpl<6ul, 2ul, 4ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE4::EstimateTokenCostImpl<7ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE4::EstimateTokenCostImpl<8ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE4::EstimateTokenCostImpl<9ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE4::EstimateTokenCostImpl<10ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE4::EstimateTokenCostImpl<11ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE4::EstimateTokenCostImpl<12ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<0ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
96.7k
                               uint32_t* JXL_RESTRICT out) {
45
96.7k
  const HWY_FULL(uint32_t) du;
46
96.7k
  const HWY_FULL(float) df;
47
96.7k
  const auto kZero = Zero(du);
48
96.7k
  const auto kSplit = Set(du, 1 << E);
49
96.7k
  const auto kExpOffset = Set(du, 127);
50
96.7k
  const auto kEBOffset = Set(du, 127 + M + L);
51
96.7k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
96.7k
  const auto kMulN = Set(du, 1 << (M + L));
53
96.7k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
96.7k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
96.7k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
96.7k
  constexpr size_t kLargeShiftVal = 10;
57
96.7k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
96.7k
  auto extra_bits = kZero;
60
96.7k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
8.17M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
8.07M
    const auto val = LoadU(du, values + i);
63
8.07M
    const auto is_large = Gt(val, kLargeThreshold);
64
8.07M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
8.07M
    const auto not_literal = Ge(val, kSplit);
66
8.07M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
8.07M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
8.07M
    const auto l = And(val, kMaskL);
69
8.07M
    const auto exp = ShiftRight<23>(b);
70
8.07M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
8.07M
    const auto n = Sub(exp_fixed, kExpOffset);
72
8.07M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
8.07M
    const auto m = ShiftRight<23 - M - L>(b);
74
8.07M
    const auto a = Add(kBase, Mul(n, kMulN));
75
8.07M
    const auto d = And(m, kMaskM);
76
8.07M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
8.07M
    const auto c = Or(a, l);
78
8.07M
    extra_bits = Add(extra_bits, eb_fixed);
79
8.07M
    const auto t = Or(c, d);
80
8.07M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
8.07M
    Store(t_fixed, du, out + i);
82
8.07M
  }
83
96.7k
  if (last_full < len) {
84
83.7k
    const auto stop = Set(du, len);
85
83.7k
    const auto fence = Iota(du, last_full);
86
83.7k
    const auto take = Lt(fence, stop);
87
83.7k
    const auto val = LoadU(du, values + last_full);
88
83.7k
    const auto is_large = Gt(val, kLargeThreshold);
89
83.7k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
83.7k
    const auto not_literal = Ge(val, kSplit);
91
83.7k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
83.7k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
83.7k
    const auto l = And(val, kMaskL);
94
83.7k
    const auto exp = ShiftRight<23>(b);
95
83.7k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
83.7k
    const auto n = Sub(exp_fixed, kExpOffset);
97
83.7k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
83.7k
    const auto m = ShiftRight<23 - M - L>(b);
99
83.7k
    const auto a = Add(kBase, Mul(n, kMulN));
100
83.7k
    const auto d = And(m, kMaskM);
101
83.7k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
83.7k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
83.7k
    const auto c = Or(a, l);
104
83.7k
    extra_bits = Add(extra_bits, eb_masked);
105
83.7k
    const auto t = Or(c, d);
106
83.7k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
83.7k
    Store(t_fixed, du, out + last_full);
108
83.7k
  }
109
96.7k
  return GetLane(SumOfLanes(du, extra_bits));
110
96.7k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<2ul, 0ul, 1ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
93.8k
                               uint32_t* JXL_RESTRICT out) {
45
93.8k
  const HWY_FULL(uint32_t) du;
46
93.8k
  const HWY_FULL(float) df;
47
93.8k
  const auto kZero = Zero(du);
48
93.8k
  const auto kSplit = Set(du, 1 << E);
49
93.8k
  const auto kExpOffset = Set(du, 127);
50
93.8k
  const auto kEBOffset = Set(du, 127 + M + L);
51
93.8k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
93.8k
  const auto kMulN = Set(du, 1 << (M + L));
53
93.8k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
93.8k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
93.8k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
93.8k
  constexpr size_t kLargeShiftVal = 10;
57
93.8k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
93.8k
  auto extra_bits = kZero;
60
93.8k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
8.16M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
8.07M
    const auto val = LoadU(du, values + i);
63
8.07M
    const auto is_large = Gt(val, kLargeThreshold);
64
8.07M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
8.07M
    const auto not_literal = Ge(val, kSplit);
66
8.07M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
8.07M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
8.07M
    const auto l = And(val, kMaskL);
69
8.07M
    const auto exp = ShiftRight<23>(b);
70
8.07M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
8.07M
    const auto n = Sub(exp_fixed, kExpOffset);
72
8.07M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
8.07M
    const auto m = ShiftRight<23 - M - L>(b);
74
8.07M
    const auto a = Add(kBase, Mul(n, kMulN));
75
8.07M
    const auto d = And(m, kMaskM);
76
8.07M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
8.07M
    const auto c = Or(a, l);
78
8.07M
    extra_bits = Add(extra_bits, eb_fixed);
79
8.07M
    const auto t = Or(c, d);
80
8.07M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
8.07M
    Store(t_fixed, du, out + i);
82
8.07M
  }
83
93.8k
  if (last_full < len) {
84
81.0k
    const auto stop = Set(du, len);
85
81.0k
    const auto fence = Iota(du, last_full);
86
81.0k
    const auto take = Lt(fence, stop);
87
81.0k
    const auto val = LoadU(du, values + last_full);
88
81.0k
    const auto is_large = Gt(val, kLargeThreshold);
89
81.0k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
81.0k
    const auto not_literal = Ge(val, kSplit);
91
81.0k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
81.0k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
81.0k
    const auto l = And(val, kMaskL);
94
81.0k
    const auto exp = ShiftRight<23>(b);
95
81.0k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
81.0k
    const auto n = Sub(exp_fixed, kExpOffset);
97
81.0k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
81.0k
    const auto m = ShiftRight<23 - M - L>(b);
99
81.0k
    const auto a = Add(kBase, Mul(n, kMulN));
100
81.0k
    const auto d = And(m, kMaskM);
101
81.0k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
81.0k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
81.0k
    const auto c = Or(a, l);
104
81.0k
    extra_bits = Add(extra_bits, eb_masked);
105
81.0k
    const auto t = Or(c, d);
106
81.0k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
81.0k
    Store(t_fixed, du, out + last_full);
108
81.0k
  }
109
93.8k
  return GetLane(SumOfLanes(du, extra_bits));
110
93.8k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<3ul, 1ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
20.2k
                               uint32_t* JXL_RESTRICT out) {
45
20.2k
  const HWY_FULL(uint32_t) du;
46
20.2k
  const HWY_FULL(float) df;
47
20.2k
  const auto kZero = Zero(du);
48
20.2k
  const auto kSplit = Set(du, 1 << E);
49
20.2k
  const auto kExpOffset = Set(du, 127);
50
20.2k
  const auto kEBOffset = Set(du, 127 + M + L);
51
20.2k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
20.2k
  const auto kMulN = Set(du, 1 << (M + L));
53
20.2k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
20.2k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
20.2k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
20.2k
  constexpr size_t kLargeShiftVal = 10;
57
20.2k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
20.2k
  auto extra_bits = kZero;
60
20.2k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
1.04M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
1.02M
    const auto val = LoadU(du, values + i);
63
1.02M
    const auto is_large = Gt(val, kLargeThreshold);
64
1.02M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
1.02M
    const auto not_literal = Ge(val, kSplit);
66
1.02M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
1.02M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
1.02M
    const auto l = And(val, kMaskL);
69
1.02M
    const auto exp = ShiftRight<23>(b);
70
1.02M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
1.02M
    const auto n = Sub(exp_fixed, kExpOffset);
72
1.02M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
1.02M
    const auto m = ShiftRight<23 - M - L>(b);
74
1.02M
    const auto a = Add(kBase, Mul(n, kMulN));
75
1.02M
    const auto d = And(m, kMaskM);
76
1.02M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
1.02M
    const auto c = Or(a, l);
78
1.02M
    extra_bits = Add(extra_bits, eb_fixed);
79
1.02M
    const auto t = Or(c, d);
80
1.02M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
1.02M
    Store(t_fixed, du, out + i);
82
1.02M
  }
83
20.2k
  if (last_full < len) {
84
17.6k
    const auto stop = Set(du, len);
85
17.6k
    const auto fence = Iota(du, last_full);
86
17.6k
    const auto take = Lt(fence, stop);
87
17.6k
    const auto val = LoadU(du, values + last_full);
88
17.6k
    const auto is_large = Gt(val, kLargeThreshold);
89
17.6k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
17.6k
    const auto not_literal = Ge(val, kSplit);
91
17.6k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
17.6k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
17.6k
    const auto l = And(val, kMaskL);
94
17.6k
    const auto exp = ShiftRight<23>(b);
95
17.6k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
17.6k
    const auto n = Sub(exp_fixed, kExpOffset);
97
17.6k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
17.6k
    const auto m = ShiftRight<23 - M - L>(b);
99
17.6k
    const auto a = Add(kBase, Mul(n, kMulN));
100
17.6k
    const auto d = And(m, kMaskM);
101
17.6k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
17.6k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
17.6k
    const auto c = Or(a, l);
104
17.6k
    extra_bits = Add(extra_bits, eb_masked);
105
17.6k
    const auto t = Or(c, d);
106
17.6k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
17.6k
    Store(t_fixed, du, out + last_full);
108
17.6k
  }
109
20.2k
  return GetLane(SumOfLanes(du, extra_bits));
110
20.2k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<3ul, 1ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
20.2k
                               uint32_t* JXL_RESTRICT out) {
45
20.2k
  const HWY_FULL(uint32_t) du;
46
20.2k
  const HWY_FULL(float) df;
47
20.2k
  const auto kZero = Zero(du);
48
20.2k
  const auto kSplit = Set(du, 1 << E);
49
20.2k
  const auto kExpOffset = Set(du, 127);
50
20.2k
  const auto kEBOffset = Set(du, 127 + M + L);
51
20.2k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
20.2k
  const auto kMulN = Set(du, 1 << (M + L));
53
20.2k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
20.2k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
20.2k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
20.2k
  constexpr size_t kLargeShiftVal = 10;
57
20.2k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
20.2k
  auto extra_bits = kZero;
60
20.2k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
1.04M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
1.02M
    const auto val = LoadU(du, values + i);
63
1.02M
    const auto is_large = Gt(val, kLargeThreshold);
64
1.02M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
1.02M
    const auto not_literal = Ge(val, kSplit);
66
1.02M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
1.02M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
1.02M
    const auto l = And(val, kMaskL);
69
1.02M
    const auto exp = ShiftRight<23>(b);
70
1.02M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
1.02M
    const auto n = Sub(exp_fixed, kExpOffset);
72
1.02M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
1.02M
    const auto m = ShiftRight<23 - M - L>(b);
74
1.02M
    const auto a = Add(kBase, Mul(n, kMulN));
75
1.02M
    const auto d = And(m, kMaskM);
76
1.02M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
1.02M
    const auto c = Or(a, l);
78
1.02M
    extra_bits = Add(extra_bits, eb_fixed);
79
1.02M
    const auto t = Or(c, d);
80
1.02M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
1.02M
    Store(t_fixed, du, out + i);
82
1.02M
  }
83
20.2k
  if (last_full < len) {
84
17.6k
    const auto stop = Set(du, len);
85
17.6k
    const auto fence = Iota(du, last_full);
86
17.6k
    const auto take = Lt(fence, stop);
87
17.6k
    const auto val = LoadU(du, values + last_full);
88
17.6k
    const auto is_large = Gt(val, kLargeThreshold);
89
17.6k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
17.6k
    const auto not_literal = Ge(val, kSplit);
91
17.6k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
17.6k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
17.6k
    const auto l = And(val, kMaskL);
94
17.6k
    const auto exp = ShiftRight<23>(b);
95
17.6k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
17.6k
    const auto n = Sub(exp_fixed, kExpOffset);
97
17.6k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
17.6k
    const auto m = ShiftRight<23 - M - L>(b);
99
17.6k
    const auto a = Add(kBase, Mul(n, kMulN));
100
17.6k
    const auto d = And(m, kMaskM);
101
17.6k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
17.6k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
17.6k
    const auto c = Or(a, l);
104
17.6k
    extra_bits = Add(extra_bits, eb_masked);
105
17.6k
    const auto t = Or(c, d);
106
17.6k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
17.6k
    Store(t_fixed, du, out + last_full);
108
17.6k
  }
109
20.2k
  return GetLane(SumOfLanes(du, extra_bits));
110
20.2k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<3ul, 2ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
20.2k
                               uint32_t* JXL_RESTRICT out) {
45
20.2k
  const HWY_FULL(uint32_t) du;
46
20.2k
  const HWY_FULL(float) df;
47
20.2k
  const auto kZero = Zero(du);
48
20.2k
  const auto kSplit = Set(du, 1 << E);
49
20.2k
  const auto kExpOffset = Set(du, 127);
50
20.2k
  const auto kEBOffset = Set(du, 127 + M + L);
51
20.2k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
20.2k
  const auto kMulN = Set(du, 1 << (M + L));
53
20.2k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
20.2k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
20.2k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
20.2k
  constexpr size_t kLargeShiftVal = 10;
57
20.2k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
20.2k
  auto extra_bits = kZero;
60
20.2k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
1.04M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
1.02M
    const auto val = LoadU(du, values + i);
63
1.02M
    const auto is_large = Gt(val, kLargeThreshold);
64
1.02M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
1.02M
    const auto not_literal = Ge(val, kSplit);
66
1.02M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
1.02M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
1.02M
    const auto l = And(val, kMaskL);
69
1.02M
    const auto exp = ShiftRight<23>(b);
70
1.02M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
1.02M
    const auto n = Sub(exp_fixed, kExpOffset);
72
1.02M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
1.02M
    const auto m = ShiftRight<23 - M - L>(b);
74
1.02M
    const auto a = Add(kBase, Mul(n, kMulN));
75
1.02M
    const auto d = And(m, kMaskM);
76
1.02M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
1.02M
    const auto c = Or(a, l);
78
1.02M
    extra_bits = Add(extra_bits, eb_fixed);
79
1.02M
    const auto t = Or(c, d);
80
1.02M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
1.02M
    Store(t_fixed, du, out + i);
82
1.02M
  }
83
20.2k
  if (last_full < len) {
84
17.6k
    const auto stop = Set(du, len);
85
17.6k
    const auto fence = Iota(du, last_full);
86
17.6k
    const auto take = Lt(fence, stop);
87
17.6k
    const auto val = LoadU(du, values + last_full);
88
17.6k
    const auto is_large = Gt(val, kLargeThreshold);
89
17.6k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
17.6k
    const auto not_literal = Ge(val, kSplit);
91
17.6k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
17.6k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
17.6k
    const auto l = And(val, kMaskL);
94
17.6k
    const auto exp = ShiftRight<23>(b);
95
17.6k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
17.6k
    const auto n = Sub(exp_fixed, kExpOffset);
97
17.6k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
17.6k
    const auto m = ShiftRight<23 - M - L>(b);
99
17.6k
    const auto a = Add(kBase, Mul(n, kMulN));
100
17.6k
    const auto d = And(m, kMaskM);
101
17.6k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
17.6k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
17.6k
    const auto c = Or(a, l);
104
17.6k
    extra_bits = Add(extra_bits, eb_masked);
105
17.6k
    const auto t = Or(c, d);
106
17.6k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
17.6k
    Store(t_fixed, du, out + last_full);
108
17.6k
  }
109
20.2k
  return GetLane(SumOfLanes(du, extra_bits));
110
20.2k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<3ul, 2ul, 1ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
20.2k
                               uint32_t* JXL_RESTRICT out) {
45
20.2k
  const HWY_FULL(uint32_t) du;
46
20.2k
  const HWY_FULL(float) df;
47
20.2k
  const auto kZero = Zero(du);
48
20.2k
  const auto kSplit = Set(du, 1 << E);
49
20.2k
  const auto kExpOffset = Set(du, 127);
50
20.2k
  const auto kEBOffset = Set(du, 127 + M + L);
51
20.2k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
20.2k
  const auto kMulN = Set(du, 1 << (M + L));
53
20.2k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
20.2k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
20.2k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
20.2k
  constexpr size_t kLargeShiftVal = 10;
57
20.2k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
20.2k
  auto extra_bits = kZero;
60
20.2k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
1.04M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
1.02M
    const auto val = LoadU(du, values + i);
63
1.02M
    const auto is_large = Gt(val, kLargeThreshold);
64
1.02M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
1.02M
    const auto not_literal = Ge(val, kSplit);
66
1.02M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
1.02M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
1.02M
    const auto l = And(val, kMaskL);
69
1.02M
    const auto exp = ShiftRight<23>(b);
70
1.02M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
1.02M
    const auto n = Sub(exp_fixed, kExpOffset);
72
1.02M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
1.02M
    const auto m = ShiftRight<23 - M - L>(b);
74
1.02M
    const auto a = Add(kBase, Mul(n, kMulN));
75
1.02M
    const auto d = And(m, kMaskM);
76
1.02M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
1.02M
    const auto c = Or(a, l);
78
1.02M
    extra_bits = Add(extra_bits, eb_fixed);
79
1.02M
    const auto t = Or(c, d);
80
1.02M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
1.02M
    Store(t_fixed, du, out + i);
82
1.02M
  }
83
20.2k
  if (last_full < len) {
84
17.6k
    const auto stop = Set(du, len);
85
17.6k
    const auto fence = Iota(du, last_full);
86
17.6k
    const auto take = Lt(fence, stop);
87
17.6k
    const auto val = LoadU(du, values + last_full);
88
17.6k
    const auto is_large = Gt(val, kLargeThreshold);
89
17.6k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
17.6k
    const auto not_literal = Ge(val, kSplit);
91
17.6k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
17.6k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
17.6k
    const auto l = And(val, kMaskL);
94
17.6k
    const auto exp = ShiftRight<23>(b);
95
17.6k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
17.6k
    const auto n = Sub(exp_fixed, kExpOffset);
97
17.6k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
17.6k
    const auto m = ShiftRight<23 - M - L>(b);
99
17.6k
    const auto a = Add(kBase, Mul(n, kMulN));
100
17.6k
    const auto d = And(m, kMaskM);
101
17.6k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
17.6k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
17.6k
    const auto c = Or(a, l);
104
17.6k
    extra_bits = Add(extra_bits, eb_masked);
105
17.6k
    const auto t = Or(c, d);
106
17.6k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
17.6k
    Store(t_fixed, du, out + last_full);
108
17.6k
  }
109
20.2k
  return GetLane(SumOfLanes(du, extra_bits));
110
20.2k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<4ul, 1ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
20.2k
                               uint32_t* JXL_RESTRICT out) {
45
20.2k
  const HWY_FULL(uint32_t) du;
46
20.2k
  const HWY_FULL(float) df;
47
20.2k
  const auto kZero = Zero(du);
48
20.2k
  const auto kSplit = Set(du, 1 << E);
49
20.2k
  const auto kExpOffset = Set(du, 127);
50
20.2k
  const auto kEBOffset = Set(du, 127 + M + L);
51
20.2k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
20.2k
  const auto kMulN = Set(du, 1 << (M + L));
53
20.2k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
20.2k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
20.2k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
20.2k
  constexpr size_t kLargeShiftVal = 10;
57
20.2k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
20.2k
  auto extra_bits = kZero;
60
20.2k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
1.04M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
1.02M
    const auto val = LoadU(du, values + i);
63
1.02M
    const auto is_large = Gt(val, kLargeThreshold);
64
1.02M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
1.02M
    const auto not_literal = Ge(val, kSplit);
66
1.02M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
1.02M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
1.02M
    const auto l = And(val, kMaskL);
69
1.02M
    const auto exp = ShiftRight<23>(b);
70
1.02M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
1.02M
    const auto n = Sub(exp_fixed, kExpOffset);
72
1.02M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
1.02M
    const auto m = ShiftRight<23 - M - L>(b);
74
1.02M
    const auto a = Add(kBase, Mul(n, kMulN));
75
1.02M
    const auto d = And(m, kMaskM);
76
1.02M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
1.02M
    const auto c = Or(a, l);
78
1.02M
    extra_bits = Add(extra_bits, eb_fixed);
79
1.02M
    const auto t = Or(c, d);
80
1.02M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
1.02M
    Store(t_fixed, du, out + i);
82
1.02M
  }
83
20.2k
  if (last_full < len) {
84
17.6k
    const auto stop = Set(du, len);
85
17.6k
    const auto fence = Iota(du, last_full);
86
17.6k
    const auto take = Lt(fence, stop);
87
17.6k
    const auto val = LoadU(du, values + last_full);
88
17.6k
    const auto is_large = Gt(val, kLargeThreshold);
89
17.6k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
17.6k
    const auto not_literal = Ge(val, kSplit);
91
17.6k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
17.6k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
17.6k
    const auto l = And(val, kMaskL);
94
17.6k
    const auto exp = ShiftRight<23>(b);
95
17.6k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
17.6k
    const auto n = Sub(exp_fixed, kExpOffset);
97
17.6k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
17.6k
    const auto m = ShiftRight<23 - M - L>(b);
99
17.6k
    const auto a = Add(kBase, Mul(n, kMulN));
100
17.6k
    const auto d = And(m, kMaskM);
101
17.6k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
17.6k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
17.6k
    const auto c = Or(a, l);
104
17.6k
    extra_bits = Add(extra_bits, eb_masked);
105
17.6k
    const auto t = Or(c, d);
106
17.6k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
17.6k
    Store(t_fixed, du, out + last_full);
108
17.6k
  }
109
20.2k
  return GetLane(SumOfLanes(du, extra_bits));
110
20.2k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<4ul, 1ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
93.8k
                               uint32_t* JXL_RESTRICT out) {
45
93.8k
  const HWY_FULL(uint32_t) du;
46
93.8k
  const HWY_FULL(float) df;
47
93.8k
  const auto kZero = Zero(du);
48
93.8k
  const auto kSplit = Set(du, 1 << E);
49
93.8k
  const auto kExpOffset = Set(du, 127);
50
93.8k
  const auto kEBOffset = Set(du, 127 + M + L);
51
93.8k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
93.8k
  const auto kMulN = Set(du, 1 << (M + L));
53
93.8k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
93.8k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
93.8k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
93.8k
  constexpr size_t kLargeShiftVal = 10;
57
93.8k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
93.8k
  auto extra_bits = kZero;
60
93.8k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
8.16M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
8.07M
    const auto val = LoadU(du, values + i);
63
8.07M
    const auto is_large = Gt(val, kLargeThreshold);
64
8.07M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
8.07M
    const auto not_literal = Ge(val, kSplit);
66
8.07M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
8.07M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
8.07M
    const auto l = And(val, kMaskL);
69
8.07M
    const auto exp = ShiftRight<23>(b);
70
8.07M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
8.07M
    const auto n = Sub(exp_fixed, kExpOffset);
72
8.07M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
8.07M
    const auto m = ShiftRight<23 - M - L>(b);
74
8.07M
    const auto a = Add(kBase, Mul(n, kMulN));
75
8.07M
    const auto d = And(m, kMaskM);
76
8.07M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
8.07M
    const auto c = Or(a, l);
78
8.07M
    extra_bits = Add(extra_bits, eb_fixed);
79
8.07M
    const auto t = Or(c, d);
80
8.07M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
8.07M
    Store(t_fixed, du, out + i);
82
8.07M
  }
83
93.8k
  if (last_full < len) {
84
81.0k
    const auto stop = Set(du, len);
85
81.0k
    const auto fence = Iota(du, last_full);
86
81.0k
    const auto take = Lt(fence, stop);
87
81.0k
    const auto val = LoadU(du, values + last_full);
88
81.0k
    const auto is_large = Gt(val, kLargeThreshold);
89
81.0k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
81.0k
    const auto not_literal = Ge(val, kSplit);
91
81.0k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
81.0k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
81.0k
    const auto l = And(val, kMaskL);
94
81.0k
    const auto exp = ShiftRight<23>(b);
95
81.0k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
81.0k
    const auto n = Sub(exp_fixed, kExpOffset);
97
81.0k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
81.0k
    const auto m = ShiftRight<23 - M - L>(b);
99
81.0k
    const auto a = Add(kBase, Mul(n, kMulN));
100
81.0k
    const auto d = And(m, kMaskM);
101
81.0k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
81.0k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
81.0k
    const auto c = Or(a, l);
104
81.0k
    extra_bits = Add(extra_bits, eb_masked);
105
81.0k
    const auto t = Or(c, d);
106
81.0k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
81.0k
    Store(t_fixed, du, out + last_full);
108
81.0k
  }
109
93.8k
  return GetLane(SumOfLanes(du, extra_bits));
110
93.8k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<4ul, 1ul, 3ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
20.2k
                               uint32_t* JXL_RESTRICT out) {
45
20.2k
  const HWY_FULL(uint32_t) du;
46
20.2k
  const HWY_FULL(float) df;
47
20.2k
  const auto kZero = Zero(du);
48
20.2k
  const auto kSplit = Set(du, 1 << E);
49
20.2k
  const auto kExpOffset = Set(du, 127);
50
20.2k
  const auto kEBOffset = Set(du, 127 + M + L);
51
20.2k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
20.2k
  const auto kMulN = Set(du, 1 << (M + L));
53
20.2k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
20.2k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
20.2k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
20.2k
  constexpr size_t kLargeShiftVal = 10;
57
20.2k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
20.2k
  auto extra_bits = kZero;
60
20.2k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
1.04M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
1.02M
    const auto val = LoadU(du, values + i);
63
1.02M
    const auto is_large = Gt(val, kLargeThreshold);
64
1.02M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
1.02M
    const auto not_literal = Ge(val, kSplit);
66
1.02M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
1.02M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
1.02M
    const auto l = And(val, kMaskL);
69
1.02M
    const auto exp = ShiftRight<23>(b);
70
1.02M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
1.02M
    const auto n = Sub(exp_fixed, kExpOffset);
72
1.02M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
1.02M
    const auto m = ShiftRight<23 - M - L>(b);
74
1.02M
    const auto a = Add(kBase, Mul(n, kMulN));
75
1.02M
    const auto d = And(m, kMaskM);
76
1.02M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
1.02M
    const auto c = Or(a, l);
78
1.02M
    extra_bits = Add(extra_bits, eb_fixed);
79
1.02M
    const auto t = Or(c, d);
80
1.02M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
1.02M
    Store(t_fixed, du, out + i);
82
1.02M
  }
83
20.2k
  if (last_full < len) {
84
17.6k
    const auto stop = Set(du, len);
85
17.6k
    const auto fence = Iota(du, last_full);
86
17.6k
    const auto take = Lt(fence, stop);
87
17.6k
    const auto val = LoadU(du, values + last_full);
88
17.6k
    const auto is_large = Gt(val, kLargeThreshold);
89
17.6k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
17.6k
    const auto not_literal = Ge(val, kSplit);
91
17.6k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
17.6k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
17.6k
    const auto l = And(val, kMaskL);
94
17.6k
    const auto exp = ShiftRight<23>(b);
95
17.6k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
17.6k
    const auto n = Sub(exp_fixed, kExpOffset);
97
17.6k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
17.6k
    const auto m = ShiftRight<23 - M - L>(b);
99
17.6k
    const auto a = Add(kBase, Mul(n, kMulN));
100
17.6k
    const auto d = And(m, kMaskM);
101
17.6k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
17.6k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
17.6k
    const auto c = Or(a, l);
104
17.6k
    extra_bits = Add(extra_bits, eb_masked);
105
17.6k
    const auto t = Or(c, d);
106
17.6k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
17.6k
    Store(t_fixed, du, out + last_full);
108
17.6k
  }
109
20.2k
  return GetLane(SumOfLanes(du, extra_bits));
110
20.2k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<4ul, 2ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
93.8k
                               uint32_t* JXL_RESTRICT out) {
45
93.8k
  const HWY_FULL(uint32_t) du;
46
93.8k
  const HWY_FULL(float) df;
47
93.8k
  const auto kZero = Zero(du);
48
93.8k
  const auto kSplit = Set(du, 1 << E);
49
93.8k
  const auto kExpOffset = Set(du, 127);
50
93.8k
  const auto kEBOffset = Set(du, 127 + M + L);
51
93.8k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
93.8k
  const auto kMulN = Set(du, 1 << (M + L));
53
93.8k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
93.8k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
93.8k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
93.8k
  constexpr size_t kLargeShiftVal = 10;
57
93.8k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
93.8k
  auto extra_bits = kZero;
60
93.8k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
8.16M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
8.07M
    const auto val = LoadU(du, values + i);
63
8.07M
    const auto is_large = Gt(val, kLargeThreshold);
64
8.07M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
8.07M
    const auto not_literal = Ge(val, kSplit);
66
8.07M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
8.07M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
8.07M
    const auto l = And(val, kMaskL);
69
8.07M
    const auto exp = ShiftRight<23>(b);
70
8.07M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
8.07M
    const auto n = Sub(exp_fixed, kExpOffset);
72
8.07M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
8.07M
    const auto m = ShiftRight<23 - M - L>(b);
74
8.07M
    const auto a = Add(kBase, Mul(n, kMulN));
75
8.07M
    const auto d = And(m, kMaskM);
76
8.07M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
8.07M
    const auto c = Or(a, l);
78
8.07M
    extra_bits = Add(extra_bits, eb_fixed);
79
8.07M
    const auto t = Or(c, d);
80
8.07M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
8.07M
    Store(t_fixed, du, out + i);
82
8.07M
  }
83
93.8k
  if (last_full < len) {
84
81.0k
    const auto stop = Set(du, len);
85
81.0k
    const auto fence = Iota(du, last_full);
86
81.0k
    const auto take = Lt(fence, stop);
87
81.0k
    const auto val = LoadU(du, values + last_full);
88
81.0k
    const auto is_large = Gt(val, kLargeThreshold);
89
81.0k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
81.0k
    const auto not_literal = Ge(val, kSplit);
91
81.0k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
81.0k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
81.0k
    const auto l = And(val, kMaskL);
94
81.0k
    const auto exp = ShiftRight<23>(b);
95
81.0k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
81.0k
    const auto n = Sub(exp_fixed, kExpOffset);
97
81.0k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
81.0k
    const auto m = ShiftRight<23 - M - L>(b);
99
81.0k
    const auto a = Add(kBase, Mul(n, kMulN));
100
81.0k
    const auto d = And(m, kMaskM);
101
81.0k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
81.0k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
81.0k
    const auto c = Or(a, l);
104
81.0k
    extra_bits = Add(extra_bits, eb_masked);
105
81.0k
    const auto t = Or(c, d);
106
81.0k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
81.0k
    Store(t_fixed, du, out + last_full);
108
81.0k
  }
109
93.8k
  return GetLane(SumOfLanes(du, extra_bits));
110
93.8k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<4ul, 2ul, 1ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
20.2k
                               uint32_t* JXL_RESTRICT out) {
45
20.2k
  const HWY_FULL(uint32_t) du;
46
20.2k
  const HWY_FULL(float) df;
47
20.2k
  const auto kZero = Zero(du);
48
20.2k
  const auto kSplit = Set(du, 1 << E);
49
20.2k
  const auto kExpOffset = Set(du, 127);
50
20.2k
  const auto kEBOffset = Set(du, 127 + M + L);
51
20.2k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
20.2k
  const auto kMulN = Set(du, 1 << (M + L));
53
20.2k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
20.2k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
20.2k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
20.2k
  constexpr size_t kLargeShiftVal = 10;
57
20.2k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
20.2k
  auto extra_bits = kZero;
60
20.2k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
1.04M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
1.02M
    const auto val = LoadU(du, values + i);
63
1.02M
    const auto is_large = Gt(val, kLargeThreshold);
64
1.02M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
1.02M
    const auto not_literal = Ge(val, kSplit);
66
1.02M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
1.02M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
1.02M
    const auto l = And(val, kMaskL);
69
1.02M
    const auto exp = ShiftRight<23>(b);
70
1.02M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
1.02M
    const auto n = Sub(exp_fixed, kExpOffset);
72
1.02M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
1.02M
    const auto m = ShiftRight<23 - M - L>(b);
74
1.02M
    const auto a = Add(kBase, Mul(n, kMulN));
75
1.02M
    const auto d = And(m, kMaskM);
76
1.02M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
1.02M
    const auto c = Or(a, l);
78
1.02M
    extra_bits = Add(extra_bits, eb_fixed);
79
1.02M
    const auto t = Or(c, d);
80
1.02M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
1.02M
    Store(t_fixed, du, out + i);
82
1.02M
  }
83
20.2k
  if (last_full < len) {
84
17.6k
    const auto stop = Set(du, len);
85
17.6k
    const auto fence = Iota(du, last_full);
86
17.6k
    const auto take = Lt(fence, stop);
87
17.6k
    const auto val = LoadU(du, values + last_full);
88
17.6k
    const auto is_large = Gt(val, kLargeThreshold);
89
17.6k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
17.6k
    const auto not_literal = Ge(val, kSplit);
91
17.6k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
17.6k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
17.6k
    const auto l = And(val, kMaskL);
94
17.6k
    const auto exp = ShiftRight<23>(b);
95
17.6k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
17.6k
    const auto n = Sub(exp_fixed, kExpOffset);
97
17.6k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
17.6k
    const auto m = ShiftRight<23 - M - L>(b);
99
17.6k
    const auto a = Add(kBase, Mul(n, kMulN));
100
17.6k
    const auto d = And(m, kMaskM);
101
17.6k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
17.6k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
17.6k
    const auto c = Or(a, l);
104
17.6k
    extra_bits = Add(extra_bits, eb_masked);
105
17.6k
    const auto t = Or(c, d);
106
17.6k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
17.6k
    Store(t_fixed, du, out + last_full);
108
17.6k
  }
109
20.2k
  return GetLane(SumOfLanes(du, extra_bits));
110
20.2k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<4ul, 2ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
20.2k
                               uint32_t* JXL_RESTRICT out) {
45
20.2k
  const HWY_FULL(uint32_t) du;
46
20.2k
  const HWY_FULL(float) df;
47
20.2k
  const auto kZero = Zero(du);
48
20.2k
  const auto kSplit = Set(du, 1 << E);
49
20.2k
  const auto kExpOffset = Set(du, 127);
50
20.2k
  const auto kEBOffset = Set(du, 127 + M + L);
51
20.2k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
20.2k
  const auto kMulN = Set(du, 1 << (M + L));
53
20.2k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
20.2k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
20.2k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
20.2k
  constexpr size_t kLargeShiftVal = 10;
57
20.2k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
20.2k
  auto extra_bits = kZero;
60
20.2k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
1.04M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
1.02M
    const auto val = LoadU(du, values + i);
63
1.02M
    const auto is_large = Gt(val, kLargeThreshold);
64
1.02M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
1.02M
    const auto not_literal = Ge(val, kSplit);
66
1.02M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
1.02M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
1.02M
    const auto l = And(val, kMaskL);
69
1.02M
    const auto exp = ShiftRight<23>(b);
70
1.02M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
1.02M
    const auto n = Sub(exp_fixed, kExpOffset);
72
1.02M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
1.02M
    const auto m = ShiftRight<23 - M - L>(b);
74
1.02M
    const auto a = Add(kBase, Mul(n, kMulN));
75
1.02M
    const auto d = And(m, kMaskM);
76
1.02M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
1.02M
    const auto c = Or(a, l);
78
1.02M
    extra_bits = Add(extra_bits, eb_fixed);
79
1.02M
    const auto t = Or(c, d);
80
1.02M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
1.02M
    Store(t_fixed, du, out + i);
82
1.02M
  }
83
20.2k
  if (last_full < len) {
84
17.6k
    const auto stop = Set(du, len);
85
17.6k
    const auto fence = Iota(du, last_full);
86
17.6k
    const auto take = Lt(fence, stop);
87
17.6k
    const auto val = LoadU(du, values + last_full);
88
17.6k
    const auto is_large = Gt(val, kLargeThreshold);
89
17.6k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
17.6k
    const auto not_literal = Ge(val, kSplit);
91
17.6k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
17.6k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
17.6k
    const auto l = And(val, kMaskL);
94
17.6k
    const auto exp = ShiftRight<23>(b);
95
17.6k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
17.6k
    const auto n = Sub(exp_fixed, kExpOffset);
97
17.6k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
17.6k
    const auto m = ShiftRight<23 - M - L>(b);
99
17.6k
    const auto a = Add(kBase, Mul(n, kMulN));
100
17.6k
    const auto d = And(m, kMaskM);
101
17.6k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
17.6k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
17.6k
    const auto c = Or(a, l);
104
17.6k
    extra_bits = Add(extra_bits, eb_masked);
105
17.6k
    const auto t = Or(c, d);
106
17.6k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
17.6k
    Store(t_fixed, du, out + last_full);
108
17.6k
  }
109
20.2k
  return GetLane(SumOfLanes(du, extra_bits));
110
20.2k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<5ul, 1ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
20.2k
                               uint32_t* JXL_RESTRICT out) {
45
20.2k
  const HWY_FULL(uint32_t) du;
46
20.2k
  const HWY_FULL(float) df;
47
20.2k
  const auto kZero = Zero(du);
48
20.2k
  const auto kSplit = Set(du, 1 << E);
49
20.2k
  const auto kExpOffset = Set(du, 127);
50
20.2k
  const auto kEBOffset = Set(du, 127 + M + L);
51
20.2k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
20.2k
  const auto kMulN = Set(du, 1 << (M + L));
53
20.2k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
20.2k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
20.2k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
20.2k
  constexpr size_t kLargeShiftVal = 10;
57
20.2k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
20.2k
  auto extra_bits = kZero;
60
20.2k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
1.04M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
1.02M
    const auto val = LoadU(du, values + i);
63
1.02M
    const auto is_large = Gt(val, kLargeThreshold);
64
1.02M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
1.02M
    const auto not_literal = Ge(val, kSplit);
66
1.02M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
1.02M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
1.02M
    const auto l = And(val, kMaskL);
69
1.02M
    const auto exp = ShiftRight<23>(b);
70
1.02M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
1.02M
    const auto n = Sub(exp_fixed, kExpOffset);
72
1.02M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
1.02M
    const auto m = ShiftRight<23 - M - L>(b);
74
1.02M
    const auto a = Add(kBase, Mul(n, kMulN));
75
1.02M
    const auto d = And(m, kMaskM);
76
1.02M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
1.02M
    const auto c = Or(a, l);
78
1.02M
    extra_bits = Add(extra_bits, eb_fixed);
79
1.02M
    const auto t = Or(c, d);
80
1.02M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
1.02M
    Store(t_fixed, du, out + i);
82
1.02M
  }
83
20.2k
  if (last_full < len) {
84
17.6k
    const auto stop = Set(du, len);
85
17.6k
    const auto fence = Iota(du, last_full);
86
17.6k
    const auto take = Lt(fence, stop);
87
17.6k
    const auto val = LoadU(du, values + last_full);
88
17.6k
    const auto is_large = Gt(val, kLargeThreshold);
89
17.6k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
17.6k
    const auto not_literal = Ge(val, kSplit);
91
17.6k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
17.6k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
17.6k
    const auto l = And(val, kMaskL);
94
17.6k
    const auto exp = ShiftRight<23>(b);
95
17.6k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
17.6k
    const auto n = Sub(exp_fixed, kExpOffset);
97
17.6k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
17.6k
    const auto m = ShiftRight<23 - M - L>(b);
99
17.6k
    const auto a = Add(kBase, Mul(n, kMulN));
100
17.6k
    const auto d = And(m, kMaskM);
101
17.6k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
17.6k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
17.6k
    const auto c = Or(a, l);
104
17.6k
    extra_bits = Add(extra_bits, eb_masked);
105
17.6k
    const auto t = Or(c, d);
106
17.6k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
17.6k
    Store(t_fixed, du, out + last_full);
108
17.6k
  }
109
20.2k
  return GetLane(SumOfLanes(du, extra_bits));
110
20.2k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<5ul, 1ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
20.2k
                               uint32_t* JXL_RESTRICT out) {
45
20.2k
  const HWY_FULL(uint32_t) du;
46
20.2k
  const HWY_FULL(float) df;
47
20.2k
  const auto kZero = Zero(du);
48
20.2k
  const auto kSplit = Set(du, 1 << E);
49
20.2k
  const auto kExpOffset = Set(du, 127);
50
20.2k
  const auto kEBOffset = Set(du, 127 + M + L);
51
20.2k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
20.2k
  const auto kMulN = Set(du, 1 << (M + L));
53
20.2k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
20.2k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
20.2k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
20.2k
  constexpr size_t kLargeShiftVal = 10;
57
20.2k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
20.2k
  auto extra_bits = kZero;
60
20.2k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
1.04M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
1.02M
    const auto val = LoadU(du, values + i);
63
1.02M
    const auto is_large = Gt(val, kLargeThreshold);
64
1.02M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
1.02M
    const auto not_literal = Ge(val, kSplit);
66
1.02M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
1.02M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
1.02M
    const auto l = And(val, kMaskL);
69
1.02M
    const auto exp = ShiftRight<23>(b);
70
1.02M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
1.02M
    const auto n = Sub(exp_fixed, kExpOffset);
72
1.02M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
1.02M
    const auto m = ShiftRight<23 - M - L>(b);
74
1.02M
    const auto a = Add(kBase, Mul(n, kMulN));
75
1.02M
    const auto d = And(m, kMaskM);
76
1.02M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
1.02M
    const auto c = Or(a, l);
78
1.02M
    extra_bits = Add(extra_bits, eb_fixed);
79
1.02M
    const auto t = Or(c, d);
80
1.02M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
1.02M
    Store(t_fixed, du, out + i);
82
1.02M
  }
83
20.2k
  if (last_full < len) {
84
17.6k
    const auto stop = Set(du, len);
85
17.6k
    const auto fence = Iota(du, last_full);
86
17.6k
    const auto take = Lt(fence, stop);
87
17.6k
    const auto val = LoadU(du, values + last_full);
88
17.6k
    const auto is_large = Gt(val, kLargeThreshold);
89
17.6k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
17.6k
    const auto not_literal = Ge(val, kSplit);
91
17.6k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
17.6k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
17.6k
    const auto l = And(val, kMaskL);
94
17.6k
    const auto exp = ShiftRight<23>(b);
95
17.6k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
17.6k
    const auto n = Sub(exp_fixed, kExpOffset);
97
17.6k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
17.6k
    const auto m = ShiftRight<23 - M - L>(b);
99
17.6k
    const auto a = Add(kBase, Mul(n, kMulN));
100
17.6k
    const auto d = And(m, kMaskM);
101
17.6k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
17.6k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
17.6k
    const auto c = Or(a, l);
104
17.6k
    extra_bits = Add(extra_bits, eb_masked);
105
17.6k
    const auto t = Or(c, d);
106
17.6k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
17.6k
    Store(t_fixed, du, out + last_full);
108
17.6k
  }
109
20.2k
  return GetLane(SumOfLanes(du, extra_bits));
110
20.2k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<5ul, 1ul, 4ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
20.1k
                               uint32_t* JXL_RESTRICT out) {
45
20.1k
  const HWY_FULL(uint32_t) du;
46
20.1k
  const HWY_FULL(float) df;
47
20.1k
  const auto kZero = Zero(du);
48
20.1k
  const auto kSplit = Set(du, 1 << E);
49
20.1k
  const auto kExpOffset = Set(du, 127);
50
20.1k
  const auto kEBOffset = Set(du, 127 + M + L);
51
20.1k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
20.1k
  const auto kMulN = Set(du, 1 << (M + L));
53
20.1k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
20.1k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
20.1k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
20.1k
  constexpr size_t kLargeShiftVal = 10;
57
20.1k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
20.1k
  auto extra_bits = kZero;
60
20.1k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
1.04M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
1.02M
    const auto val = LoadU(du, values + i);
63
1.02M
    const auto is_large = Gt(val, kLargeThreshold);
64
1.02M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
1.02M
    const auto not_literal = Ge(val, kSplit);
66
1.02M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
1.02M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
1.02M
    const auto l = And(val, kMaskL);
69
1.02M
    const auto exp = ShiftRight<23>(b);
70
1.02M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
1.02M
    const auto n = Sub(exp_fixed, kExpOffset);
72
1.02M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
1.02M
    const auto m = ShiftRight<23 - M - L>(b);
74
1.02M
    const auto a = Add(kBase, Mul(n, kMulN));
75
1.02M
    const auto d = And(m, kMaskM);
76
1.02M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
1.02M
    const auto c = Or(a, l);
78
1.02M
    extra_bits = Add(extra_bits, eb_fixed);
79
1.02M
    const auto t = Or(c, d);
80
1.02M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
1.02M
    Store(t_fixed, du, out + i);
82
1.02M
  }
83
20.1k
  if (last_full < len) {
84
17.6k
    const auto stop = Set(du, len);
85
17.6k
    const auto fence = Iota(du, last_full);
86
17.6k
    const auto take = Lt(fence, stop);
87
17.6k
    const auto val = LoadU(du, values + last_full);
88
17.6k
    const auto is_large = Gt(val, kLargeThreshold);
89
17.6k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
17.6k
    const auto not_literal = Ge(val, kSplit);
91
17.6k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
17.6k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
17.6k
    const auto l = And(val, kMaskL);
94
17.6k
    const auto exp = ShiftRight<23>(b);
95
17.6k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
17.6k
    const auto n = Sub(exp_fixed, kExpOffset);
97
17.6k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
17.6k
    const auto m = ShiftRight<23 - M - L>(b);
99
17.6k
    const auto a = Add(kBase, Mul(n, kMulN));
100
17.6k
    const auto d = And(m, kMaskM);
101
17.6k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
17.6k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
17.6k
    const auto c = Or(a, l);
104
17.6k
    extra_bits = Add(extra_bits, eb_masked);
105
17.6k
    const auto t = Or(c, d);
106
17.6k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
17.6k
    Store(t_fixed, du, out + last_full);
108
17.6k
  }
109
20.1k
  return GetLane(SumOfLanes(du, extra_bits));
110
20.1k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<5ul, 2ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
20.2k
                               uint32_t* JXL_RESTRICT out) {
45
20.2k
  const HWY_FULL(uint32_t) du;
46
20.2k
  const HWY_FULL(float) df;
47
20.2k
  const auto kZero = Zero(du);
48
20.2k
  const auto kSplit = Set(du, 1 << E);
49
20.2k
  const auto kExpOffset = Set(du, 127);
50
20.2k
  const auto kEBOffset = Set(du, 127 + M + L);
51
20.2k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
20.2k
  const auto kMulN = Set(du, 1 << (M + L));
53
20.2k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
20.2k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
20.2k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
20.2k
  constexpr size_t kLargeShiftVal = 10;
57
20.2k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
20.2k
  auto extra_bits = kZero;
60
20.2k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
1.04M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
1.02M
    const auto val = LoadU(du, values + i);
63
1.02M
    const auto is_large = Gt(val, kLargeThreshold);
64
1.02M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
1.02M
    const auto not_literal = Ge(val, kSplit);
66
1.02M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
1.02M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
1.02M
    const auto l = And(val, kMaskL);
69
1.02M
    const auto exp = ShiftRight<23>(b);
70
1.02M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
1.02M
    const auto n = Sub(exp_fixed, kExpOffset);
72
1.02M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
1.02M
    const auto m = ShiftRight<23 - M - L>(b);
74
1.02M
    const auto a = Add(kBase, Mul(n, kMulN));
75
1.02M
    const auto d = And(m, kMaskM);
76
1.02M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
1.02M
    const auto c = Or(a, l);
78
1.02M
    extra_bits = Add(extra_bits, eb_fixed);
79
1.02M
    const auto t = Or(c, d);
80
1.02M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
1.02M
    Store(t_fixed, du, out + i);
82
1.02M
  }
83
20.2k
  if (last_full < len) {
84
17.6k
    const auto stop = Set(du, len);
85
17.6k
    const auto fence = Iota(du, last_full);
86
17.6k
    const auto take = Lt(fence, stop);
87
17.6k
    const auto val = LoadU(du, values + last_full);
88
17.6k
    const auto is_large = Gt(val, kLargeThreshold);
89
17.6k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
17.6k
    const auto not_literal = Ge(val, kSplit);
91
17.6k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
17.6k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
17.6k
    const auto l = And(val, kMaskL);
94
17.6k
    const auto exp = ShiftRight<23>(b);
95
17.6k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
17.6k
    const auto n = Sub(exp_fixed, kExpOffset);
97
17.6k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
17.6k
    const auto m = ShiftRight<23 - M - L>(b);
99
17.6k
    const auto a = Add(kBase, Mul(n, kMulN));
100
17.6k
    const auto d = And(m, kMaskM);
101
17.6k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
17.6k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
17.6k
    const auto c = Or(a, l);
104
17.6k
    extra_bits = Add(extra_bits, eb_masked);
105
17.6k
    const auto t = Or(c, d);
106
17.6k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
17.6k
    Store(t_fixed, du, out + last_full);
108
17.6k
  }
109
20.2k
  return GetLane(SumOfLanes(du, extra_bits));
110
20.2k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<5ul, 2ul, 1ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
20.2k
                               uint32_t* JXL_RESTRICT out) {
45
20.2k
  const HWY_FULL(uint32_t) du;
46
20.2k
  const HWY_FULL(float) df;
47
20.2k
  const auto kZero = Zero(du);
48
20.2k
  const auto kSplit = Set(du, 1 << E);
49
20.2k
  const auto kExpOffset = Set(du, 127);
50
20.2k
  const auto kEBOffset = Set(du, 127 + M + L);
51
20.2k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
20.2k
  const auto kMulN = Set(du, 1 << (M + L));
53
20.2k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
20.2k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
20.2k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
20.2k
  constexpr size_t kLargeShiftVal = 10;
57
20.2k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
20.2k
  auto extra_bits = kZero;
60
20.2k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
1.04M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
1.02M
    const auto val = LoadU(du, values + i);
63
1.02M
    const auto is_large = Gt(val, kLargeThreshold);
64
1.02M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
1.02M
    const auto not_literal = Ge(val, kSplit);
66
1.02M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
1.02M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
1.02M
    const auto l = And(val, kMaskL);
69
1.02M
    const auto exp = ShiftRight<23>(b);
70
1.02M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
1.02M
    const auto n = Sub(exp_fixed, kExpOffset);
72
1.02M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
1.02M
    const auto m = ShiftRight<23 - M - L>(b);
74
1.02M
    const auto a = Add(kBase, Mul(n, kMulN));
75
1.02M
    const auto d = And(m, kMaskM);
76
1.02M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
1.02M
    const auto c = Or(a, l);
78
1.02M
    extra_bits = Add(extra_bits, eb_fixed);
79
1.02M
    const auto t = Or(c, d);
80
1.02M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
1.02M
    Store(t_fixed, du, out + i);
82
1.02M
  }
83
20.2k
  if (last_full < len) {
84
17.6k
    const auto stop = Set(du, len);
85
17.6k
    const auto fence = Iota(du, last_full);
86
17.6k
    const auto take = Lt(fence, stop);
87
17.6k
    const auto val = LoadU(du, values + last_full);
88
17.6k
    const auto is_large = Gt(val, kLargeThreshold);
89
17.6k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
17.6k
    const auto not_literal = Ge(val, kSplit);
91
17.6k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
17.6k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
17.6k
    const auto l = And(val, kMaskL);
94
17.6k
    const auto exp = ShiftRight<23>(b);
95
17.6k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
17.6k
    const auto n = Sub(exp_fixed, kExpOffset);
97
17.6k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
17.6k
    const auto m = ShiftRight<23 - M - L>(b);
99
17.6k
    const auto a = Add(kBase, Mul(n, kMulN));
100
17.6k
    const auto d = And(m, kMaskM);
101
17.6k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
17.6k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
17.6k
    const auto c = Or(a, l);
104
17.6k
    extra_bits = Add(extra_bits, eb_masked);
105
17.6k
    const auto t = Or(c, d);
106
17.6k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
17.6k
    Store(t_fixed, du, out + last_full);
108
17.6k
  }
109
20.2k
  return GetLane(SumOfLanes(du, extra_bits));
110
20.2k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<5ul, 2ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
20.2k
                               uint32_t* JXL_RESTRICT out) {
45
20.2k
  const HWY_FULL(uint32_t) du;
46
20.2k
  const HWY_FULL(float) df;
47
20.2k
  const auto kZero = Zero(du);
48
20.2k
  const auto kSplit = Set(du, 1 << E);
49
20.2k
  const auto kExpOffset = Set(du, 127);
50
20.2k
  const auto kEBOffset = Set(du, 127 + M + L);
51
20.2k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
20.2k
  const auto kMulN = Set(du, 1 << (M + L));
53
20.2k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
20.2k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
20.2k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
20.2k
  constexpr size_t kLargeShiftVal = 10;
57
20.2k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
20.2k
  auto extra_bits = kZero;
60
20.2k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
1.04M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
1.02M
    const auto val = LoadU(du, values + i);
63
1.02M
    const auto is_large = Gt(val, kLargeThreshold);
64
1.02M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
1.02M
    const auto not_literal = Ge(val, kSplit);
66
1.02M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
1.02M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
1.02M
    const auto l = And(val, kMaskL);
69
1.02M
    const auto exp = ShiftRight<23>(b);
70
1.02M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
1.02M
    const auto n = Sub(exp_fixed, kExpOffset);
72
1.02M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
1.02M
    const auto m = ShiftRight<23 - M - L>(b);
74
1.02M
    const auto a = Add(kBase, Mul(n, kMulN));
75
1.02M
    const auto d = And(m, kMaskM);
76
1.02M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
1.02M
    const auto c = Or(a, l);
78
1.02M
    extra_bits = Add(extra_bits, eb_fixed);
79
1.02M
    const auto t = Or(c, d);
80
1.02M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
1.02M
    Store(t_fixed, du, out + i);
82
1.02M
  }
83
20.2k
  if (last_full < len) {
84
17.6k
    const auto stop = Set(du, len);
85
17.6k
    const auto fence = Iota(du, last_full);
86
17.6k
    const auto take = Lt(fence, stop);
87
17.6k
    const auto val = LoadU(du, values + last_full);
88
17.6k
    const auto is_large = Gt(val, kLargeThreshold);
89
17.6k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
17.6k
    const auto not_literal = Ge(val, kSplit);
91
17.6k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
17.6k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
17.6k
    const auto l = And(val, kMaskL);
94
17.6k
    const auto exp = ShiftRight<23>(b);
95
17.6k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
17.6k
    const auto n = Sub(exp_fixed, kExpOffset);
97
17.6k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
17.6k
    const auto m = ShiftRight<23 - M - L>(b);
99
17.6k
    const auto a = Add(kBase, Mul(n, kMulN));
100
17.6k
    const auto d = And(m, kMaskM);
101
17.6k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
17.6k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
17.6k
    const auto c = Or(a, l);
104
17.6k
    extra_bits = Add(extra_bits, eb_masked);
105
17.6k
    const auto t = Or(c, d);
106
17.6k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
17.6k
    Store(t_fixed, du, out + last_full);
108
17.6k
  }
109
20.2k
  return GetLane(SumOfLanes(du, extra_bits));
110
20.2k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<5ul, 2ul, 3ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
20.1k
                               uint32_t* JXL_RESTRICT out) {
45
20.1k
  const HWY_FULL(uint32_t) du;
46
20.1k
  const HWY_FULL(float) df;
47
20.1k
  const auto kZero = Zero(du);
48
20.1k
  const auto kSplit = Set(du, 1 << E);
49
20.1k
  const auto kExpOffset = Set(du, 127);
50
20.1k
  const auto kEBOffset = Set(du, 127 + M + L);
51
20.1k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
20.1k
  const auto kMulN = Set(du, 1 << (M + L));
53
20.1k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
20.1k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
20.1k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
20.1k
  constexpr size_t kLargeShiftVal = 10;
57
20.1k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
20.1k
  auto extra_bits = kZero;
60
20.1k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
1.04M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
1.02M
    const auto val = LoadU(du, values + i);
63
1.02M
    const auto is_large = Gt(val, kLargeThreshold);
64
1.02M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
1.02M
    const auto not_literal = Ge(val, kSplit);
66
1.02M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
1.02M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
1.02M
    const auto l = And(val, kMaskL);
69
1.02M
    const auto exp = ShiftRight<23>(b);
70
1.02M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
1.02M
    const auto n = Sub(exp_fixed, kExpOffset);
72
1.02M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
1.02M
    const auto m = ShiftRight<23 - M - L>(b);
74
1.02M
    const auto a = Add(kBase, Mul(n, kMulN));
75
1.02M
    const auto d = And(m, kMaskM);
76
1.02M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
1.02M
    const auto c = Or(a, l);
78
1.02M
    extra_bits = Add(extra_bits, eb_fixed);
79
1.02M
    const auto t = Or(c, d);
80
1.02M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
1.02M
    Store(t_fixed, du, out + i);
82
1.02M
  }
83
20.1k
  if (last_full < len) {
84
17.6k
    const auto stop = Set(du, len);
85
17.6k
    const auto fence = Iota(du, last_full);
86
17.6k
    const auto take = Lt(fence, stop);
87
17.6k
    const auto val = LoadU(du, values + last_full);
88
17.6k
    const auto is_large = Gt(val, kLargeThreshold);
89
17.6k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
17.6k
    const auto not_literal = Ge(val, kSplit);
91
17.6k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
17.6k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
17.6k
    const auto l = And(val, kMaskL);
94
17.6k
    const auto exp = ShiftRight<23>(b);
95
17.6k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
17.6k
    const auto n = Sub(exp_fixed, kExpOffset);
97
17.6k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
17.6k
    const auto m = ShiftRight<23 - M - L>(b);
99
17.6k
    const auto a = Add(kBase, Mul(n, kMulN));
100
17.6k
    const auto d = And(m, kMaskM);
101
17.6k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
17.6k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
17.6k
    const auto c = Or(a, l);
104
17.6k
    extra_bits = Add(extra_bits, eb_masked);
105
17.6k
    const auto t = Or(c, d);
106
17.6k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
17.6k
    Store(t_fixed, du, out + last_full);
108
17.6k
  }
109
20.1k
  return GetLane(SumOfLanes(du, extra_bits));
110
20.1k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<6ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
20.2k
                               uint32_t* JXL_RESTRICT out) {
45
20.2k
  const HWY_FULL(uint32_t) du;
46
20.2k
  const HWY_FULL(float) df;
47
20.2k
  const auto kZero = Zero(du);
48
20.2k
  const auto kSplit = Set(du, 1 << E);
49
20.2k
  const auto kExpOffset = Set(du, 127);
50
20.2k
  const auto kEBOffset = Set(du, 127 + M + L);
51
20.2k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
20.2k
  const auto kMulN = Set(du, 1 << (M + L));
53
20.2k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
20.2k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
20.2k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
20.2k
  constexpr size_t kLargeShiftVal = 10;
57
20.2k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
20.2k
  auto extra_bits = kZero;
60
20.2k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
1.04M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
1.02M
    const auto val = LoadU(du, values + i);
63
1.02M
    const auto is_large = Gt(val, kLargeThreshold);
64
1.02M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
1.02M
    const auto not_literal = Ge(val, kSplit);
66
1.02M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
1.02M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
1.02M
    const auto l = And(val, kMaskL);
69
1.02M
    const auto exp = ShiftRight<23>(b);
70
1.02M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
1.02M
    const auto n = Sub(exp_fixed, kExpOffset);
72
1.02M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
1.02M
    const auto m = ShiftRight<23 - M - L>(b);
74
1.02M
    const auto a = Add(kBase, Mul(n, kMulN));
75
1.02M
    const auto d = And(m, kMaskM);
76
1.02M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
1.02M
    const auto c = Or(a, l);
78
1.02M
    extra_bits = Add(extra_bits, eb_fixed);
79
1.02M
    const auto t = Or(c, d);
80
1.02M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
1.02M
    Store(t_fixed, du, out + i);
82
1.02M
  }
83
20.2k
  if (last_full < len) {
84
17.6k
    const auto stop = Set(du, len);
85
17.6k
    const auto fence = Iota(du, last_full);
86
17.6k
    const auto take = Lt(fence, stop);
87
17.6k
    const auto val = LoadU(du, values + last_full);
88
17.6k
    const auto is_large = Gt(val, kLargeThreshold);
89
17.6k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
17.6k
    const auto not_literal = Ge(val, kSplit);
91
17.6k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
17.6k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
17.6k
    const auto l = And(val, kMaskL);
94
17.6k
    const auto exp = ShiftRight<23>(b);
95
17.6k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
17.6k
    const auto n = Sub(exp_fixed, kExpOffset);
97
17.6k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
17.6k
    const auto m = ShiftRight<23 - M - L>(b);
99
17.6k
    const auto a = Add(kBase, Mul(n, kMulN));
100
17.6k
    const auto d = And(m, kMaskM);
101
17.6k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
17.6k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
17.6k
    const auto c = Or(a, l);
104
17.6k
    extra_bits = Add(extra_bits, eb_masked);
105
17.6k
    const auto t = Or(c, d);
106
17.6k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
17.6k
    Store(t_fixed, du, out + last_full);
108
17.6k
  }
109
20.2k
  return GetLane(SumOfLanes(du, extra_bits));
110
20.2k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<6ul, 1ul, 5ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
17.3k
                               uint32_t* JXL_RESTRICT out) {
45
17.3k
  const HWY_FULL(uint32_t) du;
46
17.3k
  const HWY_FULL(float) df;
47
17.3k
  const auto kZero = Zero(du);
48
17.3k
  const auto kSplit = Set(du, 1 << E);
49
17.3k
  const auto kExpOffset = Set(du, 127);
50
17.3k
  const auto kEBOffset = Set(du, 127 + M + L);
51
17.3k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
17.3k
  const auto kMulN = Set(du, 1 << (M + L));
53
17.3k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
17.3k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
17.3k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
17.3k
  constexpr size_t kLargeShiftVal = 10;
57
17.3k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
17.3k
  auto extra_bits = kZero;
60
17.3k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
570k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
552k
    const auto val = LoadU(du, values + i);
63
552k
    const auto is_large = Gt(val, kLargeThreshold);
64
552k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
552k
    const auto not_literal = Ge(val, kSplit);
66
552k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
552k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
552k
    const auto l = And(val, kMaskL);
69
552k
    const auto exp = ShiftRight<23>(b);
70
552k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
552k
    const auto n = Sub(exp_fixed, kExpOffset);
72
552k
    const auto eb = Sub(exp_fixed, kEBOffset);
73
552k
    const auto m = ShiftRight<23 - M - L>(b);
74
552k
    const auto a = Add(kBase, Mul(n, kMulN));
75
552k
    const auto d = And(m, kMaskM);
76
552k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
552k
    const auto c = Or(a, l);
78
552k
    extra_bits = Add(extra_bits, eb_fixed);
79
552k
    const auto t = Or(c, d);
80
552k
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
552k
    Store(t_fixed, du, out + i);
82
552k
  }
83
17.3k
  if (last_full < len) {
84
15.2k
    const auto stop = Set(du, len);
85
15.2k
    const auto fence = Iota(du, last_full);
86
15.2k
    const auto take = Lt(fence, stop);
87
15.2k
    const auto val = LoadU(du, values + last_full);
88
15.2k
    const auto is_large = Gt(val, kLargeThreshold);
89
15.2k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
15.2k
    const auto not_literal = Ge(val, kSplit);
91
15.2k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
15.2k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
15.2k
    const auto l = And(val, kMaskL);
94
15.2k
    const auto exp = ShiftRight<23>(b);
95
15.2k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
15.2k
    const auto n = Sub(exp_fixed, kExpOffset);
97
15.2k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
15.2k
    const auto m = ShiftRight<23 - M - L>(b);
99
15.2k
    const auto a = Add(kBase, Mul(n, kMulN));
100
15.2k
    const auto d = And(m, kMaskM);
101
15.2k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
15.2k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
15.2k
    const auto c = Or(a, l);
104
15.2k
    extra_bits = Add(extra_bits, eb_masked);
105
15.2k
    const auto t = Or(c, d);
106
15.2k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
15.2k
    Store(t_fixed, du, out + last_full);
108
15.2k
  }
109
17.3k
  return GetLane(SumOfLanes(du, extra_bits));
110
17.3k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<6ul, 2ul, 4ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
17.3k
                               uint32_t* JXL_RESTRICT out) {
45
17.3k
  const HWY_FULL(uint32_t) du;
46
17.3k
  const HWY_FULL(float) df;
47
17.3k
  const auto kZero = Zero(du);
48
17.3k
  const auto kSplit = Set(du, 1 << E);
49
17.3k
  const auto kExpOffset = Set(du, 127);
50
17.3k
  const auto kEBOffset = Set(du, 127 + M + L);
51
17.3k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
17.3k
  const auto kMulN = Set(du, 1 << (M + L));
53
17.3k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
17.3k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
17.3k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
17.3k
  constexpr size_t kLargeShiftVal = 10;
57
17.3k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
17.3k
  auto extra_bits = kZero;
60
17.3k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
570k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
552k
    const auto val = LoadU(du, values + i);
63
552k
    const auto is_large = Gt(val, kLargeThreshold);
64
552k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
552k
    const auto not_literal = Ge(val, kSplit);
66
552k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
552k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
552k
    const auto l = And(val, kMaskL);
69
552k
    const auto exp = ShiftRight<23>(b);
70
552k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
552k
    const auto n = Sub(exp_fixed, kExpOffset);
72
552k
    const auto eb = Sub(exp_fixed, kEBOffset);
73
552k
    const auto m = ShiftRight<23 - M - L>(b);
74
552k
    const auto a = Add(kBase, Mul(n, kMulN));
75
552k
    const auto d = And(m, kMaskM);
76
552k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
552k
    const auto c = Or(a, l);
78
552k
    extra_bits = Add(extra_bits, eb_fixed);
79
552k
    const auto t = Or(c, d);
80
552k
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
552k
    Store(t_fixed, du, out + i);
82
552k
  }
83
17.3k
  if (last_full < len) {
84
15.2k
    const auto stop = Set(du, len);
85
15.2k
    const auto fence = Iota(du, last_full);
86
15.2k
    const auto take = Lt(fence, stop);
87
15.2k
    const auto val = LoadU(du, values + last_full);
88
15.2k
    const auto is_large = Gt(val, kLargeThreshold);
89
15.2k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
15.2k
    const auto not_literal = Ge(val, kSplit);
91
15.2k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
15.2k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
15.2k
    const auto l = And(val, kMaskL);
94
15.2k
    const auto exp = ShiftRight<23>(b);
95
15.2k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
15.2k
    const auto n = Sub(exp_fixed, kExpOffset);
97
15.2k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
15.2k
    const auto m = ShiftRight<23 - M - L>(b);
99
15.2k
    const auto a = Add(kBase, Mul(n, kMulN));
100
15.2k
    const auto d = And(m, kMaskM);
101
15.2k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
15.2k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
15.2k
    const auto c = Or(a, l);
104
15.2k
    extra_bits = Add(extra_bits, eb_masked);
105
15.2k
    const auto t = Or(c, d);
106
15.2k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
15.2k
    Store(t_fixed, du, out + last_full);
108
15.2k
  }
109
17.3k
  return GetLane(SumOfLanes(du, extra_bits));
110
17.3k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<7ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
20.2k
                               uint32_t* JXL_RESTRICT out) {
45
20.2k
  const HWY_FULL(uint32_t) du;
46
20.2k
  const HWY_FULL(float) df;
47
20.2k
  const auto kZero = Zero(du);
48
20.2k
  const auto kSplit = Set(du, 1 << E);
49
20.2k
  const auto kExpOffset = Set(du, 127);
50
20.2k
  const auto kEBOffset = Set(du, 127 + M + L);
51
20.2k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
20.2k
  const auto kMulN = Set(du, 1 << (M + L));
53
20.2k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
20.2k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
20.2k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
20.2k
  constexpr size_t kLargeShiftVal = 10;
57
20.2k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
20.2k
  auto extra_bits = kZero;
60
20.2k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
1.04M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
1.02M
    const auto val = LoadU(du, values + i);
63
1.02M
    const auto is_large = Gt(val, kLargeThreshold);
64
1.02M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
1.02M
    const auto not_literal = Ge(val, kSplit);
66
1.02M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
1.02M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
1.02M
    const auto l = And(val, kMaskL);
69
1.02M
    const auto exp = ShiftRight<23>(b);
70
1.02M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
1.02M
    const auto n = Sub(exp_fixed, kExpOffset);
72
1.02M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
1.02M
    const auto m = ShiftRight<23 - M - L>(b);
74
1.02M
    const auto a = Add(kBase, Mul(n, kMulN));
75
1.02M
    const auto d = And(m, kMaskM);
76
1.02M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
1.02M
    const auto c = Or(a, l);
78
1.02M
    extra_bits = Add(extra_bits, eb_fixed);
79
1.02M
    const auto t = Or(c, d);
80
1.02M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
1.02M
    Store(t_fixed, du, out + i);
82
1.02M
  }
83
20.2k
  if (last_full < len) {
84
17.6k
    const auto stop = Set(du, len);
85
17.6k
    const auto fence = Iota(du, last_full);
86
17.6k
    const auto take = Lt(fence, stop);
87
17.6k
    const auto val = LoadU(du, values + last_full);
88
17.6k
    const auto is_large = Gt(val, kLargeThreshold);
89
17.6k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
17.6k
    const auto not_literal = Ge(val, kSplit);
91
17.6k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
17.6k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
17.6k
    const auto l = And(val, kMaskL);
94
17.6k
    const auto exp = ShiftRight<23>(b);
95
17.6k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
17.6k
    const auto n = Sub(exp_fixed, kExpOffset);
97
17.6k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
17.6k
    const auto m = ShiftRight<23 - M - L>(b);
99
17.6k
    const auto a = Add(kBase, Mul(n, kMulN));
100
17.6k
    const auto d = And(m, kMaskM);
101
17.6k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
17.6k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
17.6k
    const auto c = Or(a, l);
104
17.6k
    extra_bits = Add(extra_bits, eb_masked);
105
17.6k
    const auto t = Or(c, d);
106
17.6k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
17.6k
    Store(t_fixed, du, out + last_full);
108
17.6k
  }
109
20.2k
  return GetLane(SumOfLanes(du, extra_bits));
110
20.2k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<8ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
15.0k
                               uint32_t* JXL_RESTRICT out) {
45
15.0k
  const HWY_FULL(uint32_t) du;
46
15.0k
  const HWY_FULL(float) df;
47
15.0k
  const auto kZero = Zero(du);
48
15.0k
  const auto kSplit = Set(du, 1 << E);
49
15.0k
  const auto kExpOffset = Set(du, 127);
50
15.0k
  const auto kEBOffset = Set(du, 127 + M + L);
51
15.0k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
15.0k
  const auto kMulN = Set(du, 1 << (M + L));
53
15.0k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
15.0k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
15.0k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
15.0k
  constexpr size_t kLargeShiftVal = 10;
57
15.0k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
15.0k
  auto extra_bits = kZero;
60
15.0k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
494k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
479k
    const auto val = LoadU(du, values + i);
63
479k
    const auto is_large = Gt(val, kLargeThreshold);
64
479k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
479k
    const auto not_literal = Ge(val, kSplit);
66
479k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
479k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
479k
    const auto l = And(val, kMaskL);
69
479k
    const auto exp = ShiftRight<23>(b);
70
479k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
479k
    const auto n = Sub(exp_fixed, kExpOffset);
72
479k
    const auto eb = Sub(exp_fixed, kEBOffset);
73
479k
    const auto m = ShiftRight<23 - M - L>(b);
74
479k
    const auto a = Add(kBase, Mul(n, kMulN));
75
479k
    const auto d = And(m, kMaskM);
76
479k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
479k
    const auto c = Or(a, l);
78
479k
    extra_bits = Add(extra_bits, eb_fixed);
79
479k
    const auto t = Or(c, d);
80
479k
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
479k
    Store(t_fixed, du, out + i);
82
479k
  }
83
15.0k
  if (last_full < len) {
84
13.1k
    const auto stop = Set(du, len);
85
13.1k
    const auto fence = Iota(du, last_full);
86
13.1k
    const auto take = Lt(fence, stop);
87
13.1k
    const auto val = LoadU(du, values + last_full);
88
13.1k
    const auto is_large = Gt(val, kLargeThreshold);
89
13.1k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
13.1k
    const auto not_literal = Ge(val, kSplit);
91
13.1k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
13.1k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
13.1k
    const auto l = And(val, kMaskL);
94
13.1k
    const auto exp = ShiftRight<23>(b);
95
13.1k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
13.1k
    const auto n = Sub(exp_fixed, kExpOffset);
97
13.1k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
13.1k
    const auto m = ShiftRight<23 - M - L>(b);
99
13.1k
    const auto a = Add(kBase, Mul(n, kMulN));
100
13.1k
    const auto d = And(m, kMaskM);
101
13.1k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
13.1k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
13.1k
    const auto c = Or(a, l);
104
13.1k
    extra_bits = Add(extra_bits, eb_masked);
105
13.1k
    const auto t = Or(c, d);
106
13.1k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
13.1k
    Store(t_fixed, du, out + last_full);
108
13.1k
  }
109
15.0k
  return GetLane(SumOfLanes(du, extra_bits));
110
15.0k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<9ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
15.0k
                               uint32_t* JXL_RESTRICT out) {
45
15.0k
  const HWY_FULL(uint32_t) du;
46
15.0k
  const HWY_FULL(float) df;
47
15.0k
  const auto kZero = Zero(du);
48
15.0k
  const auto kSplit = Set(du, 1 << E);
49
15.0k
  const auto kExpOffset = Set(du, 127);
50
15.0k
  const auto kEBOffset = Set(du, 127 + M + L);
51
15.0k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
15.0k
  const auto kMulN = Set(du, 1 << (M + L));
53
15.0k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
15.0k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
15.0k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
15.0k
  constexpr size_t kLargeShiftVal = 10;
57
15.0k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
15.0k
  auto extra_bits = kZero;
60
15.0k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
494k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
479k
    const auto val = LoadU(du, values + i);
63
479k
    const auto is_large = Gt(val, kLargeThreshold);
64
479k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
479k
    const auto not_literal = Ge(val, kSplit);
66
479k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
479k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
479k
    const auto l = And(val, kMaskL);
69
479k
    const auto exp = ShiftRight<23>(b);
70
479k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
479k
    const auto n = Sub(exp_fixed, kExpOffset);
72
479k
    const auto eb = Sub(exp_fixed, kEBOffset);
73
479k
    const auto m = ShiftRight<23 - M - L>(b);
74
479k
    const auto a = Add(kBase, Mul(n, kMulN));
75
479k
    const auto d = And(m, kMaskM);
76
479k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
479k
    const auto c = Or(a, l);
78
479k
    extra_bits = Add(extra_bits, eb_fixed);
79
479k
    const auto t = Or(c, d);
80
479k
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
479k
    Store(t_fixed, du, out + i);
82
479k
  }
83
15.0k
  if (last_full < len) {
84
13.1k
    const auto stop = Set(du, len);
85
13.1k
    const auto fence = Iota(du, last_full);
86
13.1k
    const auto take = Lt(fence, stop);
87
13.1k
    const auto val = LoadU(du, values + last_full);
88
13.1k
    const auto is_large = Gt(val, kLargeThreshold);
89
13.1k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
13.1k
    const auto not_literal = Ge(val, kSplit);
91
13.1k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
13.1k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
13.1k
    const auto l = And(val, kMaskL);
94
13.1k
    const auto exp = ShiftRight<23>(b);
95
13.1k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
13.1k
    const auto n = Sub(exp_fixed, kExpOffset);
97
13.1k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
13.1k
    const auto m = ShiftRight<23 - M - L>(b);
99
13.1k
    const auto a = Add(kBase, Mul(n, kMulN));
100
13.1k
    const auto d = And(m, kMaskM);
101
13.1k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
13.1k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
13.1k
    const auto c = Or(a, l);
104
13.1k
    extra_bits = Add(extra_bits, eb_masked);
105
13.1k
    const auto t = Or(c, d);
106
13.1k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
13.1k
    Store(t_fixed, du, out + last_full);
108
13.1k
  }
109
15.0k
  return GetLane(SumOfLanes(du, extra_bits));
110
15.0k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<10ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
15.0k
                               uint32_t* JXL_RESTRICT out) {
45
15.0k
  const HWY_FULL(uint32_t) du;
46
15.0k
  const HWY_FULL(float) df;
47
15.0k
  const auto kZero = Zero(du);
48
15.0k
  const auto kSplit = Set(du, 1 << E);
49
15.0k
  const auto kExpOffset = Set(du, 127);
50
15.0k
  const auto kEBOffset = Set(du, 127 + M + L);
51
15.0k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
15.0k
  const auto kMulN = Set(du, 1 << (M + L));
53
15.0k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
15.0k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
15.0k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
15.0k
  constexpr size_t kLargeShiftVal = 10;
57
15.0k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
15.0k
  auto extra_bits = kZero;
60
15.0k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
494k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
479k
    const auto val = LoadU(du, values + i);
63
479k
    const auto is_large = Gt(val, kLargeThreshold);
64
479k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
479k
    const auto not_literal = Ge(val, kSplit);
66
479k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
479k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
479k
    const auto l = And(val, kMaskL);
69
479k
    const auto exp = ShiftRight<23>(b);
70
479k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
479k
    const auto n = Sub(exp_fixed, kExpOffset);
72
479k
    const auto eb = Sub(exp_fixed, kEBOffset);
73
479k
    const auto m = ShiftRight<23 - M - L>(b);
74
479k
    const auto a = Add(kBase, Mul(n, kMulN));
75
479k
    const auto d = And(m, kMaskM);
76
479k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
479k
    const auto c = Or(a, l);
78
479k
    extra_bits = Add(extra_bits, eb_fixed);
79
479k
    const auto t = Or(c, d);
80
479k
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
479k
    Store(t_fixed, du, out + i);
82
479k
  }
83
15.0k
  if (last_full < len) {
84
13.1k
    const auto stop = Set(du, len);
85
13.1k
    const auto fence = Iota(du, last_full);
86
13.1k
    const auto take = Lt(fence, stop);
87
13.1k
    const auto val = LoadU(du, values + last_full);
88
13.1k
    const auto is_large = Gt(val, kLargeThreshold);
89
13.1k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
13.1k
    const auto not_literal = Ge(val, kSplit);
91
13.1k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
13.1k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
13.1k
    const auto l = And(val, kMaskL);
94
13.1k
    const auto exp = ShiftRight<23>(b);
95
13.1k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
13.1k
    const auto n = Sub(exp_fixed, kExpOffset);
97
13.1k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
13.1k
    const auto m = ShiftRight<23 - M - L>(b);
99
13.1k
    const auto a = Add(kBase, Mul(n, kMulN));
100
13.1k
    const auto d = And(m, kMaskM);
101
13.1k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
13.1k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
13.1k
    const auto c = Or(a, l);
104
13.1k
    extra_bits = Add(extra_bits, eb_masked);
105
13.1k
    const auto t = Or(c, d);
106
13.1k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
13.1k
    Store(t_fixed, du, out + last_full);
108
13.1k
  }
109
15.0k
  return GetLane(SumOfLanes(du, extra_bits));
110
15.0k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<11ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
15.0k
                               uint32_t* JXL_RESTRICT out) {
45
15.0k
  const HWY_FULL(uint32_t) du;
46
15.0k
  const HWY_FULL(float) df;
47
15.0k
  const auto kZero = Zero(du);
48
15.0k
  const auto kSplit = Set(du, 1 << E);
49
15.0k
  const auto kExpOffset = Set(du, 127);
50
15.0k
  const auto kEBOffset = Set(du, 127 + M + L);
51
15.0k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
15.0k
  const auto kMulN = Set(du, 1 << (M + L));
53
15.0k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
15.0k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
15.0k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
15.0k
  constexpr size_t kLargeShiftVal = 10;
57
15.0k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
15.0k
  auto extra_bits = kZero;
60
15.0k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
494k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
479k
    const auto val = LoadU(du, values + i);
63
479k
    const auto is_large = Gt(val, kLargeThreshold);
64
479k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
479k
    const auto not_literal = Ge(val, kSplit);
66
479k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
479k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
479k
    const auto l = And(val, kMaskL);
69
479k
    const auto exp = ShiftRight<23>(b);
70
479k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
479k
    const auto n = Sub(exp_fixed, kExpOffset);
72
479k
    const auto eb = Sub(exp_fixed, kEBOffset);
73
479k
    const auto m = ShiftRight<23 - M - L>(b);
74
479k
    const auto a = Add(kBase, Mul(n, kMulN));
75
479k
    const auto d = And(m, kMaskM);
76
479k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
479k
    const auto c = Or(a, l);
78
479k
    extra_bits = Add(extra_bits, eb_fixed);
79
479k
    const auto t = Or(c, d);
80
479k
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
479k
    Store(t_fixed, du, out + i);
82
479k
  }
83
15.0k
  if (last_full < len) {
84
13.1k
    const auto stop = Set(du, len);
85
13.1k
    const auto fence = Iota(du, last_full);
86
13.1k
    const auto take = Lt(fence, stop);
87
13.1k
    const auto val = LoadU(du, values + last_full);
88
13.1k
    const auto is_large = Gt(val, kLargeThreshold);
89
13.1k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
13.1k
    const auto not_literal = Ge(val, kSplit);
91
13.1k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
13.1k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
13.1k
    const auto l = And(val, kMaskL);
94
13.1k
    const auto exp = ShiftRight<23>(b);
95
13.1k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
13.1k
    const auto n = Sub(exp_fixed, kExpOffset);
97
13.1k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
13.1k
    const auto m = ShiftRight<23 - M - L>(b);
99
13.1k
    const auto a = Add(kBase, Mul(n, kMulN));
100
13.1k
    const auto d = And(m, kMaskM);
101
13.1k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
13.1k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
13.1k
    const auto c = Or(a, l);
104
13.1k
    extra_bits = Add(extra_bits, eb_masked);
105
13.1k
    const auto t = Or(c, d);
106
13.1k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
13.1k
    Store(t_fixed, du, out + last_full);
108
13.1k
  }
109
15.0k
  return GetLane(SumOfLanes(du, extra_bits));
110
15.0k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<12ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
15.0k
                               uint32_t* JXL_RESTRICT out) {
45
15.0k
  const HWY_FULL(uint32_t) du;
46
15.0k
  const HWY_FULL(float) df;
47
15.0k
  const auto kZero = Zero(du);
48
15.0k
  const auto kSplit = Set(du, 1 << E);
49
15.0k
  const auto kExpOffset = Set(du, 127);
50
15.0k
  const auto kEBOffset = Set(du, 127 + M + L);
51
15.0k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
15.0k
  const auto kMulN = Set(du, 1 << (M + L));
53
15.0k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
15.0k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
15.0k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
15.0k
  constexpr size_t kLargeShiftVal = 10;
57
15.0k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
15.0k
  auto extra_bits = kZero;
60
15.0k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
494k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
479k
    const auto val = LoadU(du, values + i);
63
479k
    const auto is_large = Gt(val, kLargeThreshold);
64
479k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
479k
    const auto not_literal = Ge(val, kSplit);
66
479k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
479k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
479k
    const auto l = And(val, kMaskL);
69
479k
    const auto exp = ShiftRight<23>(b);
70
479k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
479k
    const auto n = Sub(exp_fixed, kExpOffset);
72
479k
    const auto eb = Sub(exp_fixed, kEBOffset);
73
479k
    const auto m = ShiftRight<23 - M - L>(b);
74
479k
    const auto a = Add(kBase, Mul(n, kMulN));
75
479k
    const auto d = And(m, kMaskM);
76
479k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
479k
    const auto c = Or(a, l);
78
479k
    extra_bits = Add(extra_bits, eb_fixed);
79
479k
    const auto t = Or(c, d);
80
479k
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
479k
    Store(t_fixed, du, out + i);
82
479k
  }
83
15.0k
  if (last_full < len) {
84
13.1k
    const auto stop = Set(du, len);
85
13.1k
    const auto fence = Iota(du, last_full);
86
13.1k
    const auto take = Lt(fence, stop);
87
13.1k
    const auto val = LoadU(du, values + last_full);
88
13.1k
    const auto is_large = Gt(val, kLargeThreshold);
89
13.1k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
13.1k
    const auto not_literal = Ge(val, kSplit);
91
13.1k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
13.1k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
13.1k
    const auto l = And(val, kMaskL);
94
13.1k
    const auto exp = ShiftRight<23>(b);
95
13.1k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
13.1k
    const auto n = Sub(exp_fixed, kExpOffset);
97
13.1k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
13.1k
    const auto m = ShiftRight<23 - M - L>(b);
99
13.1k
    const auto a = Add(kBase, Mul(n, kMulN));
100
13.1k
    const auto d = And(m, kMaskM);
101
13.1k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
13.1k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
13.1k
    const auto c = Or(a, l);
104
13.1k
    extra_bits = Add(extra_bits, eb_masked);
105
13.1k
    const auto t = Or(c, d);
106
13.1k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
13.1k
    Store(t_fixed, du, out + last_full);
108
13.1k
  }
109
15.0k
  return GetLane(SumOfLanes(du, extra_bits));
110
15.0k
}
Unexecuted instantiation: unsigned int jxl::N_AVX3::EstimateTokenCostImpl<0ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3::EstimateTokenCostImpl<2ul, 0ul, 1ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3::EstimateTokenCostImpl<3ul, 1ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3::EstimateTokenCostImpl<3ul, 1ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3::EstimateTokenCostImpl<3ul, 2ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3::EstimateTokenCostImpl<3ul, 2ul, 1ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3::EstimateTokenCostImpl<4ul, 1ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3::EstimateTokenCostImpl<4ul, 1ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3::EstimateTokenCostImpl<4ul, 1ul, 3ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3::EstimateTokenCostImpl<4ul, 2ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3::EstimateTokenCostImpl<4ul, 2ul, 1ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3::EstimateTokenCostImpl<4ul, 2ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3::EstimateTokenCostImpl<5ul, 1ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3::EstimateTokenCostImpl<5ul, 1ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3::EstimateTokenCostImpl<5ul, 1ul, 4ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3::EstimateTokenCostImpl<5ul, 2ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3::EstimateTokenCostImpl<5ul, 2ul, 1ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3::EstimateTokenCostImpl<5ul, 2ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3::EstimateTokenCostImpl<5ul, 2ul, 3ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3::EstimateTokenCostImpl<6ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3::EstimateTokenCostImpl<6ul, 1ul, 5ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3::EstimateTokenCostImpl<6ul, 2ul, 4ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3::EstimateTokenCostImpl<7ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3::EstimateTokenCostImpl<8ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3::EstimateTokenCostImpl<9ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3::EstimateTokenCostImpl<10ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3::EstimateTokenCostImpl<11ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3::EstimateTokenCostImpl<12ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_ZEN4::EstimateTokenCostImpl<0ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_ZEN4::EstimateTokenCostImpl<2ul, 0ul, 1ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_ZEN4::EstimateTokenCostImpl<3ul, 1ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_ZEN4::EstimateTokenCostImpl<3ul, 1ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_ZEN4::EstimateTokenCostImpl<3ul, 2ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_ZEN4::EstimateTokenCostImpl<3ul, 2ul, 1ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_ZEN4::EstimateTokenCostImpl<4ul, 1ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_ZEN4::EstimateTokenCostImpl<4ul, 1ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_ZEN4::EstimateTokenCostImpl<4ul, 1ul, 3ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_ZEN4::EstimateTokenCostImpl<4ul, 2ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_ZEN4::EstimateTokenCostImpl<4ul, 2ul, 1ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_ZEN4::EstimateTokenCostImpl<4ul, 2ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_ZEN4::EstimateTokenCostImpl<5ul, 1ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_ZEN4::EstimateTokenCostImpl<5ul, 1ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_ZEN4::EstimateTokenCostImpl<5ul, 1ul, 4ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_ZEN4::EstimateTokenCostImpl<5ul, 2ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_ZEN4::EstimateTokenCostImpl<5ul, 2ul, 1ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_ZEN4::EstimateTokenCostImpl<5ul, 2ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_ZEN4::EstimateTokenCostImpl<5ul, 2ul, 3ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_ZEN4::EstimateTokenCostImpl<6ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_ZEN4::EstimateTokenCostImpl<6ul, 1ul, 5ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_ZEN4::EstimateTokenCostImpl<6ul, 2ul, 4ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_ZEN4::EstimateTokenCostImpl<7ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_ZEN4::EstimateTokenCostImpl<8ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_ZEN4::EstimateTokenCostImpl<9ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_ZEN4::EstimateTokenCostImpl<10ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_ZEN4::EstimateTokenCostImpl<11ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_ZEN4::EstimateTokenCostImpl<12ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_SPR::EstimateTokenCostImpl<0ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_SPR::EstimateTokenCostImpl<2ul, 0ul, 1ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_SPR::EstimateTokenCostImpl<3ul, 1ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_SPR::EstimateTokenCostImpl<3ul, 1ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_SPR::EstimateTokenCostImpl<3ul, 2ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_SPR::EstimateTokenCostImpl<3ul, 2ul, 1ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_SPR::EstimateTokenCostImpl<4ul, 1ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_SPR::EstimateTokenCostImpl<4ul, 1ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_SPR::EstimateTokenCostImpl<4ul, 1ul, 3ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_SPR::EstimateTokenCostImpl<4ul, 2ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_SPR::EstimateTokenCostImpl<4ul, 2ul, 1ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_SPR::EstimateTokenCostImpl<4ul, 2ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_SPR::EstimateTokenCostImpl<5ul, 1ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_SPR::EstimateTokenCostImpl<5ul, 1ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_SPR::EstimateTokenCostImpl<5ul, 1ul, 4ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_SPR::EstimateTokenCostImpl<5ul, 2ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_SPR::EstimateTokenCostImpl<5ul, 2ul, 1ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_SPR::EstimateTokenCostImpl<5ul, 2ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_SPR::EstimateTokenCostImpl<5ul, 2ul, 3ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_SPR::EstimateTokenCostImpl<6ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_SPR::EstimateTokenCostImpl<6ul, 1ul, 5ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_SPR::EstimateTokenCostImpl<6ul, 2ul, 4ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_SPR::EstimateTokenCostImpl<7ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_SPR::EstimateTokenCostImpl<8ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_SPR::EstimateTokenCostImpl<9ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_SPR::EstimateTokenCostImpl<10ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_SPR::EstimateTokenCostImpl<11ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_AVX3_SPR::EstimateTokenCostImpl<12ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE2::EstimateTokenCostImpl<0ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE2::EstimateTokenCostImpl<2ul, 0ul, 1ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE2::EstimateTokenCostImpl<3ul, 1ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE2::EstimateTokenCostImpl<3ul, 1ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE2::EstimateTokenCostImpl<3ul, 2ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE2::EstimateTokenCostImpl<3ul, 2ul, 1ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE2::EstimateTokenCostImpl<4ul, 1ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE2::EstimateTokenCostImpl<4ul, 1ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE2::EstimateTokenCostImpl<4ul, 1ul, 3ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE2::EstimateTokenCostImpl<4ul, 2ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE2::EstimateTokenCostImpl<4ul, 2ul, 1ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE2::EstimateTokenCostImpl<4ul, 2ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE2::EstimateTokenCostImpl<5ul, 1ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE2::EstimateTokenCostImpl<5ul, 1ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE2::EstimateTokenCostImpl<5ul, 1ul, 4ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE2::EstimateTokenCostImpl<5ul, 2ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE2::EstimateTokenCostImpl<5ul, 2ul, 1ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE2::EstimateTokenCostImpl<5ul, 2ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE2::EstimateTokenCostImpl<5ul, 2ul, 3ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE2::EstimateTokenCostImpl<6ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE2::EstimateTokenCostImpl<6ul, 1ul, 5ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE2::EstimateTokenCostImpl<6ul, 2ul, 4ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE2::EstimateTokenCostImpl<7ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE2::EstimateTokenCostImpl<8ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE2::EstimateTokenCostImpl<9ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE2::EstimateTokenCostImpl<10ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE2::EstimateTokenCostImpl<11ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Unexecuted instantiation: unsigned int jxl::N_SSE2::EstimateTokenCostImpl<12ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
111
112
uint32_t EstimateTokenCost(uint32_t* JXL_RESTRICT values, size_t len,
113
831k
                           HybridUintConfig cfg, AlignedMemory& tokens) {
114
831k
  uint32_t* JXL_RESTRICT out = tokens.address<uint32_t>();
115
#if HWY_TARGET == HWY_SCALAR
116
  uint32_t extra_bits = 0;
117
  for (size_t i = 0; i < len; ++i) {
118
    uint32_t v = values[i];
119
    uint32_t tok, nbits, bits;
120
    cfg.Encode(v, &tok, &nbits, &bits);
121
    extra_bits += nbits;
122
    out[i] = tok;
123
  }
124
  return extra_bits;
125
#else
126
831k
  if (cfg.split_exponent == 0) {
127
96.7k
    return EstimateTokenCostImpl<0, 0, 0>(values, len, out);
128
734k
  } else if (cfg.split_exponent == 2) {
129
93.8k
    JXL_DASSERT((cfg.msb_in_token == 0) && (cfg.lsb_in_token == 1));
130
93.8k
    return EstimateTokenCostImpl<2, 0, 1>(values, len, out);
131
641k
  } else if (cfg.split_exponent == 3) {
132
80.8k
    if (cfg.msb_in_token == 1) {
133
40.4k
      if (cfg.lsb_in_token == 0) {
134
20.2k
        return EstimateTokenCostImpl<3, 1, 0>(values, len, out);
135
20.2k
      } else {
136
20.2k
        JXL_DASSERT(cfg.lsb_in_token == 2);
137
20.2k
        return EstimateTokenCostImpl<3, 1, 2>(values, len, out);
138
20.2k
      }
139
40.4k
    } else {
140
40.4k
      JXL_DASSERT(cfg.msb_in_token == 2);
141
40.4k
      if (cfg.lsb_in_token == 0) {
142
20.2k
        return EstimateTokenCostImpl<3, 2, 0>(values, len, out);
143
20.2k
      } else {
144
20.2k
        JXL_DASSERT(cfg.lsb_in_token == 1);
145
20.2k
        return EstimateTokenCostImpl<3, 2, 1>(values, len, out);
146
20.2k
      }
147
40.4k
    }
148
560k
  } else if (cfg.split_exponent == 4) {
149
268k
    if (cfg.msb_in_token == 1) {
150
134k
      if (cfg.lsb_in_token == 0) {
151
20.2k
        return EstimateTokenCostImpl<4, 1, 0>(values, len, out);
152
114k
      } else if (cfg.lsb_in_token == 2) {
153
93.8k
        return EstimateTokenCostImpl<4, 1, 2>(values, len, out);
154
93.8k
      } else {
155
20.2k
        JXL_DASSERT(cfg.lsb_in_token == 3);
156
20.2k
        return EstimateTokenCostImpl<4, 1, 3>(values, len, out);
157
20.2k
      }
158
134k
    } else {
159
134k
      JXL_DASSERT(cfg.msb_in_token == 2);
160
134k
      if (cfg.lsb_in_token == 0) {
161
93.8k
        return EstimateTokenCostImpl<4, 2, 0>(values, len, out);
162
93.8k
      } else if (cfg.lsb_in_token == 1) {
163
20.2k
        return EstimateTokenCostImpl<4, 2, 1>(values, len, out);
164
20.2k
      } else {
165
20.2k
        JXL_DASSERT(cfg.lsb_in_token == 2);
166
20.2k
        return EstimateTokenCostImpl<4, 2, 2>(values, len, out);
167
20.2k
      }
168
134k
    }
169
291k
  } else if (cfg.split_exponent == 5) {
170
141k
    if (cfg.msb_in_token == 1) {
171
60.6k
      if (cfg.lsb_in_token == 0) {
172
20.2k
        return EstimateTokenCostImpl<5, 1, 0>(values, len, out);
173
40.3k
      } else if (cfg.lsb_in_token == 2) {
174
20.2k
        return EstimateTokenCostImpl<5, 1, 2>(values, len, out);
175
20.2k
      } else {
176
20.1k
        JXL_DASSERT(cfg.lsb_in_token == 4);
177
20.1k
        return EstimateTokenCostImpl<5, 1, 4>(values, len, out);
178
20.1k
      }
179
80.8k
    } else {
180
80.8k
      JXL_DASSERT(cfg.msb_in_token == 2);
181
80.8k
      if (cfg.lsb_in_token == 0) {
182
20.2k
        return EstimateTokenCostImpl<5, 2, 0>(values, len, out);
183
60.6k
      } else if (cfg.lsb_in_token == 1) {
184
20.2k
        return EstimateTokenCostImpl<5, 2, 1>(values, len, out);
185
40.3k
      } else if (cfg.lsb_in_token == 2) {
186
20.2k
        return EstimateTokenCostImpl<5, 2, 2>(values, len, out);
187
20.2k
      } else {
188
20.1k
        JXL_DASSERT(cfg.lsb_in_token == 3);
189
20.1k
        return EstimateTokenCostImpl<5, 2, 3>(values, len, out);
190
20.1k
      }
191
80.8k
    }
192
150k
  } else if (cfg.split_exponent == 6) {
193
54.9k
    if (cfg.msb_in_token == 0) {
194
20.2k
      JXL_DASSERT(cfg.lsb_in_token == 0);
195
20.2k
      return EstimateTokenCostImpl<6, 0, 0>(values, len, out);
196
34.7k
    } else if (cfg.msb_in_token == 1) {
197
17.3k
      JXL_DASSERT(cfg.lsb_in_token == 5);
198
17.3k
      return EstimateTokenCostImpl<6, 1, 5>(values, len, out);
199
17.3k
    } else {
200
17.3k
      JXL_DASSERT(cfg.msb_in_token == 2);
201
17.3k
      JXL_DASSERT(cfg.lsb_in_token == 4);
202
17.3k
      return EstimateTokenCostImpl<6, 2, 4>(values, len, out);
203
17.3k
    }
204
95.4k
  } else if (cfg.split_exponent >= 7 && cfg.split_exponent <= 12) {
205
95.4k
    JXL_DASSERT(cfg.msb_in_token == 0);
206
95.4k
    JXL_DASSERT(cfg.lsb_in_token == 0);
207
95.4k
    if (cfg.split_exponent == 7) {
208
20.2k
      return EstimateTokenCostImpl<7, 0, 0>(values, len, out);
209
75.2k
    } else if (cfg.split_exponent == 8) {
210
15.0k
      return EstimateTokenCostImpl<8, 0, 0>(values, len, out);
211
60.2k
    } else if (cfg.split_exponent == 9) {
212
15.0k
      return EstimateTokenCostImpl<9, 0, 0>(values, len, out);
213
45.1k
    } else if (cfg.split_exponent == 10) {
214
15.0k
      return EstimateTokenCostImpl<10, 0, 0>(values, len, out);
215
30.1k
    } else if (cfg.split_exponent == 11) {
216
15.0k
      return EstimateTokenCostImpl<11, 0, 0>(values, len, out);
217
15.0k
    } else {
218
15.0k
      return EstimateTokenCostImpl<12, 0, 0>(values, len, out);
219
15.0k
    }
220
95.4k
  } else {
221
0
    JXL_DASSERT(false);
222
0
  }
223
0
  return ~0;
224
831k
#endif
225
831k
}
Unexecuted instantiation: jxl::N_SSE4::EstimateTokenCost(unsigned int*, unsigned long, jxl::HybridUintConfig, jxl::AlignedMemory&)
jxl::N_AVX2::EstimateTokenCost(unsigned int*, unsigned long, jxl::HybridUintConfig, jxl::AlignedMemory&)
Line
Count
Source
113
831k
                           HybridUintConfig cfg, AlignedMemory& tokens) {
114
831k
  uint32_t* JXL_RESTRICT out = tokens.address<uint32_t>();
115
#if HWY_TARGET == HWY_SCALAR
116
  uint32_t extra_bits = 0;
117
  for (size_t i = 0; i < len; ++i) {
118
    uint32_t v = values[i];
119
    uint32_t tok, nbits, bits;
120
    cfg.Encode(v, &tok, &nbits, &bits);
121
    extra_bits += nbits;
122
    out[i] = tok;
123
  }
124
  return extra_bits;
125
#else
126
831k
  if (cfg.split_exponent == 0) {
127
96.7k
    return EstimateTokenCostImpl<0, 0, 0>(values, len, out);
128
734k
  } else if (cfg.split_exponent == 2) {
129
93.8k
    JXL_DASSERT((cfg.msb_in_token == 0) && (cfg.lsb_in_token == 1));
130
93.8k
    return EstimateTokenCostImpl<2, 0, 1>(values, len, out);
131
641k
  } else if (cfg.split_exponent == 3) {
132
80.8k
    if (cfg.msb_in_token == 1) {
133
40.4k
      if (cfg.lsb_in_token == 0) {
134
20.2k
        return EstimateTokenCostImpl<3, 1, 0>(values, len, out);
135
20.2k
      } else {
136
20.2k
        JXL_DASSERT(cfg.lsb_in_token == 2);
137
20.2k
        return EstimateTokenCostImpl<3, 1, 2>(values, len, out);
138
20.2k
      }
139
40.4k
    } else {
140
40.4k
      JXL_DASSERT(cfg.msb_in_token == 2);
141
40.4k
      if (cfg.lsb_in_token == 0) {
142
20.2k
        return EstimateTokenCostImpl<3, 2, 0>(values, len, out);
143
20.2k
      } else {
144
20.2k
        JXL_DASSERT(cfg.lsb_in_token == 1);
145
20.2k
        return EstimateTokenCostImpl<3, 2, 1>(values, len, out);
146
20.2k
      }
147
40.4k
    }
148
560k
  } else if (cfg.split_exponent == 4) {
149
268k
    if (cfg.msb_in_token == 1) {
150
134k
      if (cfg.lsb_in_token == 0) {
151
20.2k
        return EstimateTokenCostImpl<4, 1, 0>(values, len, out);
152
114k
      } else if (cfg.lsb_in_token == 2) {
153
93.8k
        return EstimateTokenCostImpl<4, 1, 2>(values, len, out);
154
93.8k
      } else {
155
20.2k
        JXL_DASSERT(cfg.lsb_in_token == 3);
156
20.2k
        return EstimateTokenCostImpl<4, 1, 3>(values, len, out);
157
20.2k
      }
158
134k
    } else {
159
134k
      JXL_DASSERT(cfg.msb_in_token == 2);
160
134k
      if (cfg.lsb_in_token == 0) {
161
93.8k
        return EstimateTokenCostImpl<4, 2, 0>(values, len, out);
162
93.8k
      } else if (cfg.lsb_in_token == 1) {
163
20.2k
        return EstimateTokenCostImpl<4, 2, 1>(values, len, out);
164
20.2k
      } else {
165
20.2k
        JXL_DASSERT(cfg.lsb_in_token == 2);
166
20.2k
        return EstimateTokenCostImpl<4, 2, 2>(values, len, out);
167
20.2k
      }
168
134k
    }
169
291k
  } else if (cfg.split_exponent == 5) {
170
141k
    if (cfg.msb_in_token == 1) {
171
60.6k
      if (cfg.lsb_in_token == 0) {
172
20.2k
        return EstimateTokenCostImpl<5, 1, 0>(values, len, out);
173
40.3k
      } else if (cfg.lsb_in_token == 2) {
174
20.2k
        return EstimateTokenCostImpl<5, 1, 2>(values, len, out);
175
20.2k
      } else {
176
20.1k
        JXL_DASSERT(cfg.lsb_in_token == 4);
177
20.1k
        return EstimateTokenCostImpl<5, 1, 4>(values, len, out);
178
20.1k
      }
179
80.8k
    } else {
180
80.8k
      JXL_DASSERT(cfg.msb_in_token == 2);
181
80.8k
      if (cfg.lsb_in_token == 0) {
182
20.2k
        return EstimateTokenCostImpl<5, 2, 0>(values, len, out);
183
60.6k
      } else if (cfg.lsb_in_token == 1) {
184
20.2k
        return EstimateTokenCostImpl<5, 2, 1>(values, len, out);
185
40.3k
      } else if (cfg.lsb_in_token == 2) {
186
20.2k
        return EstimateTokenCostImpl<5, 2, 2>(values, len, out);
187
20.2k
      } else {
188
20.1k
        JXL_DASSERT(cfg.lsb_in_token == 3);
189
20.1k
        return EstimateTokenCostImpl<5, 2, 3>(values, len, out);
190
20.1k
      }
191
80.8k
    }
192
150k
  } else if (cfg.split_exponent == 6) {
193
54.9k
    if (cfg.msb_in_token == 0) {
194
20.2k
      JXL_DASSERT(cfg.lsb_in_token == 0);
195
20.2k
      return EstimateTokenCostImpl<6, 0, 0>(values, len, out);
196
34.7k
    } else if (cfg.msb_in_token == 1) {
197
17.3k
      JXL_DASSERT(cfg.lsb_in_token == 5);
198
17.3k
      return EstimateTokenCostImpl<6, 1, 5>(values, len, out);
199
17.3k
    } else {
200
17.3k
      JXL_DASSERT(cfg.msb_in_token == 2);
201
17.3k
      JXL_DASSERT(cfg.lsb_in_token == 4);
202
17.3k
      return EstimateTokenCostImpl<6, 2, 4>(values, len, out);
203
17.3k
    }
204
95.4k
  } else if (cfg.split_exponent >= 7 && cfg.split_exponent <= 12) {
205
95.4k
    JXL_DASSERT(cfg.msb_in_token == 0);
206
95.4k
    JXL_DASSERT(cfg.lsb_in_token == 0);
207
95.4k
    if (cfg.split_exponent == 7) {
208
20.2k
      return EstimateTokenCostImpl<7, 0, 0>(values, len, out);
209
75.2k
    } else if (cfg.split_exponent == 8) {
210
15.0k
      return EstimateTokenCostImpl<8, 0, 0>(values, len, out);
211
60.2k
    } else if (cfg.split_exponent == 9) {
212
15.0k
      return EstimateTokenCostImpl<9, 0, 0>(values, len, out);
213
45.1k
    } else if (cfg.split_exponent == 10) {
214
15.0k
      return EstimateTokenCostImpl<10, 0, 0>(values, len, out);
215
30.1k
    } else if (cfg.split_exponent == 11) {
216
15.0k
      return EstimateTokenCostImpl<11, 0, 0>(values, len, out);
217
15.0k
    } else {
218
15.0k
      return EstimateTokenCostImpl<12, 0, 0>(values, len, out);
219
15.0k
    }
220
95.4k
  } else {
221
0
    JXL_DASSERT(false);
222
0
  }
223
0
  return ~0;
224
831k
#endif
225
831k
}
Unexecuted instantiation: jxl::N_AVX3::EstimateTokenCost(unsigned int*, unsigned long, jxl::HybridUintConfig, jxl::AlignedMemory&)
Unexecuted instantiation: jxl::N_AVX3_ZEN4::EstimateTokenCost(unsigned int*, unsigned long, jxl::HybridUintConfig, jxl::AlignedMemory&)
Unexecuted instantiation: jxl::N_AVX3_SPR::EstimateTokenCost(unsigned int*, unsigned long, jxl::HybridUintConfig, jxl::AlignedMemory&)
Unexecuted instantiation: jxl::N_SSE2::EstimateTokenCost(unsigned int*, unsigned long, jxl::HybridUintConfig, jxl::AlignedMemory&)
226
227
// NOLINTNEXTLINE(google-readability-namespace-comments)
228
}  // namespace HWY_NAMESPACE
229
}  // namespace jxl
230
HWY_AFTER_NAMESPACE();
231
232
#if HWY_ONCE
233
namespace jxl {
234
235
HWY_EXPORT(EstimateTokenCost);
236
237
uint32_t EstimateTokenCost(uint32_t* JXL_RESTRICT values, size_t len,
238
831k
                           HybridUintConfig cfg, AlignedMemory& tokens) {
239
831k
  JXL_DASSERT(cfg.lsb_in_token + cfg.msb_in_token <= cfg.split_exponent);
240
831k
  return HWY_DYNAMIC_DISPATCH(EstimateTokenCost)(values, len, cfg, tokens);
241
831k
}
242
243
}  // namespace jxl
244
#endif