From: Ben Adams Date: Fri, 25 Jan 2019 16:17:58 +0000 (+0100) Subject: Use AggressiveOptimization for intrinsics-based SpanHelpers (#22191) X-Git-Tag: accepted/tizen/unified/20190813.215958~222 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e0d680101a93797c9e1a049bf582a874e2cb4113;p=platform%2Fupstream%2Fcoreclr.git Use AggressiveOptimization for intrinsics-based SpanHelpers (#22191) * Use AggressiveOptimization for intrinsics-based SpanHelpers * Remove from LastIndexOfAny --- diff --git a/src/System.Private.CoreLib/shared/System/SpanHelpers.Byte.cs b/src/System.Private.CoreLib/shared/System/SpanHelpers.Byte.cs index 3062a40..443c7be 100644 --- a/src/System.Private.CoreLib/shared/System/SpanHelpers.Byte.cs +++ b/src/System.Private.CoreLib/shared/System/SpanHelpers.Byte.cs @@ -101,6 +101,7 @@ namespace System } // Adapted from IndexOf(...) + [MethodImpl(MethodImplOptions.AggressiveOptimization)] public static unsafe bool Contains(ref byte searchSpace, byte value, int length) { Debug.Assert(length >= 0); @@ -190,6 +191,7 @@ namespace System return true; } + [MethodImpl(MethodImplOptions.AggressiveOptimization)] public static unsafe int IndexOf(ref byte searchSpace, byte value, int length) { Debug.Assert(length >= 0); @@ -430,6 +432,7 @@ namespace System return -1; } + [MethodImpl(MethodImplOptions.AggressiveOptimization)] public static unsafe int LastIndexOf(ref byte searchSpace, byte value, int length) { Debug.Assert(length >= 0); @@ -534,6 +537,7 @@ namespace System 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); @@ -765,6 +769,7 @@ namespace System 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); @@ -1265,6 +1270,7 @@ namespace System // 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)) @@ -1335,6 +1341,7 @@ namespace System 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); diff --git a/src/System.Private.CoreLib/shared/System/SpanHelpers.Char.cs b/src/System.Private.CoreLib/shared/System/SpanHelpers.Char.cs index d57944e..b591152 100644 --- a/src/System.Private.CoreLib/shared/System/SpanHelpers.Char.cs +++ b/src/System.Private.CoreLib/shared/System/SpanHelpers.Char.cs @@ -61,6 +61,7 @@ namespace System return -1; } + [MethodImpl(MethodImplOptions.AggressiveOptimization)] public static unsafe int SequenceCompareTo(ref char first, int firstLength, ref char second, int secondLength) { Debug.Assert(firstLength >= 0); @@ -124,6 +125,7 @@ namespace System } // Adapted from IndexOf(...) + [MethodImpl(MethodImplOptions.AggressiveOptimization)] public static unsafe bool Contains(ref char searchSpace, char value, int length) { Debug.Assert(length >= 0); @@ -211,6 +213,7 @@ namespace System } } + [MethodImpl(MethodImplOptions.AggressiveOptimization)] public static unsafe int IndexOf(ref char searchSpace, char value, int length) { Debug.Assert(length >= 0); @@ -304,6 +307,7 @@ namespace System } } + [MethodImpl(MethodImplOptions.AggressiveOptimization)] public static unsafe int IndexOfAny(ref char searchSpace, char value0, char value1, int length) { Debug.Assert(length >= 0); @@ -401,6 +405,7 @@ namespace System } } + [MethodImpl(MethodImplOptions.AggressiveOptimization)] public static unsafe int IndexOfAny(ref char searchSpace, char value0, char value1, char value2, int length) { Debug.Assert(length >= 0); @@ -501,6 +506,7 @@ namespace System } } + [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); @@ -603,6 +609,7 @@ namespace System } } + [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); @@ -708,6 +715,7 @@ namespace System } } + [MethodImpl(MethodImplOptions.AggressiveOptimization)] public static unsafe int LastIndexOf(ref char searchSpace, char value, int length) { Debug.Assert(length >= 0);