Repository navigation
[AUTOMATED] Print a compiler-merged range test as its two comparisons (option rangetest) - #1979
Merged
Merged
Conversation
…isons (option rangetest) [AUTOMATED] work in progress; tests and counters follow. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013BBaWVABMswm9QwjnywGWU
…rds, round trip [AUTOMATED] work in progress. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013BBaWVABMswm9QwjnywGWU
…rd) and option counts [AUTOMATED] kuna-rangetest.xml pins the split inside/outside/chain/returned tests, and the wrapping range, the loop condition and the ten-value stand-alone test that stay merged; kuna-rangetest-thumb.xml pins a tbb switch's bound check that keeps its one comparison under every value. Stages baseline re-recorded (5,489), settable count 245. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013BBaWVABMswm9QwjnywGWU
… chain [AUTOMATED] The first clause of an &&/|| chain prints its branch with an empty operator stack, and gets no parenthesis of its own when the chain is the second (comma-separated) clause of another chain. A split `x < A || C < x` there bound to the following `&&` (openssh vasnmprintf/strnvis). emit_block_condition now names the chain's operator while its first clause prints, and the split wraps itself when that operator binds tighter. Fixture function ctl, round-trip inputs 5/10/11 and stage assertions #13/#14 pin it (the old spelling returns 45 for ctl(9, 5), the source 5). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013BBaWVABMswm9QwjnywGWU
…ased auto [AUTOMATED] The phases.toml summary/use_when and the docs/spec/09-emission.md prose now describe the shipped auto (loop conditions and stand-alone conditions of at most 16 values stay merged; no unoptimized-code rule), the chain-head parenthesis rule and the measured corpus effect. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013BBaWVABMswm9QwjnywGWU
[AUTOMATED] xml.rs corpus count 930 (main 928 + kuna-rangetest, kuna-rangetest-thumb); docs/baseline-stages.json synthesized with mergebaseline.py (main 5,480 + 17 = 5,497). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013BBaWVABMswm9QwjnywGWU
[AUTOMATED] docs/options.md and tests/fixtures/phase_catalog.json from the merged build (245 settables, rangetest row). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_013BBaWVABMswm9QwjnywGWU
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.
Optimizing compilers fold
n < 1 || n > 30andc >= '0' && c <= '9'into one unsigned comparison of a subtraction, and kuna printed that merged form. This prints the two comparisons the test stands for, where they are exact:(the fixture is
gcc -O2 -fno-inlineofrangetest.cbeside it.)rangetest merged|split|auto, defaultauto, in a new P9 modulep9_emit/kuna_rangetest.rs.mergedis the old output.xprints in an unsigned type of the test's width or the upper bound is below that width's sign bit (casts and extensions that keep the range one interval are looked through).xprints twice, so it must be a variable or a side-effect-free in-place expression. Anything else keeps the merged form, as does the bound check before a recoveredswitch(ARMtbb/tbhprints one).autokeeps the merged form in loop conditions and in stand-aloneifconditions whose range holds at most 16 values, which are more often aswitchcase list or anisdigit-style macro in the source. Returned or assigned tests and&&/||operands split at any range size.||heading an&&chain that is itself the second clause of another chain prints in its own parentheses, since that clause gets none.On the decbench corpus 50 more optimized functions (54 gained, 4 lost) and 12 more unoptimized ones (16 gained, 4 lost) match the source's control flow exactly; most losses are
switchcase lists or anRTA_PAYLOAD(x) < nmacro whose subtraction the source wrote itself.Tests:
tests/stages/kuna-rangetest.xml(gcc -O2 x86-64, all three values: inside and outside ranges, a wrapping range, a loop condition, a ten-value test, the nested chain) andkuna-rangetest-thumb.xml(a clangtbbswitch guard that stays merged).kuna-cli/tests/rangetest_round_trip.rscompiles the printed C of every value with gcc and clang at -O0 and -O2 and compares each function with its source at the range boundaries, 0 and the type extremes. No datatest expectation moved.Model:
anthropic/claude-opus-5-5🤖 Generated with Claude Code
https://claude.ai/code/session_013BBaWVABMswm9QwjnywGWU