Skip to content

backend: use short offsets for x86-64 memory accesses - #8601

Draft
zcanann wants to merge 2 commits into
mainfrom
work/backend-compact-memory-offsets
Draft

zcanann wants to merge 2 commits into
mainfrom
work/backend-compact-memory-offsets

Conversation

@zcanann

@zcanann zcanann commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

The x86-64 compiler spends four bytes encoding the offset on ordinary pointer loads and stores, even for an access at offset zero. Reuse the target’s existing canonical x86 addressing encoder so that known offsets use zero, one, or four bytes. Loads, stores and address calculations keep their selected operation, register operands and memory effects.

An offline experiment on the full Omega-written lexer shortened 14,871 memory operands, including frame-address operations. Its executable segment shrank from 391,282 to 336,563 bytes. The production change takes the ordinary scalar subset. The comparison of compiler-emitted executables is in progress.

Slot: claimed | Task: BACKEND-COMPACT-MEMORY-OFFSETS
Acceptance: Validate exact bytes and offset boundaries, lint the affected crates, and compare full lexer output and speed with the parent compiler.
Current state: Encoder and size bounds implemented. Parent and candidate builds in progress.
Next step: Run the same Linux x86-64 source fixture through both compilers and time their emitted executables.

Claim 18edf620fd5dda200000000018e7e039.

Gate: RC-NATIVE-MATRIX | Emit compact fixed-base addresses for ordinary x86-64 loads and stores.
Spec: wiki/spec/build/machine_state_evidence.md#final-artifact-validation-placement
Proof: Exact-byte, emitted-program and timing checks | In progress.
Agent: Codex | Model: unavailable | Effort: unavailable | Tokens: unavailable in (unavailable cached), unavailable out | Steps: unavailable | Time: unavailable | Steers: unavailable

Ordinary scalar loads, stores and address calculations reserve four bytes for every known offset. Emit the shortest displacement that still addresses the selected base and byte offset, using the same encoding as existing AVX2 memory operands. RBP and R13 carry a zero displacement byte when the offset is zero.

Gate: native matrix | x86-64 scalar memory instructions carry their shortest fixed displacement
Spec: wiki/spec/build/machine_state_evidence.md#native-emission-and-backend-testing
Proof: exact bytes and altered operands for scalar forms and displacement boundaries | scoped verification in progress

Agent: Codex | Model: unavailable | Effort: unavailable | Tokens: unavailable in (unavailable cached), unavailable out | Steps: unavailable | Time: unavailable | Steers: unavailable
@zcanann zcanann added slot:claimed Draft PR slot actively owned by an agent/host track:3 Track 3: Build, packages, early eval & interpreter labels Dec 4, 2026
@zcanann zcanann added the track:4 Track 4: Native backend, ABI, targets & host runs (psi-to-native) label Dec 4, 2026 — with ChatGPT Codex Connector
@zcanann zcanann removed the track:3 Track 3: Build, packages, early eval & interpreter label Dec 4, 2026
The x86 encoding fixture could not compile after the target catalog moved its alternatives to shared slices. Iterate the slice explicitly so the fixture can compare emitted effects against the selected alternative.

Gate: native matrix | x86-64 encoder tests use the current machine-effect catalog
Spec: wiki/spec/build/machine_state_evidence.md#native-emission-and-backend-testing
Proof: strict all-target Clippy and x86-64 unit tests | fixed a test-only iterator error also present on the base revision

Agent: Codex | Model: unavailable | Effort: unavailable | Tokens: unavailable in (unavailable cached), unavailable out | Steps: unavailable | Time: unavailable | Steers: unavailable

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

slot:claimed Draft PR slot actively owned by an agent/host track:4 Track 4: Native backend, ABI, targets & host runs (psi-to-native)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant