Skip to content

Commit d21415f

Browse files
committed
remove pragma warning disable IntrinsicsInSystemPrivateCoreLibConditionParsing
1 parent 0b7a129 commit d21415f

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

src/libraries/System.Private.CoreLib/src/System/Text/Ascii.Utility.cs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,15 +1521,19 @@ private static bool VectorContainsNonAsciiChar(Vector128<byte> asciiVector)
15211521
internal static bool VectorContainsNonAsciiChar(Vector128<ushort> utf16Vector)
15221522
{
15231523
// prefer architecture specific intrinsic as they offer better perf
1524-
#pragma warning disable IntrinsicsInSystemPrivateCoreLibConditionParsing // A negated IsSupported condition isn't parseable by the intrinsics analyzer
1525-
if (Sse2.IsSupported && !Sse41.IsSupported)
1526-
#pragma warning restore IntrinsicsInSystemPrivateCoreLibConditionParsing
1524+
if (Sse2.IsSupported)
15271525
{
1528-
Vector128<ushort> asciiMaskForAddSaturate = Vector128.Create((ushort)0x7F80);
1529-
// The operation below forces the 0x8000 bit of each WORD to be set iff the WORD element
1530-
// has value >= 0x0800 (non-ASCII). Then we'll treat the vector as a BYTE vector in order
1531-
// to extract the mask. Reminder: the 0x0080 bit of each WORD should be ignored.
1532-
return (Sse2.MoveMask(Sse2.AddSaturate(utf16Vector, asciiMaskForAddSaturate).AsByte()) & 0b_1010_1010_1010_1010) != 0;
1526+
if (Sse41.IsSupported)
1527+
{
1528+
}
1529+
else
1530+
{
1531+
Vector128<ushort> asciiMaskForAddSaturate = Vector128.Create((ushort)0x7F80);
1532+
// The operation below forces the 0x8000 bit of each WORD to be set iff the WORD element
1533+
// has value >= 0x0800 (non-ASCII). Then we'll treat the vector as a BYTE vector in order
1534+
// to extract the mask. Reminder: the 0x0080 bit of each WORD should be ignored.
1535+
return (Sse2.MoveMask(Sse2.AddSaturate(utf16Vector, asciiMaskForAddSaturate).AsByte()) & 0b_1010_1010_1010_1010) != 0;
1536+
}
15331537
}
15341538
else if (AdvSimd.Arm64.IsSupported)
15351539
{
@@ -1538,13 +1542,11 @@ internal static bool VectorContainsNonAsciiChar(Vector128<ushort> utf16Vector)
15381542
Vector128<ushort> maxChars = AdvSimd.Arm64.MaxPairwise(utf16Vector, utf16Vector);
15391543
return (maxChars.AsUInt64().ToScalar() & 0xFF80FF80FF80FF80) != 0;
15401544
}
1541-
else
1542-
{
1543-
const ushort asciiMask = ushort.MaxValue - 127; // 0xFF80
1544-
Vector128<ushort> zeroIsAscii = utf16Vector & Vector128.Create(asciiMask);
1545-
// If a non-ASCII bit is set in any WORD of the vector, we have seen non-ASCII data.
1546-
return zeroIsAscii != Vector128<ushort>.Zero;
1547-
}
1545+
1546+
const ushort asciiMask = ushort.MaxValue - 127; // 0xFF80
1547+
Vector128<ushort> zeroIsAscii = utf16Vector & Vector128.Create(asciiMask);
1548+
// If a non-ASCII bit is set in any WORD of the vector, we have seen non-ASCII data.
1549+
return zeroIsAscii != Vector128<ushort>.Zero;
15481550
}
15491551

15501552
[MethodImpl(MethodImplOptions.AggressiveInlining)]

0 commit comments

Comments
 (0)