Coverage Report

Created: 2026-03-26 06:31

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
87.8k
{
30
87.8k
    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
87.8k
}
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
87.8k
{
30
87.8k
    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
87.8k
}
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
56.3G
{
69
56.3G
    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.3G
}
Unexecuted instantiation: zstd_common.c:ZSTD_countLeadingZeros32
zstd_compress.c:ZSTD_countLeadingZeros32
Line
Count
Source
68
27.6M
{
69
27.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
27.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
52.1M
{
69
52.1M
    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
52.1M
}
Unexecuted instantiation: zstd_ldm.c:ZSTD_countLeadingZeros32
zstd_opt.c:ZSTD_countLeadingZeros32
Line
Count
Source
68
56.1G
{
69
56.1G
    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.1G
}
Unexecuted instantiation: zstd_decompress.c:ZSTD_countLeadingZeros32
zstd_decompress_block.c:ZSTD_countLeadingZeros32
Line
Count
Source
68
11.6M
{
69
11.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
11.6M
}
entropy_common.c:ZSTD_countLeadingZeros32
Line
Count
Source
68
447k
{
69
447k
    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
447k
}
fse_decompress.c:ZSTD_countLeadingZeros32
Line
Count
Source
68
1.84M
{
69
1.84M
    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
1.84M
}
fse_compress.c:ZSTD_countLeadingZeros32
Line
Count
Source
68
6.74M
{
69
6.74M
    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
6.74M
}
huf_compress.c:ZSTD_countLeadingZeros32
Line
Count
Source
68
92.1M
{
69
92.1M
    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
92.1M
}
huf_decompress.c:ZSTD_countLeadingZeros32
Line
Count
Source
68
96.3k
{
69
96.3k
    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
96.3k
}
Unexecuted instantiation: zstd_ddict.c:ZSTD_countLeadingZeros32
89
90
MEM_STATIC unsigned ZSTD_countTrailingZeros64(U64 val)
91
4.17G
{
92
4.17G
    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
4.17G
}
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
6.90M
{
92
6.90M
    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
6.90M
}
zstd_fast.c:ZSTD_countTrailingZeros64
Line
Count
Source
91
3.04M
{
92
3.04M
    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
3.04M
}
zstd_lazy.c:ZSTD_countTrailingZeros64
Line
Count
Source
91
160M
{
92
160M
    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
160M
}
Unexecuted instantiation: zstd_ldm.c:ZSTD_countTrailingZeros64
zstd_opt.c:ZSTD_countTrailingZeros64
Line
Count
Source
91
4.00G
{
92
4.00G
    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
4.00G
}
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
184k
{
92
184k
    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
184k
}
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
4.08G
{
154
4.08G
    if (MEM_isLittleEndian()) {
155
4.08G
        if (MEM_64bits()) {
156
4.08G
            return ZSTD_countTrailingZeros64((U64)val) >> 3;
157
4.08G
        } else {
158
0
            return ZSTD_countTrailingZeros32((U32)val) >> 3;
159
0
        }
160
4.08G
    } 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
4.08G
}
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
6.90M
{
154
6.90M
    if (MEM_isLittleEndian()) {
155
6.90M
        if (MEM_64bits()) {
156
6.90M
            return ZSTD_countTrailingZeros64((U64)val) >> 3;
157
6.90M
        } else {
158
0
            return ZSTD_countTrailingZeros32((U32)val) >> 3;
159
0
        }
160
6.90M
    } 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
6.90M
}
zstd_fast.c:ZSTD_NbCommonBytes
Line
Count
Source
153
3.04M
{
154
3.04M
    if (MEM_isLittleEndian()) {
155
3.04M
        if (MEM_64bits()) {
156
3.04M
            return ZSTD_countTrailingZeros64((U64)val) >> 3;
157
3.04M
        } else {
158
0
            return ZSTD_countTrailingZeros32((U32)val) >> 3;
159
0
        }
160
3.04M
    } 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
3.04M
}
zstd_lazy.c:ZSTD_NbCommonBytes
Line
Count
Source
153
76.1M
{
154
76.1M
    if (MEM_isLittleEndian()) {
155
76.1M
        if (MEM_64bits()) {
156
76.1M
            return ZSTD_countTrailingZeros64((U64)val) >> 3;
157
76.1M
        } else {
158
0
            return ZSTD_countTrailingZeros32((U32)val) >> 3;
159
0
        }
160
76.1M
    } 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
76.1M
}
Unexecuted instantiation: zstd_ldm.c:ZSTD_NbCommonBytes
zstd_opt.c:ZSTD_NbCommonBytes
Line
Count
Source
153
4.00G
{
154
4.00G
    if (MEM_isLittleEndian()) {
155
4.00G
        if (MEM_64bits()) {
156
4.00G
            return ZSTD_countTrailingZeros64((U64)val) >> 3;
157
4.00G
        } else {
158
0
            return ZSTD_countTrailingZeros32((U32)val) >> 3;
159
0
        }
160
4.00G
    } 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
4.00G
}
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
56.3G
{
171
56.3G
    assert(val != 0);
172
56.3G
    return 31 - ZSTD_countLeadingZeros32(val);
173
56.3G
}
Unexecuted instantiation: zstd_common.c:ZSTD_highbit32
zstd_compress.c:ZSTD_highbit32
Line
Count
Source
170
27.6M
{
171
27.6M
    assert(val != 0);
172
27.6M
    return 31 - ZSTD_countLeadingZeros32(val);
173
27.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
52.1M
{
171
52.1M
    assert(val != 0);
172
52.1M
    return 31 - ZSTD_countLeadingZeros32(val);
173
52.1M
}
Unexecuted instantiation: zstd_ldm.c:ZSTD_highbit32
zstd_opt.c:ZSTD_highbit32
Line
Count
Source
170
56.1G
{
171
56.1G
    assert(val != 0);
172
56.1G
    return 31 - ZSTD_countLeadingZeros32(val);
173
56.1G
}
Unexecuted instantiation: zstd_decompress.c:ZSTD_highbit32
zstd_decompress_block.c:ZSTD_highbit32
Line
Count
Source
170
11.6M
{
171
11.6M
    assert(val != 0);
172
11.6M
    return 31 - ZSTD_countLeadingZeros32(val);
173
11.6M
}
entropy_common.c:ZSTD_highbit32
Line
Count
Source
170
447k
{
171
447k
    assert(val != 0);
172
447k
    return 31 - ZSTD_countLeadingZeros32(val);
173
447k
}
fse_decompress.c:ZSTD_highbit32
Line
Count
Source
170
1.84M
{
171
1.84M
    assert(val != 0);
172
1.84M
    return 31 - ZSTD_countLeadingZeros32(val);
173
1.84M
}
fse_compress.c:ZSTD_highbit32
Line
Count
Source
170
6.74M
{
171
6.74M
    assert(val != 0);
172
6.74M
    return 31 - ZSTD_countLeadingZeros32(val);
173
6.74M
}
huf_compress.c:ZSTD_highbit32
Line
Count
Source
170
92.1M
{
171
92.1M
    assert(val != 0);
172
92.1M
    return 31 - ZSTD_countLeadingZeros32(val);
173
92.1M
}
huf_decompress.c:ZSTD_highbit32
Line
Count
Source
170
96.3k
{
171
96.3k
    assert(val != 0);
172
96.3k
    return 31 - ZSTD_countLeadingZeros32(val);
173
96.3k
}
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
15.0k
U64 ZSTD_rotateRight_U64(U64 const value, U32 count) {
181
15.0k
    assert(count < 64);
182
15.0k
    count &= 0x3F; /* for fickle pattern recognition */
183
15.0k
    return (value >> count) | (U64)(value << ((0U - count) & 0x3F));
184
15.0k
}
Unexecuted instantiation: zstd_common.c:ZSTD_rotateRight_U64
zstd_compress.c:ZSTD_rotateRight_U64
Line
Count
Source
180
15.0k
U64 ZSTD_rotateRight_U64(U64 const value, U32 count) {
181
15.0k
    assert(count < 64);
182
15.0k
    count &= 0x3F; /* for fickle pattern recognition */
183
15.0k
    return (value >> count) | (U64)(value << ((0U - count) & 0x3F));
184
15.0k
}
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.04M
U32 ZSTD_rotateRight_U32(U32 const value, U32 count) {
188
9.04M
    assert(count < 32);
189
9.04M
    count &= 0x1F; /* for fickle pattern recognition */
190
9.04M
    return (value >> count) | (U32)(value << ((0U - count) & 0x1F));
191
9.04M
}
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.04M
U32 ZSTD_rotateRight_U32(U32 const value, U32 count) {
188
9.04M
    assert(count < 32);
189
9.04M
    count &= 0x1F; /* for fickle pattern recognition */
190
9.04M
    return (value >> count) | (U32)(value << ((0U - count) & 0x1F));
191
9.04M
}
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
43.6M
U16 ZSTD_rotateRight_U16(U16 const value, U32 count) {
195
43.6M
    assert(count < 16);
196
43.6M
    count &= 0x0F; /* for fickle pattern recognition */
197
43.6M
    return (value >> count) | (U16)(value << ((0U - count) & 0x0F));
198
43.6M
}
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
43.6M
U16 ZSTD_rotateRight_U16(U16 const value, U32 count) {
195
43.6M
    assert(count < 16);
196
43.6M
    count &= 0x0F; /* for fickle pattern recognition */
197
43.6M
    return (value >> count) | (U16)(value << ((0U - count) & 0x0F));
198
43.6M
}
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 */