• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

neon-sunset / U8String / 5993769794

27 Aug 2023 11:22PM UTC coverage: 18.282% (-0.08%) from 18.359%
5993769794

push

github

neon-sunset
perf: interleave CountMatches for V128, change runes enumerator to use common CopyTo impl.

134 of 1038 branches covered (0.0%)

Branch coverage included in aggregate %.

17 of 17 new or added lines in 2 files covered. (100.0%)

479 of 2315 relevant lines covered (20.69%)

35564.69 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

19.35
/src/Extensions/VectorExtensions.cs
1
using System.Numerics;
2
using System.Runtime.Intrinsics;
3
using System.Runtime.Intrinsics.Arm;
4

5
namespace U8Primitives;
6

7
internal static class VectorExtensions
8
{
9
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
10
    internal static int CountMatches(this Vector256<byte> mask)
11
    {
12
        if (Vector256.IsHardwareAccelerated)
141!
13
        {
14
            return BitOperations.PopCount(mask.ExtractMostSignificantBits());
141✔
15
        }
16

17
        var upper = mask.GetUpper();
×
18
        var lower = mask.GetLower();
×
19

20
        int upperCount, lowerCount;
21
        if (AdvSimd.Arm64.IsSupported)
×
22
        {
23
            var upperMatches = AdvSimd
×
24
                .ShiftRightLogicalNarrowingLower(upper.AsUInt16(), 4)
×
25
                .AsUInt64();
×
26
            var lowerMatches = AdvSimd
×
27
                .ShiftRightLogicalNarrowingLower(lower.AsUInt16(), 4)
×
28
                .AsUInt64();
×
29
            upperCount = BitOperations.PopCount(upperMatches.ToScalar()) >> 2;
×
30
            lowerCount = BitOperations.PopCount(lowerMatches.ToScalar()) >> 2;
×
31
        }
32
        else
33
        {
34
            var upperMatches = upper.ExtractMostSignificantBits();
×
35
            var lowerMatches = lower.ExtractMostSignificantBits();
×
36
            upperCount = BitOperations.PopCount(upperMatches);
×
37
            lowerCount = BitOperations.PopCount(lowerMatches);
×
38
        }
39

40
        return upperCount + lowerCount;
×
41
    }
42

43
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
44
    internal static int CountMatches(this Vector128<byte> mask)
45
    {
46
        // Is there really no way to use AddAcross here?
47
        if (AdvSimd.Arm64.IsSupported)
6!
48
        {
49
            var matches = AdvSimd
×
50
                .ShiftRightLogicalNarrowingLower(mask.AsUInt16(), 4)
×
51
                .AsUInt64()
×
52
                .ToScalar();
×
53
            return BitOperations.PopCount(matches) >> 2;
×
54
        }
55

56
        return BitOperations.PopCount(mask.ExtractMostSignificantBits());
6✔
57
    }
58
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc