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

Function ReverseBits32

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

TUNING: use rbit for arm/arm64

Source from the content-addressed store, hash-verified

356
357// TUNING: use rbit for arm/arm64
358inline static uint32_t ReverseBits32(uint32_t opnd) {
359 // Hacker's Delight 7-1
360 opnd = ((opnd >> 1) & 0x55555555) | ((opnd & 0x55555555) << 1);
361 opnd = ((opnd >> 2) & 0x33333333) | ((opnd & 0x33333333) << 2);
362 opnd = ((opnd >> 4) & 0x0F0F0F0F) | ((opnd & 0x0F0F0F0F) << 4);
363 opnd = ((opnd >> 8) & 0x00FF00FF) | ((opnd & 0x00FF00FF) << 8);
364 opnd = ((opnd >> 16)) | ((opnd) << 16);
365 return opnd;
366}
367
368// TUNING: use rbit for arm/arm64
369inline static uint64_t ReverseBits64(uint64_t opnd) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected