566 references to BitOperations
GenerateDocumentationAndConfigFiles (2)
src\roslyn\src\Dependencies\Collections\Internal\ArraySortHelper.cs (1)
1269return BitOperations.Log2(value);
src\roslyn\src\Dependencies\Collections\Internal\SegmentedArrayHelper.cs (1)
175return System.Numerics.BitOperations.Log2((uint)((Threshold / elementSize) - (2 * Unsafe.SizeOf<object>() + 8)));
ILCompiler.Compiler (19)
Compiler\ObjectWriter\Eabi\EabiUnwindConverter.cs (5)
212int bitRunLength = BitOperations.TrailingZeroCount(~r5AndHigher); 262int leadingZeros = BitOperations.LeadingZeroCount(mask); 263int bitRunLength = BitOperations.LeadingZeroCount(~(mask << leadingZeros)); 275int leadingZeros = BitOperations.LeadingZeroCount(mask); 276int bitRunLength = BitOperations.LeadingZeroCount(~(mask << leadingZeros));
src\runtime\src\coreclr\tools\Common\Compiler\ObjectWriter\CoffObjectWriter.cs (2)
164Debug.Assert(alignment > 0 && BitOperations.IsPow2((uint)alignment)); 165int minimumAlignment = (BitOperations.Log2((uint)alignment) + 1) << 20;
src\runtime\src\coreclr\tools\Common\Compiler\ObjectWriter\Dwarf\DwarfHelper.cs (2)
18uint x = 6 + 64 - (uint)BitOperations.LeadingZeroCount(value | 1UL); 27uint x = 1 + 6 + 64 - (uint)BitOperations.LeadingZeroCount((ulong)(value ^ (value >> 63)) | 1UL);
src\runtime\src\coreclr\tools\Common\Compiler\ObjectWriter\MachObjectWriter.cs (2)
391Debug.Assert(BitOperations.IsPow2(alignment)); 392machSection.Log2Alignment = Math.Max(machSection.Log2Alignment, (uint)BitOperations.Log2((uint)alignment));
src\runtime\src\coreclr\tools\Common\Internal\Text\Utf8String.cs (5)
58hash = (hash + BitOperations.RotateLeft(hash, 5)) ^ *(uint*)a; 63hash = (hash + BitOperations.RotateLeft(hash, 5)) ^ *(ushort*)a; 68hash = (hash + BitOperations.RotateLeft(hash, 5)) ^ *a; 70hash += BitOperations.RotateLeft(hash, 7); 71hash += BitOperations.RotateLeft(hash, 15);
src\runtime\src\coreclr\tools\Common\TypeSystem\Interop\UnmanagedCallingConventions.cs (1)
229int count = ((convention != platformDefault) ? 1 : 0) + BitOperations.PopCount((uint)modifiers);
src\runtime\src\libraries\Common\src\Internal\VersionResilientHashCode.cs (2)
171return (int)BitOperations.RotateLeft((uint)value, bitCount); 183return (BitOperations.RotateLeft((hash + queuedValue * 3266489917U/*Prime3*/), 17)) * 668265263U/*Prime4*/;
ILCompiler.MetadataTransform (1)
src\runtime\src\coreclr\tools\Common\Internal\NativeFormat\NativeFormatWriter.cs (1)
1923return (sizeof(uint) * 8) - BitOperations.LeadingZeroCount(x);
ILCompiler.ReadyToRun (21)
Compiler\DependencyAnalysis\ReadyToRun\AttributePresenceFilterNode.cs (2)
295uint result = BitOperations.RotateLeft(s[1] * 5, 7) * 9; 304s[3] = BitOperations.RotateLeft(s[3], 11);
Compiler\DependencyAnalysis\ReadyToRun\DebugInfoTableNode.cs (2)
161int bitWidthForNativeDelta = Math.Max(1, 32 - System.Numerics.BitOperations.LeadingZeroCount(maxNativeDelta)); 162int bitWidthForILOffset = Math.Max(1, 32 - System.Numerics.BitOperations.LeadingZeroCount(maxILValue));
src\runtime\src\coreclr\tools\Common\Compiler\ObjectWriter\CoffObjectWriter.cs (2)
164Debug.Assert(alignment > 0 && BitOperations.IsPow2((uint)alignment)); 165int minimumAlignment = (BitOperations.Log2((uint)alignment) + 1) << 20;
src\runtime\src\coreclr\tools\Common\Compiler\ObjectWriter\Dwarf\DwarfHelper.cs (2)
18uint x = 6 + 64 - (uint)BitOperations.LeadingZeroCount(value | 1UL); 27uint x = 1 + 6 + 64 - (uint)BitOperations.LeadingZeroCount((ulong)(value ^ (value >> 63)) | 1UL);
src\runtime\src\coreclr\tools\Common\Compiler\ObjectWriter\MachObjectWriter.cs (2)
391Debug.Assert(BitOperations.IsPow2(alignment)); 392machSection.Log2Alignment = Math.Max(machSection.Log2Alignment, (uint)BitOperations.Log2((uint)alignment));
src\runtime\src\coreclr\tools\Common\Compiler\ObjectWriter\WebCilObjectWriter.cs (2)
202Debug.Assert(BitOperations.IsPow2(webcilSection.MinAlignment) && BitOperations.IsPow2(WebcilSectionAlignment) &&
src\runtime\src\coreclr\tools\Common\Internal\NativeFormat\NativeFormatWriter.cs (1)
1923return (sizeof(uint) * 8) - BitOperations.LeadingZeroCount(x);
src\runtime\src\coreclr\tools\Common\Internal\Text\Utf8String.cs (5)
58hash = (hash + BitOperations.RotateLeft(hash, 5)) ^ *(uint*)a; 63hash = (hash + BitOperations.RotateLeft(hash, 5)) ^ *(ushort*)a; 68hash = (hash + BitOperations.RotateLeft(hash, 5)) ^ *a; 70hash += BitOperations.RotateLeft(hash, 7); 71hash += BitOperations.RotateLeft(hash, 15);
src\runtime\src\coreclr\tools\Common\TypeSystem\Interop\UnmanagedCallingConventions.cs (1)
229int count = ((convention != platformDefault) ? 1 : 0) + BitOperations.PopCount((uint)modifiers);
src\runtime\src\libraries\Common\src\Internal\VersionResilientHashCode.cs (2)
171return (int)BitOperations.RotateLeft((uint)value, bitCount); 183return (BitOperations.RotateLeft((hash + queuedValue * 3266489917U/*Prime3*/), 17)) * 668265263U/*Prime4*/;
ILCompiler.TypeSystem (2)
src\runtime\src\libraries\Common\src\Internal\VersionResilientHashCode.cs (2)
171return (int)BitOperations.RotateLeft((uint)value, bitCount); 183return (BitOperations.RotateLeft((hash + queuedValue * 3266489917U/*Prime3*/), 17)) * 668265263U/*Prime4*/;
Microsoft.AspNetCore.Antiforgery (1)
src\aspnetcore\src\Shared\Encoding\Int7BitEncodingUtils.cs (1)
17return ((31 - System.Numerics.BitOperations.LeadingZeroCount(value | 1)) / 7) + 1;
Microsoft.AspNetCore.DataProtection (1)
src\aspnetcore\src\Shared\Encoding\Int7BitEncodingUtils.cs (1)
17return ((31 - System.Numerics.BitOperations.LeadingZeroCount(value | 1)) / 7) + 1;
Microsoft.AspNetCore.HttpLogging (17)
W3CLoggingMiddleware.cs (17)
25internal static readonly int _dateIndex = BitOperations.Log2((int)W3CLoggingFields.Date); 26internal static readonly int _timeIndex = BitOperations.Log2((int)W3CLoggingFields.Time); 27internal static readonly int _clientIpIndex = BitOperations.Log2((int)W3CLoggingFields.ClientIpAddress); 28internal static readonly int _userNameIndex = BitOperations.Log2((int)W3CLoggingFields.UserName); 29internal static readonly int _serverNameIndex = BitOperations.Log2((int)W3CLoggingFields.ServerName); 30internal static readonly int _serverIpIndex = BitOperations.Log2((int)W3CLoggingFields.ServerIpAddress); 31internal static readonly int _serverPortIndex = BitOperations.Log2((int)W3CLoggingFields.ServerPort); 32internal static readonly int _methodIndex = BitOperations.Log2((int)W3CLoggingFields.Method); 33internal static readonly int _uriStemIndex = BitOperations.Log2((int)W3CLoggingFields.UriStem); 34internal static readonly int _uriQueryIndex = BitOperations.Log2((int)W3CLoggingFields.UriQuery); 35internal static readonly int _protocolStatusIndex = BitOperations.Log2((int)W3CLoggingFields.ProtocolStatus); 36internal static readonly int _timeTakenIndex = BitOperations.Log2((int)W3CLoggingFields.TimeTaken); 37internal static readonly int _protocolVersionIndex = BitOperations.Log2((int)W3CLoggingFields.ProtocolVersion); 38internal static readonly int _hostIndex = BitOperations.Log2((int)W3CLoggingFields.Host); 39internal static readonly int _userAgentIndex = BitOperations.Log2((int)W3CLoggingFields.UserAgent); 40internal static readonly int _cookieIndex = BitOperations.Log2((int)W3CLoggingFields.Cookie); 41internal static readonly int _refererIndex = BitOperations.Log2((int)W3CLoggingFields.Referer);
Microsoft.AspNetCore.Server.Kestrel.Core (22)
Internal\Http\HttpHeaders.Generated.cs (17)
2586return (_contentLength.HasValue ? 1 : 0 ) + BitOperations.PopCount((ulong)_bits) + (MaybeUnknown?.Count ?? 0); 8664_next = BitOperations.TrailingZeroCount(_currentBits); 8678? BitOperations.TrailingZeroCount(bits) 10872return (_contentLength.HasValue ? 1 : 0 ) + BitOperations.PopCount((ulong)_bits) + (MaybeUnknown?.Count ?? 0); 14053if(BitOperations.PopCount((ulong)tempBits) > 12) 14813var next = BitOperations.TrailingZeroCount(tempBits); 14840next = BitOperations.TrailingZeroCount(tempBits); 14866next = BitOperations.TrailingZeroCount(tempBits); 14885next = BitOperations.TrailingZeroCount(tempBits); 14967next = BitOperations.TrailingZeroCount(tempBits); 15112next = BitOperations.TrailingZeroCount(tempBits); 15192next = BitOperations.TrailingZeroCount(tempBits); 15500_next = BitOperations.TrailingZeroCount(_currentBits); 15514? BitOperations.TrailingZeroCount(bits) 17169return (_contentLength.HasValue ? 1 : 0 ) + BitOperations.PopCount((ulong)_bits) + (MaybeUnknown?.Count ?? 0); 17486if(BitOperations.PopCount((ulong)tempBits) > 12) 17621_next = BitOperations.TrailingZeroCount(_currentBits);
Internal\Http\HttpResponseTrailers.cs (2)
63_next = _currentBits != 0 ? BitOperations.TrailingZeroCount(_currentBits) : -1; 85_next = _currentBits != 0 ? BitOperations.TrailingZeroCount(_currentBits) : -1;
src\aspnetcore\src\Shared\runtime\Http2\Hpack\HPackDecoder.cs (1)
319switch (BitOperations.LeadingZeroCount(b) - 24) // byte 'b' is extended to uint, so will have 24 extra 0s.
src\aspnetcore\src\Shared\runtime\Http2\Hpack\IntegerDecoder.cs (1)
71if (BitOperations.LeadingZeroCount((uint)b) <= _m)
src\aspnetcore\src\Shared\runtime\Http3\QPack\QPackDecoder.cs (1)
434switch (BitOperations.LeadingZeroCount(b) - 24) // byte 'b' is extended to uint, so will have 24 extra 0s.
Microsoft.Build (2)
src\msbuild\artifacts\.packages\microsoft.codeanalysis.collections\5.0.0-1.25277.114\contentFiles\cs\net9.0\Internal\ArraySortHelper.cs (1)
1269return BitOperations.Log2(value);
src\msbuild\artifacts\.packages\microsoft.codeanalysis.collections\5.0.0-1.25277.114\contentFiles\cs\net9.0\Internal\SegmentedArrayHelper.cs (1)
175return System.Numerics.BitOperations.Log2((uint)((Threshold / elementSize) - (2 * Unsafe.SizeOf<object>() + 8)));
Microsoft.CodeAnalysis (2)
src\roslyn\src\Dependencies\Collections\Internal\ArraySortHelper.cs (1)
1269return BitOperations.Log2(value);
src\roslyn\src\Dependencies\Collections\Internal\SegmentedArrayHelper.cs (1)
175return System.Numerics.BitOperations.Log2((uint)((Threshold / elementSize) - (2 * Unsafe.SizeOf<object>() + 8)));
Microsoft.CodeAnalysis.Workspaces (2)
src\roslyn\src\Dependencies\Collections\Internal\ArraySortHelper.cs (1)
1269return BitOperations.Log2(value);
src\roslyn\src\Dependencies\Collections\Internal\SegmentedArrayHelper.cs (1)
175return System.Numerics.BitOperations.Log2((uint)((Threshold / elementSize) - (2 * Unsafe.SizeOf<object>() + 8)));
Microsoft.Diagnostics.DataContractReader.Contracts (4)
Contracts\GCInfo\GCInfoDecoder.cs (1)
1269return (uint)(63 - BitOperations.LeadingZeroCount(value));
Contracts\GCInfo\X86\GCInfo.cs (1)
449return (uint)System.Numerics.BitOperations.Log2((uint)reg);
src\runtime\src\coreclr\tools\Common\Compiler\ObjectWriter\Dwarf\DwarfHelper.cs (2)
18uint x = 6 + 64 - (uint)BitOperations.LeadingZeroCount(value | 1UL); 27uint x = 1 + 6 + 64 - (uint)BitOperations.LeadingZeroCount((ulong)(value ^ (value >> 63)) | 1UL);
Microsoft.NET.StringTools (1)
InternableString.cs (1)
391return System.Numerics.BitOperations.RotateLeft(value, offset);
System.Collections (1)
System\Collections\Generic\SortedSet.cs (1)
2011private static int Log2(int value) => BitOperations.Log2((uint)value);
System.Collections.Immutable (22)
System\Collections\Frozen\String\Hashing.cs (22)
36hash2 = (BitOperations.RotateLeft(Hash1Start, 5) + Hash1Start) ^ src[0]; 40hash2 = (BitOperations.RotateLeft(Hash1Start, 5) + Hash1Start) ^ src[0]; 41hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ src[1]; 45hash2 = (BitOperations.RotateLeft(Hash1Start, 5) + Hash1Start) ^ src[0]; 46hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ src[1]; 47hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ src[2]; 51hash1 = (BitOperations.RotateLeft(Hash1Start, 5) + Hash1Start) ^ Unsafe.ReadUnaligned<uint>(src); 52hash2 = (BitOperations.RotateLeft(Hash1Start, 5) + Hash1Start) ^ Unsafe.ReadUnaligned<uint>(src + 2); 62hash1 = (BitOperations.RotateLeft(hash1, 5) + hash1) ^ Unsafe.ReadUnaligned<uint>(ptr); 63hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ Unsafe.ReadUnaligned<uint>(ptr + 2); 70hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ *ptr++; 99hash2 = (BitOperations.RotateLeft(Hash1Start, 5) + Hash1Start) ^ (src[0] | LowercaseChar); 103hash2 = (BitOperations.RotateLeft(Hash1Start, 5) + Hash1Start) ^ (src[0] | LowercaseChar); 104hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ (src[1] | LowercaseChar); 108hash2 = (BitOperations.RotateLeft(Hash1Start, 5) + Hash1Start) ^ (src[0] | LowercaseChar); 109hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ (src[1] | LowercaseChar); 110hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ (src[2] | LowercaseChar); 114hash1 = (BitOperations.RotateLeft(Hash1Start, 5) + Hash1Start) ^ (Unsafe.ReadUnaligned<uint>(src) | LowercaseUInt32); 115hash2 = (BitOperations.RotateLeft(Hash1Start, 5) + Hash1Start) ^ (Unsafe.ReadUnaligned<uint>(src + 2) | LowercaseUInt32); 125hash1 = (BitOperations.RotateLeft(hash1, 5) + hash1) ^ (Unsafe.ReadUnaligned<uint>(ptr) | LowercaseUInt32); 126hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ (Unsafe.ReadUnaligned<uint>(ptr + 2) | LowercaseUInt32); 133hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ (*ptr | LowercaseUInt32);
System.Collections.Specialized (2)
System\Collections\Specialized\BitVector32.cs (2)
141short offset = (short)(priorOffset + BitOperations.PopCount((uint)(ushort)priorMask)); 147short mask = (short)(BitOperations.RoundUpToPowerOf2((uint)(ushort)maxValue + 1) - 1);
System.Diagnostics.DiagnosticSource (1)
System\Diagnostics\Metrics\Base2ExponentialHistogramAggregator.cs (1)
255exp -= BitOperations.LeadingZeroCount((ulong)(fraction - 1)) - 12 /* 64 - fraction width */;
System.IO.Hashing (18)
System\IO\Hashing\XxHash128.cs (1)
266uint combinedh = BitOperations.RotateLeft(BinaryPrimitives.ReverseEndianness(combinedl), 13);
System\IO\Hashing\XxHash32.State.cs (7)
54BitOperations.RotateLeft(_acc1, 1) + 55BitOperations.RotateLeft(_acc2, 7) + 56BitOperations.RotateLeft(_acc3, 12) + 57BitOperations.RotateLeft(_acc4, 18); 63acc = BitOperations.RotateLeft(acc, 13); 79acc = BitOperations.RotateLeft(acc, 17); 89acc = BitOperations.RotateLeft(acc, 11);
System\IO\Hashing\XxHash64.State.cs (8)
73BitOperations.RotateLeft(_acc1, 1) + 74BitOperations.RotateLeft(_acc2, 7) + 75BitOperations.RotateLeft(_acc3, 12) + 76BitOperations.RotateLeft(_acc4, 18); 94acc = BitOperations.RotateLeft(acc, 31); 114acc = BitOperations.RotateLeft(acc, 27); 126acc = BitOperations.RotateLeft(acc, 23); 137acc = BitOperations.RotateLeft(acc, 11);
System\IO\Hashing\XxHashShared.cs (2)
196hash ^= BitOperations.RotateLeft(hash, 49) ^ BitOperations.RotateLeft(hash, 24);
System.Linq.Expressions (1)
System\Dynamic\Utils\CacheDict.cs (1)
44int alignedSize = (int)BitOperations.RoundUpToPowerOf2((uint)size);
System.Net.Http (3)
src\runtime\src\libraries\Common\src\System\Net\Http\aspnetcore\Http2\Hpack\HPackDecoder.cs (1)
319switch (BitOperations.LeadingZeroCount(b) - 24) // byte 'b' is extended to uint, so will have 24 extra 0s.
src\runtime\src\libraries\Common\src\System\Net\Http\aspnetcore\Http2\Hpack\IntegerDecoder.cs (1)
71if (BitOperations.LeadingZeroCount((uint)b) <= _m)
src\runtime\src\libraries\Common\src\System\Net\Http\aspnetcore\Http3\QPack\QPackDecoder.cs (1)
434switch (BitOperations.LeadingZeroCount(b) - 24) // byte 'b' is extended to uint, so will have 24 extra 0s.
System.Net.Security (3)
src\runtime\src\libraries\Common\src\System\Net\Security\MD4.cs (3)
158a = BitOperations.RotateLeft(a, s); 164a = BitOperations.RotateLeft(a, s); 170a = BitOperations.RotateLeft(a, s);
System.Net.WebSockets (2)
System\Net\WebSockets\ManagedWebSocket.cs (2)
1693(int)BitOperations.RotateRight((uint)mask, maskIndex * 8) : 1694(int)BitOperations.RotateLeft((uint)mask, maskIndex * 8);
System.Numerics.Tensors (9)
System\Numerics\Tensors\netcore\TensorPrimitives.HammingDistance.cs (6)
91count += BitOperations.PopCount((~Vector512.Equals(xVec, yVec)).ExtractMostSignificantBits()); 107count += BitOperations.PopCount((~Vector512.Equals(xVec, yVec)).ExtractMostSignificantBits()); 123count += BitOperations.PopCount((~Vector256.Equals(xVec, yVec)).ExtractMostSignificantBits()); 139count += BitOperations.PopCount((~Vector256.Equals(xVec, yVec)).ExtractMostSignificantBits()); 156count += BitOperations.PopCount((~Vector128.Equals(xVec, yVec)).ExtractMostSignificantBits()); 172count += BitOperations.PopCount((~Vector128.Equals(xVec, yVec)).ExtractMostSignificantBits());
System\Numerics\Tensors\netcore\TensorPrimitives.IndexOfMax.cs (3)
93BitOperations.TrailingZeroCount(mask.ExtractMostSignificantBits()); 96BitOperations.TrailingZeroCount(mask.ExtractMostSignificantBits()); 99BitOperations.TrailingZeroCount(mask.ExtractMostSignificantBits());
System.Private.CoreLib (349)
src\runtime\src\coreclr\nativeaot\Runtime.Base\src\System\Runtime\CachedInterfaceDispatch.cs (1)
54IntPtr context = (IntPtr)System.Numerics.BitOperations.RotateLeft((nuint)_dispatchCell, 16);
src\runtime\src\libraries\Common\src\System\Sha1ForNonSecretPurposes.cs (9)
180w[i] = BitOperations.RotateLeft(w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16], 1); 193uint temp = BitOperations.RotateLeft(a, 5) + f + e + k + w[i]; e = d; d = c; c = BitOperations.RotateLeft(b, 30); b = a; a = temp; 200uint temp = BitOperations.RotateLeft(a, 5) + f + e + k + w[i]; e = d; d = c; c = BitOperations.RotateLeft(b, 30); b = a; a = temp; 207uint temp = BitOperations.RotateLeft(a, 5) + f + e + k + w[i]; e = d; d = c; c = BitOperations.RotateLeft(b, 30); b = a; a = temp; 214uint temp = BitOperations.RotateLeft(a, 5) + f + e + k + w[i]; e = d; d = c; c = BitOperations.RotateLeft(b, 30); b = a; a = temp;
src\runtime\src\libraries\System.Private.CoreLib\src\System\Array.cs (2)
2704IntroSort(left, length + left - 1, 2 * (BitOperations.Log2((uint)length) + 1)); 2917IntroSort(left, length + left - 1, 2 * (BitOperations.Log2((uint)length) + 1));
src\runtime\src\libraries\System.Private.CoreLib\src\System\Buffers\Binary\BinaryPrimitives.ReverseEndianness.cs (2)
150return BitOperations.RotateRight(value & 0x00FF00FFu, 8) // xx zz 151+ BitOperations.RotateLeft(value & 0xFF00FF00u, 8); // ww yy
src\runtime\src\libraries\System.Private.CoreLib\src\System\Buffers\Text\FormattingHelpers.CountDigits.cs (1)
112return (BitOperations.Log2(value) >> 2) + 1;
src\runtime\src\libraries\System.Private.CoreLib\src\System\Buffers\Utilities.cs (1)
20return BitOperations.Log2((uint)bufferSize - 1 | 15) - 3;
src\runtime\src\libraries\System.Private.CoreLib\src\System\Byte.cs (5)
276public static byte LeadingZeroCount(byte value) => (byte)(BitOperations.LeadingZeroCount(value) - 24); 282public static byte PopCount(byte value) => (byte)BitOperations.PopCount(value); 291public static byte TrailingZeroCount(byte value) => (byte)(BitOperations.TrailingZeroCount(value << 24) - 24); 407public static bool IsPow2(byte value) => BitOperations.IsPow2((uint)value); 410public static byte Log2(byte value) => (byte)BitOperations.Log2(value);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Char.cs (3)
1230static char IBinaryInteger<char>.LeadingZeroCount(char value) => (char)(BitOperations.LeadingZeroCount(value) - 16); 1236static char IBinaryInteger<char>.PopCount(char value) => (char)BitOperations.PopCount(value); 1245static char IBinaryInteger<char>.TrailingZeroCount(char value) => (char)(BitOperations.TrailingZeroCount(value << 16) - 16);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Collections\Concurrent\ConcurrentQueue.cs (1)
97length = (int)Math.Min(BitOperations.RoundUpToPowerOf2((uint)count), MaxSegmentLength);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Collections\Concurrent\ConcurrentQueueSegment.cs (1)
49Debug.Assert(BitOperations.IsPow2(boundedLength), $"Must be a power of 2, got {boundedLength}");
src\runtime\src\libraries\System.Private.CoreLib\src\System\Collections\Generic\ArraySortHelper.cs (6)
127IntroSort(keys, 2 * (BitOperations.Log2((uint)keys.Length) + 1), comparer); 306IntroSort(keys, 2 * (BitOperations.Log2((uint)keys.Length) + 1)); 673IntroSort(keys, values, 2 * (BitOperations.Log2((uint)keys.Length) + 1), comparer); 858IntroSort(keys, values, 2 * (BitOperations.Log2((uint)keys.Length) + 1)); 1196IntroSort(keys, 2 * (BitOperations.Log2((uint)keys.Length) + 1), comparer); 1411IntroSort(keys, values, 2 * (BitOperations.Log2((uint)keys.Length) + 1), comparer);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Decimal.DecCalc.cs (5)
613newScale -= BitOperations.LeadingZeroCount(result[hiRes]); 1647int trailingZeros = BitOperations.TrailingZeroCount(significand); 1660int significandBits = 64 - BitOperations.LeadingZeroCount(significand); 2010curScale = BitOperations.LeadingZeroCount(tmp); 2298int shift = BitOperations.LeadingZeroCount(tmp);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\ManifestBuilder.cs (1)
456if (isbitmap && !BitOperations.IsPow2(hexValue))
src\runtime\src\libraries\System.Private.CoreLib\src\System\Globalization\Ordinal.cs (4)
516mask = BitOperations.ResetLowestSetBit(BitOperations.ResetLowestSetBit(mask)); 582mask = BitOperations.ResetLowestSetBit(BitOperations.ResetLowestSetBit(mask));
src\runtime\src\libraries\System.Private.CoreLib\src\System\Half.cs (1)
1138int shiftDist = BitOperations.LeadingZeroCount(sig) - 16 - 5;
src\runtime\src\libraries\System.Private.CoreLib\src\System\HashCode.cs (6)
270return BitOperations.RotateLeft(hash + input * Prime2, 13) * Prime1; 276return BitOperations.RotateLeft(hash + queuedValue * Prime3, 17) * Prime4; 282return BitOperations.RotateLeft(v1, 1) + BitOperations.RotateLeft(v2, 7) + BitOperations.RotateLeft(v3, 12) + BitOperations.RotateLeft(v4, 18);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Int128.cs (2)
718return 64 + BitOperations.LeadingZeroCount(value._lower); 720return BitOperations.LeadingZeroCount(value._upper);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Int16.cs (5)
279public static short LeadingZeroCount(short value) => (short)(BitOperations.LeadingZeroCount((ushort)value) - 16); 292public static short PopCount(short value) => (short)BitOperations.PopCount((ushort)value); 301public static short TrailingZeroCount(short value) => (byte)(BitOperations.TrailingZeroCount(value << 16) - 16); 487public static bool IsPow2(short value) => BitOperations.IsPow2(value); 496return (short)BitOperations.Log2((ushort)value);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Int32.cs (7)
295public static int LeadingZeroCount(int value) => BitOperations.LeadingZeroCount((uint)value); 310public static int PopCount(int value) => BitOperations.PopCount((uint)value); 314public static int RotateLeft(int value, int rotateAmount) => (int)BitOperations.RotateLeft((uint)value, rotateAmount); 318public static int RotateRight(int value, int rotateAmount) => (int)BitOperations.RotateRight((uint)value, rotateAmount); 322public static int TrailingZeroCount(int value) => BitOperations.TrailingZeroCount(value); 527public static bool IsPow2(int value) => BitOperations.IsPow2(value); 538return BitOperations.Log2((uint)value);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Int64.cs (9)
292public static long LeadingZeroCount(long value) => BitOperations.LeadingZeroCount((ulong)value); 307public static long PopCount(long value) => BitOperations.PopCount((ulong)value); 311public static long RotateLeft(long value, int rotateAmount) => (long)BitOperations.RotateLeft((ulong)value, rotateAmount); 315public static long RotateRight(long value, int rotateAmount) => (long)BitOperations.RotateRight((ulong)value, rotateAmount); 319public static long TrailingZeroCount(long value) => BitOperations.TrailingZeroCount(value); 479return (sizeof(long) * 8) - BitOperations.LeadingZeroCount((ulong)(value)); 483return (sizeof(long) * 8) + 1 - BitOperations.LeadingZeroCount((ulong)(~value)); 524public static bool IsPow2(long value) => BitOperations.IsPow2(value); 535return BitOperations.Log2((ulong)value);
src\runtime\src\libraries\System.Private.CoreLib\src\System\IntPtr.cs (9)
325public static nint LeadingZeroCount(nint value) => BitOperations.LeadingZeroCount((nuint)value); 340public static nint PopCount(nint value) => BitOperations.PopCount((nuint)value); 344public static nint RotateLeft(nint value, int rotateAmount) => (nint)BitOperations.RotateLeft((nuint)value, rotateAmount); 348public static nint RotateRight(nint value, int rotateAmount) => (nint)BitOperations.RotateRight((nuint)value, rotateAmount); 352public static nint TrailingZeroCount(nint value) => BitOperations.TrailingZeroCount(value); 512return (sizeof(nint_t) * 8) - BitOperations.LeadingZeroCount((nuint)value); 516return (sizeof(nint_t) * 8) + 1 - BitOperations.LeadingZeroCount((nuint)(~value)); 557public static bool IsPow2(nint value) => BitOperations.IsPow2(value); 568return BitOperations.Log2((nuint)value);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Marvin.cs (1)
10using static System.Numerics.BitOperations;
src\runtime\src\libraries\System.Private.CoreLib\src\System\Math.cs (1)
909return double.MinExponent - (BitOperations.LeadingZeroCount(x.TrailingSignificand) - double.BiasedExponentLength);
src\runtime\src\libraries\System.Private.CoreLib\src\System\MathF.cs (1)
211return float.MinExponent - (BitOperations.LeadingZeroCount(x.TrailingSignificand) - float.BiasedExponentLength);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Number.BigInteger.cs (2)
536return 64 - BitOperations.LeadingZeroCount(value); 550return (lastIndex * BitsPerBlock) + (BitsPerBlock - BitOperations.LeadingZeroCount(value._blocks[lastIndex]));
src\runtime\src\libraries\System.Private.CoreLib\src\System\Number.DiyFp.cs (1)
93int lzcnt = BitOperations.LeadingZeroCount(f);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Number.Dragon4.cs (2)
41mantissaHighBitIdx = (uint)BitOperations.Log2(mantissa); 293int hiBlockLog2 = BitOperations.Log2(hiBlock);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Number.Formatting.cs (2)
821int lz = BitOperations.LeadingZeroCount(fraction) - (63 - mantissaBits); 932int trailingZeroBits = BitOperations.TrailingZeroCount(nibbleAligned);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Number.NumberToFloatingPointBits.cs (1)
1284int lz = BitOperations.LeadingZeroCount(w);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Number.Parsing.cs (1)
1480int lz = BitOperations.LeadingZeroCount(significand);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Random.CompatImpl.cs (2)
72int bits = BitOperations.Log2Ceiling(exclusiveRange); 195int bits = BitOperations.Log2Ceiling(exclusiveRange);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Random.cs (2)
503if (BitOperations.IsPow2(choices.Length)) 535int mask = (int)BitOperations.RoundUpToPowerOf2((uint)choices.Length) - 1;
src\runtime\src\libraries\System.Private.CoreLib\src\System\Random.Xoshiro256StarStarImpl.cs (6)
57ulong result = BitOperations.RotateLeft(s1 * 5, 7) * 9; 66s3 = BitOperations.RotateLeft(s3, 45); 142MemoryMarshal.Write(buffer, BitOperations.RotateLeft(s1 * 5, 7) * 9); 151s3 = BitOperations.RotateLeft(s3, 45); 158ulong next = BitOperations.RotateLeft(s1 * 5, 7) * 9; 173s3 = BitOperations.RotateLeft(s3, 45);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\CastCache.cs (4)
39Debug.Assert(BitOperations.PopCount((uint)initialCacheSize) == 1 && initialCacheSize > 1); 40Debug.Assert(BitOperations.PopCount((uint)maxCacheSize) == 1 && maxCacheSize >= initialCacheSize); 95nuint hash = BitOperations.RotateLeft(source, (nuint.Size * 8) / 2) ^ target; 245byte shift = (byte)BitOperations.LeadingZeroCount((nuint)(size - 1));
src\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\ConditionalWeakTable.cs (3)
570Debug.Assert(BitOperations.IsPow2(InitialCapacity)); 593Debug.Assert(BitOperations.IsPow2(buckets.Length)); 798Debug.Assert(BitOperations.IsPow2(newSize));
src\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\GenericCache.cs (3)
77Debug.Assert(BitOperations.PopCount((uint)initialCacheSize) == 1 && initialCacheSize > 1); 78Debug.Assert(BitOperations.PopCount((uint)maxCacheSize) == 1 && maxCacheSize >= initialCacheSize); 234byte shift = (byte)BitOperations.LeadingZeroCount((nuint)(size - 1));
src\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\ComWrappers.cs (1)
1341uint bucketCount = BitOperations.RoundUpToPowerOf2((uint)Math.Min(Environment.ProcessorCount, MaxBucketCount));
src\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\NativeMemory.Unix.cs (2)
27if (!BitOperations.IsPow2(alignment)) 88if (!BitOperations.IsPow2(alignment))
src\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\Vector128.cs (6)
4341return AdvSimdFixupBitCount<T>(BitOperations.PopCount(AdvSimdExtractBitMask(vector))); 4345return BitOperations.PopCount(vector.ExtractMostSignificantBits()); 4362int result = AdvSimdFixupBitCount<T>(BitOperations.TrailingZeroCount(AdvSimdExtractBitMask(vector))); 4367int result = BitOperations.TrailingZeroCount(vector.ExtractMostSignificantBits()); 4377return (Vector128<T>.Count - 1) - AdvSimdFixupBitCount<T>(BitOperations.LeadingZeroCount(AdvSimdExtractBitMask(vector))); 4381return 31 - BitOperations.LeadingZeroCount(vector.ExtractMostSignificantBits());
src\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\Vector256.cs (3)
4246return BitOperations.PopCount(vector.ExtractMostSignificantBits()); 4268int result = BitOperations.TrailingZeroCount(vector.ExtractMostSignificantBits()); 4290return 31 - BitOperations.LeadingZeroCount(vector.ExtractMostSignificantBits());
src\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\Vector512.cs (3)
4225return BitOperations.PopCount(vector.ExtractMostSignificantBits()); 4247int result = BitOperations.TrailingZeroCount(vector.ExtractMostSignificantBits()); 4269return 63 - BitOperations.LeadingZeroCount(vector.ExtractMostSignificantBits());
src\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\Vector64.cs (6)
4464return AdvSimdFixupBitCount<T>(BitOperations.PopCount(AdvSimdExtractBitMask(vector))); 4468return BitOperations.PopCount(vector.ExtractMostSignificantBits()); 4485int result = AdvSimdFixupBitCount<T>(BitOperations.TrailingZeroCount(AdvSimdExtractBitMask(vector))); 4490int result = BitOperations.TrailingZeroCount(vector.ExtractMostSignificantBits()); 4500return (Vector64<T>.Count - 1) - AdvSimdFixupBitCount<T>(BitOperations.LeadingZeroCount(AdvSimdExtractBitMask(vector))); 4504return 31 - BitOperations.LeadingZeroCount(vector.ExtractMostSignificantBits());
src\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\X86\X86Base.cs (4)
41/// <para>Its functionality is exposed in the public <see cref="Numerics.BitOperations" /> class.</para> 52/// <para>Its functionality is exposed in the public <see cref="Numerics.BitOperations" /> class.</para> 98/// <para>Its functionality is exposed in the public <see cref="Numerics.BitOperations" /> class.</para> 109/// <para>Its functionality is exposed in the public <see cref="Numerics.BitOperations" /> class.</para>
src\runtime\src\libraries\System.Private.CoreLib\src\System\SByte.cs (5)
282public static sbyte LeadingZeroCount(sbyte value) => (sbyte)(BitOperations.LeadingZeroCount((byte)value) - 24); 295public static sbyte PopCount(sbyte value) => (sbyte)BitOperations.PopCount((byte)value); 304public static sbyte TrailingZeroCount(sbyte value) => (sbyte)(BitOperations.TrailingZeroCount(value << 24) - 24); 466public static bool IsPow2(sbyte value) => BitOperations.IsPow2(value); 475return (sbyte)BitOperations.Log2((byte)value);
src\runtime\src\libraries\System.Private.CoreLib\src\System\SearchValues\ProbabilisticMap.cs (16)
793index = BitOperations.TrailingZeroCount(mask); 800mask = BitOperations.ResetLowestSetBit(mask); 814index = BitOperations.TrailingZeroCount(mask); 828mask = BitOperations.ResetLowestSetBit(mask); 842index = BitOperations.TrailingZeroCount(mask); 849mask = BitOperations.ResetLowestSetBit(mask); 863index = BitOperations.TrailingZeroCount(mask); 877mask = BitOperations.ResetLowestSetBit(mask); 891index = 31 - BitOperations.LeadingZeroCount(mask); 899mask = BitOperations.FlipBit(mask, index); 913index = 31 - BitOperations.LeadingZeroCount(mask); 916mask = BitOperations.FlipBit(mask, index); 942index = 63 - BitOperations.LeadingZeroCount(mask); 950mask = BitOperations.FlipBit(mask, index); 964index = 63 - BitOperations.LeadingZeroCount(mask); 967mask = BitOperations.FlipBit(mask, index);
src\runtime\src\libraries\System.Private.CoreLib\src\System\SearchValues\Strings\AsciiStringSearchValuesTeddyBase.cs (12)
548int matchOffset = BitOperations.TrailingZeroCount(resultMask); 563int candidateOffset = BitOperations.TrailingZeroCount(candidateMask); 575candidateMask = BitOperations.ResetLowestSetBit(candidateMask); 579resultMask = BitOperations.ResetLowestSetBit(resultMask); 596int matchOffset = BitOperations.TrailingZeroCount(resultMask); 608int candidateOffset = BitOperations.TrailingZeroCount(candidateMask); 620candidateMask = BitOperations.ResetLowestSetBit(candidateMask); 624resultMask = BitOperations.ResetLowestSetBit(resultMask); 641int matchOffset = BitOperations.TrailingZeroCount(resultMask); 653int candidateOffset = BitOperations.TrailingZeroCount(candidateMask); 665candidateMask = BitOperations.ResetLowestSetBit(candidateMask); 669resultMask = BitOperations.ResetLowestSetBit(resultMask);
src\runtime\src\libraries\System.Private.CoreLib\src\System\SearchValues\Strings\SingleStringSearchValuesPackedThreeChars.cs (4)
335int bitPos = BitOperations.TrailingZeroCount(mask); 347mask = BitOperations.ResetLowestSetBit(mask); 362int bitPos = BitOperations.TrailingZeroCount(mask); 374mask = BitOperations.ResetLowestSetBit(mask);
src\runtime\src\libraries\System.Private.CoreLib\src\System\SearchValues\Strings\SingleStringSearchValuesThreeChars.cs (6)
332int bitPos = BitOperations.TrailingZeroCount(mask); 345mask = BitOperations.ResetLowestSetBit(BitOperations.ResetLowestSetBit(mask)); 360int bitPos = BitOperations.TrailingZeroCount(mask); 373mask = BitOperations.ResetLowestSetBit(BitOperations.ResetLowestSetBit(mask));
src\runtime\src\libraries\System.Private.CoreLib\src\System\SpanHelpers.Byte.cs (26)
113int bitPos = BitOperations.TrailingZeroCount(mask); 121mask = BitOperations.ResetLowestSetBit(mask); // Clear the lowest set bit 174int bitPos = BitOperations.TrailingZeroCount(mask); 182mask = BitOperations.ResetLowestSetBit(mask); // Clear the lowest set bit 235int bitPos = BitOperations.TrailingZeroCount(mask); 244mask = BitOperations.ResetLowestSetBit(mask); 325int highestSetBitIndex = 63 - BitOperations.LeadingZeroCount(mask); 334mask = BitOperations.FlipBit(mask, highestSetBitIndex); 372int highestSetBitIndex = 31 - BitOperations.LeadingZeroCount(mask); 381mask = BitOperations.FlipBit(mask, highestSetBitIndex); 421int highestSetBitIndex = 31 - BitOperations.LeadingZeroCount(mask); 430mask = BitOperations.FlipBit(mask, highestSetBitIndex); 542return (int)(offset + (uint)BitOperations.TrailingZeroCount(matches)); 564return (int)(offset + (uint)BitOperations.TrailingZeroCount(matches)); 584return (int)(offset + (uint)BitOperations.TrailingZeroCount(matches)); 603return (int)(offset + (uint)BitOperations.TrailingZeroCount(matches)); 622return (int)(offset + (uint)BitOperations.TrailingZeroCount(matches)); 655return (int)(offset + (uint)BitOperations.TrailingZeroCount(matches)); 676return (int)(offset + (uint)BitOperations.TrailingZeroCount(matches)); 695return (int)(offset + (uint)BitOperations.TrailingZeroCount(matches)); 727return (int)(offset + (uint)BitOperations.TrailingZeroCount(matches)); 1011offset += (uint)BitOperations.TrailingZeroCount(differences); 1052offset += (uint)BitOperations.TrailingZeroCount(differences); 1089offset += (uint)BitOperations.TrailingZeroCount(differences); 1246=> BitOperations.TrailingZeroCount(match) >> 3; 1250=> BitOperations.Log2(match) >> 3;
src\runtime\src\libraries\System.Private.CoreLib\src\System\SpanHelpers.Char.cs (18)
118int bitPos = BitOperations.TrailingZeroCount(mask); 195mask = BitOperations.ResetLowestSetBit(BitOperations.ResetLowestSetBit(mask)); 257mask = BitOperations.ResetLowestSetBit(BitOperations.ResetLowestSetBit(mask)); 342int bitPos = 62 - BitOperations.LeadingZeroCount(mask); 392int bitPos = 30 - BitOperations.LeadingZeroCount(mask); 442int bitPos = 30 - BitOperations.LeadingZeroCount(mask); 611return (int)(offset + ((uint)BitOperations.TrailingZeroCount(matches) / sizeof(char))); 638return (int)(offset + ((uint)BitOperations.TrailingZeroCount(matches) / sizeof(char))); 669return (int)(offset + (uint)BitOperations.TrailingZeroCount(matches)); 692return (int)(offset + ((uint)BitOperations.TrailingZeroCount(matches) / sizeof(char))); 715return (int)(offset + ((uint)BitOperations.TrailingZeroCount(matches) / sizeof(char))); 755return (int)(offset + ((uint)BitOperations.TrailingZeroCount(matches) / sizeof(char))); 780return (int)(offset + ((uint)BitOperations.TrailingZeroCount(matches) / sizeof(char))); 803return (int)(offset + ((uint)BitOperations.TrailingZeroCount(matches) / sizeof(char))); 842return (int)(offset + ((uint)BitOperations.TrailingZeroCount(matches) / sizeof(char))); 867=> BitOperations.TrailingZeroCount(match) >> 4;
src\runtime\src\libraries\System.Private.CoreLib\src\System\SpanHelpers.Packed.cs (6)
1233int index = BitOperations.TrailingZeroCount(notEqualsElements); 1242int index = BitOperations.TrailingZeroCount(notEqualsElements); 1251int index = BitOperations.TrailingZeroCount(notEqualsElements); 1259int offsetInVector = BitOperations.TrailingZeroCount(notEqualsElements); 1274int offsetInVector = BitOperations.TrailingZeroCount(notEqualsElements); 1289int offsetInVector = BitOperations.TrailingZeroCount(notEqualsElements);
src\runtime\src\libraries\System.Private.CoreLib\src\System\SpanHelpers.T.cs (13)
38if (!BitOperations.IsPow2(sizeof(T))) 3717int index = BitOperations.TrailingZeroCount(notEqualsElements); 3725int index = BitOperations.TrailingZeroCount(notEqualsElements); 3733int index = BitOperations.TrailingZeroCount(notEqualsElements); 3741int index = 31 - BitOperations.LeadingZeroCount(notEqualsElements); // 31 = 32 (bits in Int32) - 1 (indexing from zero) 3749int index = 31 - BitOperations.LeadingZeroCount(notEqualsElements); // 31 = 32 (bits in Int32) - 1 (indexing from zero) 3757int index = 63 - BitOperations.LeadingZeroCount(notEqualsElements); // 31 = 32 (bits in Int32) - 1 (indexing from zero) 4179count += BitOperations.PopCount(Vector512.Equals(Vector512.LoadUnsafe(ref current), targetVector).ExtractMostSignificantBits()); 4186count += BitOperations.PopCount(mask); 4194count += BitOperations.PopCount(Vector256.Equals(Vector256.LoadUnsafe(ref current), targetVector).ExtractMostSignificantBits()); 4201count += BitOperations.PopCount(mask); 4209count += BitOperations.PopCount(Vector128.Equals(Vector128.LoadUnsafe(ref current), targetVector).ExtractMostSignificantBits()); 4216count += BitOperations.PopCount(mask);
src\runtime\src\libraries\System.Private.CoreLib\src\System\String.Comparison.cs (21)
784hash1 = (BitOperations.RotateLeft(hash1, 5) + hash1) ^ ptr[0]; 785hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ ptr[1]; 791hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ ptr[0]; 815hash1 = BitOperations.RotateLeft(hash1, 5) + hash1 ^ Unsafe.ReadUnaligned<uint>(ptr); 816hash2 = BitOperations.RotateLeft(hash2, 5) + hash2 ^ Unsafe.ReadUnaligned<uint>(ptr + 1); 823hash1 = BitOperations.RotateLeft(hash1, 5) + hash1 ^ Unsafe.ReadUnaligned<uint>(ptr); 830hash2 = BitOperations.RotateLeft(hash2, 5) + hash2 ^ p1; 834hash2 = BitOperations.RotateLeft(hash2, 5) + hash2 ^ Unsafe.ReadUnaligned<uint>(ptr); 844hash2 = BitOperations.RotateLeft(hash2, 5) + hash2 ^ p0; 884hash1 = (BitOperations.RotateLeft(hash1, 5) + hash1) ^ (p0 | NormalizeToLowercase); 885hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ (p1 | NormalizeToLowercase); 897hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ (p0 | NormalizeToLowercase); 933hash1 = (BitOperations.RotateLeft(hash1, 5) + hash1) ^ (p0 | NormalizeToLowercase); 934hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ (p1 | NormalizeToLowercase); 953hash1 = (BitOperations.RotateLeft(hash1, 5) + hash1) ^ (p0 | NormalizeToLowercase); 954hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ (p1 | NormalizeToLowercase); 964hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ (p0 | NormalizeToLowercase); 979hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ (p0 | NormalizeToLowercase); 1016hash1 = (BitOperations.RotateLeft(hash1, 5) + hash1) ^ (ptr[0] | NormalizeToLowercase); 1017hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ (ptr[1] | NormalizeToLowercase); 1023hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ (ptr[0] | NormalizeToLowercase);
src\runtime\src\libraries\System.Private.CoreLib\src\System\String.Manipulation.cs (24)
2159uint bitPos = (uint)BitOperations.TrailingZeroCount(mask1) / sizeof(char); 2161mask1 = BitOperations.ResetLowestSetBit(mask1); 2165uint bitPos = (uint)BitOperations.TrailingZeroCount(mask2) / sizeof(char); 2167mask2 = BitOperations.ResetLowestSetBit(mask2); 2195uint bitPos = (uint)BitOperations.TrailingZeroCount(mask) / sizeof(char); 2197mask = BitOperations.ResetLowestSetBit(mask); 2215uint bitPos = (uint)BitOperations.TrailingZeroCount(mask) / sizeof(char); 2217mask = BitOperations.ResetLowestSetBit(mask); 2254uint bitPos = (uint)BitOperations.TrailingZeroCount(mask1) / sizeof(char); 2256mask1 = BitOperations.ResetLowestSetBit(mask1); 2260uint bitPos = (uint)BitOperations.TrailingZeroCount(mask2) / sizeof(char); 2262mask2 = BitOperations.ResetLowestSetBit(mask2); 2290uint bitPos = (uint)BitOperations.TrailingZeroCount(mask) / sizeof(char); 2292mask = BitOperations.ResetLowestSetBit(mask); 2310uint bitPos = (uint)BitOperations.TrailingZeroCount(mask) / sizeof(char); 2312mask = BitOperations.ResetLowestSetBit(mask); 2349uint bitPos = (uint)BitOperations.TrailingZeroCount(mask1) / sizeof(char); 2351mask1 = BitOperations.ResetLowestSetBit(mask1); 2355uint bitPos = (uint)BitOperations.TrailingZeroCount(mask2) / sizeof(char); 2357mask2 = BitOperations.ResetLowestSetBit(mask2); 2385uint bitPos = (uint)BitOperations.TrailingZeroCount(mask) / sizeof(char); 2387mask = BitOperations.ResetLowestSetBit(mask); 2405uint bitPos = (uint)BitOperations.TrailingZeroCount(mask) / sizeof(char); 2407mask = BitOperations.ResetLowestSetBit(mask);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Text\Ascii.Utility.cs (7)
83int index = BitOperations.TrailingZeroCount(mask) >> 2; 602pBuffer += (uint)BitOperations.TrailingZeroCount(currentSseMask); 647pBuffer += (nuint)(BitOperations.TrailingZeroCount(candidateUInt64) >> 3); 1144pBuffer = (char*)((byte*)pBuffer + (uint)BitOperations.TrailingZeroCount(currentMask) - 1); 1157pBuffer += BitOperations.TrailingZeroCount(asciiCompareMask) >> 3; 1205pBuffer = (char*)((byte*)pBuffer + ((nuint)(BitOperations.TrailingZeroCount(candidateUInt64) >> 3) & ~(nuint)1)); 2184asciiData = BitOperations.RotateLeft(asciiData, 8);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Text\Ascii.Utility.Helpers.cs (4)
53return (uint)BitOperations.TrailingZeroCount(value & UInt32HighBitsOnlyMask) >> 3; 69value = BitOperations.RotateLeft(value, 1); 74value = BitOperations.RotateLeft(value, 8); 79value = BitOperations.RotateLeft(value, 8);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Text\Latin1Utility.cs (1)
427pBuffer = (char*)((byte*)pBuffer + (uint)BitOperations.TrailingZeroCount(currentMask) - 1);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Text\Unicode\Utf16Utility.Validation.cs (2)
200popcnt = (uint)BitOperations.PopCount(mask); // on x64, perform zero-extension for free 233nint surrogatePairsCountNint = (nint)BitOperations.PopCount(maskLow);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Text\Unicode\Utf8Utility.Helpers.cs (1)
118tempA = BitOperations.RotateLeft(tempA, 16); // = [ 00xxxxxx 00000000 00000000 00000uuu ]
src\runtime\src\libraries\System.Private.CoreLib\src\System\Text\Unicode\Utf8Utility.Transcoding.cs (1)
605toCheck = BitOperations.RotateRight(toCheck, 8);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Text\Unicode\Utf8Utility.Validation.cs (4)
140trailingZeroCount = (nuint)BitOperations.TrailingZeroCount(mask) >> 2; 158trailingZeroCount = (nuint)BitOperations.TrailingZeroCount(mask); 167trailingZeroCount = (nuint)BitOperations.TrailingZeroCount(mask); 619thisDWord = BitOperations.RotateRight(thisDWord, 8);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Threading\ThreadLocal.cs (1)
556uint newSize = BitOperations.RoundUpToPowerOf2((uint)minSize);
src\runtime\src\libraries\System.Private.CoreLib\src\System\UInt128.cs (5)
807int shift = BitOperations.LeadingZeroCount(divHi); 900int shift = BitOperations.LeadingZeroCount(divisor); 918Debug.Assert(BitOperations.LeadingZeroCount(divisor) == 0); 1014return 64 + BitOperations.LeadingZeroCount(value._lower); 1016return BitOperations.LeadingZeroCount(value._upper);
src\runtime\src\libraries\System.Private.CoreLib\src\System\UInt16.cs (5)
273public static ushort LeadingZeroCount(ushort value) => (ushort)(BitOperations.LeadingZeroCount(value) - 16); 279public static ushort PopCount(ushort value) => (ushort)BitOperations.PopCount(value); 288public static ushort TrailingZeroCount(ushort value) => (ushort)(BitOperations.TrailingZeroCount(value << 16) - 16); 412public static bool IsPow2(ushort value) => BitOperations.IsPow2((uint)value); 415public static ushort Log2(ushort value) => (ushort)BitOperations.Log2(value);
src\runtime\src\libraries\System.Private.CoreLib\src\System\UInt32.cs (9)
290public static uint LeadingZeroCount(uint value) => (uint)BitOperations.LeadingZeroCount(value); 301uint log2 = (uint)BitOperations.Log2(value) + 1; 323public static uint PopCount(uint value) => (uint)BitOperations.PopCount(value); 327public static uint RotateLeft(uint value, int rotateAmount) => BitOperations.RotateLeft(value, rotateAmount); 331public static uint RotateRight(uint value, int rotateAmount) => BitOperations.RotateRight(value, rotateAmount); 335public static uint TrailingZeroCount(uint value) => (uint)BitOperations.TrailingZeroCount(value); 437int IBinaryInteger<uint>.GetShortestBitLength() => (sizeof(uint) * 8) - BitOperations.LeadingZeroCount(m_value); 476public static bool IsPow2(uint value) => BitOperations.IsPow2(value); 480public static uint Log2(uint value) => (uint)BitOperations.Log2(value);
src\runtime\src\libraries\System.Private.CoreLib\src\System\UInt64.cs (9)
289public static ulong LeadingZeroCount(ulong value) => (ulong)BitOperations.LeadingZeroCount(value); 298uint log2 = (uint)BitOperations.Log2(value) + 1; 330public static ulong PopCount(ulong value) => (ulong)BitOperations.PopCount(value); 334public static ulong RotateLeft(ulong value, int rotateAmount) => BitOperations.RotateLeft(value, rotateAmount); 338public static ulong RotateRight(ulong value, int rotateAmount) => BitOperations.RotateRight(value, rotateAmount); 342public static ulong TrailingZeroCount(ulong value) => (ulong)BitOperations.TrailingZeroCount(value); 444int IBinaryInteger<ulong>.GetShortestBitLength() => (sizeof(ulong) * 8) - BitOperations.LeadingZeroCount(m_value); 483public static bool IsPow2(ulong value) => BitOperations.IsPow2(value); 487public static ulong Log2(ulong value) => (ulong)BitOperations.Log2(value);
src\runtime\src\libraries\System.Private.CoreLib\src\System\UIntPtr.cs (8)
321public static nuint LeadingZeroCount(nuint value) => (nuint)BitOperations.LeadingZeroCount(value); 335public static nuint PopCount(nuint value) => (nuint)BitOperations.PopCount(value); 339public static nuint RotateLeft(nuint value, int rotateAmount) => BitOperations.RotateLeft(value, rotateAmount); 343public static nuint RotateRight(nuint value, int rotateAmount) => BitOperations.RotateRight(value, rotateAmount); 347public static nuint TrailingZeroCount(nuint value) => (nuint)BitOperations.TrailingZeroCount(value); 449int IBinaryInteger<nuint>.GetShortestBitLength() => (sizeof(nuint_t) * 8) - BitOperations.LeadingZeroCount(_value); 492public static bool IsPow2(nuint value) => BitOperations.IsPow2(value); 496public static nuint Log2(nuint value) => (nuint)BitOperations.Log2(value);
System\Runtime\CompilerServices\RuntimeHelpers.NativeAot.cs (1)
271if (!BitOperations.IsPow2(alignment))
System\Runtime\ThunkPool.cs (1)
49public static readonly uint PageSize = BitOperations.RoundUpToPowerOf2((uint)Math.Max(ThunkCodeSize * NumThunksPerBlock, ThunkDataSize * NumThunksPerBlock + IntPtr.Size));
System\Runtime\TypeLoaderExports.cs (1)
57IntPtr context = (IntPtr)BitOperations.RotateLeft((nuint)_context, 16);
System.Private.StackTraceMetadata (2)
src\runtime\src\libraries\Common\src\Internal\VersionResilientHashCode.cs (2)
171return (int)BitOperations.RotateLeft((uint)value, bitCount); 183return (BitOperations.RotateLeft((hash + queuedValue * 3266489917U/*Prime3*/), 17)) * 668265263U/*Prime4*/;
System.Private.TypeLoader (2)
src\runtime\src\libraries\Common\src\Internal\VersionResilientHashCode.cs (2)
171return (int)BitOperations.RotateLeft((uint)value, bitCount); 183return (BitOperations.RotateLeft((hash + queuedValue * 3266489917U/*Prime3*/), 17)) * 668265263U/*Prime4*/;
System.Private.Xml (11)
System\Xml\Schema\XsdDateTime.cs (4)
198Debug.Assert(BitOperations.IsPow2((uint)kinds), "One and only one DateTime type code can be set."); 201DateTimeTypeCode code = (DateTimeTypeCode)BitOperations.TrailingZeroCount((uint)kinds); 242Debug.Assert(BitOperations.IsPow2((uint)kinds), "Only one DateTime type code can be set."); 247DateTimeTypeCode code = (DateTimeTypeCode)BitOperations.TrailingZeroCount((uint)kinds);
System\Xml\Xsl\IlGen\XmlIlVisitor.cs (1)
3268if (!BitOperations.IsPow2((uint)kinds))
System\Xml\Xsl\XmlQueryTypeFactory.cs (3)
706if (BitOperations.IsPow2(kinds)) 708return ItemType.Create(s_nodeKindToTypeCode[BitOperations.TrailingZeroCount(kinds) + 1], false); 714members.Add(ItemType.Create(s_nodeKindToTypeCode[BitOperations.TrailingZeroCount(kinds) + 1], false));
System\Xml\Xsl\Xslt\CompilerScopeManager.cs (2)
149Debug.Assert(flag == (flag & ScopeFlags.ExclusiveFlags) && BitOperations.IsPow2((uint)flag), "One exclusive flag"); 168Debug.Assert(flag == (flag & ScopeFlags.InheritedFlags) && BitOperations.IsPow2((uint)flag), "one inherited flag");
System\Xml\Xsl\Xslt\MatcherBuilder.cs (1)
183if (!BitOperations.IsPow2((uint)nodeKinds))
System.Private.Xml.Linq (1)
System\Xml\Linq\XHashtable.cs (1)
147Debug.Assert(BitOperations.IsPow2(capacity), "capacity must be a power of 2");
System.Reflection.Metadata (5)
System\Reflection\Internal\Utilities\BitArithmetic.cs (2)
13Debug.Assert(BitOperations.PopCount(alignment) == 1); 27Debug.Assert(BitOperations.PopCount((uint)alignment) == 1);
System\Reflection\Metadata\Ecma335\MetadataSizes.cs (1)
444BitOperations.PopCount(ExternalTablesMask) * sizeof(int); // External row counts
System\Reflection\PortableExecutable\PEHeaderBuilder.cs (2)
67if (fileAlignment < 512 || fileAlignment > 64 * 1024 || BitOperations.PopCount((uint)fileAlignment) != 1) 72if (sectionAlignment < fileAlignment || BitOperations.PopCount((uint)sectionAlignment) != 1)
System.Runtime (1)
src\runtime\artifacts\obj\System.Runtime\Release\net11.0\System.Runtime.Forwards.cs (1)
377[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Numerics.BitOperations))]
System.Runtime.Extensions (1)
System.Runtime.Extensions.cs (1)
53[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Numerics.BitOperations))]
System.Runtime.Numerics (28)
src\runtime\src\libraries\System.Private.CoreLib\src\System\Buffers\Text\FormattingHelpers.CountDigits.cs (1)
112return (BitOperations.Log2(value) >> 2) + 1;
System\Number.BigInteger.cs (3)
1418maxIndex = BitOperations.Log2(scale1E9); 1487int fi = BitOperations.TrailingZeroCount(trailingPartialCount); 1496if ((BitOperations.PopCount((uint)trailingPartialCount) & 1) != 0)
System\Numerics\BigInteger.cs (20)
777return BitOperations.IsPow2(_sign); 786return BitOperations.IsPow2(_bits[iu]) && !_bits.AsSpan(0, iu).ContainsAnyExcept(0u); 1017c = BitOperations.LeadingZeroCount(h); 1030c = BitOperations.LeadingZeroCount((uint)h); 1615int lzc = BitOperations.LeadingZeroCount(highLimb); 1621int lzc = BitOperations.LeadingZeroCount(~highLimb); 2107int z = BitOperations.LeadingZeroCount(h); 2122int z = BitOperations.LeadingZeroCount((uint)h); 3282BitOperations.LeadingZeroCount(highValue); 3391return BitOperations.LeadingZeroCount(value._bits[^1]) & 31; 3411result += (ulong)BitOperations.PopCount(part); 3426result += (ulong)BitOperations.PopCount(part); 3433result += (ulong)BitOperations.PopCount(part); 3768result += (ulong)BitOperations.TrailingZeroCount(part); 3796return value >= 0 ? 32 - BitOperations.LeadingZeroCount((uint)value) : 33 - BitOperations.LeadingZeroCount(~(uint)value); 3803result += BigIntegerCalculator.BitsPerLimb - BitOperations.LeadingZeroCount(bits[^1]); 3818result += BigIntegerCalculator.BitsPerLimb + 1 - BitOperations.LeadingZeroCount(~part); 4035? (BigInteger)((BigIntegerCalculator.BitsPerLimb - 1) ^ BitOperations.LeadingZeroCount((nuint)value._sign | 1)) 4036: (BigInteger)(((long)value._bits.Length * BigIntegerCalculator.BitsPerLimb - 1) ^ BitOperations.LeadingZeroCount(value._bits[^1]));
System\Numerics\BigIntegerCalculator.DivRem.cs (1)
191int m = (int)BitOperations.RoundUpToPowerOf2((uint)right.Length / (uint)DivideBurnikelZieglerThreshold + 1);
System\Numerics\BigIntegerCalculator.GcdInv.cs (2)
332int z = BitOperations.LeadingZeroCount((uint)xh); 368int z = BitOperations.LeadingZeroCount(xh);
System\Numerics\BigIntegerCalculator.PowMod.cs (1)
619int trailingZeros = BitOperations.TrailingZeroCount(wValue);
System.Security.Cryptography (3)
System\Security\Cryptography\RandomNumberGenerator.cs (2)
362if (BitOperations.IsPow2(choices.Length)) 394int mask = (int)BitOperations.RoundUpToPowerOf2((uint)choices.Length) - 1;
System\Security\Cryptography\X509Certificates\ChainPal.Windows.GetChainStatusInformation.cs (1)
16int count = BitOperations.PopCount((uint)dwStatus);
System.Text.Encodings.Web (2)
System\Text\Encodings\Web\DefaultHtmlEncoder.cs (2)
106int idxOfSemicolon = (int)((uint)BitOperations.Log2(scalarValue) / 4) + 4; 181int idxOfSemicolon = (int)((uint)BitOperations.Log2(scalarValue) / 4) + 4;
System.Text.RegularExpressions (2)
System\Text\RegularExpressions\RegexCharClass.cs (1)
1224return BitOperations.IsPow2(mask);
System\Text\RegularExpressions\Symbolic\SymbolicRegexMatcher.cs (1)
183_mintermsLog = BitOperations.Log2((uint)_minterms.Length) + 1;