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: Verified baseline member of a 3-capsule Equivalence Class; useful as a reference or cross-validation peer. Multi-step compute kernel (3306553/50000 cyc/op); best used at frame, block, or batch aggregation boundaries.
Snap-Circuit Wiring Role: 1-to-1 Unary Transform Stage `(u64)->u64` — snaps directly into linear pipelines or fan-out DAG branches.
.text: 788 B (240 x86_64 insns)591 B)pub fn onecompression_b158_bitplane_decompose(trit_word: u64) -> u64 {
let mut pos_plane: u64 = 0;
let mut neg_plane: u64 = 0;
let mut lane: u32 = 0;
while lane < 16 {
let cell = ((trit_word >> (lane * 4)) & 0x0F) as i64 - 8;
let is_pos = (cell > 2) as u64;
let is_neg = (cell < -2) as u64;
pos_plane |= is_pos << lane;
neg_plane |= is_neg << lane;
lane += 1;
}
let active_trits = (pos_plane.count_ones() + neg_plane.count_ones()) as u64;
(active_trits << 32) | ((neg_plane & 0xFFFF) << 16) | (pos_plane & 0xFFFF)
}
rustc -C opt-level=3 x86_64 Disassembly (788 B .text / 240 insns)onecompression_b158_bitplane_decompose:
push rbp
push r15
push r14
push r13
push r12
push rbx
mov eax, edi
and eax, 15
xor ecx, ecx
cmp rax, 11
setae cl
xor edx, edx
cmp rax, 6
setb dl
mov eax, edi
shr eax, 4
and eax, 15
xor esi, esi
cmp eax, 11
setae sil
xor r8d, r8d
cmp eax, 6
setb r8b
lea rax, [rcx + 2*rsi]
lea rcx, [rdx + 2*r8]
mov edx, edi
shr edx, 8
and edx, 15
xor esi, esi
cmp edx, 11
setae sil
xor r8d, r8d
cmp edx, 6
setb r8b
lea rax, [rax + 4*rsi]
lea rcx, [rcx + 4*r8]
mov edx, edi
shr edx, 12
and edx, 15
xor esi, esi
cmp edx, 11
setae sil
xor r8d, r8d
cmp edx, 6
setb r8b
lea rax, [rax + 8*rsi]
lea rcx, [rcx + 8*r8]
mov edx, edi
shr edx, 16
and edx, 15
xor esi, esi
cmp edx, 11
setae sil
xor r9d, r9d
cmp edx, 6
setb r9b
shl esi, 4
or rsi, rax
shl r9d, 4
or r9, rcx
mov eax, edi
shr eax, 20
and eax, 15
xor r14d, r14d
cmp eax, 11
setae r14b
xor ebp, ebp
cmp eax, 6
setb bpl
shl r14d, 5
shl ebp, 5
mov ecx, edi
shr ecx, 24
and ecx, 15
xor r12d, r12d
cmp ecx, 11
setae r12b
xor eax, eax
cmp ecx, 6
setb al
mov edx, edi
shr edx, 28
mov r13, rdi
shr r13, 32
and r13d, 15
mov r15, rdi
shr r15, 36
and r15d, 15
mov rbx, rdi
shr rbx, 40
and ebx, 15
mov r11, rdi
shr r11, 44
and r11d, 15
mov r10, rdi
shr r10, 48
and r10d, 15
mov rcx, rdi
shr rcx, 52
and ecx, 15
mov qword ptr [rsp - 16], rcx
mov rcx, rdi
shr rcx, 56
and ecx, 15
mov qword ptr [rsp - 8], rcx
mov rcx, rdi
shr rcx, 60
xor r8d, r8d
cmp ecx, 11
setae r8b
shr rdi, 61
xor ecx, ecx
cmp edi, 3
setb cl
shl eax, 6
or rax, rbp
shl r12d, 6
or r12, r14
xor edi, edi
cmp edx, 6
setb dil
xor ebp, ebp
cmp edx, 11
setae bpl
shl edi, 7
or rdi, rax
shl ebp, 7
or rbp, r12
xor r14d, r14d
cmp r13, 6
setb r14b
xor r12d, r12d
cmp r13, 11
setae r12b
shl r14d, 8
or r14, rdi
or r14, r9
shl r12d, 8
or r12, rbp
or r12, rsi
xor edi, edi
cmp r15, 6
setb dil
xor edx, edx
cmp r15, 11
setae dl
shl edi, 9
shl edx, 9
xor esi, esi
cmp rbx, 6
setb sil
xor eax, eax
cmp rbx, 11
setae al
shl esi, 10
or rsi, rdi
shl eax, 10
or rax, rdx
xor edi, edi
cmp r11, 6
setb dil
xor edx, edx
cmp r11, 11
setae dl
shl edi, 11
or rdi, rsi
shl edx, 11
or rdx, rax
xor r9d, r9d
cmp r10, 6
setb r9b
xor esi, esi
cmp r10, 11
setae sil
shl r9d, 12
or r9, rdi
shl esi, 12
or rsi, rdx
xor edx, edx
mov rdi, qword ptr [rsp - 16]
cmp rdi, 6
setb dl
xor eax, eax
cmp rdi, 11
setae al
shl edx, 13
or rdx, r9
or rdx, r14
shl eax, 13
or rax, rsi
or rax, r12
xor esi, esi
mov r9, qword ptr [rsp - 8]
cmp r9, 6
setb sil
xor edi, edi
cmp r9, 11
setae dil
shl esi, 14
shl ecx, 15
or rcx, rsi
or rcx, rdx
shl edi, 14
shl r8d, 15
or r8, rdi
or r8, rax
movq xmm0, rcx
movq xmm1, r8
punpcklqdq xmm1, xmm0
movdqa xmm0, xmm1
psrlw xmm0, 1
pand xmm0, xmmword ptr [rip + .LCPI7_0]
psubb xmm1, xmm0
movdqa xmm0, xmmword ptr [rip + .LCPI7_1]
movdqa xmm2, xmm1
pand xmm2, xmm0
psrlw xmm1, 2
pand xmm1, xmm0
paddb xmm1, xmm2
movdqa xmm0, xmm1
psrlw xmm0, 4
paddb xmm0, xmm1
pand xmm0, xmmword ptr [rip + .LCPI7_2]
pxor xmm1, xmm1
psadbw xmm1, xmm0
pshufd xmm0, xmm1, 238
paddq xmm0, xmm1
shl rcx, 16
or rcx, r8
movq rax, xmm0
shl rax, 32
or rcx, rax
mov rax, rcx
pop rbx
pop r12
pop r13
pop r14
pop r15
pop rbp
ret
| Global Rank | Capsule & Domain | Hardware _rdtsc | Latency | Throughput | ELF .text | Ternary Vote | Author Aye |
|---|---|---|---|---|---|---|---|
| #332 | st_golf_b158_bitplane_swar_u64 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 |
| #1191 | 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 (THIS CAPSULE) 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 |