Conversation
added 26 commits
February 24, 2026 20:40
refactor: enhance BinOp and UnOp enums with Hash derive refactor: clean up copy propagation and dead block elimination logic refactor: merge blocks optimization and update imports
…tant arithmetic - Added a new module for constant propagation in the optimizer. - Integrated constant propagation into the optimization pipeline. - Updated the end-to-end test for constant arithmetic to verify constant folding, ensuring that the expression `10 + 20` is evaluated to `30` at compile time.
- Added a new module `licm.rs` that implements the Loop-Invariant Code Motion optimization. - The `eliminate` function identifies and hoists loop-invariant instructions from loop headers to preheader blocks. - Updated `mod.rs` to include the LICM module and integrate it into the optimization pipeline. - Ensured LICM is executed as part of the optimization process, following copy propagation and local common subexpression elimination.
…thmetic operations
…build enforcement at compile time
… map and cross-block propagation
- Added a new module `licm.rs` that implements the Loop-Invariant Code Motion algorithm. - The `eliminate` function identifies and hoists loop-invariant instructions from loop headers to preheader blocks. - Updated the optimizer to include the LICM pass in the optimization sequence.
Implements two optimization passes: 1. Algebraic Simplifications (algebraic.rs) - Eliminates identity patterns (x+0, x*1, x^0, etc.) - Replaces annihilators (x*0, x&0, etc.) - Simplifies self-referential operations (x==x, x^x, etc.) - Runs after constant propagation to fold constant operands 2. Branch Condition Folding (branch_fold.rs) - Detects single-use comparisons that feed directly into BranchIf - Enables codegen to inline comparisons into branch conditions - Eliminates the materialize-bool-then-test-bool pattern - Generates cleaner, more idiomatic Rust Both passes are integrated into the optimizer pipeline. Semantic correctness is prioritized over microbenchmark performance—real programs benefit more from these optimizations than synthetic fibonacci benchmarks.
The current `copy_prop` only works within a single block. In SSA form, every `Assign { dest, src }` is a global fact.
`dest` is defined exactly once and always equals `src` at the point of definition.
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.
contributing to #3