Coverage Report

Created: 2026-10-28 07:26

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