Coverage Report

Created: 2026-09-14 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/compiler_specific.h"
11
#include "lib/jxl/base/status.h"
12
#include "lib/jxl/dec_ans.h"
13
#include "lib/jxl/memory_manager_internal.h"
14
15
#undef HWY_TARGET_INCLUDE
16
#define HWY_TARGET_INCLUDE "lib/jxl/enc_ans_simd.cc"
17
#include <hwy/foreach_target.h>
18
#include <hwy/highway.h>
19
20
HWY_BEFORE_NAMESPACE();
21
namespace jxl {
22
namespace HWY_NAMESPACE {
23
24
// These templates are not found via ADL.
25
using hwy::HWY_NAMESPACE::Add;
26
using hwy::HWY_NAMESPACE::And;
27
using hwy::HWY_NAMESPACE::Ge;
28
using hwy::HWY_NAMESPACE::GetLane;
29
using hwy::HWY_NAMESPACE::Gt;
30
using hwy::HWY_NAMESPACE::IfThenElse;
31
using hwy::HWY_NAMESPACE::IfThenElseZero;
32
using hwy::HWY_NAMESPACE::Iota;
33
using hwy::HWY_NAMESPACE::LoadU;
34
using hwy::HWY_NAMESPACE::Lt;
35
using hwy::HWY_NAMESPACE::Mul;
36
using hwy::HWY_NAMESPACE::Or;
37
using hwy::HWY_NAMESPACE::Set;
38
using hwy::HWY_NAMESPACE::ShiftRight;
39
using hwy::HWY_NAMESPACE::Store;
40
using hwy::HWY_NAMESPACE::Sub;
41
using hwy::HWY_NAMESPACE::Zero;
42
43
template <size_t E, size_t M, size_t L>
44
uint32_t EstimateTokenCostImpl(uint32_t* JXL_RESTRICT values, size_t len,
45
961k
                               uint32_t* JXL_RESTRICT out) {
46
961k
  const HWY_FULL(uint32_t) du;
47
961k
  const HWY_FULL(float) df;
48
961k
  const auto kZero = Zero(du);
49
961k
  const auto kSplit = Set(du, 1 << E);
50
961k
  const auto kExpOffset = Set(du, 127);
51
961k
  const auto kEBOffset = Set(du, 127 + M + L);
52
961k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
53
961k
  const auto kMulN = Set(du, 1 << (M + L));
54
961k
  const auto kMaskL = Set(du, (1 << L) - 1);
55
961k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
56
961k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
57
961k
  constexpr size_t kLargeShiftVal = 10;
58
961k
  const auto kLargeShift = Set(du, kLargeShiftVal);
59
60
961k
  auto extra_bits = kZero;
61
961k
  size_t last_full = Lanes(du) * (len / Lanes(du));
62
58.7M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
63
57.7M
    const auto val = LoadU(du, values + i);
64
57.7M
    const auto is_large = Gt(val, kLargeThreshold);
65
57.7M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
66
57.7M
    const auto not_literal = Ge(val, kSplit);
67
57.7M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
68
57.7M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
69
57.7M
    const auto l = And(val, kMaskL);
70
57.7M
    const auto exp = ShiftRight<23>(b);
71
57.7M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
72
57.7M
    const auto n = Sub(exp_fixed, kExpOffset);
73
57.7M
    const auto eb = Sub(exp_fixed, kEBOffset);
74
57.7M
    const auto m = ShiftRight<23 - M - L>(b);
75
57.7M
    const auto a = Add(kBase, Mul(n, kMulN));
76
57.7M
    const auto d = And(m, kMaskM);
77
57.7M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
78
57.7M
    const auto c = Or(a, l);
79
57.7M
    extra_bits = Add(extra_bits, eb_fixed);
80
57.7M
    const auto t = Or(c, d);
81
57.7M
    const auto t_fixed = IfThenElse(not_literal, t, val);
82
57.7M
    Store(t_fixed, du, out + i);
83
57.7M
  }
84
961k
  if (last_full < len) {
85
826k
    const auto stop = Set(du, len);
86
826k
    const auto fence = Iota(du, last_full);
87
826k
    const auto take = Lt(fence, stop);
88
826k
    const auto val = LoadU(du, values + last_full);
89
826k
    const auto is_large = Gt(val, kLargeThreshold);
90
826k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
91
826k
    const auto not_literal = Ge(val, kSplit);
92
826k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
93
826k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
94
826k
    const auto l = And(val, kMaskL);
95
826k
    const auto exp = ShiftRight<23>(b);
96
826k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
97
826k
    const auto n = Sub(exp_fixed, kExpOffset);
98
826k
    const auto eb = Sub(exp_fixed, kEBOffset);
99
826k
    const auto m = ShiftRight<23 - M - L>(b);
100
826k
    const auto a = Add(kBase, Mul(n, kMulN));
101
826k
    const auto d = And(m, kMaskM);
102
826k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
103
826k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
104
826k
    const auto c = Or(a, l);
105
826k
    extra_bits = Add(extra_bits, eb_masked);
106
826k
    const auto t = Or(c, d);
107
826k
    const auto t_fixed = IfThenElse(not_literal, t, val);
108
826k
    Store(t_fixed, du, out + last_full);
109
826k
  }
110
961k
  return GetLane(SumOfLanes(du, extra_bits));
111
961k
}
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
45
109k
                               uint32_t* JXL_RESTRICT out) {
46
109k
  const HWY_FULL(uint32_t) du;
47
109k
  const HWY_FULL(float) df;
48
109k
  const auto kZero = Zero(du);
49
109k
  const auto kSplit = Set(du, 1 << E);
50
109k
  const auto kExpOffset = Set(du, 127);
51
109k
  const auto kEBOffset = Set(du, 127 + M + L);
52
109k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
53
109k
  const auto kMulN = Set(du, 1 << (M + L));
54
109k
  const auto kMaskL = Set(du, (1 << L) - 1);
55
109k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
56
109k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
57
109k
  constexpr size_t kLargeShiftVal = 10;
58
109k
  const auto kLargeShift = Set(du, kLargeShiftVal);
59
60
109k
  auto extra_bits = kZero;
61
109k
  size_t last_full = Lanes(du) * (len / Lanes(du));
62
8.86M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
63
8.75M
    const auto val = LoadU(du, values + i);
64
8.75M
    const auto is_large = Gt(val, kLargeThreshold);
65
8.75M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
66
8.75M
    const auto not_literal = Ge(val, kSplit);
67
8.75M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
68
8.75M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
69
8.75M
    const auto l = And(val, kMaskL);
70
8.75M
    const auto exp = ShiftRight<23>(b);
71
8.75M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
72
8.75M
    const auto n = Sub(exp_fixed, kExpOffset);
73
8.75M
    const auto eb = Sub(exp_fixed, kEBOffset);
74
8.75M
    const auto m = ShiftRight<23 - M - L>(b);
75
8.75M
    const auto a = Add(kBase, Mul(n, kMulN));
76
8.75M
    const auto d = And(m, kMaskM);
77
8.75M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
78
8.75M
    const auto c = Or(a, l);
79
8.75M
    extra_bits = Add(extra_bits, eb_fixed);
80
8.75M
    const auto t = Or(c, d);
81
8.75M
    const auto t_fixed = IfThenElse(not_literal, t, val);
82
8.75M
    Store(t_fixed, du, out + i);
83
8.75M
  }
84
109k
  if (last_full < len) {
85
94.1k
    const auto stop = Set(du, len);
86
94.1k
    const auto fence = Iota(du, last_full);
87
94.1k
    const auto take = Lt(fence, stop);
88
94.1k
    const auto val = LoadU(du, values + last_full);
89
94.1k
    const auto is_large = Gt(val, kLargeThreshold);
90
94.1k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
91
94.1k
    const auto not_literal = Ge(val, kSplit);
92
94.1k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
93
94.1k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
94
94.1k
    const auto l = And(val, kMaskL);
95
94.1k
    const auto exp = ShiftRight<23>(b);
96
94.1k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
97
94.1k
    const auto n = Sub(exp_fixed, kExpOffset);
98
94.1k
    const auto eb = Sub(exp_fixed, kEBOffset);
99
94.1k
    const auto m = ShiftRight<23 - M - L>(b);
100
94.1k
    const auto a = Add(kBase, Mul(n, kMulN));
101
94.1k
    const auto d = And(m, kMaskM);
102
94.1k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
103
94.1k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
104
94.1k
    const auto c = Or(a, l);
105
94.1k
    extra_bits = Add(extra_bits, eb_masked);
106
94.1k
    const auto t = Or(c, d);
107
94.1k
    const auto t_fixed = IfThenElse(not_literal, t, val);
108
94.1k
    Store(t_fixed, du, out + last_full);
109
94.1k
  }
110
109k
  return GetLane(SumOfLanes(du, extra_bits));
111
109k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<2ul, 0ul, 1ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
45
105k
                               uint32_t* JXL_RESTRICT out) {
46
105k
  const HWY_FULL(uint32_t) du;
47
105k
  const HWY_FULL(float) df;
48
105k
  const auto kZero = Zero(du);
49
105k
  const auto kSplit = Set(du, 1 << E);
50
105k
  const auto kExpOffset = Set(du, 127);
51
105k
  const auto kEBOffset = Set(du, 127 + M + L);
52
105k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
53
105k
  const auto kMulN = Set(du, 1 << (M + L));
54
105k
  const auto kMaskL = Set(du, (1 << L) - 1);
55
105k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
56
105k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
57
105k
  constexpr size_t kLargeShiftVal = 10;
58
105k
  const auto kLargeShift = Set(du, kLargeShiftVal);
59
60
105k
  auto extra_bits = kZero;
61
105k
  size_t last_full = Lanes(du) * (len / Lanes(du));
62
8.85M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
63
8.75M
    const auto val = LoadU(du, values + i);
64
8.75M
    const auto is_large = Gt(val, kLargeThreshold);
65
8.75M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
66
8.75M
    const auto not_literal = Ge(val, kSplit);
67
8.75M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
68
8.75M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
69
8.75M
    const auto l = And(val, kMaskL);
70
8.75M
    const auto exp = ShiftRight<23>(b);
71
8.75M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
72
8.75M
    const auto n = Sub(exp_fixed, kExpOffset);
73
8.75M
    const auto eb = Sub(exp_fixed, kEBOffset);
74
8.75M
    const auto m = ShiftRight<23 - M - L>(b);
75
8.75M
    const auto a = Add(kBase, Mul(n, kMulN));
76
8.75M
    const auto d = And(m, kMaskM);
77
8.75M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
78
8.75M
    const auto c = Or(a, l);
79
8.75M
    extra_bits = Add(extra_bits, eb_fixed);
80
8.75M
    const auto t = Or(c, d);
81
8.75M
    const auto t_fixed = IfThenElse(not_literal, t, val);
82
8.75M
    Store(t_fixed, du, out + i);
83
8.75M
  }
84
105k
  if (last_full < len) {
85
90.8k
    const auto stop = Set(du, len);
86
90.8k
    const auto fence = Iota(du, last_full);
87
90.8k
    const auto take = Lt(fence, stop);
88
90.8k
    const auto val = LoadU(du, values + last_full);
89
90.8k
    const auto is_large = Gt(val, kLargeThreshold);
90
90.8k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
91
90.8k
    const auto not_literal = Ge(val, kSplit);
92
90.8k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
93
90.8k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
94
90.8k
    const auto l = And(val, kMaskL);
95
90.8k
    const auto exp = ShiftRight<23>(b);
96
90.8k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
97
90.8k
    const auto n = Sub(exp_fixed, kExpOffset);
98
90.8k
    const auto eb = Sub(exp_fixed, kEBOffset);
99
90.8k
    const auto m = ShiftRight<23 - M - L>(b);
100
90.8k
    const auto a = Add(kBase, Mul(n, kMulN));
101
90.8k
    const auto d = And(m, kMaskM);
102
90.8k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
103
90.8k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
104
90.8k
    const auto c = Or(a, l);
105
90.8k
    extra_bits = Add(extra_bits, eb_masked);
106
90.8k
    const auto t = Or(c, d);
107
90.8k
    const auto t_fixed = IfThenElse(not_literal, t, val);
108
90.8k
    Store(t_fixed, du, out + last_full);
109
90.8k
  }
110
105k
  return GetLane(SumOfLanes(du, extra_bits));
111
105k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<3ul, 1ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
45
23.8k
                               uint32_t* JXL_RESTRICT out) {
46
23.8k
  const HWY_FULL(uint32_t) du;
47
23.8k
  const HWY_FULL(float) df;
48
23.8k
  const auto kZero = Zero(du);
49
23.8k
  const auto kSplit = Set(du, 1 << E);
50
23.8k
  const auto kExpOffset = Set(du, 127);
51
23.8k
  const auto kEBOffset = Set(du, 127 + M + L);
52
23.8k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
53
23.8k
  const auto kMulN = Set(du, 1 << (M + L));
54
23.8k
  const auto kMaskL = Set(du, (1 << L) - 1);
55
23.8k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
56
23.8k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
57
23.8k
  constexpr size_t kLargeShiftVal = 10;
58
23.8k
  const auto kLargeShift = Set(du, kLargeShiftVal);
59
60
23.8k
  auto extra_bits = kZero;
61
23.8k
  size_t last_full = Lanes(du) * (len / Lanes(du));
62
1.13M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
63
1.11M
    const auto val = LoadU(du, values + i);
64
1.11M
    const auto is_large = Gt(val, kLargeThreshold);
65
1.11M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
66
1.11M
    const auto not_literal = Ge(val, kSplit);
67
1.11M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
68
1.11M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
69
1.11M
    const auto l = And(val, kMaskL);
70
1.11M
    const auto exp = ShiftRight<23>(b);
71
1.11M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
72
1.11M
    const auto n = Sub(exp_fixed, kExpOffset);
73
1.11M
    const auto eb = Sub(exp_fixed, kEBOffset);
74
1.11M
    const auto m = ShiftRight<23 - M - L>(b);
75
1.11M
    const auto a = Add(kBase, Mul(n, kMulN));
76
1.11M
    const auto d = And(m, kMaskM);
77
1.11M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
78
1.11M
    const auto c = Or(a, l);
79
1.11M
    extra_bits = Add(extra_bits, eb_fixed);
80
1.11M
    const auto t = Or(c, d);
81
1.11M
    const auto t_fixed = IfThenElse(not_literal, t, val);
82
1.11M
    Store(t_fixed, du, out + i);
83
1.11M
  }
84
23.8k
  if (last_full < len) {
85
20.4k
    const auto stop = Set(du, len);
86
20.4k
    const auto fence = Iota(du, last_full);
87
20.4k
    const auto take = Lt(fence, stop);
88
20.4k
    const auto val = LoadU(du, values + last_full);
89
20.4k
    const auto is_large = Gt(val, kLargeThreshold);
90
20.4k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
91
20.4k
    const auto not_literal = Ge(val, kSplit);
92
20.4k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
93
20.4k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
94
20.4k
    const auto l = And(val, kMaskL);
95
20.4k
    const auto exp = ShiftRight<23>(b);
96
20.4k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
97
20.4k
    const auto n = Sub(exp_fixed, kExpOffset);
98
20.4k
    const auto eb = Sub(exp_fixed, kEBOffset);
99
20.4k
    const auto m = ShiftRight<23 - M - L>(b);
100
20.4k
    const auto a = Add(kBase, Mul(n, kMulN));
101
20.4k
    const auto d = And(m, kMaskM);
102
20.4k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
103
20.4k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
104
20.4k
    const auto c = Or(a, l);
105
20.4k
    extra_bits = Add(extra_bits, eb_masked);
106
20.4k
    const auto t = Or(c, d);
107
20.4k
    const auto t_fixed = IfThenElse(not_literal, t, val);
108
20.4k
    Store(t_fixed, du, out + last_full);
109
20.4k
  }
110
23.8k
  return GetLane(SumOfLanes(du, extra_bits));
111
23.8k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<3ul, 1ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
45
23.8k
                               uint32_t* JXL_RESTRICT out) {
46
23.8k
  const HWY_FULL(uint32_t) du;
47
23.8k
  const HWY_FULL(float) df;
48
23.8k
  const auto kZero = Zero(du);
49
23.8k
  const auto kSplit = Set(du, 1 << E);
50
23.8k
  const auto kExpOffset = Set(du, 127);
51
23.8k
  const auto kEBOffset = Set(du, 127 + M + L);
52
23.8k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
53
23.8k
  const auto kMulN = Set(du, 1 << (M + L));
54
23.8k
  const auto kMaskL = Set(du, (1 << L) - 1);
55
23.8k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
56
23.8k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
57
23.8k
  constexpr size_t kLargeShiftVal = 10;
58
23.8k
  const auto kLargeShift = Set(du, kLargeShiftVal);
59
60
23.8k
  auto extra_bits = kZero;
61
23.8k
  size_t last_full = Lanes(du) * (len / Lanes(du));
62
1.13M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
63
1.11M
    const auto val = LoadU(du, values + i);
64
1.11M
    const auto is_large = Gt(val, kLargeThreshold);
65
1.11M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
66
1.11M
    const auto not_literal = Ge(val, kSplit);
67
1.11M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
68
1.11M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
69
1.11M
    const auto l = And(val, kMaskL);
70
1.11M
    const auto exp = ShiftRight<23>(b);
71
1.11M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
72
1.11M
    const auto n = Sub(exp_fixed, kExpOffset);
73
1.11M
    const auto eb = Sub(exp_fixed, kEBOffset);
74
1.11M
    const auto m = ShiftRight<23 - M - L>(b);
75
1.11M
    const auto a = Add(kBase, Mul(n, kMulN));
76
1.11M
    const auto d = And(m, kMaskM);
77
1.11M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
78
1.11M
    const auto c = Or(a, l);
79
1.11M
    extra_bits = Add(extra_bits, eb_fixed);
80
1.11M
    const auto t = Or(c, d);
81
1.11M
    const auto t_fixed = IfThenElse(not_literal, t, val);
82
1.11M
    Store(t_fixed, du, out + i);
83
1.11M
  }
84
23.8k
  if (last_full < len) {
85
20.4k
    const auto stop = Set(du, len);
86
20.4k
    const auto fence = Iota(du, last_full);
87
20.4k
    const auto take = Lt(fence, stop);
88
20.4k
    const auto val = LoadU(du, values + last_full);
89
20.4k
    const auto is_large = Gt(val, kLargeThreshold);
90
20.4k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
91
20.4k
    const auto not_literal = Ge(val, kSplit);
92
20.4k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
93
20.4k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
94
20.4k
    const auto l = And(val, kMaskL);
95
20.4k
    const auto exp = ShiftRight<23>(b);
96
20.4k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
97
20.4k
    const auto n = Sub(exp_fixed, kExpOffset);
98
20.4k
    const auto eb = Sub(exp_fixed, kEBOffset);
99
20.4k
    const auto m = ShiftRight<23 - M - L>(b);
100
20.4k
    const auto a = Add(kBase, Mul(n, kMulN));
101
20.4k
    const auto d = And(m, kMaskM);
102
20.4k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
103
20.4k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
104
20.4k
    const auto c = Or(a, l);
105
20.4k
    extra_bits = Add(extra_bits, eb_masked);
106
20.4k
    const auto t = Or(c, d);
107
20.4k
    const auto t_fixed = IfThenElse(not_literal, t, val);
108
20.4k
    Store(t_fixed, du, out + last_full);
109
20.4k
  }
110
23.8k
  return GetLane(SumOfLanes(du, extra_bits));
111
23.8k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<3ul, 2ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
45
23.8k
                               uint32_t* JXL_RESTRICT out) {
46
23.8k
  const HWY_FULL(uint32_t) du;
47
23.8k
  const HWY_FULL(float) df;
48
23.8k
  const auto kZero = Zero(du);
49
23.8k
  const auto kSplit = Set(du, 1 << E);
50
23.8k
  const auto kExpOffset = Set(du, 127);
51
23.8k
  const auto kEBOffset = Set(du, 127 + M + L);
52
23.8k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
53
23.8k
  const auto kMulN = Set(du, 1 << (M + L));
54
23.8k
  const auto kMaskL = Set(du, (1 << L) - 1);
55
23.8k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
56
23.8k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
57
23.8k
  constexpr size_t kLargeShiftVal = 10;
58
23.8k
  const auto kLargeShift = Set(du, kLargeShiftVal);
59
60
23.8k
  auto extra_bits = kZero;
61
23.8k
  size_t last_full = Lanes(du) * (len / Lanes(du));
62
1.13M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
63
1.11M
    const auto val = LoadU(du, values + i);
64
1.11M
    const auto is_large = Gt(val, kLargeThreshold);
65
1.11M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
66
1.11M
    const auto not_literal = Ge(val, kSplit);
67
1.11M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
68
1.11M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
69
1.11M
    const auto l = And(val, kMaskL);
70
1.11M
    const auto exp = ShiftRight<23>(b);
71
1.11M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
72
1.11M
    const auto n = Sub(exp_fixed, kExpOffset);
73
1.11M
    const auto eb = Sub(exp_fixed, kEBOffset);
74
1.11M
    const auto m = ShiftRight<23 - M - L>(b);
75
1.11M
    const auto a = Add(kBase, Mul(n, kMulN));
76
1.11M
    const auto d = And(m, kMaskM);
77
1.11M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
78
1.11M
    const auto c = Or(a, l);
79
1.11M
    extra_bits = Add(extra_bits, eb_fixed);
80
1.11M
    const auto t = Or(c, d);
81
1.11M
    const auto t_fixed = IfThenElse(not_literal, t, val);
82
1.11M
    Store(t_fixed, du, out + i);
83
1.11M
  }
84
23.8k
  if (last_full < len) {
85
20.4k
    const auto stop = Set(du, len);
86
20.4k
    const auto fence = Iota(du, last_full);
87
20.4k
    const auto take = Lt(fence, stop);
88
20.4k
    const auto val = LoadU(du, values + last_full);
89
20.4k
    const auto is_large = Gt(val, kLargeThreshold);
90
20.4k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
91
20.4k
    const auto not_literal = Ge(val, kSplit);
92
20.4k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
93
20.4k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
94
20.4k
    const auto l = And(val, kMaskL);
95
20.4k
    const auto exp = ShiftRight<23>(b);
96
20.4k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
97
20.4k
    const auto n = Sub(exp_fixed, kExpOffset);
98
20.4k
    const auto eb = Sub(exp_fixed, kEBOffset);
99
20.4k
    const auto m = ShiftRight<23 - M - L>(b);
100
20.4k
    const auto a = Add(kBase, Mul(n, kMulN));
101
20.4k
    const auto d = And(m, kMaskM);
102
20.4k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
103
20.4k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
104
20.4k
    const auto c = Or(a, l);
105
20.4k
    extra_bits = Add(extra_bits, eb_masked);
106
20.4k
    const auto t = Or(c, d);
107
20.4k
    const auto t_fixed = IfThenElse(not_literal, t, val);
108
20.4k
    Store(t_fixed, du, out + last_full);
109
20.4k
  }
110
23.8k
  return GetLane(SumOfLanes(du, extra_bits));
111
23.8k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<3ul, 2ul, 1ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
45
23.8k
                               uint32_t* JXL_RESTRICT out) {
46
23.8k
  const HWY_FULL(uint32_t) du;
47
23.8k
  const HWY_FULL(float) df;
48
23.8k
  const auto kZero = Zero(du);
49
23.8k
  const auto kSplit = Set(du, 1 << E);
50
23.8k
  const auto kExpOffset = Set(du, 127);
51
23.8k
  const auto kEBOffset = Set(du, 127 + M + L);
52
23.8k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
53
23.8k
  const auto kMulN = Set(du, 1 << (M + L));
54
23.8k
  const auto kMaskL = Set(du, (1 << L) - 1);
55
23.8k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
56
23.8k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
57
23.8k
  constexpr size_t kLargeShiftVal = 10;
58
23.8k
  const auto kLargeShift = Set(du, kLargeShiftVal);
59
60
23.8k
  auto extra_bits = kZero;
61
23.8k
  size_t last_full = Lanes(du) * (len / Lanes(du));
62
1.13M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
63
1.11M
    const auto val = LoadU(du, values + i);
64
1.11M
    const auto is_large = Gt(val, kLargeThreshold);
65
1.11M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
66
1.11M
    const auto not_literal = Ge(val, kSplit);
67
1.11M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
68
1.11M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
69
1.11M
    const auto l = And(val, kMaskL);
70
1.11M
    const auto exp = ShiftRight<23>(b);
71
1.11M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
72
1.11M
    const auto n = Sub(exp_fixed, kExpOffset);
73
1.11M
    const auto eb = Sub(exp_fixed, kEBOffset);
74
1.11M
    const auto m = ShiftRight<23 - M - L>(b);
75
1.11M
    const auto a = Add(kBase, Mul(n, kMulN));
76
1.11M
    const auto d = And(m, kMaskM);
77
1.11M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
78
1.11M
    const auto c = Or(a, l);
79
1.11M
    extra_bits = Add(extra_bits, eb_fixed);
80
1.11M
    const auto t = Or(c, d);
81
1.11M
    const auto t_fixed = IfThenElse(not_literal, t, val);
82
1.11M
    Store(t_fixed, du, out + i);
83
1.11M
  }
84
23.8k
  if (last_full < len) {
85
20.4k
    const auto stop = Set(du, len);
86
20.4k
    const auto fence = Iota(du, last_full);
87
20.4k
    const auto take = Lt(fence, stop);
88
20.4k
    const auto val = LoadU(du, values + last_full);
89
20.4k
    const auto is_large = Gt(val, kLargeThreshold);
90
20.4k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
91
20.4k
    const auto not_literal = Ge(val, kSplit);
92
20.4k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
93
20.4k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
94
20.4k
    const auto l = And(val, kMaskL);
95
20.4k
    const auto exp = ShiftRight<23>(b);
96
20.4k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
97
20.4k
    const auto n = Sub(exp_fixed, kExpOffset);
98
20.4k
    const auto eb = Sub(exp_fixed, kEBOffset);
99
20.4k
    const auto m = ShiftRight<23 - M - L>(b);
100
20.4k
    const auto a = Add(kBase, Mul(n, kMulN));
101
20.4k
    const auto d = And(m, kMaskM);
102
20.4k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
103
20.4k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
104
20.4k
    const auto c = Or(a, l);
105
20.4k
    extra_bits = Add(extra_bits, eb_masked);
106
20.4k
    const auto t = Or(c, d);
107
20.4k
    const auto t_fixed = IfThenElse(not_literal, t, val);
108
20.4k
    Store(t_fixed, du, out + last_full);
109
20.4k
  }
110
23.8k
  return GetLane(SumOfLanes(du, extra_bits));
111
23.8k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<4ul, 1ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
45
23.8k
                               uint32_t* JXL_RESTRICT out) {
46
23.8k
  const HWY_FULL(uint32_t) du;
47
23.8k
  const HWY_FULL(float) df;
48
23.8k
  const auto kZero = Zero(du);
49
23.8k
  const auto kSplit = Set(du, 1 << E);
50
23.8k
  const auto kExpOffset = Set(du, 127);
51
23.8k
  const auto kEBOffset = Set(du, 127 + M + L);
52
23.8k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
53
23.8k
  const auto kMulN = Set(du, 1 << (M + L));
54
23.8k
  const auto kMaskL = Set(du, (1 << L) - 1);
55
23.8k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
56
23.8k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
57
23.8k
  constexpr size_t kLargeShiftVal = 10;
58
23.8k
  const auto kLargeShift = Set(du, kLargeShiftVal);
59
60
23.8k
  auto extra_bits = kZero;
61
23.8k
  size_t last_full = Lanes(du) * (len / Lanes(du));
62
1.13M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
63
1.11M
    const auto val = LoadU(du, values + i);
64
1.11M
    const auto is_large = Gt(val, kLargeThreshold);
65
1.11M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
66
1.11M
    const auto not_literal = Ge(val, kSplit);
67
1.11M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
68
1.11M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
69
1.11M
    const auto l = And(val, kMaskL);
70
1.11M
    const auto exp = ShiftRight<23>(b);
71
1.11M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
72
1.11M
    const auto n = Sub(exp_fixed, kExpOffset);
73
1.11M
    const auto eb = Sub(exp_fixed, kEBOffset);
74
1.11M
    const auto m = ShiftRight<23 - M - L>(b);
75
1.11M
    const auto a = Add(kBase, Mul(n, kMulN));
76
1.11M
    const auto d = And(m, kMaskM);
77
1.11M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
78
1.11M
    const auto c = Or(a, l);
79
1.11M
    extra_bits = Add(extra_bits, eb_fixed);
80
1.11M
    const auto t = Or(c, d);
81
1.11M
    const auto t_fixed = IfThenElse(not_literal, t, val);
82
1.11M
    Store(t_fixed, du, out + i);
83
1.11M
  }
84
23.8k
  if (last_full < len) {
85
20.4k
    const auto stop = Set(du, len);
86
20.4k
    const auto fence = Iota(du, last_full);
87
20.4k
    const auto take = Lt(fence, stop);
88
20.4k
    const auto val = LoadU(du, values + last_full);
89
20.4k
    const auto is_large = Gt(val, kLargeThreshold);
90
20.4k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
91
20.4k
    const auto not_literal = Ge(val, kSplit);
92
20.4k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
93
20.4k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
94
20.4k
    const auto l = And(val, kMaskL);
95
20.4k
    const auto exp = ShiftRight<23>(b);
96
20.4k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
97
20.4k
    const auto n = Sub(exp_fixed, kExpOffset);
98
20.4k
    const auto eb = Sub(exp_fixed, kEBOffset);
99
20.4k
    const auto m = ShiftRight<23 - M - L>(b);
100
20.4k
    const auto a = Add(kBase, Mul(n, kMulN));
101
20.4k
    const auto d = And(m, kMaskM);
102
20.4k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
103
20.4k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
104
20.4k
    const auto c = Or(a, l);
105
20.4k
    extra_bits = Add(extra_bits, eb_masked);
106
20.4k
    const auto t = Or(c, d);
107
20.4k
    const auto t_fixed = IfThenElse(not_literal, t, val);
108
20.4k
    Store(t_fixed, du, out + last_full);
109
20.4k
  }
110
23.8k
  return GetLane(SumOfLanes(du, extra_bits));
111
23.8k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<4ul, 1ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
45
105k
                               uint32_t* JXL_RESTRICT out) {
46
105k
  const HWY_FULL(uint32_t) du;
47
105k
  const HWY_FULL(float) df;
48
105k
  const auto kZero = Zero(du);
49
105k
  const auto kSplit = Set(du, 1 << E);
50
105k
  const auto kExpOffset = Set(du, 127);
51
105k
  const auto kEBOffset = Set(du, 127 + M + L);
52
105k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
53
105k
  const auto kMulN = Set(du, 1 << (M + L));
54
105k
  const auto kMaskL = Set(du, (1 << L) - 1);
55
105k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
56
105k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
57
105k
  constexpr size_t kLargeShiftVal = 10;
58
105k
  const auto kLargeShift = Set(du, kLargeShiftVal);
59
60
105k
  auto extra_bits = kZero;
61
105k
  size_t last_full = Lanes(du) * (len / Lanes(du));
62
8.85M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
63
8.75M
    const auto val = LoadU(du, values + i);
64
8.75M
    const auto is_large = Gt(val, kLargeThreshold);
65
8.75M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
66
8.75M
    const auto not_literal = Ge(val, kSplit);
67
8.75M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
68
8.75M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
69
8.75M
    const auto l = And(val, kMaskL);
70
8.75M
    const auto exp = ShiftRight<23>(b);
71
8.75M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
72
8.75M
    const auto n = Sub(exp_fixed, kExpOffset);
73
8.75M
    const auto eb = Sub(exp_fixed, kEBOffset);
74
8.75M
    const auto m = ShiftRight<23 - M - L>(b);
75
8.75M
    const auto a = Add(kBase, Mul(n, kMulN));
76
8.75M
    const auto d = And(m, kMaskM);
77
8.75M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
78
8.75M
    const auto c = Or(a, l);
79
8.75M
    extra_bits = Add(extra_bits, eb_fixed);
80
8.75M
    const auto t = Or(c, d);
81
8.75M
    const auto t_fixed = IfThenElse(not_literal, t, val);
82
8.75M
    Store(t_fixed, du, out + i);
83
8.75M
  }
84
105k
  if (last_full < len) {
85
90.8k
    const auto stop = Set(du, len);
86
90.8k
    const auto fence = Iota(du, last_full);
87
90.8k
    const auto take = Lt(fence, stop);
88
90.8k
    const auto val = LoadU(du, values + last_full);
89
90.8k
    const auto is_large = Gt(val, kLargeThreshold);
90
90.8k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
91
90.8k
    const auto not_literal = Ge(val, kSplit);
92
90.8k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
93
90.8k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
94
90.8k
    const auto l = And(val, kMaskL);
95
90.8k
    const auto exp = ShiftRight<23>(b);
96
90.8k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
97
90.8k
    const auto n = Sub(exp_fixed, kExpOffset);
98
90.8k
    const auto eb = Sub(exp_fixed, kEBOffset);
99
90.8k
    const auto m = ShiftRight<23 - M - L>(b);
100
90.8k
    const auto a = Add(kBase, Mul(n, kMulN));
101
90.8k
    const auto d = And(m, kMaskM);
102
90.8k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
103
90.8k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
104
90.8k
    const auto c = Or(a, l);
105
90.8k
    extra_bits = Add(extra_bits, eb_masked);
106
90.8k
    const auto t = Or(c, d);
107
90.8k
    const auto t_fixed = IfThenElse(not_literal, t, val);
108
90.8k
    Store(t_fixed, du, out + last_full);
109
90.8k
  }
110
105k
  return GetLane(SumOfLanes(du, extra_bits));
111
105k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<4ul, 1ul, 3ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
45
23.8k
                               uint32_t* JXL_RESTRICT out) {
46
23.8k
  const HWY_FULL(uint32_t) du;
47
23.8k
  const HWY_FULL(float) df;
48
23.8k
  const auto kZero = Zero(du);
49
23.8k
  const auto kSplit = Set(du, 1 << E);
50
23.8k
  const auto kExpOffset = Set(du, 127);
51
23.8k
  const auto kEBOffset = Set(du, 127 + M + L);
52
23.8k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
53
23.8k
  const auto kMulN = Set(du, 1 << (M + L));
54
23.8k
  const auto kMaskL = Set(du, (1 << L) - 1);
55
23.8k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
56
23.8k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
57
23.8k
  constexpr size_t kLargeShiftVal = 10;
58
23.8k
  const auto kLargeShift = Set(du, kLargeShiftVal);
59
60
23.8k
  auto extra_bits = kZero;
61
23.8k
  size_t last_full = Lanes(du) * (len / Lanes(du));
62
1.13M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
63
1.11M
    const auto val = LoadU(du, values + i);
64
1.11M
    const auto is_large = Gt(val, kLargeThreshold);
65
1.11M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
66
1.11M
    const auto not_literal = Ge(val, kSplit);
67
1.11M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
68
1.11M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
69
1.11M
    const auto l = And(val, kMaskL);
70
1.11M
    const auto exp = ShiftRight<23>(b);
71
1.11M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
72
1.11M
    const auto n = Sub(exp_fixed, kExpOffset);
73
1.11M
    const auto eb = Sub(exp_fixed, kEBOffset);
74
1.11M
    const auto m = ShiftRight<23 - M - L>(b);
75
1.11M
    const auto a = Add(kBase, Mul(n, kMulN));
76
1.11M
    const auto d = And(m, kMaskM);
77
1.11M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
78
1.11M
    const auto c = Or(a, l);
79
1.11M
    extra_bits = Add(extra_bits, eb_fixed);
80
1.11M
    const auto t = Or(c, d);
81
1.11M
    const auto t_fixed = IfThenElse(not_literal, t, val);
82
1.11M
    Store(t_fixed, du, out + i);
83
1.11M
  }
84
23.8k
  if (last_full < len) {
85
20.4k
    const auto stop = Set(du, len);
86
20.4k
    const auto fence = Iota(du, last_full);
87
20.4k
    const auto take = Lt(fence, stop);
88
20.4k
    const auto val = LoadU(du, values + last_full);
89
20.4k
    const auto is_large = Gt(val, kLargeThreshold);
90
20.4k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
91
20.4k
    const auto not_literal = Ge(val, kSplit);
92
20.4k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
93
20.4k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
94
20.4k
    const auto l = And(val, kMaskL);
95
20.4k
    const auto exp = ShiftRight<23>(b);
96
20.4k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
97
20.4k
    const auto n = Sub(exp_fixed, kExpOffset);
98
20.4k
    const auto eb = Sub(exp_fixed, kEBOffset);
99
20.4k
    const auto m = ShiftRight<23 - M - L>(b);
100
20.4k
    const auto a = Add(kBase, Mul(n, kMulN));
101
20.4k
    const auto d = And(m, kMaskM);
102
20.4k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
103
20.4k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
104
20.4k
    const auto c = Or(a, l);
105
20.4k
    extra_bits = Add(extra_bits, eb_masked);
106
20.4k
    const auto t = Or(c, d);
107
20.4k
    const auto t_fixed = IfThenElse(not_literal, t, val);
108
20.4k
    Store(t_fixed, du, out + last_full);
109
20.4k
  }
110
23.8k
  return GetLane(SumOfLanes(du, extra_bits));
111
23.8k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<4ul, 2ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
45
105k
                               uint32_t* JXL_RESTRICT out) {
46
105k
  const HWY_FULL(uint32_t) du;
47
105k
  const HWY_FULL(float) df;
48
105k
  const auto kZero = Zero(du);
49
105k
  const auto kSplit = Set(du, 1 << E);
50
105k
  const auto kExpOffset = Set(du, 127);
51
105k
  const auto kEBOffset = Set(du, 127 + M + L);
52
105k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
53
105k
  const auto kMulN = Set(du, 1 << (M + L));
54
105k
  const auto kMaskL = Set(du, (1 << L) - 1);
55
105k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
56
105k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
57
105k
  constexpr size_t kLargeShiftVal = 10;
58
105k
  const auto kLargeShift = Set(du, kLargeShiftVal);
59
60
105k
  auto extra_bits = kZero;
61
105k
  size_t last_full = Lanes(du) * (len / Lanes(du));
62
8.85M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
63
8.75M
    const auto val = LoadU(du, values + i);
64
8.75M
    const auto is_large = Gt(val, kLargeThreshold);
65
8.75M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
66
8.75M
    const auto not_literal = Ge(val, kSplit);
67
8.75M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
68
8.75M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
69
8.75M
    const auto l = And(val, kMaskL);
70
8.75M
    const auto exp = ShiftRight<23>(b);
71
8.75M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
72
8.75M
    const auto n = Sub(exp_fixed, kExpOffset);
73
8.75M
    const auto eb = Sub(exp_fixed, kEBOffset);
74
8.75M
    const auto m = ShiftRight<23 - M - L>(b);
75
8.75M
    const auto a = Add(kBase, Mul(n, kMulN));
76
8.75M
    const auto d = And(m, kMaskM);
77
8.75M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
78
8.75M
    const auto c = Or(a, l);
79
8.75M
    extra_bits = Add(extra_bits, eb_fixed);
80
8.75M
    const auto t = Or(c, d);
81
8.75M
    const auto t_fixed = IfThenElse(not_literal, t, val);
82
8.75M
    Store(t_fixed, du, out + i);
83
8.75M
  }
84
105k
  if (last_full < len) {
85
90.8k
    const auto stop = Set(du, len);
86
90.8k
    const auto fence = Iota(du, last_full);
87
90.8k
    const auto take = Lt(fence, stop);
88
90.8k
    const auto val = LoadU(du, values + last_full);
89
90.8k
    const auto is_large = Gt(val, kLargeThreshold);
90
90.8k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
91
90.8k
    const auto not_literal = Ge(val, kSplit);
92
90.8k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
93
90.8k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
94
90.8k
    const auto l = And(val, kMaskL);
95
90.8k
    const auto exp = ShiftRight<23>(b);
96
90.8k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
97
90.8k
    const auto n = Sub(exp_fixed, kExpOffset);
98
90.8k
    const auto eb = Sub(exp_fixed, kEBOffset);
99
90.8k
    const auto m = ShiftRight<23 - M - L>(b);
100
90.8k
    const auto a = Add(kBase, Mul(n, kMulN));
101
90.8k
    const auto d = And(m, kMaskM);
102
90.8k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
103
90.8k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
104
90.8k
    const auto c = Or(a, l);
105
90.8k
    extra_bits = Add(extra_bits, eb_masked);
106
90.8k
    const auto t = Or(c, d);
107
90.8k
    const auto t_fixed = IfThenElse(not_literal, t, val);
108
90.8k
    Store(t_fixed, du, out + last_full);
109
90.8k
  }
110
105k
  return GetLane(SumOfLanes(du, extra_bits));
111
105k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<4ul, 2ul, 1ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
45
23.8k
                               uint32_t* JXL_RESTRICT out) {
46
23.8k
  const HWY_FULL(uint32_t) du;
47
23.8k
  const HWY_FULL(float) df;
48
23.8k
  const auto kZero = Zero(du);
49
23.8k
  const auto kSplit = Set(du, 1 << E);
50
23.8k
  const auto kExpOffset = Set(du, 127);
51
23.8k
  const auto kEBOffset = Set(du, 127 + M + L);
52
23.8k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
53
23.8k
  const auto kMulN = Set(du, 1 << (M + L));
54
23.8k
  const auto kMaskL = Set(du, (1 << L) - 1);
55
23.8k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
56
23.8k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
57
23.8k
  constexpr size_t kLargeShiftVal = 10;
58
23.8k
  const auto kLargeShift = Set(du, kLargeShiftVal);
59
60
23.8k
  auto extra_bits = kZero;
61
23.8k
  size_t last_full = Lanes(du) * (len / Lanes(du));
62
1.13M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
63
1.11M
    const auto val = LoadU(du, values + i);
64
1.11M
    const auto is_large = Gt(val, kLargeThreshold);
65
1.11M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
66
1.11M
    const auto not_literal = Ge(val, kSplit);
67
1.11M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
68
1.11M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
69
1.11M
    const auto l = And(val, kMaskL);
70
1.11M
    const auto exp = ShiftRight<23>(b);
71
1.11M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
72
1.11M
    const auto n = Sub(exp_fixed, kExpOffset);
73
1.11M
    const auto eb = Sub(exp_fixed, kEBOffset);
74
1.11M
    const auto m = ShiftRight<23 - M - L>(b);
75
1.11M
    const auto a = Add(kBase, Mul(n, kMulN));
76
1.11M
    const auto d = And(m, kMaskM);
77
1.11M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
78
1.11M
    const auto c = Or(a, l);
79
1.11M
    extra_bits = Add(extra_bits, eb_fixed);
80
1.11M
    const auto t = Or(c, d);
81
1.11M
    const auto t_fixed = IfThenElse(not_literal, t, val);
82
1.11M
    Store(t_fixed, du, out + i);
83
1.11M
  }
84
23.8k
  if (last_full < len) {
85
20.4k
    const auto stop = Set(du, len);
86
20.4k
    const auto fence = Iota(du, last_full);
87
20.4k
    const auto take = Lt(fence, stop);
88
20.4k
    const auto val = LoadU(du, values + last_full);
89
20.4k
    const auto is_large = Gt(val, kLargeThreshold);
90
20.4k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
91
20.4k
    const auto not_literal = Ge(val, kSplit);
92
20.4k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
93
20.4k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
94
20.4k
    const auto l = And(val, kMaskL);
95
20.4k
    const auto exp = ShiftRight<23>(b);
96
20.4k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
97
20.4k
    const auto n = Sub(exp_fixed, kExpOffset);
98
20.4k
    const auto eb = Sub(exp_fixed, kEBOffset);
99
20.4k
    const auto m = ShiftRight<23 - M - L>(b);
100
20.4k
    const auto a = Add(kBase, Mul(n, kMulN));
101
20.4k
    const auto d = And(m, kMaskM);
102
20.4k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
103
20.4k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
104
20.4k
    const auto c = Or(a, l);
105
20.4k
    extra_bits = Add(extra_bits, eb_masked);
106
20.4k
    const auto t = Or(c, d);
107
20.4k
    const auto t_fixed = IfThenElse(not_literal, t, val);
108
20.4k
    Store(t_fixed, du, out + last_full);
109
20.4k
  }
110
23.8k
  return GetLane(SumOfLanes(du, extra_bits));
111
23.8k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<4ul, 2ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
45
23.8k
                               uint32_t* JXL_RESTRICT out) {
46
23.8k
  const HWY_FULL(uint32_t) du;
47
23.8k
  const HWY_FULL(float) df;
48
23.8k
  const auto kZero = Zero(du);
49
23.8k
  const auto kSplit = Set(du, 1 << E);
50
23.8k
  const auto kExpOffset = Set(du, 127);
51
23.8k
  const auto kEBOffset = Set(du, 127 + M + L);
52
23.8k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
53
23.8k
  const auto kMulN = Set(du, 1 << (M + L));
54
23.8k
  const auto kMaskL = Set(du, (1 << L) - 1);
55
23.8k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
56
23.8k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
57
23.8k
  constexpr size_t kLargeShiftVal = 10;
58
23.8k
  const auto kLargeShift = Set(du, kLargeShiftVal);
59
60
23.8k
  auto extra_bits = kZero;
61
23.8k
  size_t last_full = Lanes(du) * (len / Lanes(du));
62
1.13M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
63
1.11M
    const auto val = LoadU(du, values + i);
64
1.11M
    const auto is_large = Gt(val, kLargeThreshold);
65
1.11M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
66
1.11M
    const auto not_literal = Ge(val, kSplit);
67
1.11M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
68
1.11M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
69
1.11M
    const auto l = And(val, kMaskL);
70
1.11M
    const auto exp = ShiftRight<23>(b);
71
1.11M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
72
1.11M
    const auto n = Sub(exp_fixed, kExpOffset);
73
1.11M
    const auto eb = Sub(exp_fixed, kEBOffset);
74
1.11M
    const auto m = ShiftRight<23 - M - L>(b);
75
1.11M
    const auto a = Add(kBase, Mul(n, kMulN));
76
1.11M
    const auto d = And(m, kMaskM);
77
1.11M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
78
1.11M
    const auto c = Or(a, l);
79
1.11M
    extra_bits = Add(extra_bits, eb_fixed);
80
1.11M
    const auto t = Or(c, d);
81
1.11M
    const auto t_fixed = IfThenElse(not_literal, t, val);
82
1.11M
    Store(t_fixed, du, out + i);
83
1.11M
  }
84
23.8k
  if (last_full < len) {
85
20.4k
    const auto stop = Set(du, len);
86
20.4k
    const auto fence = Iota(du, last_full);
87
20.4k
    const auto take = Lt(fence, stop);
88
20.4k
    const auto val = LoadU(du, values + last_full);
89
20.4k
    const auto is_large = Gt(val, kLargeThreshold);
90
20.4k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
91
20.4k
    const auto not_literal = Ge(val, kSplit);
92
20.4k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
93
20.4k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
94
20.4k
    const auto l = And(val, kMaskL);
95
20.4k
    const auto exp = ShiftRight<23>(b);
96
20.4k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
97
20.4k
    const auto n = Sub(exp_fixed, kExpOffset);
98
20.4k
    const auto eb = Sub(exp_fixed, kEBOffset);
99
20.4k
    const auto m = ShiftRight<23 - M - L>(b);
100
20.4k
    const auto a = Add(kBase, Mul(n, kMulN));
101
20.4k
    const auto d = And(m, kMaskM);
102
20.4k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
103
20.4k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
104
20.4k
    const auto c = Or(a, l);
105
20.4k
    extra_bits = Add(extra_bits, eb_masked);
106
20.4k
    const auto t = Or(c, d);
107
20.4k
    const auto t_fixed = IfThenElse(not_literal, t, val);
108
20.4k
    Store(t_fixed, du, out + last_full);
109
20.4k
  }
110
23.8k
  return GetLane(SumOfLanes(du, extra_bits));
111
23.8k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<5ul, 1ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
45
23.8k
                               uint32_t* JXL_RESTRICT out) {
46
23.8k
  const HWY_FULL(uint32_t) du;
47
23.8k
  const HWY_FULL(float) df;
48
23.8k
  const auto kZero = Zero(du);
49
23.8k
  const auto kSplit = Set(du, 1 << E);
50
23.8k
  const auto kExpOffset = Set(du, 127);
51
23.8k
  const auto kEBOffset = Set(du, 127 + M + L);
52
23.8k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
53
23.8k
  const auto kMulN = Set(du, 1 << (M + L));
54
23.8k
  const auto kMaskL = Set(du, (1 << L) - 1);
55
23.8k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
56
23.8k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
57
23.8k
  constexpr size_t kLargeShiftVal = 10;
58
23.8k
  const auto kLargeShift = Set(du, kLargeShiftVal);
59
60
23.8k
  auto extra_bits = kZero;
61
23.8k
  size_t last_full = Lanes(du) * (len / Lanes(du));
62
1.13M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
63
1.11M
    const auto val = LoadU(du, values + i);
64
1.11M
    const auto is_large = Gt(val, kLargeThreshold);
65
1.11M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
66
1.11M
    const auto not_literal = Ge(val, kSplit);
67
1.11M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
68
1.11M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
69
1.11M
    const auto l = And(val, kMaskL);
70
1.11M
    const auto exp = ShiftRight<23>(b);
71
1.11M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
72
1.11M
    const auto n = Sub(exp_fixed, kExpOffset);
73
1.11M
    const auto eb = Sub(exp_fixed, kEBOffset);
74
1.11M
    const auto m = ShiftRight<23 - M - L>(b);
75
1.11M
    const auto a = Add(kBase, Mul(n, kMulN));
76
1.11M
    const auto d = And(m, kMaskM);
77
1.11M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
78
1.11M
    const auto c = Or(a, l);
79
1.11M
    extra_bits = Add(extra_bits, eb_fixed);
80
1.11M
    const auto t = Or(c, d);
81
1.11M
    const auto t_fixed = IfThenElse(not_literal, t, val);
82
1.11M
    Store(t_fixed, du, out + i);
83
1.11M
  }
84
23.8k
  if (last_full < len) {
85
20.4k
    const auto stop = Set(du, len);
86
20.4k
    const auto fence = Iota(du, last_full);
87
20.4k
    const auto take = Lt(fence, stop);
88
20.4k
    const auto val = LoadU(du, values + last_full);
89
20.4k
    const auto is_large = Gt(val, kLargeThreshold);
90
20.4k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
91
20.4k
    const auto not_literal = Ge(val, kSplit);
92
20.4k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
93
20.4k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
94
20.4k
    const auto l = And(val, kMaskL);
95
20.4k
    const auto exp = ShiftRight<23>(b);
96
20.4k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
97
20.4k
    const auto n = Sub(exp_fixed, kExpOffset);
98
20.4k
    const auto eb = Sub(exp_fixed, kEBOffset);
99
20.4k
    const auto m = ShiftRight<23 - M - L>(b);
100
20.4k
    const auto a = Add(kBase, Mul(n, kMulN));
101
20.4k
    const auto d = And(m, kMaskM);
102
20.4k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
103
20.4k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
104
20.4k
    const auto c = Or(a, l);
105
20.4k
    extra_bits = Add(extra_bits, eb_masked);
106
20.4k
    const auto t = Or(c, d);
107
20.4k
    const auto t_fixed = IfThenElse(not_literal, t, val);
108
20.4k
    Store(t_fixed, du, out + last_full);
109
20.4k
  }
110
23.8k
  return GetLane(SumOfLanes(du, extra_bits));
111
23.8k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<5ul, 1ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
45
23.8k
                               uint32_t* JXL_RESTRICT out) {
46
23.8k
  const HWY_FULL(uint32_t) du;
47
23.8k
  const HWY_FULL(float) df;
48
23.8k
  const auto kZero = Zero(du);
49
23.8k
  const auto kSplit = Set(du, 1 << E);
50
23.8k
  const auto kExpOffset = Set(du, 127);
51
23.8k
  const auto kEBOffset = Set(du, 127 + M + L);
52
23.8k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
53
23.8k
  const auto kMulN = Set(du, 1 << (M + L));
54
23.8k
  const auto kMaskL = Set(du, (1 << L) - 1);
55
23.8k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
56
23.8k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
57
23.8k
  constexpr size_t kLargeShiftVal = 10;
58
23.8k
  const auto kLargeShift = Set(du, kLargeShiftVal);
59
60
23.8k
  auto extra_bits = kZero;
61
23.8k
  size_t last_full = Lanes(du) * (len / Lanes(du));
62
1.13M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
63
1.11M
    const auto val = LoadU(du, values + i);
64
1.11M
    const auto is_large = Gt(val, kLargeThreshold);
65
1.11M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
66
1.11M
    const auto not_literal = Ge(val, kSplit);
67
1.11M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
68
1.11M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
69
1.11M
    const auto l = And(val, kMaskL);
70
1.11M
    const auto exp = ShiftRight<23>(b);
71
1.11M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
72
1.11M
    const auto n = Sub(exp_fixed, kExpOffset);
73
1.11M
    const auto eb = Sub(exp_fixed, kEBOffset);
74
1.11M
    const auto m = ShiftRight<23 - M - L>(b);
75
1.11M
    const auto a = Add(kBase, Mul(n, kMulN));
76
1.11M
    const auto d = And(m, kMaskM);
77
1.11M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
78
1.11M
    const auto c = Or(a, l);
79
1.11M
    extra_bits = Add(extra_bits, eb_fixed);
80
1.11M
    const auto t = Or(c, d);
81
1.11M
    const auto t_fixed = IfThenElse(not_literal, t, val);
82
1.11M
    Store(t_fixed, du, out + i);
83
1.11M
  }
84
23.8k
  if (last_full < len) {
85
20.4k
    const auto stop = Set(du, len);
86
20.4k
    const auto fence = Iota(du, last_full);
87
20.4k
    const auto take = Lt(fence, stop);
88
20.4k
    const auto val = LoadU(du, values + last_full);
89
20.4k
    const auto is_large = Gt(val, kLargeThreshold);
90
20.4k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
91
20.4k
    const auto not_literal = Ge(val, kSplit);
92
20.4k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
93
20.4k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
94
20.4k
    const auto l = And(val, kMaskL);
95
20.4k
    const auto exp = ShiftRight<23>(b);
96
20.4k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
97
20.4k
    const auto n = Sub(exp_fixed, kExpOffset);
98
20.4k
    const auto eb = Sub(exp_fixed, kEBOffset);
99
20.4k
    const auto m = ShiftRight<23 - M - L>(b);
100
20.4k
    const auto a = Add(kBase, Mul(n, kMulN));
101
20.4k
    const auto d = And(m, kMaskM);
102
20.4k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
103
20.4k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
104
20.4k
    const auto c = Or(a, l);
105
20.4k
    extra_bits = Add(extra_bits, eb_masked);
106
20.4k
    const auto t = Or(c, d);
107
20.4k
    const auto t_fixed = IfThenElse(not_literal, t, val);
108
20.4k
    Store(t_fixed, du, out + last_full);
109
20.4k
  }
110
23.8k
  return GetLane(SumOfLanes(du, extra_bits));
111
23.8k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<5ul, 1ul, 4ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
45
23.8k
                               uint32_t* JXL_RESTRICT out) {
46
23.8k
  const HWY_FULL(uint32_t) du;
47
23.8k
  const HWY_FULL(float) df;
48
23.8k
  const auto kZero = Zero(du);
49
23.8k
  const auto kSplit = Set(du, 1 << E);
50
23.8k
  const auto kExpOffset = Set(du, 127);
51
23.8k
  const auto kEBOffset = Set(du, 127 + M + L);
52
23.8k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
53
23.8k
  const auto kMulN = Set(du, 1 << (M + L));
54
23.8k
  const auto kMaskL = Set(du, (1 << L) - 1);
55
23.8k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
56
23.8k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
57
23.8k
  constexpr size_t kLargeShiftVal = 10;
58
23.8k
  const auto kLargeShift = Set(du, kLargeShiftVal);
59
60
23.8k
  auto extra_bits = kZero;
61
23.8k
  size_t last_full = Lanes(du) * (len / Lanes(du));
62
1.13M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
63
1.11M
    const auto val = LoadU(du, values + i);
64
1.11M
    const auto is_large = Gt(val, kLargeThreshold);
65
1.11M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
66
1.11M
    const auto not_literal = Ge(val, kSplit);
67
1.11M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
68
1.11M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
69
1.11M
    const auto l = And(val, kMaskL);
70
1.11M
    const auto exp = ShiftRight<23>(b);
71
1.11M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
72
1.11M
    const auto n = Sub(exp_fixed, kExpOffset);
73
1.11M
    const auto eb = Sub(exp_fixed, kEBOffset);
74
1.11M
    const auto m = ShiftRight<23 - M - L>(b);
75
1.11M
    const auto a = Add(kBase, Mul(n, kMulN));
76
1.11M
    const auto d = And(m, kMaskM);
77
1.11M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
78
1.11M
    const auto c = Or(a, l);
79
1.11M
    extra_bits = Add(extra_bits, eb_fixed);
80
1.11M
    const auto t = Or(c, d);
81
1.11M
    const auto t_fixed = IfThenElse(not_literal, t, val);
82
1.11M
    Store(t_fixed, du, out + i);
83
1.11M
  }
84
23.8k
  if (last_full < len) {
85
20.4k
    const auto stop = Set(du, len);
86
20.4k
    const auto fence = Iota(du, last_full);
87
20.4k
    const auto take = Lt(fence, stop);
88
20.4k
    const auto val = LoadU(du, values + last_full);
89
20.4k
    const auto is_large = Gt(val, kLargeThreshold);
90
20.4k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
91
20.4k
    const auto not_literal = Ge(val, kSplit);
92
20.4k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
93
20.4k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
94
20.4k
    const auto l = And(val, kMaskL);
95
20.4k
    const auto exp = ShiftRight<23>(b);
96
20.4k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
97
20.4k
    const auto n = Sub(exp_fixed, kExpOffset);
98
20.4k
    const auto eb = Sub(exp_fixed, kEBOffset);
99
20.4k
    const auto m = ShiftRight<23 - M - L>(b);
100
20.4k
    const auto a = Add(kBase, Mul(n, kMulN));
101
20.4k
    const auto d = And(m, kMaskM);
102
20.4k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
103
20.4k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
104
20.4k
    const auto c = Or(a, l);
105
20.4k
    extra_bits = Add(extra_bits, eb_masked);
106
20.4k
    const auto t = Or(c, d);
107
20.4k
    const auto t_fixed = IfThenElse(not_literal, t, val);
108
20.4k
    Store(t_fixed, du, out + last_full);
109
20.4k
  }
110
23.8k
  return GetLane(SumOfLanes(du, extra_bits));
111
23.8k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<5ul, 2ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
45
23.8k
                               uint32_t* JXL_RESTRICT out) {
46
23.8k
  const HWY_FULL(uint32_t) du;
47
23.8k
  const HWY_FULL(float) df;
48
23.8k
  const auto kZero = Zero(du);
49
23.8k
  const auto kSplit = Set(du, 1 << E);
50
23.8k
  const auto kExpOffset = Set(du, 127);
51
23.8k
  const auto kEBOffset = Set(du, 127 + M + L);
52
23.8k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
53
23.8k
  const auto kMulN = Set(du, 1 << (M + L));
54
23.8k
  const auto kMaskL = Set(du, (1 << L) - 1);
55
23.8k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
56
23.8k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
57
23.8k
  constexpr size_t kLargeShiftVal = 10;
58
23.8k
  const auto kLargeShift = Set(du, kLargeShiftVal);
59
60
23.8k
  auto extra_bits = kZero;
61
23.8k
  size_t last_full = Lanes(du) * (len / Lanes(du));
62
1.13M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
63
1.11M
    const auto val = LoadU(du, values + i);
64
1.11M
    const auto is_large = Gt(val, kLargeThreshold);
65
1.11M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
66
1.11M
    const auto not_literal = Ge(val, kSplit);
67
1.11M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
68
1.11M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
69
1.11M
    const auto l = And(val, kMaskL);
70
1.11M
    const auto exp = ShiftRight<23>(b);
71
1.11M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
72
1.11M
    const auto n = Sub(exp_fixed, kExpOffset);
73
1.11M
    const auto eb = Sub(exp_fixed, kEBOffset);
74
1.11M
    const auto m = ShiftRight<23 - M - L>(b);
75
1.11M
    const auto a = Add(kBase, Mul(n, kMulN));
76
1.11M
    const auto d = And(m, kMaskM);
77
1.11M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
78
1.11M
    const auto c = Or(a, l);
79
1.11M
    extra_bits = Add(extra_bits, eb_fixed);
80
1.11M
    const auto t = Or(c, d);
81
1.11M
    const auto t_fixed = IfThenElse(not_literal, t, val);
82
1.11M
    Store(t_fixed, du, out + i);
83
1.11M
  }
84
23.8k
  if (last_full < len) {
85
20.4k
    const auto stop = Set(du, len);
86
20.4k
    const auto fence = Iota(du, last_full);
87
20.4k
    const auto take = Lt(fence, stop);
88
20.4k
    const auto val = LoadU(du, values + last_full);
89
20.4k
    const auto is_large = Gt(val, kLargeThreshold);
90
20.4k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
91
20.4k
    const auto not_literal = Ge(val, kSplit);
92
20.4k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
93
20.4k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
94
20.4k
    const auto l = And(val, kMaskL);
95
20.4k
    const auto exp = ShiftRight<23>(b);
96
20.4k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
97
20.4k
    const auto n = Sub(exp_fixed, kExpOffset);
98
20.4k
    const auto eb = Sub(exp_fixed, kEBOffset);
99
20.4k
    const auto m = ShiftRight<23 - M - L>(b);
100
20.4k
    const auto a = Add(kBase, Mul(n, kMulN));
101
20.4k
    const auto d = And(m, kMaskM);
102
20.4k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
103
20.4k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
104
20.4k
    const auto c = Or(a, l);
105
20.4k
    extra_bits = Add(extra_bits, eb_masked);
106
20.4k
    const auto t = Or(c, d);
107
20.4k
    const auto t_fixed = IfThenElse(not_literal, t, val);
108
20.4k
    Store(t_fixed, du, out + last_full);
109
20.4k
  }
110
23.8k
  return GetLane(SumOfLanes(du, extra_bits));
111
23.8k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<5ul, 2ul, 1ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
45
23.8k
                               uint32_t* JXL_RESTRICT out) {
46
23.8k
  const HWY_FULL(uint32_t) du;
47
23.8k
  const HWY_FULL(float) df;
48
23.8k
  const auto kZero = Zero(du);
49
23.8k
  const auto kSplit = Set(du, 1 << E);
50
23.8k
  const auto kExpOffset = Set(du, 127);
51
23.8k
  const auto kEBOffset = Set(du, 127 + M + L);
52
23.8k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
53
23.8k
  const auto kMulN = Set(du, 1 << (M + L));
54
23.8k
  const auto kMaskL = Set(du, (1 << L) - 1);
55
23.8k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
56
23.8k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
57
23.8k
  constexpr size_t kLargeShiftVal = 10;
58
23.8k
  const auto kLargeShift = Set(du, kLargeShiftVal);
59
60
23.8k
  auto extra_bits = kZero;
61
23.8k
  size_t last_full = Lanes(du) * (len / Lanes(du));
62
1.13M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
63
1.11M
    const auto val = LoadU(du, values + i);
64
1.11M
    const auto is_large = Gt(val, kLargeThreshold);
65
1.11M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
66
1.11M
    const auto not_literal = Ge(val, kSplit);
67
1.11M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
68
1.11M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
69
1.11M
    const auto l = And(val, kMaskL);
70
1.11M
    const auto exp = ShiftRight<23>(b);
71
1.11M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
72
1.11M
    const auto n = Sub(exp_fixed, kExpOffset);
73
1.11M
    const auto eb = Sub(exp_fixed, kEBOffset);
74
1.11M
    const auto m = ShiftRight<23 - M - L>(b);
75
1.11M
    const auto a = Add(kBase, Mul(n, kMulN));
76
1.11M
    const auto d = And(m, kMaskM);
77
1.11M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
78
1.11M
    const auto c = Or(a, l);
79
1.11M
    extra_bits = Add(extra_bits, eb_fixed);
80
1.11M
    const auto t = Or(c, d);
81
1.11M
    const auto t_fixed = IfThenElse(not_literal, t, val);
82
1.11M
    Store(t_fixed, du, out + i);
83
1.11M
  }
84
23.8k
  if (last_full < len) {
85
20.4k
    const auto stop = Set(du, len);
86
20.4k
    const auto fence = Iota(du, last_full);
87
20.4k
    const auto take = Lt(fence, stop);
88
20.4k
    const auto val = LoadU(du, values + last_full);
89
20.4k
    const auto is_large = Gt(val, kLargeThreshold);
90
20.4k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
91
20.4k
    const auto not_literal = Ge(val, kSplit);
92
20.4k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
93
20.4k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
94
20.4k
    const auto l = And(val, kMaskL);
95
20.4k
    const auto exp = ShiftRight<23>(b);
96
20.4k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
97
20.4k
    const auto n = Sub(exp_fixed, kExpOffset);
98
20.4k
    const auto eb = Sub(exp_fixed, kEBOffset);
99
20.4k
    const auto m = ShiftRight<23 - M - L>(b);
100
20.4k
    const auto a = Add(kBase, Mul(n, kMulN));
101
20.4k
    const auto d = And(m, kMaskM);
102
20.4k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
103
20.4k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
104
20.4k
    const auto c = Or(a, l);
105
20.4k
    extra_bits = Add(extra_bits, eb_masked);
106
20.4k
    const auto t = Or(c, d);
107
20.4k
    const auto t_fixed = IfThenElse(not_literal, t, val);
108
20.4k
    Store(t_fixed, du, out + last_full);
109
20.4k
  }
110
23.8k
  return GetLane(SumOfLanes(du, extra_bits));
111
23.8k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<5ul, 2ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
45
23.8k
                               uint32_t* JXL_RESTRICT out) {
46
23.8k
  const HWY_FULL(uint32_t) du;
47
23.8k
  const HWY_FULL(float) df;
48
23.8k
  const auto kZero = Zero(du);
49
23.8k
  const auto kSplit = Set(du, 1 << E);
50
23.8k
  const auto kExpOffset = Set(du, 127);
51
23.8k
  const auto kEBOffset = Set(du, 127 + M + L);
52
23.8k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
53
23.8k
  const auto kMulN = Set(du, 1 << (M + L));
54
23.8k
  const auto kMaskL = Set(du, (1 << L) - 1);
55
23.8k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
56
23.8k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
57
23.8k
  constexpr size_t kLargeShiftVal = 10;
58
23.8k
  const auto kLargeShift = Set(du, kLargeShiftVal);
59
60
23.8k
  auto extra_bits = kZero;
61
23.8k
  size_t last_full = Lanes(du) * (len / Lanes(du));
62
1.13M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
63
1.11M
    const auto val = LoadU(du, values + i);
64
1.11M
    const auto is_large = Gt(val, kLargeThreshold);
65
1.11M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
66
1.11M
    const auto not_literal = Ge(val, kSplit);
67
1.11M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
68
1.11M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
69
1.11M
    const auto l = And(val, kMaskL);
70
1.11M
    const auto exp = ShiftRight<23>(b);
71
1.11M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
72
1.11M
    const auto n = Sub(exp_fixed, kExpOffset);
73
1.11M
    const auto eb = Sub(exp_fixed, kEBOffset);
74
1.11M
    const auto m = ShiftRight<23 - M - L>(b);
75
1.11M
    const auto a = Add(kBase, Mul(n, kMulN));
76
1.11M
    const auto d = And(m, kMaskM);
77
1.11M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
78
1.11M
    const auto c = Or(a, l);
79
1.11M
    extra_bits = Add(extra_bits, eb_fixed);
80
1.11M
    const auto t = Or(c, d);
81
1.11M
    const auto t_fixed = IfThenElse(not_literal, t, val);
82
1.11M
    Store(t_fixed, du, out + i);
83
1.11M
  }
84
23.8k
  if (last_full < len) {
85
20.4k
    const auto stop = Set(du, len);
86
20.4k
    const auto fence = Iota(du, last_full);
87
20.4k
    const auto take = Lt(fence, stop);
88
20.4k
    const auto val = LoadU(du, values + last_full);
89
20.4k
    const auto is_large = Gt(val, kLargeThreshold);
90
20.4k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
91
20.4k
    const auto not_literal = Ge(val, kSplit);
92
20.4k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
93
20.4k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
94
20.4k
    const auto l = And(val, kMaskL);
95
20.4k
    const auto exp = ShiftRight<23>(b);
96
20.4k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
97
20.4k
    const auto n = Sub(exp_fixed, kExpOffset);
98
20.4k
    const auto eb = Sub(exp_fixed, kEBOffset);
99
20.4k
    const auto m = ShiftRight<23 - M - L>(b);
100
20.4k
    const auto a = Add(kBase, Mul(n, kMulN));
101
20.4k
    const auto d = And(m, kMaskM);
102
20.4k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
103
20.4k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
104
20.4k
    const auto c = Or(a, l);
105
20.4k
    extra_bits = Add(extra_bits, eb_masked);
106
20.4k
    const auto t = Or(c, d);
107
20.4k
    const auto t_fixed = IfThenElse(not_literal, t, val);
108
20.4k
    Store(t_fixed, du, out + last_full);
109
20.4k
  }
110
23.8k
  return GetLane(SumOfLanes(du, extra_bits));
111
23.8k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<5ul, 2ul, 3ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
45
23.8k
                               uint32_t* JXL_RESTRICT out) {
46
23.8k
  const HWY_FULL(uint32_t) du;
47
23.8k
  const HWY_FULL(float) df;
48
23.8k
  const auto kZero = Zero(du);
49
23.8k
  const auto kSplit = Set(du, 1 << E);
50
23.8k
  const auto kExpOffset = Set(du, 127);
51
23.8k
  const auto kEBOffset = Set(du, 127 + M + L);
52
23.8k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
53
23.8k
  const auto kMulN = Set(du, 1 << (M + L));
54
23.8k
  const auto kMaskL = Set(du, (1 << L) - 1);
55
23.8k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
56
23.8k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
57
23.8k
  constexpr size_t kLargeShiftVal = 10;
58
23.8k
  const auto kLargeShift = Set(du, kLargeShiftVal);
59
60
23.8k
  auto extra_bits = kZero;
61
23.8k
  size_t last_full = Lanes(du) * (len / Lanes(du));
62
1.13M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
63
1.11M
    const auto val = LoadU(du, values + i);
64
1.11M
    const auto is_large = Gt(val, kLargeThreshold);
65
1.11M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
66
1.11M
    const auto not_literal = Ge(val, kSplit);
67
1.11M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
68
1.11M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
69
1.11M
    const auto l = And(val, kMaskL);
70
1.11M
    const auto exp = ShiftRight<23>(b);
71
1.11M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
72
1.11M
    const auto n = Sub(exp_fixed, kExpOffset);
73
1.11M
    const auto eb = Sub(exp_fixed, kEBOffset);
74
1.11M
    const auto m = ShiftRight<23 - M - L>(b);
75
1.11M
    const auto a = Add(kBase, Mul(n, kMulN));
76
1.11M
    const auto d = And(m, kMaskM);
77
1.11M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
78
1.11M
    const auto c = Or(a, l);
79
1.11M
    extra_bits = Add(extra_bits, eb_fixed);
80
1.11M
    const auto t = Or(c, d);
81
1.11M
    const auto t_fixed = IfThenElse(not_literal, t, val);
82
1.11M
    Store(t_fixed, du, out + i);
83
1.11M
  }
84
23.8k
  if (last_full < len) {
85
20.4k
    const auto stop = Set(du, len);
86
20.4k
    const auto fence = Iota(du, last_full);
87
20.4k
    const auto take = Lt(fence, stop);
88
20.4k
    const auto val = LoadU(du, values + last_full);
89
20.4k
    const auto is_large = Gt(val, kLargeThreshold);
90
20.4k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
91
20.4k
    const auto not_literal = Ge(val, kSplit);
92
20.4k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
93
20.4k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
94
20.4k
    const auto l = And(val, kMaskL);
95
20.4k
    const auto exp = ShiftRight<23>(b);
96
20.4k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
97
20.4k
    const auto n = Sub(exp_fixed, kExpOffset);
98
20.4k
    const auto eb = Sub(exp_fixed, kEBOffset);
99
20.4k
    const auto m = ShiftRight<23 - M - L>(b);
100
20.4k
    const auto a = Add(kBase, Mul(n, kMulN));
101
20.4k
    const auto d = And(m, kMaskM);
102
20.4k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
103
20.4k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
104
20.4k
    const auto c = Or(a, l);
105
20.4k
    extra_bits = Add(extra_bits, eb_masked);
106
20.4k
    const auto t = Or(c, d);
107
20.4k
    const auto t_fixed = IfThenElse(not_literal, t, val);
108
20.4k
    Store(t_fixed, du, out + last_full);
109
20.4k
  }
110
23.8k
  return GetLane(SumOfLanes(du, extra_bits));
111
23.8k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<6ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
45
23.8k
                               uint32_t* JXL_RESTRICT out) {
46
23.8k
  const HWY_FULL(uint32_t) du;
47
23.8k
  const HWY_FULL(float) df;
48
23.8k
  const auto kZero = Zero(du);
49
23.8k
  const auto kSplit = Set(du, 1 << E);
50
23.8k
  const auto kExpOffset = Set(du, 127);
51
23.8k
  const auto kEBOffset = Set(du, 127 + M + L);
52
23.8k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
53
23.8k
  const auto kMulN = Set(du, 1 << (M + L));
54
23.8k
  const auto kMaskL = Set(du, (1 << L) - 1);
55
23.8k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
56
23.8k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
57
23.8k
  constexpr size_t kLargeShiftVal = 10;
58
23.8k
  const auto kLargeShift = Set(du, kLargeShiftVal);
59
60
23.8k
  auto extra_bits = kZero;
61
23.8k
  size_t last_full = Lanes(du) * (len / Lanes(du));
62
1.13M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
63
1.11M
    const auto val = LoadU(du, values + i);
64
1.11M
    const auto is_large = Gt(val, kLargeThreshold);
65
1.11M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
66
1.11M
    const auto not_literal = Ge(val, kSplit);
67
1.11M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
68
1.11M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
69
1.11M
    const auto l = And(val, kMaskL);
70
1.11M
    const auto exp = ShiftRight<23>(b);
71
1.11M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
72
1.11M
    const auto n = Sub(exp_fixed, kExpOffset);
73
1.11M
    const auto eb = Sub(exp_fixed, kEBOffset);
74
1.11M
    const auto m = ShiftRight<23 - M - L>(b);
75
1.11M
    const auto a = Add(kBase, Mul(n, kMulN));
76
1.11M
    const auto d = And(m, kMaskM);
77
1.11M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
78
1.11M
    const auto c = Or(a, l);
79
1.11M
    extra_bits = Add(extra_bits, eb_fixed);
80
1.11M
    const auto t = Or(c, d);
81
1.11M
    const auto t_fixed = IfThenElse(not_literal, t, val);
82
1.11M
    Store(t_fixed, du, out + i);
83
1.11M
  }
84
23.8k
  if (last_full < len) {
85
20.4k
    const auto stop = Set(du, len);
86
20.4k
    const auto fence = Iota(du, last_full);
87
20.4k
    const auto take = Lt(fence, stop);
88
20.4k
    const auto val = LoadU(du, values + last_full);
89
20.4k
    const auto is_large = Gt(val, kLargeThreshold);
90
20.4k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
91
20.4k
    const auto not_literal = Ge(val, kSplit);
92
20.4k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
93
20.4k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
94
20.4k
    const auto l = And(val, kMaskL);
95
20.4k
    const auto exp = ShiftRight<23>(b);
96
20.4k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
97
20.4k
    const auto n = Sub(exp_fixed, kExpOffset);
98
20.4k
    const auto eb = Sub(exp_fixed, kEBOffset);
99
20.4k
    const auto m = ShiftRight<23 - M - L>(b);
100
20.4k
    const auto a = Add(kBase, Mul(n, kMulN));
101
20.4k
    const auto d = And(m, kMaskM);
102
20.4k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
103
20.4k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
104
20.4k
    const auto c = Or(a, l);
105
20.4k
    extra_bits = Add(extra_bits, eb_masked);
106
20.4k
    const auto t = Or(c, d);
107
20.4k
    const auto t_fixed = IfThenElse(not_literal, t, val);
108
20.4k
    Store(t_fixed, du, out + last_full);
109
20.4k
  }
110
23.8k
  return GetLane(SumOfLanes(du, extra_bits));
111
23.8k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<6ul, 1ul, 5ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
45
20.3k
                               uint32_t* JXL_RESTRICT out) {
46
20.3k
  const HWY_FULL(uint32_t) du;
47
20.3k
  const HWY_FULL(float) df;
48
20.3k
  const auto kZero = Zero(du);
49
20.3k
  const auto kSplit = Set(du, 1 << E);
50
20.3k
  const auto kExpOffset = Set(du, 127);
51
20.3k
  const auto kEBOffset = Set(du, 127 + M + L);
52
20.3k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
53
20.3k
  const auto kMulN = Set(du, 1 << (M + L));
54
20.3k
  const auto kMaskL = Set(du, (1 << L) - 1);
55
20.3k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
56
20.3k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
57
20.3k
  constexpr size_t kLargeShiftVal = 10;
58
20.3k
  const auto kLargeShift = Set(du, kLargeShiftVal);
59
60
20.3k
  auto extra_bits = kZero;
61
20.3k
  size_t last_full = Lanes(du) * (len / Lanes(du));
62
624k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
63
603k
    const auto val = LoadU(du, values + i);
64
603k
    const auto is_large = Gt(val, kLargeThreshold);
65
603k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
66
603k
    const auto not_literal = Ge(val, kSplit);
67
603k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
68
603k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
69
603k
    const auto l = And(val, kMaskL);
70
603k
    const auto exp = ShiftRight<23>(b);
71
603k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
72
603k
    const auto n = Sub(exp_fixed, kExpOffset);
73
603k
    const auto eb = Sub(exp_fixed, kEBOffset);
74
603k
    const auto m = ShiftRight<23 - M - L>(b);
75
603k
    const auto a = Add(kBase, Mul(n, kMulN));
76
603k
    const auto d = And(m, kMaskM);
77
603k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
78
603k
    const auto c = Or(a, l);
79
603k
    extra_bits = Add(extra_bits, eb_fixed);
80
603k
    const auto t = Or(c, d);
81
603k
    const auto t_fixed = IfThenElse(not_literal, t, val);
82
603k
    Store(t_fixed, du, out + i);
83
603k
  }
84
20.3k
  if (last_full < len) {
85
17.4k
    const auto stop = Set(du, len);
86
17.4k
    const auto fence = Iota(du, last_full);
87
17.4k
    const auto take = Lt(fence, stop);
88
17.4k
    const auto val = LoadU(du, values + last_full);
89
17.4k
    const auto is_large = Gt(val, kLargeThreshold);
90
17.4k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
91
17.4k
    const auto not_literal = Ge(val, kSplit);
92
17.4k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
93
17.4k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
94
17.4k
    const auto l = And(val, kMaskL);
95
17.4k
    const auto exp = ShiftRight<23>(b);
96
17.4k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
97
17.4k
    const auto n = Sub(exp_fixed, kExpOffset);
98
17.4k
    const auto eb = Sub(exp_fixed, kEBOffset);
99
17.4k
    const auto m = ShiftRight<23 - M - L>(b);
100
17.4k
    const auto a = Add(kBase, Mul(n, kMulN));
101
17.4k
    const auto d = And(m, kMaskM);
102
17.4k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
103
17.4k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
104
17.4k
    const auto c = Or(a, l);
105
17.4k
    extra_bits = Add(extra_bits, eb_masked);
106
17.4k
    const auto t = Or(c, d);
107
17.4k
    const auto t_fixed = IfThenElse(not_literal, t, val);
108
17.4k
    Store(t_fixed, du, out + last_full);
109
17.4k
  }
110
20.3k
  return GetLane(SumOfLanes(du, extra_bits));
111
20.3k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<6ul, 2ul, 4ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
45
20.3k
                               uint32_t* JXL_RESTRICT out) {
46
20.3k
  const HWY_FULL(uint32_t) du;
47
20.3k
  const HWY_FULL(float) df;
48
20.3k
  const auto kZero = Zero(du);
49
20.3k
  const auto kSplit = Set(du, 1 << E);
50
20.3k
  const auto kExpOffset = Set(du, 127);
51
20.3k
  const auto kEBOffset = Set(du, 127 + M + L);
52
20.3k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
53
20.3k
  const auto kMulN = Set(du, 1 << (M + L));
54
20.3k
  const auto kMaskL = Set(du, (1 << L) - 1);
55
20.3k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
56
20.3k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
57
20.3k
  constexpr size_t kLargeShiftVal = 10;
58
20.3k
  const auto kLargeShift = Set(du, kLargeShiftVal);
59
60
20.3k
  auto extra_bits = kZero;
61
20.3k
  size_t last_full = Lanes(du) * (len / Lanes(du));
62
624k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
63
603k
    const auto val = LoadU(du, values + i);
64
603k
    const auto is_large = Gt(val, kLargeThreshold);
65
603k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
66
603k
    const auto not_literal = Ge(val, kSplit);
67
603k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
68
603k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
69
603k
    const auto l = And(val, kMaskL);
70
603k
    const auto exp = ShiftRight<23>(b);
71
603k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
72
603k
    const auto n = Sub(exp_fixed, kExpOffset);
73
603k
    const auto eb = Sub(exp_fixed, kEBOffset);
74
603k
    const auto m = ShiftRight<23 - M - L>(b);
75
603k
    const auto a = Add(kBase, Mul(n, kMulN));
76
603k
    const auto d = And(m, kMaskM);
77
603k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
78
603k
    const auto c = Or(a, l);
79
603k
    extra_bits = Add(extra_bits, eb_fixed);
80
603k
    const auto t = Or(c, d);
81
603k
    const auto t_fixed = IfThenElse(not_literal, t, val);
82
603k
    Store(t_fixed, du, out + i);
83
603k
  }
84
20.3k
  if (last_full < len) {
85
17.4k
    const auto stop = Set(du, len);
86
17.4k
    const auto fence = Iota(du, last_full);
87
17.4k
    const auto take = Lt(fence, stop);
88
17.4k
    const auto val = LoadU(du, values + last_full);
89
17.4k
    const auto is_large = Gt(val, kLargeThreshold);
90
17.4k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
91
17.4k
    const auto not_literal = Ge(val, kSplit);
92
17.4k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
93
17.4k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
94
17.4k
    const auto l = And(val, kMaskL);
95
17.4k
    const auto exp = ShiftRight<23>(b);
96
17.4k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
97
17.4k
    const auto n = Sub(exp_fixed, kExpOffset);
98
17.4k
    const auto eb = Sub(exp_fixed, kEBOffset);
99
17.4k
    const auto m = ShiftRight<23 - M - L>(b);
100
17.4k
    const auto a = Add(kBase, Mul(n, kMulN));
101
17.4k
    const auto d = And(m, kMaskM);
102
17.4k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
103
17.4k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
104
17.4k
    const auto c = Or(a, l);
105
17.4k
    extra_bits = Add(extra_bits, eb_masked);
106
17.4k
    const auto t = Or(c, d);
107
17.4k
    const auto t_fixed = IfThenElse(not_literal, t, val);
108
17.4k
    Store(t_fixed, du, out + last_full);
109
17.4k
  }
110
20.3k
  return GetLane(SumOfLanes(du, extra_bits));
111
20.3k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<7ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
45
23.8k
                               uint32_t* JXL_RESTRICT out) {
46
23.8k
  const HWY_FULL(uint32_t) du;
47
23.8k
  const HWY_FULL(float) df;
48
23.8k
  const auto kZero = Zero(du);
49
23.8k
  const auto kSplit = Set(du, 1 << E);
50
23.8k
  const auto kExpOffset = Set(du, 127);
51
23.8k
  const auto kEBOffset = Set(du, 127 + M + L);
52
23.8k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
53
23.8k
  const auto kMulN = Set(du, 1 << (M + L));
54
23.8k
  const auto kMaskL = Set(du, (1 << L) - 1);
55
23.8k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
56
23.8k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
57
23.8k
  constexpr size_t kLargeShiftVal = 10;
58
23.8k
  const auto kLargeShift = Set(du, kLargeShiftVal);
59
60
23.8k
  auto extra_bits = kZero;
61
23.8k
  size_t last_full = Lanes(du) * (len / Lanes(du));
62
1.13M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
63
1.11M
    const auto val = LoadU(du, values + i);
64
1.11M
    const auto is_large = Gt(val, kLargeThreshold);
65
1.11M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
66
1.11M
    const auto not_literal = Ge(val, kSplit);
67
1.11M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
68
1.11M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
69
1.11M
    const auto l = And(val, kMaskL);
70
1.11M
    const auto exp = ShiftRight<23>(b);
71
1.11M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
72
1.11M
    const auto n = Sub(exp_fixed, kExpOffset);
73
1.11M
    const auto eb = Sub(exp_fixed, kEBOffset);
74
1.11M
    const auto m = ShiftRight<23 - M - L>(b);
75
1.11M
    const auto a = Add(kBase, Mul(n, kMulN));
76
1.11M
    const auto d = And(m, kMaskM);
77
1.11M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
78
1.11M
    const auto c = Or(a, l);
79
1.11M
    extra_bits = Add(extra_bits, eb_fixed);
80
1.11M
    const auto t = Or(c, d);
81
1.11M
    const auto t_fixed = IfThenElse(not_literal, t, val);
82
1.11M
    Store(t_fixed, du, out + i);
83
1.11M
  }
84
23.8k
  if (last_full < len) {
85
20.4k
    const auto stop = Set(du, len);
86
20.4k
    const auto fence = Iota(du, last_full);
87
20.4k
    const auto take = Lt(fence, stop);
88
20.4k
    const auto val = LoadU(du, values + last_full);
89
20.4k
    const auto is_large = Gt(val, kLargeThreshold);
90
20.4k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
91
20.4k
    const auto not_literal = Ge(val, kSplit);
92
20.4k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
93
20.4k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
94
20.4k
    const auto l = And(val, kMaskL);
95
20.4k
    const auto exp = ShiftRight<23>(b);
96
20.4k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
97
20.4k
    const auto n = Sub(exp_fixed, kExpOffset);
98
20.4k
    const auto eb = Sub(exp_fixed, kEBOffset);
99
20.4k
    const auto m = ShiftRight<23 - M - L>(b);
100
20.4k
    const auto a = Add(kBase, Mul(n, kMulN));
101
20.4k
    const auto d = And(m, kMaskM);
102
20.4k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
103
20.4k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
104
20.4k
    const auto c = Or(a, l);
105
20.4k
    extra_bits = Add(extra_bits, eb_masked);
106
20.4k
    const auto t = Or(c, d);
107
20.4k
    const auto t_fixed = IfThenElse(not_literal, t, val);
108
20.4k
    Store(t_fixed, du, out + last_full);
109
20.4k
  }
110
23.8k
  return GetLane(SumOfLanes(du, extra_bits));
111
23.8k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<8ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
45
17.6k
                               uint32_t* JXL_RESTRICT out) {
46
17.6k
  const HWY_FULL(uint32_t) du;
47
17.6k
  const HWY_FULL(float) df;
48
17.6k
  const auto kZero = Zero(du);
49
17.6k
  const auto kSplit = Set(du, 1 << E);
50
17.6k
  const auto kExpOffset = Set(du, 127);
51
17.6k
  const auto kEBOffset = Set(du, 127 + M + L);
52
17.6k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
53
17.6k
  const auto kMulN = Set(du, 1 << (M + L));
54
17.6k
  const auto kMaskL = Set(du, (1 << L) - 1);
55
17.6k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
56
17.6k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
57
17.6k
  constexpr size_t kLargeShiftVal = 10;
58
17.6k
  const auto kLargeShift = Set(du, kLargeShiftVal);
59
60
17.6k
  auto extra_bits = kZero;
61
17.6k
  size_t last_full = Lanes(du) * (len / Lanes(du));
62
545k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
63
527k
    const auto val = LoadU(du, values + i);
64
527k
    const auto is_large = Gt(val, kLargeThreshold);
65
527k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
66
527k
    const auto not_literal = Ge(val, kSplit);
67
527k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
68
527k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
69
527k
    const auto l = And(val, kMaskL);
70
527k
    const auto exp = ShiftRight<23>(b);
71
527k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
72
527k
    const auto n = Sub(exp_fixed, kExpOffset);
73
527k
    const auto eb = Sub(exp_fixed, kEBOffset);
74
527k
    const auto m = ShiftRight<23 - M - L>(b);
75
527k
    const auto a = Add(kBase, Mul(n, kMulN));
76
527k
    const auto d = And(m, kMaskM);
77
527k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
78
527k
    const auto c = Or(a, l);
79
527k
    extra_bits = Add(extra_bits, eb_fixed);
80
527k
    const auto t = Or(c, d);
81
527k
    const auto t_fixed = IfThenElse(not_literal, t, val);
82
527k
    Store(t_fixed, du, out + i);
83
527k
  }
84
17.6k
  if (last_full < len) {
85
15.1k
    const auto stop = Set(du, len);
86
15.1k
    const auto fence = Iota(du, last_full);
87
15.1k
    const auto take = Lt(fence, stop);
88
15.1k
    const auto val = LoadU(du, values + last_full);
89
15.1k
    const auto is_large = Gt(val, kLargeThreshold);
90
15.1k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
91
15.1k
    const auto not_literal = Ge(val, kSplit);
92
15.1k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
93
15.1k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
94
15.1k
    const auto l = And(val, kMaskL);
95
15.1k
    const auto exp = ShiftRight<23>(b);
96
15.1k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
97
15.1k
    const auto n = Sub(exp_fixed, kExpOffset);
98
15.1k
    const auto eb = Sub(exp_fixed, kEBOffset);
99
15.1k
    const auto m = ShiftRight<23 - M - L>(b);
100
15.1k
    const auto a = Add(kBase, Mul(n, kMulN));
101
15.1k
    const auto d = And(m, kMaskM);
102
15.1k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
103
15.1k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
104
15.1k
    const auto c = Or(a, l);
105
15.1k
    extra_bits = Add(extra_bits, eb_masked);
106
15.1k
    const auto t = Or(c, d);
107
15.1k
    const auto t_fixed = IfThenElse(not_literal, t, val);
108
15.1k
    Store(t_fixed, du, out + last_full);
109
15.1k
  }
110
17.6k
  return GetLane(SumOfLanes(du, extra_bits));
111
17.6k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<9ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
45
17.6k
                               uint32_t* JXL_RESTRICT out) {
46
17.6k
  const HWY_FULL(uint32_t) du;
47
17.6k
  const HWY_FULL(float) df;
48
17.6k
  const auto kZero = Zero(du);
49
17.6k
  const auto kSplit = Set(du, 1 << E);
50
17.6k
  const auto kExpOffset = Set(du, 127);
51
17.6k
  const auto kEBOffset = Set(du, 127 + M + L);
52
17.6k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
53
17.6k
  const auto kMulN = Set(du, 1 << (M + L));
54
17.6k
  const auto kMaskL = Set(du, (1 << L) - 1);
55
17.6k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
56
17.6k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
57
17.6k
  constexpr size_t kLargeShiftVal = 10;
58
17.6k
  const auto kLargeShift = Set(du, kLargeShiftVal);
59
60
17.6k
  auto extra_bits = kZero;
61
17.6k
  size_t last_full = Lanes(du) * (len / Lanes(du));
62
545k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
63
527k
    const auto val = LoadU(du, values + i);
64
527k
    const auto is_large = Gt(val, kLargeThreshold);
65
527k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
66
527k
    const auto not_literal = Ge(val, kSplit);
67
527k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
68
527k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
69
527k
    const auto l = And(val, kMaskL);
70
527k
    const auto exp = ShiftRight<23>(b);
71
527k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
72
527k
    const auto n = Sub(exp_fixed, kExpOffset);
73
527k
    const auto eb = Sub(exp_fixed, kEBOffset);
74
527k
    const auto m = ShiftRight<23 - M - L>(b);
75
527k
    const auto a = Add(kBase, Mul(n, kMulN));
76
527k
    const auto d = And(m, kMaskM);
77
527k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
78
527k
    const auto c = Or(a, l);
79
527k
    extra_bits = Add(extra_bits, eb_fixed);
80
527k
    const auto t = Or(c, d);
81
527k
    const auto t_fixed = IfThenElse(not_literal, t, val);
82
527k
    Store(t_fixed, du, out + i);
83
527k
  }
84
17.6k
  if (last_full < len) {
85
15.1k
    const auto stop = Set(du, len);
86
15.1k
    const auto fence = Iota(du, last_full);
87
15.1k
    const auto take = Lt(fence, stop);
88
15.1k
    const auto val = LoadU(du, values + last_full);
89
15.1k
    const auto is_large = Gt(val, kLargeThreshold);
90
15.1k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
91
15.1k
    const auto not_literal = Ge(val, kSplit);
92
15.1k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
93
15.1k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
94
15.1k
    const auto l = And(val, kMaskL);
95
15.1k
    const auto exp = ShiftRight<23>(b);
96
15.1k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
97
15.1k
    const auto n = Sub(exp_fixed, kExpOffset);
98
15.1k
    const auto eb = Sub(exp_fixed, kEBOffset);
99
15.1k
    const auto m = ShiftRight<23 - M - L>(b);
100
15.1k
    const auto a = Add(kBase, Mul(n, kMulN));
101
15.1k
    const auto d = And(m, kMaskM);
102
15.1k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
103
15.1k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
104
15.1k
    const auto c = Or(a, l);
105
15.1k
    extra_bits = Add(extra_bits, eb_masked);
106
15.1k
    const auto t = Or(c, d);
107
15.1k
    const auto t_fixed = IfThenElse(not_literal, t, val);
108
15.1k
    Store(t_fixed, du, out + last_full);
109
15.1k
  }
110
17.6k
  return GetLane(SumOfLanes(du, extra_bits));
111
17.6k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<10ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
45
17.6k
                               uint32_t* JXL_RESTRICT out) {
46
17.6k
  const HWY_FULL(uint32_t) du;
47
17.6k
  const HWY_FULL(float) df;
48
17.6k
  const auto kZero = Zero(du);
49
17.6k
  const auto kSplit = Set(du, 1 << E);
50
17.6k
  const auto kExpOffset = Set(du, 127);
51
17.6k
  const auto kEBOffset = Set(du, 127 + M + L);
52
17.6k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
53
17.6k
  const auto kMulN = Set(du, 1 << (M + L));
54
17.6k
  const auto kMaskL = Set(du, (1 << L) - 1);
55
17.6k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
56
17.6k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
57
17.6k
  constexpr size_t kLargeShiftVal = 10;
58
17.6k
  const auto kLargeShift = Set(du, kLargeShiftVal);
59
60
17.6k
  auto extra_bits = kZero;
61
17.6k
  size_t last_full = Lanes(du) * (len / Lanes(du));
62
545k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
63
527k
    const auto val = LoadU(du, values + i);
64
527k
    const auto is_large = Gt(val, kLargeThreshold);
65
527k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
66
527k
    const auto not_literal = Ge(val, kSplit);
67
527k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
68
527k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
69
527k
    const auto l = And(val, kMaskL);
70
527k
    const auto exp = ShiftRight<23>(b);
71
527k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
72
527k
    const auto n = Sub(exp_fixed, kExpOffset);
73
527k
    const auto eb = Sub(exp_fixed, kEBOffset);
74
527k
    const auto m = ShiftRight<23 - M - L>(b);
75
527k
    const auto a = Add(kBase, Mul(n, kMulN));
76
527k
    const auto d = And(m, kMaskM);
77
527k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
78
527k
    const auto c = Or(a, l);
79
527k
    extra_bits = Add(extra_bits, eb_fixed);
80
527k
    const auto t = Or(c, d);
81
527k
    const auto t_fixed = IfThenElse(not_literal, t, val);
82
527k
    Store(t_fixed, du, out + i);
83
527k
  }
84
17.6k
  if (last_full < len) {
85
15.1k
    const auto stop = Set(du, len);
86
15.1k
    const auto fence = Iota(du, last_full);
87
15.1k
    const auto take = Lt(fence, stop);
88
15.1k
    const auto val = LoadU(du, values + last_full);
89
15.1k
    const auto is_large = Gt(val, kLargeThreshold);
90
15.1k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
91
15.1k
    const auto not_literal = Ge(val, kSplit);
92
15.1k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
93
15.1k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
94
15.1k
    const auto l = And(val, kMaskL);
95
15.1k
    const auto exp = ShiftRight<23>(b);
96
15.1k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
97
15.1k
    const auto n = Sub(exp_fixed, kExpOffset);
98
15.1k
    const auto eb = Sub(exp_fixed, kEBOffset);
99
15.1k
    const auto m = ShiftRight<23 - M - L>(b);
100
15.1k
    const auto a = Add(kBase, Mul(n, kMulN));
101
15.1k
    const auto d = And(m, kMaskM);
102
15.1k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
103
15.1k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
104
15.1k
    const auto c = Or(a, l);
105
15.1k
    extra_bits = Add(extra_bits, eb_masked);
106
15.1k
    const auto t = Or(c, d);
107
15.1k
    const auto t_fixed = IfThenElse(not_literal, t, val);
108
15.1k
    Store(t_fixed, du, out + last_full);
109
15.1k
  }
110
17.6k
  return GetLane(SumOfLanes(du, extra_bits));
111
17.6k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<11ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
45
17.6k
                               uint32_t* JXL_RESTRICT out) {
46
17.6k
  const HWY_FULL(uint32_t) du;
47
17.6k
  const HWY_FULL(float) df;
48
17.6k
  const auto kZero = Zero(du);
49
17.6k
  const auto kSplit = Set(du, 1 << E);
50
17.6k
  const auto kExpOffset = Set(du, 127);
51
17.6k
  const auto kEBOffset = Set(du, 127 + M + L);
52
17.6k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
53
17.6k
  const auto kMulN = Set(du, 1 << (M + L));
54
17.6k
  const auto kMaskL = Set(du, (1 << L) - 1);
55
17.6k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
56
17.6k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
57
17.6k
  constexpr size_t kLargeShiftVal = 10;
58
17.6k
  const auto kLargeShift = Set(du, kLargeShiftVal);
59
60
17.6k
  auto extra_bits = kZero;
61
17.6k
  size_t last_full = Lanes(du) * (len / Lanes(du));
62
545k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
63
527k
    const auto val = LoadU(du, values + i);
64
527k
    const auto is_large = Gt(val, kLargeThreshold);
65
527k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
66
527k
    const auto not_literal = Ge(val, kSplit);
67
527k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
68
527k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
69
527k
    const auto l = And(val, kMaskL);
70
527k
    const auto exp = ShiftRight<23>(b);
71
527k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
72
527k
    const auto n = Sub(exp_fixed, kExpOffset);
73
527k
    const auto eb = Sub(exp_fixed, kEBOffset);
74
527k
    const auto m = ShiftRight<23 - M - L>(b);
75
527k
    const auto a = Add(kBase, Mul(n, kMulN));
76
527k
    const auto d = And(m, kMaskM);
77
527k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
78
527k
    const auto c = Or(a, l);
79
527k
    extra_bits = Add(extra_bits, eb_fixed);
80
527k
    const auto t = Or(c, d);
81
527k
    const auto t_fixed = IfThenElse(not_literal, t, val);
82
527k
    Store(t_fixed, du, out + i);
83
527k
  }
84
17.6k
  if (last_full < len) {
85
15.1k
    const auto stop = Set(du, len);
86
15.1k
    const auto fence = Iota(du, last_full);
87
15.1k
    const auto take = Lt(fence, stop);
88
15.1k
    const auto val = LoadU(du, values + last_full);
89
15.1k
    const auto is_large = Gt(val, kLargeThreshold);
90
15.1k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
91
15.1k
    const auto not_literal = Ge(val, kSplit);
92
15.1k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
93
15.1k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
94
15.1k
    const auto l = And(val, kMaskL);
95
15.1k
    const auto exp = ShiftRight<23>(b);
96
15.1k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
97
15.1k
    const auto n = Sub(exp_fixed, kExpOffset);
98
15.1k
    const auto eb = Sub(exp_fixed, kEBOffset);
99
15.1k
    const auto m = ShiftRight<23 - M - L>(b);
100
15.1k
    const auto a = Add(kBase, Mul(n, kMulN));
101
15.1k
    const auto d = And(m, kMaskM);
102
15.1k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
103
15.1k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
104
15.1k
    const auto c = Or(a, l);
105
15.1k
    extra_bits = Add(extra_bits, eb_masked);
106
15.1k
    const auto t = Or(c, d);
107
15.1k
    const auto t_fixed = IfThenElse(not_literal, t, val);
108
15.1k
    Store(t_fixed, du, out + last_full);
109
15.1k
  }
110
17.6k
  return GetLane(SumOfLanes(du, extra_bits));
111
17.6k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<12ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
45
17.6k
                               uint32_t* JXL_RESTRICT out) {
46
17.6k
  const HWY_FULL(uint32_t) du;
47
17.6k
  const HWY_FULL(float) df;
48
17.6k
  const auto kZero = Zero(du);
49
17.6k
  const auto kSplit = Set(du, 1 << E);
50
17.6k
  const auto kExpOffset = Set(du, 127);
51
17.6k
  const auto kEBOffset = Set(du, 127 + M + L);
52
17.6k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
53
17.6k
  const auto kMulN = Set(du, 1 << (M + L));
54
17.6k
  const auto kMaskL = Set(du, (1 << L) - 1);
55
17.6k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
56
17.6k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
57
17.6k
  constexpr size_t kLargeShiftVal = 10;
58
17.6k
  const auto kLargeShift = Set(du, kLargeShiftVal);
59
60
17.6k
  auto extra_bits = kZero;
61
17.6k
  size_t last_full = Lanes(du) * (len / Lanes(du));
62
545k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
63
527k
    const auto val = LoadU(du, values + i);
64
527k
    const auto is_large = Gt(val, kLargeThreshold);
65
527k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
66
527k
    const auto not_literal = Ge(val, kSplit);
67
527k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
68
527k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
69
527k
    const auto l = And(val, kMaskL);
70
527k
    const auto exp = ShiftRight<23>(b);
71
527k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
72
527k
    const auto n = Sub(exp_fixed, kExpOffset);
73
527k
    const auto eb = Sub(exp_fixed, kEBOffset);
74
527k
    const auto m = ShiftRight<23 - M - L>(b);
75
527k
    const auto a = Add(kBase, Mul(n, kMulN));
76
527k
    const auto d = And(m, kMaskM);
77
527k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
78
527k
    const auto c = Or(a, l);
79
527k
    extra_bits = Add(extra_bits, eb_fixed);
80
527k
    const auto t = Or(c, d);
81
527k
    const auto t_fixed = IfThenElse(not_literal, t, val);
82
527k
    Store(t_fixed, du, out + i);
83
527k
  }
84
17.6k
  if (last_full < len) {
85
15.1k
    const auto stop = Set(du, len);
86
15.1k
    const auto fence = Iota(du, last_full);
87
15.1k
    const auto take = Lt(fence, stop);
88
15.1k
    const auto val = LoadU(du, values + last_full);
89
15.1k
    const auto is_large = Gt(val, kLargeThreshold);
90
15.1k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
91
15.1k
    const auto not_literal = Ge(val, kSplit);
92
15.1k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
93
15.1k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
94
15.1k
    const auto l = And(val, kMaskL);
95
15.1k
    const auto exp = ShiftRight<23>(b);
96
15.1k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
97
15.1k
    const auto n = Sub(exp_fixed, kExpOffset);
98
15.1k
    const auto eb = Sub(exp_fixed, kEBOffset);
99
15.1k
    const auto m = ShiftRight<23 - M - L>(b);
100
15.1k
    const auto a = Add(kBase, Mul(n, kMulN));
101
15.1k
    const auto d = And(m, kMaskM);
102
15.1k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
103
15.1k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
104
15.1k
    const auto c = Or(a, l);
105
15.1k
    extra_bits = Add(extra_bits, eb_masked);
106
15.1k
    const auto t = Or(c, d);
107
15.1k
    const auto t_fixed = IfThenElse(not_literal, t, val);
108
15.1k
    Store(t_fixed, du, out + last_full);
109
15.1k
  }
110
17.6k
  return GetLane(SumOfLanes(du, extra_bits));
111
17.6k
}
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*)
112
113
uint32_t EstimateTokenCost(uint32_t* JXL_RESTRICT values, size_t len,
114
961k
                           HybridUintConfig cfg, AlignedMemory& tokens) {
115
961k
  uint32_t* JXL_RESTRICT out = tokens.address<uint32_t>();
116
#if HWY_TARGET == HWY_SCALAR
117
  uint32_t extra_bits = 0;
118
  for (size_t i = 0; i < len; ++i) {
119
    uint32_t v = values[i];
120
    uint32_t tok, nbits, bits;
121
    cfg.Encode(v, &tok, &nbits, &bits);
122
    extra_bits += nbits;
123
    out[i] = tok;
124
  }
125
  return extra_bits;
126
#else
127
961k
  if (cfg.split_exponent == 0) {
128
109k
    return EstimateTokenCostImpl<0, 0, 0>(values, len, out);
129
852k
  } else if (cfg.split_exponent == 2) {
130
105k
    JXL_DASSERT((cfg.msb_in_token == 0) && (cfg.lsb_in_token == 1));
131
105k
    return EstimateTokenCostImpl<2, 0, 1>(values, len, out);
132
746k
  } else if (cfg.split_exponent == 3) {
133
95.3k
    if (cfg.msb_in_token == 1) {
134
47.6k
      if (cfg.lsb_in_token == 0) {
135
23.8k
        return EstimateTokenCostImpl<3, 1, 0>(values, len, out);
136
23.8k
      } else {
137
23.8k
        JXL_DASSERT(cfg.lsb_in_token == 2);
138
23.8k
        return EstimateTokenCostImpl<3, 1, 2>(values, len, out);
139
23.8k
      }
140
47.6k
    } else {
141
47.6k
      JXL_DASSERT(cfg.msb_in_token == 2);
142
47.6k
      if (cfg.lsb_in_token == 0) {
143
23.8k
        return EstimateTokenCostImpl<3, 2, 0>(values, len, out);
144
23.8k
      } else {
145
23.8k
        JXL_DASSERT(cfg.lsb_in_token == 1);
146
23.8k
        return EstimateTokenCostImpl<3, 2, 1>(values, len, out);
147
23.8k
      }
148
47.6k
    }
149
650k
  } else if (cfg.split_exponent == 4) {
150
307k
    if (cfg.msb_in_token == 1) {
151
153k
      if (cfg.lsb_in_token == 0) {
152
23.8k
        return EstimateTokenCostImpl<4, 1, 0>(values, len, out);
153
129k
      } else if (cfg.lsb_in_token == 2) {
154
105k
        return EstimateTokenCostImpl<4, 1, 2>(values, len, out);
155
105k
      } else {
156
23.8k
        JXL_DASSERT(cfg.lsb_in_token == 3);
157
23.8k
        return EstimateTokenCostImpl<4, 1, 3>(values, len, out);
158
23.8k
      }
159
153k
    } else {
160
153k
      JXL_DASSERT(cfg.msb_in_token == 2);
161
153k
      if (cfg.lsb_in_token == 0) {
162
105k
        return EstimateTokenCostImpl<4, 2, 0>(values, len, out);
163
105k
      } else if (cfg.lsb_in_token == 1) {
164
23.8k
        return EstimateTokenCostImpl<4, 2, 1>(values, len, out);
165
23.8k
      } else {
166
23.8k
        JXL_DASSERT(cfg.lsb_in_token == 2);
167
23.8k
        return EstimateTokenCostImpl<4, 2, 2>(values, len, out);
168
23.8k
      }
169
153k
    }
170
343k
  } else if (cfg.split_exponent == 5) {
171
166k
    if (cfg.msb_in_token == 1) {
172
71.5k
      if (cfg.lsb_in_token == 0) {
173
23.8k
        return EstimateTokenCostImpl<5, 1, 0>(values, len, out);
174
47.6k
      } else if (cfg.lsb_in_token == 2) {
175
23.8k
        return EstimateTokenCostImpl<5, 1, 2>(values, len, out);
176
23.8k
      } else {
177
23.8k
        JXL_DASSERT(cfg.lsb_in_token == 4);
178
23.8k
        return EstimateTokenCostImpl<5, 1, 4>(values, len, out);
179
23.8k
      }
180
95.3k
    } else {
181
95.3k
      JXL_DASSERT(cfg.msb_in_token == 2);
182
95.3k
      if (cfg.lsb_in_token == 0) {
183
23.8k
        return EstimateTokenCostImpl<5, 2, 0>(values, len, out);
184
71.5k
      } else if (cfg.lsb_in_token == 1) {
185
23.8k
        return EstimateTokenCostImpl<5, 2, 1>(values, len, out);
186
47.6k
      } else if (cfg.lsb_in_token == 2) {
187
23.8k
        return EstimateTokenCostImpl<5, 2, 2>(values, len, out);
188
23.8k
      } else {
189
23.8k
        JXL_DASSERT(cfg.lsb_in_token == 3);
190
23.8k
        return EstimateTokenCostImpl<5, 2, 3>(values, len, out);
191
23.8k
      }
192
95.3k
    }
193
176k
  } else if (cfg.split_exponent == 6) {
194
64.5k
    if (cfg.msb_in_token == 0) {
195
23.8k
      JXL_DASSERT(cfg.lsb_in_token == 0);
196
23.8k
      return EstimateTokenCostImpl<6, 0, 0>(values, len, out);
197
40.6k
    } else if (cfg.msb_in_token == 1) {
198
20.3k
      JXL_DASSERT(cfg.lsb_in_token == 5);
199
20.3k
      return EstimateTokenCostImpl<6, 1, 5>(values, len, out);
200
20.3k
    } else {
201
20.3k
      JXL_DASSERT(cfg.msb_in_token == 2);
202
20.3k
      JXL_DASSERT(cfg.lsb_in_token == 4);
203
20.3k
      return EstimateTokenCostImpl<6, 2, 4>(values, len, out);
204
20.3k
    }
205
112k
  } else if (cfg.split_exponent >= 7 && cfg.split_exponent <= 12) {
206
112k
    JXL_DASSERT(cfg.msb_in_token == 0);
207
112k
    JXL_DASSERT(cfg.lsb_in_token == 0);
208
112k
    if (cfg.split_exponent == 7) {
209
23.8k
      return EstimateTokenCostImpl<7, 0, 0>(values, len, out);
210
88.4k
    } else if (cfg.split_exponent == 8) {
211
17.6k
      return EstimateTokenCostImpl<8, 0, 0>(values, len, out);
212
70.7k
    } else if (cfg.split_exponent == 9) {
213
17.6k
      return EstimateTokenCostImpl<9, 0, 0>(values, len, out);
214
53.0k
    } else if (cfg.split_exponent == 10) {
215
17.6k
      return EstimateTokenCostImpl<10, 0, 0>(values, len, out);
216
35.3k
    } else if (cfg.split_exponent == 11) {
217
17.6k
      return EstimateTokenCostImpl<11, 0, 0>(values, len, out);
218
17.6k
    } else {
219
17.6k
      return EstimateTokenCostImpl<12, 0, 0>(values, len, out);
220
17.6k
    }
221
112k
  } else {
222
0
    JXL_DASSERT(false);
223
0
  }
224
0
  return ~0;
225
961k
#endif
226
961k
}
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
114
961k
                           HybridUintConfig cfg, AlignedMemory& tokens) {
115
961k
  uint32_t* JXL_RESTRICT out = tokens.address<uint32_t>();
116
#if HWY_TARGET == HWY_SCALAR
117
  uint32_t extra_bits = 0;
118
  for (size_t i = 0; i < len; ++i) {
119
    uint32_t v = values[i];
120
    uint32_t tok, nbits, bits;
121
    cfg.Encode(v, &tok, &nbits, &bits);
122
    extra_bits += nbits;
123
    out[i] = tok;
124
  }
125
  return extra_bits;
126
#else
127
961k
  if (cfg.split_exponent == 0) {
128
109k
    return EstimateTokenCostImpl<0, 0, 0>(values, len, out);
129
852k
  } else if (cfg.split_exponent == 2) {
130
105k
    JXL_DASSERT((cfg.msb_in_token == 0) && (cfg.lsb_in_token == 1));
131
105k
    return EstimateTokenCostImpl<2, 0, 1>(values, len, out);
132
746k
  } else if (cfg.split_exponent == 3) {
133
95.3k
    if (cfg.msb_in_token == 1) {
134
47.6k
      if (cfg.lsb_in_token == 0) {
135
23.8k
        return EstimateTokenCostImpl<3, 1, 0>(values, len, out);
136
23.8k
      } else {
137
23.8k
        JXL_DASSERT(cfg.lsb_in_token == 2);
138
23.8k
        return EstimateTokenCostImpl<3, 1, 2>(values, len, out);
139
23.8k
      }
140
47.6k
    } else {
141
47.6k
      JXL_DASSERT(cfg.msb_in_token == 2);
142
47.6k
      if (cfg.lsb_in_token == 0) {
143
23.8k
        return EstimateTokenCostImpl<3, 2, 0>(values, len, out);
144
23.8k
      } else {
145
23.8k
        JXL_DASSERT(cfg.lsb_in_token == 1);
146
23.8k
        return EstimateTokenCostImpl<3, 2, 1>(values, len, out);
147
23.8k
      }
148
47.6k
    }
149
650k
  } else if (cfg.split_exponent == 4) {
150
307k
    if (cfg.msb_in_token == 1) {
151
153k
      if (cfg.lsb_in_token == 0) {
152
23.8k
        return EstimateTokenCostImpl<4, 1, 0>(values, len, out);
153
129k
      } else if (cfg.lsb_in_token == 2) {
154
105k
        return EstimateTokenCostImpl<4, 1, 2>(values, len, out);
155
105k
      } else {
156
23.8k
        JXL_DASSERT(cfg.lsb_in_token == 3);
157
23.8k
        return EstimateTokenCostImpl<4, 1, 3>(values, len, out);
158
23.8k
      }
159
153k
    } else {
160
153k
      JXL_DASSERT(cfg.msb_in_token == 2);
161
153k
      if (cfg.lsb_in_token == 0) {
162
105k
        return EstimateTokenCostImpl<4, 2, 0>(values, len, out);
163
105k
      } else if (cfg.lsb_in_token == 1) {
164
23.8k
        return EstimateTokenCostImpl<4, 2, 1>(values, len, out);
165
23.8k
      } else {
166
23.8k
        JXL_DASSERT(cfg.lsb_in_token == 2);
167
23.8k
        return EstimateTokenCostImpl<4, 2, 2>(values, len, out);
168
23.8k
      }
169
153k
    }
170
343k
  } else if (cfg.split_exponent == 5) {
171
166k
    if (cfg.msb_in_token == 1) {
172
71.5k
      if (cfg.lsb_in_token == 0) {
173
23.8k
        return EstimateTokenCostImpl<5, 1, 0>(values, len, out);
174
47.6k
      } else if (cfg.lsb_in_token == 2) {
175
23.8k
        return EstimateTokenCostImpl<5, 1, 2>(values, len, out);
176
23.8k
      } else {
177
23.8k
        JXL_DASSERT(cfg.lsb_in_token == 4);
178
23.8k
        return EstimateTokenCostImpl<5, 1, 4>(values, len, out);
179
23.8k
      }
180
95.3k
    } else {
181
95.3k
      JXL_DASSERT(cfg.msb_in_token == 2);
182
95.3k
      if (cfg.lsb_in_token == 0) {
183
23.8k
        return EstimateTokenCostImpl<5, 2, 0>(values, len, out);
184
71.5k
      } else if (cfg.lsb_in_token == 1) {
185
23.8k
        return EstimateTokenCostImpl<5, 2, 1>(values, len, out);
186
47.6k
      } else if (cfg.lsb_in_token == 2) {
187
23.8k
        return EstimateTokenCostImpl<5, 2, 2>(values, len, out);
188
23.8k
      } else {
189
23.8k
        JXL_DASSERT(cfg.lsb_in_token == 3);
190
23.8k
        return EstimateTokenCostImpl<5, 2, 3>(values, len, out);
191
23.8k
      }
192
95.3k
    }
193
176k
  } else if (cfg.split_exponent == 6) {
194
64.5k
    if (cfg.msb_in_token == 0) {
195
23.8k
      JXL_DASSERT(cfg.lsb_in_token == 0);
196
23.8k
      return EstimateTokenCostImpl<6, 0, 0>(values, len, out);
197
40.6k
    } else if (cfg.msb_in_token == 1) {
198
20.3k
      JXL_DASSERT(cfg.lsb_in_token == 5);
199
20.3k
      return EstimateTokenCostImpl<6, 1, 5>(values, len, out);
200
20.3k
    } else {
201
20.3k
      JXL_DASSERT(cfg.msb_in_token == 2);
202
20.3k
      JXL_DASSERT(cfg.lsb_in_token == 4);
203
20.3k
      return EstimateTokenCostImpl<6, 2, 4>(values, len, out);
204
20.3k
    }
205
112k
  } else if (cfg.split_exponent >= 7 && cfg.split_exponent <= 12) {
206
112k
    JXL_DASSERT(cfg.msb_in_token == 0);
207
112k
    JXL_DASSERT(cfg.lsb_in_token == 0);
208
112k
    if (cfg.split_exponent == 7) {
209
23.8k
      return EstimateTokenCostImpl<7, 0, 0>(values, len, out);
210
88.4k
    } else if (cfg.split_exponent == 8) {
211
17.6k
      return EstimateTokenCostImpl<8, 0, 0>(values, len, out);
212
70.7k
    } else if (cfg.split_exponent == 9) {
213
17.6k
      return EstimateTokenCostImpl<9, 0, 0>(values, len, out);
214
53.0k
    } else if (cfg.split_exponent == 10) {
215
17.6k
      return EstimateTokenCostImpl<10, 0, 0>(values, len, out);
216
35.3k
    } else if (cfg.split_exponent == 11) {
217
17.6k
      return EstimateTokenCostImpl<11, 0, 0>(values, len, out);
218
17.6k
    } else {
219
17.6k
      return EstimateTokenCostImpl<12, 0, 0>(values, len, out);
220
17.6k
    }
221
112k
  } else {
222
0
    JXL_DASSERT(false);
223
0
  }
224
0
  return ~0;
225
961k
#endif
226
961k
}
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&)
227
228
// NOLINTNEXTLINE(google-readability-namespace-comments)
229
}  // namespace HWY_NAMESPACE
230
}  // namespace jxl
231
HWY_AFTER_NAMESPACE();
232
233
#if HWY_ONCE
234
namespace jxl {
235
236
HWY_EXPORT(EstimateTokenCost);
237
238
uint32_t EstimateTokenCost(uint32_t* JXL_RESTRICT values, size_t len,
239
961k
                           HybridUintConfig cfg, AlignedMemory& tokens) {
240
961k
  JXL_DASSERT(cfg.lsb_in_token + cfg.msb_in_token <= cfg.split_exponent);
241
961k
  return HWY_DYNAMIC_DISPATCH(EstimateTokenCost)(values, len, cfg, tokens);
242
961k
}
243
244
}  // namespace jxl
245
#endif