Skip to content

Commit

Permalink
Use AggressiveOptimization for intrinsics-based SpanHelpers (dotnet/c…
Browse files Browse the repository at this point in the history
…oreclr#22191)

* Use AggressiveOptimization for intrinsics-based SpanHelpers

* Remove from LastIndexOfAny


Commit migrated from dotnet/coreclr@e0d6801
  • Loading branch information
benaadams authored and jkotas committed Jan 25, 2019
1 parent ee94f2d commit d590522
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public static int LastIndexOfAny(ref byte searchSpace, int searchSpaceLength, re
}

// Adapted from IndexOf(...)
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
public static unsafe bool Contains(ref byte searchSpace, byte value, int length)
{
Debug.Assert(length >= 0);
Expand Down Expand Up @@ -190,6 +191,7 @@ public static unsafe bool Contains(ref byte searchSpace, byte value, int length)
return true;
}

[MethodImpl(MethodImplOptions.AggressiveOptimization)]
public static unsafe int IndexOf(ref byte searchSpace, byte value, int length)
{
Debug.Assert(length >= 0);
Expand Down Expand Up @@ -430,6 +432,7 @@ public static int LastIndexOf(ref byte searchSpace, int searchSpaceLength, ref b
return -1;
}

[MethodImpl(MethodImplOptions.AggressiveOptimization)]
public static unsafe int LastIndexOf(ref byte searchSpace, byte value, int length)
{
Debug.Assert(length >= 0);
Expand Down Expand Up @@ -534,6 +537,7 @@ public static unsafe int LastIndexOf(ref byte searchSpace, byte value, int lengt
return (int)(byte*)(offset + 7);
}

[MethodImpl(MethodImplOptions.AggressiveOptimization)]
public static unsafe int IndexOfAny(ref byte searchSpace, byte value0, byte value1, int length)
{
Debug.Assert(length >= 0);
Expand Down Expand Up @@ -765,6 +769,7 @@ public static unsafe int IndexOfAny(ref byte searchSpace, byte value0, byte valu
return (int)(byte*)(offset + 7);
}

[MethodImpl(MethodImplOptions.AggressiveOptimization)]
public static unsafe int IndexOfAny(ref byte searchSpace, byte value0, byte value1, byte value2, int length)
{
Debug.Assert(length >= 0);
Expand Down Expand Up @@ -1265,6 +1270,7 @@ public static unsafe int LastIndexOfAny(ref byte searchSpace, byte value0, byte

// Optimized byte-based SequenceEquals. The "length" parameter for this one is declared a nuint rather than int as we also use it for types other than byte
// where the length can exceed 2Gb once scaled by sizeof(T).
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
public static unsafe bool SequenceEqual(ref byte first, ref byte second, nuint length)
{
if (Unsafe.AreSame(ref first, ref second))
Expand Down Expand Up @@ -1335,6 +1341,7 @@ private static int LocateFirstFoundByte(Vector<byte> match)
return i * 8 + LocateFirstFoundByte(candidate);
}

[MethodImpl(MethodImplOptions.AggressiveOptimization)]
public static unsafe int SequenceCompareTo(ref byte first, int firstLength, ref byte second, int secondLength)
{
Debug.Assert(firstLength >= 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ ref Unsafe.As<char, byte>(ref valueTail),
return -1;
}

[MethodImpl(MethodImplOptions.AggressiveOptimization)]
public static unsafe int SequenceCompareTo(ref char first, int firstLength, ref char second, int secondLength)
{
Debug.Assert(firstLength >= 0);
Expand Down Expand Up @@ -124,6 +125,7 @@ public static unsafe int SequenceCompareTo(ref char first, int firstLength, ref
}

// Adapted from IndexOf(...)
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
public static unsafe bool Contains(ref char searchSpace, char value, int length)
{
Debug.Assert(length >= 0);
Expand Down Expand Up @@ -211,6 +213,7 @@ public static unsafe bool Contains(ref char searchSpace, char value, int length)
}
}

[MethodImpl(MethodImplOptions.AggressiveOptimization)]
public static unsafe int IndexOf(ref char searchSpace, char value, int length)
{
Debug.Assert(length >= 0);
Expand Down Expand Up @@ -304,6 +307,7 @@ public static unsafe int IndexOf(ref char searchSpace, char value, int length)
}
}

[MethodImpl(MethodImplOptions.AggressiveOptimization)]
public static unsafe int IndexOfAny(ref char searchSpace, char value0, char value1, int length)
{
Debug.Assert(length >= 0);
Expand Down Expand Up @@ -401,6 +405,7 @@ public static unsafe int IndexOfAny(ref char searchSpace, char value0, char valu
}
}

[MethodImpl(MethodImplOptions.AggressiveOptimization)]
public static unsafe int IndexOfAny(ref char searchSpace, char value0, char value1, char value2, int length)
{
Debug.Assert(length >= 0);
Expand Down Expand Up @@ -501,6 +506,7 @@ public static unsafe int IndexOfAny(ref char searchSpace, char value0, char valu
}
}

[MethodImpl(MethodImplOptions.AggressiveOptimization)]
public static unsafe int IndexOfAny(ref char searchSpace, char value0, char value1, char value2, char value3, int length)
{
Debug.Assert(length >= 0);
Expand Down Expand Up @@ -603,6 +609,7 @@ public static unsafe int IndexOfAny(ref char searchSpace, char value0, char valu
}
}

[MethodImpl(MethodImplOptions.AggressiveOptimization)]
public static unsafe int IndexOfAny(ref char searchSpace, char value0, char value1, char value2, char value3, char value4, int length)
{
Debug.Assert(length >= 0);
Expand Down Expand Up @@ -708,6 +715,7 @@ public static unsafe int IndexOfAny(ref char searchSpace, char value0, char valu
}
}

[MethodImpl(MethodImplOptions.AggressiveOptimization)]
public static unsafe int LastIndexOf(ref char searchSpace, char value, int length)
{
Debug.Assert(length >= 0);
Expand Down

0 comments on commit d590522

Please sign in to comment.