@@ -435,11 +435,11 @@ private static Buffer2DRegion<byte> TrimTransparentPixels(Buffer2D<byte> buffer,
435
435
{
436
436
Vector256 < byte > vec = Vector256 . LoadUnsafe ( ref rowPtr , ( nuint ) x ) ;
437
437
Vector256 < byte > notEquals = ~ Vector256 . Equals ( vec , trimmableVec256 ) ;
438
+ uint mask = notEquals . ExtractMostSignificantBits ( ) ;
438
439
439
- if ( notEquals != Vector256 < byte > . Zero )
440
+ if ( mask != 0 )
440
441
{
441
442
isTransparentRow = false ;
442
- uint mask = notEquals . ExtractMostSignificantBits ( ) ;
443
443
nint start = x + ( nint ) uint . TrailingZeroCount ( mask ) ;
444
444
nint end = ( nint ) uint . LeadingZeroCount ( mask ) ;
445
445
@@ -463,11 +463,11 @@ private static Buffer2DRegion<byte> TrimTransparentPixels(Buffer2D<byte> buffer,
463
463
{
464
464
Vector128 < byte > vec = Vector128 . LoadUnsafe ( ref rowPtr , ( nuint ) x ) ;
465
465
Vector128 < byte > notEquals = ~ Vector128 . Equals ( vec , trimmableVec ) ;
466
+ uint mask = notEquals . ExtractMostSignificantBits ( ) ;
466
467
467
- if ( notEquals != Vector128 < byte > . Zero )
468
+ if ( mask != 0 )
468
469
{
469
470
isTransparentRow = false ;
470
- uint mask = notEquals . ExtractMostSignificantBits ( ) ;
471
471
nint start = x + ( nint ) uint . TrailingZeroCount ( mask ) ;
472
472
nint end = ( nint ) uint . LeadingZeroCount ( mask ) - Vector128 < byte > . Count ;
473
473
@@ -493,11 +493,11 @@ private static Buffer2DRegion<byte> TrimTransparentPixels(Buffer2D<byte> buffer,
493
493
Vector256 < byte > vec = Unsafe . ReadUnaligned < Vector256 < byte > > ( ref Unsafe . Add ( ref rowPtr , x ) ) ;
494
494
Vector256 < byte > notEquals = Avx2 . CompareEqual ( vec , trimmableVec256 ) ;
495
495
notEquals = Avx2 . Xor ( notEquals , Vector256 < byte > . AllBitsSet ) ;
496
+ int mask = Avx2 . MoveMask ( notEquals ) ;
496
497
497
- if ( ! Avx . TestZ ( notEquals , notEquals ) )
498
+ if ( mask != 0 )
498
499
{
499
500
isTransparentRow = false ;
500
- int mask = Avx2 . MoveMask ( notEquals ) ;
501
501
nint start = x + ( nint ) ( uint ) BitOperations . TrailingZeroCount ( mask ) ;
502
502
nint end = ( nint ) ( uint ) BitOperations . LeadingZeroCount ( ( uint ) mask ) ;
503
503
@@ -522,11 +522,11 @@ private static Buffer2DRegion<byte> TrimTransparentPixels(Buffer2D<byte> buffer,
522
522
Vector128 < byte > vec = Unsafe . ReadUnaligned < Vector128 < byte > > ( ref Unsafe . Add ( ref rowPtr , x ) ) ;
523
523
Vector128 < byte > notEquals = Sse2 . CompareEqual ( vec , trimmableVec ) ;
524
524
notEquals = Sse2 . Xor ( notEquals , Vector128 < byte > . AllBitsSet ) ;
525
+ int mask = Sse2 . MoveMask ( notEquals ) ;
525
526
526
- if ( ! Sse41 . TestZ ( notEquals , notEquals ) )
527
+ if ( mask != 0 )
527
528
{
528
529
isTransparentRow = false ;
529
- int mask = Sse2 . MoveMask ( notEquals ) ;
530
530
nint start = x + ( nint ) ( uint ) BitOperations . TrailingZeroCount ( mask ) ;
531
531
nint end = ( nint ) ( uint ) BitOperations . LeadingZeroCount ( ( uint ) mask ) - Vector128 < byte > . Count ;
532
532
0 commit comments