Skip to content

VCR-RA-010: const-remat eligibility DERIVED from the stream, the hint only gates (#242) - #920

Merged
avrabe merged 3 commits into
mainfrom
lane/v055-l2-vcr-ra-010-remat
Aug 7, 2026
Merged

VCR-RA-010: const-remat eligibility DERIVED from the stream, the hint only gates (#242)#920
avrabe merged 3 commits into
mainfrom
lane/v055-l2-vcr-ra-010-remat

Conversation

@avrabe

@avrabe avrabe commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Wave-2 lane L2 of the v0.55 "scry seam" hub. Flag-off; bytes unchanged.

scry's interval domain identifies locals with a singleton interval [c, c] — provably constant values the allocator can rematerialize at the use instead of spilling and reloading. That signal was a dev-dependency test (scry_const_remat_signal.rs); this promotes it to an allocator input.

The design question

A wrong --proven-safe verdict (#901) elides a bounds guard — a memory-safety hole. A wrong const-remat verdict would re-emit the wrong value — a miscompile. So this seam follows the --wcet-hints shape, not the trusted-fact shape:

Eligibility is DERIVED from the emitted ARM stream. The hint only GATES consumption and can never create an eligible site.

plan_const_remat walks the final stream and admits a reload only where it can itself see the constant definition reaching the spill with no intervening write. MOVT over an unknown low half stays unknown; a non-constant store retires the slot; a branch/call/label closes the window.

Conservatism is reported, not hidden

Any op the walk cannot classify clears all state — a large amount of missed opportunity, deliberate for a first increment, because an op wrongly treated as harmless could hide a write to the slot and turn a stale constant into a miscompile. reloads_seen and windows_closed accompany every site count so a small number reads as narrow window, never as small opportunity. Widening the safe set op-by-op is the named follow-up.

Mutation earned its keep

Mutating the walk to treat an unknown register as the constant 0 exposed that the red-first test lying_hint_yields_no_candidates passed for the wrong reason: it offered hint value 999 while a broken walk invents 0, so the gate's value comparison did the rejecting, not the stream check. Fixed to run the gate OPEN so only the stream can reject — it now goes red under that mutation, as do two other tests.

7/7 tests, clippy clean, cargo fmt clean.

Refs #242

avrabe added 2 commits August 6, 2026 22:34
…y gates (#242)

scry's singleton-interval signal is promoted from a dev-dependency test to an
allocator input — under the rule the release is named for: verified or refused,
never believed.

A wrong --proven-safe verdict opens a memory-safety hole; a wrong const-remat
verdict re-emits the WRONG VALUE, i.e. a miscompile. So this seam follows the
--wcet-hints shape, not the trusted-fact shape: plan_const_remat walks the FINAL
ARM stream and admits a reload only where it can see the constant definition
reaching the spill with no intervening write. The hint can only SHRINK that set.

Conservative by construction and reported as such: unclassifiable ops clear all
state, and reloads_seen/windows_closed accompany every site count.

Mutation-checked — and the mutation paid for itself by exposing that the
red-first test passed for the wrong reason (the gate's value comparison was
doing the rejecting, not the stream check). Fixed; it is now potent.

7/7 tests, clippy clean, flag-off so bytes are unchanged.

Refs #242
The original push landed during the GitHub Actions major outage, so no
workflow ever started for this branch — zero checks, not failing checks.
@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.01408% with 17 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/synth-synthesis/src/const_remat.rs 94.01% 17 Missing ⚠️

📢 Thoughts on this report? Let us know!

@avrabe
avrabe merged commit 1bc4fec into main Aug 7, 2026
56 checks passed
@avrabe
avrabe deleted the lane/v055-l2-vcr-ra-010-remat branch August 7, 2026 08:56
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