Repository navigation
feat: plan 08 part B known-case folding, representation cancellation and default O1 - #39
Merged
Merged
Conversation
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
Signed-off-by: microproofs <kwhitemsg@gmail.com>
5 tasks
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.
Summary
Second part of plan 08 (plans/08-optimizer.md). This PR completes the retained scope of Chunk 7 (known-case and field simplification), adds the Chunk 8 representation cancellation, and connects the accepted pipeline to production assembly. Twenty commits, seven changesets.
Behavior change:
nash buildandnash testnow default to trace-preserving O1, so the generated UPLC changes for every project.-O0keeps the baseline lowering that builds used before.Versioning: minor bumps for
nash-ir,nash-codegen,nash-config,nash-driverandnash-cli; patch fornash-plutus. See.sampo/changesets/.Known-case folding, Chunk 7
Each rule landed as an isolated trial commit, then as an adoption commit that adds it to the shared pipeline. Malformed branch tables and unknown subjects stay unchanged in every rule.
trial bound constructor case folding,adopt bound constructor folding). The pass tracks constructor bindings and their variable aliases. Non-variable fields get one name at the construction site, and matching branches receive aliases to them. The constructor stays until ordinary cleanup proves it unused, so escaping values and repeated matches work. Strict fields stay evaluated once, in source order.trialandadopt native list case folding). Covers literalProtoListsubjects and exactly saturatedMkConsvalues.MkConsstays strict at its original position, because the builtin also checks the runtime shapes of its operands.trialandadopt literal Data case folding). SelectsDataI,DataB,DataList,DataMaporDataConstrforConstant::Datasubjects and their aliases. This is shape selection, not wrap and unwrap cancellation.Data wrapper,collection DataandConstrData case folding). Folds cases on values built by saturatedIData,BData,ListData,MapDataandConstrDatacalls.fold fields of known native constructors). Folds field accesses on known native constructors. Strict field evaluation, escaping values and malformed runtime shapes are preserved.fold known integer and byte cases). Folds known native integer and byte case subjects. Invalid tables and runtime failures are preserved.Representation cancellation, Chunk 8
nash-ir::inversepass (trial direct integer representation cancellation,cancel proven representation round trips).O1 as the default (
feat(codegen): default builds and tests to trace-preserving O1)crates/nash-codegen/src/optimizer.rsholds the production O1 pipeline. Snapshots (tests/support/optimizer.rs) andtools/optimizer-perfnow render and measure this same pipeline instead of a test-only copy.nash-configaddsOptimizationLevel(O0,O1; defaultO1) and theoptimizeproject field, which accepts0or1.nash buildandnash testaccept-O0,-O1and--optimize 0|1. The CLI option overrides the project configuration.lower. O1 useslower_with_constant_sharing. Explicitcomptimeevaluation stays on O0 with its existing budget semantics.docs/cli.md,docs/codegen.md,docs/overview.md,docs/testing.mdandSPEC.mdare updated to match.Stack safety (
fix(codegen): use heap work lists throughout assembly,fix(ir): print Core with heap work lists)ledger_contextsfixture.Tests and measurements (
refactor(test): consolidate optimizer coverage)known_case.rsholds the Boolean, constructor, list and Data suites.dead_code.rsholds the binding and recursive reachability suites.unused_params.rsis one pre-ANF suite.inverse.rsis new.tools/optimizer-perf/baseline.jsongrows from 23 to 108 rows. The 85 new rows are representation cancellation cases shared with the semantic tests.Not in this PR
Test plan
cargo fmt --all -- --checkcargo clippy --all-targets --all-features -- -D warningscargo nextest run --workspacecargo check --manifest-path tools/optimizer-perf/Cargo.toml