From 3b2f83395cacc1509453c410850e4f2d7374531d Mon Sep 17 00:00:00 2001 From: Andy Ayers Date: Sat, 21 May 2022 08:06:50 -0700 Subject: [PATCH] Fix IsSupported guard check for use of Ssse3.Shuffle in Span.Reverse (#69623) We were checking for SSE2 support and then using SSSE3 instructions. Fixes #68880. --- .../System.Private.CoreLib/src/System/SpanHelpers.Byte.cs | 2 +- .../System.Private.CoreLib/src/System/SpanHelpers.Char.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Byte.cs b/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Byte.cs index 45523ea650f8..949f315aa8d5 100644 --- a/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Byte.cs +++ b/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Byte.cs @@ -2374,7 +2374,7 @@ public static void Reverse(ref byte buf, nuint length) buf = ref Unsafe.Add(ref buf, numIters * numElements); length -= numIters * numElements * 2; } - else if (Sse2.IsSupported && (nuint)Vector128.Count * 2 <= length) + else if (Ssse3.IsSupported && (nuint)Vector128.Count * 2 <= length) { Vector128 reverseMask = Vector128.Create((byte)15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); nuint numElements = (nuint)Vector128.Count; diff --git a/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs b/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs index 24994c650413..a009dc566404 100644 --- a/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs +++ b/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs @@ -2061,7 +2061,7 @@ public static void Reverse(ref char buf, nuint length) bufByte = ref Unsafe.Add(ref bufByte, numIters * numElements); length -= numIters * (nuint)Vector256.Count * 2; } - else if (Sse2.IsSupported && (nuint)Vector128.Count * 2 <= length) + else if (Ssse3.IsSupported && (nuint)Vector128.Count * 2 <= length) { Vector128 reverseMask = Vector128.Create((byte)14, 15, 12, 13, 10, 11, 8, 9, 6, 7, 4, 5, 2, 3, 0, 1); nuint numElements = (nuint)Vector128.Count;