Coverage Report

Created: 2026-07-16 07:06

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/c-blosc/internal-complibs/zstd-1.5.6/common/bits.h
Line
Count
Source
1
/*
2
 * Copyright (c) Meta Platforms, Inc. and affiliates.
3
 * All rights reserved.
4
 *
5
 * This source code is licensed under both the BSD-style license (found in the
6
 * LICENSE file in the root directory of this source tree) and the GPLv2 (found
7
 * in the COPYING file in the root directory of this source tree).
8
 * You may select, at your option, one of the above-listed licenses.
9
 */
10
11
#ifndef ZSTD_BITS_H
12
#define ZSTD_BITS_H
13
14
#include "mem.h"
15
16
MEM_STATIC unsigned ZSTD_countTrailingZeros32_fallback(U32 val)
17
0
{
18
0
    assert(val != 0);
19
0
    {
20
0
        static const U32 DeBruijnBytePos[32] = {0, 1, 28, 2, 29, 14, 24, 3,
21
0
                                                30, 22, 20, 15, 25, 17, 4, 8,
22
0
                                                31, 27, 13, 23, 21, 19, 16, 7,
23
0
                                                26, 12, 18, 6, 11, 5, 10, 9};
24
0
        return DeBruijnBytePos[((U32) ((val & -(S32) val) * 0x077CB531U)) >> 27];
25
0
    }
26
0
}
Unexecuted instantiation: zstd_common.c:ZSTD_countTrailingZeros32_fallback
Unexecuted instantiation: zstd_compress.c:ZSTD_countTrailingZeros32_fallback
Unexecuted instantiation: zstd_compress_literals.c:ZSTD_countTrailingZeros32_fallback
Unexecuted instantiation: zstd_compress_sequences.c:ZSTD_countTrailingZeros32_fallback
Unexecuted instantiation: zstd_compress_superblock.c:ZSTD_countTrailingZeros32_fallback
Unexecuted instantiation: zstd_double_fast.c:ZSTD_countTrailingZeros32_fallback
Unexecuted instantiation: zstd_fast.c:ZSTD_countTrailingZeros32_fallback
Unexecuted instantiation: zstd_lazy.c:ZSTD_countTrailingZeros32_fallback
Unexecuted instantiation: zstd_ldm.c:ZSTD_countTrailingZeros32_fallback
Unexecuted instantiation: zstd_opt.c:ZSTD_countTrailingZeros32_fallback
Unexecuted instantiation: zstd_decompress.c:ZSTD_countTrailingZeros32_fallback
Unexecuted instantiation: zstd_decompress_block.c:ZSTD_countTrailingZeros32_fallback
Unexecuted instantiation: entropy_common.c:ZSTD_countTrailingZeros32_fallback
Unexecuted instantiation: fse_decompress.c:ZSTD_countTrailingZeros32_fallback
Unexecuted instantiation: fse_compress.c:ZSTD_countTrailingZeros32_fallback
Unexecuted instantiation: huf_compress.c:ZSTD_countTrailingZeros32_fallback
Unexecuted instantiation: huf_decompress.c:ZSTD_countTrailingZeros32_fallback
Unexecuted instantiation: zstd_ddict.c:ZSTD_countTrailingZeros32_fallback
27
28
MEM_STATIC unsigned ZSTD_countTrailingZeros32(U32 val)
29
124k
{
30
124k
    assert(val != 0);
31
#   if defined(_MSC_VER)
32
#       if STATIC_BMI2 == 1
33
            return (unsigned)_tzcnt_u32(val);
34
#       else
35
            if (val != 0) {
36
                unsigned long r;
37
                _BitScanForward(&r, val);
38
                return (unsigned)r;
39
            } else {
40
                /* Should not reach this code path */
41
                __assume(0);
42
            }
43
#       endif
44
#   elif defined(__GNUC__) && (__GNUC__ >= 4)
45
        return (unsigned)__builtin_ctz(val);
46
#   else
47
        return ZSTD_countTrailingZeros32_fallback(val);
48
#   endif
49
124k
}
Unexecuted instantiation: zstd_common.c:ZSTD_countTrailingZeros32
Unexecuted instantiation: zstd_compress.c:ZSTD_countTrailingZeros32
Unexecuted instantiation: zstd_compress_literals.c:ZSTD_countTrailingZeros32
Unexecuted instantiation: zstd_compress_sequences.c:ZSTD_countTrailingZeros32
Unexecuted instantiation: zstd_compress_superblock.c:ZSTD_countTrailingZeros32
Unexecuted instantiation: zstd_double_fast.c:ZSTD_countTrailingZeros32
Unexecuted instantiation: zstd_fast.c:ZSTD_countTrailingZeros32
Unexecuted instantiation: zstd_lazy.c:ZSTD_countTrailingZeros32
Unexecuted instantiation: zstd_ldm.c:ZSTD_countTrailingZeros32
Unexecuted instantiation: zstd_opt.c:ZSTD_countTrailingZeros32
Unexecuted instantiation: zstd_decompress.c:ZSTD_countTrailingZeros32
Unexecuted instantiation: zstd_decompress_block.c:ZSTD_countTrailingZeros32
entropy_common.c:ZSTD_countTrailingZeros32
Line
Count
Source
29
124k
{
30
124k
    assert(val != 0);
31
#   if defined(_MSC_VER)
32
#       if STATIC_BMI2 == 1
33
            return (unsigned)_tzcnt_u32(val);
34
#       else
35
            if (val != 0) {
36
                unsigned long r;
37
                _BitScanForward(&r, val);
38
                return (unsigned)r;
39
            } else {
40
                /* Should not reach this code path */
41
                __assume(0);
42
            }
43
#       endif
44
#   elif defined(__GNUC__) && (__GNUC__ >= 4)
45
        return (unsigned)__builtin_ctz(val);
46
#   else
47
        return ZSTD_countTrailingZeros32_fallback(val);
48
#   endif
49
124k
}
Unexecuted instantiation: fse_decompress.c:ZSTD_countTrailingZeros32
Unexecuted instantiation: fse_compress.c:ZSTD_countTrailingZeros32
Unexecuted instantiation: huf_compress.c:ZSTD_countTrailingZeros32
Unexecuted instantiation: huf_decompress.c:ZSTD_countTrailingZeros32
Unexecuted instantiation: zstd_ddict.c:ZSTD_countTrailingZeros32
50
51
0
MEM_STATIC unsigned ZSTD_countLeadingZeros32_fallback(U32 val) {
52
0
    assert(val != 0);
53
0
    {
54
0
        static const U32 DeBruijnClz[32] = {0, 9, 1, 10, 13, 21, 2, 29,
55
0
                                            11, 14, 16, 18, 22, 25, 3, 30,
56
0
                                            8, 12, 20, 28, 15, 17, 24, 7,
57
0
                                            19, 27, 23, 6, 26, 5, 4, 31};
58
0
        val |= val >> 1;
59
0
        val |= val >> 2;
60
0
        val |= val >> 4;
61
0
        val |= val >> 8;
62
0
        val |= val >> 16;
63
0
        return 31 - DeBruijnClz[(val * 0x07C4ACDDU) >> 27];
64
0
    }
65
0
}
Unexecuted instantiation: zstd_common.c:ZSTD_countLeadingZeros32_fallback
Unexecuted instantiation: zstd_compress.c:ZSTD_countLeadingZeros32_fallback
Unexecuted instantiation: zstd_compress_literals.c:ZSTD_countLeadingZeros32_fallback
Unexecuted instantiation: zstd_compress_sequences.c:ZSTD_countLeadingZeros32_fallback
Unexecuted instantiation: zstd_compress_superblock.c:ZSTD_countLeadingZeros32_fallback
Unexecuted instantiation: zstd_double_fast.c:ZSTD_countLeadingZeros32_fallback
Unexecuted instantiation: zstd_fast.c:ZSTD_countLeadingZeros32_fallback
Unexecuted instantiation: zstd_lazy.c:ZSTD_countLeadingZeros32_fallback
Unexecuted instantiation: zstd_ldm.c:ZSTD_countLeadingZeros32_fallback
Unexecuted instantiation: zstd_opt.c:ZSTD_countLeadingZeros32_fallback
Unexecuted instantiation: zstd_decompress.c:ZSTD_countLeadingZeros32_fallback
Unexecuted instantiation: zstd_decompress_block.c:ZSTD_countLeadingZeros32_fallback
Unexecuted instantiation: entropy_common.c:ZSTD_countLeadingZeros32_fallback
Unexecuted instantiation: fse_decompress.c:ZSTD_countLeadingZeros32_fallback
Unexecuted instantiation: fse_compress.c:ZSTD_countLeadingZeros32_fallback
Unexecuted instantiation: huf_compress.c:ZSTD_countLeadingZeros32_fallback
Unexecuted instantiation: huf_decompress.c:ZSTD_countLeadingZeros32_fallback
Unexecuted instantiation: zstd_ddict.c:ZSTD_countLeadingZeros32_fallback
66
67
MEM_STATIC unsigned ZSTD_countLeadingZeros32(U32 val)
68
26.0G
{
69
26.0G
    assert(val != 0);
70
#   if defined(_MSC_VER)
71
#       if STATIC_BMI2 == 1
72
            return (unsigned)_lzcnt_u32(val);
73
#       else
74
            if (val != 0) {
75
                unsigned long r;
76
                _BitScanReverse(&r, val);
77
                return (unsigned)(31 - r);
78
            } else {
79
                /* Should not reach this code path */
80
                __assume(0);
81
            }
82
#       endif
83
#   elif defined(__GNUC__) && (__GNUC__ >= 4)
84
        return (unsigned)__builtin_clz(val);
85
#   else
86
        return ZSTD_countLeadingZeros32_fallback(val);
87
#   endif
88
26.0G
}
Unexecuted instantiation: zstd_common.c:ZSTD_countLeadingZeros32
zstd_compress.c:ZSTD_countLeadingZeros32
Line
Count
Source
68
19.6M
{
69
19.6M
    assert(val != 0);
70
#   if defined(_MSC_VER)
71
#       if STATIC_BMI2 == 1
72
            return (unsigned)_lzcnt_u32(val);
73
#       else
74
            if (val != 0) {
75
                unsigned long r;
76
                _BitScanReverse(&r, val);
77
                return (unsigned)(31 - r);
78
            } else {
79
                /* Should not reach this code path */
80
                __assume(0);
81
            }
82
#       endif
83
#   elif defined(__GNUC__) && (__GNUC__ >= 4)
84
        return (unsigned)__builtin_clz(val);
85
#   else
86
        return ZSTD_countLeadingZeros32_fallback(val);
87
#   endif
88
19.6M
}
Unexecuted instantiation: zstd_compress_literals.c:ZSTD_countLeadingZeros32
Unexecuted instantiation: zstd_compress_sequences.c:ZSTD_countLeadingZeros32
Unexecuted instantiation: zstd_compress_superblock.c:ZSTD_countLeadingZeros32
Unexecuted instantiation: zstd_double_fast.c:ZSTD_countLeadingZeros32
Unexecuted instantiation: zstd_fast.c:ZSTD_countLeadingZeros32
zstd_lazy.c:ZSTD_countLeadingZeros32
Line
Count
Source
68
39.0M
{
69
39.0M
    assert(val != 0);
70
#   if defined(_MSC_VER)
71
#       if STATIC_BMI2 == 1
72
            return (unsigned)_lzcnt_u32(val);
73
#       else
74
            if (val != 0) {
75
                unsigned long r;
76
                _BitScanReverse(&r, val);
77
                return (unsigned)(31 - r);
78
            } else {
79
                /* Should not reach this code path */
80
                __assume(0);
81
            }
82
#       endif
83
#   elif defined(__GNUC__) && (__GNUC__ >= 4)
84
        return (unsigned)__builtin_clz(val);
85
#   else
86
        return ZSTD_countLeadingZeros32_fallback(val);
87
#   endif
88
39.0M
}
Unexecuted instantiation: zstd_ldm.c:ZSTD_countLeadingZeros32
zstd_opt.c:ZSTD_countLeadingZeros32
Line
Count
Source
68
25.8G
{
69
25.8G
    assert(val != 0);
70
#   if defined(_MSC_VER)
71
#       if STATIC_BMI2 == 1
72
            return (unsigned)_lzcnt_u32(val);
73
#       else
74
            if (val != 0) {
75
                unsigned long r;
76
                _BitScanReverse(&r, val);
77
                return (unsigned)(31 - r);
78
            } else {
79
                /* Should not reach this code path */
80
                __assume(0);
81
            }
82
#       endif
83
#   elif defined(__GNUC__) && (__GNUC__ >= 4)
84
        return (unsigned)__builtin_clz(val);
85
#   else
86
        return ZSTD_countLeadingZeros32_fallback(val);
87
#   endif
88
25.8G
}
Unexecuted instantiation: zstd_decompress.c:ZSTD_countLeadingZeros32
zstd_decompress_block.c:ZSTD_countLeadingZeros32
Line
Count
Source
68
14.7M
{
69
14.7M
    assert(val != 0);
70
#   if defined(_MSC_VER)
71
#       if STATIC_BMI2 == 1
72
            return (unsigned)_lzcnt_u32(val);
73
#       else
74
            if (val != 0) {
75
                unsigned long r;
76
                _BitScanReverse(&r, val);
77
                return (unsigned)(31 - r);
78
            } else {
79
                /* Should not reach this code path */
80
                __assume(0);
81
            }
82
#       endif
83
#   elif defined(__GNUC__) && (__GNUC__ >= 4)
84
        return (unsigned)__builtin_clz(val);
85
#   else
86
        return ZSTD_countLeadingZeros32_fallback(val);
87
#   endif
88
14.7M
}
entropy_common.c:ZSTD_countLeadingZeros32
Line
Count
Source
68
596k
{
69
596k
    assert(val != 0);
70
#   if defined(_MSC_VER)
71
#       if STATIC_BMI2 == 1
72
            return (unsigned)_lzcnt_u32(val);
73
#       else
74
            if (val != 0) {
75
                unsigned long r;
76
                _BitScanReverse(&r, val);
77
                return (unsigned)(31 - r);
78
            } else {
79
                /* Should not reach this code path */
80
                __assume(0);
81
            }
82
#       endif
83
#   elif defined(__GNUC__) && (__GNUC__ >= 4)
84
        return (unsigned)__builtin_clz(val);
85
#   else
86
        return ZSTD_countLeadingZeros32_fallback(val);
87
#   endif
88
596k
}
fse_decompress.c:ZSTD_countLeadingZeros32
Line
Count
Source
68
2.66M
{
69
2.66M
    assert(val != 0);
70
#   if defined(_MSC_VER)
71
#       if STATIC_BMI2 == 1
72
            return (unsigned)_lzcnt_u32(val);
73
#       else
74
            if (val != 0) {
75
                unsigned long r;
76
                _BitScanReverse(&r, val);
77
                return (unsigned)(31 - r);
78
            } else {
79
                /* Should not reach this code path */
80
                __assume(0);
81
            }
82
#       endif
83
#   elif defined(__GNUC__) && (__GNUC__ >= 4)
84
        return (unsigned)__builtin_clz(val);
85
#   else
86
        return ZSTD_countLeadingZeros32_fallback(val);
87
#   endif
88
2.66M
}
fse_compress.c:ZSTD_countLeadingZeros32
Line
Count
Source
68
4.27M
{
69
4.27M
    assert(val != 0);
70
#   if defined(_MSC_VER)
71
#       if STATIC_BMI2 == 1
72
            return (unsigned)_lzcnt_u32(val);
73
#       else
74
            if (val != 0) {
75
                unsigned long r;
76
                _BitScanReverse(&r, val);
77
                return (unsigned)(31 - r);
78
            } else {
79
                /* Should not reach this code path */
80
                __assume(0);
81
            }
82
#       endif
83
#   elif defined(__GNUC__) && (__GNUC__ >= 4)
84
        return (unsigned)__builtin_clz(val);
85
#   else
86
        return ZSTD_countLeadingZeros32_fallback(val);
87
#   endif
88
4.27M
}
huf_compress.c:ZSTD_countLeadingZeros32
Line
Count
Source
68
56.6M
{
69
56.6M
    assert(val != 0);
70
#   if defined(_MSC_VER)
71
#       if STATIC_BMI2 == 1
72
            return (unsigned)_lzcnt_u32(val);
73
#       else
74
            if (val != 0) {
75
                unsigned long r;
76
                _BitScanReverse(&r, val);
77
                return (unsigned)(31 - r);
78
            } else {
79
                /* Should not reach this code path */
80
                __assume(0);
81
            }
82
#       endif
83
#   elif defined(__GNUC__) && (__GNUC__ >= 4)
84
        return (unsigned)__builtin_clz(val);
85
#   else
86
        return ZSTD_countLeadingZeros32_fallback(val);
87
#   endif
88
56.6M
}
huf_decompress.c:ZSTD_countLeadingZeros32
Line
Count
Source
68
133k
{
69
133k
    assert(val != 0);
70
#   if defined(_MSC_VER)
71
#       if STATIC_BMI2 == 1
72
            return (unsigned)_lzcnt_u32(val);
73
#       else
74
            if (val != 0) {
75
                unsigned long r;
76
                _BitScanReverse(&r, val);
77
                return (unsigned)(31 - r);
78
            } else {
79
                /* Should not reach this code path */
80
                __assume(0);
81
            }
82
#       endif
83
#   elif defined(__GNUC__) && (__GNUC__ >= 4)
84
        return (unsigned)__builtin_clz(val);
85
#   else
86
        return ZSTD_countLeadingZeros32_fallback(val);
87
#   endif
88
133k
}
Unexecuted instantiation: zstd_ddict.c:ZSTD_countLeadingZeros32
89
90
MEM_STATIC unsigned ZSTD_countTrailingZeros64(U64 val)
91
1.95G
{
92
1.95G
    assert(val != 0);
93
#   if defined(_MSC_VER) && defined(_WIN64)
94
#       if STATIC_BMI2 == 1
95
            return (unsigned)_tzcnt_u64(val);
96
#       else
97
            if (val != 0) {
98
                unsigned long r;
99
                _BitScanForward64(&r, val);
100
                return (unsigned)r;
101
            } else {
102
                /* Should not reach this code path */
103
                __assume(0);
104
            }
105
#       endif
106
#   elif defined(__GNUC__) && (__GNUC__ >= 4) && defined(__LP64__)
107
        return (unsigned)__builtin_ctzll(val);
108
#   else
109
        {
110
            U32 mostSignificantWord = (U32)(val >> 32);
111
            U32 leastSignificantWord = (U32)val;
112
            if (leastSignificantWord == 0) {
113
                return 32 + ZSTD_countTrailingZeros32(mostSignificantWord);
114
            } else {
115
                return ZSTD_countTrailingZeros32(leastSignificantWord);
116
            }
117
        }
118
#   endif
119
1.95G
}
Unexecuted instantiation: zstd_common.c:ZSTD_countTrailingZeros64
Unexecuted instantiation: zstd_compress.c:ZSTD_countTrailingZeros64
Unexecuted instantiation: zstd_compress_literals.c:ZSTD_countTrailingZeros64
Unexecuted instantiation: zstd_compress_sequences.c:ZSTD_countTrailingZeros64
Unexecuted instantiation: zstd_compress_superblock.c:ZSTD_countTrailingZeros64
zstd_double_fast.c:ZSTD_countTrailingZeros64
Line
Count
Source
91
5.85M
{
92
5.85M
    assert(val != 0);
93
#   if defined(_MSC_VER) && defined(_WIN64)
94
#       if STATIC_BMI2 == 1
95
            return (unsigned)_tzcnt_u64(val);
96
#       else
97
            if (val != 0) {
98
                unsigned long r;
99
                _BitScanForward64(&r, val);
100
                return (unsigned)r;
101
            } else {
102
                /* Should not reach this code path */
103
                __assume(0);
104
            }
105
#       endif
106
#   elif defined(__GNUC__) && (__GNUC__ >= 4) && defined(__LP64__)
107
        return (unsigned)__builtin_ctzll(val);
108
#   else
109
        {
110
            U32 mostSignificantWord = (U32)(val >> 32);
111
            U32 leastSignificantWord = (U32)val;
112
            if (leastSignificantWord == 0) {
113
                return 32 + ZSTD_countTrailingZeros32(mostSignificantWord);
114
            } else {
115
                return ZSTD_countTrailingZeros32(leastSignificantWord);
116
            }
117
        }
118
#   endif
119
5.85M
}
zstd_fast.c:ZSTD_countTrailingZeros64
Line
Count
Source
91
2.38M
{
92
2.38M
    assert(val != 0);
93
#   if defined(_MSC_VER) && defined(_WIN64)
94
#       if STATIC_BMI2 == 1
95
            return (unsigned)_tzcnt_u64(val);
96
#       else
97
            if (val != 0) {
98
                unsigned long r;
99
                _BitScanForward64(&r, val);
100
                return (unsigned)r;
101
            } else {
102
                /* Should not reach this code path */
103
                __assume(0);
104
            }
105
#       endif
106
#   elif defined(__GNUC__) && (__GNUC__ >= 4) && defined(__LP64__)
107
        return (unsigned)__builtin_ctzll(val);
108
#   else
109
        {
110
            U32 mostSignificantWord = (U32)(val >> 32);
111
            U32 leastSignificantWord = (U32)val;
112
            if (leastSignificantWord == 0) {
113
                return 32 + ZSTD_countTrailingZeros32(mostSignificantWord);
114
            } else {
115
                return ZSTD_countTrailingZeros32(leastSignificantWord);
116
            }
117
        }
118
#   endif
119
2.38M
}
zstd_lazy.c:ZSTD_countTrailingZeros64
Line
Count
Source
91
147M
{
92
147M
    assert(val != 0);
93
#   if defined(_MSC_VER) && defined(_WIN64)
94
#       if STATIC_BMI2 == 1
95
            return (unsigned)_tzcnt_u64(val);
96
#       else
97
            if (val != 0) {
98
                unsigned long r;
99
                _BitScanForward64(&r, val);
100
                return (unsigned)r;
101
            } else {
102
                /* Should not reach this code path */
103
                __assume(0);
104
            }
105
#       endif
106
#   elif defined(__GNUC__) && (__GNUC__ >= 4) && defined(__LP64__)
107
        return (unsigned)__builtin_ctzll(val);
108
#   else
109
        {
110
            U32 mostSignificantWord = (U32)(val >> 32);
111
            U32 leastSignificantWord = (U32)val;
112
            if (leastSignificantWord == 0) {
113
                return 32 + ZSTD_countTrailingZeros32(mostSignificantWord);
114
            } else {
115
                return ZSTD_countTrailingZeros32(leastSignificantWord);
116
            }
117
        }
118
#   endif
119
147M
}
Unexecuted instantiation: zstd_ldm.c:ZSTD_countTrailingZeros64
zstd_opt.c:ZSTD_countTrailingZeros64
Line
Count
Source
91
1.80G
{
92
1.80G
    assert(val != 0);
93
#   if defined(_MSC_VER) && defined(_WIN64)
94
#       if STATIC_BMI2 == 1
95
            return (unsigned)_tzcnt_u64(val);
96
#       else
97
            if (val != 0) {
98
                unsigned long r;
99
                _BitScanForward64(&r, val);
100
                return (unsigned)r;
101
            } else {
102
                /* Should not reach this code path */
103
                __assume(0);
104
            }
105
#       endif
106
#   elif defined(__GNUC__) && (__GNUC__ >= 4) && defined(__LP64__)
107
        return (unsigned)__builtin_ctzll(val);
108
#   else
109
        {
110
            U32 mostSignificantWord = (U32)(val >> 32);
111
            U32 leastSignificantWord = (U32)val;
112
            if (leastSignificantWord == 0) {
113
                return 32 + ZSTD_countTrailingZeros32(mostSignificantWord);
114
            } else {
115
                return ZSTD_countTrailingZeros32(leastSignificantWord);
116
            }
117
        }
118
#   endif
119
1.80G
}
Unexecuted instantiation: zstd_decompress.c:ZSTD_countTrailingZeros64
Unexecuted instantiation: zstd_decompress_block.c:ZSTD_countTrailingZeros64
Unexecuted instantiation: entropy_common.c:ZSTD_countTrailingZeros64
Unexecuted instantiation: fse_decompress.c:ZSTD_countTrailingZeros64
Unexecuted instantiation: fse_compress.c:ZSTD_countTrailingZeros64
Unexecuted instantiation: huf_compress.c:ZSTD_countTrailingZeros64
huf_decompress.c:ZSTD_countTrailingZeros64
Line
Count
Source
91
274k
{
92
274k
    assert(val != 0);
93
#   if defined(_MSC_VER) && defined(_WIN64)
94
#       if STATIC_BMI2 == 1
95
            return (unsigned)_tzcnt_u64(val);
96
#       else
97
            if (val != 0) {
98
                unsigned long r;
99
                _BitScanForward64(&r, val);
100
                return (unsigned)r;
101
            } else {
102
                /* Should not reach this code path */
103
                __assume(0);
104
            }
105
#       endif
106
#   elif defined(__GNUC__) && (__GNUC__ >= 4) && defined(__LP64__)
107
        return (unsigned)__builtin_ctzll(val);
108
#   else
109
        {
110
            U32 mostSignificantWord = (U32)(val >> 32);
111
            U32 leastSignificantWord = (U32)val;
112
            if (leastSignificantWord == 0) {
113
                return 32 + ZSTD_countTrailingZeros32(mostSignificantWord);
114
            } else {
115
                return ZSTD_countTrailingZeros32(leastSignificantWord);
116
            }
117
        }
118
#   endif
119
274k
}
Unexecuted instantiation: zstd_ddict.c:ZSTD_countTrailingZeros64
120
121
MEM_STATIC unsigned ZSTD_countLeadingZeros64(U64 val)
122
0
{
123
0
    assert(val != 0);
124
#   if defined(_MSC_VER) && defined(_WIN64)
125
#       if STATIC_BMI2 == 1
126
            return (unsigned)_lzcnt_u64(val);
127
#       else
128
            if (val != 0) {
129
                unsigned long r;
130
                _BitScanReverse64(&r, val);
131
                return (unsigned)(63 - r);
132
            } else {
133
                /* Should not reach this code path */
134
                __assume(0);
135
            }
136
#       endif
137
#   elif defined(__GNUC__) && (__GNUC__ >= 4)
138
        return (unsigned)(__builtin_clzll(val));
139
#   else
140
        {
141
            U32 mostSignificantWord = (U32)(val >> 32);
142
            U32 leastSignificantWord = (U32)val;
143
            if (mostSignificantWord == 0) {
144
                return 32 + ZSTD_countLeadingZeros32(leastSignificantWord);
145
            } else {
146
                return ZSTD_countLeadingZeros32(mostSignificantWord);
147
            }
148
        }
149
#   endif
150
0
}
Unexecuted instantiation: zstd_common.c:ZSTD_countLeadingZeros64
Unexecuted instantiation: zstd_compress.c:ZSTD_countLeadingZeros64
Unexecuted instantiation: zstd_compress_literals.c:ZSTD_countLeadingZeros64
Unexecuted instantiation: zstd_compress_sequences.c:ZSTD_countLeadingZeros64
Unexecuted instantiation: zstd_compress_superblock.c:ZSTD_countLeadingZeros64
Unexecuted instantiation: zstd_double_fast.c:ZSTD_countLeadingZeros64
Unexecuted instantiation: zstd_fast.c:ZSTD_countLeadingZeros64
Unexecuted instantiation: zstd_lazy.c:ZSTD_countLeadingZeros64
Unexecuted instantiation: zstd_ldm.c:ZSTD_countLeadingZeros64
Unexecuted instantiation: zstd_opt.c:ZSTD_countLeadingZeros64
Unexecuted instantiation: zstd_decompress.c:ZSTD_countLeadingZeros64
Unexecuted instantiation: zstd_decompress_block.c:ZSTD_countLeadingZeros64
Unexecuted instantiation: entropy_common.c:ZSTD_countLeadingZeros64
Unexecuted instantiation: fse_decompress.c:ZSTD_countLeadingZeros64
Unexecuted instantiation: fse_compress.c:ZSTD_countLeadingZeros64
Unexecuted instantiation: huf_compress.c:ZSTD_countLeadingZeros64
Unexecuted instantiation: huf_decompress.c:ZSTD_countLeadingZeros64
Unexecuted instantiation: zstd_ddict.c:ZSTD_countLeadingZeros64
151
152
MEM_STATIC unsigned ZSTD_NbCommonBytes(size_t val)
153
1.86G
{
154
1.86G
    if (MEM_isLittleEndian()) {
155
1.86G
        if (MEM_64bits()) {
156
1.86G
            return ZSTD_countTrailingZeros64((U64)val) >> 3;
157
1.86G
        } else {
158
0
            return ZSTD_countTrailingZeros32((U32)val) >> 3;
159
0
        }
160
1.86G
    } else {  /* Big Endian CPU */
161
0
        if (MEM_64bits()) {
162
0
            return ZSTD_countLeadingZeros64((U64)val) >> 3;
163
0
        } else {
164
0
            return ZSTD_countLeadingZeros32((U32)val) >> 3;
165
0
        }
166
0
    }
167
1.86G
}
Unexecuted instantiation: zstd_common.c:ZSTD_NbCommonBytes
Unexecuted instantiation: zstd_compress.c:ZSTD_NbCommonBytes
Unexecuted instantiation: zstd_compress_literals.c:ZSTD_NbCommonBytes
Unexecuted instantiation: zstd_compress_sequences.c:ZSTD_NbCommonBytes
Unexecuted instantiation: zstd_compress_superblock.c:ZSTD_NbCommonBytes
zstd_double_fast.c:ZSTD_NbCommonBytes
Line
Count
Source
153
5.85M
{
154
5.85M
    if (MEM_isLittleEndian()) {
155
5.85M
        if (MEM_64bits()) {
156
5.85M
            return ZSTD_countTrailingZeros64((U64)val) >> 3;
157
5.85M
        } else {
158
0
            return ZSTD_countTrailingZeros32((U32)val) >> 3;
159
0
        }
160
5.85M
    } else {  /* Big Endian CPU */
161
0
        if (MEM_64bits()) {
162
0
            return ZSTD_countLeadingZeros64((U64)val) >> 3;
163
0
        } else {
164
0
            return ZSTD_countLeadingZeros32((U32)val) >> 3;
165
0
        }
166
0
    }
167
5.85M
}
zstd_fast.c:ZSTD_NbCommonBytes
Line
Count
Source
153
2.38M
{
154
2.38M
    if (MEM_isLittleEndian()) {
155
2.38M
        if (MEM_64bits()) {
156
2.38M
            return ZSTD_countTrailingZeros64((U64)val) >> 3;
157
2.38M
        } else {
158
0
            return ZSTD_countTrailingZeros32((U32)val) >> 3;
159
0
        }
160
2.38M
    } else {  /* Big Endian CPU */
161
0
        if (MEM_64bits()) {
162
0
            return ZSTD_countLeadingZeros64((U64)val) >> 3;
163
0
        } else {
164
0
            return ZSTD_countLeadingZeros32((U32)val) >> 3;
165
0
        }
166
0
    }
167
2.38M
}
zstd_lazy.c:ZSTD_NbCommonBytes
Line
Count
Source
153
60.0M
{
154
60.0M
    if (MEM_isLittleEndian()) {
155
60.0M
        if (MEM_64bits()) {
156
60.0M
            return ZSTD_countTrailingZeros64((U64)val) >> 3;
157
60.0M
        } else {
158
0
            return ZSTD_countTrailingZeros32((U32)val) >> 3;
159
0
        }
160
60.0M
    } else {  /* Big Endian CPU */
161
0
        if (MEM_64bits()) {
162
0
            return ZSTD_countLeadingZeros64((U64)val) >> 3;
163
0
        } else {
164
0
            return ZSTD_countLeadingZeros32((U32)val) >> 3;
165
0
        }
166
0
    }
167
60.0M
}
Unexecuted instantiation: zstd_ldm.c:ZSTD_NbCommonBytes
zstd_opt.c:ZSTD_NbCommonBytes
Line
Count
Source
153
1.80G
{
154
1.80G
    if (MEM_isLittleEndian()) {
155
1.80G
        if (MEM_64bits()) {
156
1.80G
            return ZSTD_countTrailingZeros64((U64)val) >> 3;
157
1.80G
        } else {
158
0
            return ZSTD_countTrailingZeros32((U32)val) >> 3;
159
0
        }
160
1.80G
    } else {  /* Big Endian CPU */
161
0
        if (MEM_64bits()) {
162
0
            return ZSTD_countLeadingZeros64((U64)val) >> 3;
163
0
        } else {
164
0
            return ZSTD_countLeadingZeros32((U32)val) >> 3;
165
0
        }
166
0
    }
167
1.80G
}
Unexecuted instantiation: zstd_decompress.c:ZSTD_NbCommonBytes
Unexecuted instantiation: zstd_decompress_block.c:ZSTD_NbCommonBytes
Unexecuted instantiation: entropy_common.c:ZSTD_NbCommonBytes
Unexecuted instantiation: fse_decompress.c:ZSTD_NbCommonBytes
Unexecuted instantiation: fse_compress.c:ZSTD_NbCommonBytes
Unexecuted instantiation: huf_compress.c:ZSTD_NbCommonBytes
Unexecuted instantiation: huf_decompress.c:ZSTD_NbCommonBytes
Unexecuted instantiation: zstd_ddict.c:ZSTD_NbCommonBytes
168
169
MEM_STATIC unsigned ZSTD_highbit32(U32 val)   /* compress, dictBuilder, decodeCorpus */
170
26.0G
{
171
26.0G
    assert(val != 0);
172
26.0G
    return 31 - ZSTD_countLeadingZeros32(val);
173
26.0G
}
Unexecuted instantiation: zstd_common.c:ZSTD_highbit32
zstd_compress.c:ZSTD_highbit32
Line
Count
Source
170
19.6M
{
171
19.6M
    assert(val != 0);
172
19.6M
    return 31 - ZSTD_countLeadingZeros32(val);
173
19.6M
}
Unexecuted instantiation: zstd_compress_literals.c:ZSTD_highbit32
Unexecuted instantiation: zstd_compress_sequences.c:ZSTD_highbit32
Unexecuted instantiation: zstd_compress_superblock.c:ZSTD_highbit32
Unexecuted instantiation: zstd_double_fast.c:ZSTD_highbit32
Unexecuted instantiation: zstd_fast.c:ZSTD_highbit32
zstd_lazy.c:ZSTD_highbit32
Line
Count
Source
170
39.0M
{
171
39.0M
    assert(val != 0);
172
39.0M
    return 31 - ZSTD_countLeadingZeros32(val);
173
39.0M
}
Unexecuted instantiation: zstd_ldm.c:ZSTD_highbit32
zstd_opt.c:ZSTD_highbit32
Line
Count
Source
170
25.8G
{
171
25.8G
    assert(val != 0);
172
25.8G
    return 31 - ZSTD_countLeadingZeros32(val);
173
25.8G
}
Unexecuted instantiation: zstd_decompress.c:ZSTD_highbit32
zstd_decompress_block.c:ZSTD_highbit32
Line
Count
Source
170
14.7M
{
171
14.7M
    assert(val != 0);
172
14.7M
    return 31 - ZSTD_countLeadingZeros32(val);
173
14.7M
}
entropy_common.c:ZSTD_highbit32
Line
Count
Source
170
596k
{
171
596k
    assert(val != 0);
172
596k
    return 31 - ZSTD_countLeadingZeros32(val);
173
596k
}
fse_decompress.c:ZSTD_highbit32
Line
Count
Source
170
2.66M
{
171
2.66M
    assert(val != 0);
172
2.66M
    return 31 - ZSTD_countLeadingZeros32(val);
173
2.66M
}
fse_compress.c:ZSTD_highbit32
Line
Count
Source
170
4.27M
{
171
4.27M
    assert(val != 0);
172
4.27M
    return 31 - ZSTD_countLeadingZeros32(val);
173
4.27M
}
huf_compress.c:ZSTD_highbit32
Line
Count
Source
170
56.6M
{
171
56.6M
    assert(val != 0);
172
56.6M
    return 31 - ZSTD_countLeadingZeros32(val);
173
56.6M
}
huf_decompress.c:ZSTD_highbit32
Line
Count
Source
170
133k
{
171
133k
    assert(val != 0);
172
133k
    return 31 - ZSTD_countLeadingZeros32(val);
173
133k
}
Unexecuted instantiation: zstd_ddict.c:ZSTD_highbit32
174
175
/* ZSTD_rotateRight_*():
176
 * Rotates a bitfield to the right by "count" bits.
177
 * https://en.wikipedia.org/w/index.php?title=Circular_shift&oldid=991635599#Implementing_circular_shifts
178
 */
179
MEM_STATIC
180
10.4k
U64 ZSTD_rotateRight_U64(U64 const value, U32 count) {
181
10.4k
    assert(count < 64);
182
10.4k
    count &= 0x3F; /* for fickle pattern recognition */
183
10.4k
    return (value >> count) | (U64)(value << ((0U - count) & 0x3F));
184
10.4k
}
Unexecuted instantiation: zstd_common.c:ZSTD_rotateRight_U64
zstd_compress.c:ZSTD_rotateRight_U64
Line
Count
Source
180
10.4k
U64 ZSTD_rotateRight_U64(U64 const value, U32 count) {
181
10.4k
    assert(count < 64);
182
10.4k
    count &= 0x3F; /* for fickle pattern recognition */
183
10.4k
    return (value >> count) | (U64)(value << ((0U - count) & 0x3F));
184
10.4k
}
Unexecuted instantiation: zstd_compress_literals.c:ZSTD_rotateRight_U64
Unexecuted instantiation: zstd_compress_sequences.c:ZSTD_rotateRight_U64
Unexecuted instantiation: zstd_compress_superblock.c:ZSTD_rotateRight_U64
Unexecuted instantiation: zstd_double_fast.c:ZSTD_rotateRight_U64
Unexecuted instantiation: zstd_fast.c:ZSTD_rotateRight_U64
Unexecuted instantiation: zstd_lazy.c:ZSTD_rotateRight_U64
Unexecuted instantiation: zstd_ldm.c:ZSTD_rotateRight_U64
Unexecuted instantiation: zstd_opt.c:ZSTD_rotateRight_U64
Unexecuted instantiation: zstd_decompress.c:ZSTD_rotateRight_U64
Unexecuted instantiation: zstd_decompress_block.c:ZSTD_rotateRight_U64
Unexecuted instantiation: entropy_common.c:ZSTD_rotateRight_U64
Unexecuted instantiation: fse_decompress.c:ZSTD_rotateRight_U64
Unexecuted instantiation: fse_compress.c:ZSTD_rotateRight_U64
Unexecuted instantiation: huf_compress.c:ZSTD_rotateRight_U64
Unexecuted instantiation: huf_decompress.c:ZSTD_rotateRight_U64
Unexecuted instantiation: zstd_ddict.c:ZSTD_rotateRight_U64
185
186
MEM_STATIC
187
9.59M
U32 ZSTD_rotateRight_U32(U32 const value, U32 count) {
188
9.59M
    assert(count < 32);
189
9.59M
    count &= 0x1F; /* for fickle pattern recognition */
190
9.59M
    return (value >> count) | (U32)(value << ((0U - count) & 0x1F));
191
9.59M
}
Unexecuted instantiation: zstd_common.c:ZSTD_rotateRight_U32
Unexecuted instantiation: zstd_compress.c:ZSTD_rotateRight_U32
Unexecuted instantiation: zstd_compress_literals.c:ZSTD_rotateRight_U32
Unexecuted instantiation: zstd_compress_sequences.c:ZSTD_rotateRight_U32
Unexecuted instantiation: zstd_compress_superblock.c:ZSTD_rotateRight_U32
Unexecuted instantiation: zstd_double_fast.c:ZSTD_rotateRight_U32
Unexecuted instantiation: zstd_fast.c:ZSTD_rotateRight_U32
zstd_lazy.c:ZSTD_rotateRight_U32
Line
Count
Source
187
9.59M
U32 ZSTD_rotateRight_U32(U32 const value, U32 count) {
188
9.59M
    assert(count < 32);
189
9.59M
    count &= 0x1F; /* for fickle pattern recognition */
190
9.59M
    return (value >> count) | (U32)(value << ((0U - count) & 0x1F));
191
9.59M
}
Unexecuted instantiation: zstd_ldm.c:ZSTD_rotateRight_U32
Unexecuted instantiation: zstd_opt.c:ZSTD_rotateRight_U32
Unexecuted instantiation: zstd_decompress.c:ZSTD_rotateRight_U32
Unexecuted instantiation: zstd_decompress_block.c:ZSTD_rotateRight_U32
Unexecuted instantiation: entropy_common.c:ZSTD_rotateRight_U32
Unexecuted instantiation: fse_decompress.c:ZSTD_rotateRight_U32
Unexecuted instantiation: fse_compress.c:ZSTD_rotateRight_U32
Unexecuted instantiation: huf_compress.c:ZSTD_rotateRight_U32
Unexecuted instantiation: huf_decompress.c:ZSTD_rotateRight_U32
Unexecuted instantiation: zstd_ddict.c:ZSTD_rotateRight_U32
192
193
MEM_STATIC
194
28.2M
U16 ZSTD_rotateRight_U16(U16 const value, U32 count) {
195
28.2M
    assert(count < 16);
196
28.2M
    count &= 0x0F; /* for fickle pattern recognition */
197
28.2M
    return (value >> count) | (U16)(value << ((0U - count) & 0x0F));
198
28.2M
}
Unexecuted instantiation: zstd_common.c:ZSTD_rotateRight_U16
Unexecuted instantiation: zstd_compress.c:ZSTD_rotateRight_U16
Unexecuted instantiation: zstd_compress_literals.c:ZSTD_rotateRight_U16
Unexecuted instantiation: zstd_compress_sequences.c:ZSTD_rotateRight_U16
Unexecuted instantiation: zstd_compress_superblock.c:ZSTD_rotateRight_U16
Unexecuted instantiation: zstd_double_fast.c:ZSTD_rotateRight_U16
Unexecuted instantiation: zstd_fast.c:ZSTD_rotateRight_U16
zstd_lazy.c:ZSTD_rotateRight_U16
Line
Count
Source
194
28.2M
U16 ZSTD_rotateRight_U16(U16 const value, U32 count) {
195
28.2M
    assert(count < 16);
196
28.2M
    count &= 0x0F; /* for fickle pattern recognition */
197
28.2M
    return (value >> count) | (U16)(value << ((0U - count) & 0x0F));
198
28.2M
}
Unexecuted instantiation: zstd_ldm.c:ZSTD_rotateRight_U16
Unexecuted instantiation: zstd_opt.c:ZSTD_rotateRight_U16
Unexecuted instantiation: zstd_decompress.c:ZSTD_rotateRight_U16
Unexecuted instantiation: zstd_decompress_block.c:ZSTD_rotateRight_U16
Unexecuted instantiation: entropy_common.c:ZSTD_rotateRight_U16
Unexecuted instantiation: fse_decompress.c:ZSTD_rotateRight_U16
Unexecuted instantiation: fse_compress.c:ZSTD_rotateRight_U16
Unexecuted instantiation: huf_compress.c:ZSTD_rotateRight_U16
Unexecuted instantiation: huf_decompress.c:ZSTD_rotateRight_U16
Unexecuted instantiation: zstd_ddict.c:ZSTD_rotateRight_U16
199
200
#endif /* ZSTD_BITS_H */