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

neon-sunset / U8String / 5994762833

28 Aug 2023 02:06AM UTC coverage: 18.353% (+0.07%) from 18.282%
5994762833

push

github

neon-sunset
perf: minor codegen improvements
- simplify count matches, it seems to give no perf improvement but, as .NET compiler gets better, in the future it might
- optimize various concat cases

134 of 1036 branches covered (0.0%)

Branch coverage included in aggregate %.

9 of 9 new or added lines in 3 files covered. (100.0%)

479 of 2304 relevant lines covered (20.79%)

35734.49 hits per line

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

33.33
/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 lower = mask.GetLower();
×
18
        var upper = mask.GetUpper();
×
19
        var lowerCount = CountMatches(lower);
×
20
        var upperCount = CountMatches(upper);
×
21

22
        return upperCount + lowerCount;
×
23
    }
24

25
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
26
    internal static int CountMatches(this Vector128<byte> mask)
27
    {
28
        // Is there really no way to use AddAcross here?
29
        if (AdvSimd.Arm64.IsSupported)
6!
30
        {
31
            var matches = AdvSimd
×
32
                .ShiftRightLogicalNarrowingLower(mask.AsUInt16(), 4)
×
33
                .AsUInt64()
×
34
                .ToScalar();
×
35
            return BitOperations.PopCount(matches) >> 2;
×
36
        }
37

38
        return BitOperations.PopCount(mask.ExtractMostSignificantBits());
6✔
39
    }
40
}
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