@@ -1352,6 +1352,8 @@ private unsafe static (int utfadjust, int scalaradjust) calculateErrorPathadjust
1352
1352
Vector128 < byte > fourthByte = Vector128 . Create ( ( byte ) ( 0b11110000u - 0x80 ) ) ;
1353
1353
Vector128 < byte > v0f = Vector128 . Create ( ( byte ) 0x0F ) ;
1354
1354
Vector128 < byte > v80 = Vector128 . Create ( ( byte ) 0x80 ) ;
1355
+ Vector128 < byte > fourthByteMinusOne = Vector128 . Create ( ( byte ) ( 0b11110000u - 1 ) ) ;
1356
+ Vector128 < sbyte > largestcont = Vector128 . Create ( ( sbyte ) - 65 ) ; // -65 => 0b10111111
1355
1357
// Performance note: we could process 64 bytes at a time for better speed in some cases.
1356
1358
int start_point = processedLength ;
1357
1359
@@ -1457,15 +1459,15 @@ private unsafe static (int utfadjust, int scalaradjust) calculateErrorPathadjust
1457
1459
return invalidBytePointer ;
1458
1460
}
1459
1461
prevIncomplete = AdvSimd . SubtractSaturate ( currentBlock , maxValue ) ;
1460
- Vector128 < sbyte > largestcont = Vector128 . Create ( ( sbyte ) - 65 ) ; // -65 => 0b10111111
1461
1462
contbytes += - AdvSimd . Arm64 . AddAcross ( AdvSimd . CompareLessThanOrEqual ( Vector128 . AsSByte ( currentBlock ) , largestcont ) ) . ToScalar ( ) ;
1462
-
1463
- // computing n4 is more expensive than we would like:
1464
- Vector128 < byte > fourthByteMinusOne = Vector128 . Create ( ( byte ) ( 0b11110000u - 1 ) ) ;
1465
1463
Vector128 < byte > largerthan0f = AdvSimd . CompareGreaterThan ( currentBlock , fourthByteMinusOne ) ;
1466
- byte n4add = ( byte ) AdvSimd . Arm64 . AddAcross ( largerthan0f ) . ToScalar ( ) ;
1467
- int negn4add = ( int ) ( byte ) - n4add ;
1468
- n4 += negn4add ;
1464
+ ulong n4marker = AdvSimd . Arm64 . MaxAcross ( Vector128 . AsUInt32 ( largerthan0f ) ) . ToScalar ( ) ;
1465
+ if ( n4marker != 0 )
1466
+ {
1467
+ byte n4add = ( byte ) AdvSimd . Arm64 . AddAcross ( largerthan0f ) . ToScalar ( ) ;
1468
+ int negn4add = ( int ) ( byte ) - n4add ;
1469
+ n4 += negn4add ;
1470
+ }
1469
1471
}
1470
1472
}
1471
1473
bool hasIncompete = AdvSimd . Arm64 . MaxAcross ( Vector128 . AsUInt32 ( prevIncomplete ) ) . ToScalar ( ) != 0 ;
0 commit comments