test(optimizer-bridge): delegate count_arm_byte_size to the production estimator (#511 follow-on, #242)#512
Merged
Conversation
…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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A small test consolidation following #511. The
#[cfg(test)]byte-counting helpercount_arm_byte_sizewas a hand-maintained mirror of the optimized-path size table — a drifted copy with its own_ => 4default and only a partial op set (a "mirror of a mirror").#511 extracted that table to
estimate_arm_byte_sizeand established the real independent check — theestimator_encoder_agreementoracle, 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
arm.iter().map(estimate_arm_byte_size).sum().reg_idxtest helper. −43 lines.Why it's safe (test-only, production codegen untouched)
estimate_arm_byte_sizeis 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 assertbytes < 30on 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_ => 2default yields counts ≤ the old proxy's_ => 4, and the explicitly-sized ops match exactly, so every assertion still holds.Verification: whole
synth-synthesissuite green (463 lib tests); no unused-symbol warnings (confirmsreg_idxhad 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