diff options
| author | Feoramund <161657516+Feoramund@users.noreply.github.com> | 2024-08-10 15:29:44 -0400 |
|---|---|---|
| committer | Feoramund <161657516+Feoramund@users.noreply.github.com> | 2024-08-10 15:29:44 -0400 |
| commit | cf8f6afefffc59509e056ffca83c48a02ebf0386 (patch) | |
| tree | 5d81b9632b9a9aaa1dbdb98eb99a74f5066069cf | |
| parent | 6918d8aaa6e13fb7529884a436aa20a87e6b6f10 (diff) | |
Use `intrinsics.reverse_bits` in `core:compress/zlib`
| -rw-r--r-- | core/compress/zlib/zlib.odin | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/core/compress/zlib/zlib.odin b/core/compress/zlib/zlib.odin index c7ae9e9c8..2dc9e81df 100644 --- a/core/compress/zlib/zlib.odin +++ b/core/compress/zlib/zlib.odin @@ -12,6 +12,7 @@ package compress_zlib import "core:compress" +import "base:intrinsics" import "core:mem" import "core:io" import "core:hash" @@ -123,13 +124,7 @@ Huffman_Table :: struct { @(optimization_mode="favor_size") z_bit_reverse :: #force_inline proc(n: u16, bits: u8) -> (r: u16) { assert(bits <= 16) - // NOTE: Can optimize with llvm.bitreverse.i64 or some bit twiddling - // by reversing all of the bits and masking out the unneeded ones. - r = n - r = ((r & 0xAAAA) >> 1) | ((r & 0x5555) << 1) - r = ((r & 0xCCCC) >> 2) | ((r & 0x3333) << 2) - r = ((r & 0xF0F0) >> 4) | ((r & 0x0F0F) << 4) - r = ((r & 0xFF00) >> 8) | ((r & 0x00FF) << 8) + r = intrinsics.reverse_bits(n) r >>= (16 - bits) return |