Skip to content

Commit

Permalink
Add AnyMatches() to iSimdVector interface
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepakRajendrakumaran authored and rgesteve committed Mar 20, 2024
1 parent 06062e7 commit 69f09db
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,12 @@ static virtual bool TryCopyTo(TSelf vector, Span<T> destination)
// New Surface Area
//

/// <summary>Checks if the MSB of any of the vector lanes is non zero.</summary>
/// <param name="vector">The vector to check MSB.</param>
/// <returns><c>true</c> if <paramref name="vector" /> has any lanes with a non-zero MSB otherwise, <c>false</c> if MSB is zero for all lanes />.</returns>
/// <exception cref="NotSupportedException">The type of the elements in the vector (<typeparamref name="T" />) is not supported.</exception>
static abstract bool AnyMatches(TSelf vector);

static abstract int IndexOfLastMatch(TSelf vector);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,12 @@ private string ToString([StringSyntax(StringSyntaxAttribute.NumericFormat)] stri
// New Surface Area
//

static bool ISimdVector<Vector128<T>, T>.AnyMatches(Vector128<T> vector)
{
uint mask = vector.ExtractMostSignificantBits();
return (mask != 0);
}

static int ISimdVector<Vector128<T>, T>.IndexOfLastMatch(Vector128<T> vector)
{
uint mask = vector.ExtractMostSignificantBits();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,12 @@ private string ToString([StringSyntax(StringSyntaxAttribute.NumericFormat)] stri
// New Surface Area
//

static bool ISimdVector<Vector256<T>, T>.AnyMatches(Vector256<T> vector)
{
uint mask = vector.ExtractMostSignificantBits();
return (mask != 0);
}

static int ISimdVector<Vector256<T>, T>.IndexOfLastMatch(Vector256<T> vector)
{
uint mask = vector.ExtractMostSignificantBits();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,12 @@ private string ToString([StringSyntax(StringSyntaxAttribute.NumericFormat)] stri
// New Surface Area
//

static bool ISimdVector<Vector512<T>, T>.AnyMatches(Vector512<T> vector)
{
ulong mask = vector.ExtractMostSignificantBits();
return (mask != 0);
}

static int ISimdVector<Vector512<T>, T>.IndexOfLastMatch(Vector512<T> vector)
{
ulong mask = vector.ExtractMostSignificantBits();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,12 @@ private string ToString([StringSyntax(StringSyntaxAttribute.NumericFormat)] stri
// New Surface Area
//

static bool ISimdVector<Vector64<T>, T>.AnyMatches(Vector64<T> vector)
{
uint mask = vector.ExtractMostSignificantBits();
return (mask != 0);
}

static int ISimdVector<Vector64<T>, T>.IndexOfLastMatch(Vector64<T> vector)
{
uint mask = vector.ExtractMostSignificantBits();
Expand Down

0 comments on commit 69f09db

Please sign in to comment.