Coverage Report

Created: 2026-05-24 07:45

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
731k
                               uint32_t* JXL_RESTRICT out) {
45
731k
  const HWY_FULL(uint32_t) du;
46
731k
  const HWY_FULL(float) df;
47
731k
  const auto kZero = Zero(du);
48
731k
  const auto kSplit = Set(du, 1 << E);
49
731k
  const auto kExpOffset = Set(du, 127);
50
731k
  const auto kEBOffset = Set(du, 127 + M + L);
51
731k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
731k
  const auto kMulN = Set(du, 1 << (M + L));
53
731k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
731k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
731k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
731k
  constexpr size_t kLargeShiftVal = 10;
57
731k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
731k
  auto extra_bits = kZero;
60
731k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
49.1M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
48.3M
    const auto val = LoadU(du, values + i);
63
48.3M
    const auto is_large = Gt(val, kLargeThreshold);
64
48.3M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
48.3M
    const auto not_literal = Ge(val, kSplit);
66
48.3M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
48.3M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
48.3M
    const auto l = And(val, kMaskL);
69
48.3M
    const auto exp = ShiftRight<23>(b);
70
48.3M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
48.3M
    const auto n = Sub(exp_fixed, kExpOffset);
72
48.3M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
48.3M
    const auto m = ShiftRight<23 - M - L>(b);
74
48.3M
    const auto a = Add(kBase, Mul(n, kMulN));
75
48.3M
    const auto d = And(m, kMaskM);
76
48.3M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
48.3M
    const auto c = Or(a, l);
78
48.3M
    extra_bits = Add(extra_bits, eb_fixed);
79
48.3M
    const auto t = Or(c, d);
80
48.3M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
48.3M
    Store(t_fixed, du, out + i);
82
48.3M
  }
83
731k
  if (last_full < len) {
84
627k
    const auto stop = Set(du, len);
85
627k
    const auto fence = Iota(du, last_full);
86
627k
    const auto take = Lt(fence, stop);
87
627k
    const auto val = LoadU(du, values + last_full);
88
627k
    const auto is_large = Gt(val, kLargeThreshold);
89
627k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
627k
    const auto not_literal = Ge(val, kSplit);
91
627k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
627k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
627k
    const auto l = And(val, kMaskL);
94
627k
    const auto exp = ShiftRight<23>(b);
95
627k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
627k
    const auto n = Sub(exp_fixed, kExpOffset);
97
627k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
627k
    const auto m = ShiftRight<23 - M - L>(b);
99
627k
    const auto a = Add(kBase, Mul(n, kMulN));
100
627k
    const auto d = And(m, kMaskM);
101
627k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
627k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
627k
    const auto c = Or(a, l);
104
627k
    extra_bits = Add(extra_bits, eb_masked);
105
627k
    const auto t = Or(c, d);
106
627k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
627k
    Store(t_fixed, du, out + last_full);
108
627k
  }
109
731k
  return GetLane(SumOfLanes(du, extra_bits));
110
731k
}
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.8k
                               uint32_t* JXL_RESTRICT out) {
45
87.8k
  const HWY_FULL(uint32_t) du;
46
87.8k
  const HWY_FULL(float) df;
47
87.8k
  const auto kZero = Zero(du);
48
87.8k
  const auto kSplit = Set(du, 1 << E);
49
87.8k
  const auto kExpOffset = Set(du, 127);
50
87.8k
  const auto kEBOffset = Set(du, 127 + M + L);
51
87.8k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
87.8k
  const auto kMulN = Set(du, 1 << (M + L));
53
87.8k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
87.8k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
87.8k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
87.8k
  constexpr size_t kLargeShiftVal = 10;
57
87.8k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
87.8k
  auto extra_bits = kZero;
60
87.8k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
7.47M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
7.38M
    const auto val = LoadU(du, values + i);
63
7.38M
    const auto is_large = Gt(val, kLargeThreshold);
64
7.38M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
7.38M
    const auto not_literal = Ge(val, kSplit);
66
7.38M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
7.38M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
7.38M
    const auto l = And(val, kMaskL);
69
7.38M
    const auto exp = ShiftRight<23>(b);
70
7.38M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
7.38M
    const auto n = Sub(exp_fixed, kExpOffset);
72
7.38M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
7.38M
    const auto m = ShiftRight<23 - M - L>(b);
74
7.38M
    const auto a = Add(kBase, Mul(n, kMulN));
75
7.38M
    const auto d = And(m, kMaskM);
76
7.38M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
7.38M
    const auto c = Or(a, l);
78
7.38M
    extra_bits = Add(extra_bits, eb_fixed);
79
7.38M
    const auto t = Or(c, d);
80
7.38M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
7.38M
    Store(t_fixed, du, out + i);
82
7.38M
  }
83
87.8k
  if (last_full < len) {
84
75.5k
    const auto stop = Set(du, len);
85
75.5k
    const auto fence = Iota(du, last_full);
86
75.5k
    const auto take = Lt(fence, stop);
87
75.5k
    const auto val = LoadU(du, values + last_full);
88
75.5k
    const auto is_large = Gt(val, kLargeThreshold);
89
75.5k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
75.5k
    const auto not_literal = Ge(val, kSplit);
91
75.5k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
75.5k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
75.5k
    const auto l = And(val, kMaskL);
94
75.5k
    const auto exp = ShiftRight<23>(b);
95
75.5k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
75.5k
    const auto n = Sub(exp_fixed, kExpOffset);
97
75.5k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
75.5k
    const auto m = ShiftRight<23 - M - L>(b);
99
75.5k
    const auto a = Add(kBase, Mul(n, kMulN));
100
75.5k
    const auto d = And(m, kMaskM);
101
75.5k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
75.5k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
75.5k
    const auto c = Or(a, l);
104
75.5k
    extra_bits = Add(extra_bits, eb_masked);
105
75.5k
    const auto t = Or(c, d);
106
75.5k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
75.5k
    Store(t_fixed, du, out + last_full);
108
75.5k
  }
109
87.8k
  return GetLane(SumOfLanes(du, extra_bits));
110
87.8k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<2ul, 0ul, 1ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
85.3k
                               uint32_t* JXL_RESTRICT out) {
45
85.3k
  const HWY_FULL(uint32_t) du;
46
85.3k
  const HWY_FULL(float) df;
47
85.3k
  const auto kZero = Zero(du);
48
85.3k
  const auto kSplit = Set(du, 1 << E);
49
85.3k
  const auto kExpOffset = Set(du, 127);
50
85.3k
  const auto kEBOffset = Set(du, 127 + M + L);
51
85.3k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
85.3k
  const auto kMulN = Set(du, 1 << (M + L));
53
85.3k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
85.3k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
85.3k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
85.3k
  constexpr size_t kLargeShiftVal = 10;
57
85.3k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
85.3k
  auto extra_bits = kZero;
60
85.3k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
7.46M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
7.38M
    const auto val = LoadU(du, values + i);
63
7.38M
    const auto is_large = Gt(val, kLargeThreshold);
64
7.38M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
7.38M
    const auto not_literal = Ge(val, kSplit);
66
7.38M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
7.38M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
7.38M
    const auto l = And(val, kMaskL);
69
7.38M
    const auto exp = ShiftRight<23>(b);
70
7.38M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
7.38M
    const auto n = Sub(exp_fixed, kExpOffset);
72
7.38M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
7.38M
    const auto m = ShiftRight<23 - M - L>(b);
74
7.38M
    const auto a = Add(kBase, Mul(n, kMulN));
75
7.38M
    const auto d = And(m, kMaskM);
76
7.38M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
7.38M
    const auto c = Or(a, l);
78
7.38M
    extra_bits = Add(extra_bits, eb_fixed);
79
7.38M
    const auto t = Or(c, d);
80
7.38M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
7.38M
    Store(t_fixed, du, out + i);
82
7.38M
  }
83
85.3k
  if (last_full < len) {
84
73.2k
    const auto stop = Set(du, len);
85
73.2k
    const auto fence = Iota(du, last_full);
86
73.2k
    const auto take = Lt(fence, stop);
87
73.2k
    const auto val = LoadU(du, values + last_full);
88
73.2k
    const auto is_large = Gt(val, kLargeThreshold);
89
73.2k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
73.2k
    const auto not_literal = Ge(val, kSplit);
91
73.2k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
73.2k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
73.2k
    const auto l = And(val, kMaskL);
94
73.2k
    const auto exp = ShiftRight<23>(b);
95
73.2k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
73.2k
    const auto n = Sub(exp_fixed, kExpOffset);
97
73.2k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
73.2k
    const auto m = ShiftRight<23 - M - L>(b);
99
73.2k
    const auto a = Add(kBase, Mul(n, kMulN));
100
73.2k
    const auto d = And(m, kMaskM);
101
73.2k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
73.2k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
73.2k
    const auto c = Or(a, l);
104
73.2k
    extra_bits = Add(extra_bits, eb_masked);
105
73.2k
    const auto t = Or(c, d);
106
73.2k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
73.2k
    Store(t_fixed, du, out + last_full);
108
73.2k
  }
109
85.3k
  return GetLane(SumOfLanes(du, extra_bits));
110
85.3k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<3ul, 1ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
17.2k
                               uint32_t* JXL_RESTRICT out) {
45
17.2k
  const HWY_FULL(uint32_t) du;
46
17.2k
  const HWY_FULL(float) df;
47
17.2k
  const auto kZero = Zero(du);
48
17.2k
  const auto kSplit = Set(du, 1 << E);
49
17.2k
  const auto kExpOffset = Set(du, 127);
50
17.2k
  const auto kEBOffset = Set(du, 127 + M + L);
51
17.2k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
17.2k
  const auto kMulN = Set(du, 1 << (M + L));
53
17.2k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
17.2k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
17.2k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
17.2k
  constexpr size_t kLargeShiftVal = 10;
57
17.2k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
17.2k
  auto extra_bits = kZero;
60
17.2k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
942k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
925k
    const auto val = LoadU(du, values + i);
63
925k
    const auto is_large = Gt(val, kLargeThreshold);
64
925k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
925k
    const auto not_literal = Ge(val, kSplit);
66
925k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
925k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
925k
    const auto l = And(val, kMaskL);
69
925k
    const auto exp = ShiftRight<23>(b);
70
925k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
925k
    const auto n = Sub(exp_fixed, kExpOffset);
72
925k
    const auto eb = Sub(exp_fixed, kEBOffset);
73
925k
    const auto m = ShiftRight<23 - M - L>(b);
74
925k
    const auto a = Add(kBase, Mul(n, kMulN));
75
925k
    const auto d = And(m, kMaskM);
76
925k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
925k
    const auto c = Or(a, l);
78
925k
    extra_bits = Add(extra_bits, eb_fixed);
79
925k
    const auto t = Or(c, d);
80
925k
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
925k
    Store(t_fixed, du, out + i);
82
925k
  }
83
17.2k
  if (last_full < len) {
84
14.7k
    const auto stop = Set(du, len);
85
14.7k
    const auto fence = Iota(du, last_full);
86
14.7k
    const auto take = Lt(fence, stop);
87
14.7k
    const auto val = LoadU(du, values + last_full);
88
14.7k
    const auto is_large = Gt(val, kLargeThreshold);
89
14.7k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
14.7k
    const auto not_literal = Ge(val, kSplit);
91
14.7k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
14.7k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
14.7k
    const auto l = And(val, kMaskL);
94
14.7k
    const auto exp = ShiftRight<23>(b);
95
14.7k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
14.7k
    const auto n = Sub(exp_fixed, kExpOffset);
97
14.7k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
14.7k
    const auto m = ShiftRight<23 - M - L>(b);
99
14.7k
    const auto a = Add(kBase, Mul(n, kMulN));
100
14.7k
    const auto d = And(m, kMaskM);
101
14.7k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
14.7k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
14.7k
    const auto c = Or(a, l);
104
14.7k
    extra_bits = Add(extra_bits, eb_masked);
105
14.7k
    const auto t = Or(c, d);
106
14.7k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
14.7k
    Store(t_fixed, du, out + last_full);
108
14.7k
  }
109
17.2k
  return GetLane(SumOfLanes(du, extra_bits));
110
17.2k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<3ul, 1ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
17.2k
                               uint32_t* JXL_RESTRICT out) {
45
17.2k
  const HWY_FULL(uint32_t) du;
46
17.2k
  const HWY_FULL(float) df;
47
17.2k
  const auto kZero = Zero(du);
48
17.2k
  const auto kSplit = Set(du, 1 << E);
49
17.2k
  const auto kExpOffset = Set(du, 127);
50
17.2k
  const auto kEBOffset = Set(du, 127 + M + L);
51
17.2k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
17.2k
  const auto kMulN = Set(du, 1 << (M + L));
53
17.2k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
17.2k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
17.2k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
17.2k
  constexpr size_t kLargeShiftVal = 10;
57
17.2k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
17.2k
  auto extra_bits = kZero;
60
17.2k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
942k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
925k
    const auto val = LoadU(du, values + i);
63
925k
    const auto is_large = Gt(val, kLargeThreshold);
64
925k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
925k
    const auto not_literal = Ge(val, kSplit);
66
925k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
925k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
925k
    const auto l = And(val, kMaskL);
69
925k
    const auto exp = ShiftRight<23>(b);
70
925k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
925k
    const auto n = Sub(exp_fixed, kExpOffset);
72
925k
    const auto eb = Sub(exp_fixed, kEBOffset);
73
925k
    const auto m = ShiftRight<23 - M - L>(b);
74
925k
    const auto a = Add(kBase, Mul(n, kMulN));
75
925k
    const auto d = And(m, kMaskM);
76
925k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
925k
    const auto c = Or(a, l);
78
925k
    extra_bits = Add(extra_bits, eb_fixed);
79
925k
    const auto t = Or(c, d);
80
925k
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
925k
    Store(t_fixed, du, out + i);
82
925k
  }
83
17.2k
  if (last_full < len) {
84
14.7k
    const auto stop = Set(du, len);
85
14.7k
    const auto fence = Iota(du, last_full);
86
14.7k
    const auto take = Lt(fence, stop);
87
14.7k
    const auto val = LoadU(du, values + last_full);
88
14.7k
    const auto is_large = Gt(val, kLargeThreshold);
89
14.7k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
14.7k
    const auto not_literal = Ge(val, kSplit);
91
14.7k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
14.7k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
14.7k
    const auto l = And(val, kMaskL);
94
14.7k
    const auto exp = ShiftRight<23>(b);
95
14.7k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
14.7k
    const auto n = Sub(exp_fixed, kExpOffset);
97
14.7k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
14.7k
    const auto m = ShiftRight<23 - M - L>(b);
99
14.7k
    const auto a = Add(kBase, Mul(n, kMulN));
100
14.7k
    const auto d = And(m, kMaskM);
101
14.7k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
14.7k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
14.7k
    const auto c = Or(a, l);
104
14.7k
    extra_bits = Add(extra_bits, eb_masked);
105
14.7k
    const auto t = Or(c, d);
106
14.7k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
14.7k
    Store(t_fixed, du, out + last_full);
108
14.7k
  }
109
17.2k
  return GetLane(SumOfLanes(du, extra_bits));
110
17.2k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<3ul, 2ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
17.2k
                               uint32_t* JXL_RESTRICT out) {
45
17.2k
  const HWY_FULL(uint32_t) du;
46
17.2k
  const HWY_FULL(float) df;
47
17.2k
  const auto kZero = Zero(du);
48
17.2k
  const auto kSplit = Set(du, 1 << E);
49
17.2k
  const auto kExpOffset = Set(du, 127);
50
17.2k
  const auto kEBOffset = Set(du, 127 + M + L);
51
17.2k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
17.2k
  const auto kMulN = Set(du, 1 << (M + L));
53
17.2k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
17.2k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
17.2k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
17.2k
  constexpr size_t kLargeShiftVal = 10;
57
17.2k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
17.2k
  auto extra_bits = kZero;
60
17.2k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
942k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
925k
    const auto val = LoadU(du, values + i);
63
925k
    const auto is_large = Gt(val, kLargeThreshold);
64
925k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
925k
    const auto not_literal = Ge(val, kSplit);
66
925k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
925k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
925k
    const auto l = And(val, kMaskL);
69
925k
    const auto exp = ShiftRight<23>(b);
70
925k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
925k
    const auto n = Sub(exp_fixed, kExpOffset);
72
925k
    const auto eb = Sub(exp_fixed, kEBOffset);
73
925k
    const auto m = ShiftRight<23 - M - L>(b);
74
925k
    const auto a = Add(kBase, Mul(n, kMulN));
75
925k
    const auto d = And(m, kMaskM);
76
925k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
925k
    const auto c = Or(a, l);
78
925k
    extra_bits = Add(extra_bits, eb_fixed);
79
925k
    const auto t = Or(c, d);
80
925k
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
925k
    Store(t_fixed, du, out + i);
82
925k
  }
83
17.2k
  if (last_full < len) {
84
14.7k
    const auto stop = Set(du, len);
85
14.7k
    const auto fence = Iota(du, last_full);
86
14.7k
    const auto take = Lt(fence, stop);
87
14.7k
    const auto val = LoadU(du, values + last_full);
88
14.7k
    const auto is_large = Gt(val, kLargeThreshold);
89
14.7k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
14.7k
    const auto not_literal = Ge(val, kSplit);
91
14.7k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
14.7k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
14.7k
    const auto l = And(val, kMaskL);
94
14.7k
    const auto exp = ShiftRight<23>(b);
95
14.7k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
14.7k
    const auto n = Sub(exp_fixed, kExpOffset);
97
14.7k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
14.7k
    const auto m = ShiftRight<23 - M - L>(b);
99
14.7k
    const auto a = Add(kBase, Mul(n, kMulN));
100
14.7k
    const auto d = And(m, kMaskM);
101
14.7k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
14.7k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
14.7k
    const auto c = Or(a, l);
104
14.7k
    extra_bits = Add(extra_bits, eb_masked);
105
14.7k
    const auto t = Or(c, d);
106
14.7k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
14.7k
    Store(t_fixed, du, out + last_full);
108
14.7k
  }
109
17.2k
  return GetLane(SumOfLanes(du, extra_bits));
110
17.2k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<3ul, 2ul, 1ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
17.2k
                               uint32_t* JXL_RESTRICT out) {
45
17.2k
  const HWY_FULL(uint32_t) du;
46
17.2k
  const HWY_FULL(float) df;
47
17.2k
  const auto kZero = Zero(du);
48
17.2k
  const auto kSplit = Set(du, 1 << E);
49
17.2k
  const auto kExpOffset = Set(du, 127);
50
17.2k
  const auto kEBOffset = Set(du, 127 + M + L);
51
17.2k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
17.2k
  const auto kMulN = Set(du, 1 << (M + L));
53
17.2k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
17.2k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
17.2k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
17.2k
  constexpr size_t kLargeShiftVal = 10;
57
17.2k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
17.2k
  auto extra_bits = kZero;
60
17.2k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
942k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
925k
    const auto val = LoadU(du, values + i);
63
925k
    const auto is_large = Gt(val, kLargeThreshold);
64
925k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
925k
    const auto not_literal = Ge(val, kSplit);
66
925k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
925k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
925k
    const auto l = And(val, kMaskL);
69
925k
    const auto exp = ShiftRight<23>(b);
70
925k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
925k
    const auto n = Sub(exp_fixed, kExpOffset);
72
925k
    const auto eb = Sub(exp_fixed, kEBOffset);
73
925k
    const auto m = ShiftRight<23 - M - L>(b);
74
925k
    const auto a = Add(kBase, Mul(n, kMulN));
75
925k
    const auto d = And(m, kMaskM);
76
925k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
925k
    const auto c = Or(a, l);
78
925k
    extra_bits = Add(extra_bits, eb_fixed);
79
925k
    const auto t = Or(c, d);
80
925k
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
925k
    Store(t_fixed, du, out + i);
82
925k
  }
83
17.2k
  if (last_full < len) {
84
14.7k
    const auto stop = Set(du, len);
85
14.7k
    const auto fence = Iota(du, last_full);
86
14.7k
    const auto take = Lt(fence, stop);
87
14.7k
    const auto val = LoadU(du, values + last_full);
88
14.7k
    const auto is_large = Gt(val, kLargeThreshold);
89
14.7k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
14.7k
    const auto not_literal = Ge(val, kSplit);
91
14.7k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
14.7k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
14.7k
    const auto l = And(val, kMaskL);
94
14.7k
    const auto exp = ShiftRight<23>(b);
95
14.7k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
14.7k
    const auto n = Sub(exp_fixed, kExpOffset);
97
14.7k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
14.7k
    const auto m = ShiftRight<23 - M - L>(b);
99
14.7k
    const auto a = Add(kBase, Mul(n, kMulN));
100
14.7k
    const auto d = And(m, kMaskM);
101
14.7k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
14.7k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
14.7k
    const auto c = Or(a, l);
104
14.7k
    extra_bits = Add(extra_bits, eb_masked);
105
14.7k
    const auto t = Or(c, d);
106
14.7k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
14.7k
    Store(t_fixed, du, out + last_full);
108
14.7k
  }
109
17.2k
  return GetLane(SumOfLanes(du, extra_bits));
110
17.2k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<4ul, 1ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
17.2k
                               uint32_t* JXL_RESTRICT out) {
45
17.2k
  const HWY_FULL(uint32_t) du;
46
17.2k
  const HWY_FULL(float) df;
47
17.2k
  const auto kZero = Zero(du);
48
17.2k
  const auto kSplit = Set(du, 1 << E);
49
17.2k
  const auto kExpOffset = Set(du, 127);
50
17.2k
  const auto kEBOffset = Set(du, 127 + M + L);
51
17.2k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
17.2k
  const auto kMulN = Set(du, 1 << (M + L));
53
17.2k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
17.2k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
17.2k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
17.2k
  constexpr size_t kLargeShiftVal = 10;
57
17.2k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
17.2k
  auto extra_bits = kZero;
60
17.2k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
942k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
925k
    const auto val = LoadU(du, values + i);
63
925k
    const auto is_large = Gt(val, kLargeThreshold);
64
925k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
925k
    const auto not_literal = Ge(val, kSplit);
66
925k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
925k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
925k
    const auto l = And(val, kMaskL);
69
925k
    const auto exp = ShiftRight<23>(b);
70
925k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
925k
    const auto n = Sub(exp_fixed, kExpOffset);
72
925k
    const auto eb = Sub(exp_fixed, kEBOffset);
73
925k
    const auto m = ShiftRight<23 - M - L>(b);
74
925k
    const auto a = Add(kBase, Mul(n, kMulN));
75
925k
    const auto d = And(m, kMaskM);
76
925k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
925k
    const auto c = Or(a, l);
78
925k
    extra_bits = Add(extra_bits, eb_fixed);
79
925k
    const auto t = Or(c, d);
80
925k
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
925k
    Store(t_fixed, du, out + i);
82
925k
  }
83
17.2k
  if (last_full < len) {
84
14.7k
    const auto stop = Set(du, len);
85
14.7k
    const auto fence = Iota(du, last_full);
86
14.7k
    const auto take = Lt(fence, stop);
87
14.7k
    const auto val = LoadU(du, values + last_full);
88
14.7k
    const auto is_large = Gt(val, kLargeThreshold);
89
14.7k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
14.7k
    const auto not_literal = Ge(val, kSplit);
91
14.7k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
14.7k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
14.7k
    const auto l = And(val, kMaskL);
94
14.7k
    const auto exp = ShiftRight<23>(b);
95
14.7k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
14.7k
    const auto n = Sub(exp_fixed, kExpOffset);
97
14.7k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
14.7k
    const auto m = ShiftRight<23 - M - L>(b);
99
14.7k
    const auto a = Add(kBase, Mul(n, kMulN));
100
14.7k
    const auto d = And(m, kMaskM);
101
14.7k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
14.7k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
14.7k
    const auto c = Or(a, l);
104
14.7k
    extra_bits = Add(extra_bits, eb_masked);
105
14.7k
    const auto t = Or(c, d);
106
14.7k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
14.7k
    Store(t_fixed, du, out + last_full);
108
14.7k
  }
109
17.2k
  return GetLane(SumOfLanes(du, extra_bits));
110
17.2k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<4ul, 1ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
85.3k
                               uint32_t* JXL_RESTRICT out) {
45
85.3k
  const HWY_FULL(uint32_t) du;
46
85.3k
  const HWY_FULL(float) df;
47
85.3k
  const auto kZero = Zero(du);
48
85.3k
  const auto kSplit = Set(du, 1 << E);
49
85.3k
  const auto kExpOffset = Set(du, 127);
50
85.3k
  const auto kEBOffset = Set(du, 127 + M + L);
51
85.3k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
85.3k
  const auto kMulN = Set(du, 1 << (M + L));
53
85.3k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
85.3k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
85.3k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
85.3k
  constexpr size_t kLargeShiftVal = 10;
57
85.3k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
85.3k
  auto extra_bits = kZero;
60
85.3k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
7.46M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
7.38M
    const auto val = LoadU(du, values + i);
63
7.38M
    const auto is_large = Gt(val, kLargeThreshold);
64
7.38M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
7.38M
    const auto not_literal = Ge(val, kSplit);
66
7.38M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
7.38M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
7.38M
    const auto l = And(val, kMaskL);
69
7.38M
    const auto exp = ShiftRight<23>(b);
70
7.38M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
7.38M
    const auto n = Sub(exp_fixed, kExpOffset);
72
7.38M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
7.38M
    const auto m = ShiftRight<23 - M - L>(b);
74
7.38M
    const auto a = Add(kBase, Mul(n, kMulN));
75
7.38M
    const auto d = And(m, kMaskM);
76
7.38M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
7.38M
    const auto c = Or(a, l);
78
7.38M
    extra_bits = Add(extra_bits, eb_fixed);
79
7.38M
    const auto t = Or(c, d);
80
7.38M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
7.38M
    Store(t_fixed, du, out + i);
82
7.38M
  }
83
85.3k
  if (last_full < len) {
84
73.2k
    const auto stop = Set(du, len);
85
73.2k
    const auto fence = Iota(du, last_full);
86
73.2k
    const auto take = Lt(fence, stop);
87
73.2k
    const auto val = LoadU(du, values + last_full);
88
73.2k
    const auto is_large = Gt(val, kLargeThreshold);
89
73.2k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
73.2k
    const auto not_literal = Ge(val, kSplit);
91
73.2k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
73.2k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
73.2k
    const auto l = And(val, kMaskL);
94
73.2k
    const auto exp = ShiftRight<23>(b);
95
73.2k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
73.2k
    const auto n = Sub(exp_fixed, kExpOffset);
97
73.2k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
73.2k
    const auto m = ShiftRight<23 - M - L>(b);
99
73.2k
    const auto a = Add(kBase, Mul(n, kMulN));
100
73.2k
    const auto d = And(m, kMaskM);
101
73.2k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
73.2k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
73.2k
    const auto c = Or(a, l);
104
73.2k
    extra_bits = Add(extra_bits, eb_masked);
105
73.2k
    const auto t = Or(c, d);
106
73.2k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
73.2k
    Store(t_fixed, du, out + last_full);
108
73.2k
  }
109
85.3k
  return GetLane(SumOfLanes(du, extra_bits));
110
85.3k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<4ul, 1ul, 3ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
17.2k
                               uint32_t* JXL_RESTRICT out) {
45
17.2k
  const HWY_FULL(uint32_t) du;
46
17.2k
  const HWY_FULL(float) df;
47
17.2k
  const auto kZero = Zero(du);
48
17.2k
  const auto kSplit = Set(du, 1 << E);
49
17.2k
  const auto kExpOffset = Set(du, 127);
50
17.2k
  const auto kEBOffset = Set(du, 127 + M + L);
51
17.2k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
17.2k
  const auto kMulN = Set(du, 1 << (M + L));
53
17.2k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
17.2k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
17.2k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
17.2k
  constexpr size_t kLargeShiftVal = 10;
57
17.2k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
17.2k
  auto extra_bits = kZero;
60
17.2k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
942k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
925k
    const auto val = LoadU(du, values + i);
63
925k
    const auto is_large = Gt(val, kLargeThreshold);
64
925k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
925k
    const auto not_literal = Ge(val, kSplit);
66
925k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
925k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
925k
    const auto l = And(val, kMaskL);
69
925k
    const auto exp = ShiftRight<23>(b);
70
925k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
925k
    const auto n = Sub(exp_fixed, kExpOffset);
72
925k
    const auto eb = Sub(exp_fixed, kEBOffset);
73
925k
    const auto m = ShiftRight<23 - M - L>(b);
74
925k
    const auto a = Add(kBase, Mul(n, kMulN));
75
925k
    const auto d = And(m, kMaskM);
76
925k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
925k
    const auto c = Or(a, l);
78
925k
    extra_bits = Add(extra_bits, eb_fixed);
79
925k
    const auto t = Or(c, d);
80
925k
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
925k
    Store(t_fixed, du, out + i);
82
925k
  }
83
17.2k
  if (last_full < len) {
84
14.7k
    const auto stop = Set(du, len);
85
14.7k
    const auto fence = Iota(du, last_full);
86
14.7k
    const auto take = Lt(fence, stop);
87
14.7k
    const auto val = LoadU(du, values + last_full);
88
14.7k
    const auto is_large = Gt(val, kLargeThreshold);
89
14.7k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
14.7k
    const auto not_literal = Ge(val, kSplit);
91
14.7k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
14.7k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
14.7k
    const auto l = And(val, kMaskL);
94
14.7k
    const auto exp = ShiftRight<23>(b);
95
14.7k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
14.7k
    const auto n = Sub(exp_fixed, kExpOffset);
97
14.7k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
14.7k
    const auto m = ShiftRight<23 - M - L>(b);
99
14.7k
    const auto a = Add(kBase, Mul(n, kMulN));
100
14.7k
    const auto d = And(m, kMaskM);
101
14.7k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
14.7k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
14.7k
    const auto c = Or(a, l);
104
14.7k
    extra_bits = Add(extra_bits, eb_masked);
105
14.7k
    const auto t = Or(c, d);
106
14.7k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
14.7k
    Store(t_fixed, du, out + last_full);
108
14.7k
  }
109
17.2k
  return GetLane(SumOfLanes(du, extra_bits));
110
17.2k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<4ul, 2ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
85.3k
                               uint32_t* JXL_RESTRICT out) {
45
85.3k
  const HWY_FULL(uint32_t) du;
46
85.3k
  const HWY_FULL(float) df;
47
85.3k
  const auto kZero = Zero(du);
48
85.3k
  const auto kSplit = Set(du, 1 << E);
49
85.3k
  const auto kExpOffset = Set(du, 127);
50
85.3k
  const auto kEBOffset = Set(du, 127 + M + L);
51
85.3k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
85.3k
  const auto kMulN = Set(du, 1 << (M + L));
53
85.3k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
85.3k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
85.3k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
85.3k
  constexpr size_t kLargeShiftVal = 10;
57
85.3k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
85.3k
  auto extra_bits = kZero;
60
85.3k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
7.46M
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
7.38M
    const auto val = LoadU(du, values + i);
63
7.38M
    const auto is_large = Gt(val, kLargeThreshold);
64
7.38M
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
7.38M
    const auto not_literal = Ge(val, kSplit);
66
7.38M
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
7.38M
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
7.38M
    const auto l = And(val, kMaskL);
69
7.38M
    const auto exp = ShiftRight<23>(b);
70
7.38M
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
7.38M
    const auto n = Sub(exp_fixed, kExpOffset);
72
7.38M
    const auto eb = Sub(exp_fixed, kEBOffset);
73
7.38M
    const auto m = ShiftRight<23 - M - L>(b);
74
7.38M
    const auto a = Add(kBase, Mul(n, kMulN));
75
7.38M
    const auto d = And(m, kMaskM);
76
7.38M
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
7.38M
    const auto c = Or(a, l);
78
7.38M
    extra_bits = Add(extra_bits, eb_fixed);
79
7.38M
    const auto t = Or(c, d);
80
7.38M
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
7.38M
    Store(t_fixed, du, out + i);
82
7.38M
  }
83
85.3k
  if (last_full < len) {
84
73.2k
    const auto stop = Set(du, len);
85
73.2k
    const auto fence = Iota(du, last_full);
86
73.2k
    const auto take = Lt(fence, stop);
87
73.2k
    const auto val = LoadU(du, values + last_full);
88
73.2k
    const auto is_large = Gt(val, kLargeThreshold);
89
73.2k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
73.2k
    const auto not_literal = Ge(val, kSplit);
91
73.2k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
73.2k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
73.2k
    const auto l = And(val, kMaskL);
94
73.2k
    const auto exp = ShiftRight<23>(b);
95
73.2k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
73.2k
    const auto n = Sub(exp_fixed, kExpOffset);
97
73.2k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
73.2k
    const auto m = ShiftRight<23 - M - L>(b);
99
73.2k
    const auto a = Add(kBase, Mul(n, kMulN));
100
73.2k
    const auto d = And(m, kMaskM);
101
73.2k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
73.2k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
73.2k
    const auto c = Or(a, l);
104
73.2k
    extra_bits = Add(extra_bits, eb_masked);
105
73.2k
    const auto t = Or(c, d);
106
73.2k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
73.2k
    Store(t_fixed, du, out + last_full);
108
73.2k
  }
109
85.3k
  return GetLane(SumOfLanes(du, extra_bits));
110
85.3k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<4ul, 2ul, 1ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
17.2k
                               uint32_t* JXL_RESTRICT out) {
45
17.2k
  const HWY_FULL(uint32_t) du;
46
17.2k
  const HWY_FULL(float) df;
47
17.2k
  const auto kZero = Zero(du);
48
17.2k
  const auto kSplit = Set(du, 1 << E);
49
17.2k
  const auto kExpOffset = Set(du, 127);
50
17.2k
  const auto kEBOffset = Set(du, 127 + M + L);
51
17.2k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
17.2k
  const auto kMulN = Set(du, 1 << (M + L));
53
17.2k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
17.2k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
17.2k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
17.2k
  constexpr size_t kLargeShiftVal = 10;
57
17.2k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
17.2k
  auto extra_bits = kZero;
60
17.2k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
942k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
925k
    const auto val = LoadU(du, values + i);
63
925k
    const auto is_large = Gt(val, kLargeThreshold);
64
925k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
925k
    const auto not_literal = Ge(val, kSplit);
66
925k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
925k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
925k
    const auto l = And(val, kMaskL);
69
925k
    const auto exp = ShiftRight<23>(b);
70
925k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
925k
    const auto n = Sub(exp_fixed, kExpOffset);
72
925k
    const auto eb = Sub(exp_fixed, kEBOffset);
73
925k
    const auto m = ShiftRight<23 - M - L>(b);
74
925k
    const auto a = Add(kBase, Mul(n, kMulN));
75
925k
    const auto d = And(m, kMaskM);
76
925k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
925k
    const auto c = Or(a, l);
78
925k
    extra_bits = Add(extra_bits, eb_fixed);
79
925k
    const auto t = Or(c, d);
80
925k
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
925k
    Store(t_fixed, du, out + i);
82
925k
  }
83
17.2k
  if (last_full < len) {
84
14.7k
    const auto stop = Set(du, len);
85
14.7k
    const auto fence = Iota(du, last_full);
86
14.7k
    const auto take = Lt(fence, stop);
87
14.7k
    const auto val = LoadU(du, values + last_full);
88
14.7k
    const auto is_large = Gt(val, kLargeThreshold);
89
14.7k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
14.7k
    const auto not_literal = Ge(val, kSplit);
91
14.7k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
14.7k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
14.7k
    const auto l = And(val, kMaskL);
94
14.7k
    const auto exp = ShiftRight<23>(b);
95
14.7k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
14.7k
    const auto n = Sub(exp_fixed, kExpOffset);
97
14.7k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
14.7k
    const auto m = ShiftRight<23 - M - L>(b);
99
14.7k
    const auto a = Add(kBase, Mul(n, kMulN));
100
14.7k
    const auto d = And(m, kMaskM);
101
14.7k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
14.7k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
14.7k
    const auto c = Or(a, l);
104
14.7k
    extra_bits = Add(extra_bits, eb_masked);
105
14.7k
    const auto t = Or(c, d);
106
14.7k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
14.7k
    Store(t_fixed, du, out + last_full);
108
14.7k
  }
109
17.2k
  return GetLane(SumOfLanes(du, extra_bits));
110
17.2k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<4ul, 2ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
17.2k
                               uint32_t* JXL_RESTRICT out) {
45
17.2k
  const HWY_FULL(uint32_t) du;
46
17.2k
  const HWY_FULL(float) df;
47
17.2k
  const auto kZero = Zero(du);
48
17.2k
  const auto kSplit = Set(du, 1 << E);
49
17.2k
  const auto kExpOffset = Set(du, 127);
50
17.2k
  const auto kEBOffset = Set(du, 127 + M + L);
51
17.2k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
17.2k
  const auto kMulN = Set(du, 1 << (M + L));
53
17.2k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
17.2k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
17.2k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
17.2k
  constexpr size_t kLargeShiftVal = 10;
57
17.2k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
17.2k
  auto extra_bits = kZero;
60
17.2k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
942k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
925k
    const auto val = LoadU(du, values + i);
63
925k
    const auto is_large = Gt(val, kLargeThreshold);
64
925k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
925k
    const auto not_literal = Ge(val, kSplit);
66
925k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
925k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
925k
    const auto l = And(val, kMaskL);
69
925k
    const auto exp = ShiftRight<23>(b);
70
925k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
925k
    const auto n = Sub(exp_fixed, kExpOffset);
72
925k
    const auto eb = Sub(exp_fixed, kEBOffset);
73
925k
    const auto m = ShiftRight<23 - M - L>(b);
74
925k
    const auto a = Add(kBase, Mul(n, kMulN));
75
925k
    const auto d = And(m, kMaskM);
76
925k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
925k
    const auto c = Or(a, l);
78
925k
    extra_bits = Add(extra_bits, eb_fixed);
79
925k
    const auto t = Or(c, d);
80
925k
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
925k
    Store(t_fixed, du, out + i);
82
925k
  }
83
17.2k
  if (last_full < len) {
84
14.7k
    const auto stop = Set(du, len);
85
14.7k
    const auto fence = Iota(du, last_full);
86
14.7k
    const auto take = Lt(fence, stop);
87
14.7k
    const auto val = LoadU(du, values + last_full);
88
14.7k
    const auto is_large = Gt(val, kLargeThreshold);
89
14.7k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
14.7k
    const auto not_literal = Ge(val, kSplit);
91
14.7k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
14.7k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
14.7k
    const auto l = And(val, kMaskL);
94
14.7k
    const auto exp = ShiftRight<23>(b);
95
14.7k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
14.7k
    const auto n = Sub(exp_fixed, kExpOffset);
97
14.7k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
14.7k
    const auto m = ShiftRight<23 - M - L>(b);
99
14.7k
    const auto a = Add(kBase, Mul(n, kMulN));
100
14.7k
    const auto d = And(m, kMaskM);
101
14.7k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
14.7k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
14.7k
    const auto c = Or(a, l);
104
14.7k
    extra_bits = Add(extra_bits, eb_masked);
105
14.7k
    const auto t = Or(c, d);
106
14.7k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
14.7k
    Store(t_fixed, du, out + last_full);
108
14.7k
  }
109
17.2k
  return GetLane(SumOfLanes(du, extra_bits));
110
17.2k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<5ul, 1ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
17.2k
                               uint32_t* JXL_RESTRICT out) {
45
17.2k
  const HWY_FULL(uint32_t) du;
46
17.2k
  const HWY_FULL(float) df;
47
17.2k
  const auto kZero = Zero(du);
48
17.2k
  const auto kSplit = Set(du, 1 << E);
49
17.2k
  const auto kExpOffset = Set(du, 127);
50
17.2k
  const auto kEBOffset = Set(du, 127 + M + L);
51
17.2k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
17.2k
  const auto kMulN = Set(du, 1 << (M + L));
53
17.2k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
17.2k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
17.2k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
17.2k
  constexpr size_t kLargeShiftVal = 10;
57
17.2k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
17.2k
  auto extra_bits = kZero;
60
17.2k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
942k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
925k
    const auto val = LoadU(du, values + i);
63
925k
    const auto is_large = Gt(val, kLargeThreshold);
64
925k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
925k
    const auto not_literal = Ge(val, kSplit);
66
925k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
925k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
925k
    const auto l = And(val, kMaskL);
69
925k
    const auto exp = ShiftRight<23>(b);
70
925k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
925k
    const auto n = Sub(exp_fixed, kExpOffset);
72
925k
    const auto eb = Sub(exp_fixed, kEBOffset);
73
925k
    const auto m = ShiftRight<23 - M - L>(b);
74
925k
    const auto a = Add(kBase, Mul(n, kMulN));
75
925k
    const auto d = And(m, kMaskM);
76
925k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
925k
    const auto c = Or(a, l);
78
925k
    extra_bits = Add(extra_bits, eb_fixed);
79
925k
    const auto t = Or(c, d);
80
925k
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
925k
    Store(t_fixed, du, out + i);
82
925k
  }
83
17.2k
  if (last_full < len) {
84
14.7k
    const auto stop = Set(du, len);
85
14.7k
    const auto fence = Iota(du, last_full);
86
14.7k
    const auto take = Lt(fence, stop);
87
14.7k
    const auto val = LoadU(du, values + last_full);
88
14.7k
    const auto is_large = Gt(val, kLargeThreshold);
89
14.7k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
14.7k
    const auto not_literal = Ge(val, kSplit);
91
14.7k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
14.7k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
14.7k
    const auto l = And(val, kMaskL);
94
14.7k
    const auto exp = ShiftRight<23>(b);
95
14.7k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
14.7k
    const auto n = Sub(exp_fixed, kExpOffset);
97
14.7k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
14.7k
    const auto m = ShiftRight<23 - M - L>(b);
99
14.7k
    const auto a = Add(kBase, Mul(n, kMulN));
100
14.7k
    const auto d = And(m, kMaskM);
101
14.7k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
14.7k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
14.7k
    const auto c = Or(a, l);
104
14.7k
    extra_bits = Add(extra_bits, eb_masked);
105
14.7k
    const auto t = Or(c, d);
106
14.7k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
14.7k
    Store(t_fixed, du, out + last_full);
108
14.7k
  }
109
17.2k
  return GetLane(SumOfLanes(du, extra_bits));
110
17.2k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<5ul, 1ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
17.2k
                               uint32_t* JXL_RESTRICT out) {
45
17.2k
  const HWY_FULL(uint32_t) du;
46
17.2k
  const HWY_FULL(float) df;
47
17.2k
  const auto kZero = Zero(du);
48
17.2k
  const auto kSplit = Set(du, 1 << E);
49
17.2k
  const auto kExpOffset = Set(du, 127);
50
17.2k
  const auto kEBOffset = Set(du, 127 + M + L);
51
17.2k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
17.2k
  const auto kMulN = Set(du, 1 << (M + L));
53
17.2k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
17.2k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
17.2k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
17.2k
  constexpr size_t kLargeShiftVal = 10;
57
17.2k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
17.2k
  auto extra_bits = kZero;
60
17.2k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
942k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
925k
    const auto val = LoadU(du, values + i);
63
925k
    const auto is_large = Gt(val, kLargeThreshold);
64
925k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
925k
    const auto not_literal = Ge(val, kSplit);
66
925k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
925k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
925k
    const auto l = And(val, kMaskL);
69
925k
    const auto exp = ShiftRight<23>(b);
70
925k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
925k
    const auto n = Sub(exp_fixed, kExpOffset);
72
925k
    const auto eb = Sub(exp_fixed, kEBOffset);
73
925k
    const auto m = ShiftRight<23 - M - L>(b);
74
925k
    const auto a = Add(kBase, Mul(n, kMulN));
75
925k
    const auto d = And(m, kMaskM);
76
925k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
925k
    const auto c = Or(a, l);
78
925k
    extra_bits = Add(extra_bits, eb_fixed);
79
925k
    const auto t = Or(c, d);
80
925k
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
925k
    Store(t_fixed, du, out + i);
82
925k
  }
83
17.2k
  if (last_full < len) {
84
14.7k
    const auto stop = Set(du, len);
85
14.7k
    const auto fence = Iota(du, last_full);
86
14.7k
    const auto take = Lt(fence, stop);
87
14.7k
    const auto val = LoadU(du, values + last_full);
88
14.7k
    const auto is_large = Gt(val, kLargeThreshold);
89
14.7k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
14.7k
    const auto not_literal = Ge(val, kSplit);
91
14.7k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
14.7k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
14.7k
    const auto l = And(val, kMaskL);
94
14.7k
    const auto exp = ShiftRight<23>(b);
95
14.7k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
14.7k
    const auto n = Sub(exp_fixed, kExpOffset);
97
14.7k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
14.7k
    const auto m = ShiftRight<23 - M - L>(b);
99
14.7k
    const auto a = Add(kBase, Mul(n, kMulN));
100
14.7k
    const auto d = And(m, kMaskM);
101
14.7k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
14.7k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
14.7k
    const auto c = Or(a, l);
104
14.7k
    extra_bits = Add(extra_bits, eb_masked);
105
14.7k
    const auto t = Or(c, d);
106
14.7k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
14.7k
    Store(t_fixed, du, out + last_full);
108
14.7k
  }
109
17.2k
  return GetLane(SumOfLanes(du, extra_bits));
110
17.2k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<5ul, 1ul, 4ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
17.2k
                               uint32_t* JXL_RESTRICT out) {
45
17.2k
  const HWY_FULL(uint32_t) du;
46
17.2k
  const HWY_FULL(float) df;
47
17.2k
  const auto kZero = Zero(du);
48
17.2k
  const auto kSplit = Set(du, 1 << E);
49
17.2k
  const auto kExpOffset = Set(du, 127);
50
17.2k
  const auto kEBOffset = Set(du, 127 + M + L);
51
17.2k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
17.2k
  const auto kMulN = Set(du, 1 << (M + L));
53
17.2k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
17.2k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
17.2k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
17.2k
  constexpr size_t kLargeShiftVal = 10;
57
17.2k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
17.2k
  auto extra_bits = kZero;
60
17.2k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
941k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
924k
    const auto val = LoadU(du, values + i);
63
924k
    const auto is_large = Gt(val, kLargeThreshold);
64
924k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
924k
    const auto not_literal = Ge(val, kSplit);
66
924k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
924k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
924k
    const auto l = And(val, kMaskL);
69
924k
    const auto exp = ShiftRight<23>(b);
70
924k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
924k
    const auto n = Sub(exp_fixed, kExpOffset);
72
924k
    const auto eb = Sub(exp_fixed, kEBOffset);
73
924k
    const auto m = ShiftRight<23 - M - L>(b);
74
924k
    const auto a = Add(kBase, Mul(n, kMulN));
75
924k
    const auto d = And(m, kMaskM);
76
924k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
924k
    const auto c = Or(a, l);
78
924k
    extra_bits = Add(extra_bits, eb_fixed);
79
924k
    const auto t = Or(c, d);
80
924k
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
924k
    Store(t_fixed, du, out + i);
82
924k
  }
83
17.2k
  if (last_full < len) {
84
14.7k
    const auto stop = Set(du, len);
85
14.7k
    const auto fence = Iota(du, last_full);
86
14.7k
    const auto take = Lt(fence, stop);
87
14.7k
    const auto val = LoadU(du, values + last_full);
88
14.7k
    const auto is_large = Gt(val, kLargeThreshold);
89
14.7k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
14.7k
    const auto not_literal = Ge(val, kSplit);
91
14.7k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
14.7k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
14.7k
    const auto l = And(val, kMaskL);
94
14.7k
    const auto exp = ShiftRight<23>(b);
95
14.7k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
14.7k
    const auto n = Sub(exp_fixed, kExpOffset);
97
14.7k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
14.7k
    const auto m = ShiftRight<23 - M - L>(b);
99
14.7k
    const auto a = Add(kBase, Mul(n, kMulN));
100
14.7k
    const auto d = And(m, kMaskM);
101
14.7k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
14.7k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
14.7k
    const auto c = Or(a, l);
104
14.7k
    extra_bits = Add(extra_bits, eb_masked);
105
14.7k
    const auto t = Or(c, d);
106
14.7k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
14.7k
    Store(t_fixed, du, out + last_full);
108
14.7k
  }
109
17.2k
  return GetLane(SumOfLanes(du, extra_bits));
110
17.2k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<5ul, 2ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
17.2k
                               uint32_t* JXL_RESTRICT out) {
45
17.2k
  const HWY_FULL(uint32_t) du;
46
17.2k
  const HWY_FULL(float) df;
47
17.2k
  const auto kZero = Zero(du);
48
17.2k
  const auto kSplit = Set(du, 1 << E);
49
17.2k
  const auto kExpOffset = Set(du, 127);
50
17.2k
  const auto kEBOffset = Set(du, 127 + M + L);
51
17.2k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
17.2k
  const auto kMulN = Set(du, 1 << (M + L));
53
17.2k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
17.2k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
17.2k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
17.2k
  constexpr size_t kLargeShiftVal = 10;
57
17.2k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
17.2k
  auto extra_bits = kZero;
60
17.2k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
942k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
925k
    const auto val = LoadU(du, values + i);
63
925k
    const auto is_large = Gt(val, kLargeThreshold);
64
925k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
925k
    const auto not_literal = Ge(val, kSplit);
66
925k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
925k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
925k
    const auto l = And(val, kMaskL);
69
925k
    const auto exp = ShiftRight<23>(b);
70
925k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
925k
    const auto n = Sub(exp_fixed, kExpOffset);
72
925k
    const auto eb = Sub(exp_fixed, kEBOffset);
73
925k
    const auto m = ShiftRight<23 - M - L>(b);
74
925k
    const auto a = Add(kBase, Mul(n, kMulN));
75
925k
    const auto d = And(m, kMaskM);
76
925k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
925k
    const auto c = Or(a, l);
78
925k
    extra_bits = Add(extra_bits, eb_fixed);
79
925k
    const auto t = Or(c, d);
80
925k
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
925k
    Store(t_fixed, du, out + i);
82
925k
  }
83
17.2k
  if (last_full < len) {
84
14.7k
    const auto stop = Set(du, len);
85
14.7k
    const auto fence = Iota(du, last_full);
86
14.7k
    const auto take = Lt(fence, stop);
87
14.7k
    const auto val = LoadU(du, values + last_full);
88
14.7k
    const auto is_large = Gt(val, kLargeThreshold);
89
14.7k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
14.7k
    const auto not_literal = Ge(val, kSplit);
91
14.7k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
14.7k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
14.7k
    const auto l = And(val, kMaskL);
94
14.7k
    const auto exp = ShiftRight<23>(b);
95
14.7k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
14.7k
    const auto n = Sub(exp_fixed, kExpOffset);
97
14.7k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
14.7k
    const auto m = ShiftRight<23 - M - L>(b);
99
14.7k
    const auto a = Add(kBase, Mul(n, kMulN));
100
14.7k
    const auto d = And(m, kMaskM);
101
14.7k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
14.7k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
14.7k
    const auto c = Or(a, l);
104
14.7k
    extra_bits = Add(extra_bits, eb_masked);
105
14.7k
    const auto t = Or(c, d);
106
14.7k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
14.7k
    Store(t_fixed, du, out + last_full);
108
14.7k
  }
109
17.2k
  return GetLane(SumOfLanes(du, extra_bits));
110
17.2k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<5ul, 2ul, 1ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
17.2k
                               uint32_t* JXL_RESTRICT out) {
45
17.2k
  const HWY_FULL(uint32_t) du;
46
17.2k
  const HWY_FULL(float) df;
47
17.2k
  const auto kZero = Zero(du);
48
17.2k
  const auto kSplit = Set(du, 1 << E);
49
17.2k
  const auto kExpOffset = Set(du, 127);
50
17.2k
  const auto kEBOffset = Set(du, 127 + M + L);
51
17.2k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
17.2k
  const auto kMulN = Set(du, 1 << (M + L));
53
17.2k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
17.2k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
17.2k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
17.2k
  constexpr size_t kLargeShiftVal = 10;
57
17.2k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
17.2k
  auto extra_bits = kZero;
60
17.2k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
942k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
925k
    const auto val = LoadU(du, values + i);
63
925k
    const auto is_large = Gt(val, kLargeThreshold);
64
925k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
925k
    const auto not_literal = Ge(val, kSplit);
66
925k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
925k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
925k
    const auto l = And(val, kMaskL);
69
925k
    const auto exp = ShiftRight<23>(b);
70
925k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
925k
    const auto n = Sub(exp_fixed, kExpOffset);
72
925k
    const auto eb = Sub(exp_fixed, kEBOffset);
73
925k
    const auto m = ShiftRight<23 - M - L>(b);
74
925k
    const auto a = Add(kBase, Mul(n, kMulN));
75
925k
    const auto d = And(m, kMaskM);
76
925k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
925k
    const auto c = Or(a, l);
78
925k
    extra_bits = Add(extra_bits, eb_fixed);
79
925k
    const auto t = Or(c, d);
80
925k
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
925k
    Store(t_fixed, du, out + i);
82
925k
  }
83
17.2k
  if (last_full < len) {
84
14.7k
    const auto stop = Set(du, len);
85
14.7k
    const auto fence = Iota(du, last_full);
86
14.7k
    const auto take = Lt(fence, stop);
87
14.7k
    const auto val = LoadU(du, values + last_full);
88
14.7k
    const auto is_large = Gt(val, kLargeThreshold);
89
14.7k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
14.7k
    const auto not_literal = Ge(val, kSplit);
91
14.7k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
14.7k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
14.7k
    const auto l = And(val, kMaskL);
94
14.7k
    const auto exp = ShiftRight<23>(b);
95
14.7k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
14.7k
    const auto n = Sub(exp_fixed, kExpOffset);
97
14.7k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
14.7k
    const auto m = ShiftRight<23 - M - L>(b);
99
14.7k
    const auto a = Add(kBase, Mul(n, kMulN));
100
14.7k
    const auto d = And(m, kMaskM);
101
14.7k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
14.7k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
14.7k
    const auto c = Or(a, l);
104
14.7k
    extra_bits = Add(extra_bits, eb_masked);
105
14.7k
    const auto t = Or(c, d);
106
14.7k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
14.7k
    Store(t_fixed, du, out + last_full);
108
14.7k
  }
109
17.2k
  return GetLane(SumOfLanes(du, extra_bits));
110
17.2k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<5ul, 2ul, 2ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
17.2k
                               uint32_t* JXL_RESTRICT out) {
45
17.2k
  const HWY_FULL(uint32_t) du;
46
17.2k
  const HWY_FULL(float) df;
47
17.2k
  const auto kZero = Zero(du);
48
17.2k
  const auto kSplit = Set(du, 1 << E);
49
17.2k
  const auto kExpOffset = Set(du, 127);
50
17.2k
  const auto kEBOffset = Set(du, 127 + M + L);
51
17.2k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
17.2k
  const auto kMulN = Set(du, 1 << (M + L));
53
17.2k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
17.2k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
17.2k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
17.2k
  constexpr size_t kLargeShiftVal = 10;
57
17.2k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
17.2k
  auto extra_bits = kZero;
60
17.2k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
942k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
925k
    const auto val = LoadU(du, values + i);
63
925k
    const auto is_large = Gt(val, kLargeThreshold);
64
925k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
925k
    const auto not_literal = Ge(val, kSplit);
66
925k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
925k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
925k
    const auto l = And(val, kMaskL);
69
925k
    const auto exp = ShiftRight<23>(b);
70
925k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
925k
    const auto n = Sub(exp_fixed, kExpOffset);
72
925k
    const auto eb = Sub(exp_fixed, kEBOffset);
73
925k
    const auto m = ShiftRight<23 - M - L>(b);
74
925k
    const auto a = Add(kBase, Mul(n, kMulN));
75
925k
    const auto d = And(m, kMaskM);
76
925k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
925k
    const auto c = Or(a, l);
78
925k
    extra_bits = Add(extra_bits, eb_fixed);
79
925k
    const auto t = Or(c, d);
80
925k
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
925k
    Store(t_fixed, du, out + i);
82
925k
  }
83
17.2k
  if (last_full < len) {
84
14.7k
    const auto stop = Set(du, len);
85
14.7k
    const auto fence = Iota(du, last_full);
86
14.7k
    const auto take = Lt(fence, stop);
87
14.7k
    const auto val = LoadU(du, values + last_full);
88
14.7k
    const auto is_large = Gt(val, kLargeThreshold);
89
14.7k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
14.7k
    const auto not_literal = Ge(val, kSplit);
91
14.7k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
14.7k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
14.7k
    const auto l = And(val, kMaskL);
94
14.7k
    const auto exp = ShiftRight<23>(b);
95
14.7k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
14.7k
    const auto n = Sub(exp_fixed, kExpOffset);
97
14.7k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
14.7k
    const auto m = ShiftRight<23 - M - L>(b);
99
14.7k
    const auto a = Add(kBase, Mul(n, kMulN));
100
14.7k
    const auto d = And(m, kMaskM);
101
14.7k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
14.7k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
14.7k
    const auto c = Or(a, l);
104
14.7k
    extra_bits = Add(extra_bits, eb_masked);
105
14.7k
    const auto t = Or(c, d);
106
14.7k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
14.7k
    Store(t_fixed, du, out + last_full);
108
14.7k
  }
109
17.2k
  return GetLane(SumOfLanes(du, extra_bits));
110
17.2k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<5ul, 2ul, 3ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
17.2k
                               uint32_t* JXL_RESTRICT out) {
45
17.2k
  const HWY_FULL(uint32_t) du;
46
17.2k
  const HWY_FULL(float) df;
47
17.2k
  const auto kZero = Zero(du);
48
17.2k
  const auto kSplit = Set(du, 1 << E);
49
17.2k
  const auto kExpOffset = Set(du, 127);
50
17.2k
  const auto kEBOffset = Set(du, 127 + M + L);
51
17.2k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
17.2k
  const auto kMulN = Set(du, 1 << (M + L));
53
17.2k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
17.2k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
17.2k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
17.2k
  constexpr size_t kLargeShiftVal = 10;
57
17.2k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
17.2k
  auto extra_bits = kZero;
60
17.2k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
941k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
924k
    const auto val = LoadU(du, values + i);
63
924k
    const auto is_large = Gt(val, kLargeThreshold);
64
924k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
924k
    const auto not_literal = Ge(val, kSplit);
66
924k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
924k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
924k
    const auto l = And(val, kMaskL);
69
924k
    const auto exp = ShiftRight<23>(b);
70
924k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
924k
    const auto n = Sub(exp_fixed, kExpOffset);
72
924k
    const auto eb = Sub(exp_fixed, kEBOffset);
73
924k
    const auto m = ShiftRight<23 - M - L>(b);
74
924k
    const auto a = Add(kBase, Mul(n, kMulN));
75
924k
    const auto d = And(m, kMaskM);
76
924k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
924k
    const auto c = Or(a, l);
78
924k
    extra_bits = Add(extra_bits, eb_fixed);
79
924k
    const auto t = Or(c, d);
80
924k
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
924k
    Store(t_fixed, du, out + i);
82
924k
  }
83
17.2k
  if (last_full < len) {
84
14.7k
    const auto stop = Set(du, len);
85
14.7k
    const auto fence = Iota(du, last_full);
86
14.7k
    const auto take = Lt(fence, stop);
87
14.7k
    const auto val = LoadU(du, values + last_full);
88
14.7k
    const auto is_large = Gt(val, kLargeThreshold);
89
14.7k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
14.7k
    const auto not_literal = Ge(val, kSplit);
91
14.7k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
14.7k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
14.7k
    const auto l = And(val, kMaskL);
94
14.7k
    const auto exp = ShiftRight<23>(b);
95
14.7k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
14.7k
    const auto n = Sub(exp_fixed, kExpOffset);
97
14.7k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
14.7k
    const auto m = ShiftRight<23 - M - L>(b);
99
14.7k
    const auto a = Add(kBase, Mul(n, kMulN));
100
14.7k
    const auto d = And(m, kMaskM);
101
14.7k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
14.7k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
14.7k
    const auto c = Or(a, l);
104
14.7k
    extra_bits = Add(extra_bits, eb_masked);
105
14.7k
    const auto t = Or(c, d);
106
14.7k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
14.7k
    Store(t_fixed, du, out + last_full);
108
14.7k
  }
109
17.2k
  return GetLane(SumOfLanes(du, extra_bits));
110
17.2k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<6ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
17.2k
                               uint32_t* JXL_RESTRICT out) {
45
17.2k
  const HWY_FULL(uint32_t) du;
46
17.2k
  const HWY_FULL(float) df;
47
17.2k
  const auto kZero = Zero(du);
48
17.2k
  const auto kSplit = Set(du, 1 << E);
49
17.2k
  const auto kExpOffset = Set(du, 127);
50
17.2k
  const auto kEBOffset = Set(du, 127 + M + L);
51
17.2k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
17.2k
  const auto kMulN = Set(du, 1 << (M + L));
53
17.2k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
17.2k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
17.2k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
17.2k
  constexpr size_t kLargeShiftVal = 10;
57
17.2k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
17.2k
  auto extra_bits = kZero;
60
17.2k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
942k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
925k
    const auto val = LoadU(du, values + i);
63
925k
    const auto is_large = Gt(val, kLargeThreshold);
64
925k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
925k
    const auto not_literal = Ge(val, kSplit);
66
925k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
925k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
925k
    const auto l = And(val, kMaskL);
69
925k
    const auto exp = ShiftRight<23>(b);
70
925k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
925k
    const auto n = Sub(exp_fixed, kExpOffset);
72
925k
    const auto eb = Sub(exp_fixed, kEBOffset);
73
925k
    const auto m = ShiftRight<23 - M - L>(b);
74
925k
    const auto a = Add(kBase, Mul(n, kMulN));
75
925k
    const auto d = And(m, kMaskM);
76
925k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
925k
    const auto c = Or(a, l);
78
925k
    extra_bits = Add(extra_bits, eb_fixed);
79
925k
    const auto t = Or(c, d);
80
925k
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
925k
    Store(t_fixed, du, out + i);
82
925k
  }
83
17.2k
  if (last_full < len) {
84
14.7k
    const auto stop = Set(du, len);
85
14.7k
    const auto fence = Iota(du, last_full);
86
14.7k
    const auto take = Lt(fence, stop);
87
14.7k
    const auto val = LoadU(du, values + last_full);
88
14.7k
    const auto is_large = Gt(val, kLargeThreshold);
89
14.7k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
14.7k
    const auto not_literal = Ge(val, kSplit);
91
14.7k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
14.7k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
14.7k
    const auto l = And(val, kMaskL);
94
14.7k
    const auto exp = ShiftRight<23>(b);
95
14.7k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
14.7k
    const auto n = Sub(exp_fixed, kExpOffset);
97
14.7k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
14.7k
    const auto m = ShiftRight<23 - M - L>(b);
99
14.7k
    const auto a = Add(kBase, Mul(n, kMulN));
100
14.7k
    const auto d = And(m, kMaskM);
101
14.7k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
14.7k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
14.7k
    const auto c = Or(a, l);
104
14.7k
    extra_bits = Add(extra_bits, eb_masked);
105
14.7k
    const auto t = Or(c, d);
106
14.7k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
14.7k
    Store(t_fixed, du, out + last_full);
108
14.7k
  }
109
17.2k
  return GetLane(SumOfLanes(du, extra_bits));
110
17.2k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<6ul, 1ul, 5ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
14.7k
                               uint32_t* JXL_RESTRICT out) {
45
14.7k
  const HWY_FULL(uint32_t) du;
46
14.7k
  const HWY_FULL(float) df;
47
14.7k
  const auto kZero = Zero(du);
48
14.7k
  const auto kSplit = Set(du, 1 << E);
49
14.7k
  const auto kExpOffset = Set(du, 127);
50
14.7k
  const auto kEBOffset = Set(du, 127 + M + L);
51
14.7k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
14.7k
  const auto kMulN = Set(du, 1 << (M + L));
53
14.7k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
14.7k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
14.7k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
14.7k
  constexpr size_t kLargeShiftVal = 10;
57
14.7k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
14.7k
  auto extra_bits = kZero;
60
14.7k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
507k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
492k
    const auto val = LoadU(du, values + i);
63
492k
    const auto is_large = Gt(val, kLargeThreshold);
64
492k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
492k
    const auto not_literal = Ge(val, kSplit);
66
492k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
492k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
492k
    const auto l = And(val, kMaskL);
69
492k
    const auto exp = ShiftRight<23>(b);
70
492k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
492k
    const auto n = Sub(exp_fixed, kExpOffset);
72
492k
    const auto eb = Sub(exp_fixed, kEBOffset);
73
492k
    const auto m = ShiftRight<23 - M - L>(b);
74
492k
    const auto a = Add(kBase, Mul(n, kMulN));
75
492k
    const auto d = And(m, kMaskM);
76
492k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
492k
    const auto c = Or(a, l);
78
492k
    extra_bits = Add(extra_bits, eb_fixed);
79
492k
    const auto t = Or(c, d);
80
492k
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
492k
    Store(t_fixed, du, out + i);
82
492k
  }
83
14.7k
  if (last_full < len) {
84
12.7k
    const auto stop = Set(du, len);
85
12.7k
    const auto fence = Iota(du, last_full);
86
12.7k
    const auto take = Lt(fence, stop);
87
12.7k
    const auto val = LoadU(du, values + last_full);
88
12.7k
    const auto is_large = Gt(val, kLargeThreshold);
89
12.7k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
12.7k
    const auto not_literal = Ge(val, kSplit);
91
12.7k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
12.7k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
12.7k
    const auto l = And(val, kMaskL);
94
12.7k
    const auto exp = ShiftRight<23>(b);
95
12.7k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
12.7k
    const auto n = Sub(exp_fixed, kExpOffset);
97
12.7k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
12.7k
    const auto m = ShiftRight<23 - M - L>(b);
99
12.7k
    const auto a = Add(kBase, Mul(n, kMulN));
100
12.7k
    const auto d = And(m, kMaskM);
101
12.7k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
12.7k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
12.7k
    const auto c = Or(a, l);
104
12.7k
    extra_bits = Add(extra_bits, eb_masked);
105
12.7k
    const auto t = Or(c, d);
106
12.7k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
12.7k
    Store(t_fixed, du, out + last_full);
108
12.7k
  }
109
14.7k
  return GetLane(SumOfLanes(du, extra_bits));
110
14.7k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<6ul, 2ul, 4ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
14.7k
                               uint32_t* JXL_RESTRICT out) {
45
14.7k
  const HWY_FULL(uint32_t) du;
46
14.7k
  const HWY_FULL(float) df;
47
14.7k
  const auto kZero = Zero(du);
48
14.7k
  const auto kSplit = Set(du, 1 << E);
49
14.7k
  const auto kExpOffset = Set(du, 127);
50
14.7k
  const auto kEBOffset = Set(du, 127 + M + L);
51
14.7k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
14.7k
  const auto kMulN = Set(du, 1 << (M + L));
53
14.7k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
14.7k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
14.7k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
14.7k
  constexpr size_t kLargeShiftVal = 10;
57
14.7k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
14.7k
  auto extra_bits = kZero;
60
14.7k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
507k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
492k
    const auto val = LoadU(du, values + i);
63
492k
    const auto is_large = Gt(val, kLargeThreshold);
64
492k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
492k
    const auto not_literal = Ge(val, kSplit);
66
492k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
492k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
492k
    const auto l = And(val, kMaskL);
69
492k
    const auto exp = ShiftRight<23>(b);
70
492k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
492k
    const auto n = Sub(exp_fixed, kExpOffset);
72
492k
    const auto eb = Sub(exp_fixed, kEBOffset);
73
492k
    const auto m = ShiftRight<23 - M - L>(b);
74
492k
    const auto a = Add(kBase, Mul(n, kMulN));
75
492k
    const auto d = And(m, kMaskM);
76
492k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
492k
    const auto c = Or(a, l);
78
492k
    extra_bits = Add(extra_bits, eb_fixed);
79
492k
    const auto t = Or(c, d);
80
492k
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
492k
    Store(t_fixed, du, out + i);
82
492k
  }
83
14.7k
  if (last_full < len) {
84
12.7k
    const auto stop = Set(du, len);
85
12.7k
    const auto fence = Iota(du, last_full);
86
12.7k
    const auto take = Lt(fence, stop);
87
12.7k
    const auto val = LoadU(du, values + last_full);
88
12.7k
    const auto is_large = Gt(val, kLargeThreshold);
89
12.7k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
12.7k
    const auto not_literal = Ge(val, kSplit);
91
12.7k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
12.7k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
12.7k
    const auto l = And(val, kMaskL);
94
12.7k
    const auto exp = ShiftRight<23>(b);
95
12.7k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
12.7k
    const auto n = Sub(exp_fixed, kExpOffset);
97
12.7k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
12.7k
    const auto m = ShiftRight<23 - M - L>(b);
99
12.7k
    const auto a = Add(kBase, Mul(n, kMulN));
100
12.7k
    const auto d = And(m, kMaskM);
101
12.7k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
12.7k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
12.7k
    const auto c = Or(a, l);
104
12.7k
    extra_bits = Add(extra_bits, eb_masked);
105
12.7k
    const auto t = Or(c, d);
106
12.7k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
12.7k
    Store(t_fixed, du, out + last_full);
108
12.7k
  }
109
14.7k
  return GetLane(SumOfLanes(du, extra_bits));
110
14.7k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<7ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
17.2k
                               uint32_t* JXL_RESTRICT out) {
45
17.2k
  const HWY_FULL(uint32_t) du;
46
17.2k
  const HWY_FULL(float) df;
47
17.2k
  const auto kZero = Zero(du);
48
17.2k
  const auto kSplit = Set(du, 1 << E);
49
17.2k
  const auto kExpOffset = Set(du, 127);
50
17.2k
  const auto kEBOffset = Set(du, 127 + M + L);
51
17.2k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
17.2k
  const auto kMulN = Set(du, 1 << (M + L));
53
17.2k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
17.2k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
17.2k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
17.2k
  constexpr size_t kLargeShiftVal = 10;
57
17.2k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
17.2k
  auto extra_bits = kZero;
60
17.2k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
942k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
925k
    const auto val = LoadU(du, values + i);
63
925k
    const auto is_large = Gt(val, kLargeThreshold);
64
925k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
925k
    const auto not_literal = Ge(val, kSplit);
66
925k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
925k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
925k
    const auto l = And(val, kMaskL);
69
925k
    const auto exp = ShiftRight<23>(b);
70
925k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
925k
    const auto n = Sub(exp_fixed, kExpOffset);
72
925k
    const auto eb = Sub(exp_fixed, kEBOffset);
73
925k
    const auto m = ShiftRight<23 - M - L>(b);
74
925k
    const auto a = Add(kBase, Mul(n, kMulN));
75
925k
    const auto d = And(m, kMaskM);
76
925k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
925k
    const auto c = Or(a, l);
78
925k
    extra_bits = Add(extra_bits, eb_fixed);
79
925k
    const auto t = Or(c, d);
80
925k
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
925k
    Store(t_fixed, du, out + i);
82
925k
  }
83
17.2k
  if (last_full < len) {
84
14.7k
    const auto stop = Set(du, len);
85
14.7k
    const auto fence = Iota(du, last_full);
86
14.7k
    const auto take = Lt(fence, stop);
87
14.7k
    const auto val = LoadU(du, values + last_full);
88
14.7k
    const auto is_large = Gt(val, kLargeThreshold);
89
14.7k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
14.7k
    const auto not_literal = Ge(val, kSplit);
91
14.7k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
14.7k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
14.7k
    const auto l = And(val, kMaskL);
94
14.7k
    const auto exp = ShiftRight<23>(b);
95
14.7k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
14.7k
    const auto n = Sub(exp_fixed, kExpOffset);
97
14.7k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
14.7k
    const auto m = ShiftRight<23 - M - L>(b);
99
14.7k
    const auto a = Add(kBase, Mul(n, kMulN));
100
14.7k
    const auto d = And(m, kMaskM);
101
14.7k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
14.7k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
14.7k
    const auto c = Or(a, l);
104
14.7k
    extra_bits = Add(extra_bits, eb_masked);
105
14.7k
    const auto t = Or(c, d);
106
14.7k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
14.7k
    Store(t_fixed, du, out + last_full);
108
14.7k
  }
109
17.2k
  return GetLane(SumOfLanes(du, extra_bits));
110
17.2k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<8ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
12.9k
                               uint32_t* JXL_RESTRICT out) {
45
12.9k
  const HWY_FULL(uint32_t) du;
46
12.9k
  const HWY_FULL(float) df;
47
12.9k
  const auto kZero = Zero(du);
48
12.9k
  const auto kSplit = Set(du, 1 << E);
49
12.9k
  const auto kExpOffset = Set(du, 127);
50
12.9k
  const auto kEBOffset = Set(du, 127 + M + L);
51
12.9k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
12.9k
  const auto kMulN = Set(du, 1 << (M + L));
53
12.9k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
12.9k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
12.9k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
12.9k
  constexpr size_t kLargeShiftVal = 10;
57
12.9k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
12.9k
  auto extra_bits = kZero;
60
12.9k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
442k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
429k
    const auto val = LoadU(du, values + i);
63
429k
    const auto is_large = Gt(val, kLargeThreshold);
64
429k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
429k
    const auto not_literal = Ge(val, kSplit);
66
429k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
429k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
429k
    const auto l = And(val, kMaskL);
69
429k
    const auto exp = ShiftRight<23>(b);
70
429k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
429k
    const auto n = Sub(exp_fixed, kExpOffset);
72
429k
    const auto eb = Sub(exp_fixed, kEBOffset);
73
429k
    const auto m = ShiftRight<23 - M - L>(b);
74
429k
    const auto a = Add(kBase, Mul(n, kMulN));
75
429k
    const auto d = And(m, kMaskM);
76
429k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
429k
    const auto c = Or(a, l);
78
429k
    extra_bits = Add(extra_bits, eb_fixed);
79
429k
    const auto t = Or(c, d);
80
429k
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
429k
    Store(t_fixed, du, out + i);
82
429k
  }
83
12.9k
  if (last_full < len) {
84
11.0k
    const auto stop = Set(du, len);
85
11.0k
    const auto fence = Iota(du, last_full);
86
11.0k
    const auto take = Lt(fence, stop);
87
11.0k
    const auto val = LoadU(du, values + last_full);
88
11.0k
    const auto is_large = Gt(val, kLargeThreshold);
89
11.0k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
11.0k
    const auto not_literal = Ge(val, kSplit);
91
11.0k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
11.0k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
11.0k
    const auto l = And(val, kMaskL);
94
11.0k
    const auto exp = ShiftRight<23>(b);
95
11.0k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
11.0k
    const auto n = Sub(exp_fixed, kExpOffset);
97
11.0k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
11.0k
    const auto m = ShiftRight<23 - M - L>(b);
99
11.0k
    const auto a = Add(kBase, Mul(n, kMulN));
100
11.0k
    const auto d = And(m, kMaskM);
101
11.0k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
11.0k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
11.0k
    const auto c = Or(a, l);
104
11.0k
    extra_bits = Add(extra_bits, eb_masked);
105
11.0k
    const auto t = Or(c, d);
106
11.0k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
11.0k
    Store(t_fixed, du, out + last_full);
108
11.0k
  }
109
12.9k
  return GetLane(SumOfLanes(du, extra_bits));
110
12.9k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<9ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
12.9k
                               uint32_t* JXL_RESTRICT out) {
45
12.9k
  const HWY_FULL(uint32_t) du;
46
12.9k
  const HWY_FULL(float) df;
47
12.9k
  const auto kZero = Zero(du);
48
12.9k
  const auto kSplit = Set(du, 1 << E);
49
12.9k
  const auto kExpOffset = Set(du, 127);
50
12.9k
  const auto kEBOffset = Set(du, 127 + M + L);
51
12.9k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
12.9k
  const auto kMulN = Set(du, 1 << (M + L));
53
12.9k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
12.9k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
12.9k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
12.9k
  constexpr size_t kLargeShiftVal = 10;
57
12.9k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
12.9k
  auto extra_bits = kZero;
60
12.9k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
442k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
429k
    const auto val = LoadU(du, values + i);
63
429k
    const auto is_large = Gt(val, kLargeThreshold);
64
429k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
429k
    const auto not_literal = Ge(val, kSplit);
66
429k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
429k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
429k
    const auto l = And(val, kMaskL);
69
429k
    const auto exp = ShiftRight<23>(b);
70
429k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
429k
    const auto n = Sub(exp_fixed, kExpOffset);
72
429k
    const auto eb = Sub(exp_fixed, kEBOffset);
73
429k
    const auto m = ShiftRight<23 - M - L>(b);
74
429k
    const auto a = Add(kBase, Mul(n, kMulN));
75
429k
    const auto d = And(m, kMaskM);
76
429k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
429k
    const auto c = Or(a, l);
78
429k
    extra_bits = Add(extra_bits, eb_fixed);
79
429k
    const auto t = Or(c, d);
80
429k
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
429k
    Store(t_fixed, du, out + i);
82
429k
  }
83
12.9k
  if (last_full < len) {
84
11.0k
    const auto stop = Set(du, len);
85
11.0k
    const auto fence = Iota(du, last_full);
86
11.0k
    const auto take = Lt(fence, stop);
87
11.0k
    const auto val = LoadU(du, values + last_full);
88
11.0k
    const auto is_large = Gt(val, kLargeThreshold);
89
11.0k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
11.0k
    const auto not_literal = Ge(val, kSplit);
91
11.0k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
11.0k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
11.0k
    const auto l = And(val, kMaskL);
94
11.0k
    const auto exp = ShiftRight<23>(b);
95
11.0k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
11.0k
    const auto n = Sub(exp_fixed, kExpOffset);
97
11.0k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
11.0k
    const auto m = ShiftRight<23 - M - L>(b);
99
11.0k
    const auto a = Add(kBase, Mul(n, kMulN));
100
11.0k
    const auto d = And(m, kMaskM);
101
11.0k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
11.0k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
11.0k
    const auto c = Or(a, l);
104
11.0k
    extra_bits = Add(extra_bits, eb_masked);
105
11.0k
    const auto t = Or(c, d);
106
11.0k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
11.0k
    Store(t_fixed, du, out + last_full);
108
11.0k
  }
109
12.9k
  return GetLane(SumOfLanes(du, extra_bits));
110
12.9k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<10ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
12.9k
                               uint32_t* JXL_RESTRICT out) {
45
12.9k
  const HWY_FULL(uint32_t) du;
46
12.9k
  const HWY_FULL(float) df;
47
12.9k
  const auto kZero = Zero(du);
48
12.9k
  const auto kSplit = Set(du, 1 << E);
49
12.9k
  const auto kExpOffset = Set(du, 127);
50
12.9k
  const auto kEBOffset = Set(du, 127 + M + L);
51
12.9k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
12.9k
  const auto kMulN = Set(du, 1 << (M + L));
53
12.9k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
12.9k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
12.9k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
12.9k
  constexpr size_t kLargeShiftVal = 10;
57
12.9k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
12.9k
  auto extra_bits = kZero;
60
12.9k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
442k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
429k
    const auto val = LoadU(du, values + i);
63
429k
    const auto is_large = Gt(val, kLargeThreshold);
64
429k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
429k
    const auto not_literal = Ge(val, kSplit);
66
429k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
429k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
429k
    const auto l = And(val, kMaskL);
69
429k
    const auto exp = ShiftRight<23>(b);
70
429k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
429k
    const auto n = Sub(exp_fixed, kExpOffset);
72
429k
    const auto eb = Sub(exp_fixed, kEBOffset);
73
429k
    const auto m = ShiftRight<23 - M - L>(b);
74
429k
    const auto a = Add(kBase, Mul(n, kMulN));
75
429k
    const auto d = And(m, kMaskM);
76
429k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
429k
    const auto c = Or(a, l);
78
429k
    extra_bits = Add(extra_bits, eb_fixed);
79
429k
    const auto t = Or(c, d);
80
429k
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
429k
    Store(t_fixed, du, out + i);
82
429k
  }
83
12.9k
  if (last_full < len) {
84
11.0k
    const auto stop = Set(du, len);
85
11.0k
    const auto fence = Iota(du, last_full);
86
11.0k
    const auto take = Lt(fence, stop);
87
11.0k
    const auto val = LoadU(du, values + last_full);
88
11.0k
    const auto is_large = Gt(val, kLargeThreshold);
89
11.0k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
11.0k
    const auto not_literal = Ge(val, kSplit);
91
11.0k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
11.0k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
11.0k
    const auto l = And(val, kMaskL);
94
11.0k
    const auto exp = ShiftRight<23>(b);
95
11.0k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
11.0k
    const auto n = Sub(exp_fixed, kExpOffset);
97
11.0k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
11.0k
    const auto m = ShiftRight<23 - M - L>(b);
99
11.0k
    const auto a = Add(kBase, Mul(n, kMulN));
100
11.0k
    const auto d = And(m, kMaskM);
101
11.0k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
11.0k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
11.0k
    const auto c = Or(a, l);
104
11.0k
    extra_bits = Add(extra_bits, eb_masked);
105
11.0k
    const auto t = Or(c, d);
106
11.0k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
11.0k
    Store(t_fixed, du, out + last_full);
108
11.0k
  }
109
12.9k
  return GetLane(SumOfLanes(du, extra_bits));
110
12.9k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<11ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
12.9k
                               uint32_t* JXL_RESTRICT out) {
45
12.9k
  const HWY_FULL(uint32_t) du;
46
12.9k
  const HWY_FULL(float) df;
47
12.9k
  const auto kZero = Zero(du);
48
12.9k
  const auto kSplit = Set(du, 1 << E);
49
12.9k
  const auto kExpOffset = Set(du, 127);
50
12.9k
  const auto kEBOffset = Set(du, 127 + M + L);
51
12.9k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
12.9k
  const auto kMulN = Set(du, 1 << (M + L));
53
12.9k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
12.9k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
12.9k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
12.9k
  constexpr size_t kLargeShiftVal = 10;
57
12.9k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
12.9k
  auto extra_bits = kZero;
60
12.9k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
442k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
429k
    const auto val = LoadU(du, values + i);
63
429k
    const auto is_large = Gt(val, kLargeThreshold);
64
429k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
429k
    const auto not_literal = Ge(val, kSplit);
66
429k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
429k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
429k
    const auto l = And(val, kMaskL);
69
429k
    const auto exp = ShiftRight<23>(b);
70
429k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
429k
    const auto n = Sub(exp_fixed, kExpOffset);
72
429k
    const auto eb = Sub(exp_fixed, kEBOffset);
73
429k
    const auto m = ShiftRight<23 - M - L>(b);
74
429k
    const auto a = Add(kBase, Mul(n, kMulN));
75
429k
    const auto d = And(m, kMaskM);
76
429k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
429k
    const auto c = Or(a, l);
78
429k
    extra_bits = Add(extra_bits, eb_fixed);
79
429k
    const auto t = Or(c, d);
80
429k
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
429k
    Store(t_fixed, du, out + i);
82
429k
  }
83
12.9k
  if (last_full < len) {
84
11.0k
    const auto stop = Set(du, len);
85
11.0k
    const auto fence = Iota(du, last_full);
86
11.0k
    const auto take = Lt(fence, stop);
87
11.0k
    const auto val = LoadU(du, values + last_full);
88
11.0k
    const auto is_large = Gt(val, kLargeThreshold);
89
11.0k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
11.0k
    const auto not_literal = Ge(val, kSplit);
91
11.0k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
11.0k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
11.0k
    const auto l = And(val, kMaskL);
94
11.0k
    const auto exp = ShiftRight<23>(b);
95
11.0k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
11.0k
    const auto n = Sub(exp_fixed, kExpOffset);
97
11.0k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
11.0k
    const auto m = ShiftRight<23 - M - L>(b);
99
11.0k
    const auto a = Add(kBase, Mul(n, kMulN));
100
11.0k
    const auto d = And(m, kMaskM);
101
11.0k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
11.0k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
11.0k
    const auto c = Or(a, l);
104
11.0k
    extra_bits = Add(extra_bits, eb_masked);
105
11.0k
    const auto t = Or(c, d);
106
11.0k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
11.0k
    Store(t_fixed, du, out + last_full);
108
11.0k
  }
109
12.9k
  return GetLane(SumOfLanes(du, extra_bits));
110
12.9k
}
unsigned int jxl::N_AVX2::EstimateTokenCostImpl<12ul, 0ul, 0ul>(unsigned int*, unsigned long, unsigned int*)
Line
Count
Source
44
12.9k
                               uint32_t* JXL_RESTRICT out) {
45
12.9k
  const HWY_FULL(uint32_t) du;
46
12.9k
  const HWY_FULL(float) df;
47
12.9k
  const auto kZero = Zero(du);
48
12.9k
  const auto kSplit = Set(du, 1 << E);
49
12.9k
  const auto kExpOffset = Set(du, 127);
50
12.9k
  const auto kEBOffset = Set(du, 127 + M + L);
51
12.9k
  const auto kBase = Set(du, static_cast<uint32_t>((1 << E) - (E << (M + L))));
52
12.9k
  const auto kMulN = Set(du, 1 << (M + L));
53
12.9k
  const auto kMaskL = Set(du, (1 << L) - 1);
54
12.9k
  const auto kMaskM = Set(du, ((1 << M) - 1) << L);
55
12.9k
  const auto kLargeThreshold = Set(du, (1 << 22) - 1);
56
12.9k
  constexpr size_t kLargeShiftVal = 10;
57
12.9k
  const auto kLargeShift = Set(du, kLargeShiftVal);
58
59
12.9k
  auto extra_bits = kZero;
60
12.9k
  size_t last_full = Lanes(du) * (len / Lanes(du));
61
442k
  for (size_t i = 0; i < last_full; i += Lanes(du)) {
62
429k
    const auto val = LoadU(du, values + i);
63
429k
    const auto is_large = Gt(val, kLargeThreshold);
64
429k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
65
429k
    const auto not_literal = Ge(val, kSplit);
66
429k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
67
429k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
68
429k
    const auto l = And(val, kMaskL);
69
429k
    const auto exp = ShiftRight<23>(b);
70
429k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
71
429k
    const auto n = Sub(exp_fixed, kExpOffset);
72
429k
    const auto eb = Sub(exp_fixed, kEBOffset);
73
429k
    const auto m = ShiftRight<23 - M - L>(b);
74
429k
    const auto a = Add(kBase, Mul(n, kMulN));
75
429k
    const auto d = And(m, kMaskM);
76
429k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
77
429k
    const auto c = Or(a, l);
78
429k
    extra_bits = Add(extra_bits, eb_fixed);
79
429k
    const auto t = Or(c, d);
80
429k
    const auto t_fixed = IfThenElse(not_literal, t, val);
81
429k
    Store(t_fixed, du, out + i);
82
429k
  }
83
12.9k
  if (last_full < len) {
84
11.0k
    const auto stop = Set(du, len);
85
11.0k
    const auto fence = Iota(du, last_full);
86
11.0k
    const auto take = Lt(fence, stop);
87
11.0k
    const auto val = LoadU(du, values + last_full);
88
11.0k
    const auto is_large = Gt(val, kLargeThreshold);
89
11.0k
    const auto val_shifted = ShiftRight<kLargeShiftVal>(val);
90
11.0k
    const auto not_literal = Ge(val, kSplit);
91
11.0k
    const auto val_fixed = IfThenElse(is_large, val_shifted, val);
92
11.0k
    const auto b = BitCast(du, ConvertTo(df, val_fixed));
93
11.0k
    const auto l = And(val, kMaskL);
94
11.0k
    const auto exp = ShiftRight<23>(b);
95
11.0k
    const auto exp_fixed = IfThenElse(is_large, Add(exp, kLargeShift), exp);
96
11.0k
    const auto n = Sub(exp_fixed, kExpOffset);
97
11.0k
    const auto eb = Sub(exp_fixed, kEBOffset);
98
11.0k
    const auto m = ShiftRight<23 - M - L>(b);
99
11.0k
    const auto a = Add(kBase, Mul(n, kMulN));
100
11.0k
    const auto d = And(m, kMaskM);
101
11.0k
    const auto eb_fixed = IfThenElseZero(not_literal, eb);
102
11.0k
    const auto eb_masked = IfThenElseZero(take, eb_fixed);
103
11.0k
    const auto c = Or(a, l);
104
11.0k
    extra_bits = Add(extra_bits, eb_masked);
105
11.0k
    const auto t = Or(c, d);
106
11.0k
    const auto t_fixed = IfThenElse(not_literal, t, val);
107
11.0k
    Store(t_fixed, du, out + last_full);
108
11.0k
  }
109
12.9k
  return GetLane(SumOfLanes(du, extra_bits));
110
12.9k
}
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
731k
                           HybridUintConfig cfg, AlignedMemory& tokens) {
114
731k
  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
731k
  if (cfg.split_exponent == 0) {
127
87.8k
    return EstimateTokenCostImpl<0, 0, 0>(values, len, out);
128
643k
  } else if (cfg.split_exponent == 2) {
129
85.3k
    JXL_DASSERT((cfg.msb_in_token == 0) && (cfg.lsb_in_token == 1));
130
85.3k
    return EstimateTokenCostImpl<2, 0, 1>(values, len, out);
131
558k
  } else if (cfg.split_exponent == 3) {
132
69.0k
    if (cfg.msb_in_token == 1) {
133
34.5k
      if (cfg.lsb_in_token == 0) {
134
17.2k
        return EstimateTokenCostImpl<3, 1, 0>(values, len, out);
135
17.2k
      } else {
136
17.2k
        JXL_DASSERT(cfg.lsb_in_token == 2);
137
17.2k
        return EstimateTokenCostImpl<3, 1, 2>(values, len, out);
138
17.2k
      }
139
34.5k
    } else {
140
34.5k
      JXL_DASSERT(cfg.msb_in_token == 2);
141
34.5k
      if (cfg.lsb_in_token == 0) {
142
17.2k
        return EstimateTokenCostImpl<3, 2, 0>(values, len, out);
143
17.2k
      } else {
144
17.2k
        JXL_DASSERT(cfg.lsb_in_token == 1);
145
17.2k
        return EstimateTokenCostImpl<3, 2, 1>(values, len, out);
146
17.2k
      }
147
34.5k
    }
148
489k
  } else if (cfg.split_exponent == 4) {
149
239k
    if (cfg.msb_in_token == 1) {
150
119k
      if (cfg.lsb_in_token == 0) {
151
17.2k
        return EstimateTokenCostImpl<4, 1, 0>(values, len, out);
152
102k
      } else if (cfg.lsb_in_token == 2) {
153
85.3k
        return EstimateTokenCostImpl<4, 1, 2>(values, len, out);
154
85.3k
      } else {
155
17.2k
        JXL_DASSERT(cfg.lsb_in_token == 3);
156
17.2k
        return EstimateTokenCostImpl<4, 1, 3>(values, len, out);
157
17.2k
      }
158
119k
    } else {
159
119k
      JXL_DASSERT(cfg.msb_in_token == 2);
160
119k
      if (cfg.lsb_in_token == 0) {
161
85.3k
        return EstimateTokenCostImpl<4, 2, 0>(values, len, out);
162
85.3k
      } else if (cfg.lsb_in_token == 1) {
163
17.2k
        return EstimateTokenCostImpl<4, 2, 1>(values, len, out);
164
17.2k
      } else {
165
17.2k
        JXL_DASSERT(cfg.lsb_in_token == 2);
166
17.2k
        return EstimateTokenCostImpl<4, 2, 2>(values, len, out);
167
17.2k
      }
168
119k
    }
169
249k
  } else if (cfg.split_exponent == 5) {
170
120k
    if (cfg.msb_in_token == 1) {
171
51.7k
      if (cfg.lsb_in_token == 0) {
172
17.2k
        return EstimateTokenCostImpl<5, 1, 0>(values, len, out);
173
34.4k
      } else if (cfg.lsb_in_token == 2) {
174
17.2k
        return EstimateTokenCostImpl<5, 1, 2>(values, len, out);
175
17.2k
      } else {
176
17.2k
        JXL_DASSERT(cfg.lsb_in_token == 4);
177
17.2k
        return EstimateTokenCostImpl<5, 1, 4>(values, len, out);
178
17.2k
      }
179
68.9k
    } else {
180
68.9k
      JXL_DASSERT(cfg.msb_in_token == 2);
181
68.9k
      if (cfg.lsb_in_token == 0) {
182
17.2k
        return EstimateTokenCostImpl<5, 2, 0>(values, len, out);
183
51.7k
      } else if (cfg.lsb_in_token == 1) {
184
17.2k
        return EstimateTokenCostImpl<5, 2, 1>(values, len, out);
185
34.4k
      } else if (cfg.lsb_in_token == 2) {
186
17.2k
        return EstimateTokenCostImpl<5, 2, 2>(values, len, out);
187
17.2k
      } else {
188
17.2k
        JXL_DASSERT(cfg.lsb_in_token == 3);
189
17.2k
        return EstimateTokenCostImpl<5, 2, 3>(values, len, out);
190
17.2k
      }
191
68.9k
    }
192
128k
  } else if (cfg.split_exponent == 6) {
193
46.8k
    if (cfg.msb_in_token == 0) {
194
17.2k
      JXL_DASSERT(cfg.lsb_in_token == 0);
195
17.2k
      return EstimateTokenCostImpl<6, 0, 0>(values, len, out);
196
29.5k
    } else if (cfg.msb_in_token == 1) {
197
14.7k
      JXL_DASSERT(cfg.lsb_in_token == 5);
198
14.7k
      return EstimateTokenCostImpl<6, 1, 5>(values, len, out);
199
14.7k
    } else {
200
14.7k
      JXL_DASSERT(cfg.msb_in_token == 2);
201
14.7k
      JXL_DASSERT(cfg.lsb_in_token == 4);
202
14.7k
      return EstimateTokenCostImpl<6, 2, 4>(values, len, out);
203
14.7k
    }
204
81.8k
  } else if (cfg.split_exponent >= 7 && cfg.split_exponent <= 12) {
205
81.8k
    JXL_DASSERT(cfg.msb_in_token == 0);
206
81.8k
    JXL_DASSERT(cfg.lsb_in_token == 0);
207
81.8k
    if (cfg.split_exponent == 7) {
208
17.2k
      return EstimateTokenCostImpl<7, 0, 0>(values, len, out);
209
64.5k
    } else if (cfg.split_exponent == 8) {
210
12.9k
      return EstimateTokenCostImpl<8, 0, 0>(values, len, out);
211
51.6k
    } else if (cfg.split_exponent == 9) {
212
12.9k
      return EstimateTokenCostImpl<9, 0, 0>(values, len, out);
213
38.7k
    } else if (cfg.split_exponent == 10) {
214
12.9k
      return EstimateTokenCostImpl<10, 0, 0>(values, len, out);
215
25.8k
    } else if (cfg.split_exponent == 11) {
216
12.9k
      return EstimateTokenCostImpl<11, 0, 0>(values, len, out);
217
12.9k
    } else {
218
12.9k
      return EstimateTokenCostImpl<12, 0, 0>(values, len, out);
219
12.9k
    }
220
81.8k
  } else {
221
0
    JXL_DASSERT(false);
222
0
  }
223
0
  return ~0;
224
731k
#endif
225
731k
}
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
731k
                           HybridUintConfig cfg, AlignedMemory& tokens) {
114
731k
  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
731k
  if (cfg.split_exponent == 0) {
127
87.8k
    return EstimateTokenCostImpl<0, 0, 0>(values, len, out);
128
643k
  } else if (cfg.split_exponent == 2) {
129
85.3k
    JXL_DASSERT((cfg.msb_in_token == 0) && (cfg.lsb_in_token == 1));
130
85.3k
    return EstimateTokenCostImpl<2, 0, 1>(values, len, out);
131
558k
  } else if (cfg.split_exponent == 3) {
132
69.0k
    if (cfg.msb_in_token == 1) {
133
34.5k
      if (cfg.lsb_in_token == 0) {
134
17.2k
        return EstimateTokenCostImpl<3, 1, 0>(values, len, out);
135
17.2k
      } else {
136
17.2k
        JXL_DASSERT(cfg.lsb_in_token == 2);
137
17.2k
        return EstimateTokenCostImpl<3, 1, 2>(values, len, out);
138
17.2k
      }
139
34.5k
    } else {
140
34.5k
      JXL_DASSERT(cfg.msb_in_token == 2);
141
34.5k
      if (cfg.lsb_in_token == 0) {
142
17.2k
        return EstimateTokenCostImpl<3, 2, 0>(values, len, out);
143
17.2k
      } else {
144
17.2k
        JXL_DASSERT(cfg.lsb_in_token == 1);
145
17.2k
        return EstimateTokenCostImpl<3, 2, 1>(values, len, out);
146
17.2k
      }
147
34.5k
    }
148
489k
  } else if (cfg.split_exponent == 4) {
149
239k
    if (cfg.msb_in_token == 1) {
150
119k
      if (cfg.lsb_in_token == 0) {
151
17.2k
        return EstimateTokenCostImpl<4, 1, 0>(values, len, out);
152
102k
      } else if (cfg.lsb_in_token == 2) {
153
85.3k
        return EstimateTokenCostImpl<4, 1, 2>(values, len, out);
154
85.3k
      } else {
155
17.2k
        JXL_DASSERT(cfg.lsb_in_token == 3);
156
17.2k
        return EstimateTokenCostImpl<4, 1, 3>(values, len, out);
157
17.2k
      }
158
119k
    } else {
159
119k
      JXL_DASSERT(cfg.msb_in_token == 2);
160
119k
      if (cfg.lsb_in_token == 0) {
161
85.3k
        return EstimateTokenCostImpl<4, 2, 0>(values, len, out);
162
85.3k
      } else if (cfg.lsb_in_token == 1) {
163
17.2k
        return EstimateTokenCostImpl<4, 2, 1>(values, len, out);
164
17.2k
      } else {
165
17.2k
        JXL_DASSERT(cfg.lsb_in_token == 2);
166
17.2k
        return EstimateTokenCostImpl<4, 2, 2>(values, len, out);
167
17.2k
      }
168
119k
    }
169
249k
  } else if (cfg.split_exponent == 5) {
170
120k
    if (cfg.msb_in_token == 1) {
171
51.7k
      if (cfg.lsb_in_token == 0) {
172
17.2k
        return EstimateTokenCostImpl<5, 1, 0>(values, len, out);
173
34.4k
      } else if (cfg.lsb_in_token == 2) {
174
17.2k
        return EstimateTokenCostImpl<5, 1, 2>(values, len, out);
175
17.2k
      } else {
176
17.2k
        JXL_DASSERT(cfg.lsb_in_token == 4);
177
17.2k
        return EstimateTokenCostImpl<5, 1, 4>(values, len, out);
178
17.2k
      }
179
68.9k
    } else {
180
68.9k
      JXL_DASSERT(cfg.msb_in_token == 2);
181
68.9k
      if (cfg.lsb_in_token == 0) {
182
17.2k
        return EstimateTokenCostImpl<5, 2, 0>(values, len, out);
183
51.7k
      } else if (cfg.lsb_in_token == 1) {
184
17.2k
        return EstimateTokenCostImpl<5, 2, 1>(values, len, out);
185
34.4k
      } else if (cfg.lsb_in_token == 2) {
186
17.2k
        return EstimateTokenCostImpl<5, 2, 2>(values, len, out);
187
17.2k
      } else {
188
17.2k
        JXL_DASSERT(cfg.lsb_in_token == 3);
189
17.2k
        return EstimateTokenCostImpl<5, 2, 3>(values, len, out);
190
17.2k
      }
191
68.9k
    }
192
128k
  } else if (cfg.split_exponent == 6) {
193
46.8k
    if (cfg.msb_in_token == 0) {
194
17.2k
      JXL_DASSERT(cfg.lsb_in_token == 0);
195
17.2k
      return EstimateTokenCostImpl<6, 0, 0>(values, len, out);
196
29.5k
    } else if (cfg.msb_in_token == 1) {
197
14.7k
      JXL_DASSERT(cfg.lsb_in_token == 5);
198
14.7k
      return EstimateTokenCostImpl<6, 1, 5>(values, len, out);
199
14.7k
    } else {
200
14.7k
      JXL_DASSERT(cfg.msb_in_token == 2);
201
14.7k
      JXL_DASSERT(cfg.lsb_in_token == 4);
202
14.7k
      return EstimateTokenCostImpl<6, 2, 4>(values, len, out);
203
14.7k
    }
204
81.8k
  } else if (cfg.split_exponent >= 7 && cfg.split_exponent <= 12) {
205
81.8k
    JXL_DASSERT(cfg.msb_in_token == 0);
206
81.8k
    JXL_DASSERT(cfg.lsb_in_token == 0);
207
81.8k
    if (cfg.split_exponent == 7) {
208
17.2k
      return EstimateTokenCostImpl<7, 0, 0>(values, len, out);
209
64.5k
    } else if (cfg.split_exponent == 8) {
210
12.9k
      return EstimateTokenCostImpl<8, 0, 0>(values, len, out);
211
51.6k
    } else if (cfg.split_exponent == 9) {
212
12.9k
      return EstimateTokenCostImpl<9, 0, 0>(values, len, out);
213
38.7k
    } else if (cfg.split_exponent == 10) {
214
12.9k
      return EstimateTokenCostImpl<10, 0, 0>(values, len, out);
215
25.8k
    } else if (cfg.split_exponent == 11) {
216
12.9k
      return EstimateTokenCostImpl<11, 0, 0>(values, len, out);
217
12.9k
    } else {
218
12.9k
      return EstimateTokenCostImpl<12, 0, 0>(values, len, out);
219
12.9k
    }
220
81.8k
  } else {
221
0
    JXL_DASSERT(false);
222
0
  }
223
0
  return ~0;
224
731k
#endif
225
731k
}
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
731k
                           HybridUintConfig cfg, AlignedMemory& tokens) {
239
731k
  JXL_DASSERT(cfg.lsb_in_token + cfg.msb_in_token <= cfg.split_exponent);
240
731k
  return HWY_DYNAMIC_DISPATCH(EstimateTokenCost)(values, len, cfg, tokens);
241
731k
}
242
243
}  // namespace jxl
244
#endif