1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
//! Built-in SSA optimization passes.
//!
//! This module contains the standard SSA transformation passes used for
//! SSA-based code transformation. Each pass operates on SSA form and returns an
//! [`EventLog`](crate::compiler::EventLog) describing the modifications made.
//!
//! # Pipeline Phases
//!
//! The [`PassScheduler`](crate::compiler::PassScheduler) organizes passes into
//! phases that run in a specific order. Within each phase, passes run
//! iteratively until a fixpoint is reached.
//!
//! ## Phase 1: Normalization
//!
//! Cleans up code and propagates values.
//!
//! | Pass | Description |
//! |------|-------------|
//! | [`DeadCodeEliminationPass`] | Removes unreachable blocks, unused definitions, and op-less instructions |
//! | [`BlockMergingPass`] | Eliminates trampoline blocks (single-jump blocks) |
//! | [`ConstantPropagationPass`] | Propagates and folds constant values using SCCP |
//! | [`GlobalValueNumberingPass`] | Eliminates redundant computations via value numbering |
//! | [`CopyPropagationPass`] | Eliminates redundant copy operations and phi nodes |
//! | [`StrengthReductionPass`] | Replaces expensive operations with cheaper equivalents |
//! | [`AlgebraicSimplificationPass`] | Simplifies algebraic expressions (x + 0 → x, etc.) |
//! | [`ReassociationPass`] | Reorders associative operations for optimization |
//!
//! ## Phase 2: Opaque Predicate Removal
//!
//! Removes always-true/false conditions.
//!
//! | Pass | Description |
//! |------|-------------|
//! | [`OpaquePredicatePass`] | Removes always-true/false conditions, simplifies comparisons |
//!
//! ## Phase 3: CFG Recovery
//!
//! Simplifies control flow after predicate removal.
//!
//! | Pass | Description |
//! |------|-------------|
//! | [`ControlFlowSimplificationPass`] | Jump threading, branch simplification, dead tail removal |
//! | [`LoopCanonicalizationPass`] | Ensures loops have single preheaders and latches |
//! | [`JumpThreadingPass`] | Threads jumps through empty blocks |
//!
//! ## Phase 4: Inlining
//!
//! Inlines small methods and proxy functions.
//!
//! | Pass | Description |
//! |------|-------------|
//! | [`InliningPass`] | Inlines small methods and constant-returning functions |
//!
//! # Utility Passes
//!
//! These passes are available but not part of the standard pipeline:
//!
//! | Pass | Description |
//! |------|-------------|
//! | [`DeadMethodEliminationPass`] | Identifies and marks methods with no live callers |
//! | [`LicmPass`] | Loop-invariant code motion optimization |
//! | [`ValueRangePropagationPass`] | Propagates value range information |
//!
//! # Pass Execution
//!
//! Passes are executed by the [`PassScheduler`](crate::compiler::PassScheduler)
//! phase by phase. Within each phase, passes run iteratively until no more changes
//! occur. Each pass implements the [`SsaPass`](crate::compiler::SsaPass) trait.
//!
//! # Analysis Integration
//!
//! Many passes integrate with the analysis infrastructure:
//!
//! - **SCCP** ([`ConstantPropagation`](crate::analysis::ConstantPropagation)): Used by
//! constant propagation for precise value tracking
//! - **Loop Analysis** ([`LoopAnalyzer`](crate::analysis::LoopAnalyzer)): Used by
//! loop canonicalization to identify and restructure loops
// Re-export passes for public API (may not be used internally but exposed for crate users)
pub use AlgebraicSimplificationPass;
pub use BlockMergingPass;
pub use ConstantPropagationPass;
pub use ControlFlowSimplificationPass;
pub use CopyPropagationPass;
pub use ;
pub use GlobalValueNumberingPass;
pub use InliningPass;
pub use LicmPass;
pub use LoopCanonicalizationPass;
pub use ;
pub use ValueRangePropagationPass;
pub use ReassociationPass;
pub use StrengthReductionPass;
pub use JumpThreadingPass;