@@ -1521,15 +1521,19 @@ private static bool VectorContainsNonAsciiChar(Vector128<byte> asciiVector)
1521
1521
internal static bool VectorContainsNonAsciiChar( Vector128 < ushort > utf16Vector )
1522
1522
{
1523
1523
// 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 )
1527
1525
{
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
+ }
1533
1537
}
1534
1538
else if ( AdvSimd . Arm64 . IsSupported )
1535
1539
{
@@ -1538,13 +1542,11 @@ internal static bool VectorContainsNonAsciiChar(Vector128<ushort> utf16Vector)
1538
1542
Vector128 < ushort > maxChars = AdvSimd. Arm64. MaxPairwise( utf16Vector, utf16Vector ) ;
1539
1543
return ( maxChars . AsUInt64 ( ) . ToScalar ( ) & 0xFF80FF80FF80FF80 ) != 0 ;
1540
1544
}
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;
1548
1550
}
1549
1551
1550
1552
[ MethodImpl( MethodImplOptions. AggressiveInlining) ]
0 commit comments