-
Notifications
You must be signed in to change notification settings - Fork 32
Cc #436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds compiler optimization infrastructure to the pcc C99 compiler, introducing the -O flag to enable optimizations. The changes include two core optimization passes (InstCombine for algebraic simplifications and constant folding, DCE for dead code elimination), comprehensive test coverage, significant refactoring of linearize.rs to improve maintainability, and cleanup of dead code warnings.
- InstCombine pass performs constant folding (2+3→5) and algebraic simplifications (x+0→x, x*1→x, etc.)
- DCE pass removes unused instructions using mark-sweep algorithm
- Optimization passes run iteratively until fixed point (max 10 iterations)
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| cc/opt.rs | New optimization pass runner infrastructure with fixed-point iteration |
| cc/instcombine.rs | New instruction combining pass with 1400+ lines of simplification rules |
| cc/dce.rs | New dead code elimination pass with mark-sweep algorithm |
| cc/tests/features/optimization.rs | Comprehensive correctness tests for optimization passes |
| cc/tests/common/mod.rs | Added helpers for running tests with optimization flags |
| cc/linearize.rs | Large refactoring extracting helper methods for better code organization |
| cc/ir.rs | Added helper methods for pseudo management (next_pseudo_id, create_const_pseudo) |
| cc/main.rs | Added -O CLI flag and optimization integration point |
| cc/target.rs | Removed unnecessary dead_code allow attributes |
| cc/arch/x86_64/lir.rs | Cleanup: removed unused helper methods, added targeted allow(dead_code) |
| cc/arch/aarch64/lir.rs | Cleanup: removed unused helper methods, added targeted allow(dead_code) |
| cc/TODO.md | Added detailed documentation for future optimization passes |
| cc/README.md | Updated feature list noting constant expression evaluation not yet implemented |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
No description provided.