Skip to content

Fix reduce identity encoding for floats and integers.#186

Merged
maleadt merged 1 commit intomainfrom
tb/zigzag
Apr 9, 2026
Merged

Fix reduce identity encoding for floats and integers.#186
maleadt merged 1 commit intomainfrom
tb/zigzag

Conversation

@maleadt
Copy link
Copy Markdown
Member

@maleadt maleadt commented Apr 9, 2026

Float identities (e.g. -Inf for max, +Inf for min) were encoded as raw bit patterns via plain varint, but the bytecode format expects ap_int encoding (zigzag + varint). This caused the disassembler to show NaN instead of -Inf for maximum, and 1.5 instead of +Inf for minimum.

Fix: use encode_signed_varint! with Int128-widened bits so the zigzag shift-left never overflows.

Integer identities had a separate bug: they were zigzag-encoded, but the format stores them as raw values (no zigzag). The existing zigzag also had a UInt32 overflow on the shift-left for typemin(Int32). Fix: remove zigzag from integer identities entirely and widen to UInt128 for the varint encoder.

Float identities (e.g. -Inf for max, +Inf for min) were encoded as raw
bit patterns via plain varint, but the bytecode format expects ap_int
encoding (zigzag + varint). This caused the disassembler to show NaN
instead of -Inf for maximum, and 1.5 instead of +Inf for minimum.

Fix: use encode_signed_varint! with Int128-widened bits so the zigzag
shift-left never overflows.

Integer identities had a separate bug: they were zigzag-encoded, but the
format stores them as raw values (no zigzag). The existing zigzag also
had a UInt32 overflow on the shift-left for typemin(Int32). Fix: remove
zigzag from integer identities entirely and widen to UInt128 for the
varint encoder.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@maleadt maleadt merged commit 2c1a1a7 into main Apr 9, 2026
13 checks passed
@maleadt maleadt deleted the tb/zigzag branch April 9, 2026 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant