MCPcopy Create free account
hub / github.com/CodingGay/BlackDex / ReverseBits64

Function ReverseBits64

Bcore/src/main/cpp/base/bit_utils.h:369–377  ·  view source on GitHub ↗

TUNING: use rbit for arm/arm64

Source from the content-addressed store, hash-verified

367
368// TUNING: use rbit for arm/arm64
369inline static uint64_t ReverseBits64(uint64_t opnd) {
370 // Hacker's Delight 7-1
371 opnd = (opnd & 0x5555555555555555L) << 1 | ((opnd >> 1) & 0x5555555555555555L);
372 opnd = (opnd & 0x3333333333333333L) << 2 | ((opnd >> 2) & 0x3333333333333333L);
373 opnd = (opnd & 0x0f0f0f0f0f0f0f0fL) << 4 | ((opnd >> 4) & 0x0f0f0f0f0f0f0f0fL);
374 opnd = (opnd & 0x00ff00ff00ff00ffL) << 8 | ((opnd >> 8) & 0x00ff00ff00ff00ffL);
375 opnd = (opnd << 48) | ((opnd & 0xffff0000L) << 16) | ((opnd >> 16) & 0xffff0000L) | (opnd >> 48);
376 return opnd;
377}
378
379// Create a mask for the least significant "bits"
380// The returned value is always unsigned to prevent undefined behavior for bitwise ops.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected