File tree Expand file tree Collapse file tree 1 file changed +1
-10
lines changed
Expand file tree Collapse file tree 1 file changed +1
-10
lines changed Original file line number Diff line number Diff line change @@ -671,16 +671,7 @@ public unsafe static (int utfadjust, int scalaradjust) calculateErrorPathadjust(
671671 contbytes += tempcont ;
672672 }
673673
674- // We update the continuation bytes count using just one SIMD instruction (Avx2.CompareGreaterThan).
675- // Then we need popcount to count the number of continuation bytes and some arithmetic operations.
676- // We use the fact that as two's complement, -65 is 0b10111111, so we can use CompareGreaterThan
677- // to find continuation bytes: any byte greater than -65 is a not continuation byte. E.g., the next one
678- // is 0b11111110 (-64) and so forth. The smallest possible value is -128, which is 0b10000000.
679-
680- Vector256 < sbyte > largestcont = Vector256 . Create ( ( sbyte ) - 65 ) ; // -65 => 0b10111111
681- uint noncont = ( uint ) Avx2 . MoveMask ( Avx2 . CompareGreaterThan ( Vector256 . AsSByte ( currentBlock ) , largestcont ) ) ;
682- contbytes += ( int ) ( 32 - Popcnt . PopCount ( noncont ) ) ;
683-
674+ contbytes += ( int ) Popcnt . PopCount ( ( uint ) Avx2 . MoveMask ( byte_2_high ) ) ;
684675 // We use two instructions (SubtractSaturate and MoveMask) to update n4, with one arithmetic operation.
685676 n4 += ( int ) Popcnt . PopCount ( ( uint ) Avx2 . MoveMask ( Avx2 . SubtractSaturate ( currentBlock , fourthByte ) ) ) ;
686677 }
You can’t perform that action at this time.
0 commit comments