Coverage Report

Created: 2025-12-03 07:28

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