Coverage Report

Created: 2026-01-20 07:37

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
861k
                               uint32_t* JXL_RESTRICT out) {
45
861k
  const HWY_FULL(uint32_t) du;
46
861k
  const HWY_FULL(float) df;
47
861k
  const auto kZero = Zero(du);
48
861k
  const auto kSplit = Set(du, 1 << E);
49
861k
  const auto kExpOffset = Set(du, 127);
50
861k
  const auto kEBOffset = Set(du, 127 + M + L);
51
861k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
861k
  const auto kMulN = Set(du, 1 << (M + L));
53
861k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
861k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
861k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
861k
  constexpr size_t kLargeShiftVal = 10;
57
861k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
861k
  auto extra_bits = kZero;
60
861k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
57.2M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
56.3M
    const auto val = LoadU(du, values + i);
63
56.3M
    const auto is_large = Gt(val, kLargeThreshold);
64
56.3M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
56.3M
    const auto not_literal = Ge(val, kSplit);
66
56.3M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
56.3M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
56.3M
    const auto l = And(val, kMaskL);
69
56.3M
    const auto exp = ShiftRight<23>(b);
70
56.3M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
56.3M
    const auto n = Sub(exp_fixed, kExpOffset);
72
56.3M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
56.3M
    const auto m = ShiftRight<23 - M - L>(b);
74
56.3M
    const auto a = Add(kBase, Mul(n, kMulN));
75
56.3M
    const auto d = And(m, kMaskM);
76
56.3M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
56.3M
    const auto c = Or(a, l);
78
56.3M
    extra_bits = Add(extra_bits, eb_fixed);
79
56.3M
    const auto t = Or(c, d);
80
56.3M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
56.3M
    Store(t_fixed, du, out + i);
82
56.3M
  }
83
861k
  if (last_full < len) {
84
741k
    const auto stop = Set(du, len);
85
741k
    const auto fence = Iota(du, last_full);
86
741k
    const auto take = Lt(fence, stop);
87
741k
    const auto val = LoadU(du, values + last_full);
88
741k
    const auto is_large = Gt(val, kLargeThreshold);
89
741k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
741k
    const auto not_literal = Ge(val, kSplit);
91
741k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
741k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
741k
    const auto l = And(val, kMaskL);
94
741k
    const auto exp = ShiftRight<23>(b);
95
741k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
741k
    const auto n = Sub(exp_fixed, kExpOffset);
97
741k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
741k
    const auto m = ShiftRight<23 - M - L>(b);
99
741k
    const auto a = Add(kBase, Mul(n, kMulN));
100
741k
    const auto d = And(m, kMaskM);
101
741k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
741k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
741k
    const auto c = Or(a, l);
104
741k
    extra_bits = Add(extra_bits, eb_masked);
105
741k
    const auto t = Or(c, d);
106
741k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
741k
    Store(t_fixed, du, out + last_full);
108
741k
  }
109
861k
  return GetLane(SumOfLanes(du, extra_bits));
110
861k
}
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
103k
                               uint32_t* JXL_RESTRICT out) {
45
103k
  const HWY_FULL(uint32_t) du;
46
103k
  const HWY_FULL(float) df;
47
103k
  const auto kZero = Zero(du);
48
103k
  const auto kSplit = Set(du, 1 << E);
49
103k
  const auto kExpOffset = Set(du, 127);
50
103k
  const auto kEBOffset = Set(du, 127 + M + L);
51
103k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
103k
  const auto kMulN = Set(du, 1 << (M + L));
53
103k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
103k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
103k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
103k
  constexpr size_t kLargeShiftVal = 10;
57
103k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
103k
  auto extra_bits = kZero;
60
103k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
8.98M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
8.88M
    const auto val = LoadU(du, values + i);
63
8.88M
    const auto is_large = Gt(val, kLargeThreshold);
64
8.88M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
8.88M
    const auto not_literal = Ge(val, kSplit);
66
8.88M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
8.88M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
8.88M
    const auto l = And(val, kMaskL);
69
8.88M
    const auto exp = ShiftRight<23>(b);
70
8.88M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
8.88M
    const auto n = Sub(exp_fixed, kExpOffset);
72
8.88M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
8.88M
    const auto m = ShiftRight<23 - M - L>(b);
74
8.88M
    const auto a = Add(kBase, Mul(n, kMulN));
75
8.88M
    const auto d = And(m, kMaskM);
76
8.88M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
8.88M
    const auto c = Or(a, l);
78
8.88M
    extra_bits = Add(extra_bits, eb_fixed);
79
8.88M
    const auto t = Or(c, d);
80
8.88M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
8.88M
    Store(t_fixed, du, out + i);
82
8.88M
  }
83
103k
  if (last_full < len) {
84
89.3k
    const auto stop = Set(du, len);
85
89.3k
    const auto fence = Iota(du, last_full);
86
89.3k
    const auto take = Lt(fence, stop);
87
89.3k
    const auto val = LoadU(du, values + last_full);
88
89.3k
    const auto is_large = Gt(val, kLargeThreshold);
89
89.3k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
89.3k
    const auto not_literal = Ge(val, kSplit);
91
89.3k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
89.3k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
89.3k
    const auto l = And(val, kMaskL);
94
89.3k
    const auto exp = ShiftRight<23>(b);
95
89.3k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
89.3k
    const auto n = Sub(exp_fixed, kExpOffset);
97
89.3k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
89.3k
    const auto m = ShiftRight<23 - M - L>(b);
99
89.3k
    const auto a = Add(kBase, Mul(n, kMulN));
100
89.3k
    const auto d = And(m, kMaskM);
101
89.3k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
89.3k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
89.3k
    const auto c = Or(a, l);
104
89.3k
    extra_bits = Add(extra_bits, eb_masked);
105
89.3k
    const auto t = Or(c, d);
106
89.3k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
89.3k
    Store(t_fixed, du, out + last_full);
108
89.3k
  }
109
103k
  return GetLane(SumOfLanes(du, extra_bits));
110
103k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<2ul, 0ul, 1ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
100k
                               uint32_t* JXL_RESTRICT out) {
45
100k
  const HWY_FULL(uint32_t) du;
46
100k
  const HWY_FULL(float) df;
47
100k
  const auto kZero = Zero(du);
48
100k
  const auto kSplit = Set(du, 1 << E);
49
100k
  const auto kExpOffset = Set(du, 127);
50
100k
  const auto kEBOffset = Set(du, 127 + M + L);
51
100k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
100k
  const auto kMulN = Set(du, 1 << (M + L));
53
100k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
100k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
100k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
100k
  constexpr size_t kLargeShiftVal = 10;
57
100k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
100k
  auto extra_bits = kZero;
60
100k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
8.98M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
8.88M
    const auto val = LoadU(du, values + i);
63
8.88M
    const auto is_large = Gt(val, kLargeThreshold);
64
8.88M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
8.88M
    const auto not_literal = Ge(val, kSplit);
66
8.88M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
8.88M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
8.88M
    const auto l = And(val, kMaskL);
69
8.88M
    const auto exp = ShiftRight<23>(b);
70
8.88M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
8.88M
    const auto n = Sub(exp_fixed, kExpOffset);
72
8.88M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
8.88M
    const auto m = ShiftRight<23 - M - L>(b);
74
8.88M
    const auto a = Add(kBase, Mul(n, kMulN));
75
8.88M
    const auto d = And(m, kMaskM);
76
8.88M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
8.88M
    const auto c = Or(a, l);
78
8.88M
    extra_bits = Add(extra_bits, eb_fixed);
79
8.88M
    const auto t = Or(c, d);
80
8.88M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
8.88M
    Store(t_fixed, du, out + i);
82
8.88M
  }
83
100k
  if (last_full < len) {
84
86.6k
    const auto stop = Set(du, len);
85
86.6k
    const auto fence = Iota(du, last_full);
86
86.6k
    const auto take = Lt(fence, stop);
87
86.6k
    const auto val = LoadU(du, values + last_full);
88
86.6k
    const auto is_large = Gt(val, kLargeThreshold);
89
86.6k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
86.6k
    const auto not_literal = Ge(val, kSplit);
91
86.6k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
86.6k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
86.6k
    const auto l = And(val, kMaskL);
94
86.6k
    const auto exp = ShiftRight<23>(b);
95
86.6k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
86.6k
    const auto n = Sub(exp_fixed, kExpOffset);
97
86.6k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
86.6k
    const auto m = ShiftRight<23 - M - L>(b);
99
86.6k
    const auto a = Add(kBase, Mul(n, kMulN));
100
86.6k
    const auto d = And(m, kMaskM);
101
86.6k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
86.6k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
86.6k
    const auto c = Or(a, l);
104
86.6k
    extra_bits = Add(extra_bits, eb_masked);
105
86.6k
    const auto t = Or(c, d);
106
86.6k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
86.6k
    Store(t_fixed, du, out + last_full);
108
86.6k
  }
109
100k
  return GetLane(SumOfLanes(du, extra_bits));
110
100k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<3ul, 1ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
20.3k
                               uint32_t* JXL_RESTRICT out) {
45
20.3k
  const HWY_FULL(uint32_t) du;
46
20.3k
  const HWY_FULL(float) df;
47
20.3k
  const auto kZero = Zero(du);
48
20.3k
  const auto kSplit = Set(du, 1 << E);
49
20.3k
  const auto kExpOffset = Set(du, 127);
50
20.3k
  const auto kEBOffset = Set(du, 127 + M + L);
51
20.3k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
20.3k
  const auto kMulN = Set(du, 1 << (M + L));
53
20.3k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
20.3k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
20.3k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
20.3k
  constexpr size_t kLargeShiftVal = 10;
57
20.3k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
20.3k
  auto extra_bits = kZero;
60
20.3k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
1.03M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
1.01M
    const auto val = LoadU(du, values + i);
63
1.01M
    const auto is_large = Gt(val, kLargeThreshold);
64
1.01M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
1.01M
    const auto not_literal = Ge(val, kSplit);
66
1.01M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
1.01M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
1.01M
    const auto l = And(val, kMaskL);
69
1.01M
    const auto exp = ShiftRight<23>(b);
70
1.01M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
1.01M
    const auto n = Sub(exp_fixed, kExpOffset);
72
1.01M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
1.01M
    const auto m = ShiftRight<23 - M - L>(b);
74
1.01M
    const auto a = Add(kBase, Mul(n, kMulN));
75
1.01M
    const auto d = And(m, kMaskM);
76
1.01M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
1.01M
    const auto c = Or(a, l);
78
1.01M
    extra_bits = Add(extra_bits, eb_fixed);
79
1.01M
    const auto t = Or(c, d);
80
1.01M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
1.01M
    Store(t_fixed, du, out + i);
82
1.01M
  }
83
20.3k
  if (last_full < len) {
84
17.3k
    const auto stop = Set(du, len);
85
17.3k
    const auto fence = Iota(du, last_full);
86
17.3k
    const auto take = Lt(fence, stop);
87
17.3k
    const auto val = LoadU(du, values + last_full);
88
17.3k
    const auto is_large = Gt(val, kLargeThreshold);
89
17.3k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
17.3k
    const auto not_literal = Ge(val, kSplit);
91
17.3k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
17.3k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
17.3k
    const auto l = And(val, kMaskL);
94
17.3k
    const auto exp = ShiftRight<23>(b);
95
17.3k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
17.3k
    const auto n = Sub(exp_fixed, kExpOffset);
97
17.3k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
17.3k
    const auto m = ShiftRight<23 - M - L>(b);
99
17.3k
    const auto a = Add(kBase, Mul(n, kMulN));
100
17.3k
    const auto d = And(m, kMaskM);
101
17.3k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
17.3k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
17.3k
    const auto c = Or(a, l);
104
17.3k
    extra_bits = Add(extra_bits, eb_masked);
105
17.3k
    const auto t = Or(c, d);
106
17.3k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
17.3k
    Store(t_fixed, du, out + last_full);
108
17.3k
  }
109
20.3k
  return GetLane(SumOfLanes(du, extra_bits));
110
20.3k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<3ul, 1ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
20.3k
                               uint32_t* JXL_RESTRICT out) {
45
20.3k
  const HWY_FULL(uint32_t) du;
46
20.3k
  const HWY_FULL(float) df;
47
20.3k
  const auto kZero = Zero(du);
48
20.3k
  const auto kSplit = Set(du, 1 << E);
49
20.3k
  const auto kExpOffset = Set(du, 127);
50
20.3k
  const auto kEBOffset = Set(du, 127 + M + L);
51
20.3k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
20.3k
  const auto kMulN = Set(du, 1 << (M + L));
53
20.3k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
20.3k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
20.3k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
20.3k
  constexpr size_t kLargeShiftVal = 10;
57
20.3k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
20.3k
  auto extra_bits = kZero;
60
20.3k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
1.03M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
1.01M
    const auto val = LoadU(du, values + i);
63
1.01M
    const auto is_large = Gt(val, kLargeThreshold);
64
1.01M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
1.01M
    const auto not_literal = Ge(val, kSplit);
66
1.01M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
1.01M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
1.01M
    const auto l = And(val, kMaskL);
69
1.01M
    const auto exp = ShiftRight<23>(b);
70
1.01M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
1.01M
    const auto n = Sub(exp_fixed, kExpOffset);
72
1.01M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
1.01M
    const auto m = ShiftRight<23 - M - L>(b);
74
1.01M
    const auto a = Add(kBase, Mul(n, kMulN));
75
1.01M
    const auto d = And(m, kMaskM);
76
1.01M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
1.01M
    const auto c = Or(a, l);
78
1.01M
    extra_bits = Add(extra_bits, eb_fixed);
79
1.01M
    const auto t = Or(c, d);
80
1.01M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
1.01M
    Store(t_fixed, du, out + i);
82
1.01M
  }
83
20.3k
  if (last_full < len) {
84
17.3k
    const auto stop = Set(du, len);
85
17.3k
    const auto fence = Iota(du, last_full);
86
17.3k
    const auto take = Lt(fence, stop);
87
17.3k
    const auto val = LoadU(du, values + last_full);
88
17.3k
    const auto is_large = Gt(val, kLargeThreshold);
89
17.3k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
17.3k
    const auto not_literal = Ge(val, kSplit);
91
17.3k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
17.3k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
17.3k
    const auto l = And(val, kMaskL);
94
17.3k
    const auto exp = ShiftRight<23>(b);
95
17.3k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
17.3k
    const auto n = Sub(exp_fixed, kExpOffset);
97
17.3k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
17.3k
    const auto m = ShiftRight<23 - M - L>(b);
99
17.3k
    const auto a = Add(kBase, Mul(n, kMulN));
100
17.3k
    const auto d = And(m, kMaskM);
101
17.3k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
17.3k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
17.3k
    const auto c = Or(a, l);
104
17.3k
    extra_bits = Add(extra_bits, eb_masked);
105
17.3k
    const auto t = Or(c, d);
106
17.3k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
17.3k
    Store(t_fixed, du, out + last_full);
108
17.3k
  }
109
20.3k
  return GetLane(SumOfLanes(du, extra_bits));
110
20.3k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<3ul, 2ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
20.3k
                               uint32_t* JXL_RESTRICT out) {
45
20.3k
  const HWY_FULL(uint32_t) du;
46
20.3k
  const HWY_FULL(float) df;
47
20.3k
  const auto kZero = Zero(du);
48
20.3k
  const auto kSplit = Set(du, 1 << E);
49
20.3k
  const auto kExpOffset = Set(du, 127);
50
20.3k
  const auto kEBOffset = Set(du, 127 + M + L);
51
20.3k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
20.3k
  const auto kMulN = Set(du, 1 << (M + L));
53
20.3k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
20.3k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
20.3k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
20.3k
  constexpr size_t kLargeShiftVal = 10;
57
20.3k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
20.3k
  auto extra_bits = kZero;
60
20.3k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
1.03M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
1.01M
    const auto val = LoadU(du, values + i);
63
1.01M
    const auto is_large = Gt(val, kLargeThreshold);
64
1.01M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
1.01M
    const auto not_literal = Ge(val, kSplit);
66
1.01M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
1.01M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
1.01M
    const auto l = And(val, kMaskL);
69
1.01M
    const auto exp = ShiftRight<23>(b);
70
1.01M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
1.01M
    const auto n = Sub(exp_fixed, kExpOffset);
72
1.01M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
1.01M
    const auto m = ShiftRight<23 - M - L>(b);
74
1.01M
    const auto a = Add(kBase, Mul(n, kMulN));
75
1.01M
    const auto d = And(m, kMaskM);
76
1.01M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
1.01M
    const auto c = Or(a, l);
78
1.01M
    extra_bits = Add(extra_bits, eb_fixed);
79
1.01M
    const auto t = Or(c, d);
80
1.01M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
1.01M
    Store(t_fixed, du, out + i);
82
1.01M
  }
83
20.3k
  if (last_full < len) {
84
17.3k
    const auto stop = Set(du, len);
85
17.3k
    const auto fence = Iota(du, last_full);
86
17.3k
    const auto take = Lt(fence, stop);
87
17.3k
    const auto val = LoadU(du, values + last_full);
88
17.3k
    const auto is_large = Gt(val, kLargeThreshold);
89
17.3k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
17.3k
    const auto not_literal = Ge(val, kSplit);
91
17.3k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
17.3k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
17.3k
    const auto l = And(val, kMaskL);
94
17.3k
    const auto exp = ShiftRight<23>(b);
95
17.3k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
17.3k
    const auto n = Sub(exp_fixed, kExpOffset);
97
17.3k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
17.3k
    const auto m = ShiftRight<23 - M - L>(b);
99
17.3k
    const auto a = Add(kBase, Mul(n, kMulN));
100
17.3k
    const auto d = And(m, kMaskM);
101
17.3k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
17.3k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
17.3k
    const auto c = Or(a, l);
104
17.3k
    extra_bits = Add(extra_bits, eb_masked);
105
17.3k
    const auto t = Or(c, d);
106
17.3k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
17.3k
    Store(t_fixed, du, out + last_full);
108
17.3k
  }
109
20.3k
  return GetLane(SumOfLanes(du, extra_bits));
110
20.3k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<3ul, 2ul, 1ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
20.3k
                               uint32_t* JXL_RESTRICT out) {
45
20.3k
  const HWY_FULL(uint32_t) du;
46
20.3k
  const HWY_FULL(float) df;
47
20.3k
  const auto kZero = Zero(du);
48
20.3k
  const auto kSplit = Set(du, 1 << E);
49
20.3k
  const auto kExpOffset = Set(du, 127);
50
20.3k
  const auto kEBOffset = Set(du, 127 + M + L);
51
20.3k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
20.3k
  const auto kMulN = Set(du, 1 << (M + L));
53
20.3k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
20.3k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
20.3k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
20.3k
  constexpr size_t kLargeShiftVal = 10;
57
20.3k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
20.3k
  auto extra_bits = kZero;
60
20.3k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
1.03M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
1.01M
    const auto val = LoadU(du, values + i);
63
1.01M
    const auto is_large = Gt(val, kLargeThreshold);
64
1.01M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
1.01M
    const auto not_literal = Ge(val, kSplit);
66
1.01M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
1.01M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
1.01M
    const auto l = And(val, kMaskL);
69
1.01M
    const auto exp = ShiftRight<23>(b);
70
1.01M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
1.01M
    const auto n = Sub(exp_fixed, kExpOffset);
72
1.01M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
1.01M
    const auto m = ShiftRight<23 - M - L>(b);
74
1.01M
    const auto a = Add(kBase, Mul(n, kMulN));
75
1.01M
    const auto d = And(m, kMaskM);
76
1.01M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
1.01M
    const auto c = Or(a, l);
78
1.01M
    extra_bits = Add(extra_bits, eb_fixed);
79
1.01M
    const auto t = Or(c, d);
80
1.01M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
1.01M
    Store(t_fixed, du, out + i);
82
1.01M
  }
83
20.3k
  if (last_full < len) {
84
17.3k
    const auto stop = Set(du, len);
85
17.3k
    const auto fence = Iota(du, last_full);
86
17.3k
    const auto take = Lt(fence, stop);
87
17.3k
    const auto val = LoadU(du, values + last_full);
88
17.3k
    const auto is_large = Gt(val, kLargeThreshold);
89
17.3k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
17.3k
    const auto not_literal = Ge(val, kSplit);
91
17.3k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
17.3k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
17.3k
    const auto l = And(val, kMaskL);
94
17.3k
    const auto exp = ShiftRight<23>(b);
95
17.3k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
17.3k
    const auto n = Sub(exp_fixed, kExpOffset);
97
17.3k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
17.3k
    const auto m = ShiftRight<23 - M - L>(b);
99
17.3k
    const auto a = Add(kBase, Mul(n, kMulN));
100
17.3k
    const auto d = And(m, kMaskM);
101
17.3k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
17.3k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
17.3k
    const auto c = Or(a, l);
104
17.3k
    extra_bits = Add(extra_bits, eb_masked);
105
17.3k
    const auto t = Or(c, d);
106
17.3k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
17.3k
    Store(t_fixed, du, out + last_full);
108
17.3k
  }
109
20.3k
  return GetLane(SumOfLanes(du, extra_bits));
110
20.3k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<4ul, 1ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
20.3k
                               uint32_t* JXL_RESTRICT out) {
45
20.3k
  const HWY_FULL(uint32_t) du;
46
20.3k
  const HWY_FULL(float) df;
47
20.3k
  const auto kZero = Zero(du);
48
20.3k
  const auto kSplit = Set(du, 1 << E);
49
20.3k
  const auto kExpOffset = Set(du, 127);
50
20.3k
  const auto kEBOffset = Set(du, 127 + M + L);
51
20.3k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
20.3k
  const auto kMulN = Set(du, 1 << (M + L));
53
20.3k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
20.3k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
20.3k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
20.3k
  constexpr size_t kLargeShiftVal = 10;
57
20.3k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
20.3k
  auto extra_bits = kZero;
60
20.3k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
1.03M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
1.01M
    const auto val = LoadU(du, values + i);
63
1.01M
    const auto is_large = Gt(val, kLargeThreshold);
64
1.01M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
1.01M
    const auto not_literal = Ge(val, kSplit);
66
1.01M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
1.01M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
1.01M
    const auto l = And(val, kMaskL);
69
1.01M
    const auto exp = ShiftRight<23>(b);
70
1.01M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
1.01M
    const auto n = Sub(exp_fixed, kExpOffset);
72
1.01M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
1.01M
    const auto m = ShiftRight<23 - M - L>(b);
74
1.01M
    const auto a = Add(kBase, Mul(n, kMulN));
75
1.01M
    const auto d = And(m, kMaskM);
76
1.01M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
1.01M
    const auto c = Or(a, l);
78
1.01M
    extra_bits = Add(extra_bits, eb_fixed);
79
1.01M
    const auto t = Or(c, d);
80
1.01M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
1.01M
    Store(t_fixed, du, out + i);
82
1.01M
  }
83
20.3k
  if (last_full < len) {
84
17.3k
    const auto stop = Set(du, len);
85
17.3k
    const auto fence = Iota(du, last_full);
86
17.3k
    const auto take = Lt(fence, stop);
87
17.3k
    const auto val = LoadU(du, values + last_full);
88
17.3k
    const auto is_large = Gt(val, kLargeThreshold);
89
17.3k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
17.3k
    const auto not_literal = Ge(val, kSplit);
91
17.3k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
17.3k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
17.3k
    const auto l = And(val, kMaskL);
94
17.3k
    const auto exp = ShiftRight<23>(b);
95
17.3k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
17.3k
    const auto n = Sub(exp_fixed, kExpOffset);
97
17.3k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
17.3k
    const auto m = ShiftRight<23 - M - L>(b);
99
17.3k
    const auto a = Add(kBase, Mul(n, kMulN));
100
17.3k
    const auto d = And(m, kMaskM);
101
17.3k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
17.3k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
17.3k
    const auto c = Or(a, l);
104
17.3k
    extra_bits = Add(extra_bits, eb_masked);
105
17.3k
    const auto t = Or(c, d);
106
17.3k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
17.3k
    Store(t_fixed, du, out + last_full);
108
17.3k
  }
109
20.3k
  return GetLane(SumOfLanes(du, extra_bits));
110
20.3k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<4ul, 1ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
100k
                               uint32_t* JXL_RESTRICT out) {
45
100k
  const HWY_FULL(uint32_t) du;
46
100k
  const HWY_FULL(float) df;
47
100k
  const auto kZero = Zero(du);
48
100k
  const auto kSplit = Set(du, 1 << E);
49
100k
  const auto kExpOffset = Set(du, 127);
50
100k
  const auto kEBOffset = Set(du, 127 + M + L);
51
100k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
100k
  const auto kMulN = Set(du, 1 << (M + L));
53
100k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
100k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
100k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
100k
  constexpr size_t kLargeShiftVal = 10;
57
100k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
100k
  auto extra_bits = kZero;
60
100k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
8.98M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
8.88M
    const auto val = LoadU(du, values + i);
63
8.88M
    const auto is_large = Gt(val, kLargeThreshold);
64
8.88M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
8.88M
    const auto not_literal = Ge(val, kSplit);
66
8.88M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
8.88M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
8.88M
    const auto l = And(val, kMaskL);
69
8.88M
    const auto exp = ShiftRight<23>(b);
70
8.88M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
8.88M
    const auto n = Sub(exp_fixed, kExpOffset);
72
8.88M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
8.88M
    const auto m = ShiftRight<23 - M - L>(b);
74
8.88M
    const auto a = Add(kBase, Mul(n, kMulN));
75
8.88M
    const auto d = And(m, kMaskM);
76
8.88M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
8.88M
    const auto c = Or(a, l);
78
8.88M
    extra_bits = Add(extra_bits, eb_fixed);
79
8.88M
    const auto t = Or(c, d);
80
8.88M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
8.88M
    Store(t_fixed, du, out + i);
82
8.88M
  }
83
100k
  if (last_full < len) {
84
86.6k
    const auto stop = Set(du, len);
85
86.6k
    const auto fence = Iota(du, last_full);
86
86.6k
    const auto take = Lt(fence, stop);
87
86.6k
    const auto val = LoadU(du, values + last_full);
88
86.6k
    const auto is_large = Gt(val, kLargeThreshold);
89
86.6k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
86.6k
    const auto not_literal = Ge(val, kSplit);
91
86.6k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
86.6k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
86.6k
    const auto l = And(val, kMaskL);
94
86.6k
    const auto exp = ShiftRight<23>(b);
95
86.6k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
86.6k
    const auto n = Sub(exp_fixed, kExpOffset);
97
86.6k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
86.6k
    const auto m = ShiftRight<23 - M - L>(b);
99
86.6k
    const auto a = Add(kBase, Mul(n, kMulN));
100
86.6k
    const auto d = And(m, kMaskM);
101
86.6k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
86.6k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
86.6k
    const auto c = Or(a, l);
104
86.6k
    extra_bits = Add(extra_bits, eb_masked);
105
86.6k
    const auto t = Or(c, d);
106
86.6k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
86.6k
    Store(t_fixed, du, out + last_full);
108
86.6k
  }
109
100k
  return GetLane(SumOfLanes(du, extra_bits));
110
100k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<4ul, 1ul, 3ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
20.3k
                               uint32_t* JXL_RESTRICT out) {
45
20.3k
  const HWY_FULL(uint32_t) du;
46
20.3k
  const HWY_FULL(float) df;
47
20.3k
  const auto kZero = Zero(du);
48
20.3k
  const auto kSplit = Set(du, 1 << E);
49
20.3k
  const auto kExpOffset = Set(du, 127);
50
20.3k
  const auto kEBOffset = Set(du, 127 + M + L);
51
20.3k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
20.3k
  const auto kMulN = Set(du, 1 << (M + L));
53
20.3k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
20.3k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
20.3k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
20.3k
  constexpr size_t kLargeShiftVal = 10;
57
20.3k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
20.3k
  auto extra_bits = kZero;
60
20.3k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
1.03M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
1.01M
    const auto val = LoadU(du, values + i);
63
1.01M
    const auto is_large = Gt(val, kLargeThreshold);
64
1.01M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
1.01M
    const auto not_literal = Ge(val, kSplit);
66
1.01M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
1.01M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
1.01M
    const auto l = And(val, kMaskL);
69
1.01M
    const auto exp = ShiftRight<23>(b);
70
1.01M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
1.01M
    const auto n = Sub(exp_fixed, kExpOffset);
72
1.01M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
1.01M
    const auto m = ShiftRight<23 - M - L>(b);
74
1.01M
    const auto a = Add(kBase, Mul(n, kMulN));
75
1.01M
    const auto d = And(m, kMaskM);
76
1.01M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
1.01M
    const auto c = Or(a, l);
78
1.01M
    extra_bits = Add(extra_bits, eb_fixed);
79
1.01M
    const auto t = Or(c, d);
80
1.01M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
1.01M
    Store(t_fixed, du, out + i);
82
1.01M
  }
83
20.3k
  if (last_full < len) {
84
17.3k
    const auto stop = Set(du, len);
85
17.3k
    const auto fence = Iota(du, last_full);
86
17.3k
    const auto take = Lt(fence, stop);
87
17.3k
    const auto val = LoadU(du, values + last_full);
88
17.3k
    const auto is_large = Gt(val, kLargeThreshold);
89
17.3k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
17.3k
    const auto not_literal = Ge(val, kSplit);
91
17.3k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
17.3k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
17.3k
    const auto l = And(val, kMaskL);
94
17.3k
    const auto exp = ShiftRight<23>(b);
95
17.3k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
17.3k
    const auto n = Sub(exp_fixed, kExpOffset);
97
17.3k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
17.3k
    const auto m = ShiftRight<23 - M - L>(b);
99
17.3k
    const auto a = Add(kBase, Mul(n, kMulN));
100
17.3k
    const auto d = And(m, kMaskM);
101
17.3k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
17.3k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
17.3k
    const auto c = Or(a, l);
104
17.3k
    extra_bits = Add(extra_bits, eb_masked);
105
17.3k
    const auto t = Or(c, d);
106
17.3k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
17.3k
    Store(t_fixed, du, out + last_full);
108
17.3k
  }
109
20.3k
  return GetLane(SumOfLanes(du, extra_bits));
110
20.3k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<4ul, 2ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
100k
                               uint32_t* JXL_RESTRICT out) {
45
100k
  const HWY_FULL(uint32_t) du;
46
100k
  const HWY_FULL(float) df;
47
100k
  const auto kZero = Zero(du);
48
100k
  const auto kSplit = Set(du, 1 << E);
49
100k
  const auto kExpOffset = Set(du, 127);
50
100k
  const auto kEBOffset = Set(du, 127 + M + L);
51
100k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
100k
  const auto kMulN = Set(du, 1 << (M + L));
53
100k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
100k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
100k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
100k
  constexpr size_t kLargeShiftVal = 10;
57
100k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
100k
  auto extra_bits = kZero;
60
100k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
8.98M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
8.88M
    const auto val = LoadU(du, values + i);
63
8.88M
    const auto is_large = Gt(val, kLargeThreshold);
64
8.88M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
8.88M
    const auto not_literal = Ge(val, kSplit);
66
8.88M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
8.88M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
8.88M
    const auto l = And(val, kMaskL);
69
8.88M
    const auto exp = ShiftRight<23>(b);
70
8.88M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
8.88M
    const auto n = Sub(exp_fixed, kExpOffset);
72
8.88M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
8.88M
    const auto m = ShiftRight<23 - M - L>(b);
74
8.88M
    const auto a = Add(kBase, Mul(n, kMulN));
75
8.88M
    const auto d = And(m, kMaskM);
76
8.88M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
8.88M
    const auto c = Or(a, l);
78
8.88M
    extra_bits = Add(extra_bits, eb_fixed);
79
8.88M
    const auto t = Or(c, d);
80
8.88M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
8.88M
    Store(t_fixed, du, out + i);
82
8.88M
  }
83
100k
  if (last_full < len) {
84
86.6k
    const auto stop = Set(du, len);
85
86.6k
    const auto fence = Iota(du, last_full);
86
86.6k
    const auto take = Lt(fence, stop);
87
86.6k
    const auto val = LoadU(du, values + last_full);
88
86.6k
    const auto is_large = Gt(val, kLargeThreshold);
89
86.6k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
86.6k
    const auto not_literal = Ge(val, kSplit);
91
86.6k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
86.6k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
86.6k
    const auto l = And(val, kMaskL);
94
86.6k
    const auto exp = ShiftRight<23>(b);
95
86.6k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
86.6k
    const auto n = Sub(exp_fixed, kExpOffset);
97
86.6k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
86.6k
    const auto m = ShiftRight<23 - M - L>(b);
99
86.6k
    const auto a = Add(kBase, Mul(n, kMulN));
100
86.6k
    const auto d = And(m, kMaskM);
101
86.6k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
86.6k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
86.6k
    const auto c = Or(a, l);
104
86.6k
    extra_bits = Add(extra_bits, eb_masked);
105
86.6k
    const auto t = Or(c, d);
106
86.6k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
86.6k
    Store(t_fixed, du, out + last_full);
108
86.6k
  }
109
100k
  return GetLane(SumOfLanes(du, extra_bits));
110
100k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<4ul, 2ul, 1ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
20.3k
                               uint32_t* JXL_RESTRICT out) {
45
20.3k
  const HWY_FULL(uint32_t) du;
46
20.3k
  const HWY_FULL(float) df;
47
20.3k
  const auto kZero = Zero(du);
48
20.3k
  const auto kSplit = Set(du, 1 << E);
49
20.3k
  const auto kExpOffset = Set(du, 127);
50
20.3k
  const auto kEBOffset = Set(du, 127 + M + L);
51
20.3k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
20.3k
  const auto kMulN = Set(du, 1 << (M + L));
53
20.3k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
20.3k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
20.3k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
20.3k
  constexpr size_t kLargeShiftVal = 10;
57
20.3k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
20.3k
  auto extra_bits = kZero;
60
20.3k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
1.03M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
1.01M
    const auto val = LoadU(du, values + i);
63
1.01M
    const auto is_large = Gt(val, kLargeThreshold);
64
1.01M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
1.01M
    const auto not_literal = Ge(val, kSplit);
66
1.01M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
1.01M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
1.01M
    const auto l = And(val, kMaskL);
69
1.01M
    const auto exp = ShiftRight<23>(b);
70
1.01M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
1.01M
    const auto n = Sub(exp_fixed, kExpOffset);
72
1.01M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
1.01M
    const auto m = ShiftRight<23 - M - L>(b);
74
1.01M
    const auto a = Add(kBase, Mul(n, kMulN));
75
1.01M
    const auto d = And(m, kMaskM);
76
1.01M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
1.01M
    const auto c = Or(a, l);
78
1.01M
    extra_bits = Add(extra_bits, eb_fixed);
79
1.01M
    const auto t = Or(c, d);
80
1.01M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
1.01M
    Store(t_fixed, du, out + i);
82
1.01M
  }
83
20.3k
  if (last_full < len) {
84
17.3k
    const auto stop = Set(du, len);
85
17.3k
    const auto fence = Iota(du, last_full);
86
17.3k
    const auto take = Lt(fence, stop);
87
17.3k
    const auto val = LoadU(du, values + last_full);
88
17.3k
    const auto is_large = Gt(val, kLargeThreshold);
89
17.3k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
17.3k
    const auto not_literal = Ge(val, kSplit);
91
17.3k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
17.3k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
17.3k
    const auto l = And(val, kMaskL);
94
17.3k
    const auto exp = ShiftRight<23>(b);
95
17.3k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
17.3k
    const auto n = Sub(exp_fixed, kExpOffset);
97
17.3k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
17.3k
    const auto m = ShiftRight<23 - M - L>(b);
99
17.3k
    const auto a = Add(kBase, Mul(n, kMulN));
100
17.3k
    const auto d = And(m, kMaskM);
101
17.3k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
17.3k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
17.3k
    const auto c = Or(a, l);
104
17.3k
    extra_bits = Add(extra_bits, eb_masked);
105
17.3k
    const auto t = Or(c, d);
106
17.3k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
17.3k
    Store(t_fixed, du, out + last_full);
108
17.3k
  }
109
20.3k
  return GetLane(SumOfLanes(du, extra_bits));
110
20.3k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<4ul, 2ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
20.3k
                               uint32_t* JXL_RESTRICT out) {
45
20.3k
  const HWY_FULL(uint32_t) du;
46
20.3k
  const HWY_FULL(float) df;
47
20.3k
  const auto kZero = Zero(du);
48
20.3k
  const auto kSplit = Set(du, 1 << E);
49
20.3k
  const auto kExpOffset = Set(du, 127);
50
20.3k
  const auto kEBOffset = Set(du, 127 + M + L);
51
20.3k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
20.3k
  const auto kMulN = Set(du, 1 << (M + L));
53
20.3k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
20.3k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
20.3k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
20.3k
  constexpr size_t kLargeShiftVal = 10;
57
20.3k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
20.3k
  auto extra_bits = kZero;
60
20.3k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
1.03M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
1.01M
    const auto val = LoadU(du, values + i);
63
1.01M
    const auto is_large = Gt(val, kLargeThreshold);
64
1.01M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
1.01M
    const auto not_literal = Ge(val, kSplit);
66
1.01M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
1.01M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
1.01M
    const auto l = And(val, kMaskL);
69
1.01M
    const auto exp = ShiftRight<23>(b);
70
1.01M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
1.01M
    const auto n = Sub(exp_fixed, kExpOffset);
72
1.01M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
1.01M
    const auto m = ShiftRight<23 - M - L>(b);
74
1.01M
    const auto a = Add(kBase, Mul(n, kMulN));
75
1.01M
    const auto d = And(m, kMaskM);
76
1.01M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
1.01M
    const auto c = Or(a, l);
78
1.01M
    extra_bits = Add(extra_bits, eb_fixed);
79
1.01M
    const auto t = Or(c, d);
80
1.01M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
1.01M
    Store(t_fixed, du, out + i);
82
1.01M
  }
83
20.3k
  if (last_full < len) {
84
17.3k
    const auto stop = Set(du, len);
85
17.3k
    const auto fence = Iota(du, last_full);
86
17.3k
    const auto take = Lt(fence, stop);
87
17.3k
    const auto val = LoadU(du, values + last_full);
88
17.3k
    const auto is_large = Gt(val, kLargeThreshold);
89
17.3k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
17.3k
    const auto not_literal = Ge(val, kSplit);
91
17.3k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
17.3k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
17.3k
    const auto l = And(val, kMaskL);
94
17.3k
    const auto exp = ShiftRight<23>(b);
95
17.3k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
17.3k
    const auto n = Sub(exp_fixed, kExpOffset);
97
17.3k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
17.3k
    const auto m = ShiftRight<23 - M - L>(b);
99
17.3k
    const auto a = Add(kBase, Mul(n, kMulN));
100
17.3k
    const auto d = And(m, kMaskM);
101
17.3k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
17.3k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
17.3k
    const auto c = Or(a, l);
104
17.3k
    extra_bits = Add(extra_bits, eb_masked);
105
17.3k
    const auto t = Or(c, d);
106
17.3k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
17.3k
    Store(t_fixed, du, out + last_full);
108
17.3k
  }
109
20.3k
  return GetLane(SumOfLanes(du, extra_bits));
110
20.3k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<5ul, 1ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
20.3k
                               uint32_t* JXL_RESTRICT out) {
45
20.3k
  const HWY_FULL(uint32_t) du;
46
20.3k
  const HWY_FULL(float) df;
47
20.3k
  const auto kZero = Zero(du);
48
20.3k
  const auto kSplit = Set(du, 1 << E);
49
20.3k
  const auto kExpOffset = Set(du, 127);
50
20.3k
  const auto kEBOffset = Set(du, 127 + M + L);
51
20.3k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
20.3k
  const auto kMulN = Set(du, 1 << (M + L));
53
20.3k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
20.3k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
20.3k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
20.3k
  constexpr size_t kLargeShiftVal = 10;
57
20.3k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
20.3k
  auto extra_bits = kZero;
60
20.3k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
1.03M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
1.01M
    const auto val = LoadU(du, values + i);
63
1.01M
    const auto is_large = Gt(val, kLargeThreshold);
64
1.01M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
1.01M
    const auto not_literal = Ge(val, kSplit);
66
1.01M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
1.01M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
1.01M
    const auto l = And(val, kMaskL);
69
1.01M
    const auto exp = ShiftRight<23>(b);
70
1.01M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
1.01M
    const auto n = Sub(exp_fixed, kExpOffset);
72
1.01M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
1.01M
    const auto m = ShiftRight<23 - M - L>(b);
74
1.01M
    const auto a = Add(kBase, Mul(n, kMulN));
75
1.01M
    const auto d = And(m, kMaskM);
76
1.01M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
1.01M
    const auto c = Or(a, l);
78
1.01M
    extra_bits = Add(extra_bits, eb_fixed);
79
1.01M
    const auto t = Or(c, d);
80
1.01M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
1.01M
    Store(t_fixed, du, out + i);
82
1.01M
  }
83
20.3k
  if (last_full < len) {
84
17.3k
    const auto stop = Set(du, len);
85
17.3k
    const auto fence = Iota(du, last_full);
86
17.3k
    const auto take = Lt(fence, stop);
87
17.3k
    const auto val = LoadU(du, values + last_full);
88
17.3k
    const auto is_large = Gt(val, kLargeThreshold);
89
17.3k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
17.3k
    const auto not_literal = Ge(val, kSplit);
91
17.3k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
17.3k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
17.3k
    const auto l = And(val, kMaskL);
94
17.3k
    const auto exp = ShiftRight<23>(b);
95
17.3k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
17.3k
    const auto n = Sub(exp_fixed, kExpOffset);
97
17.3k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
17.3k
    const auto m = ShiftRight<23 - M - L>(b);
99
17.3k
    const auto a = Add(kBase, Mul(n, kMulN));
100
17.3k
    const auto d = And(m, kMaskM);
101
17.3k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
17.3k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
17.3k
    const auto c = Or(a, l);
104
17.3k
    extra_bits = Add(extra_bits, eb_masked);
105
17.3k
    const auto t = Or(c, d);
106
17.3k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
17.3k
    Store(t_fixed, du, out + last_full);
108
17.3k
  }
109
20.3k
  return GetLane(SumOfLanes(du, extra_bits));
110
20.3k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<5ul, 1ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
20.3k
                               uint32_t* JXL_RESTRICT out) {
45
20.3k
  const HWY_FULL(uint32_t) du;
46
20.3k
  const HWY_FULL(float) df;
47
20.3k
  const auto kZero = Zero(du);
48
20.3k
  const auto kSplit = Set(du, 1 << E);
49
20.3k
  const auto kExpOffset = Set(du, 127);
50
20.3k
  const auto kEBOffset = Set(du, 127 + M + L);
51
20.3k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
20.3k
  const auto kMulN = Set(du, 1 << (M + L));
53
20.3k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
20.3k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
20.3k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
20.3k
  constexpr size_t kLargeShiftVal = 10;
57
20.3k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
20.3k
  auto extra_bits = kZero;
60
20.3k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
1.03M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
1.01M
    const auto val = LoadU(du, values + i);
63
1.01M
    const auto is_large = Gt(val, kLargeThreshold);
64
1.01M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
1.01M
    const auto not_literal = Ge(val, kSplit);
66
1.01M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
1.01M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
1.01M
    const auto l = And(val, kMaskL);
69
1.01M
    const auto exp = ShiftRight<23>(b);
70
1.01M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
1.01M
    const auto n = Sub(exp_fixed, kExpOffset);
72
1.01M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
1.01M
    const auto m = ShiftRight<23 - M - L>(b);
74
1.01M
    const auto a = Add(kBase, Mul(n, kMulN));
75
1.01M
    const auto d = And(m, kMaskM);
76
1.01M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
1.01M
    const auto c = Or(a, l);
78
1.01M
    extra_bits = Add(extra_bits, eb_fixed);
79
1.01M
    const auto t = Or(c, d);
80
1.01M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
1.01M
    Store(t_fixed, du, out + i);
82
1.01M
  }
83
20.3k
  if (last_full < len) {
84
17.3k
    const auto stop = Set(du, len);
85
17.3k
    const auto fence = Iota(du, last_full);
86
17.3k
    const auto take = Lt(fence, stop);
87
17.3k
    const auto val = LoadU(du, values + last_full);
88
17.3k
    const auto is_large = Gt(val, kLargeThreshold);
89
17.3k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
17.3k
    const auto not_literal = Ge(val, kSplit);
91
17.3k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
17.3k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
17.3k
    const auto l = And(val, kMaskL);
94
17.3k
    const auto exp = ShiftRight<23>(b);
95
17.3k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
17.3k
    const auto n = Sub(exp_fixed, kExpOffset);
97
17.3k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
17.3k
    const auto m = ShiftRight<23 - M - L>(b);
99
17.3k
    const auto a = Add(kBase, Mul(n, kMulN));
100
17.3k
    const auto d = And(m, kMaskM);
101
17.3k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
17.3k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
17.3k
    const auto c = Or(a, l);
104
17.3k
    extra_bits = Add(extra_bits, eb_masked);
105
17.3k
    const auto t = Or(c, d);
106
17.3k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
17.3k
    Store(t_fixed, du, out + last_full);
108
17.3k
  }
109
20.3k
  return GetLane(SumOfLanes(du, extra_bits));
110
20.3k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<5ul, 1ul, 4ul>(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.03M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
1.01M
    const auto val = LoadU(du, values + i);
63
1.01M
    const auto is_large = Gt(val, kLargeThreshold);
64
1.01M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
1.01M
    const auto not_literal = Ge(val, kSplit);
66
1.01M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
1.01M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
1.01M
    const auto l = And(val, kMaskL);
69
1.01M
    const auto exp = ShiftRight<23>(b);
70
1.01M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
1.01M
    const auto n = Sub(exp_fixed, kExpOffset);
72
1.01M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
1.01M
    const auto m = ShiftRight<23 - M - L>(b);
74
1.01M
    const auto a = Add(kBase, Mul(n, kMulN));
75
1.01M
    const auto d = And(m, kMaskM);
76
1.01M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
1.01M
    const auto c = Or(a, l);
78
1.01M
    extra_bits = Add(extra_bits, eb_fixed);
79
1.01M
    const auto t = Or(c, d);
80
1.01M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
1.01M
    Store(t_fixed, du, out + i);
82
1.01M
  }
83
20.2k
  if (last_full < len) {
84
17.3k
    const auto stop = Set(du, len);
85
17.3k
    const auto fence = Iota(du, last_full);
86
17.3k
    const auto take = Lt(fence, stop);
87
17.3k
    const auto val = LoadU(du, values + last_full);
88
17.3k
    const auto is_large = Gt(val, kLargeThreshold);
89
17.3k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
17.3k
    const auto not_literal = Ge(val, kSplit);
91
17.3k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
17.3k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
17.3k
    const auto l = And(val, kMaskL);
94
17.3k
    const auto exp = ShiftRight<23>(b);
95
17.3k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
17.3k
    const auto n = Sub(exp_fixed, kExpOffset);
97
17.3k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
17.3k
    const auto m = ShiftRight<23 - M - L>(b);
99
17.3k
    const auto a = Add(kBase, Mul(n, kMulN));
100
17.3k
    const auto d = And(m, kMaskM);
101
17.3k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
17.3k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
17.3k
    const auto c = Or(a, l);
104
17.3k
    extra_bits = Add(extra_bits, eb_masked);
105
17.3k
    const auto t = Or(c, d);
106
17.3k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
17.3k
    Store(t_fixed, du, out + last_full);
108
17.3k
  }
109
20.2k
  return GetLane(SumOfLanes(du, extra_bits));
110
20.2k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<5ul, 2ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
20.3k
                               uint32_t* JXL_RESTRICT out) {
45
20.3k
  const HWY_FULL(uint32_t) du;
46
20.3k
  const HWY_FULL(float) df;
47
20.3k
  const auto kZero = Zero(du);
48
20.3k
  const auto kSplit = Set(du, 1 << E);
49
20.3k
  const auto kExpOffset = Set(du, 127);
50
20.3k
  const auto kEBOffset = Set(du, 127 + M + L);
51
20.3k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
20.3k
  const auto kMulN = Set(du, 1 << (M + L));
53
20.3k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
20.3k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
20.3k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
20.3k
  constexpr size_t kLargeShiftVal = 10;
57
20.3k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
20.3k
  auto extra_bits = kZero;
60
20.3k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
1.03M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
1.01M
    const auto val = LoadU(du, values + i);
63
1.01M
    const auto is_large = Gt(val, kLargeThreshold);
64
1.01M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
1.01M
    const auto not_literal = Ge(val, kSplit);
66
1.01M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
1.01M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
1.01M
    const auto l = And(val, kMaskL);
69
1.01M
    const auto exp = ShiftRight<23>(b);
70
1.01M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
1.01M
    const auto n = Sub(exp_fixed, kExpOffset);
72
1.01M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
1.01M
    const auto m = ShiftRight<23 - M - L>(b);
74
1.01M
    const auto a = Add(kBase, Mul(n, kMulN));
75
1.01M
    const auto d = And(m, kMaskM);
76
1.01M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
1.01M
    const auto c = Or(a, l);
78
1.01M
    extra_bits = Add(extra_bits, eb_fixed);
79
1.01M
    const auto t = Or(c, d);
80
1.01M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
1.01M
    Store(t_fixed, du, out + i);
82
1.01M
  }
83
20.3k
  if (last_full < len) {
84
17.3k
    const auto stop = Set(du, len);
85
17.3k
    const auto fence = Iota(du, last_full);
86
17.3k
    const auto take = Lt(fence, stop);
87
17.3k
    const auto val = LoadU(du, values + last_full);
88
17.3k
    const auto is_large = Gt(val, kLargeThreshold);
89
17.3k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
17.3k
    const auto not_literal = Ge(val, kSplit);
91
17.3k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
17.3k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
17.3k
    const auto l = And(val, kMaskL);
94
17.3k
    const auto exp = ShiftRight<23>(b);
95
17.3k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
17.3k
    const auto n = Sub(exp_fixed, kExpOffset);
97
17.3k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
17.3k
    const auto m = ShiftRight<23 - M - L>(b);
99
17.3k
    const auto a = Add(kBase, Mul(n, kMulN));
100
17.3k
    const auto d = And(m, kMaskM);
101
17.3k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
17.3k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
17.3k
    const auto c = Or(a, l);
104
17.3k
    extra_bits = Add(extra_bits, eb_masked);
105
17.3k
    const auto t = Or(c, d);
106
17.3k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
17.3k
    Store(t_fixed, du, out + last_full);
108
17.3k
  }
109
20.3k
  return GetLane(SumOfLanes(du, extra_bits));
110
20.3k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<5ul, 2ul, 1ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
20.3k
                               uint32_t* JXL_RESTRICT out) {
45
20.3k
  const HWY_FULL(uint32_t) du;
46
20.3k
  const HWY_FULL(float) df;
47
20.3k
  const auto kZero = Zero(du);
48
20.3k
  const auto kSplit = Set(du, 1 << E);
49
20.3k
  const auto kExpOffset = Set(du, 127);
50
20.3k
  const auto kEBOffset = Set(du, 127 + M + L);
51
20.3k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
20.3k
  const auto kMulN = Set(du, 1 << (M + L));
53
20.3k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
20.3k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
20.3k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
20.3k
  constexpr size_t kLargeShiftVal = 10;
57
20.3k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
20.3k
  auto extra_bits = kZero;
60
20.3k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
1.03M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
1.01M
    const auto val = LoadU(du, values + i);
63
1.01M
    const auto is_large = Gt(val, kLargeThreshold);
64
1.01M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
1.01M
    const auto not_literal = Ge(val, kSplit);
66
1.01M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
1.01M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
1.01M
    const auto l = And(val, kMaskL);
69
1.01M
    const auto exp = ShiftRight<23>(b);
70
1.01M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
1.01M
    const auto n = Sub(exp_fixed, kExpOffset);
72
1.01M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
1.01M
    const auto m = ShiftRight<23 - M - L>(b);
74
1.01M
    const auto a = Add(kBase, Mul(n, kMulN));
75
1.01M
    const auto d = And(m, kMaskM);
76
1.01M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
1.01M
    const auto c = Or(a, l);
78
1.01M
    extra_bits = Add(extra_bits, eb_fixed);
79
1.01M
    const auto t = Or(c, d);
80
1.01M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
1.01M
    Store(t_fixed, du, out + i);
82
1.01M
  }
83
20.3k
  if (last_full < len) {
84
17.3k
    const auto stop = Set(du, len);
85
17.3k
    const auto fence = Iota(du, last_full);
86
17.3k
    const auto take = Lt(fence, stop);
87
17.3k
    const auto val = LoadU(du, values + last_full);
88
17.3k
    const auto is_large = Gt(val, kLargeThreshold);
89
17.3k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
17.3k
    const auto not_literal = Ge(val, kSplit);
91
17.3k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
17.3k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
17.3k
    const auto l = And(val, kMaskL);
94
17.3k
    const auto exp = ShiftRight<23>(b);
95
17.3k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
17.3k
    const auto n = Sub(exp_fixed, kExpOffset);
97
17.3k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
17.3k
    const auto m = ShiftRight<23 - M - L>(b);
99
17.3k
    const auto a = Add(kBase, Mul(n, kMulN));
100
17.3k
    const auto d = And(m, kMaskM);
101
17.3k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
17.3k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
17.3k
    const auto c = Or(a, l);
104
17.3k
    extra_bits = Add(extra_bits, eb_masked);
105
17.3k
    const auto t = Or(c, d);
106
17.3k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
17.3k
    Store(t_fixed, du, out + last_full);
108
17.3k
  }
109
20.3k
  return GetLane(SumOfLanes(du, extra_bits));
110
20.3k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<5ul, 2ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
20.3k
                               uint32_t* JXL_RESTRICT out) {
45
20.3k
  const HWY_FULL(uint32_t) du;
46
20.3k
  const HWY_FULL(float) df;
47
20.3k
  const auto kZero = Zero(du);
48
20.3k
  const auto kSplit = Set(du, 1 << E);
49
20.3k
  const auto kExpOffset = Set(du, 127);
50
20.3k
  const auto kEBOffset = Set(du, 127 + M + L);
51
20.3k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
20.3k
  const auto kMulN = Set(du, 1 << (M + L));
53
20.3k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
20.3k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
20.3k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
20.3k
  constexpr size_t kLargeShiftVal = 10;
57
20.3k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
20.3k
  auto extra_bits = kZero;
60
20.3k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
1.03M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
1.01M
    const auto val = LoadU(du, values + i);
63
1.01M
    const auto is_large = Gt(val, kLargeThreshold);
64
1.01M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
1.01M
    const auto not_literal = Ge(val, kSplit);
66
1.01M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
1.01M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
1.01M
    const auto l = And(val, kMaskL);
69
1.01M
    const auto exp = ShiftRight<23>(b);
70
1.01M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
1.01M
    const auto n = Sub(exp_fixed, kExpOffset);
72
1.01M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
1.01M
    const auto m = ShiftRight<23 - M - L>(b);
74
1.01M
    const auto a = Add(kBase, Mul(n, kMulN));
75
1.01M
    const auto d = And(m, kMaskM);
76
1.01M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
1.01M
    const auto c = Or(a, l);
78
1.01M
    extra_bits = Add(extra_bits, eb_fixed);
79
1.01M
    const auto t = Or(c, d);
80
1.01M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
1.01M
    Store(t_fixed, du, out + i);
82
1.01M
  }
83
20.3k
  if (last_full < len) {
84
17.3k
    const auto stop = Set(du, len);
85
17.3k
    const auto fence = Iota(du, last_full);
86
17.3k
    const auto take = Lt(fence, stop);
87
17.3k
    const auto val = LoadU(du, values + last_full);
88
17.3k
    const auto is_large = Gt(val, kLargeThreshold);
89
17.3k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
17.3k
    const auto not_literal = Ge(val, kSplit);
91
17.3k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
17.3k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
17.3k
    const auto l = And(val, kMaskL);
94
17.3k
    const auto exp = ShiftRight<23>(b);
95
17.3k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
17.3k
    const auto n = Sub(exp_fixed, kExpOffset);
97
17.3k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
17.3k
    const auto m = ShiftRight<23 - M - L>(b);
99
17.3k
    const auto a = Add(kBase, Mul(n, kMulN));
100
17.3k
    const auto d = And(m, kMaskM);
101
17.3k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
17.3k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
17.3k
    const auto c = Or(a, l);
104
17.3k
    extra_bits = Add(extra_bits, eb_masked);
105
17.3k
    const auto t = Or(c, d);
106
17.3k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
17.3k
    Store(t_fixed, du, out + last_full);
108
17.3k
  }
109
20.3k
  return GetLane(SumOfLanes(du, extra_bits));
110
20.3k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<5ul, 2ul, 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.03M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
1.01M
    const auto val = LoadU(du, values + i);
63
1.01M
    const auto is_large = Gt(val, kLargeThreshold);
64
1.01M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
1.01M
    const auto not_literal = Ge(val, kSplit);
66
1.01M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
1.01M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
1.01M
    const auto l = And(val, kMaskL);
69
1.01M
    const auto exp = ShiftRight<23>(b);
70
1.01M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
1.01M
    const auto n = Sub(exp_fixed, kExpOffset);
72
1.01M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
1.01M
    const auto m = ShiftRight<23 - M - L>(b);
74
1.01M
    const auto a = Add(kBase, Mul(n, kMulN));
75
1.01M
    const auto d = And(m, kMaskM);
76
1.01M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
1.01M
    const auto c = Or(a, l);
78
1.01M
    extra_bits = Add(extra_bits, eb_fixed);
79
1.01M
    const auto t = Or(c, d);
80
1.01M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
1.01M
    Store(t_fixed, du, out + i);
82
1.01M
  }
83
20.2k
  if (last_full < len) {
84
17.3k
    const auto stop = Set(du, len);
85
17.3k
    const auto fence = Iota(du, last_full);
86
17.3k
    const auto take = Lt(fence, stop);
87
17.3k
    const auto val = LoadU(du, values + last_full);
88
17.3k
    const auto is_large = Gt(val, kLargeThreshold);
89
17.3k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
17.3k
    const auto not_literal = Ge(val, kSplit);
91
17.3k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
17.3k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
17.3k
    const auto l = And(val, kMaskL);
94
17.3k
    const auto exp = ShiftRight<23>(b);
95
17.3k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
17.3k
    const auto n = Sub(exp_fixed, kExpOffset);
97
17.3k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
17.3k
    const auto m = ShiftRight<23 - M - L>(b);
99
17.3k
    const auto a = Add(kBase, Mul(n, kMulN));
100
17.3k
    const auto d = And(m, kMaskM);
101
17.3k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
17.3k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
17.3k
    const auto c = Or(a, l);
104
17.3k
    extra_bits = Add(extra_bits, eb_masked);
105
17.3k
    const auto t = Or(c, d);
106
17.3k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
17.3k
    Store(t_fixed, du, out + last_full);
108
17.3k
  }
109
20.2k
  return GetLane(SumOfLanes(du, extra_bits));
110
20.2k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<6ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
20.3k
                               uint32_t* JXL_RESTRICT out) {
45
20.3k
  const HWY_FULL(uint32_t) du;
46
20.3k
  const HWY_FULL(float) df;
47
20.3k
  const auto kZero = Zero(du);
48
20.3k
  const auto kSplit = Set(du, 1 << E);
49
20.3k
  const auto kExpOffset = Set(du, 127);
50
20.3k
  const auto kEBOffset = Set(du, 127 + M + L);
51
20.3k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
20.3k
  const auto kMulN = Set(du, 1 << (M + L));
53
20.3k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
20.3k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
20.3k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
20.3k
  constexpr size_t kLargeShiftVal = 10;
57
20.3k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
20.3k
  auto extra_bits = kZero;
60
20.3k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
1.03M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
1.01M
    const auto val = LoadU(du, values + i);
63
1.01M
    const auto is_large = Gt(val, kLargeThreshold);
64
1.01M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
1.01M
    const auto not_literal = Ge(val, kSplit);
66
1.01M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
1.01M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
1.01M
    const auto l = And(val, kMaskL);
69
1.01M
    const auto exp = ShiftRight<23>(b);
70
1.01M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
1.01M
    const auto n = Sub(exp_fixed, kExpOffset);
72
1.01M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
1.01M
    const auto m = ShiftRight<23 - M - L>(b);
74
1.01M
    const auto a = Add(kBase, Mul(n, kMulN));
75
1.01M
    const auto d = And(m, kMaskM);
76
1.01M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
1.01M
    const auto c = Or(a, l);
78
1.01M
    extra_bits = Add(extra_bits, eb_fixed);
79
1.01M
    const auto t = Or(c, d);
80
1.01M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
1.01M
    Store(t_fixed, du, out + i);
82
1.01M
  }
83
20.3k
  if (last_full < len) {
84
17.3k
    const auto stop = Set(du, len);
85
17.3k
    const auto fence = Iota(du, last_full);
86
17.3k
    const auto take = Lt(fence, stop);
87
17.3k
    const auto val = LoadU(du, values + last_full);
88
17.3k
    const auto is_large = Gt(val, kLargeThreshold);
89
17.3k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
17.3k
    const auto not_literal = Ge(val, kSplit);
91
17.3k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
17.3k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
17.3k
    const auto l = And(val, kMaskL);
94
17.3k
    const auto exp = ShiftRight<23>(b);
95
17.3k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
17.3k
    const auto n = Sub(exp_fixed, kExpOffset);
97
17.3k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
17.3k
    const auto m = ShiftRight<23 - M - L>(b);
99
17.3k
    const auto a = Add(kBase, Mul(n, kMulN));
100
17.3k
    const auto d = And(m, kMaskM);
101
17.3k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
17.3k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
17.3k
    const auto c = Or(a, l);
104
17.3k
    extra_bits = Add(extra_bits, eb_masked);
105
17.3k
    const auto t = Or(c, d);
106
17.3k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
17.3k
    Store(t_fixed, du, out + last_full);
108
17.3k
  }
109
20.3k
  return GetLane(SumOfLanes(du, extra_bits));
110
20.3k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<6ul, 1ul, 5ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
17.8k
                               uint32_t* JXL_RESTRICT out) {
45
17.8k
  const HWY_FULL(uint32_t) du;
46
17.8k
  const HWY_FULL(float) df;
47
17.8k
  const auto kZero = Zero(du);
48
17.8k
  const auto kSplit = Set(du, 1 << E);
49
17.8k
  const auto kExpOffset = Set(du, 127);
50
17.8k
  const auto kEBOffset = Set(du, 127 + M + L);
51
17.8k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
17.8k
  const auto kMulN = Set(du, 1 << (M + L));
53
17.8k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
17.8k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
17.8k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
17.8k
  constexpr size_t kLargeShiftVal = 10;
57
17.8k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
17.8k
  auto extra_bits = kZero;
60
17.8k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
587k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
569k
    const auto val = LoadU(du, values + i);
63
569k
    const auto is_large = Gt(val, kLargeThreshold);
64
569k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
569k
    const auto not_literal = Ge(val, kSplit);
66
569k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
569k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
569k
    const auto l = And(val, kMaskL);
69
569k
    const auto exp = ShiftRight<23>(b);
70
569k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
569k
    const auto n = Sub(exp_fixed, kExpOffset);
72
569k
    const auto eb = Sub(exp_fixed, kEBOffset);
73
569k
    const auto m = ShiftRight<23 - M - L>(b);
74
569k
    const auto a = Add(kBase, Mul(n, kMulN));
75
569k
    const auto d = And(m, kMaskM);
76
569k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
569k
    const auto c = Or(a, l);
78
569k
    extra_bits = Add(extra_bits, eb_fixed);
79
569k
    const auto t = Or(c, d);
80
569k
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
569k
    Store(t_fixed, du, out + i);
82
569k
  }
83
17.8k
  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.8k
  return GetLane(SumOfLanes(du, extra_bits));
110
17.8k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<6ul, 2ul, 4ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
17.8k
                               uint32_t* JXL_RESTRICT out) {
45
17.8k
  const HWY_FULL(uint32_t) du;
46
17.8k
  const HWY_FULL(float) df;
47
17.8k
  const auto kZero = Zero(du);
48
17.8k
  const auto kSplit = Set(du, 1 << E);
49
17.8k
  const auto kExpOffset = Set(du, 127);
50
17.8k
  const auto kEBOffset = Set(du, 127 + M + L);
51
17.8k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
17.8k
  const auto kMulN = Set(du, 1 << (M + L));
53
17.8k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
17.8k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
17.8k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
17.8k
  constexpr size_t kLargeShiftVal = 10;
57
17.8k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
17.8k
  auto extra_bits = kZero;
60
17.8k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
587k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
569k
    const auto val = LoadU(du, values + i);
63
569k
    const auto is_large = Gt(val, kLargeThreshold);
64
569k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
569k
    const auto not_literal = Ge(val, kSplit);
66
569k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
569k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
569k
    const auto l = And(val, kMaskL);
69
569k
    const auto exp = ShiftRight<23>(b);
70
569k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
569k
    const auto n = Sub(exp_fixed, kExpOffset);
72
569k
    const auto eb = Sub(exp_fixed, kEBOffset);
73
569k
    const auto m = ShiftRight<23 - M - L>(b);
74
569k
    const auto a = Add(kBase, Mul(n, kMulN));
75
569k
    const auto d = And(m, kMaskM);
76
569k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
569k
    const auto c = Or(a, l);
78
569k
    extra_bits = Add(extra_bits, eb_fixed);
79
569k
    const auto t = Or(c, d);
80
569k
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
569k
    Store(t_fixed, du, out + i);
82
569k
  }
83
17.8k
  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.8k
  return GetLane(SumOfLanes(du, extra_bits));
110
17.8k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<7ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
20.3k
                               uint32_t* JXL_RESTRICT out) {
45
20.3k
  const HWY_FULL(uint32_t) du;
46
20.3k
  const HWY_FULL(float) df;
47
20.3k
  const auto kZero = Zero(du);
48
20.3k
  const auto kSplit = Set(du, 1 << E);
49
20.3k
  const auto kExpOffset = Set(du, 127);
50
20.3k
  const auto kEBOffset = Set(du, 127 + M + L);
51
20.3k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
20.3k
  const auto kMulN = Set(du, 1 << (M + L));
53
20.3k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
20.3k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
20.3k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
20.3k
  constexpr size_t kLargeShiftVal = 10;
57
20.3k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
20.3k
  auto extra_bits = kZero;
60
20.3k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
1.03M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
1.01M
    const auto val = LoadU(du, values + i);
63
1.01M
    const auto is_large = Gt(val, kLargeThreshold);
64
1.01M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
1.01M
    const auto not_literal = Ge(val, kSplit);
66
1.01M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
1.01M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
1.01M
    const auto l = And(val, kMaskL);
69
1.01M
    const auto exp = ShiftRight<23>(b);
70
1.01M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
1.01M
    const auto n = Sub(exp_fixed, kExpOffset);
72
1.01M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
1.01M
    const auto m = ShiftRight<23 - M - L>(b);
74
1.01M
    const auto a = Add(kBase, Mul(n, kMulN));
75
1.01M
    const auto d = And(m, kMaskM);
76
1.01M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
1.01M
    const auto c = Or(a, l);
78
1.01M
    extra_bits = Add(extra_bits, eb_fixed);
79
1.01M
    const auto t = Or(c, d);
80
1.01M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
1.01M
    Store(t_fixed, du, out + i);
82
1.01M
  }
83
20.3k
  if (last_full < len) {
84
17.3k
    const auto stop = Set(du, len);
85
17.3k
    const auto fence = Iota(du, last_full);
86
17.3k
    const auto take = Lt(fence, stop);
87
17.3k
    const auto val = LoadU(du, values + last_full);
88
17.3k
    const auto is_large = Gt(val, kLargeThreshold);
89
17.3k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
17.3k
    const auto not_literal = Ge(val, kSplit);
91
17.3k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
17.3k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
17.3k
    const auto l = And(val, kMaskL);
94
17.3k
    const auto exp = ShiftRight<23>(b);
95
17.3k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
17.3k
    const auto n = Sub(exp_fixed, kExpOffset);
97
17.3k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
17.3k
    const auto m = ShiftRight<23 - M - L>(b);
99
17.3k
    const auto a = Add(kBase, Mul(n, kMulN));
100
17.3k
    const auto d = And(m, kMaskM);
101
17.3k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
17.3k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
17.3k
    const auto c = Or(a, l);
104
17.3k
    extra_bits = Add(extra_bits, eb_masked);
105
17.3k
    const auto t = Or(c, d);
106
17.3k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
17.3k
    Store(t_fixed, du, out + last_full);
108
17.3k
  }
109
20.3k
  return GetLane(SumOfLanes(du, extra_bits));
110
20.3k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<8ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
15.4k
                               uint32_t* JXL_RESTRICT out) {
45
15.4k
  const HWY_FULL(uint32_t) du;
46
15.4k
  const HWY_FULL(float) df;
47
15.4k
  const auto kZero = Zero(du);
48
15.4k
  const auto kSplit = Set(du, 1 << E);
49
15.4k
  const auto kExpOffset = Set(du, 127);
50
15.4k
  const auto kEBOffset = Set(du, 127 + M + L);
51
15.4k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
15.4k
  const auto kMulN = Set(du, 1 << (M + L));
53
15.4k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
15.4k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
15.4k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
15.4k
  constexpr size_t kLargeShiftVal = 10;
57
15.4k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
15.4k
  auto extra_bits = kZero;
60
15.4k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
500k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
484k
    const auto val = LoadU(du, values + i);
63
484k
    const auto is_large = Gt(val, kLargeThreshold);
64
484k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
484k
    const auto not_literal = Ge(val, kSplit);
66
484k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
484k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
484k
    const auto l = And(val, kMaskL);
69
484k
    const auto exp = ShiftRight<23>(b);
70
484k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
484k
    const auto n = Sub(exp_fixed, kExpOffset);
72
484k
    const auto eb = Sub(exp_fixed, kEBOffset);
73
484k
    const auto m = ShiftRight<23 - M - L>(b);
74
484k
    const auto a = Add(kBase, Mul(n, kMulN));
75
484k
    const auto d = And(m, kMaskM);
76
484k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
484k
    const auto c = Or(a, l);
78
484k
    extra_bits = Add(extra_bits, eb_fixed);
79
484k
    const auto t = Or(c, d);
80
484k
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
484k
    Store(t_fixed, du, out + i);
82
484k
  }
83
15.4k
  if (last_full < len) {
84
13.2k
    const auto stop = Set(du, len);
85
13.2k
    const auto fence = Iota(du, last_full);
86
13.2k
    const auto take = Lt(fence, stop);
87
13.2k
    const auto val = LoadU(du, values + last_full);
88
13.2k
    const auto is_large = Gt(val, kLargeThreshold);
89
13.2k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
13.2k
    const auto not_literal = Ge(val, kSplit);
91
13.2k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
13.2k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
13.2k
    const auto l = And(val, kMaskL);
94
13.2k
    const auto exp = ShiftRight<23>(b);
95
13.2k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
13.2k
    const auto n = Sub(exp_fixed, kExpOffset);
97
13.2k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
13.2k
    const auto m = ShiftRight<23 - M - L>(b);
99
13.2k
    const auto a = Add(kBase, Mul(n, kMulN));
100
13.2k
    const auto d = And(m, kMaskM);
101
13.2k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
13.2k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
13.2k
    const auto c = Or(a, l);
104
13.2k
    extra_bits = Add(extra_bits, eb_masked);
105
13.2k
    const auto t = Or(c, d);
106
13.2k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
13.2k
    Store(t_fixed, du, out + last_full);
108
13.2k
  }
109
15.4k
  return GetLane(SumOfLanes(du, extra_bits));
110
15.4k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<9ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
15.4k
                               uint32_t* JXL_RESTRICT out) {
45
15.4k
  const HWY_FULL(uint32_t) du;
46
15.4k
  const HWY_FULL(float) df;
47
15.4k
  const auto kZero = Zero(du);
48
15.4k
  const auto kSplit = Set(du, 1 << E);
49
15.4k
  const auto kExpOffset = Set(du, 127);
50
15.4k
  const auto kEBOffset = Set(du, 127 + M + L);
51
15.4k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
15.4k
  const auto kMulN = Set(du, 1 << (M + L));
53
15.4k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
15.4k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
15.4k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
15.4k
  constexpr size_t kLargeShiftVal = 10;
57
15.4k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
15.4k
  auto extra_bits = kZero;
60
15.4k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
500k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
484k
    const auto val = LoadU(du, values + i);
63
484k
    const auto is_large = Gt(val, kLargeThreshold);
64
484k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
484k
    const auto not_literal = Ge(val, kSplit);
66
484k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
484k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
484k
    const auto l = And(val, kMaskL);
69
484k
    const auto exp = ShiftRight<23>(b);
70
484k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
484k
    const auto n = Sub(exp_fixed, kExpOffset);
72
484k
    const auto eb = Sub(exp_fixed, kEBOffset);
73
484k
    const auto m = ShiftRight<23 - M - L>(b);
74
484k
    const auto a = Add(kBase, Mul(n, kMulN));
75
484k
    const auto d = And(m, kMaskM);
76
484k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
484k
    const auto c = Or(a, l);
78
484k
    extra_bits = Add(extra_bits, eb_fixed);
79
484k
    const auto t = Or(c, d);
80
484k
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
484k
    Store(t_fixed, du, out + i);
82
484k
  }
83
15.4k
  if (last_full < len) {
84
13.2k
    const auto stop = Set(du, len);
85
13.2k
    const auto fence = Iota(du, last_full);
86
13.2k
    const auto take = Lt(fence, stop);
87
13.2k
    const auto val = LoadU(du, values + last_full);
88
13.2k
    const auto is_large = Gt(val, kLargeThreshold);
89
13.2k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
13.2k
    const auto not_literal = Ge(val, kSplit);
91
13.2k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
13.2k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
13.2k
    const auto l = And(val, kMaskL);
94
13.2k
    const auto exp = ShiftRight<23>(b);
95
13.2k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
13.2k
    const auto n = Sub(exp_fixed, kExpOffset);
97
13.2k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
13.2k
    const auto m = ShiftRight<23 - M - L>(b);
99
13.2k
    const auto a = Add(kBase, Mul(n, kMulN));
100
13.2k
    const auto d = And(m, kMaskM);
101
13.2k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
13.2k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
13.2k
    const auto c = Or(a, l);
104
13.2k
    extra_bits = Add(extra_bits, eb_masked);
105
13.2k
    const auto t = Or(c, d);
106
13.2k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
13.2k
    Store(t_fixed, du, out + last_full);
108
13.2k
  }
109
15.4k
  return GetLane(SumOfLanes(du, extra_bits));
110
15.4k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<10ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
15.4k
                               uint32_t* JXL_RESTRICT out) {
45
15.4k
  const HWY_FULL(uint32_t) du;
46
15.4k
  const HWY_FULL(float) df;
47
15.4k
  const auto kZero = Zero(du);
48
15.4k
  const auto kSplit = Set(du, 1 << E);
49
15.4k
  const auto kExpOffset = Set(du, 127);
50
15.4k
  const auto kEBOffset = Set(du, 127 + M + L);
51
15.4k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
15.4k
  const auto kMulN = Set(du, 1 << (M + L));
53
15.4k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
15.4k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
15.4k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
15.4k
  constexpr size_t kLargeShiftVal = 10;
57
15.4k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
15.4k
  auto extra_bits = kZero;
60
15.4k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
500k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
484k
    const auto val = LoadU(du, values + i);
63
484k
    const auto is_large = Gt(val, kLargeThreshold);
64
484k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
484k
    const auto not_literal = Ge(val, kSplit);
66
484k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
484k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
484k
    const auto l = And(val, kMaskL);
69
484k
    const auto exp = ShiftRight<23>(b);
70
484k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
484k
    const auto n = Sub(exp_fixed, kExpOffset);
72
484k
    const auto eb = Sub(exp_fixed, kEBOffset);
73
484k
    const auto m = ShiftRight<23 - M - L>(b);
74
484k
    const auto a = Add(kBase, Mul(n, kMulN));
75
484k
    const auto d = And(m, kMaskM);
76
484k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
484k
    const auto c = Or(a, l);
78
484k
    extra_bits = Add(extra_bits, eb_fixed);
79
484k
    const auto t = Or(c, d);
80
484k
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
484k
    Store(t_fixed, du, out + i);
82
484k
  }
83
15.4k
  if (last_full < len) {
84
13.2k
    const auto stop = Set(du, len);
85
13.2k
    const auto fence = Iota(du, last_full);
86
13.2k
    const auto take = Lt(fence, stop);
87
13.2k
    const auto val = LoadU(du, values + last_full);
88
13.2k
    const auto is_large = Gt(val, kLargeThreshold);
89
13.2k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
13.2k
    const auto not_literal = Ge(val, kSplit);
91
13.2k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
13.2k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
13.2k
    const auto l = And(val, kMaskL);
94
13.2k
    const auto exp = ShiftRight<23>(b);
95
13.2k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
13.2k
    const auto n = Sub(exp_fixed, kExpOffset);
97
13.2k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
13.2k
    const auto m = ShiftRight<23 - M - L>(b);
99
13.2k
    const auto a = Add(kBase, Mul(n, kMulN));
100
13.2k
    const auto d = And(m, kMaskM);
101
13.2k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
13.2k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
13.2k
    const auto c = Or(a, l);
104
13.2k
    extra_bits = Add(extra_bits, eb_masked);
105
13.2k
    const auto t = Or(c, d);
106
13.2k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
13.2k
    Store(t_fixed, du, out + last_full);
108
13.2k
  }
109
15.4k
  return GetLane(SumOfLanes(du, extra_bits));
110
15.4k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<11ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
15.4k
                               uint32_t* JXL_RESTRICT out) {
45
15.4k
  const HWY_FULL(uint32_t) du;
46
15.4k
  const HWY_FULL(float) df;
47
15.4k
  const auto kZero = Zero(du);
48
15.4k
  const auto kSplit = Set(du, 1 << E);
49
15.4k
  const auto kExpOffset = Set(du, 127);
50
15.4k
  const auto kEBOffset = Set(du, 127 + M + L);
51
15.4k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
15.4k
  const auto kMulN = Set(du, 1 << (M + L));
53
15.4k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
15.4k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
15.4k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
15.4k
  constexpr size_t kLargeShiftVal = 10;
57
15.4k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
15.4k
  auto extra_bits = kZero;
60
15.4k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
500k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
484k
    const auto val = LoadU(du, values + i);
63
484k
    const auto is_large = Gt(val, kLargeThreshold);
64
484k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
484k
    const auto not_literal = Ge(val, kSplit);
66
484k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
484k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
484k
    const auto l = And(val, kMaskL);
69
484k
    const auto exp = ShiftRight<23>(b);
70
484k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
484k
    const auto n = Sub(exp_fixed, kExpOffset);
72
484k
    const auto eb = Sub(exp_fixed, kEBOffset);
73
484k
    const auto m = ShiftRight<23 - M - L>(b);
74
484k
    const auto a = Add(kBase, Mul(n, kMulN));
75
484k
    const auto d = And(m, kMaskM);
76
484k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
484k
    const auto c = Or(a, l);
78
484k
    extra_bits = Add(extra_bits, eb_fixed);
79
484k
    const auto t = Or(c, d);
80
484k
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
484k
    Store(t_fixed, du, out + i);
82
484k
  }
83
15.4k
  if (last_full < len) {
84
13.2k
    const auto stop = Set(du, len);
85
13.2k
    const auto fence = Iota(du, last_full);
86
13.2k
    const auto take = Lt(fence, stop);
87
13.2k
    const auto val = LoadU(du, values + last_full);
88
13.2k
    const auto is_large = Gt(val, kLargeThreshold);
89
13.2k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
13.2k
    const auto not_literal = Ge(val, kSplit);
91
13.2k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
13.2k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
13.2k
    const auto l = And(val, kMaskL);
94
13.2k
    const auto exp = ShiftRight<23>(b);
95
13.2k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
13.2k
    const auto n = Sub(exp_fixed, kExpOffset);
97
13.2k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
13.2k
    const auto m = ShiftRight<23 - M - L>(b);
99
13.2k
    const auto a = Add(kBase, Mul(n, kMulN));
100
13.2k
    const auto d = And(m, kMaskM);
101
13.2k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
13.2k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
13.2k
    const auto c = Or(a, l);
104
13.2k
    extra_bits = Add(extra_bits, eb_masked);
105
13.2k
    const auto t = Or(c, d);
106
13.2k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
13.2k
    Store(t_fixed, du, out + last_full);
108
13.2k
  }
109
15.4k
  return GetLane(SumOfLanes(du, extra_bits));
110
15.4k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<12ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
15.4k
                               uint32_t* JXL_RESTRICT out) {
45
15.4k
  const HWY_FULL(uint32_t) du;
46
15.4k
  const HWY_FULL(float) df;
47
15.4k
  const auto kZero = Zero(du);
48
15.4k
  const auto kSplit = Set(du, 1 << E);
49
15.4k
  const auto kExpOffset = Set(du, 127);
50
15.4k
  const auto kEBOffset = Set(du, 127 + M + L);
51
15.4k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
15.4k
  const auto kMulN = Set(du, 1 << (M + L));
53
15.4k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
15.4k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
15.4k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
15.4k
  constexpr size_t kLargeShiftVal = 10;
57
15.4k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
15.4k
  auto extra_bits = kZero;
60
15.4k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
500k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
484k
    const auto val = LoadU(du, values + i);
63
484k
    const auto is_large = Gt(val, kLargeThreshold);
64
484k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
484k
    const auto not_literal = Ge(val, kSplit);
66
484k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
484k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
484k
    const auto l = And(val, kMaskL);
69
484k
    const auto exp = ShiftRight<23>(b);
70
484k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
484k
    const auto n = Sub(exp_fixed, kExpOffset);
72
484k
    const auto eb = Sub(exp_fixed, kEBOffset);
73
484k
    const auto m = ShiftRight<23 - M - L>(b);
74
484k
    const auto a = Add(kBase, Mul(n, kMulN));
75
484k
    const auto d = And(m, kMaskM);
76
484k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
484k
    const auto c = Or(a, l);
78
484k
    extra_bits = Add(extra_bits, eb_fixed);
79
484k
    const auto t = Or(c, d);
80
484k
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
484k
    Store(t_fixed, du, out + i);
82
484k
  }
83
15.4k
  if (last_full < len) {
84
13.2k
    const auto stop = Set(du, len);
85
13.2k
    const auto fence = Iota(du, last_full);
86
13.2k
    const auto take = Lt(fence, stop);
87
13.2k
    const auto val = LoadU(du, values + last_full);
88
13.2k
    const auto is_large = Gt(val, kLargeThreshold);
89
13.2k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
13.2k
    const auto not_literal = Ge(val, kSplit);
91
13.2k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
13.2k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
13.2k
    const auto l = And(val, kMaskL);
94
13.2k
    const auto exp = ShiftRight<23>(b);
95
13.2k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
13.2k
    const auto n = Sub(exp_fixed, kExpOffset);
97
13.2k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
13.2k
    const auto m = ShiftRight<23 - M - L>(b);
99
13.2k
    const auto a = Add(kBase, Mul(n, kMulN));
100
13.2k
    const auto d = And(m, kMaskM);
101
13.2k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
13.2k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
13.2k
    const auto c = Or(a, l);
104
13.2k
    extra_bits = Add(extra_bits, eb_masked);
105
13.2k
    const auto t = Or(c, d);
106
13.2k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
13.2k
    Store(t_fixed, du, out + last_full);
108
13.2k
  }
109
15.4k
  return GetLane(SumOfLanes(du, extra_bits));
110
15.4k
}
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
861k
                           HybridUintConfig cfg, AlignedMemory& tokens) {
114
861k
  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
861k
  if (cfg.split_exponent == 0) {
127
103k
    return EstimateTokenCostImpl<0, 0, 0>(values, len, out);
128
758k
  } else if (cfg.split_exponent == 2) {
129
100k
    JXL_DASSERT((cfg.msb_in_token == 0) && (cfg.lsb_in_token == 1));
130
100k
    return EstimateTokenCostImpl<2, 0, 1>(values, len, out);
131
658k
  } else if (cfg.split_exponent == 3) {
132
81.2k
    if (cfg.msb_in_token == 1) {
133
40.6k
      if (cfg.lsb_in_token == 0) {
134
20.3k
        return EstimateTokenCostImpl<3, 1, 0>(values, len, out);
135
20.3k
      } else {
136
20.3k
        JXL_DASSERT(cfg.lsb_in_token == 2);
137
20.3k
        return EstimateTokenCostImpl<3, 1, 2>(values, len, out);
138
20.3k
      }
139
40.6k
    } else {
140
40.6k
      JXL_DASSERT(cfg.msb_in_token == 2);
141
40.6k
      if (cfg.lsb_in_token == 0) {
142
20.3k
        return EstimateTokenCostImpl<3, 2, 0>(values, len, out);
143
20.3k
      } else {
144
20.3k
        JXL_DASSERT(cfg.lsb_in_token == 1);
145
20.3k
        return EstimateTokenCostImpl<3, 2, 1>(values, len, out);
146
20.3k
      }
147
40.6k
    }
148
577k
  } else if (cfg.split_exponent == 4) {
149
281k
    if (cfg.msb_in_token == 1) {
150
140k
      if (cfg.lsb_in_token == 0) {
151
20.3k
        return EstimateTokenCostImpl<4, 1, 0>(values, len, out);
152
120k
      } else if (cfg.lsb_in_token == 2) {
153
100k
        return EstimateTokenCostImpl<4, 1, 2>(values, len, out);
154
100k
      } else {
155
20.3k
        JXL_DASSERT(cfg.lsb_in_token == 3);
156
20.3k
        return EstimateTokenCostImpl<4, 1, 3>(values, len, out);
157
20.3k
      }
158
140k
    } else {
159
140k
      JXL_DASSERT(cfg.msb_in_token == 2);
160
140k
      if (cfg.lsb_in_token == 0) {
161
100k
        return EstimateTokenCostImpl<4, 2, 0>(values, len, out);
162
100k
      } else if (cfg.lsb_in_token == 1) {
163
20.3k
        return EstimateTokenCostImpl<4, 2, 1>(values, len, out);
164
20.3k
      } else {
165
20.3k
        JXL_DASSERT(cfg.lsb_in_token == 2);
166
20.3k
        return EstimateTokenCostImpl<4, 2, 2>(values, len, out);
167
20.3k
      }
168
140k
    }
169
295k
  } else if (cfg.split_exponent == 5) {
170
142k
    if (cfg.msb_in_token == 1) {
171
60.8k
      if (cfg.lsb_in_token == 0) {
172
20.3k
        return EstimateTokenCostImpl<5, 1, 0>(values, len, out);
173
40.5k
      } else if (cfg.lsb_in_token == 2) {
174
20.3k
        return EstimateTokenCostImpl<5, 1, 2>(values, len, out);
175
20.3k
      } else {
176
20.2k
        JXL_DASSERT(cfg.lsb_in_token == 4);
177
20.2k
        return EstimateTokenCostImpl<5, 1, 4>(values, len, out);
178
20.2k
      }
179
81.1k
    } else {
180
81.1k
      JXL_DASSERT(cfg.msb_in_token == 2);
181
81.1k
      if (cfg.lsb_in_token == 0) {
182
20.3k
        return EstimateTokenCostImpl<5, 2, 0>(values, len, out);
183
60.8k
      } else if (cfg.lsb_in_token == 1) {
184
20.3k
        return EstimateTokenCostImpl<5, 2, 1>(values, len, out);
185
40.5k
      } else if (cfg.lsb_in_token == 2) {
186
20.3k
        return EstimateTokenCostImpl<5, 2, 2>(values, len, out);
187
20.3k
      } else {
188
20.2k
        JXL_DASSERT(cfg.lsb_in_token == 3);
189
20.2k
        return EstimateTokenCostImpl<5, 2, 3>(values, len, out);
190
20.2k
      }
191
81.1k
    }
192
153k
  } else if (cfg.split_exponent == 6) {
193
55.9k
    if (cfg.msb_in_token == 0) {
194
20.3k
      JXL_DASSERT(cfg.lsb_in_token == 0);
195
20.3k
      return EstimateTokenCostImpl<6, 0, 0>(values, len, out);
196
35.6k
    } else if (cfg.msb_in_token == 1) {
197
17.8k
      JXL_DASSERT(cfg.lsb_in_token == 5);
198
17.8k
      return EstimateTokenCostImpl<6, 1, 5>(values, len, out);
199
17.8k
    } else {
200
17.8k
      JXL_DASSERT(cfg.msb_in_token == 2);
201
17.8k
      JXL_DASSERT(cfg.lsb_in_token == 4);
202
17.8k
      return EstimateTokenCostImpl<6, 2, 4>(values, len, out);
203
17.8k
    }
204
97.3k
  } else if (cfg.split_exponent >= 7 && cfg.split_exponent <= 12) {
205
97.3k
    JXL_DASSERT(cfg.msb_in_token == 0);
206
97.3k
    JXL_DASSERT(cfg.lsb_in_token == 0);
207
97.3k
    if (cfg.split_exponent == 7) {
208
20.3k
      return EstimateTokenCostImpl<7, 0, 0>(values, len, out);
209
77.0k
    } else if (cfg.split_exponent == 8) {
210
15.4k
      return EstimateTokenCostImpl<8, 0, 0>(values, len, out);
211
61.6k
    } else if (cfg.split_exponent == 9) {
212
15.4k
      return EstimateTokenCostImpl<9, 0, 0>(values, len, out);
213
46.2k
    } else if (cfg.split_exponent == 10) {
214
15.4k
      return EstimateTokenCostImpl<10, 0, 0>(values, len, out);
215
30.8k
    } else if (cfg.split_exponent == 11) {
216
15.4k
      return EstimateTokenCostImpl<11, 0, 0>(values, len, out);
217
15.4k
    } else {
218
15.4k
      return EstimateTokenCostImpl<12, 0, 0>(values, len, out);
219
15.4k
    }
220
97.3k
  } else {
221
0
    JXL_DASSERT(false);
222
0
  }
223
0
  return ~0;
224
861k
#endif
225
861k
}
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
861k
                           HybridUintConfig cfg, AlignedMemory& tokens) {
114
861k
  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
861k
  if (cfg.split_exponent == 0) {
127
103k
    return EstimateTokenCostImpl<0, 0, 0>(values, len, out);
128
758k
  } else if (cfg.split_exponent == 2) {
129
100k
    JXL_DASSERT((cfg.msb_in_token == 0) && (cfg.lsb_in_token == 1));
130
100k
    return EstimateTokenCostImpl<2, 0, 1>(values, len, out);
131
658k
  } else if (cfg.split_exponent == 3) {
132
81.2k
    if (cfg.msb_in_token == 1) {
133
40.6k
      if (cfg.lsb_in_token == 0) {
134
20.3k
        return EstimateTokenCostImpl<3, 1, 0>(values, len, out);
135
20.3k
      } else {
136
20.3k
        JXL_DASSERT(cfg.lsb_in_token == 2);
137
20.3k
        return EstimateTokenCostImpl<3, 1, 2>(values, len, out);
138
20.3k
      }
139
40.6k
    } else {
140
40.6k
      JXL_DASSERT(cfg.msb_in_token == 2);
141
40.6k
      if (cfg.lsb_in_token == 0) {
142
20.3k
        return EstimateTokenCostImpl<3, 2, 0>(values, len, out);
143
20.3k
      } else {
144
20.3k
        JXL_DASSERT(cfg.lsb_in_token == 1);
145
20.3k
        return EstimateTokenCostImpl<3, 2, 1>(values, len, out);
146
20.3k
      }
147
40.6k
    }
148
577k
  } else if (cfg.split_exponent == 4) {
149
281k
    if (cfg.msb_in_token == 1) {
150
140k
      if (cfg.lsb_in_token == 0) {
151
20.3k
        return EstimateTokenCostImpl<4, 1, 0>(values, len, out);
152
120k
      } else if (cfg.lsb_in_token == 2) {
153
100k
        return EstimateTokenCostImpl<4, 1, 2>(values, len, out);
154
100k
      } else {
155
20.3k
        JXL_DASSERT(cfg.lsb_in_token == 3);
156
20.3k
        return EstimateTokenCostImpl<4, 1, 3>(values, len, out);
157
20.3k
      }
158
140k
    } else {
159
140k
      JXL_DASSERT(cfg.msb_in_token == 2);
160
140k
      if (cfg.lsb_in_token == 0) {
161
100k
        return EstimateTokenCostImpl<4, 2, 0>(values, len, out);
162
100k
      } else if (cfg.lsb_in_token == 1) {
163
20.3k
        return EstimateTokenCostImpl<4, 2, 1>(values, len, out);
164
20.3k
      } else {
165
20.3k
        JXL_DASSERT(cfg.lsb_in_token == 2);
166
20.3k
        return EstimateTokenCostImpl<4, 2, 2>(values, len, out);
167
20.3k
      }
168
140k
    }
169
295k
  } else if (cfg.split_exponent == 5) {
170
142k
    if (cfg.msb_in_token == 1) {
171
60.8k
      if (cfg.lsb_in_token == 0) {
172
20.3k
        return EstimateTokenCostImpl<5, 1, 0>(values, len, out);
173
40.5k
      } else if (cfg.lsb_in_token == 2) {
174
20.3k
        return EstimateTokenCostImpl<5, 1, 2>(values, len, out);
175
20.3k
      } else {
176
20.2k
        JXL_DASSERT(cfg.lsb_in_token == 4);
177
20.2k
        return EstimateTokenCostImpl<5, 1, 4>(values, len, out);
178
20.2k
      }
179
81.1k
    } else {
180
81.1k
      JXL_DASSERT(cfg.msb_in_token == 2);
181
81.1k
      if (cfg.lsb_in_token == 0) {
182
20.3k
        return EstimateTokenCostImpl<5, 2, 0>(values, len, out);
183
60.8k
      } else if (cfg.lsb_in_token == 1) {
184
20.3k
        return EstimateTokenCostImpl<5, 2, 1>(values, len, out);
185
40.5k
      } else if (cfg.lsb_in_token == 2) {
186
20.3k
        return EstimateTokenCostImpl<5, 2, 2>(values, len, out);
187
20.3k
      } else {
188
20.2k
        JXL_DASSERT(cfg.lsb_in_token == 3);
189
20.2k
        return EstimateTokenCostImpl<5, 2, 3>(values, len, out);
190
20.2k
      }
191
81.1k
    }
192
153k
  } else if (cfg.split_exponent == 6) {
193
55.9k
    if (cfg.msb_in_token == 0) {
194
20.3k
      JXL_DASSERT(cfg.lsb_in_token == 0);
195
20.3k
      return EstimateTokenCostImpl<6, 0, 0>(values, len, out);
196
35.6k
    } else if (cfg.msb_in_token == 1) {
197
17.8k
      JXL_DASSERT(cfg.lsb_in_token == 5);
198
17.8k
      return EstimateTokenCostImpl<6, 1, 5>(values, len, out);
199
17.8k
    } else {
200
17.8k
      JXL_DASSERT(cfg.msb_in_token == 2);
201
17.8k
      JXL_DASSERT(cfg.lsb_in_token == 4);
202
17.8k
      return EstimateTokenCostImpl<6, 2, 4>(values, len, out);
203
17.8k
    }
204
97.3k
  } else if (cfg.split_exponent >= 7 && cfg.split_exponent <= 12) {
205
97.3k
    JXL_DASSERT(cfg.msb_in_token == 0);
206
97.3k
    JXL_DASSERT(cfg.lsb_in_token == 0);
207
97.3k
    if (cfg.split_exponent == 7) {
208
20.3k
      return EstimateTokenCostImpl<7, 0, 0>(values, len, out);
209
77.0k
    } else if (cfg.split_exponent == 8) {
210
15.4k
      return EstimateTokenCostImpl<8, 0, 0>(values, len, out);
211
61.6k
    } else if (cfg.split_exponent == 9) {
212
15.4k
      return EstimateTokenCostImpl<9, 0, 0>(values, len, out);
213
46.2k
    } else if (cfg.split_exponent == 10) {
214
15.4k
      return EstimateTokenCostImpl<10, 0, 0>(values, len, out);
215
30.8k
    } else if (cfg.split_exponent == 11) {
216
15.4k
      return EstimateTokenCostImpl<11, 0, 0>(values, len, out);
217
15.4k
    } else {
218
15.4k
      return EstimateTokenCostImpl<12, 0, 0>(values, len, out);
219
15.4k
    }
220
97.3k
  } else {
221
0
    JXL_DASSERT(false);
222
0
  }
223
0
  return ~0;
224
861k
#endif
225
861k
}
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
861k
                           HybridUintConfig cfg, AlignedMemory& tokens) {
239
861k
  JXL_DASSERT(cfg.lsb_in_token + cfg.msb_in_token <= cfg.split_exponent);
240
861k
  return HWY_DYNAMIC_DISPATCH(EstimateTokenCost)(values, len, cfg, tokens);
241
861k
}
242
243
}  // namespace jxl
244
#endif