File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
Ramstack.Globbing/Internal Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -339,17 +339,29 @@ public PathSegmentIterator() =>
339339 var offset = BitOperations . TrailingZeroCount ( _mask ) ;
340340 if ( AdvSimd . IsSupported )
341341 {
342+ //
343+ // On ARM, ExtractMostSignificantBits returns a mask where each bit
344+ // represents one vector element (1 bit per ushort), so offset
345+ // directly corresponds to the element index
346+ //
342347 _last = ( int ) ( _position + ( nint ) ( uint ) offset ) ;
348+
343349 //
344- // Clear the bits for the current separator to process the next position in the mask
350+ // Clear the bits for the current separator
345351 //
346352 _mask &= ~ ( 1u << offset ) ;
347353 }
348354 else
349355 {
356+ //
357+ // On x86, MoveMask (and ExtractMostSignificantBits on byte-based vectors)
358+ // returns a mask where each bit represents one byte (2 bits per ushort),
359+ // so we need to divide offset by 2 to get the actual element index
360+ //
350361 _last = ( int ) ( _position + ( nint ) ( ( uint ) offset >> 1 ) ) ;
362+
351363 //
352- // Clear the bits for the current separator to process the next position in the mask
364+ // Clear the bits for the current separator
353365 //
354366 _mask &= ~ ( 0b_11u << offset ) ;
355367 }
You can’t perform that action at this time.
0 commit comments