Skip to content

test(optimizer-bridge): delegate count_arm_byte_size to the production estimator (#511 follow-on, #242)#512

Merged
avrabe merged 1 commit into
mainfrom
test-consolidate-count-arm-byte-size
Jun 26, 2026
Merged

test(optimizer-bridge): delegate count_arm_byte_size to the production estimator (#511 follow-on, #242)#512
avrabe merged 1 commit into
mainfrom
test-consolidate-count-arm-byte-size

Conversation

@avrabe

@avrabe avrabe commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

What

A small test consolidation following #511. The #[cfg(test)] byte-counting helper count_arm_byte_size was a hand-maintained mirror of the optimized-path size table — a drifted copy with its own _ => 4 default and only a partial op set (a "mirror of a mirror").

#511 extracted that table to estimate_arm_byte_size and established the real independent check — the estimator_encoder_agreement oracle, which pins the table against the actual Thumb-2 encoder (the ground truth). With the encoder as the independent oracle, the local hand-drifted proxy is redundant.

How

  • Replace the helper body with arm.iter().map(estimate_arm_byte_size).sum().
  • Delete the now-unused reg_idx test helper. −43 lines.

Why it's safe (test-only, production codegen untouched)

estimate_arm_byte_size is unchanged — only the test helper's body is replaced, so this is frozen-by-construction (the frozen byte gate is vacuous here, as in #511).

The three test_issue94_* consumers assert bytes < 30 on post-optimization sequences (Mov/Movw/Asr — all ≤ 4 bytes in both the old proxy and the production table) plus direct structural checks (!has_runtime_shift, asr_count == 1). The production estimator's _ => 2 default yields counts the old proxy's _ => 4, and the explicitly-sized ops match exactly, so every assertion still holds.

Verification: whole synth-synthesis suite green (463 lib tests); no unused-symbol warnings (confirms reg_idx had no other consumer); fmt + clippy clean.

Scope

Test consolidation — a #511 follow-on. Not a codegen change, not a #242 north-star advance. Refs #511, #242.

🤖 Generated with Claude Code

…n estimator (#511 follow-on, #242)

The `#[cfg(test)]` byte-counting helper `count_arm_byte_size` was a
hand-maintained mirror of the optimized-path size table — a drifted copy with
its own `_ => 4` default and only a partial op set. PR #511 extracted that table
to `estimate_arm_byte_size` AND established the real independent check (the
`estimator_encoder_agreement` oracle, which pins the table against the actual
Thumb-2 encoder, the ground truth). With the encoder as the independent oracle,
the local hand-drifted proxy is redundant.

Replace its body with `arm.iter().map(estimate_arm_byte_size).sum()` and delete
the now-unused `reg_idx` test helper (−43 lines). The three byte-count tests
(`test_issue94_*`) assert `bytes < 30` on POST-optimization sequences
(Mov/Movw/Asr, all ≤4 in both tables) plus direct structural checks
(`!has_runtime_shift`, `asr_count == 1`); the production estimator's `_ => 2`
default yields counts ≤ the old proxy, so every assertion still holds.

Test-only: production codegen is untouched — `estimate_arm_byte_size` is
unchanged, only the test helper's body is replaced (frozen-by-construction).
Whole synth-synthesis suite green (463 lib tests); no unused-symbol warnings
(confirms `reg_idx` had no other consumer). Scope: test consolidation, not a
codegen change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@avrabe avrabe merged commit 92762a0 into main Jun 26, 2026
22 checks passed
@avrabe avrabe deleted the test-consolidate-count-arm-byte-size branch June 26, 2026 11:44
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