Skip to content

IndexOfAnyInRange with invalid ranges behaves differently depending on hardware #123364

@vcsjones

Description

@vcsjones

Consider the following application:

using System;

class Program
{
    static void Main()
    {
        ReadOnlySpan<byte> data = [50];
        byte lowInclusive = 200;
        byte highInclusive = 100;

        int idx = data.IndexOfAnyInRange(lowInclusive, highInclusive);
        Console.WriteLine(idx);
    }
}

On an Apple M1 processor (and maybe other architectures), this will behave differently depending on if hardware intrinsics are available, or not.

Regularly:

❯ dotnet run                           
0

With intrinsics disabled:

❯ DOTNET_EnableHWIntrinsic=0 dotnet run
-1

Since this is not a "low level" SIMD API, I think it would be ideal if the invalid ranges produced consistent results (or threw an exception, but that is perhaps a breaking change).

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions