Engineering Category: Balanced Ternary & b158 Quantization
Best Use in Production: Separating packed ternary words into positive and negative bitplanes with popcount sparsity tracking for rank-1 quantum-inspired compression.
When to Select This Capsule: Holds the #1 Equivalence Crown across 3 functionally identical implementations (fastest verified hardware _rdtsc). Low-latency L1-resident kernel (2222129/200000 cyc/op); well-suited for high-frequency pipeline stages.
Snap-Circuit Wiring Role: 1-to-1 Unary Transform Stage `(u64)->u64` — snaps directly into linear pipelines or fan-out DAG branches.
.text: 256 B (67 x86_64 insns)825 B)pub const fn st_golf_b158_bitplane_swar_u64(trit_word: u64) -> u64 {
const M: u64 = 0x1111_1111_1111_1111;
let pos_nib = ((trit_word >> 3) & ((trit_word >> 2) | ((trit_word >> 1) & trit_word))) & M;
let nw = !trit_word;
let neg_nib = ((nw >> 3) & ((nw >> 2) | (nw >> 1))) & M;
let mut p = (pos_nib | (pos_nib >> 3)) & 0x0303_0303_0303_0303;
p = (p | (p >> 6)) & 0x000F_000F_000F_000F;
p = (p | (p >> 12)) & 0x0000_00FF_0000_00FF;
let pos_plane = (p | (p >> 24)) & 0xFFFF;
let mut n = (neg_nib | (neg_nib >> 3)) & 0x0303_0303_0303_0303;
n = (n | (n >> 6)) & 0x000F_000F_000F_000F;
n = (n | (n >> 12)) & 0x0000_00FF_0000_00FF;
let neg_plane = (n | (n >> 24)) & 0xFFFF;
let active = (pos_nib | neg_nib).count_ones() as u64;
(active << 32) | (neg_plane << 16) | pos_plane
}
rustc -C opt-level=3 x86_64 Disassembly (256 B .text / 67 insns)st_golf_b158_bitplane_swar_u64:
mov rcx, rdi
shr rcx, 3
mov rax, rdi
shr rax, 2
mov rdx, rdi
shr rdx
and rdx, rdi
or rdx, rax
movabs rax, 1229782938247303441
and rcx, rax
and rcx, rdx
not rdi
mov rdx, rdi
shr rdx, 3
mov rsi, rdi
shr rsi, 2
shr rdi
or rsi, rdi
and rdx, rax
and rdx, rsi
mov rax, rcx
shr rax, 3
or rax, rcx
mov rsi, rax
shr rsi, 6
movabs rdi, 3377751260921868
and rsi, rdi
movabs r8, 844437815230467
and rax, r8
or rax, rsi
mov rsi, rax
shr rsi, 12
or rsi, rax
mov rax, rsi
shr rax, 24
or eax, esi
movzx esi, ax
mov rax, rdx
shr rax, 3
or rax, rdx
mov r9, rax
shr r9, 6
and r9, rdi
and rax, r8
or rax, r9
mov rdi, rax
shr rdi, 12
or rdi, rax
movzx r8d, di
mov rax, rdi
shr rax, 24
or eax, r8d
or rdx, rcx
mov rcx, rdx
shr rcx, 4
add rcx, rdx
movabs rdx, 217020518514230019
and rdx, rcx
movabs rcx, 72340172838076673
imul rcx, rdx
shr rcx, 24
movabs rdx, 1095216660480
and rdx, rcx
shl eax, 16
or rax, rdx
or rax, rsi
ret
| Global Rank | Capsule & Domain | Hardware _rdtsc | Latency | Throughput | ELF .text | Ternary Vote | Author Aye |
|---|---|---|---|---|---|---|---|
| #331 | st_golf_b158_bitplane_swar_u64 (THIS CAPSULE) domain: OneCompression | id: ad03cf6a56d8304f9fa9d5dbbed27066 | 2222129/200000 cyc/op | 1205733/400000 ns/op | 400000000/1205733 ops/us | 256 B .text (67 insns) | + (1) | aye::Hue+Gemini(0+1)::x86_64 @ 432Hz |
| #1190 | st_golf_b158_bitplane_swar_u64 domain: OneCompression | id: 82481a0614b3ee6b172b3df6ae9e94ba | 802421/40000 cyc/op | 2177019/400000 ns/op | 400000000/2177019 ops/us | 231 B .text (56 insns) | + (1) | aye::Hue+Gemini(0+1)::x86_64 @ 432Hz |
| #1714 | onecompression_b158_bitplane_decompose domain: OneCompression | id: ec740dcee41886836ec931a638661abb | 3306553/50000 cyc/op | 8550889/400000 ns/op | 400000000/8550889 ops/us | 788 B .text (240 insns) | 0 (0) | omni-toss-weaver @ 528Hz |